Ejemplo n.º 1
0
        public void VerifyThatParameterHasNoError()
        {
            var valuesetoverriden = new ParameterValueSet(Guid.NewGuid(), null, null);
            var valueset          = new ParameterSubscriptionValueSet(Guid.NewGuid(), null, null)
            {
                SubscribedValueSet = valuesetoverriden
            };
            var data = new List <string> {
                "-"
            };

            valueset.Manual             = new ValueArray <string>(data);
            valuesetoverriden.Computed  = new ValueArray <string>(data);
            valuesetoverriden.Reference = new ValueArray <string>(data);
            valuesetoverriden.Formula   = new ValueArray <string>(data);
            valuesetoverriden.Published = new ValueArray <string>(data);

            this.parameter.IsOptionDependent = false;
            this.parameter.StateDependence   = null;

            this.parameterSubscription.ValueSet.Add(valueset);
            valueset.ValidatePoco();
            this.parameterSubscription.ValidatePoco();

            Assert.IsEmpty(this.parameterSubscription.ValidationErrors);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Asserts whether the <see cref="ParameterSubscriptionValueSet"/> that is represented by the current <see cref="ProcessedValueSet"/> is Dirty or not
        /// </summary>
        /// <param name="original">
        /// The <see cref="ParameterSubscriptionValueSet"/> whose values are being compared to assert the dirtyness
        /// </param>
        /// <param name="componentIndex">
        /// The index of the component of the <see cref="CompoundParameterType"/>
        /// </param>
        /// <param name="parameterType">
        /// The <see cref="ParameterType"/> that is referenced by the container <see cref="ParameterSubscriptionValueSet"/>
        /// </param>
        /// <param name="switchKind">
        /// The <see cref="ParameterSwitchKind"/> that is read from the Parameter sheet
        /// </param>
        /// <param name="manualValue">
        /// The manual value that is read from the Parameter sheet
        /// </param>
        /// <param name="valueSetValues">
        /// The <see cref="ValueSetValues"/> that is created and returned as an out when the return value is true.
        /// </param>
        /// <returns>
        /// True when the values in the Parameter sheet are different from the values of the the <see cref="ParameterSubscriptionValueSet"/> that is being represented by the current <see cref="ProcessedValueSet"/>
        /// </returns>
        private bool IsDirty(ParameterSubscriptionValueSet original, int componentIndex, ParameterType parameterType, ParameterSwitchKind switchKind, object manualValue, out ValueSetValues valueSetValues)
        {
            // here we use CultureInfo.InvariantCulture, these are values that are not shown to the user
            // but serve the purpose to update the data-source.
            var stringManualValue = manualValue.ToValueSetString(parameterType);

            bool isManualValueDirty;

            try
            {
                isManualValueDirty = original.Manual[componentIndex] != stringManualValue;
            }
            catch (ArgumentOutOfRangeException e)
            {
                isManualValueDirty = true;
                logger.Debug("The ParameterSubscriptionValueSet.Manual ValueArray has an incorrect number of slots {0}", original.Iid);
            }
            catch (Exception e)
            {
                throw e;
            }

            var isSwitchKindDirty = original.ValueSwitch != switchKind;

            if (isManualValueDirty || isSwitchKindDirty)
            {
                valueSetValues = new ValueSetValues(componentIndex, parameterType, switchKind, stringManualValue, null, null, null);
                return(true);
            }

            valueSetValues = null;
            return(false);
        }
        public void verifyThatOptionDependentValuesetsComparerCompareReturnsExpectedResults()
        {
            var parametervalueseta = new ParameterValueSet();

            parametervalueseta.ActualOption = this.optiona;
            var parametervaluesetb = new ParameterValueSet();

            parametervaluesetb.ActualOption = this.optionb;

            var subscriptioinvalueseta = new ParameterSubscriptionValueSet();

            subscriptioinvalueseta.SubscribedValueSet = parametervalueseta;

            var subscriptioinvaluesetb = new ParameterSubscriptionValueSet();

            subscriptioinvaluesetb.SubscribedValueSet = parametervaluesetb;

            var comparer     = new ParameterSubscriptionValueSetComparer();
            var comparisonab = comparer.Compare(subscriptioinvalueseta, subscriptioinvaluesetb);

            Assert.AreEqual(1, comparisonab);

            var comparisonba = comparer.Compare(subscriptioinvaluesetb, subscriptioinvalueseta);

            Assert.AreEqual(-1, comparisonba);

            var comparisonaa = comparer.Compare(subscriptioinvalueseta, subscriptioinvalueseta);

            Assert.AreEqual(0, comparisonaa);

            var comparisonbb = comparer.Compare(subscriptioinvaluesetb, subscriptioinvaluesetb);

            Assert.AreEqual(0, comparisonbb);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Update the <see cref="ParameterSubscriptionValueSet"/> with the row values
        /// </summary>
        /// <param name="valueSet">The <see cref="ParameterSubscriptionValueSet"/> to update</param>
        public void UpdateValueSets(ParameterSubscriptionValueSet 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.RedirectUpdateCall(valueSet, actualStateRow);
                }
                else
                {
                    this.RedirectUpdateCall(valueSet, optionRow);
                }
            }
            else
            {
                if (actualState != null)
                {
                    var actualStateRow = this.ContainedRows.Cast <ParameterStateRowViewModel>().Single(x => x.ActualState == actualState);
                    this.RedirectUpdateCall(valueSet, actualStateRow);
                }
                else
                {
                    this.RedirectUpdateCall(valueSet);
                }
            }
        }
        public void VerifyThatStateFullValueSetsComparerCompareReturnsExpectedResults()
        {
            var parametervalueseta = new ParameterValueSet();

            parametervalueseta.ActualState = this.actualFiniteStatea;
            var parametervaluesetb = new ParameterValueSet();

            parametervaluesetb.ActualState = this.actualFiniteStateb;

            var subscriptionValueseta = new ParameterSubscriptionValueSet();

            subscriptionValueseta.SubscribedValueSet = parametervalueseta;

            var subscriptionValuesetb = new ParameterSubscriptionValueSet();

            subscriptionValuesetb.SubscribedValueSet = parametervaluesetb;

            var comparer     = new ParameterSubscriptionValueSetComparer();
            var comparisonab = comparer.Compare(subscriptionValueseta, subscriptionValuesetb);

            Assert.AreEqual(1, comparisonab);

            var comparisonba = comparer.Compare(subscriptionValuesetb, subscriptionValueseta);

            Assert.AreEqual(-1, comparisonba);

            var comparisonaa = comparer.Compare(subscriptionValueseta, subscriptionValueseta);

            Assert.AreEqual(0, comparisonaa);

            var comparisonbb = comparer.Compare(subscriptionValuesetb, subscriptionValuesetb);

            Assert.AreEqual(0, comparisonbb);
        }
