Beispiel #1
0
        /// <summary>
        /// Process the current <see cref="ParameterSubscription"/>s to create any ContainedRows for value-sets
        /// </summary>
        /// <param name="processedValueSets">
        /// The <see cref="Thing"/>s for which the values need to be restored to what the user provided.
        /// </param>
        private void ProcessParameter(IReadOnlyDictionary <Guid, ProcessedValueSet> processedValueSets)
        {
            if (!this.Thing.IsOptionDependent && this.Thing.StateDependence == null)
            {
                var scalarParameterType = this.Thing.ParameterType as ScalarParameterType;
                if (scalarParameterType != null)
                {
                    var parameterValueSet = this.Thing.ValueSet.FirstOrDefault();
                    if (parameterValueSet != null)
                    {
                        ProcessedValueSet processedValueSet;
                        if (processedValueSets.TryGetValue(parameterValueSet.Iid, out processedValueSet))
                        {
                            parameterValueSet = (ParameterSubscriptionValueSet)processedValueSet.ClonedThing;
                        }

                        this.Id             = parameterValueSet.Iid.ToString();
                        this.Switch         = parameterValueSet.ValueSwitch.ToString();
                        this.ActualValue    = ParameterValueConverter.ConvertToObject(scalarParameterType, parameterValueSet.ActualValue[0]);
                        this.ComputedValue  = ParameterValueConverter.ConvertToObject(scalarParameterType, parameterValueSet.Computed[0]);
                        this.ManualValue    = ParameterValueConverter.ConvertToObject(scalarParameterType, parameterValueSet.Manual[0]);
                        this.ReferenceValue = ParameterValueConverter.ConvertToObject(scalarParameterType, parameterValueSet.Reference[0]);

                        this.Format = NumberFormat.Format(this.Thing.ParameterType, this.Thing.Scale);

                        this.ModelCode = parameterValueSet.ModelCode();
                    }

                    // do not create sub rows, the parameter row represents the only valueset that exists
                    return;
                }

                var compoundParameterType = this.Thing.ParameterType as CompoundParameterType;
                if (compoundParameterType != null)
                {
                    this.Format    = NumberFormat.Format(this.Thing.ParameterType, this.Thing.Scale);
                    this.ModelCode = this.Thing.ModelCode();

                    var parameterValueSet = this.Thing.ValueSet.FirstOrDefault();
                    if (parameterValueSet != null)
                    {
                        ProcessedValueSet processedValueSet;
                        if (processedValueSets.TryGetValue(parameterValueSet.Iid, out processedValueSet))
                        {
                            parameterValueSet = (ParameterSubscriptionValueSet)processedValueSet.ClonedThing;
                        }

                        this.Id     = parameterValueSet.Iid.ToString();
                        this.Switch = parameterValueSet.ValueSwitch.ToString();
                    }

                    // create rows for each component
                    foreach (ParameterTypeComponent component in compoundParameterType.Component)
                    {
                        var componentExcelRow = new ComponentExcelRow(component, parameterValueSet, this.Level + 1);
                        this.ContainedRows.Add(componentExcelRow);
                        componentExcelRow.Container = this;
                    }
                }

                return;
            }

            var sortedvaluesets = this.Thing.ValueSet.OrderBy(p => p, new ParameterSubscriptionValueSetComparer());

            foreach (var valueset in sortedvaluesets)
            {
                if (valueset.ActualState != null && valueset.ActualState.Kind == ActualFiniteStateKind.FORBIDDEN)
                {
                    continue;
                }

                var valueSetRow = new ParameterSubscriptionValuesetExcelRow(valueset, this.Level + 1, processedValueSets);
                this.ContainedRows.Add(valueSetRow);
                valueSetRow.Container = this;
            }
        }
