コード例 #1
0
        /// <summary>
        /// Initializes the column index associated to the given <paramref name="parameterValueSet"/>
        /// </summary>
        /// <param name="parameterValueSet">
        /// The given <see cref="ParameterValueSet"/>
        /// </param>
        private void SetContentColumnIndex(ParameterValueSetBase parameterValueSet)
        {
            var parameter = (Parameter)parameterValueSet.Container;

            if (parameter.ParameterType is CompoundParameterType compoundParameterType)
            {
                // NOTE: call Select so that 'component' has a proper type, not object
                foreach (var component in compoundParameterType.Component.Select(x => x))
                {
                    this.SetContentColumnIndex((
                                                   parameter.ParameterType.ShortName,
                                                   component.ParameterType.ShortName,
                                                   component.Scale?.ShortName ?? "",
                                                   parameterValueSet.ActualOption?.ShortName ?? "",
                                                   parameter.StateDependence?.ShortName ?? "",
                                                   parameterValueSet.ActualState?.ShortName ?? ""),
                                               -1);
                }
            }
            else
            {
                this.SetContentColumnIndex((
                                               parameter.ParameterType.ShortName,
                                               "",
                                               parameter.Scale?.ShortName ?? "",
                                               parameterValueSet.ActualOption?.ShortName ?? "",
                                               parameter.StateDependence?.ShortName ?? "",
                                               parameterValueSet.ActualState?.ShortName ?? ""),
                                           -1);
            }
        }
コード例 #2
0
        /// <summary>
        /// Set a ValueSet for a compound ParameterType with 2 components
        /// </summary>
        /// <param name="valueset">The <see cref="ParameterValueSetBase"/> to set</param>
        private void SetCompoundValueSet(ParameterValueSetBase valueset)
        {
            var manualSet = new ValueArray <string>(new List <string> {
                "manual1", "manual2"
            });
            var referenceSet = new ValueArray <string>(new List <string> {
                "ref1", "ref2"
            });
            var computedSet = new ValueArray <string>(new List <string> {
                "computed1", "computed2"
            });
            var publishedSet = new ValueArray <string>(new List <string> {
                "published1", "published2"
            });
            var formulaSet = new ValueArray <string>(new List <string> {
                "formula1", "formula2"
            });

            valueset.Manual      = manualSet;
            valueset.Reference   = referenceSet;
            valueset.Computed    = computedSet;
            valueset.Published   = publishedSet;
            valueset.Formula     = formulaSet;
            valueset.ValueSwitch = ParameterSwitchKind.REFERENCE;
        }
コード例 #3
0
        /// <summary>
        /// Add the value set update listener for this row
        /// </summary>
        /// <param name="thing">The <see cref="ParameterValueSetBase"/> which updates need to be handled in this row</param>
        private void AddValueSetListener(ParameterValueSetBase thing)
        {
            if (this.isValueSetListenerInitialized)
            {
                return;
            }

            Func <ObjectChangedEvent, bool> discriminator = objectChange => objectChange.EventKind == EventKind.Updated && objectChange.ChangedThing.RevisionNumber > this.RevisionNumber;
            Action <ObjectChangedEvent>     action        = x => this.SetValues();

            if (this.AllowMessageBusSubscriptions)
            {
                var listener = CDPMessageBus.Current.Listen <ObjectChangedEvent>(thing)
                               .Where(discriminator)
                               .ObserveOn(RxApp.MainThreadScheduler)
                               .Subscribe(action);

                this.Disposables.Add(listener);
            }
            else
            {
                var parameterValueSetBaseObserver = CDPMessageBus.Current.Listen <ObjectChangedEvent>(typeof(ParameterValueSetBase));
                this.Disposables.Add(
                    this.MessageBusHandler.GetHandler <ObjectChangedEvent>().RegisterEventHandler(parameterValueSetBaseObserver, new ObjectChangedMessageBusEventHandlerSubscription(thing, discriminator, action)));
            }

            this.isValueSetListenerInitialized = true;
        }