Ejemplo n.º 6
0
        public void VerifyThatParameterSubscriptionHasRightOwnerValue()
        {
            this.parameter5Subscription = new ParameterSubscription(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Owner = this.activeDomain
            };
            this.parameter5ForSubscription.ParameterSubscription.Add(this.parameter5Subscription);

            var valueSet = new ParameterValueSet(Guid.NewGuid(), this.assembler.Cache, this.uri);

            this.SetScalarValueSet(valueSet);

            var valueSetSub = new ParameterSubscriptionValueSet(Guid.NewGuid(), this.assembler.Cache, this.uri);

            valueSetSub.SubscribedValueSet = valueSet;

            this.parameter5Subscription.ValueSet.Add(valueSetSub);

            var row = new ParameterSubscriptionRowViewModel(this.parameter5Subscription, this.session.Object, null, false);

            Assert.AreEqual(0, row.ContainedRows.Count);
            Assert.AreEqual("PTName", row.Name);
            Assert.AreEqual("[other]", row.OwnerName);
            Assert.AreEqual("formula", row.Formula);
            Assert.AreEqual("ref", row.Reference);
            Assert.That(row.ScaleName, Is.Null.Or.Empty);
        }
Ejemplo n.º 7
0
        public void VerifyThatInlineEditWorkSimpleNoOptionNoState()
        {
            this.subscription = new ParameterSubscription(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.parameter.IsOptionDependent = false;
            this.parameter.ParameterSubscription.Add(this.subscription);
            this.parameter.StateDependence = null;

            var set1 = new ParameterValueSet(Guid.NewGuid(), this.assembler.Cache, this.uri);

            this.parameter.ValueSet.Add(set1);

            var subset1 = new ParameterSubscriptionValueSet(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                SubscribedValueSet = set1
            };

            this.subscription.ValueSet.Add(subset1);

            var row = new ParameterSubscriptionRowViewModel(this.subscription, this.session.Object, null, false);

            Assert.AreEqual(0, row.ContainedRows.Count);

            row.Switch = ParameterSwitchKind.REFERENCE;
            row.CreateCloneAndWrite(ParameterSwitchKind.REFERENCE, "Switch");

            this.session.Verify(x => x.Write(It.Is <OperationContainer>(op => ((CDP4Common.DTO.ParameterSubscriptionValueSet)op.Operations.Single().ModifiedThing).ValueSwitch == ParameterSwitchKind.REFERENCE)));
        }
Ejemplo n.º 8
0
        public void VerifyThatUpdateValueSetUpdates(IViewModelBase <Thing> container, string scenario)
        {
            var valueset = new ParameterValueSet(Guid.NewGuid(), this.assembler.Cache, this.uri);

            this.parameter.ValueSet.Add(valueset);

            this.subscription = new ParameterSubscription(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.parameter.ParameterSubscription.Add(subscription);

            var subscriptionValueSet = new ParameterSubscriptionValueSet(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                SubscribedValueSet = valueset
            };

            this.subscription.ValueSet.Add(subscriptionValueSet);

            var row = new ParameterSubscriptionRowViewModel(this.subscription, this.session.Object, container, false);

            var revInfo = typeof(Thing).GetProperty("RevisionNumber");

            revInfo.SetValue(subscriptionValueSet, 10);

            Assert.AreEqual("-", row.Manual);
            subscriptionValueSet.Manual = new ValueArray <string>(new List <string> {
                "test"
            });
            CDPMessageBus.Current.SendObjectChangeEvent(subscriptionValueSet, EventKind.Updated);

            Assert.AreEqual("test", row.Manual);
            row.Dispose();
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Queries the container of the <see cref="ParameterValueSet"/> for the <see cref="ParameterType"/> and <see cref="MeasurementScale"/>
        /// </summary>
        /// <param name="parameterSubscriptionValueSet">
        /// The subject <see cref="ParameterSubscriptionValueSet"/>
        /// </param>
        /// <param name="componentIndex">
        /// The index of the <see cref="ParameterTypeComponent"/>.
        /// </param>
        /// <param name="parameterType">
        /// The resulting <see cref="ParameterType"/>
        /// </param>
        /// <param name="measurementScale">
        /// The resulting <see cref="MeasurementScale"/>, this may be null if the <see cref="ParameterType"/> is not a <see cref="QuantityKind"/>
        /// </param>
        public static void QueryParameterTypeAndScale(ParameterSubscriptionValueSet parameterSubscriptionValueSet, int componentIndex, out ParameterType parameterType, out MeasurementScale measurementScale)
        {
            var parameterSubscription = (ParameterSubscription)parameterSubscriptionValueSet.Container;

            var scalarParameterType = parameterSubscription.ParameterType as ScalarParameterType;

            if (scalarParameterType != null)
            {
                parameterType    = scalarParameterType;
                measurementScale = parameterSubscription.Scale;
                return;
            }

            var compoundParameterType = parameterSubscription.ParameterType as CompoundParameterType;

            if (compoundParameterType != null)
            {
                var component = compoundParameterType.Component[componentIndex];
                parameterType    = component.ParameterType;
                measurementScale = component.Scale;
                return;
            }

            logger.Debug("The ParameterType and MeasurementScale of ParameterSubscriptionValueSet {0} could not be queried", parameterSubscriptionValueSet.Iid);

            parameterType    = null;
            measurementScale = null;
        }
        public void VerifyThatNestedParameterExcelRowPropertiesAreSetForParameterSubscription()
        {
            var parameter = new Parameter(Guid.NewGuid(), this.cache, this.uri)
            {
                ParameterType = this.length,
                Scale         = this.meter,
                Owner         = this.systemEngineering
            };

            var parameterValueSet = new ParameterValueSet(Guid.NewGuid(), this.cache, this.uri)
            {
                Manual = new ValueArray <string>(new List <string> {
                    "A"
                }),
                Computed = new ValueArray <string>(new List <string> {
                    "B"
                }),
                Formula = new ValueArray <string>(new List <string> {
                    "C"
                }),
                ValueSwitch = ParameterSwitchKind.MANUAL
            };

            parameter.ValueSet.Add(parameterValueSet);
            this.satellite.Parameter.Add(parameter);

            var parameterSubscription = new ParameterSubscription(Guid.NewGuid(), this.cache, this.uri)
            {
                Owner = this.powerEngineering
            };

            var parameterSubscriptionValueSet = new ParameterSubscriptionValueSet(Guid.NewGuid(), this.cache, this.uri)
            {
                Manual = new ValueArray <string>(new List <string> {
                    "AA"
                }),
                ValueSwitch        = ParameterSwitchKind.MANUAL,
                SubscribedValueSet = parameterValueSet
            };

            parameterSubscription.ValueSet.Add(parameterSubscriptionValueSet);
            parameter.ParameterSubscription.Add(parameterSubscription);

            var nestedElementTreeGenerator = new NestedElementTreeGenerator();
            var nestedElements             = nestedElementTreeGenerator.Generate(this.option, this.powerEngineering);

            var rootnode        = nestedElements.Single(ne => ne.ShortName == "SAT");
            var nestedparameter = rootnode.NestedParameter.Single();

            var excelRow = new NestedParameterExcelRow(nestedparameter);

            Assert.AreEqual("=SAT.l", excelRow.ActualValue);
            Assert.AreEqual("SAT\\l\\option1\\", excelRow.ModelCode);
            Assert.AreEqual("Length", excelRow.Name);
            Assert.AreEqual("PWR [SYS]", excelRow.Owner);
            Assert.AreEqual("l [m]", excelRow.ParameterTypeShortName);
            Assert.AreEqual("NPS", excelRow.Type);
        }
Ejemplo n.º 11
0
        public void TestGetOwnerThrowsException()
        {
            this.parameterSubscriptionValueSet = new ParameterSubscriptionValueSet();

            Assert.Throws <ContainmentException>(() =>
            {
                Console.WriteLine(this.parameterSubscriptionValueSet.Owner);
            });
        }
Ejemplo n.º 12
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 UpdateSimpleValueSet(ParameterSubscriptionValueSet valueSet, ParameterValueBaseRowViewModel row = null)
 {
     valueSet.ValueSwitch = row == null ? this.Switch.Value : row.Switch.Value;
     valueSet.Manual      = row == null ? new ValueArray <string>(new List <string> {
         ValueSetConverter.ToValueSetString(this.Manual, this.ParameterType)
     }) : new ValueArray <string>(new List <string> {
         ValueSetConverter.ToValueSetString(row.Manual, this.ParameterType)
     });
 }
Ejemplo n.º 13
0
        /// <summary>
        /// Update the value switch and create a transaction to persist the change
        /// </summary>
        /// <param name="parameterSubscriptionValueSet">the value set on to change the value switch</param>
        private void UpdateValueSwitch(ParameterSubscriptionValueSet parameterSubscriptionValueSet)
        {
            var thingClone  = parameterSubscriptionValueSet.Clone(true);
            var transaction = new ThingTransaction(TransactionContextResolver.ResolveContext(thingClone), thingClone);

            thingClone.ValueSwitch = this.commandArguments.ParameterSwitchKind.Value;
            transaction.CreateOrUpdate(thingClone);
            this.sessionService.Transactions.Add(transaction);
        }
Ejemplo n.º 14
0
        private void SetValueSet(ParameterSubscriptionValueSet param, string value)
        {
            var stringlist = new List <string> {
                value
            };

            param.Manual      = new CDP4Common.Types.ValueArray <string>(stringlist);
            param.ValueSwitch = ParameterSwitchKind.MANUAL;
        }
Ejemplo n.º 15
0
 /// <summary>
 /// Call the correct update method depending on kind of parameter type (scalar, compound)
 /// </summary>
 /// <param name="valueSet">The <see cref="ParameterSubscriptionValueSet"/> to update</param>
 /// <param name="row">The <see cref="ParameterValueBaseRowViewModel"/> containing the information, or if null the current row</param>
 private void RedirectUpdateCall(ParameterSubscriptionValueSet valueSet, ParameterValueBaseRowViewModel row = null)
 {
     if (this.IsCompoundType)
     {
         this.UpdateCompoundValueSet(valueSet, row);
     }
     else
     {
         this.UpdateSimpleValueSet(valueSet, row);
     }
 }
 /// <summary>
 /// Call the correct update method depending on kind of parameter type (scalar, compound)
 /// </summary>
 /// <param name="valueSet">The <see cref="ParameterSubscriptionValueSet"/> to update</param>
 /// <param name="row">The <see cref="ParameterValueBaseRowViewModel"/> containing the information, or if null the current row</param>
 private void UpdateScalarOrCompoundValueSet(ParameterSubscriptionValueSet valueSet, ParameterValueBaseRowViewModel row = null)
 {
     if (this.isCompoundType)
     {
         this.UpdateCompoundValueSet(valueSet, row);
     }
     else
     {
         this.UpdateScalarValueSet(valueSet, row);
     }
 }
Ejemplo n.º 17
0
        /// <summary>
        /// Update the clone of the <see cref="ParameterSubscriptionValueSet"/> represented by this row
        /// </summary>
        /// <param name="valueset">The clone of the <see cref="ParameterSubscriptionValueSet"/> to update</param>
        private void UpdateValueSet(ParameterSubscriptionValueSet valueset)
        {
            if (this.ContainerViewModel is ParameterValueBaseRowViewModel parameterValueBaseRow)
            {
                parameterValueBaseRow.UpdateValueSet(valueset);
            }

            if (this.ContainerViewModel is ParameterSubscriptionRowViewModel parameterSubscriptionRow)
            {
                parameterSubscriptionRow.UpdateValueSets(valueset);
            }
        }
        public void VerifyThatOptionDepStateFullValueSetsComparerCompareReturnsExpectedResults()
        {
            var parametervaluesetaa = new ParameterValueSet();

            parametervaluesetaa.ActualOption = this.optiona;
            parametervaluesetaa.ActualState  = this.actualFiniteStatea;

            var aa = new ParameterSubscriptionValueSet();

            aa.SubscribedValueSet = parametervaluesetaa;

            var parametervaluesetab = new ParameterValueSet();

            parametervaluesetab.ActualOption = this.optiona;
            parametervaluesetab.ActualState  = this.actualFiniteStateb;

            var ab = new ParameterSubscriptionValueSet();

            ab.SubscribedValueSet = parametervaluesetab;

            var parametervaluesetbb = new ParameterValueSet();

            parametervaluesetbb.ActualOption = this.optionb;
            parametervaluesetbb.ActualState  = this.actualFiniteStateb;

            var bb = new ParameterSubscriptionValueSet();

            bb.SubscribedValueSet = parametervaluesetbb;

            var parametervaluesetba = new ParameterValueSet();

            parametervaluesetba.ActualOption = this.optionb;
            parametervaluesetba.ActualState  = this.actualFiniteStatea;

            var ba = new ParameterSubscriptionValueSet();

            ba.SubscribedValueSet = parametervaluesetba;

            var comparer = new ParameterSubscriptionValueSetComparer();

            var comparison_aa_ab = comparer.Compare(aa, ab);

            Assert.AreEqual(1, comparison_aa_ab);

            var comparison_aa_bb = comparer.Compare(aa, bb);

            Assert.AreEqual(1, comparison_aa_bb);

            var comparison_ab_ab = comparer.Compare(ab, ab);

            Assert.AreEqual(0, comparison_ab_ab);
        }
Ejemplo n.º 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(ParameterSubscriptionValueSet valueSet, ParameterValueBaseRowViewModel row = null)
        {
            var componentRows = (row == null)
                ? this.ContainedRows.Cast <ParameterComponentValueRowViewModel>().ToList()
                : row.ContainedRows.Cast <ParameterComponentValueRowViewModel>().ToList();

            valueSet.Manual      = 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.Manual[i] = componentRows[i].Manual.ToValueSetString(this.ParameterType);
            }
        }
        public void VerifyThatCreateValueSetsUpdateOperationsWorks()
        {
            var valueset = new ParameterValueSet(Guid.NewGuid(), this.assembler.Cache, this.uri);

            valueset.Manual = new ValueArray <string>(manual);
            this.parameter1.ValueSet.Add(valueset);

            var subscriptionvalueset = new ParameterSubscriptionValueSet(Guid.NewGuid(), this.assembler.Cache, this.uri);

            subscriptionvalueset.Manual = new ValueArray <string>(manual);
            this.subscription1.ValueSet.Add(subscriptionvalueset);

            var modeldto     = this.model2.ToDto();
            var iterationDto = (Dto.Iteration) this.iteration2.ToDto();
            var def2Dto      = new Dto.ElementDefinition(this.def2Copy.Iid, 2);
            var parameterDto = new Dto.Parameter(this.parameter1Copy.Iid, 2);
            var newValueSet  = new Dto.ParameterValueSet(Guid.NewGuid(), 2);

            var subscription         = new Dto.ParameterSubscription(this.subscriptionCopy.Iid, 1);
            var subscriptionValueSet = new Dto.ParameterSubscriptionValueSet(Guid.NewGuid(), 1);

            iterationDto.Element.Add(def2Dto.Iid);
            def2Dto.Parameter.Add(parameterDto.Iid);
            parameterDto.ValueSet.Add(newValueSet.Iid);
            parameterDto.ParameterSubscription.Add(subscription.Iid);
            subscription.ValueSet.Add(subscriptionValueSet.Iid);

            var returnedDto = new List <Dto.Thing>
            {
                modeldto,
                iterationDto,
                def2Dto,
                parameterDto,
                newValueSet,
                subscription,
                subscriptionValueSet
            };

            var transactionContext = TransactionContextResolver.ResolveContext(this.iteration2);
            var context            = transactionContext.ContextRoute();

            var operationCreator   = new ValueSetOperationCreator(this.session.Object);
            var operationContainer = operationCreator.CreateValueSetsUpdateOperations(context, returnedDto, this.map);

            Assert.AreEqual(2, operationContainer.Operations.Count());
            var operation   = operationContainer.Operations.Single(x => x.OriginalThing.ClassKind == ClassKind.ParameterValueSet);
            var originalPvs = (Dto.ParameterValueSet)operation.OriginalThing;
            var modifiedPvs = (Dto.ParameterValueSet)operation.ModifiedThing;

            Assert.AreNotEqual(originalPvs.Manual, modifiedPvs.Manual);
        }
Ejemplo n.º 21
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WorkbookRebuildRowViewModel"/> class.
 /// </summary>
 /// <param name="parameterSubscriptionValueSet">
 /// The <see cref="ParameterSubscriptionValueSet"/> that is represented by the current view model
 /// </param>
 /// <param name="componentIndex">
 /// The component index.
 /// </param>
 /// <param name="validationResult">
 /// The result of the Validation
 /// </param>
 public WorkbookRebuildRowViewModel(ParameterSubscriptionValueSet parameterSubscriptionValueSet, int componentIndex, ValidationResultKind validationResult)
 {
     this.Thing              = parameterSubscriptionValueSet;
     this.IsSelected         = true;
     this.ModelCode          = parameterSubscriptionValueSet.ModelCode(componentIndex);
     this.ManualValue        = parameterSubscriptionValueSet.Manual[componentIndex];
     this.ReferenceValue     = parameterSubscriptionValueSet.Reference[componentIndex];
     this.FormulaValue       = string.Empty;
     this.ComputedValue      = parameterSubscriptionValueSet.Computed[componentIndex];
     this.ActualValue        = parameterSubscriptionValueSet.ActualValue[componentIndex];
     this.Switch             = parameterSubscriptionValueSet.ValueSwitch.ToString();
     this.HasValidationError = validationResult != ValidationResultKind.Valid;
     this.IsSelected         = this.HasValidationError == false;
 }
Ejemplo n.º 22
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();
        }
Ejemplo n.º 23
0
        private void SetValueSet(ParameterSubscription subscription, ParameterOrOverrideBase param, IReadOnlyList <string> values)
        {
            var i = 0;

            foreach (var parameterValueSet in param.ValueSets)
            {
                var valueset = new ParameterSubscriptionValueSet(Guid.NewGuid(), this.cache, this.uri)
                {
                    SubscribedValueSet = (ParameterValueSetBase)parameterValueSet
                };
                this.SetValueSet(valueset, values[i]);
                subscription.ValueSet.Add(valueset);
                i++;
            }
        }
        /// <summary>
        /// Create a <see cref="ParameterSubscriptionValueSet"/> from an old <see cref="ParameterSubscriptionValueSet"/>
        /// </summary>
        /// <param name="oldValueSet">The old <see cref="ParameterSubscriptionValueSet"/>. If null the default values are used</param>
        /// <param name="subscribedValueSetGuid">The subscribed value-set</param>
        /// <param name="defaultValueArray">The default value-array</param>
        /// <returns>The new <see cref="ParameterSubscriptionValueSet"/></returns>
        public ParameterSubscriptionValueSet CreateWithOldValues(ParameterSubscriptionValueSet oldValueSet, Guid subscribedValueSetGuid, ValueArray <string> defaultValueArray)
        {
            if (oldValueSet == null)
            {
                return(this.CreateWithDefaultValueArray(subscribedValueSetGuid, defaultValueArray));
            }

            var parameterSubscriptionValueSet = new ParameterSubscriptionValueSet(Guid.NewGuid(), -1)
            {
                SubscribedValueSet = subscribedValueSetGuid,
                Manual             = oldValueSet.Manual,
                ValueSwitch        = oldValueSet.ValueSwitch
            };

            return(parameterSubscriptionValueSet);
        }
        /// <summary>
        /// Serialize the <see cref="ParameterSubscriptionValueSet"/>
        /// </summary>
        /// <param name="parameterSubscriptionValueSet">The <see cref="ParameterSubscriptionValueSet"/> to serialize</param>
        /// <returns>The <see cref="JObject"/></returns>
        private JObject Serialize(ParameterSubscriptionValueSet parameterSubscriptionValueSet)
        {
            var jsonObject = new JObject();

            jsonObject.Add("classKind", this.PropertySerializerMap["classKind"](Enum.GetName(typeof(CDP4Common.CommonData.ClassKind), parameterSubscriptionValueSet.ClassKind)));
            jsonObject.Add("excludedDomain", this.PropertySerializerMap["excludedDomain"](parameterSubscriptionValueSet.ExcludedDomain.OrderBy(x => x, this.guidComparer)));
            jsonObject.Add("excludedPerson", this.PropertySerializerMap["excludedPerson"](parameterSubscriptionValueSet.ExcludedPerson.OrderBy(x => x, this.guidComparer)));
            jsonObject.Add("iid", this.PropertySerializerMap["iid"](parameterSubscriptionValueSet.Iid));
            jsonObject.Add("manual", this.PropertySerializerMap["manual"](parameterSubscriptionValueSet.Manual));
            jsonObject.Add("modifiedOn", this.PropertySerializerMap["modifiedOn"](parameterSubscriptionValueSet.ModifiedOn));
            jsonObject.Add("revisionNumber", this.PropertySerializerMap["revisionNumber"](parameterSubscriptionValueSet.RevisionNumber));
            jsonObject.Add("subscribedValueSet", this.PropertySerializerMap["subscribedValueSet"](parameterSubscriptionValueSet.SubscribedValueSet));
            jsonObject.Add("thingPreference", this.PropertySerializerMap["thingPreference"](parameterSubscriptionValueSet.ThingPreference));
            jsonObject.Add("valueSwitch", this.PropertySerializerMap["valueSwitch"](Enum.GetName(typeof(CDP4Common.EngineeringModelData.ParameterSwitchKind), parameterSubscriptionValueSet.ValueSwitch)));
            return(jsonObject);
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Update the clone of the <see cref="ParameterSubscriptionValueSet"/> represented by this row
        /// </summary>
        /// <param name="valueset">The clone of the <see cref="ParameterSubscriptionValueSet"/> to update</param>
        private void UpdateValueSet(ParameterSubscriptionValueSet valueset)
        {
            var parameterValueBaseRow = this.ContainerViewModel as ParameterValueBaseRowViewModel;

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

            var parameterSubscriptionRow = this.ContainerViewModel as ParameterSubscriptionRowViewModel;

            if (parameterSubscriptionRow != null)
            {
                parameterSubscriptionRow.UpdateValueSets(valueset);
            }
        }
        /// <summary>
        /// Creates a new <see cref="ParameterSubscriptionValueSet"/> where manual value is equal to a <see cref="ValueArray{String}"/> where each slot is a "-"
        /// and the <see cref="CDP4Common.EngineeringModelData.ParameterSwitchKind"/> is set to <see cref="CDP4Common.EngineeringModelData.ParameterSwitchKind.MANUAL"/>
        /// </summary>
        /// <param name="subscribedValueSetIid">
        /// The unique id of the <see cref="ParameterValueSetBase"/> that is referenced by the <see cref="ParameterSubscriptionValueSet"/>s that are to be created
        /// </param>
        /// <param name="valueArray">
        /// A <see cref="ValueArray{String}"/> where each slot is a "-"
        /// </param>
        /// <returns>
        /// A instance of <see cref="ParameterSubscriptionValueSet"/>
        /// </returns>
        public ParameterSubscriptionValueSet CreateWithDefaultValueArray(Guid subscribedValueSetIid, ValueArray <string> valueArray)
        {
            if (valueArray.Any(value => value != "-"))
            {
                throw new ArgumentException("The valueArray must be a default valueArray that only contains \"-\"", "valueArray");
            }

            var parameterSubscriptionValueSet = new ParameterSubscriptionValueSet(Guid.NewGuid(), -1)
            {
                SubscribedValueSet = subscribedValueSetIid,
                Manual             = valueArray,
                ValueSwitch        = CDP4Common.EngineeringModelData.ParameterSwitchKind.MANUAL
            };

            return(parameterSubscriptionValueSet);
        }
Ejemplo n.º 28
0
        public void VerifyThatParameterSubscriptionModelCodeReturnsExpectedResult()
        {
            var parameterValueSet = new ParameterValueSet();

            this.parameter.ValueSet.Add(parameterValueSet);

            var subscription         = new ParameterSubscription();
            var subscriptionValueSet = new ParameterSubscriptionValueSet();

            subscription.ValueSet.Add(subscriptionValueSet);

            subscriptionValueSet.SubscribedValueSet = parameterValueSet;

            this.parameter.ParameterSubscription.Add(subscription);

            Assert.AreEqual(@"Bat.bool", subscriptionValueSet.ModelCode(0));
        }
Ejemplo n.º 29
0
        public void VerifyThatParameterWithEmptyArrayValueSetHasError()
        {
            var valuesetoverriden = new ParameterValueSet(Guid.NewGuid(), null, null);
            var valueset          = new ParameterSubscriptionValueSet(Guid.NewGuid(), null, null)
            {
                SubscribedValueSet = valuesetoverriden
            };

            this.parameter.IsOptionDependent = false;
            this.parameter.StateDependence   = null;

            this.parameterSubscription.ValueSet.Add(valueset);
            valueset.ValidatePoco();
            this.parameterSubscription.ValidatePoco();

            Assert.IsNotEmpty(this.parameterSubscription.ValidationErrors);
        }
Ejemplo n.º 30
0
        public void SetUp()
        {
            this.concurentDictionary = new ConcurrentDictionary <CacheKey, Lazy <Thing> >();

            this.parameterType = new TextParameterType(Guid.NewGuid(), this.concurentDictionary, this.uri);

            var manualValue = new ValueArray <string>(new List <string> {
                "-"
            });
            var computedValue = new ValueArray <string>(new List <string> {
                "-"
            });
            var referenceValue = new ValueArray <string>(new List <string> {
                "-"
            });
            var formula = new ValueArray <string>(new List <string> {
                "-"
            });

            this.parameterValueSet = new ParameterValueSet(Guid.NewGuid(), this.concurentDictionary, this.uri)
            {
                Manual      = manualValue,
                Computed    = computedValue,
                Reference   = referenceValue,
                Formula     = formula,
                ValueSwitch = ParameterSwitchKind.MANUAL
            };


            this.parameterOverrideValueSet = new ParameterOverrideValueSet(Guid.NewGuid(), this.concurentDictionary, this.uri)
            {
                Manual      = manualValue,
                Computed    = computedValue,
                Reference   = referenceValue,
                Formula     = formula,
                ValueSwitch = ParameterSwitchKind.MANUAL
            };

            this.parameterSubscriptionValueSet = new ParameterSubscriptionValueSet(Guid.NewGuid(), this.concurentDictionary, this.uri)
            {
                Manual      = manualValue,
                ValueSwitch = ParameterSwitchKind.MANUAL
            };

            this.valueSetValues = new ValueSetValues(0, this.parameterType, ParameterSwitchKind.COMPUTED, "manual", "computed", "reference", "formula");
        }