public EnumeratedValue GetValueForMeter(SpatialValue value, EnumeratedWorkingData meter)
        {
            if (Convert.ToInt32(value.Dlv.A, 16) != DDI)
                return null;

            ApplicationDataModel.Representations.EnumerationMember enumMember = DefinedTypeEnumerationInstanceList.dtiSCMasterUndefined.ToModelEnumMember();

            var reservedBitsMask = 0x00000003;
            var valueLowerTwoBits = (int)value.Value & reservedBitsMask;

            if(valueLowerTwoBits == 0)
                enumMember = DefinedTypeEnumerationInstanceList.dtiSCMasterManualOff.ToModelEnumMember();
            else if (valueLowerTwoBits == 1)
                enumMember = DefinedTypeEnumerationInstanceList.dtiSCMasterAutoOn.ToModelEnumMember();
            else if (valueLowerTwoBits == 2)
                enumMember = DefinedTypeEnumerationInstanceList.dtiSCMasterError.ToModelEnumMember();
            else if (valueLowerTwoBits == 3)
                enumMember = DefinedTypeEnumerationInstanceList.dtiSCMasterUndefined.ToModelEnumMember();

            return new EnumeratedValue
            {
                Representation = meter.Representation as ApplicationDataModel.Representations.EnumeratedRepresentation,
                Value = enumMember,
                Code = enumMember.Code
            };
        }
        public EnumeratedValue GetValueForMeter(SpatialValue value, EnumeratedWorkingData meter)
        {
            if (value == null)
                return null;

            EnumerationMember enumMember;

            if ((int)value.Value == 0)
                enumMember = DefinedTypeEnumerationInstanceList.dtiPrscMasterManualOff.ToModelEnumMember();
            else if ((int)value.Value == 1)
                enumMember = DefinedTypeEnumerationInstanceList.dtiPrscMasterAutoOn.ToModelEnumMember();
            else if ((int)value.Value == 2)
                enumMember = DefinedTypeEnumerationInstanceList.dtiPrscMasterError.ToModelEnumMember();
            else if ((int)value.Value == 3)
                enumMember = DefinedTypeEnumerationInstanceList.dtiPrscMasterUndefined.ToModelEnumMember();
            else
                enumMember = DefinedTypeEnumerationInstanceList.dtiPrscMasterError.ToModelEnumMember();

            return new EnumeratedValue
            {
                Representation = meter.Representation as EnumeratedRepresentation,
                Value = enumMember,
                Code = enumMember.Code
            };
        }
        public EnumeratedValue GetValueForMeter(SpatialValue value, EnumeratedWorkingData meter)
        {
            if (Convert.ToInt32(value.Dlv.A, 16) != DDI)
                return null;

            ApplicationDataModel.Representations.EnumerationMember enumMember = null;

            if (value.Value == 1)
                enumMember = DefinedTypeEnumerationInstanceList.dtiDrawbar.ToModelEnumMember();
            else if (value.Value == 2)
                enumMember = DefinedTypeEnumerationInstanceList.dtiRearTwoPoint.ToModelEnumMember();
            else if (value.Value == 3)
                enumMember = DefinedTypeEnumerationInstanceList.dtiThreePoint.ToModelEnumMember();
            else if (value.Value == 7)
                enumMember = DefinedTypeEnumerationInstanceList.dtiRearPivotWagonHitch.ToModelEnumMember();

            if (enumMember == null)
                return null;

            return new EnumeratedValue
            {
                Representation = meter.Representation as ApplicationDataModel.Representations.EnumeratedRepresentation,
                Value = enumMember,
                Code = enumMember.Code
            };
        }
 public EnumeratedValue GetValueForMeter(SpatialValue value, EnumeratedWorkingData meter)
 {
     var enumMember = value != null && value.Value == 1
         ? DefinedTypeEnumerationInstanceList.dtiRecordingStatusOn.ToModelEnumMember()
         : DefinedTypeEnumerationInstanceList.dtiRecordingStatusOff.ToModelEnumMember();
     return new EnumeratedValue
     {
         Representation = meter.Representation as EnumeratedRepresentation,
         Value = enumMember,
         Code = enumMember.Code
     };
 }
 private void SetEnumeratedMeterValue(ISOSpatialRow isoSpatialRow, EnumeratedWorkingData meter, SpatialRecord spatialRecord)
 {
     var isoValue = isoSpatialRow.SpatialValues.SingleOrDefault(v => v.Id == meter.Id.FindIntIsoId());
     if (isoValue != null)
     {
         var isoEnumeratedMeter = meter as ISOEnumeratedMeter;
         var enumeratedValue = isoEnumeratedMeter.GetEnumeratedValue(isoValue, isoEnumeratedMeter);
         spatialRecord.SetMeterValue(meter, enumeratedValue);
         _representationValueInterpolator.SetMostRecentMeterValue(meter, enumeratedValue);
     }
     else
     {
         var value = _representationValueInterpolator.Interpolate(meter) as EnumeratedValue;
         spatialRecord.SetMeterValue(meter, value);
     }
 }
        public EnumeratedValue GetValueForMeter(SpatialValue value, EnumeratedWorkingData meter)
        {
            if (Convert.ToInt32(value.Dlv.A, 16) != DDI)
                return null;

            ApplicationDataModel.Representations.EnumerationMember enumMember;

            if (value.Value == 0)
                enumMember = DefinedTypeEnumerationInstanceList.dtiWeightUnStable.ToModelEnumMember();
            else if (value.Value == 1)
                enumMember = DefinedTypeEnumerationInstanceList.dtiWeightStable.ToModelEnumMember();
            else if (value.Value == 2)
                enumMember = DefinedTypeEnumerationInstanceList.dtiWeightError.ToModelEnumMember();
            else
                return null;

            return new EnumeratedValue
            {
                Representation = meter.Representation as ApplicationDataModel.Representations.EnumeratedRepresentation,
                Value = enumMember,
                Code = enumMember.Code
            };
        }
        public EnumeratedValue GetValueForMeter(SpatialValue value, EnumeratedWorkingData meter)
        {
            if (Convert.ToInt32(value.Dlv.A, 16) != DDI)
                return null;

            const int clear = 0x20524C43;
            const int mostlySunny = 0x2043534E;
            const int partlySunny = 0x20574546;
            const int partlyCloudy = 0x20544353;
            const int mostlyCloudy = 0x204E4B42;
            const int overcast = 0x2043564F;

            ApplicationDataModel.Representations.EnumerationMember enumMember;

            if (value.Value == clear)
                enumMember = DefinedTypeEnumerationInstanceList.dtiClear.ToModelEnumMember();
            else if (value.Value == mostlySunny)
                enumMember = DefinedTypeEnumerationInstanceList.dtiSunny.ToModelEnumMember();
            else if (value.Value == partlySunny)
                enumMember = DefinedTypeEnumerationInstanceList.dtiPartlyCloudy.ToModelEnumMember();
            else if (value.Value == partlyCloudy)
                enumMember = DefinedTypeEnumerationInstanceList.dtiPartlyCloudy.ToModelEnumMember();
            else if (value.Value == mostlyCloudy)
                enumMember = DefinedTypeEnumerationInstanceList.dtiCloudy.ToModelEnumMember();
            else if (value.Value == overcast)
                enumMember = DefinedTypeEnumerationInstanceList.dtiCloudy.ToModelEnumMember();
            else
                return null;

            return new EnumeratedValue
            {
                Representation = meter.Representation as ApplicationDataModel.Representations.EnumeratedRepresentation,
                Value = enumMember,
                Code = enumMember.Code
            };
        }
        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 } }
            };
        }
        public void GivenDdiAndSpatialValueWithNotInstalledStateWhenGetValueForMeterThenPrescriptionNotUsedIsReturned()
        {
            var spatialValue = new SpatialValue
            {
                Dlv = new DLV
                {
                    A = "16F"
                },
                Value = 3
            };

            var meter = new EnumeratedWorkingData
            {
                DeviceElementUseId = 1
            };

            var result = new CondensedSectionOverrideStateMeterCreator(367).GetValueForMeter(spatialValue, meter);

            Assert.AreEqual(DefinedTypeEnumerationInstanceList.dtiPrescriptionNotUsed.ToModelEnumMember().Value, result.Value.Value);
        }
        public EnumeratedValue GetValueForMeter(SpatialValue value, EnumeratedWorkingData meter)
        {
            var sectionValue = GetSectionValue((uint)value.Value, meter.DeviceElementUseId);
            var enumerationMember = SectionValueToEnumerationMember[(int)sectionValue];

            return new EnumeratedValue
            {
                Representation = meter.Representation as EnumeratedRepresentation,
                Value = enumerationMember.ToModelEnumMember(),
                Code = (int)enumerationMember.DomainTag
            };
        }
        public void GivenDdiAndSpatialValueWithNotInstalledStateWhenGetValueForMeterThenSectionValueOffIsReturned()
        {
            var spatialValue = new SpatialValue
            {
                Dlv = new DLV
                {
                    A = "A1"
                },
                Value = 3
            };

            var meter = new EnumeratedWorkingData
            {
                DeviceElementUseId = 1
            };

            var result = new CondensedWorkStateMeterCreator(161, 161).GetValueForMeter(spatialValue, meter);

            Assert.AreEqual(DefinedTypeEnumerationInstanceList.dtiRecordingStatusOff.ToModelEnumMember().Value, result.Value.Value);
        }
        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]);
        }
        public void GivenOperationDataWithSpatialRecordDataWithNullMeterWhenProcessOperationDataThenRowsAreAdded()
        {
            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();

            _spatialRecords.Add(spatialRecord);

            var dataTable = _operationDataProcessor.ProcessOperationData(_operationData);

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