コード例 #4
0
        /// <summary>
        /// Update a <see cref="ParameterValueSetBase"/> that may or may not be option and/or state dependent
        /// </summary>
        /// <param name="valueSet">
        /// The <see cref="ParameterValueSetBase"/> to update
        /// </param>
        public void UpdateValueSets(ParameterValueSetBase valueSet)
        {
            var actualOption = valueSet.ActualOption;
            var actualState  = valueSet.ActualState;

            if (actualOption != null)
            {
                var optionRow = this.ContainedRows.Cast <ParameterOptionRowViewModel>().Single(x => x.ActualOption == actualOption);
                if (actualState != null)
                {
                    var actualStateRow = optionRow.ContainedRows.Cast <ParameterStateRowViewModel>().Single(x => x.ActualState == actualState);
                    this.UpdateScalarOrCompoundValueSet(valueSet, actualStateRow);
                }
                else
                {
                    this.UpdateScalarOrCompoundValueSet(valueSet, optionRow);
                }
            }
            else
            {
                if (actualState != null)
                {
                    var actualStateRow = this.ContainedRows.Cast <ParameterStateRowViewModel>().Single(x => x.ActualState == actualState);
                    this.UpdateScalarOrCompoundValueSet(valueSet, actualStateRow);
                }
                else
                {
                    this.UpdateScalarOrCompoundValueSet(valueSet);
                }
            }
        }
        /// <summary>
        /// Set the value for this row from the <see cref="ParameterOrOverrideBase"/> and the associated <see cref="ParameterValueSetBase"/>
        /// </summary>
        /// <param name="parameterOrOveride">The <see cref="ParameterOrOverrideBase"/></param>
        /// <param name="valueSet">The <see cref="ParameterValueSetBase"/></param>
        /// <param name="index">The Index of the Value to get</param>
        public void SetScalarValue(ParameterOrOverrideBase parameterOrOveride, ParameterValueSetBase valueSet, int?index = null)
        {
            this.Value = index.HasValue && valueSet.Published.Count() > index
                ? valueSet.Published[index.Value]
                : valueSet.Published.FirstOrDefault();

            var actualValue = index.HasValue && valueSet.Published.Count() > index
                ? valueSet.ActualValue[index.Value]
                : valueSet.ActualValue.FirstOrDefault();

            // propagate values to aid in modelcode updates
            this.valueSetIndex = index;
            this.valueSet      = valueSet;

            this.UpdateModelCode();

            this.Switch = valueSet.ValueSwitch;
            if (this.Value == null || actualValue == null)
            {
                return;
            }

            if (this.Value != actualValue)
            {
                this.IsPublishable = true;
            }

            if (this.Scale != null)
            {
                this.Value += " [" + this.Scale.ShortName + "]";
            }
        }
        /// <summary>
        /// Set the value for this row from the associated <see cref="ParameterValueSetBase"/>
        /// </summary>
        /// <param name="valueSet">The <see cref="ParameterValueSetBase"/></param>
        public void SetScalarValue(ParameterValueSetBase valueSet)
        {
            // perform checks to see if this is indeed a scalar value
            if (valueSet.Published.Count() > 1)
            {
                logger.Warn("The value set of Parameter or override {0} is marked as Scalar, yet has multiple values.", this.Thing.Iid);
            }

            this.Value = valueSet.Published.FirstOrDefault();

            // handle zero values returned
            if (this.Value == null)
            {
                logger.Warn("The value set of Parameter or override {0} is marked as Scalar, yet has no values.", this.Thing.Iid);
                this.Value = "-";
            }

            if (this.Thing.Scale != null)
            {
                this.Value += " [" + this.Thing.Scale.ShortName + "]";
            }

            this.Switch = valueSet.ValueSwitch;

            // propagate values to aid in modelcode updates
            this.valueSet = valueSet;

            this.UpdateModelCode();
        }
