Inheritance: AgGateway.ADAPT.ApplicationDataModel.LoggedData.EnumeratedWorkingData
コード例 #1
0
        public void GivenIsoSpatialRowAndEnumeratedMeterWhenMapThenSpatialRecordContainsMeterValue()
        {
            var spatialValue = new SpatialValue
            {
                Id = 0,
                Value = 1
            };
            _isoSpatialRow.SpatialValues = new List<SpatialValue> { spatialValue };
            _isoSpatialRows = new List<ISOSpatialRow> { _isoSpatialRow };

            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",
                Source = UniqueIdMapper.IsoSource
            };
            meter.Id.UniqueIds.Add(uniqueId);
            _meters.Add(meter);

            var result = Map();
            var meterValue = result.First().GetMeterValue(meter) as EnumeratedValue;

            Assert.AreEqual(3, meterValue.Value.Code);
        }
コード例 #2
0
        public List<ISOEnumeratedMeter> CreateMeters(IEnumerable<ISOSpatialRow> spatialRows)
        {
            var meter = new ISOEnumeratedMeter
            {
                Representation = RepresentationInstanceList.dtRecordingStatus.ToModelRepresentation(),
                GetEnumeratedValue = GetValueForMeter
            };

            return new List<ISOEnumeratedMeter> {meter};
        }
コード例 #3
0
        public List<ISOEnumeratedMeter> CreateMeters(IEnumerable<ISOSpatialRow> spatialRows)
        {
            var meter = new ISOEnumeratedMeter
            {
                Representation = RepresentationInstanceList.dtPrescriptionControlMasterState.ToModelRepresentation(),
                GetEnumeratedValue = GetValueForMeter
            };

            return new List<ISOEnumeratedMeter> { meter };
        }
コード例 #4
0
        public void GivenMetersWithRearPivotWagonHitchWhenGetMetersValueThenSeven()
        {
            var enumeratedMeter1 = new ISOEnumeratedMeter();
            var meters = new List<WorkingData> { enumeratedMeter1 };

            var spatialRecord = new SpatialRecord();
            spatialRecord.SetMeterValue(enumeratedMeter1, new EnumeratedValue { Value = DefinedTypeEnumerationInstanceList.dtiRearPivotWagonHitch.ToModelEnumMember() });

            var result = _creator.GetMetersValue(meters, spatialRecord);
            Assert.AreEqual(0x07, result);
        }
コード例 #5
0
        public void GivenMetersWithUnStableWhenGetMetersValueThenIsZero()
        {
            var enumeratedMeter = new ISOEnumeratedMeter();
            var meters = new List<WorkingData> { enumeratedMeter };

            var spatialRecord = new SpatialRecord();
            spatialRecord.SetMeterValue(enumeratedMeter, new EnumeratedValue { Value = DefinedTypeEnumerationInstanceList.dtiWeightUnStable.ToModelEnumMember() });

            var result = _creator.GetMetersValue(meters, spatialRecord);
            Assert.AreEqual(0x00, result);
        }
コード例 #6
0
        public void GivenMetersWithPartlyCloudyWhenGetMetersValueThenIsCorrect()
        {
            var enumeratedMeter = new ISOEnumeratedMeter();
            var meters = new List<WorkingData> { enumeratedMeter };

            var spatialRecord = new SpatialRecord();
            spatialRecord.SetMeterValue(enumeratedMeter, new EnumeratedValue { Value = DefinedTypeEnumerationInstanceList.dtiPartlyCloudy.ToModelEnumMember() });

            var result = _creator.GetMetersValue(meters, spatialRecord);
            Assert.AreEqual(0x20544353, result);
        }
コード例 #7
0
        public void GivenMetersWithUnknownWhenGetMetersValueThenThree()
        {
            var enumeratedMeter1 = new ISOEnumeratedMeter();
            var meters = new List<WorkingData> { enumeratedMeter1 };

            var spatialRecord = new SpatialRecord();
            spatialRecord.SetMeterValue(enumeratedMeter1, new EnumeratedValue { Value = DefinedTypeEnumerationInstanceList.dtiSunny.ToModelEnumMember() });

            var result = _creator.GetMetersValue(meters, spatialRecord);
            Assert.AreEqual(0x03, result);
        }
コード例 #8
0
        public UInt32 Map(ISOEnumeratedMeter currentMeter, List<WorkingData> meters, SpatialRecord spatialRecord)
        {
            var matchingMeters = meters.Where(x => x.Id.FindIntIsoId() == currentMeter.Id.FindIntIsoId()).ToList();
            var ddi = _representationMapper.Map(currentMeter.Representation);

            if (ddi == 141 && currentMeter.DeviceElementUseId != 0)
                ddi = 161;

            var creator = _enumeratedMeterFactory.GetMeterCreator(ddi.GetValueOrDefault());
            return creator.GetMetersValue(matchingMeters, spatialRecord);
        }
