public static void AreEqual(ISOSpatialRow isoSpatialRow, SpatialRecord adaptSpatialRecord, IEnumerable<WorkingData> meters) { foreach (var meter in meters) { var isoValue = isoSpatialRow.SpatialValues.SingleOrDefault(v => v.Id == meter.Id.FindIntIsoId()); if(isoValue == null) continue; if (meter is NumericWorkingData) { var numericMeter = meter as NumericWorkingData; var numericRepresentationValue = (NumericRepresentationValue)adaptSpatialRecord.GetMeterValue(numericMeter); if (isoValue != null) Assert.AreEqual(isoValue.Value, numericRepresentationValue.Value.Value); } if (meter is EnumeratedWorkingData) { var isoEnumeratedMeter = meter as ISOEnumeratedMeter; var enumeratedValue = isoEnumeratedMeter.GetEnumeratedValue(isoValue, isoEnumeratedMeter); Assert.AreEqual(enumeratedValue.Representation.Description, meter.Representation.Description); } } }
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); }
private static void CreateNumericMeterCell(SpatialRecord spatialRecord, WorkingData workingData, int depth, DataRow dataRow) { var numericRepresentationValue = spatialRecord.GetMeterValue(workingData) as NumericRepresentationValue; var value = numericRepresentationValue != null ? numericRepresentationValue.Value.Value.ToString(CultureInfo.InvariantCulture) : ""; dataRow[GetColumnName(workingData, depth)] = value; }
public UInt32 GetMetersValue(List<WorkingData> meters, SpatialRecord spatialRecord) { var meter = (ISOEnumeratedMeter) meters.SingleOrDefault(); var value = (EnumeratedValue)spatialRecord.GetMeterValue(meter); if (value.Value.Code == DefinedTypeEnumerationInstanceList.dtiRecordingStatusOn.ToModelEnumMember().Code) return 1; if (value.Value.Code == DefinedTypeEnumerationInstanceList.dtiRecordingStatusOff.ToModelEnumMember().Code) return 0; return 3; }
public UInt32 GetMetersValue(List<WorkingData> meters, SpatialRecord spatialRecord) { var meter = (ISOEnumeratedMeter) meters.FirstOrDefault(); var value = (EnumeratedValue)spatialRecord.GetMeterValue(meter); if (value.Value.Code == DefinedTypeEnumerationInstanceList.dtiPrscMasterManualOff.ToModelEnumMember().Code) return 0; if (value.Value.Code == DefinedTypeEnumerationInstanceList.dtiPrscMasterAutoOn.ToModelEnumMember().Code) return 1; if (value.Value.Code == DefinedTypeEnumerationInstanceList.dtiPrscMasterError.ToModelEnumMember().Code) return 2; return 3; }
public static void AreEqual(ISOSpatialRow isoSpatialRow, SpatialRecord adaptSpatialRecord, List<WorkingData> meters) { foreach (var meter in meters) { var adaptValue = adaptSpatialRecord.GetMeterValue(meter); if(adaptValue == null) continue; var isoValue = isoSpatialRow.SpatialValues.Single(v => v.Id == meter.Id.FindIntIsoId()); var adaptEnumeratedValue = adaptValue as EnumeratedValue; if (adaptEnumeratedValue != null) { var representation = RepresentationManager.Instance.Representations.First(x => x.DomainId == adaptEnumeratedValue.Representation.Code); Assert.AreEqual(representation.Ddi.GetValueOrDefault(), Convert.ToInt32(isoValue.Dlv.A, 16)); if(representation.Ddi == 141) CompareWorkState(adaptEnumeratedValue, isoValue); if (representation.Ddi == 157) CompareConnectorType(adaptEnumeratedValue, isoValue); if (representation.Ddi == 158) ComparePrescriptionControl(adaptEnumeratedValue, isoValue); if (representation.Ddi == 160) CompareSectionControlState(adaptEnumeratedValue, isoValue); if (representation.Ddi >= 161 && representation.Ddi <= 176) CompareCondensedWorkState(adaptEnumeratedValue, isoValue); if (representation.Ddi == 210) CompareSkyConditions(adaptEnumeratedValue, isoValue); if (representation.Ddi == 230) CompareNetWeightState(adaptEnumeratedValue, isoValue); if (representation.Ddi == 240) CompareActualLoadingSystemStatus(adaptEnumeratedValue, isoValue); if (representation.Ddi >= 290 && representation.Ddi < 305) CompareCondensedWorkState(adaptEnumeratedValue, isoValue); if (representation.Ddi >= 367 && representation.Ddi <= 382) CompareCondensedSectionOverrideState(adaptEnumeratedValue, isoValue); } var adaptNumericValue = adaptValue as NumericRepresentationValue; if (adaptNumericValue != null) { var representation = RepresentationManager.Instance.Representations.FirstOrDefault(x => x.DomainId == adaptNumericValue.Representation.Code); if (representation != null) Assert.AreEqual(representation.Ddi, Convert.ToInt32(isoValue.Dlv.A, 16)); Assert.AreEqual(adaptNumericValue.Value.Value, isoValue.Value); } } }
public UInt32 GetMetersValue(List<WorkingData> meters, SpatialRecord spatialRecord) { var meter = (ISOEnumeratedMeter) meters.FirstOrDefault(); var value = (EnumeratedValue) spatialRecord.GetMeterValue(meter); if (value.Value.Code == DefinedTypeEnumerationInstanceList.dtiClear.ToModelEnumMember().Code) return 0x20524C43; if (value.Value.Code == DefinedTypeEnumerationInstanceList.dtiSunny.ToModelEnumMember().Code) return 0x2043534E; if (value.Value.Code == DefinedTypeEnumerationInstanceList.dtiPartlyCloudy.ToModelEnumMember().Code) return 0x20544353; if (value.Value.Code == DefinedTypeEnumerationInstanceList.dtiCloudy.ToModelEnumMember().Code) return 0x2043564F; return 0; }
public UInt32 GetMetersValue(List<WorkingData> meters, SpatialRecord spatialRecord) { var meter = (ISOEnumeratedMeter) meters.FirstOrDefault(); var value = (EnumeratedValue) spatialRecord.GetMeterValue(meter); if (value.Value.Code == DefinedTypeEnumerationInstanceList.dtiDrawbar.ToModelEnumMember().Code) return 1; if (value.Value.Code == DefinedTypeEnumerationInstanceList.dtiRearTwoPoint.ToModelEnumMember().Code) return 2; if (value.Value.Code == DefinedTypeEnumerationInstanceList.dtiThreePoint.ToModelEnumMember().Code) return 3; if (value.Value.Code == DefinedTypeEnumerationInstanceList.dtiRearPivotWagonHitch.ToModelEnumMember().Code) return 7; return 0; }
private Dictionary<int, uint> GetMeterValues(SpatialRecord spatialRecord, List<WorkingData> meters, Dictionary<WorkingData, int> metersByIsoIds) { var dlvsToWrite = new Dictionary<int, uint>(); var metersWithValues = meters.Where(x => spatialRecord.GetMeterValue(x) != null); var dlvOrders = metersWithValues.Select(m => metersByIsoIds[m]).Distinct(); foreach (var order in dlvOrders) { var dlvMeters = meters.Where(m => metersByIsoIds[m] == order).ToList(); var numericMeter = dlvMeters[0] as NumericWorkingData; UInt32? value = null; if (numericMeter != null && spatialRecord.GetMeterValue(numericMeter) != null) { value = _numericValueMapper.Map(numericMeter, spatialRecord); } var isoEnumerateMeter = dlvMeters[0] as ISOEnumeratedMeter; if (isoEnumerateMeter != null && spatialRecord.GetMeterValue(isoEnumerateMeter) != null) { value = _enumeratedValueMapper.Map(isoEnumerateMeter, dlvMeters, spatialRecord); } if (value == null) continue; if (_previousDlvs.ContainsKey(order) && _previousDlvs[order] != value) { _previousDlvs[order] = value.Value; dlvsToWrite.Add(order, value.Value); } else if (!_previousDlvs.ContainsKey(order)) { _previousDlvs.Add(order, value.Value); dlvsToWrite.Add(order, value.Value); } } return dlvsToWrite; }
public override UInt32 GetMetersValue(List<WorkingData> meters, SpatialRecord spatialRecord) { var returnValue = new UInt32(); for (int i = 0; i < meters.Count; i++) { var sectionId = ((DDI - StartingDdi) * 16) + (i + 1); var meter = (ISOEnumeratedMeter)meters.SingleOrDefault(x => x.DeviceElementUseId == sectionId); var value = (EnumeratedValue)spatialRecord.GetMeterValue(meter); int meterInt; if (value.Value.Code == DefinedTypeEnumerationInstanceList.dtiPrescriptionUsed.ToModelEnumMember().Code) meterInt = 0; else if (value.Value.Code == DefinedTypeEnumerationInstanceList.dtiPrescriptionOverridden.ToModelEnumMember().Code) meterInt = 1; else meterInt = 3; returnValue |= Convert.ToUInt32(meterInt << (i * 2)); } return returnValue; }
private Dictionary<int, uint> GetMeterValuesAndAssignDlvNumbers(SpatialRecord spatialRecord, List<WorkingData> meters) { var dlvValues = new Dictionary<int, uint>(); for (int meterIndex = 0; meterIndex < meters.Count; meterIndex++) { var meter = meters[meterIndex]; var numericMeter = meter as NumericWorkingData; UInt32? value = null; if (numericMeter != null && spatialRecord.GetMeterValue(numericMeter) != null) { value = _numericValueMapper.Map(numericMeter, spatialRecord); } var isoEnumerateMeter = meter as ISOEnumeratedMeter; if (isoEnumerateMeter != null && spatialRecord.GetMeterValue(isoEnumerateMeter) != null) { value = _enumeratedValueMapper.Map(isoEnumerateMeter, new List<WorkingData> {meter}, spatialRecord); } if (value == null) continue; if (_previousDlvs.ContainsKey(meterIndex) && _previousDlvs[meterIndex] != value) { _previousDlvs[meterIndex] = value.Value; dlvValues.Add(meterIndex, value.Value); } else if (!_previousDlvs.ContainsKey(meterIndex)) { _previousDlvs.Add(meterIndex, value.Value); dlvValues.Add(meterIndex, value.Value); } } return dlvValues; }
private static void CreateEnumeratedMeterCell(SpatialRecord spatialRecord, WorkingData workingData, int depth, DataRow dataRow) { var enumeratedValue = spatialRecord.GetMeterValue(workingData) as EnumeratedValue; dataRow[GetColumnName(workingData, depth)] = enumeratedValue != null && enumeratedValue.Value != null ? enumeratedValue.Value.Value : ""; }