コード例 #7
0
        /// <summary>
        /// Set a ValueSet for a scalar ParameterType
        /// </summary>
        /// <param name="valueset">The <see cref="ParameterValueSetBase"/> to set</param>
        private void SetScalarValueSet(ParameterValueSetBase valueset)
        {
            var manualSet = new ValueArray <string>(new List <string> {
                "-"
            });
            var referenceSet = new ValueArray <string>(new List <string> {
                "-"
            });
            var computedSet = new ValueArray <string>(new List <string> {
                "-"
            });
            var publishedSet = new ValueArray <string>(new List <string> {
                "-"
            });
            var formulaSet = new ValueArray <string>(new List <string> {
                "-"
            });

            valueset.Manual      = manualSet;
            valueset.Reference   = referenceSet;
            valueset.Computed    = computedSet;
            valueset.Published   = publishedSet;
            valueset.Formula     = formulaSet;
            valueset.ValueSwitch = ParameterSwitchKind.REFERENCE;
        }
 /// <summary>
 /// Set the values of the <see cref="Dto.ParameterValueSetBase"/> with the values of a original <see cref="ParameterValueSetBase"/>
 /// </summary>
 /// <param name="valueSet">The <see cref="Dto.ParameterValueSetBase"/></param>
 /// <param name="originalValueSet">The <see cref="ParameterValueSetBase"/></param>
 private void SetValueSetValues(Dto.ParameterValueSetBase valueSet, ParameterValueSetBase originalValueSet)
 {
     valueSet.Manual      = originalValueSet.Manual;
     valueSet.Reference   = originalValueSet.Reference;
     valueSet.ValueSwitch = originalValueSet.ValueSwitch;
     valueSet.Formula     = originalValueSet.Formula;
     valueSet.Computed    = originalValueSet.Computed;
 }
コード例 #9
0
        /// <summary>
        /// Generate a cell name for the given <paramref name="parameterValueSetBase"/>. Note that non-<see cref="ParameterOverrideValueSet"/>s
        /// displayed on <see cref="ElementUsage"/> <paramref name="rowThing"/>s will not have a name, as they are not interactible.
        /// </summary>
        /// <param name="rowThing">
        /// The <see cref="Thing"/> of the associated row.
        /// </param>
        /// <param name="parameterValueSetBase">
        ///  The <see cref="ParameterValueSetBase"/> for which to generate the cell name.
        /// </param>
        /// <param name="componentIndex">
        /// Optional, the <see cref="ParameterTypeComponent"/> index.
        /// </param>
        /// <returns>
        /// The cell name.
        /// </returns>
        private static string GetCellName(Thing rowThing, ParameterValueSetBase parameterValueSetBase, int?componentIndex = null)
        {
            // non-overrides displayed on EUs are not interactible
            if (rowThing is ElementUsage && parameterValueSetBase is ParameterValueSet)
            {
                return(null);
            }

            return($"{CrossviewSheetConstants.CrossviewSheetName}_{parameterValueSetBase.ModelCode(componentIndex)}");
        }
コード例 #10
0
 /// <summary>
 /// Update a <see cref="ParameterValueSetBase"/> with the values from the current row or the passed <see cref="ParameterValueBaseRowViewModel"/>
 /// </summary>
 /// <param name="valueSet">The <see cref="ParameterValueSetBase"/> to update</param>
 /// <param name="row">The <see cref="ParameterValueBaseRowViewModel"/> containing the information, or if null the current row</param>
 private void UpdateScalarOrCompoundValueSet(ParameterValueSetBase valueSet, ParameterValueBaseRowViewModel row = null)
 {
     if (this.isCompoundType)
     {
         this.UpdateCompoundValueSet(valueSet, row);
     }
     else
     {
         this.UpdateScalarValueSet(valueSet, row);
     }
 }
コード例 #11
0
        public void TestGetOwner2()
        {
            var container = new ParameterOverride();

            container.Owner            = new DomainOfExpertise();
            this.parameterValueSetBase = new ParameterOverrideValueSet();

            container.ValueSet.Add(this.parameterValueSetBase as ParameterOverrideValueSet);

            Assert.IsTrue(ReferenceEquals(container.Owner, this.parameterValueSetBase.Owner));
        }