コード例 #9
0
        public List <ISOEnumeratedMeter> CreateMeters(IEnumerable <ISOSpatialRow> spatialRows)
        {
            var meter = new ISOEnumeratedMeter
            {
                Representation     = RepresentationInstanceList.dtHitchType.ToModelRepresentation(),
                GetEnumeratedValue = GetValueForMeter
            };

            return(new List <ISOEnumeratedMeter> {
                meter
            });
        }
コード例 #10
0
        public void GivenMetersWithRearTwoPointWhenGetMetersValueThenTwo()
        {
            var enumeratedMeter1 = new ISOEnumeratedMeter
            {
                GetEnumeratedValue = (value, meter) => new EnumeratedValue
                {
                    Value = DefinedTypeEnumerationInstanceList.dtiRearTwoPoint.ToModelEnumMember(),
                },
            };
            var meters = new List<WorkingData> { enumeratedMeter1 };

            var spatialRecord = new SpatialRecord();
            spatialRecord.SetMeterValue(enumeratedMeter1, new EnumeratedValue { Value = DefinedTypeEnumerationInstanceList.dtiRearTwoPoint.ToModelEnumMember() });

            var result = _creator.GetMetersValue(meters, spatialRecord);
            Assert.AreEqual(0x02, result);
        }
コード例 #11
0
        public void GivenMetersWithRecordingStatusOnWhenGetMetersValueThenOne()
        {
            var enumeratedMeter1 = new ISOEnumeratedMeter
            {
                GetEnumeratedValue = (value, meter) => new EnumeratedValue
                {
                    Value = DefinedTypeEnumerationInstanceList.dtiRecordingStatusOn.ToModelEnumMember(),
                },
                DeviceElementUseId = 1,
            };
            var meters = new List<WorkingData> { enumeratedMeter1 };

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

            var result = _creator.GetMetersValue(meters, spatialRecord);
            Assert.AreEqual(0x01, result);
        }
コード例 #12
0
        public void GivenMetersErrorAndNotAvailableWhenGetMetersValueThenValuesReturned()
        {
            var enumeratedMeter1 = new ISOEnumeratedMeter
            {
                DeviceElementUseId = 1,
            };
            var enumeratedMeter2 = new ISOEnumeratedMeter
            {
                DeviceElementUseId = 2,
            };
            var meters = new List<WorkingData> { enumeratedMeter1, enumeratedMeter2 };

            var spatialRecord = new SpatialRecord();
            spatialRecord.SetMeterValue(enumeratedMeter1, new EnumeratedValue { Value = DefinedTypeEnumerationInstanceList.dtiUnloadingAugerStateError.ToModelEnumMember() });
            spatialRecord.SetMeterValue(enumeratedMeter2, new EnumeratedValue { Value = DefinedTypeEnumerationInstanceList.dtiUnloadingAugerStateNotAvailable.ToModelEnumMember() });

            var result = _creator.GetMetersValue(meters, spatialRecord);
            Assert.AreEqual(0x0302, result);
        }
コード例 #13
0
ファイル: MeterMapperTest.cs プロジェクト: ADAPT/ISOv4Plugin
        public void GivenEnumeratedDlvWhenMapThenEnumerateMeterHasId()
        {
            const int ddiValue = 131;
            var dlv = new DLV { A = ddiValue.ToString("x4") };
            _tim.Items = new List<DLV> { dlv }.ToArray();

            var expected = new ISOEnumeratedMeter { TriggerId = 8675309 };
            var meterCreator = new Mock<IEnumeratedMeterCreator>();
            meterCreator.Setup(m => m.CreateMeters(It.IsAny<IEnumerable<ISOSpatialRow>>())).Returns(new List<ISOEnumeratedMeter> {expected});

            _enumeratorMeterFactoryMock.Setup(m => m.GetMeterCreator(ddiValue)).Returns(meterCreator.Object);
            var uniqueId = new UniqueId();
            _uniqueIdMapperMock.Setup(x => x.Map("DLV0")).Returns(uniqueId);

            var result = MapSingle();

            Assert.AreSame(expected, result);
            Assert.Contains(uniqueId, result.Id.UniqueIds);
        }
コード例 #14
0
        public List <ISOEnumeratedMeter> CreateMeters(IEnumerable <ISOSpatialRow> spatialRows)
        {
            var unloadingMeter = new ISOEnumeratedMeter
            {
                DeviceElementUseId = 1,
                Representation     = RepresentationInstanceList.dtUnloadingAugerState.ToModelRepresentation(),
                GetEnumeratedValue = GetValueForMeter
            };

            var loadingMeter = new ISOEnumeratedMeter
            {
                DeviceElementUseId = 2,
                Representation     = RepresentationInstanceList.dtUnloadingAugerState.ToModelRepresentation(),
                GetEnumeratedValue = GetValueForMeter
            };

            var meters = new List <ISOEnumeratedMeter> {
                unloadingMeter, loadingMeter
            };

            return(meters);
        }
