From 955ed5609a8fab532a5c6c3beb2a23376ee7dc27 Mon Sep 17 00:00:00 2001 From: Kelly Nelson Date: Mon, 10 Jun 2024 10:41:56 -0500 Subject: [PATCH 1/3] Updating dotnet versions of build / test projects --- .github/workflows/ci.yml | 8 ++++---- TestUtilities/TestUtilities.csproj | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 112d2ad3..6085216e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,11 +15,11 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Setup .NET Core SDK '3.1' - uses: actions/setup-dotnet@v1.7.2 + - uses: actions/checkout@v4.1.6 + - name: Setup .NET Core SDK '8.0' + uses: actions/setup-dotnet@v4.0.0 with: - dotnet-version: '3.1' + dotnet-version: '8.0' - name: Install dependencies run: dotnet restore - name: Build diff --git a/TestUtilities/TestUtilities.csproj b/TestUtilities/TestUtilities.csproj index f4f0b582..59f22516 100644 --- a/TestUtilities/TestUtilities.csproj +++ b/TestUtilities/TestUtilities.csproj @@ -1,7 +1,7 @@ - netcoreapp2.0 + net8.0 AgGateway.ADAPT.TestUtilities AgGateway.ADAPT.TestUtilities From 44e7cf5695a3da73a1cebd17c306c8d4f137b792 Mon Sep 17 00:00:00 2001 From: Kelly Nelson Date: Thu, 15 Aug 2024 10:00:47 -0500 Subject: [PATCH 2/3] Adjustment to grouping logic for certain split timelogs --- ISOv4Plugin/Mappers/Factories/TimeLogMapperFactory.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ISOv4Plugin/Mappers/Factories/TimeLogMapperFactory.cs b/ISOv4Plugin/Mappers/Factories/TimeLogMapperFactory.cs index d755bbbe..c3c7c990 100644 --- a/ISOv4Plugin/Mappers/Factories/TimeLogMapperFactory.cs +++ b/ISOv4Plugin/Mappers/Factories/TimeLogMapperFactory.cs @@ -93,7 +93,7 @@ private List HandleDuplicateDataLogValues(List x.DataLogValues) - .Where(x => x.DataLogPGN == null) + .Where(x => x.DataLogPGN == null && x.ProcessDataDDI != "0000") .GroupBy(x => new { x.DeviceElementIdRef, x.ProcessDataDDI }) .Where(x => x.Count() > 1); if (!timeLogGroup.KeepAsGroup && duplicatesByElementAndDDI.Any()) From ac1c84cfd3f20f764b372a726dcf410845fce27e Mon Sep 17 00:00:00 2001 From: Kelly Nelson Date: Wed, 28 Aug 2024 11:42:20 -0500 Subject: [PATCH 3/3] Adding example prescription export. Fixing null reference exception when no Loss of GPS rate set on Grid Type 2 Rx --- Examples/Examples.csproj | 18 +++++ Examples/Program.cs | 2 + Examples/RasterPrescriptions.cs | 81 +++++++++++++++++++++++ ISOv4Plugin.sln | 6 ++ ISOv4Plugin/Mappers/PrescriptionMapper.cs | 2 +- 5 files changed, 108 insertions(+), 1 deletion(-) create mode 100644 Examples/Examples.csproj create mode 100644 Examples/Program.cs create mode 100644 Examples/RasterPrescriptions.cs diff --git a/Examples/Examples.csproj b/Examples/Examples.csproj new file mode 100644 index 00000000..5050edb9 --- /dev/null +++ b/Examples/Examples.csproj @@ -0,0 +1,18 @@ + + + + + + + + + + + + Exe + net8.0 + enable + enable + + + diff --git a/Examples/Program.cs b/Examples/Program.cs new file mode 100644 index 00000000..f4d0a022 --- /dev/null +++ b/Examples/Program.cs @@ -0,0 +1,2 @@ +//Currently one 1 example +RasterPrescriptions.ExportExamplePrescription(); \ No newline at end of file diff --git a/Examples/RasterPrescriptions.cs b/Examples/RasterPrescriptions.cs new file mode 100644 index 00000000..7301d597 --- /dev/null +++ b/Examples/RasterPrescriptions.cs @@ -0,0 +1,81 @@ +//While ISO1173-10 (and this plugin) supports vector prescriptions, industry adoption is limited. +//Raster prescriptions are commonly used. + +using AgGateway.ADAPT.ApplicationDataModel; +using AgGateway.ADAPT.ApplicationDataModel.Common; +using AgGateway.ADAPT.ApplicationDataModel.Products; +using AgGateway.ADAPT.ApplicationDataModel.Prescriptions; +using AgGateway.ADAPT.ApplicationDataModel.Representations; +using AgGateway.ADAPT.ApplicationDataModel.ADM; +using AgGateway.ADAPT.ApplicationDataModel.Shapes; +using AgGateway.ADAPT.ApplicationDataModel.Documents; + +class RasterPrescriptions +{ + public static void ExportExamplePrescription() + { + var adm = new ApplicationDataModel + { + Catalog = new Catalog + { + Products = new List + { + new GenericProduct { Description = "Product 1", Category = CategoryEnum.Fertilizer, ProductType = ProductTypeEnum.Fertilizer, Form = ProductFormEnum.Solid, Status = ProductStatusEnum.Active }, + new GenericProduct { Description = "Product 2", Category = CategoryEnum.Fungicide, ProductType = ProductTypeEnum.Chemical, Form = ProductFormEnum.Liquid, Status = ProductStatusEnum.Active }, + new GenericProduct { Description = "Product 3", Category = CategoryEnum.Herbicide, ProductType = ProductTypeEnum.Chemical, Form = ProductFormEnum.Liquid, Status = ProductStatusEnum.Active }, + new GenericProduct { Description = "Product 4", Category = CategoryEnum.Insecticide, ProductType = ProductTypeEnum.Chemical, Form = ProductFormEnum.Liquid, Status = ProductStatusEnum.Active } + }, + }, + Documents = new Documents() + }; + + var rx = new RasterGridPrescription + { + CellHeight = new NumericRepresentationValue { Value = new NumericValue(new UnitOfMeasure(), 0.001) }, //In ISO1173-10, cell size is listed in degrees of lat/lon + CellWidth = new NumericRepresentationValue { Value = new NumericValue(new UnitOfMeasure(), 0.002) }, + ColumnCount = 10, + RowCount = 5, + OperationType = OperationTypeEnum.SowingAndPlanting, + Origin = new Point { X = -87.60, Y = 41.88 }, //SW Corner + RxProductLookups = adm.Catalog.Products.Select(x => new RxProductLookup { ProductId = x.Id.ReferenceId, UnitOfMeasure = new UnitOfMeasure { } }).ToList(), + ProductIds = adm.Catalog.Products.Select(x => x.Id.ReferenceId).ToList(), + Rates = new List(), + Description = "RasterRx" + }; + + for (int h = 0; h < rx.RowCount; h++) //Rates in ADAPT/ISOXML Raster prescriptions are in a simple list, starting at the SW cell and going row-by-row left to right + { + for (int w = 0; w < rx.ColumnCount; w++) + { + var rates = rx.RxProductLookups.Select((x, i) => new RxRate + { + Rate = h * rx.ColumnCount + w + i * 100, //Dummy rates for the example for illustrative purposes + RxProductLookupId = x.Id.ReferenceId + }).ToList(); + rx.Rates.Add(new RxCellLookup { RxRates = rates }); + } + } + + adm.Catalog.Prescriptions = new List { rx }; + + //The plugin is currently only recognizes Prescriptions mapped through Work Items and Work Item Operations + //See TaskDataMapper.cs at "Tasks" export + var workItemOperation = new WorkItemOperation + { + PrescriptionId = rx.Id.ReferenceId + }; + adm.Documents.WorkItemOperations = new List { workItemOperation }; + + var workItem = new WorkItem + { + WorkItemOperationIds = new List() { workItemOperation.Id.ReferenceId } + }; + adm.Documents.WorkItems = new List { workItem }; + + + var plugin = new AgGateway.ADAPT.ISOv4Plugin.Plugin(); + var properties = new AgGateway.ADAPT.ApplicationDataModel.ADM.Properties(); + properties.SetProperty("GridType", "2"); //ISOXML has 2 formats of grid prescriptions. 2 is the default if this property is omitted. + plugin.Export(adm, System.IO.Directory.GetCurrentDirectory(), properties); //Exports to location of the Examples binary + } +} \ No newline at end of file diff --git a/ISOv4Plugin.sln b/ISOv4Plugin.sln index a62c40b0..5b18ea98 100644 --- a/ISOv4Plugin.sln +++ b/ISOv4Plugin.sln @@ -7,6 +7,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ISOv4Plugin", "ISOv4Plugin\ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestUtilities", "TestUtilities\TestUtilities.csproj", "{98DBD0C7-5677-4B64-8DDA-BDA1E3B3DFCB}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Examples", "Examples\Examples.csproj", "{22ECC922-F80E-4142-9835-455B02A70B63}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -21,6 +23,10 @@ Global {98DBD0C7-5677-4B64-8DDA-BDA1E3B3DFCB}.Debug|Any CPU.Build.0 = Debug|Any CPU {98DBD0C7-5677-4B64-8DDA-BDA1E3B3DFCB}.Release|Any CPU.ActiveCfg = Release|Any CPU {98DBD0C7-5677-4B64-8DDA-BDA1E3B3DFCB}.Release|Any CPU.Build.0 = Release|Any CPU + {22ECC922-F80E-4142-9835-455B02A70B63}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {22ECC922-F80E-4142-9835-455B02A70B63}.Debug|Any CPU.Build.0 = Debug|Any CPU + {22ECC922-F80E-4142-9835-455B02A70B63}.Release|Any CPU.ActiveCfg = Release|Any CPU + {22ECC922-F80E-4142-9835-455B02A70B63}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/ISOv4Plugin/Mappers/PrescriptionMapper.cs b/ISOv4Plugin/Mappers/PrescriptionMapper.cs index f39502b0..d972e47d 100644 --- a/ISOv4Plugin/Mappers/PrescriptionMapper.cs +++ b/ISOv4Plugin/Mappers/PrescriptionMapper.cs @@ -285,7 +285,7 @@ private ISOTreatmentZone ExportTreatmentZonesForType2(ISOTask task, RasterGridPr outOfFieldTreatmentZone.ProcessDataVariables.Add(oofPDV); } - NumericRepresentation defaultRepresentation = productLookup?.LossOfGpsRate.Representation; //We can reuse the loss of gps representation here if it exists + NumericRepresentation defaultRepresentation = productLookup?.LossOfGpsRate?.Representation; //We can reuse the loss of gps representation here if it exists if (defaultRepresentation == null) { //Determine the representation based on the unit of the product to be applied