コード例 #12
0
        /// <summary>
        /// Update the clone of the <see cref="ParameterValueSetBase"/> represented by this row
        /// </summary>
        /// <param name="valueset">The clone of the <see cref="ParameterValueSetBase"/> to update</param>
        private void UpdateValueSet(ParameterValueSetBase valueset)
        {
            if (this.ContainerViewModel is ParameterValueBaseRowViewModel parameterValueBaseRow)
            {
                parameterValueBaseRow.UpdateValueSet(valueset);
            }

            if (this.ContainerViewModel is ParameterOrOverrideBaseRowViewModel parameterOrOverrideRow)
            {
                parameterOrOverrideRow.UpdateValueSets(valueset);
            }
        }
コード例 #13
0
        private void SetValueSet(ParameterValueSetBase param, string value)
        {
            var stringlist = new List <string> {
                value
            };

            param.Manual      = new CDP4Common.Types.ValueArray <string>(stringlist);
            param.Reference   = new CDP4Common.Types.ValueArray <string>(stringlist);
            param.Computed    = new CDP4Common.Types.ValueArray <string>(stringlist);
            param.Formula     = new CDP4Common.Types.ValueArray <string>(stringlist);
            param.ValueSwitch = ParameterSwitchKind.MANUAL;
        }
コード例 #14
0
        public void Setup()
        {
            this.booleanParameterType = new BooleanParameterType(Guid.NewGuid(), null, null)
            {
                ShortName = "bool"
            };

            this.elementDefinition1 = new ElementDefinition(Guid.NewGuid(), null, null)
            {
                ShortName = "Sat"
            };
            this.elementDefinition2 = new ElementDefinition(Guid.NewGuid(), null, null)
            {
                ShortName = "Bat"
            };
            this.elementUsage = new ElementUsage(Guid.NewGuid(), null, null)
            {
                ShortName         = "battery_1",
                ElementDefinition = this.elementDefinition2
            };
            this.elementDefinition1.ContainedElement.Add(this.elementUsage);
            this.parameter = new Parameter(Guid.NewGuid(), null, null);
            this.parameter.ParameterType = this.booleanParameterType;
            this.elementDefinition2.Parameter.Add(this.parameter);
            this.parameterOverride           = new ParameterOverride(Guid.NewGuid(), null, null);
            this.parameterOverride.Parameter = this.parameter;

            this.parameterSubscriptionValueSet   = new ParameterSubscriptionValueSet();
            this.parameterValueSetBase           = new ParameterValueSet();
            this.parameterValueSetBase.Published = new ValueArray <string>(new List <string> {
                "computed"
            });
            this.parameterValueSetBase.Computed = new ValueArray <string>(new List <string> {
                "computed"
            });
            this.parameterValueSetBase.Reference = new ValueArray <string>(new List <string> {
                "ref"
            });
            this.parameterValueSetBase.ActualState  = new ActualFiniteState();
            this.parameterValueSetBase.ActualOption = new Option();

            this.parameterSubscriptionValueSet.SubscribedValueSet = this.parameterValueSetBase;
            this.parameterSubscriptionValueSet.Manual             = new ValueArray <string>(new List <string> {
                "manual"
            });

            this.parameterSubscription = new ParameterSubscription();
            this.parameterSubscription.ValueSet.Add(this.parameterSubscriptionValueSet);
            this.parameterSubscription.Owner = new DomainOfExpertise();
        }
コード例 #15
0
        /// <summary>
        /// Add the value set update listener for this row
        /// </summary>
        /// <param name="thing">The <see cref="ParameterValueSetBase"/> which updates need to be handled in this row</param>
        private void AddValueSetListener(ParameterValueSetBase thing)
        {
            if (this.isValueSetListenerInitialized)
            {
                return;
            }

            var listener = CDPMessageBus.Current.Listen <ObjectChangedEvent>(thing)
                           .Where(objectChange => objectChange.EventKind == EventKind.Updated && objectChange.ChangedThing.RevisionNumber > this.RevisionNumber)
                           .ObserveOn(RxApp.MainThreadScheduler)
                           .Subscribe(_ => this.SetValues());

            this.Disposables.Add(listener);
            this.isValueSetListenerInitialized = true;
        }
