Digital Twin - GUI
DatFileCreator.cs
1 using System;
2 using System.Collections.Generic;
3 using System.IO;
4 using System.Linq;
5 using System.Text;
6 using System.Threading.Tasks;
7 
8 namespace GUI.IO_Modules
9 {
11  {
12  private ModelData md;
13  private DateTime startTime;
14  private DateTime endTime;
15  public String Data;
16 
17  public DatFileCreator(ModelData m, DateTime start, DateTime end)
18  {
19  md = m;
20  md.maxN = 0;
21  startTime = start;
22  endTime = end;
23  }
24 
25  public bool createDatFile(double d)
26  {
27  //d is between 0 and 1. Timeslot length will be 60min*d
28  if (d > 1 || d <= 0) throw new Exception("Not a valid discretization");
29 
30  StringBuilder sb = new StringBuilder(5000);
31  sb.Append(md.toDatString(d, startTime, endTime));
32 
33  Data = sb.ToString();
34  if (md.maxN == 0)
35  {
36  return false;
37  }
38  else
39  {
40  return true;
41  }
42  }
43 
44  public void export()
45  {
46  String folder = Directory.GetParent(Directory.GetParent(Directory.GetParent(Directory.GetCurrentDirectory()).ToString()).ToString()) + "\\Resources";
47  using (StreamWriter outputFile = new StreamWriter(folder + @"\Test.dat"))
48  {
49  outputFile.Write(Data);
50  }
51  }
52 
53  }
54 }
String toDatString(double d, DateTime start, DateTime end)
Concatenates the array and set strings, suitable for Xpress. Considers only the needed data...
Definition: ModelData.cs:308
int maxN
Maximum amount of orders for a single product.
Definition: ModelData.cs:56
This class reads all the important data out of an Excel file related to the model.
Definition: ModelData.cs:16