Пример #1
0
 private static void CompareCondensedSectionOverrideState(EnumeratedValue adaptEnumeratedValue, SpatialValue isoValue)
 {
     if (adaptEnumeratedValue.Value.Code == DefinedTypeEnumerationInstanceList.dtiPrescriptionUsed.ToModelEnumMember().Code)
         Assert.AreEqual(0, isoValue.Value);
     if (adaptEnumeratedValue.Value.Code == DefinedTypeEnumerationInstanceList.dtiPrescriptionOverridden.ToModelEnumMember().Code)
         Assert.AreEqual(1, isoValue.Value);
 }
Пример #2
0
 private static void CompareActualLoadingSystemStatus(EnumeratedValue adaptEnumeratedValue, SpatialValue isoValue)
 {
     if (adaptEnumeratedValue.Value.Code == DefinedTypeEnumerationInstanceList.dtiUnloadingAugerStateDisabled.ToModelEnumMember().Code)
         Assert.AreEqual(0, isoValue.Value);
     if (adaptEnumeratedValue.Value.Code == DefinedTypeEnumerationInstanceList.dtiUnloadingAugerStateEnabled.ToModelEnumMember().Code)
         Assert.AreEqual(1, isoValue.Value);
     if (adaptEnumeratedValue.Value.Code == DefinedTypeEnumerationInstanceList.dtiUnloadingAugerStateError.ToModelEnumMember().Code)
         Assert.AreEqual(2, isoValue.Value);
     if (adaptEnumeratedValue.Value.Code == DefinedTypeEnumerationInstanceList.dtiUnloadingAugerStateNotAvailable.ToModelEnumMember().Code)
         Assert.AreEqual(3, isoValue.Value);
 }
Пример #3
0
        private void WriteListValues(XmlWriter writer, EnumeratedValue value)
        {
            if (value == null)
                return;

            if (value.Representation != null &&
                value.Representation.EnumeratedMembers != null)
            {
                _listWriter.Write(writer, value.Representation.EnumeratedMembers);
            }
            else if (value.Value != null)
            {
                _listWriter.Write(writer, new List<EnumerationMember> { value.Value });
            }
        }
        public void GivenEnumeratedRepresentationValueWhenInterpolateThenRepresentationValue()
        {
            var previousEnumeratedValue = new EnumeratedValue
            {
                Representation = RepresentationInstanceList.dtSkyCondition.ToModelRepresentation()
            };

            var enumMember = DefinedTypeEnumerationInstanceList.dtiSunny.ToModelEnumMember();
            previousEnumeratedValue.Value = enumMember;
            previousEnumeratedValue.Code = enumMember.Code;

            _interpolator.SetMostRecentMeterValue(_enumeratedMeter, previousEnumeratedValue);

            var result = _interpolator.Interpolate(_enumeratedMeter);

            Assert.IsInstanceOf<EnumeratedValue>(result);
        }
        public void GivenEnumeratedValueWhenInterpolateThenValueIsSameAsPrevious()
        {
            var previousEnumeratedValue = new EnumeratedValue
            {
                Representation = RepresentationInstanceList.dtSkyCondition.ToModelRepresentation()
            };

            var enumMember = DefinedTypeEnumerationInstanceList.dtiSunny.ToModelEnumMember();
            previousEnumeratedValue.Value = enumMember;
            previousEnumeratedValue.Code = enumMember.Code;

            _interpolator.SetMostRecentMeterValue(_enumeratedMeter, previousEnumeratedValue);
            var result = _interpolator.Interpolate(_enumeratedMeter);

            var enumeratedRepresentation = result as EnumeratedValue;
            Assert.AreEqual(previousEnumeratedValue.Representation, enumeratedRepresentation.Representation);
            Assert.AreEqual(previousEnumeratedValue.Code, enumeratedRepresentation.Code);
        }
        public RepresentationValue Interpolate(WorkingData meter)
        {
            if (!_meterToPreviousValue.ContainsKey(meter))
                return null;

            var previousValue = _meterToPreviousValue[meter];

            var numericRepresentationValue = previousValue as NumericRepresentationValue;
            if (numericRepresentationValue != null)
            {
                var newNumericRepresentationValue = numericRepresentationValue.Copy();

                if (numericRepresentationValue.Representation != null && _numericRepresentationTotals.Contains(numericRepresentationValue.Representation.Code))
                {
                    newNumericRepresentationValue.Value.Value = 0;
                }

                return newNumericRepresentationValue;
            }

            var enumeratedValue = previousValue as EnumeratedValue;
            if (enumeratedValue != null)
            {
                var newEnumeratedValue = new EnumeratedValue
                {
                    Code = enumeratedValue.Code,
                    Value = new EnumerationMember
                    {
                        Code = enumeratedValue.Value.Code,
                        Value = enumeratedValue.Value.Value
                    },
                    Representation = enumeratedValue.Representation

                };

                return newEnumeratedValue;
            }

            return null;
        }