コード例 #16
0
        /// <summary>
        /// Update the clone of the <see cref="ParameterValueSetBase"/> represented by this row
        /// </summary>
        /// <param name="valueset">The clone of the <see cref="ParameterValueSetBase"/> to update</param>
        private void UpdateValueSet(ParameterValueSetBase valueset)
        {
            var parameterValueBaseRow = this.ContainerViewModel as ParameterValueBaseRowViewModel;

            if (parameterValueBaseRow != null)
            {
                parameterValueBaseRow.UpdateValueSet(valueset);
            }

            var parameterOrOverrideRow = this.ContainerViewModel as ParameterOrOverrideBaseRowViewModel;

            if (parameterOrOverrideRow != null)
            {
                parameterOrOverrideRow.UpdateValueSets(valueset);
            }
        }
        /// <summary>
        /// Process the <see cref="ParameterValueSet"/> .
        /// </summary>
        /// <param name="parameterValueSet">
        /// The <see cref="ParameterValueSetBase"/> to be processed.
        /// </param>
        /// <param name="parameterOrOverrideBase">
        /// The <see cref="ParameterOrOverrideBase"/> the <see cref="ParameterValueSetBase"/ belongs to.
        /// </param>
        /// <param name="componentIndex">
        /// The index of the <see cref="ParameterTypeComponent"/>.
        /// </param>
        /// <param name="computedValue">
        /// The manual value of the <see cref="ParameterValueSet"/>.
        /// </param>
        /// <param name="processedValueSets">
        /// A <see cref="Dictionary{Guid,ProcessedValueSet}"/> of ProcessedValueSe that capture the updated <see cref="Thing"/>s with its value validation result
        /// </param>
        /// <param name="provider">
        /// The <see cref="IFormatProvider"/> used to validate.
        /// </param>
        /// <param name="validationErrorText">
        /// <see cref="String"/> that holds the validation error text.
        /// </param>
        /// <returns>
        /// The added or changed <see cref="ProcessedValueSet"/>
        /// </returns>
        private ProcessedValueSet ProcessValueSet(ParameterValueSetBase parameterValueSet, ParameterOrOverrideBase parameterOrOverrideBase, int componentIndex, string computedValue, ref Dictionary <Guid, ProcessedValueSet> processedValueSets, IFormatProvider provider, out string validationErrorText)
        {
            var validationResult = ValidationResultKind.InConclusive;

            var switchKind       = parameterValueSet.ValueSwitch;
            var measurementScale = parameterOrOverrideBase.Scale;
            var parameterType    = parameterOrOverrideBase.ParameterType;

            validationErrorText = string.Empty;

            if (parameterType != null)
            {
                if (ValueSetConverter.TryParseDouble(computedValue, parameterType, out var convertedComputedValue))
                {
                    computedValue = convertedComputedValue.ToString(CultureInfo.InvariantCulture);
                }

                computedValue = computedValue?.ToValueSetObject(parameterType).ToValueSetString(parameterType) ?? parameterValueSet.Computed[componentIndex];

                var validManualValue = parameterType.Validate(computedValue, measurementScale, provider);

                if (validManualValue.ResultKind > validationResult)
                {
                    validationResult    = validManualValue.ResultKind;
                    validationErrorText = validManualValue.Message;
                }
            }

            var valueSetExists = processedValueSets.TryGetValue(parameterValueSet.Iid, out var processedValueSet);

            if (!valueSetExists)
            {
                processedValueSet = new ProcessedValueSet(parameterValueSet, validationResult);
            }

            if (processedValueSet.IsDirty(componentIndex, parameterType, switchKind, parameterValueSet.Manual[componentIndex], computedValue, parameterValueSet.Reference[componentIndex], computedValue, out var valueSetValues))
            {
                processedValueSet.UpdateClone(valueSetValues);

                if (!valueSetExists)
                {
                    processedValueSets.Add(parameterValueSet.Iid, processedValueSet);
                }
            }

            return(processedValueSet);
        }
