コード例 #1
0
        public void GivenOperationDataWithSpatialRecordDataWithNumericRepValueWhenProcessOperationDAtaThenRowsAreAdded()
        {
            var harvestMoistureMeter = new NumericWorkingData { Representation = RepresentationInstanceList.vrHarvestMoisture.ToModelRepresentation() };
            _workingDatas.Add(harvestMoistureMeter);
            _deviceElementUses.Add(0, new List<DeviceElementUse>
            {
                new DeviceElementUse
                {
                    Depth = 0,
                    GetWorkingDatas = () => _workingDatas,
                }
            });

            var spatialRecord = new SpatialRecord();
            var numericRepresentation = new NumericRepresentationValue(RepresentationInstanceList.vrHarvestMoisture.ToModelRepresentation(), UnitSystemManager.GetUnitOfMeasure("prcnt"), new NumericValue(UnitSystemManager.GetUnitOfMeasure("prcnt"), 3.0));

            spatialRecord.SetMeterValue(harvestMoistureMeter, numericRepresentation);

            _spatialRecords.Add(spatialRecord);

            var dataTable = _operationDataProcessor.ProcessOperationData(_operationData);

            Assert.AreEqual(1, dataTable.Rows.Count);
            Assert.AreEqual(numericRepresentation.Value.Value.ToString(), dataTable.Rows[0][0]);
        }
コード例 #2
0
        public void GivenMetersWhenMapThenMetersAreSorted()
        {
            _meter.Id.UniqueIds.Add(new UniqueId
            {
                Id = "DLV3",
                CiTypeEnum = CompoundIdentifierTypeEnum.String,
                Source = UniqueIdMapper.IsoSource
               });
            _meter.Representation = RepresentationInstanceList.vrYieldMass.ToModelRepresentation();
            _representationMapperMock.Setup(x => x.Map(_meter.Representation)).Returns(5);
            _meters.Add(_meter);

            var meter1 = new NumericWorkingData();
            meter1.Id.UniqueIds.Add(new UniqueId
            {
                Id = "DLV1",
                CiTypeEnum = CompoundIdentifierTypeEnum.String,
                Source = UniqueIdMapper.IsoSource
            });
            meter1.Representation = RepresentationInstanceList.vrYieldMass.ToModelRepresentation();
            _representationMapperMock.Setup(x => x.Map(meter1.Representation)).Returns(8);
            _meters.Add(meter1);

            var result = Map().ToList();
            Assert.AreEqual(8.ToString(), result[0].A);
            Assert.AreEqual(5.ToString(), result[1].A);
        }
コード例 #3
0
        public uint Map(NumericWorkingData meter, SpatialRecord spatialRecord)
        {
            var value = (NumericRepresentationValue)spatialRecord.GetMeterValue(meter);
            if (value == null)
                return 0;

            var resolution = GetResolution(value);
            return (UInt32)(value.Value.Value / resolution);
        }
コード例 #4
0
        public void Setup()
        {
            _interpolator = new RepresentationValueInterpolator();

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

            _enumeratedMeter = 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 } }
            };
        }
コード例 #5
0
ファイル: MeterMapper.cs プロジェクト: ADAPT/ISOv4Plugin
 private NumericWorkingData MapNumericMeter(DLV dlv, int sectionId, int order)
 {
     var meter = new NumericWorkingData
     {
         UnitOfMeasure = _representationMapper.GetUnitForDdi(Convert.ToInt32(dlv.A, 16)),
         DeviceElementUseId = sectionId,
         Representation = _representationMapper.Map(Convert.ToInt32(dlv.A, 16))
     };
     meter.Id.UniqueIds.Add(_uniqueIdMapper.Map("DLV" + order));
     return meter;
 }
コード例 #6
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);
        }