Пример #7
0
 private static void CompareConnectorType(EnumeratedValue adaptEnumeratedValue, SpatialValue isoValue)
 {
     if (adaptEnumeratedValue.Value.Code == DefinedTypeEnumerationInstanceList.dtiDrawbar.ToModelEnumMember().Code)
         Assert.AreEqual(1, isoValue.Value);
     if (adaptEnumeratedValue.Value.Code == DefinedTypeEnumerationInstanceList.dtiRearTwoPoint.ToModelEnumMember().Code)
         Assert.AreEqual(2, isoValue.Value);
     if (adaptEnumeratedValue.Value.Code == DefinedTypeEnumerationInstanceList.dtiThreePoint.ToModelEnumMember().Code)
         Assert.AreEqual(3, isoValue.Value);
     if (adaptEnumeratedValue.Value.Code == DefinedTypeEnumerationInstanceList.dtiRearPivotWagonHitch.ToModelEnumMember().Code)
         Assert.AreEqual(7, isoValue.Value);
 }
Пример #8
0
 private static void CompareCondensedWorkState(EnumeratedValue adaptEnumeratedValue, SpatialValue isoValue)
 {
     if (adaptEnumeratedValue.Value.Code == DefinedTypeEnumerationInstanceList.dtiRecordingStatusOff.ToModelEnumMember().Code)
         Assert.AreEqual(0, isoValue.Value);
     if (adaptEnumeratedValue.Value.Code == DefinedTypeEnumerationInstanceList.dtiRecordingStatusOn.ToModelEnumMember().Code)
         Assert.AreEqual(1, isoValue.Value);
 }
Пример #9
0
 private static void CompareSkyConditions(EnumeratedValue adaptEnumeratedValue, SpatialValue isoValue)
 {
     if (adaptEnumeratedValue.Value.Code == DefinedTypeEnumerationInstanceList.dtiClear.ToModelEnumMember().Code)
         Assert.AreEqual(0x20524C43, isoValue.Value);
     if (adaptEnumeratedValue.Value.Code == DefinedTypeEnumerationInstanceList.dtiSunny.ToModelEnumMember().Code)
         Assert.AreEqual(0x2043534E, isoValue.Value);
     if (adaptEnumeratedValue.Value.Code == DefinedTypeEnumerationInstanceList.dtiPartlyCloudy.ToModelEnumMember().Code)
         Assert.AreEqual(0x20544353, isoValue.Value);
     if (adaptEnumeratedValue.Value.Code == DefinedTypeEnumerationInstanceList.dtiCloudy.ToModelEnumMember().Code)
         Assert.AreEqual(0x2043564F, isoValue.Value);
 }