コード例 #15
0
        public void GivenCurrentMeterWithMatchingMetersWhenMapThenValueReturned()
        {
            var enumeratedMeter1 = new ISOEnumeratedMeter{ Representation = RepresentationInstanceList.dtRecordingStatus.ToModelRepresentation() };
            var enumeratedMeter2 = new ISOEnumeratedMeter();

            enumeratedMeter1.Id.UniqueIds.Add(new UniqueId{ Id = "DLV3", Source = UniqueIdMapper.IsoSource, CiTypeEnum = CompoundIdentifierTypeEnum.String });
            enumeratedMeter2.Id.UniqueIds.Add(new UniqueId{ Id = "DLV3", Source = UniqueIdMapper.IsoSource, CiTypeEnum = CompoundIdentifierTypeEnum.String });

            var meters = new List<WorkingData> { enumeratedMeter1, enumeratedMeter2 };

            var spatialRecord = new SpatialRecord();

            const int ddi = 141;
            _representationMapperMock.Setup(x => x.Map(enumeratedMeter1.Representation)).Returns(ddi);

            var enumeratedMeterCreatorMock = new Mock<IEnumeratedMeterCreator>();
            _enumeratedMeterFactoryMock.Setup(x => x.GetMeterCreator(ddi)).Returns(enumeratedMeterCreatorMock.Object);

            const uint value = 0x123456;
            enumeratedMeterCreatorMock.Setup(x => x.GetMetersValue(meters, spatialRecord)).Returns(value);

            var result = _enumeratedValueMapper.Map(enumeratedMeter1, meters, spatialRecord);
            Assert.AreEqual(value, result);
        }
コード例 #16
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);
        }
コード例 #17
0
ファイル: BinaryWriterTest.cs プロジェクト: ADAPT/ISOv4Plugin
        public void Setup()
        {
            _dataPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
            Directory.CreateDirectory(_dataPath);
            _fileName = "test.bin";
            _meters = new List<WorkingData>();
            _spatialRecord = new SpatialRecord {Geometry = new Point {X = 93.6208, Y = 41.5908}};
            _spatialRecords = new List<SpatialRecord> {_spatialRecord};

            _numericMeter = new NumericWorkingData
            {
                Representation = RepresentationInstanceList.vrAvgHarvestMoisture.ToModelRepresentation(),
                UnitOfMeasure = UnitSystemManager.GetUnitOfMeasure("prcnt"),
                DeviceElementUseId = 1
            };

            _enumeratedMeter = new ISOEnumeratedMeter
            {
                Representation = RepresentationInstanceList.dtSkyCondition.ToModelRepresentation(),
                DeviceElementUseId = 1,
                ValueCodes = new List<int> {0, 1, 2}
            };

            _numericValueMapperMock = new Mock<INumericValueMapper>();
            _enumeratedMeterMapperMock = new Mock<IEnumeratedValueMapper>();
            _binaryWriter = new BinaryWriter(_enumeratedMeterMapperMock.Object, _numericValueMapperMock.Object);
        }
コード例 #18
0
ファイル: BinaryWriterTest.cs プロジェクト: ADAPT/ISOv4Plugin
        public void GivenSpatialRecordWithEnumeratedMetersWithSameIdsWhenWriteThenEnumeratedMeterIsCombined()
        {
            var isoEnumeratedMeter = new ISOEnumeratedMeter();
            _meters.AddRange(new List<WorkingData> { isoEnumeratedMeter });

            var spatialRecord = new SpatialRecord
            {
                Timestamp = new DateTime(2000, 1, 1, 8, 0, 0),
                Geometry = new Point {X = 93.6208, Y = 41.5908}
            };
            spatialRecord.SetMeterValue(isoEnumeratedMeter, new EnumeratedValue());
            _spatialRecords = new List<SpatialRecord> {spatialRecord};

            const uint value = 0x12345678;
            _enumeratedMeterMapperMock.Setup(x => x.Map(isoEnumeratedMeter, _meters, spatialRecord)).Returns(value);

            Write();

            var expectedBytes = new List<byte>
            {
                0x00,
                0x74,
                0xB7,
                0x01,
                0x89,
                0x1C, // SpatialRecord1 TimeStart
                0xA0,
                0x40,
                0xCA,
                0x18, // SpatialRecord1 Position North
                0x80,
                0x66,
                0xCD,
                0x37, // SpatialRecord1 Position East
                0x00,
                0x00,
                0x00,
                0x00, // SpatialRecord1 Position Up
            //                0x00,
            //                0x0B,
            //                0x01,
            //                0x03,
            //                0x89,
            //                0x1C, // SpatialRecord1 GpsUtcTime and Date
                0x01, // number of DLVs to follow
                0x00,
                0x78,
                0x56,
                0x34,
                0x12, // DLV0 and value
            };

            VerifyFileContents(expectedBytes, 0);
        }