Beispiel #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ParameterOverrideValueSetExcelRow"/> class.
        /// </summary>
        /// <param name="parameterOverrideValueSet">
        /// The <see cref="ParameterOverrideValueSet"/> that is represented by the current row.
        /// </param>
        /// <param name="level">
        /// the grouping level of the current row.
        /// </param>
        /// <param name="clones">
        /// The <see cref="Thing"/>s for which the values need to be restored to what the user provided.
        /// </param>
        public ParameterOverrideValueSetExcelRow(ParameterOverrideValueSet parameterOverrideValueSet, int level, IReadOnlyDictionary <Guid, ProcessedValueSet> processedValueSets)
            : base(parameterOverrideValueSet)
        {
            this.Level = level;
            this.Id    = this.Thing.Iid.ToString();

            ProcessedValueSet processedValueSet;

            if (processedValueSets.TryGetValue(parameterOverrideValueSet.Iid, out processedValueSet))
            {
                parameterOverrideValueSet = (ParameterOverrideValueSet)processedValueSet.ClonedThing;
            }

            var parameterOverride = parameterOverrideValueSet.Container as ParameterOverride;

            if (parameterOverride != null)
            {
                this.ParameterType = parameterOverride.ParameterType;

                if (this.ParameterType is CompoundParameterType)
                {
                    this.Type = ParameterSheetConstants.POVSCD;
                }
                else if (this.ParameterType is SampledFunctionParameterType)
                {
                    this.Type = ParameterSheetConstants.SFPOVS;
                }
                else
                {
                    this.Type = ParameterSheetConstants.POVS;
                }

                var spaces = new string(' ', 3 * Math.Abs(level - 1));
                this.ParameterTypeShortName = parameterOverride.Scale == null ? parameterOverride.ParameterType.ShortName : string.Format("{0} [{1}]", parameterOverride.ParameterType.ShortName, parameterOverride.Scale.ShortName);
                var optionPart = parameterOverrideValueSet.ActualOption != null ? parameterOverrideValueSet.ActualOption.ShortName : string.Empty;
                var statePart  = parameterOverrideValueSet.ActualState != null ? parameterOverrideValueSet.ActualState.ShortName : string.Empty;

                this.Name      = string.Format("{0}{1}\\{2}\\{3}", spaces, parameterOverride.ParameterType.Name, optionPart, statePart);
                this.ShortName = string.Format("{0}\\{1}\\{2}", parameterOverride.ParameterType.ShortName, optionPart, statePart);
                this.Format    = NumberFormat.Format(parameterOverride.ParameterType, parameterOverride.Scale);
                this.Switch    = parameterOverrideValueSet.ValueSwitch.ToString();

                this.ModelCode = parameterOverrideValueSet.ModelCode();

                var sampledFunctionParameterType = this.ParameterType as SampledFunctionParameterType;
                if (sampledFunctionParameterType != null)
                {
                    this.Id             = parameterOverrideValueSet.Iid.ToString();
                    this.Switch         = parameterOverrideValueSet.ValueSwitch.ToString();
                    this.ActualValue    = "N/A";
                    this.ComputedValue  = "N/A";
                    this.ManualValue    = "N/A";
                    this.ReferenceValue = "N/A";
                    this.Formula        = string.Empty;

                    this.Format = NumberFormat.Format(this.ParameterType, null);

                    this.ModelCode = parameterOverrideValueSet.ModelCode();

                    // do not create sub rows, the parameter row represents the only valueset that exists
                    return;
                }

                var compoundParameterType = parameterOverride.ParameterType as CompoundParameterType;
                if (compoundParameterType == null)
                {
                    this.ActualValue    = ParameterValueConverter.ConvertToObject(this.ParameterType, parameterOverrideValueSet.ActualValue[0]);
                    this.ComputedValue  = ParameterValueConverter.ConvertToObject(this.ParameterType, parameterOverrideValueSet.Computed[0]);
                    this.ManualValue    = ParameterValueConverter.ConvertToObject(this.ParameterType, parameterOverrideValueSet.Manual[0]);
                    this.ReferenceValue = ParameterValueConverter.ConvertToObject(this.ParameterType, parameterOverrideValueSet.Reference[0]);
                    this.Formula        = parameterOverrideValueSet.Formula[0];
                }
                else
                {
                    // create rows for each component
                    foreach (ParameterTypeComponent component in compoundParameterType.Component)
                    {
                        var componentExcelRow = new ComponentExcelRow(component, parameterOverrideValueSet, this.Level + 1);
                        this.ContainedRows.Add(componentExcelRow);
                        componentExcelRow.Container = this;
                    }
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ParameterSubscriptionValuesetExcelRow"/> class.
        /// </summary>
        /// <param name="parameterSubscriptionValueSet">
        /// The <see cref="ParameterSubscriptionValueSet"/> that is represented by the row.
        /// </param>
        /// <param name="level">
        /// the grouping level of the current row.
        /// </param>
        /// <param name="processedValueSets">
        /// The <see cref="Thing"/>s for which the values need to be restored to what the user provided.
        /// </param>
        public ParameterSubscriptionValuesetExcelRow(ParameterSubscriptionValueSet parameterSubscriptionValueSet, int level, IReadOnlyDictionary <Guid, ProcessedValueSet> processedValueSets)
            : base(parameterSubscriptionValueSet)
        {
            this.Level = level;
            this.Id    = this.Thing.Iid.ToString();

            ProcessedValueSet processedValueSet;

            if (processedValueSets.TryGetValue(parameterSubscriptionValueSet.Iid, out processedValueSet))
            {
                parameterSubscriptionValueSet = (ParameterSubscriptionValueSet)processedValueSet.ClonedThing;
            }

            var parameterSubscription = parameterSubscriptionValueSet.Container as ParameterSubscription;

            if (parameterSubscription != null)
            {
                this.ParameterType = parameterSubscription.ParameterType;

                if (this.ParameterType is CompoundParameterType)
                {
                    this.Type = ParameterSheetConstants.PSVSCD;
                }
                else
                {
                    this.Type = ParameterSheetConstants.PSVS;
                }

                var spaces = new string(' ', 3 * Math.Abs(level - 1));

                this.ParameterTypeShortName = parameterSubscription.Scale == null ? parameterSubscription.ParameterType.ShortName : string.Format("{0} [{1}]", parameterSubscription.ParameterType.ShortName, parameterSubscription.Scale.ShortName);
                var optionPart = parameterSubscriptionValueSet.ActualOption != null ? parameterSubscriptionValueSet.ActualOption.ShortName : string.Empty;
                var statePart  = parameterSubscriptionValueSet.ActualState != null ? parameterSubscriptionValueSet.ActualState.ShortName : string.Empty;

                this.Name      = string.Format("{0}{1}\\{2}\\{3}", spaces, parameterSubscription.ParameterType.Name, optionPart, statePart);
                this.ShortName = string.Format("{0}\\{1}\\{2}", parameterSubscription.ParameterType.ShortName, optionPart, statePart);
                this.Format    = NumberFormat.Format(parameterSubscription.ParameterType, parameterSubscription.Scale);
                this.Switch    = parameterSubscriptionValueSet.ValueSwitch.ToString();
                this.Owner     = string.Format("--{0}", PropertyHelper.ComputeContainerOwnerShortName(parameterSubscription));

                this.ModelCode = parameterSubscriptionValueSet.ModelCode();

                var compoundParameterType = parameterSubscription.ParameterType as CompoundParameterType;
                if (compoundParameterType == null)
                {
                    this.ActualValue    = ParameterValueConverter.ConvertToObject(this.ParameterType, parameterSubscriptionValueSet.ActualValue[0]);
                    this.ComputedValue  = ParameterValueConverter.ConvertToObject(this.ParameterType, parameterSubscriptionValueSet.Computed[0]);
                    this.ManualValue    = ParameterValueConverter.ConvertToObject(this.ParameterType, parameterSubscriptionValueSet.Manual[0]);
                    this.ReferenceValue = ParameterValueConverter.ConvertToObject(this.ParameterType, parameterSubscriptionValueSet.Reference[0]);
                    this.Formula        = string.Empty;
                }
                else
                {
                    // create rows for each component
                    foreach (ParameterTypeComponent component in compoundParameterType.Component)
                    {
                        var componentExcelRow = new ComponentExcelRow(component, parameterSubscriptionValueSet, this.Level + 1);
                        this.ContainedRows.Add(componentExcelRow);
                        componentExcelRow.Container = this;
                    }
                }
            }
        }