コード例 #18
0
        /// <summary>
        /// Check if the current <see cref="ParameterValueSetBase"/> is publishable (the published and actual values are different)
        /// </summary>
        /// <param name="valueset">The <see cref="ParameterValueSetBase"/></param>
        /// <returns>True if the Published value is different from the Actual value</returns>
        private bool CheckValuesPublishabledStatus(ParameterValueSetBase valueset)
        {
            if (valueset == null)
            {
                return(false);
            }

            for (var i = 0; i < valueset.Published.Count(); i++)
            {
                if (valueset.Published[i] != valueset.ActualValue[i])
                {
                    return(true);
                }
            }

            return(false);
        }
コード例 #19
0
        /// <summary>
        /// Update value-set for a compound parameter.
        /// </summary>
        /// <param name="valueSet">The value set to update</param>
        /// <param name="row">The value row containing the information. If null the data is retrieved from the current row.</param>
        /// <remarks>
        /// If <paramref name="row"/> is null, it means the parameter is not compound, not option dependent and not state dependent.
        /// </remarks>
        private void UpdateCompoundValueSet(ParameterValueSetBase valueSet, ParameterValueBaseRowViewModel row = null)
        {
            var componentRows = (row == null)
                ? this.ContainedRows.Cast <ParameterComponentValueRowViewModel>().ToList()
                : row.ContainedRows.Cast <ParameterComponentValueRowViewModel>().ToList();

            valueSet.Computed    = new ValueArray <string>(new string[componentRows.Count]);
            valueSet.Manual      = new ValueArray <string>(new string[componentRows.Count]);
            valueSet.Reference   = new ValueArray <string>(new string[componentRows.Count]);
            valueSet.ValueSwitch = componentRows[0].Switch.Value; // all the switches should have the same value
            for (var i = 0; i < componentRows.Count; i++)
            {
                valueSet.Computed[i]  = componentRows[i].Computed;
                valueSet.Manual[i]    = componentRows[i].Manual.ToValueSetString(this.ParameterType);
                valueSet.Reference[i] = componentRows[i].Reference.ToValueSetString(this.ParameterType);
            }
        }
コード例 #20
0
 /// <summary>
 /// Sets the values of the <see cref="ParameterValueSetBase"/>.
 /// </summary>
 /// <param name="valueSet">
 /// The valueSet.
 /// </param>
 private void SetValueSetValues(ParameterValueSetBase valueSet)
 {
     this.Value          = valueSet.ActualValue.Any() ? valueSet.ActualValue.First() : "-";
     this.ScaleShortName = this.Thing.Scale == null ? "-" : this.Thing.Scale.ShortName;
     this.Switch         = valueSet.ValueSwitch;
     this.Formula        = valueSet.Formula.Any() ? valueSet.Formula.First() : "-";
     this.Computed       = valueSet.Computed.Any() ? valueSet.Computed.First() : "-";
     this.Manual         = valueSet.Manual.Any()
                       ? valueSet.Manual.First().ToValueSetObject(this.ParameterType)
                       : ValueSetConverter.DefaultObject(this.ParameterType);
     this.Reference = valueSet.Reference.Any()
                          ? valueSet.Reference.First().ToValueSetObject(this.ParameterType)
                          : ValueSetConverter.DefaultObject(this.ParameterType);
     this.State     = valueSet.ActualState == null ? "-" : valueSet.ActualState.ShortName;
     this.Option    = valueSet.ActualOption;
     this.Published = valueSet.Published.Any() ? valueSet.Published.First() : "-";
 }
