Ejemplo n.º 1
0
 /// <summary>
 /// Constructor
 /// </summary>
 public ZoneCLEM()
 {
     ModelSummaryStyle = HTMLSummaryStyle.Helper;
     CLEMModel.SetPropertyDefaults(this);
 }
Ejemplo n.º 2
0
        ///<inheritdoc/>
        public string GetFullSummary(IModel model, List <string> parentControls, string htmlString, Func <string, string> markdown2Html = null)
        {
            using (StringWriter htmlWriter = new StringWriter())
            {
                htmlWriter.Write("\r\n<div class=\"holdermain\" style=\"opacity: " + ((!this.Enabled) ? "0.4" : "1") + "\">");

                CurrentAncestorList = parentControls.ToList();
                CurrentAncestorList.Add(model.GetType().Name);

                // get clock
                IModel parentSim = FindAncestor <Simulation>();

                htmlWriter.Write(CLEMModel.AddMemosToSummary(parentSim, markdown2Html));

                // create the summary box with properties of this component
                if (this is ICLEMDescriptiveSummary)
                {
                    htmlWriter.Write(this.ModelSummaryOpeningTags());
                    htmlWriter.Write(this.ModelSummaryInnerOpeningTagsBeforeSummary());
                    htmlWriter.Write(this.ModelSummary());
                    // TODO: May need to implement Adding Memos for some Models with reduced display
                    htmlWriter.Write(this.ModelSummaryInnerOpeningTags());
                    htmlWriter.Write(this.ModelSummaryInnerClosingTags());
                    htmlWriter.Write(this.ModelSummaryClosingTags());
                }

                // find random number generator
                RandomNumberGenerator rnd = parentSim.FindDescendant <RandomNumberGenerator>();
                if (rnd != null)
                {
                    htmlWriter.Write("\r\n<div class=\"clearfix defaultbanner\">");
                    htmlWriter.Write("<div class=\"namediv\">" + rnd.Name + "</div>");
                    htmlWriter.Write("<div class=\"typediv\">RandomNumberGenerator</div>");
                    htmlWriter.Write("</div>");
                    htmlWriter.Write("\r\n<div class=\"defaultcontent\">");
                    htmlWriter.Write("\r\n<div class=\"activityentry\">Random numbers are provided for this simultion.<br />");
                    if (rnd.Seed == 0)
                    {
                        htmlWriter.Write("Every run of this simulation will be different.");
                    }
                    else
                    {
                        htmlWriter.Write("Each run of this simulation will be identical using the seed <span class=\"setvalue\">" + rnd.Seed.ToString() + "</span>");
                    }
                    htmlWriter.Write("\r\n</div>");

                    htmlWriter.Write(CLEMModel.AddMemosToSummary(rnd, markdown2Html));

                    htmlWriter.Write("\r\n</div>");
                }

                Clock clk = parentSim.FindChild <Clock>();
                if (clk != null)
                {
                    htmlWriter.Write("\r\n<div class=\"clearfix defaultbanner\">");
                    htmlWriter.Write("<div class=\"namediv\">" + clk.Name + "</div>");
                    htmlWriter.Write("<div class=\"typediv\">Clock</div>");
                    htmlWriter.Write("</div>");
                    htmlWriter.Write("\r\n<div class=\"defaultcontent\">");
                    htmlWriter.Write("\r\n<div class=\"activityentry\">This simulation runs from ");
                    if (clk.StartDate == null)
                    {
                        htmlWriter.Write("<span class=\"errorlink\">[START DATE NOT SET]</span>");
                    }
                    else
                    {
                        htmlWriter.Write("<span class=\"setvalue\">" + clk.StartDate.ToShortDateString() + "</span>");
                    }
                    htmlWriter.Write(" to ");
                    if (clk.EndDate == null)
                    {
                        htmlWriter.Write("<span class=\"errorlink\">[END DATE NOT SET]</span>");
                    }
                    else
                    {
                        htmlWriter.Write("<span class=\"setvalue\">" + clk.EndDate.ToShortDateString() + "</span>");
                    }
                    htmlWriter.Write("\r\n</div>");

                    htmlWriter.Write(CLEMModel.AddMemosToSummary(clk, markdown2Html));

                    htmlWriter.Write("\r\n</div>");
                    htmlWriter.Write("\r\n</div>");
                }

                foreach (CLEMModel cm in this.FindAllChildren <CLEMModel>())
                {
                    htmlWriter.Write(cm.GetFullSummary(cm, CurrentAncestorList, "", markdown2Html));
                }

                CurrentAncestorList = null;

                return(htmlWriter.ToString());
            }
        }
Ejemplo n.º 3
0
        /// <inheritdoc/>
        public virtual string GetFullSummary(IModel model, List <string> parentControls, string htmlString, Func <string, string> markdown2Html = null)
        {
            using (StringWriter htmlWriter = new StringWriter())
            {
                if (model.GetType().IsSubclassOf(typeof(CLEMModel)))
                {
                    CLEMModel cm = model as CLEMModel;
                    cm.CurrentAncestorList = parentControls.ToList();
                    cm.CurrentAncestorList.Add(model.GetType().Name);

                    htmlWriter.Write(cm.ModelSummaryOpeningTags());

                    if (cm.Notes != null && cm.Notes != "")
                    {
                        htmlWriter.Write("\r\n<div class='memo-container'><div class='memo-head'>Notes</div>");
                        htmlWriter.Write($"\r\n<div class='memo-text'>{cm.Notes}</div></div>");
                    }

                    htmlWriter.Write(cm.ModelSummaryInnerOpeningTagsBeforeSummary());

                    htmlWriter.Write(cm.ModelSummary());

                    htmlWriter.Write(cm.ModelSummaryInnerOpeningTags());

                    bool reportMemosInPlace = false;
                    // think through the various model types that do not support memos being writen within children
                    // for example all the filters in a filter group and timers and cohorts
                    // basically anyting that does special actions with all the children
                    // if if the current model supports memos in place set reportMemosInPlace to true.

                    if (!reportMemosInPlace)
                    {
                        htmlWriter.Write(AddMemosToSummary(model, markdown2Html));
                    }

                    foreach (var item in (model).Children)
                    {
                        if (item is Memo)
                        {
                            if (reportMemosInPlace)
                            {
                                string markdownMemo = (item as Memo).Text;
                                if (markdown2Html != null)
                                {
                                    markdownMemo = markdown2Html(markdownMemo);
                                }
                                htmlWriter.Write($"<div class='memo-container'><div class='memo-head'>Memo</div><div class='memo-text'>{markdownMemo}</div></div>");
                            }
                        }
                        else
                        {
                            if (ChildrenToIgnoreInSummary() is null || !ChildrenToIgnoreInSummary().Contains(item.GetType()))
                            {
                                htmlWriter.Write(GetFullSummary(item, cm.CurrentAncestorList.ToList(), htmlString));
                            }
                        }
                    }

                    htmlWriter.Write(cm.ModelSummaryInnerClosingTags());

                    htmlWriter.Write(cm.ModelSummaryClosingTags());
                }
                return(htmlWriter.ToString());
            }
        }