2 using System.Collections.Generic;
3 using System.ComponentModel;
8 using System.Threading.Tasks;
44 string resourcesFolder = Directory.GetParent(Directory.GetParent(Directory.GetParent(Directory.GetCurrentDirectory()).ToString()).ToString()) +
"\\Resources";
51 string excelFilePath = Directory.GetParent(Directory.GetParent(Directory.GetParent(Directory.GetCurrentDirectory()).ToString()).ToString()) +
"\\Resources\\Dataset.xlsx";
54 DateTime
startTime =
new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, 0, 0);
56 DateTime
endTime =
new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, 0, 0).AddHours(1);
81 numericUpDown2.Value = DateTime.Now.Hour;
82 numericUpDown1.Value = DateTime.Now.Hour;
93 ThreadExceptionDialog ted =
new ThreadExceptionDialog(e);
105 LocationFlowLayouts =
new FlowLayoutPanel[locations.Length];
106 for (
int i = 0; i < locations.Length; i++)
109 locations[i].MinimumSize =
new Size(width, 0);
112 LocationFlowLayouts[i] =
new FlowLayoutPanel();
113 LocationFlowLayouts[i].Padding =
new Padding(0, 3, 0, 3);
114 LocationFlowLayouts[i].Size =
new Size(width, flowLayoutPanelLocations.Size.Height - flowLayoutPanelLocations.Padding.Top - flowLayoutPanelLocations.Padding.Bottom - 6);
115 LocationFlowLayouts[i].Controls.Add(locations[i]);
116 flowLayoutPanelLocations.Controls.Add(LocationFlowLayouts[i]);
120 MachineFlowLayouts =
new FlowLayoutPanel[locations.Length];
121 for (
int i = 0; i < locations.Length; i++)
123 MachineFlowLayouts[i] =
new FlowLayoutPanel();
124 MachineFlowLayouts[i].Padding =
new Padding(0, 3, 0, 3);
125 MachineFlowLayouts[i].Size =
new Size(width, flowLayoutPanelMachines.Size.Height - flowLayoutPanelMachines.Padding.Top - flowLayoutPanelMachines.Padding.Bottom - 6);
126 MachineFlowLayouts[i].FlowDirection = FlowDirection.TopDown;
127 MachineFlowLayouts[i].AutoScroll =
true;
128 MachineFlowLayouts[i].WrapContents =
false;
129 MachineFlowLayouts[i].MaximumSize =
new Size(width, 10000);
130 flowLayoutPanelMachines.Controls.Add(MachineFlowLayouts[i]);
131 foreach (
MachineCB mac
in machinesAtLocation[i])
135 MachineFlowLayouts[i].Controls.Add(mac);
140 ProductFlowLayouts =
new FlowLayoutPanel[locations.Length];
141 for (
int i = 0; i < locations.Length; i++)
143 ProductFlowLayouts[i] =
new FlowLayoutPanel();
144 ProductFlowLayouts[i].Padding =
new Padding(0, 3, 0, 3);
145 ProductFlowLayouts[i].Size =
new Size(width, flowLayoutPanelProducts.Size.Height - flowLayoutPanelProducts.Padding.Top - flowLayoutPanelProducts.Padding.Bottom - 6);
146 ProductFlowLayouts[i].FlowDirection = FlowDirection.TopDown;
147 ProductFlowLayouts[i].AutoScroll =
true;
148 ProductFlowLayouts[i].WrapContents =
false;
149 ProductFlowLayouts[i].MaximumSize =
new Size(width, 10000);
150 flowLayoutPanelProducts.Controls.Add(ProductFlowLayouts[i]);
151 foreach (
MachineCB mac
in machinesAtLocation[i])
153 ProductFlowLayouts[i].Controls.Add(
new Label() { Text = mac.Name });
157 ProductFlowLayouts[i].Controls.Add(prod);
163 textBox1.ReadOnly =
true;
180 if (loc.CheckState.Equals(CheckState.Checked))
185 if (loc.CheckState.Equals(CheckState.Unchecked))
190 if (loc.CheckState.Equals(CheckState.Indeterminate))
194 loc.CheckState = CheckState.Unchecked;
200 loc.CheckState = CheckState.Checked;
220 if (mac.CheckState.Equals(CheckState.Checked))
229 mac.
getLocation().CheckState = CheckState.Indeterminate;
233 if (mac.CheckState.Equals(CheckState.Unchecked))
238 mac.
getLocation().CheckState = CheckState.Unchecked;
242 mac.
getLocation().CheckState = CheckState.Indeterminate;
246 if (mac.CheckState.Equals(CheckState.Indeterminate))
250 mac.CheckState = CheckState.Unchecked;
256 mac.CheckState = CheckState.Checked;
260 mac.
getLocation().CheckState = CheckState.Indeterminate;
279 if (mac.CheckState.Equals(CheckState.Checked))
299 if (c.CheckState.Equals(CheckState.Checked))
319 if (p.CheckState == CheckState.Checked)
323 p.
getMachine().CheckState = CheckState.Checked;
327 p.
getMachine().CheckState = CheckState.Indeterminate;
331 if (p.CheckState == CheckState.Unchecked)
335 p.
getMachine().CheckState = CheckState.Unchecked;
339 p.
getMachine().CheckState = CheckState.Indeterminate;
356 OpenFileDialog ofd =
new OpenFileDialog();
357 ofd.Filter =
"Exceldateien | *.xlsx";
358 DialogResult result = ofd.ShowDialog();
361 if (result == DialogResult.Cancel)
367 if (result == DialogResult.OK)
372 if (s.EndsWith(
"TestDatei.xlsx"))
385 MessageBox.Show(
"Datei muss auf *Dataset.xlsx enden.");
396 locationDictionary.Clear();
397 locationNames = null;
399 machinesAtLocation = null;
400 productsAtMachine = null;
401 ExcelFileReadIn =
false;
404 foreach (FlowLayoutPanel f
in LocationFlowLayouts)
409 foreach (FlowLayoutPanel f
in MachineFlowLayouts)
414 foreach (FlowLayoutPanel f
in ProductFlowLayouts)
428 DateTime sd =
new DateTime(dateTimePicker1.Value.Year, dateTimePicker1.Value.Month, dateTimePicker1.Value.Day, (
int)numericUpDown1.Value, 0, 0);
432 if (sd.CompareTo(endTime) >= 0)
434 endTime = startTime.AddHours(1);
435 numericUpDown2.Value = endTime.Hour;
436 dateTimePicker2.Value =
new DateTime(endTime.Year, endTime.Month, endTime.Day);
468 DateTime et =
new DateTime(dateTimePicker2.Value.Year, dateTimePicker2.Value.Month, dateTimePicker2.Value.Day, (
int)numericUpDown2.Value, 0, 0);
470 if (et.CompareTo(startTime)>0)
477 endTime = startTime.AddHours(1);
478 numericUpDown2.Value = endTime.Hour;
479 dateTimePicker2.Value =
new DateTime(endTime.Year, endTime.Month, endTime.Day);
511 int num = (int)Math.Ceiling(endTime.Subtract(startTime).TotalHours);
512 if (machinesAtLocation != null)
514 foreach (List<MachineCB> l
in machinesAtLocation)
523 if (locations != null)
525 for (
int i = 0; i < locations.Length; i++)
540 if (!ExcelFileReadIn)
542 md =
new ModelData(excelFilePath, locationNames, locations, locationDictionary);
543 ExcelFileReadIn =
true;
549 if (dfc.createDatFile(d))
554 XPRM mosel = XPRM.Init();
557 XPRMModel model = mosel.CompileAndLoad(resourcesFolder +
"\\Test.mos");
561 model.Bind(
"ModelIni",
new StringReader(dfc.Data));
562 model.Bind(
"ModelIniSecond",
new StringReader(dfc.Data));
566 model.SetDefaultStream(XPRMStreamType.F_OUTPUT, modelOut);
569 model.SetDefaultStream(XPRMStreamType.F_ERROR, errorOut);
574 model.SetExecParam(
"DATAFILE",
"dotnet:ModelIni");
575 model.SetExecParam(
"SECONDDATAFILE",
"dotnet:ModelIniSecond");
578 if (errorOut.
sb.Length > 0)
580 MessageBox.Show(errorOut.
sb.ToString(),
"ERROR in Mosel");
584 MessageBox.Show(modelOut.
sb.ToString(),
"Mosel Output");
593 MessageBox.Show(
"Es muss mindestens eine Bestellung im Planungshorizont liegen.");
void numericUpDown2_ValueChanged(object sender, EventArgs e)
Called whenever the user change the hour for the endTime.
void MachineCheckBoxClicked(object sender, EventArgs e)
Eventhandler that is called when the machine checkbox has been clicked.
void UpdateNumberOfTimeslots()
Update number of timeslots for each machine and Location every time endTime or startTime change...
void UpdateStartTime()
Function which updates the startTime, and updates the endTime if necessary.
MachineCB getMachine()
Grants access to the machine this product is meant to be produced on.
double allChildrenChecked()
Check if every machine belonging to the location is checked.
This class reads all the important data out of an Excel file and creates all the Checkboxes we need...
This is the main window, where the locations, machines and products are shown.
FlowLayoutPanel[] LocationFlowLayouts
Each Location is wrapped by a Location FlowLayout.
List< ProductCB >[] productsAtMachine
All products at a specific location. Indexed by location's indexed, so that they can be aligned verti...
LocationCB[] GetAllLocations()
Grants access to the location array.
void InitializeComponent()
Erforderliche Methode für die Designerunterstützung. Der Inhalt der Methode darf nicht mit dem Code-E...
A class that lets us catch the output Stream of Mosel.
DateTime startTime
Starttime of planning horizon.
void setNumberOfTimeslots(int num)
Sets the number of timeslots to a certain amount.
void checkAllProducts()
Check all the product Checkboxes that belong to this machine.
StringBuilder sb
Save every incoming message to the StringBuilder.
int width
Number to easily adjust width of all elements.
void uncheckAllProducts()
Uncheck all the product Checkboxes that belong to this machine.
LocationCB getLocation()
Grants access to the location where the machine is located.
void dateTimePicker1_ValueChanged(object sender, EventArgs e)
Called whenever the user change the date for the startTime.
void Create()
Reads all the Data from Dir + "\\Dataset.xlsx".
DateTime endTime
Endtime of planning horizon.
List< MachineCB >[] machinesAtLocation
All machines at a specific location. Indexed by location's indexed, so that they can be aligned verti...
void button2_Click(object sender, EventArgs e)
Function that is called when the "Compute" Button is clicked. Reads in the rest of the model data and...
List< MachineCB >[] GetAllMachines()
Grants access to the machine checkboxes.
List< ProductCB > getProducts()
Grants access to the list of products that belong to the machine.
A wrapper class for products.
void LocationCheckBoxChanged(object sender, EventArgs e)
Eventhandler that is called when the Checkstate of a location has changed.
Dialog that lets users choose which timeslots are available.
A wrapper class for locations.
void UpdateEndtime()
Function which updates the endTime, provided that the end time is at least the startTime + 1 hour...
List< ProductCB >[] GetAllProducts()
Grants access to the product checkboxes.
void LocationCheckBoxClicked(object sender, EventArgs e)
Eventhandler that is called when the location checkbox has been clicked.
FlowLayoutPanel[] ProductFlowLayouts
Each block of products is wrapped by a Location FlowLayout.
void setup()
Reads in data from a user defined folder (or the standard one) and sets the interface up with all its...
ModelData md
Object that contains additional model data.
void button1_Click(object sender, EventArgs e)
Eventhandler that is called when the "Durchsuchen..." button is clicked.
void clear()
Deletes every object on the interface.
void MachineCheckBoxChanged(object sender, EventArgs e)
Eventhandler that is called when the Checkstate of a machine has changed.
Dictionary< String, int > locationDictionary
Dictionary that maps a location's name to its position in the locations array.
void setNumberOfTimeslots(int num)
Sets the number of timeslots to a certain amount.
void dateTimePicker2_ValueChanged(object sender, EventArgs e)
Called whenever the user change the date for the endTime.
double allChildrenChecked()
Check if every procuct belonging to the machine is checked.
string resourcesFolder
Folder directory where the model related files are located.
LocationCB[] locations
Array that stores all locations.
void uncheckAllMachines()
Uncheck all the machine Checkboxes that belong to this location.
void numericUpDown1_ValueChanged(object sender, EventArgs e)
Called whenever the user change the hour for the startTime.
string excelFilePath
Folder directory where the Excel input file is located.
void ProductCheckBoxChanged(object sender, EventArgs e)
Eventhandler that is called when the Checkstate of a product has changed.
A wrapper class for machines.
Dictionary< String, int > GetLocationDict()
Grants access to the location dictionary.
This class reads all the important data out of an Excel file related to the model.
bool ExcelFileReadIn
Check if Excel file has been read in before.
String[] locationNames
Array that contains all of the locations' names.
void checkAllMachines()
Check all the machine Checkboxes that belong to this location.
String[] GetLocationNames()
Grants access to the all the location names.
FlowLayoutPanel[] MachineFlowLayouts
Each block of machines is wrapped by a Location FlowLayout.