コード例 #21
0
 /// <summary>
 /// Update value-set for a not-compound parameter.
 /// </summary>
 /// <param name="valueSet">The value set to update</param>
 /// <param name="row">The value row containing the information. If null the data is retrieved from the current row.</param>
 /// <remarks>
 /// If <paramref name="row"/> is null, it means the parameter is not compound, not option dependent and not state dependent.
 /// </remarks>
 private void UpdateScalarValueSet(ParameterValueSetBase valueSet, ParameterValueBaseRowViewModel row = null)
 {
     valueSet.ValueSwitch = row == null ? this.Switch.Value : row.Switch.Value;
     valueSet.Computed    = row == null ? new ValueArray <string>(new List <string> {
         this.Computed
     }) : new ValueArray <string>(new List <string> {
         row.Computed
     });
     valueSet.Manual = row == null ? new ValueArray <string>(new List <string> {
         this.Manual.ToValueSetString(this.ParameterType)
     }) : new ValueArray <string>(new List <string> {
         row.Manual.ToValueSetString(this.ParameterType)
     });
     valueSet.Reference = row == null ? new ValueArray <string>(new List <string> {
         this.Reference.ToValueSetString(this.ParameterType)
     }) : new ValueArray <string>(new List <string> {
         ValueSetConverter.ToValueSetString(row.Reference, this.ParameterType)
     });
 }
コード例 #22
0
        /// <summary>
        /// The method that performs the necessary calculations and and returns the <see cref="RequirementStateOfCompliance"/> based on those calculations
        /// </summary>
        /// <param name="valueSet">The <see cref="ParameterValueSetBase"/> that is used for calculations</param>
        /// <param name="relationalExpression">The <see cref="RelationalExpression"/> that is used for calculations</param>
        /// <returns><see cref="RequirementStateOfCompliance"/> based on the calculations</returns>
        public RequirementStateOfCompliance Calculate(ParameterValueSetBase valueSet, RelationalExpression relationalExpression)
        {
            var comparer = this.GetValueSetComparer(relationalExpression);

            switch (relationalExpression.RelationalOperator)
            {
            case RelationalOperatorKind.EQ:
                return(comparer.Compare(valueSet.ActualValue, relationalExpression.Value) == 0
                        ? RequirementStateOfCompliance.Pass
                        : RequirementStateOfCompliance.Failed);

            case RelationalOperatorKind.GE:
                return(comparer.Compare(valueSet.ActualValue, relationalExpression.Value) >= 0
                        ? RequirementStateOfCompliance.Pass
                        : RequirementStateOfCompliance.Failed);

            case RelationalOperatorKind.GT:
                return(comparer.Compare(valueSet.ActualValue, relationalExpression.Value) > 0
                        ? RequirementStateOfCompliance.Pass
                        : RequirementStateOfCompliance.Failed);

            case RelationalOperatorKind.LE:
                return(comparer.Compare(valueSet.ActualValue, relationalExpression.Value) <= 0
                        ? RequirementStateOfCompliance.Pass
                        : RequirementStateOfCompliance.Failed);

            case RelationalOperatorKind.LT:
                return(comparer.Compare(valueSet.ActualValue, relationalExpression.Value) < 0
                        ? RequirementStateOfCompliance.Pass
                        : RequirementStateOfCompliance.Failed);

            case RelationalOperatorKind.NE:
                return(comparer.Compare(valueSet.ActualValue, relationalExpression.Value) != 0
                        ? RequirementStateOfCompliance.Pass
                        : RequirementStateOfCompliance.Failed);

            default: throw new ArgumentOutOfRangeException(nameof(relationalExpression.RelationalOperator), relationalExpression.RelationalOperator, $"Unknown {nameof(relationalExpression.RelationalOperator)}");
            }
        }
