From 52172bafcf627a47b93b1e3021c148e71d3232e2 Mon Sep 17 00:00:00 2001 From: Eric Pohl Date: Mon, 23 Jun 2025 10:14:03 -0400 Subject: [PATCH 1/3] Handle null representation code when examining workingdatas --- ISOv4Plugin/ExtensionMethods/ExtensionMethods.cs | 7 +++++++ ISOv4Plugin/Mappers/TimeLogMapper.cs | 8 ++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/ISOv4Plugin/ExtensionMethods/ExtensionMethods.cs b/ISOv4Plugin/ExtensionMethods/ExtensionMethods.cs index 66a5615..0949024 100644 --- a/ISOv4Plugin/ExtensionMethods/ExtensionMethods.cs +++ b/ISOv4Plugin/ExtensionMethods/ExtensionMethods.cs @@ -95,6 +95,13 @@ public static bool ReverseEquals(this string s1, string s2) return true; } + /// + /// Matches NumericRepresentation by code, accounting for null representation code + /// + public static bool ContainsCode(this ApplicationDataModel.Representations.Representation representation, string code) + { + return representation?.Code != null && representation.Code.Contains(code); + } /// /// Looks up unit, converts and loads representation diff --git a/ISOv4Plugin/Mappers/TimeLogMapper.cs b/ISOv4Plugin/Mappers/TimeLogMapper.cs index f0eccf2..4bbbd14 100644 --- a/ISOv4Plugin/Mappers/TimeLogMapper.cs +++ b/ISOv4Plugin/Mappers/TimeLogMapper.cs @@ -431,17 +431,17 @@ protected IEnumerable ImportTimeLog(ISOTask loggedTask, ISOTimeLo private OperationTypeEnum? GetOperationTypeFromWorkingDatas(List workingDatas) { //Harvest/ForageHarvest omitted intentionally to be determined from machine type vs. working data - if (workingDatas.Any(w => w.Representation.Code.Contains("Seed"))) + if (workingDatas.Any(w => w.Representation.ContainsCode("Seed"))) { return OperationTypeEnum.SowingAndPlanting; } - else if (workingDatas.Any(w => w.Representation.Code.Contains("Tillage"))) + else if (workingDatas.Any(w => w.Representation.ContainsCode("Tillage"))) { return OperationTypeEnum.Tillage; } - if (workingDatas.Any(w => w.Representation.Code.Contains("AppRate"))) + if (workingDatas.Any(w => w.Representation.ContainsCode("AppRate"))) { - return OperationTypeEnum.Unknown; //We can't differentiate CropProtection from Fertilizing, but prefer unkonwn to letting implement type set to SowingAndPlanting + return OperationTypeEnum.Unknown; //We can't differentiate CropProtection from Fertilizing, but prefer unknown to letting implement type set to SowingAndPlanting } return null; } From ab75c2f8f78604cdc3a17a7bcd178568049d64ba Mon Sep 17 00:00:00 2001 From: Andrew Vardeman Date: Wed, 30 Jul 2025 13:07:40 -0500 Subject: [PATCH 2/3] Keep valuable operation information from device when possible --- ISOv4Plugin/Mappers/TimeLogMapper.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/ISOv4Plugin/Mappers/TimeLogMapper.cs b/ISOv4Plugin/Mappers/TimeLogMapper.cs index 4bbbd14..5c7e1e9 100644 --- a/ISOv4Plugin/Mappers/TimeLogMapper.cs +++ b/ISOv4Plugin/Mappers/TimeLogMapper.cs @@ -409,8 +409,7 @@ protected IEnumerable ImportTimeLog(ISOTask loggedTask, ISOTimeLo operationData.GetDeviceElementUses = x => operationData.DeviceElementUses.Where(s => s.Depth == x).ToList(); operationData.PrescriptionId = prescriptionID; operationData.OperationType = GetOperationTypeFromProductCategory(productIDs) ?? - GetOperationTypeFromWorkingDatas(workingDatas) ?? - GetOperationTypeFromLoggingDevices(time); + OverrideOperationTypeFromWorkingDatas(GetOperationTypeFromLoggingDevices(time), workingDatas); operationData.ProductIds = productIDs; if (!useDeferredExecution) { @@ -428,7 +427,7 @@ protected IEnumerable ImportTimeLog(ISOTask loggedTask, ISOTimeLo return null; } - private OperationTypeEnum? GetOperationTypeFromWorkingDatas(List workingDatas) + private OperationTypeEnum OverrideOperationTypeFromWorkingDatas(OperationTypeEnum deviceOperationType, List workingDatas) { //Harvest/ForageHarvest omitted intentionally to be determined from machine type vs. working data if (workingDatas.Any(w => w.Representation.ContainsCode("Seed"))) @@ -441,9 +440,12 @@ protected IEnumerable ImportTimeLog(ISOTask loggedTask, ISOTimeLo } if (workingDatas.Any(w => w.Representation.ContainsCode("AppRate"))) { - return OperationTypeEnum.Unknown; //We can't differentiate CropProtection from Fertilizing, but prefer unknown to letting implement type set to SowingAndPlanting + if (deviceOperationType != OperationTypeEnum.Fertilizing && deviceOperationType != OperationTypeEnum.CropProtection) + { + return OperationTypeEnum.Unknown; //We can't differentiate CropProtection from Fertilizing, but prefer unknown to letting implement type set to SowingAndPlanting + } } - return null; + return deviceOperationType; } private List> SplitElementsByProductProperties(Dictionary> productAllocations, HashSet loggedDeviceElementIds, ISODevice dvc) From d81d4d888488a6a091275422c3092705a6d73ecc Mon Sep 17 00:00:00 2001 From: Andrew Vardeman Date: Thu, 7 Aug 2025 14:23:33 -0500 Subject: [PATCH 3/3] Two fixes for reading CNH Pro1200 Harvest data: - Stop forcing CategoryEnum.Variety to OperationTypeEnum.SowingAndPlanting (could be Harvesting) - In GetOperationTypeFromLoggingDevices, prefer a non-Unknown operation type --- ISOv4Plugin/Mappers/TimeLogMapper.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/ISOv4Plugin/Mappers/TimeLogMapper.cs b/ISOv4Plugin/Mappers/TimeLogMapper.cs index 5c7e1e9..4922ace 100644 --- a/ISOv4Plugin/Mappers/TimeLogMapper.cs +++ b/ISOv4Plugin/Mappers/TimeLogMapper.cs @@ -684,9 +684,6 @@ private void AddProductAllocationsForDeviceElement(Dictionary t.ClientNAMEMachineType >= 2 && t.ClientNAMEMachineType <= 11); + DeviceOperationType deviceType = representedTypes.FirstOrDefault(t => t.ClientNAMEMachineType >= 2 && t.ClientNAMEMachineType <= 11 && + t.OperationType != OperationTypeEnum.Unknown); + if (deviceType != null) { //2-11 represent known types of operations