|
1 | 1 | package FileXService; |
2 | 2 |
|
| 3 | +import DSSATModel.ExperimentType; |
3 | 4 | import Extensions.Utils; |
4 | 5 | import FileXModel.FileX; |
5 | 6 | import FileXModel.Simulation; |
@@ -31,6 +32,7 @@ public static SimulationList Read(String fileName) { |
31 | 32 | String simNitrogenHeader = ""; |
32 | 33 | String simResidueHeader = ""; |
33 | 34 | String simHarvestHeader = ""; |
| 35 | + String simForecastHeader = ""; |
34 | 36 |
|
35 | 37 | boolean bSimulation = false; |
36 | 38 | int nSimulation = 0; |
@@ -70,6 +72,9 @@ public static SimulationList Read(String fileName) { |
70 | 72 | } else if (bSimulation && tmp.trim().startsWith("@N HARVEST")) { |
71 | 73 | simHarvestHeader = tmp.trim(); |
72 | 74 | nSimulation = 10; |
| 75 | + } else if (bSimulation && tmp.trim().startsWith("@N SIMDATES")) { |
| 76 | + simForecastHeader = tmp.trim(); |
| 77 | + nSimulation = 11; |
73 | 78 | } |
74 | 79 |
|
75 | 80 | else if (bSimulation && nSimulation == 1 && !tmp.trim().startsWith("!") && !"".equals(tmp.trim()) && !tmp.trim().startsWith("@ AUTOMATIC MANAGEMENT")) { |
@@ -363,6 +368,33 @@ else if (bSimulation && nSimulation == 10 && !tmp.trim().startsWith("!") && !"". |
363 | 368 | sim.HPCNP = Utils.GetFloat(simHarvestHeader, tmp, "HPCNP", 5); |
364 | 369 | sim.HPCNR = Utils.GetFloat(simHarvestHeader, tmp, "HPCNR", 5); |
365 | 370 |
|
| 371 | + if(isAdd) { |
| 372 | + simulationList.AddNew(sim); |
| 373 | + } |
| 374 | + nSimulation = -1; |
| 375 | + } |
| 376 | + else if (bSimulation && nSimulation == 11 && !tmp.trim().startsWith("!") && !"".equals(tmp.trim()) && !tmp.trim().startsWith("@ AUTOMATIC MANAGEMENT")) { |
| 377 | + Simulation sim; |
| 378 | + Integer level = Integer.valueOf(tmp.substring(0, 2).trim()); |
| 379 | + |
| 380 | + //@N SIMDATES ENDAT SDUR FODAT FSTRYR FENDYR FWFILE FONAME |
| 381 | + boolean isAdd = false; |
| 382 | + if(!simulationList.IsLevelExists(level)) { |
| 383 | + sim = new Simulation(); |
| 384 | + sim.SetLevel(level); |
| 385 | + isAdd = true; |
| 386 | + } else { |
| 387 | + sim = (Simulation)simulationList.GetAt(level); |
| 388 | + } |
| 389 | + |
| 390 | + sim.ENDAT = Utils.GetDate(simForecastHeader, tmp, "ENDAT", 8); |
| 391 | + sim.SDUR = Utils.GetInteger(simForecastHeader, tmp, " SDUR", 7); |
| 392 | + sim.FODAT = Utils.GetDate(simForecastHeader, tmp, "FODAT", 8); |
| 393 | + sim.FSTRYR = Utils.GetInteger(simForecastHeader, tmp, "FSTRYR", 7); |
| 394 | + sim.FENDYR = Utils.GetInteger(simForecastHeader, tmp, "FENDYR", 7); |
| 395 | + sim.FWFILE = Utils.GetString(simForecastHeader, tmp, "FWFILE", 16); |
| 396 | + sim.FONAME = Utils.GetString(simForecastHeader, tmp, "FONAME", tmp.length() - simForecastHeader.indexOf("FONAME")); |
| 397 | + |
366 | 398 | if(isAdd) { |
367 | 399 | simulationList.AddNew(sim); |
368 | 400 | } |
@@ -519,6 +551,22 @@ public static void Extract(PrintWriter pw) { |
519 | 551 | pw.print(" " + Utils.PadLeft(sim.HPCNP, 5, ' ')); |
520 | 552 | pw.print(" " + Utils.PadLeft(sim.HPCNR, 5, ' ')); |
521 | 553 | pw.println(); |
| 554 | + |
| 555 | + |
| 556 | + if(FileX.general.FileType == ExperimentType.Forecast){ |
| 557 | + pw.println("@N SIMDATES ENDAT SDUR FODAT FSTRYR FENDYR FWFILE FONAME"); |
| 558 | + pw.print(Utils.PadLeft(level, 2, ' ')); |
| 559 | + pw.print(" SI "); |
| 560 | + pw.print(" " + Utils.PadLeft(Utils.JulianDate(sim.ENDAT, "yyyy"), 7, ' ')); |
| 561 | + pw.print(" " + Utils.PadLeft(sim.SDUR, 7, ' ')); |
| 562 | + pw.print(" " + Utils.PadLeft(Utils.JulianDate(sim.FODAT, "yyyy"), 7, ' ')); |
| 563 | + pw.print(" " + Utils.PadLeft(sim.FSTRYR, 7, ' ')); |
| 564 | + pw.print(" " + Utils.PadLeft(sim.FENDYR, 7, ' ')); |
| 565 | + pw.print(" " + Utils.PadRight(sim.FWFILE, 16, ' ')); |
| 566 | + pw.print(" " + sim.FONAME); |
| 567 | + pw.println(); |
| 568 | + } |
| 569 | + |
522 | 570 | pw.println(); |
523 | 571 | } |
524 | 572 | } |
|
0 commit comments