コード例 #23
0
        /// <summary>
        /// Gets the column index associated to the given <paramref name="parameterValueSetBase"/>
        /// </summary>
        /// <param name="parameterValueSetBase">
        /// The given <see cref="ParameterValueSetBase"/>
        /// </param>
        /// <param name="component">
        /// The given <see cref="ParameterTypeComponent"/>
        /// </param>
        /// <returns>
        /// The column index
        /// </returns>
        internal int GetContentColumnIndex(ParameterValueSetBase parameterValueSetBase, ParameterTypeComponent component = null)
        {
            var parameterOrOverrideBase = (ParameterOrOverrideBase)parameterValueSetBase.Container;

            if (component != null)
            {
                return(this.GetContentColumnIndex((
                                                      parameterOrOverrideBase.ParameterType.ShortName,
                                                      component.ParameterType.ShortName,
                                                      component.Scale?.ShortName ?? "",
                                                      parameterValueSetBase.ActualOption?.ShortName ?? "",
                                                      parameterOrOverrideBase.StateDependence?.ShortName ?? "",
                                                      parameterValueSetBase.ActualState?.ShortName ?? "")));
            }

            return(this.GetContentColumnIndex((
                                                  parameterOrOverrideBase.ParameterType.ShortName,
                                                  "",
                                                  parameterOrOverrideBase.Scale?.ShortName ?? "",
                                                  parameterValueSetBase.ActualOption?.ShortName ?? "",
                                                  parameterOrOverrideBase.StateDependence?.ShortName ?? "",
                                                  parameterValueSetBase.ActualState?.ShortName ?? "")));
        }
        /// <summary>
        /// Set the value of this row in case of the <see cref="ParameterType"/> is a <see cref="SampledFunctionParameterType"/>
        /// </summary>
        /// <param name="valueSet">The <see cref="ParameterValueSetBase"/> containing the value</param>
        public void SetSampledFunctionValue(ParameterValueSetBase valueSet)
        {
            // perform checks to see if this is indeed a scalar value
            if (valueSet.Published.Count() < 2)
            {
                logger.Warn("The value set of Parameter or override {0} is marked as SampledFunction, yet has less than 2 values.", this.Thing.Iid);
            }

            this.Switch = valueSet.ValueSwitch;

            var samplesFunctionParameterType = this.Thing.ParameterType as SampledFunctionParameterType;

            if (samplesFunctionParameterType == null)
            {
                logger.Warn("ParameterType mismatch, in {0} is marked as SampledFunction, yet cannot be converted.", this.Thing.Iid);
                this.Value = "-";

                return;
            }

            var cols = samplesFunctionParameterType.NumberOfValues;

            this.Value = $"[{valueSet.Published.Count / cols}x{cols}]";
        }
コード例 #25
0
        /// <summary>
        /// Creates a <see cref="NestedParameter"/> based on the provided <see cref="ParameterOrOverrideBase"/> and <see cref="ParameterValueSetBase"/>
        /// </summary>
        /// <param name="parameter">
        /// The <see cref="ParameterOrOverrideBase"/> that contains the <see cref="ParameterValueSetBase"/> based on which the
        /// <see cref="NestedParameter"/> is created.
        /// </param>
        /// <param name="component">
        /// The <see cref="ParameterTypeComponent"/> that this <see cref="NestedParameter"/> is associated to. This may be null in case the <see cref="ParameterType"/>
        /// of the associated <see cref="Parameter"/> is a <see cref="ScalarParameterType"/>.
        /// </param>
        /// <param name="valueSet">
        /// The <see cref="ParameterValueSetBase"/> that provides the reference to the <see cref="ActualFiniteState"/> and values
        /// to create the <see cref="NestedParameter"/>
        /// </param>
        /// <param name="option">
        /// The <see cref="Option"/> for which the <see cref="NestedParameter"/> is created.
        /// </param>
        /// <returns>
        /// An instance of a non-volatile <see cref="NestedParameter"/>
        /// </returns>
        private NestedParameter CreatedNestedParameter(ParameterOrOverrideBase parameter, ParameterTypeComponent component, ParameterValueSetBase valueSet, Option option)
        {
            var componentIndex = component == null ? 0 : component.Index;
            var actualValue    = valueSet.ActualValue[componentIndex];
            var formula        = valueSet.Formula[componentIndex];

            var nestedParameter = new NestedParameter(Guid.NewGuid(), parameter.Cache, parameter.IDalUri)
            {
                IsVolatile          = true,
                AssociatedParameter = parameter,
                Owner       = parameter.Owner,
                Component   = component,
                ActualState = valueSet.ActualState,
                ActualValue = actualValue,
                Formula     = formula,
                ValueSet    = valueSet,
                Option      = option
            };

            return(nestedParameter);
        }
コード例 #26
0
 public void Setup()
 {
     this.parameterValueSetBase = new ParameterValueSet();
 }