commented out the totalNfertiliserInput = totalNferiliserCropfield check

master
ttenden 2024-05-27 15:35:25 +02:00
parent 6d6b5b1b7a
commit c2e4f9d861
1 changed files with 23 additions and 24 deletions

View File

@ -92,7 +92,7 @@ namespace FarmmapsKPI
int nrun = 1; int nrun = 1;
for (int run = 1; run <= nrun; run++) { for (int run = 1; run <= nrun; run++) {
for (int i = 0; i < fieldsInputs.Count; i++) for (int i = 0; i < fieldsInputs.Count; i++)
//for (int i = 3; i < 4; i++) // for testing //for (int i = 6; i < 7; i++) // for testing
{ {
watch.Restart(); watch.Restart();
input = fieldsInputs[i]; input = fieldsInputs[i];
@ -130,8 +130,8 @@ namespace FarmmapsKPI
int targetKPIitemsCount; //if we know we should be getting 8 KPI items (A1,B1,B2,C1,D1,E1,F1,F2) int targetKPIitemsCount; //if we know we should be getting 8 KPI items (A1,B1,B2,C1,D1,E1,F1,F2)
int maxtries = 5; // but don't keep on trying forever; there is a maximum number of tries int maxtries = 5; // but don't keep on trying forever; there is a maximum number of tries
int trycnt; int trycnt;
double totalNferiliserInput = 0; //double totalNferiliserInput = 0;
double totalNferiliserCropfield = 0; //double totalNferiliserCropfield = 0;
string downloadFolder = input.DownloadFolder; string downloadFolder = input.DownloadFolder;
if (string.IsNullOrEmpty(downloadFolder)) { if (string.IsNullOrEmpty(downloadFolder)) {
@ -325,7 +325,7 @@ namespace FarmmapsKPI
crpOperationItems.Add(crpOperationItem); crpOperationItems.Add(crpOperationItem);
crpOperationItemCodes.Add(crpOperationItem.Code); crpOperationItemCodes.Add(crpOperationItem.Code);
//Keep track of totalNferiliserInput //Keep track of totalNferiliserInput
totalNferiliserInput = totalNferiliserInput + (double)data.n; //totalNferiliserInput = totalNferiliserInput + (double)data.n; / this causes a problem if N content of the fertilizer is missing. As this check is no longer needed I just commented it out
} }
_settings.OperationItemCodes = crpOperationItemCodes.ToArray(); _settings.OperationItemCodes = crpOperationItemCodes.ToArray();
SaveSettings(settingsfile); SaveSettings(settingsfile);
@ -371,17 +371,17 @@ namespace FarmmapsKPI
} }
//Check totalNfertiliser input and Cropfield //Check totalNfertiliser input and Cropfield,
for (int o = 0; o < crprecChildren.Count; o++) //for (int o = 0; o < crprecChildren.Count; o++)
{ //{
dynamic data = JObject.Parse(crprecChildren[o].Data.ToString()); // dynamic data = JObject.Parse(crprecChildren[o].Data.ToString());
totalNferiliserCropfield = totalNferiliserCropfield + (double)data.n; // totalNferiliserCropfield = totalNferiliserCropfield + (double)data.n;
} //}
if (totalNferiliserInput != totalNferiliserCropfield) //if (totalNferiliserInput != totalNferiliserCropfield)
{ //{
_logger.LogWarning(String.Format($"2. run {run}: totalNferiliserInput != totalNferiliserCropfield?!")); // _logger.LogWarning(String.Format($"2. run {run}: totalNferiliserInput != totalNferiliserCropfield?!"));
//throw new Exception(String.Format($"run {run}: totalNferiliserInput != totalNferiliserCropfield?!")); // //throw new Exception(String.Format($"run {run}: totalNferiliserInput != totalNferiliserCropfield?!"));
} //}
//Now get the KPIs for this cropfield, mounted with operations & cropyield //Now get the KPIs for this cropfield, mounted with operations & cropyield
List<Item> KPIItems = await _generalService.GetKpiItemsForCropField(cropfieldItem, 3); List<Item> KPIItems = await _generalService.GetKpiItemsForCropField(cropfieldItem, 3);
@ -564,15 +564,14 @@ namespace FarmmapsKPI
sw.WriteLine(string.Join(",", dataList)); sw.WriteLine(string.Join(",", dataList));
//Check if totalNferiliserInput is equal to what comes out of the KPI calculation //Check if totalNferiliserInput is equal to what comes out of the KPI calculation
//PO20240515: Hier gaat het mis!!! //if (elementName == "nFertilizerNKgHa")
if (elementName == "nFertilizerNKgHa") //{
{ // if (totalNferiliserInput != Convert.ToDouble(elementValue))
if (totalNferiliserInput != Convert.ToDouble(elementValue)) // {
{ // _logger.LogWarning(String.Format($"3. run {run}: totalNferiliserInput != nFertilizerNKgHa"));
_logger.LogWarning(String.Format($"3. run {run}: totalNferiliserInput != nFertilizerNKgHa")); // //throw new Exception(String.Format($"run {run}: totalNferiliserInput != nFertilizerNKgHa"));
//throw new Exception(String.Format($"run {run}: totalNferiliserInput != nFertilizerNKgHa")); // }
} //}
}
} }
} }
else if (kpio.id == "B2") else if (kpio.id == "B2")