Added KPI G1 ammonia emissions (only on test servers)

- Ammonia emissions from fertilizers not yet fully functional
This commit is contained in:
2024-07-04 13:35:33 +02:00
parent da82c232e3
commit 67e5cb6bb4
4 changed files with 94 additions and 37 deletions

View File

@@ -48,7 +48,8 @@ namespace FarmmapsKPI
//fnKPIinput = Console.ReadLine();
//if (string.IsNullOrEmpty(fnKPIinput))
//{
fnKPIinput = "KPIinput.json";
//fnKPIinput = "KPIinput.json";
fnKPIinput = "C:\\git\\FarmMapsApiClient_KB34_MAST\\FarmmapsKPI\\KPIinput.json";
//}
var fieldsInputJson = File.ReadAllText(fnKPIinput);
@@ -93,7 +94,7 @@ namespace FarmmapsKPI
int nrun = 1;
for (int run = 1; run <= nrun; run++) {
for (int i = 0; i < fieldsInputs.Count; i++)
//for (int i = 11; i < 13; i++) // for testing
//for (int i = 2; i < 3; i++) // for testing
{
watch.Restart();
input = fieldsInputs[i];
@@ -432,7 +433,7 @@ namespace FarmmapsKPI
int DuplicateCounter;
value = 0;
id = "";
DuplicateCounter = 1;
DuplicateCounter = 1;
for (int i = 0; i < KPIItems.Count; i++)
{
itemi = KPIItems[i];
@@ -668,7 +669,6 @@ namespace FarmmapsKPI
sw.WriteLine(string.Join(",", dataList));
}
}
else if (kpio.id == "E1")
{
//for E1, environmentMeasureData is an array of elements with 1 per pesticide. Inside each element there are multiple mbp_KPIvariables to be written
@@ -705,9 +705,53 @@ namespace FarmmapsKPI
}
}
}
else if (kpio.id == "G1") //TtD
{
//Make a new dataList = new line to be written
dataList = new List<string>
{
run.ToString(),
kpio.parentName,
cropfieldItem.Code,
kpio.data.area,
kpio.data.cropTypeCode,
kpio.data.cropTypeName,
kpio.id,
kpio.quantity, // in KPI output quantity is what we call KPIvariable in headerlist of csv file
kpio.value,
kpio.unit,
kpio.targetValue,
kpio.thresholdValue
};
//Write the datalist to a line to the streamwrieter sw for the output csv file
sw.WriteLine(string.Join(",", dataList));
foreach (string elementName in kpio.G1elements)
{
// get G1element from the element called values
string elementValue = (string)kPIelementsOfBalance.GetType().GetProperty(elementName).GetValue(kPIelementsOfBalance, null);
dataList = new List<string>
{
run.ToString(),
kpio.parentName,
cropfieldItem.Code,
kpio.data.area,
kpio.data.cropTypeCode,
kpio.data.cropTypeName,
kpio.id,
elementName, // specific output variable name for G1 element
elementValue, // specific output value name for G1 element
kpio.unit,
"",
""
};
//Write the datalist to a line to the streamwrieter sw for the output csv file
sw.WriteLine(string.Join(",", dataList));
}
}
else
{
//Any other KPI, example A1 or D1, with just 1 record to write
//Any other KPI, (D1, F1, and F2), with just 1 record to write
dataList = new List<string>
{
run.ToString(),