コード例 #7
0
        private void SetNumericMeterValue(ISOSpatialRow isoSpatialRow, NumericWorkingData meter, SpatialRecord spatialRecord)
        {
            var isoValue = isoSpatialRow.SpatialValues.SingleOrDefault(v => v.Id == meter.Id.FindIntIsoId());

            if (isoValue != null)
            {
                var value = new NumericRepresentationValue(meter.Representation as NumericRepresentation, meter.UnitOfMeasure, new NumericValue(meter.UnitOfMeasure, isoValue.Value));
                spatialRecord.SetMeterValue(meter, value);

                var other = new NumericRepresentationValue(meter.Representation as NumericRepresentation, meter.UnitOfMeasure, new NumericValue(meter.UnitOfMeasure, isoValue.Value));
                _representationValueInterpolator.SetMostRecentMeterValue(meter, other);
            }
            else
            {
                var value = _representationValueInterpolator.Interpolate(meter) as NumericRepresentationValue;
                spatialRecord.SetMeterValue(meter, value);
            }
        }
コード例 #8
0
        public void GivenIsoSpatialRowAndMeterWhenMapThenSpatialRecordContainsMeterValue()
        {
            var spatialValue = new SpatialValue
            {
                Id = 0,
                Value = 12.3
            };
            _isoSpatialRow.SpatialValues = new List<SpatialValue> { spatialValue };
            _isoSpatialRows.Add(_isoSpatialRow);

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

            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 NumericRepresentationValue;

            Assert.AreEqual(12.3, meterValue.Value.Value);
        }
コード例 #9
0
        public void GivenIsoSpatialRowWithoutMeterWhenMapThenInterpolatorIsCalled()
        {
            var spatialValue = new SpatialValue
            {
                Id = 0,
                Value = 12.3
            };
            _isoSpatialRow.SpatialValues = new List<SpatialValue> { spatialValue };

            var isoSpatialRow2 = new ISOSpatialRow { SpatialValues = new List<SpatialValue>() };

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

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

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

            Map().ToList();
            _spatialValueInterpolator.Verify(s => s.Interpolate(It.IsAny<WorkingData>()));
        }
コード例 #10
0
        public void GivenIsoSpatialRowsWithoutNumericMeterOnSecondWhenMapThenSecondValueIsInterpolator()
        {
            var spatialValue = new SpatialValue
            {
                Id = 0,
                Value = 12.3
            };
            _isoSpatialRow.SpatialValues = new List<SpatialValue> { spatialValue };

            var isoSpatialRow2 = new ISOSpatialRow { SpatialValues = new List<SpatialValue>() };

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

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

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

            var numericRepresentation = new NumericRepresentationValue(meter.Representation as NumericRepresentation,
                    meter.UnitOfMeasure, new NumericValue(meter.UnitOfMeasure, 2.3));

            _spatialValueInterpolator.Setup(s => s.Interpolate(meter)).Returns(numericRepresentation);

            var result = Map().ToList();

            Assert.AreEqual(numericRepresentation, result[1].GetMeterValue(meter) as NumericRepresentationValue);
        }
コード例 #11
0
        public void GivenOperationDataWithSpatialRecordDataWithNumericRepValueWhenProcessOperationDataThenColumnNamesContainUom()
        {
            var harvestMoistureMeter = new NumericWorkingData { Representation = RepresentationInstanceList.vrHarvestMoisture.ToModelRepresentation() };
            _workingDatas.Add(harvestMoistureMeter);
            _deviceElementUses.Add(0, new List<DeviceElementUse>
            {
                new DeviceElementUse
                {
                    Depth = 0,
                    GetWorkingDatas = () => _workingDatas,
                }
            });

            var spatialRecord = new SpatialRecord();
            var numericRepresentation = new NumericRepresentationValue(RepresentationInstanceList.vrHarvestMoisture.ToModelRepresentation(), UnitSystemManager.GetUnitOfMeasure("prcnt"), new NumericValue(UnitSystemManager.GetUnitOfMeasure("prcnt"), 3.0));

            spatialRecord.SetMeterValue(harvestMoistureMeter, numericRepresentation);

            _spatialRecords.Add(spatialRecord);

            var dataTable = _operationDataProcessor.ProcessOperationData(_operationData);

            var expectedColumnName = _workingDatas.First().Representation.Code + "-" + _workingDatas.First().Id.ReferenceId + "-0-" +  numericRepresentation.Value.UnitOfMeasure.Code;
            Assert.AreEqual(expectedColumnName, dataTable.Columns[0].ColumnName);
        }