Пример #10
0
 private static void CompareSectionControlState(EnumeratedValue adaptEnumeratedValue, SpatialValue isoValue)
 {
     if (adaptEnumeratedValue.Value.Code == DefinedTypeEnumerationInstanceList.dtiSCMasterManualOff.ToModelEnumMember().Code)
         Assert.AreEqual(0, isoValue.Value);
     if (adaptEnumeratedValue.Value.Code == DefinedTypeEnumerationInstanceList.dtiSCMasterAutoOn.ToModelEnumMember().Code)
         Assert.AreEqual(1, isoValue.Value);
     if (adaptEnumeratedValue.Value.Code == DefinedTypeEnumerationInstanceList.dtiSCMasterError.ToModelEnumMember().Code)
         Assert.AreEqual(2, isoValue.Value);
 }
Пример #11
0
 private static void CompareNetWeightState(EnumeratedValue adaptEnumeratedValue, SpatialValue isoValue)
 {
     if (adaptEnumeratedValue.Value.Code == DefinedTypeEnumerationInstanceList.dtiWeightUnStable.ToModelEnumMember().Code)
         Assert.AreEqual(0, isoValue.Value);
     if (adaptEnumeratedValue.Value.Code == DefinedTypeEnumerationInstanceList.dtiWeightStable.ToModelEnumMember().Code)
         Assert.AreEqual(1, isoValue.Value);
 }
Пример #12
0
        public void GivenIsoSpatialRowsWithoutEnumeratedMeterOnSecondWhenMapThenSecondValueIsInterpolator()
        {
            var spatialValue = new SpatialValue
            {
                Id = 0,
                Value = 1
            };
            _isoSpatialRow.SpatialValues = new List<SpatialValue> { spatialValue };
            var isoSpatialRow2 = new ISOSpatialRow {SpatialValues = new List<SpatialValue>()};

            _isoSpatialRows = new List<ISOSpatialRow> { _isoSpatialRow, isoSpatialRow2 };

            var meter = new ISOEnumeratedMeter
            {
                Representation = RepresentationInstanceList.dtSectionControlMasterState.ToModelRepresentation(),
                ValueCodes = new List<int> { 1, 2, 3 },
                DeviceElementUseId = 1,
                GetEnumeratedValue = (sv, im) => new EnumeratedValue { Value = new AgGateway.ADAPT.ApplicationDataModel.Representations.EnumerationMember { Code = 3 } }
            };

            var uniqueId = new UniqueId
            {
                CiTypeEnum = CompoundIdentifierTypeEnum.String,
                Id = "DLV0"
            };
            meter.Id.UniqueIds.Add(uniqueId);
            _meters.Add(meter);

            var enumeratedRepresentation = new EnumeratedValue { Value = new AgGateway.ADAPT.ApplicationDataModel.Representations.EnumerationMember { Code = 3 } };
            _spatialValueInterpolator.Setup(s => s.Interpolate(meter)).Returns(enumeratedRepresentation);

            var result = Map().ToList();

            Assert.AreEqual(enumeratedRepresentation, result[1].GetMeterValue(meter) as EnumeratedValue);
        }
Пример #13
0
        public void GivenOperationDataWithSpatialRecordDataWithEnumeratedValueWhenProcessOperationDataThenRowsAreAdded()
        {
            var meter = new EnumeratedWorkingData { Representation = RepresentationInstanceList.dtRecordingStatus.ToModelRepresentation() };
            _workingDatas.Add(meter);
            _deviceElementUses.Add(0, new List<DeviceElementUse>
            {
                new DeviceElementUse
                {
                    Depth = 0,
                    GetWorkingDatas = () => _workingDatas,
                }
            });

            var spatialRecord = new SpatialRecord();
            var enumeratedValue = new EnumeratedValue{Value = DefinedTypeEnumerationInstanceList.dtiRecordingStatusOn.ToModelEnumMember() };

            spatialRecord.SetMeterValue(meter, enumeratedValue);

            _spatialRecords.Add(spatialRecord);

            var dataTable = _operationDataProcessor.ProcessOperationData(_operationData);

            Assert.AreEqual(1, dataTable.Rows.Count);
            Assert.AreEqual(enumeratedValue.Value.Value, dataTable.Rows[0][0]);
        }