Digital Twin - GUI
LocationCB.cs
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using System.Threading.Tasks;
6 using System.Windows.Forms;
7 using GUI.Datatypes;
8 
9 namespace GUI.Datatypes
10 {
14 
19  public class LocationCB : CheckBox
20  {
24  private List<MachineCB> machines;
28  private bool[] timeslots;
32  public double Penalty;
36  private List<Toolkit> toolkits;
37 
43 
46  public LocationCB(String name, double penalty) : base()
47  {
48  this.Name = name;
49  this.Text = name;
50  this.ThreeState = true;
51  machines = new List<MachineCB>();
52  toolkits = new List<Toolkit>();
53  timeslots = new bool[] { true };
54  this.Penalty = penalty;
55  }
56 
57 
61 
65  public void checkAllMachines()
66  {
67  foreach (MachineCB mac in machines)
68  {
69  mac.CheckState = CheckState.Checked;
70  }
71  }
72 
73 
77 
81  public void uncheckAllMachines()
82  {
83  foreach (MachineCB mac in machines)
84  {
85  mac.CheckState = CheckState.Unchecked;
86  }
87  }
88 
89 
94 
98  public double allChildrenChecked()
99  {
100  int sum = 0;
101 
102  foreach (MachineCB m in machines)
103  {
104  if (m.CheckState.Equals(CheckState.Checked)) sum += 2;
105  if (m.CheckState.Equals(CheckState.Indeterminate)) sum += 1;
106  if (m.CheckState.Equals(CheckState.Unchecked)) sum += 0;
107  }
108 
109  double d = (double)sum / (double)machines.Count;
110  return d;
111  }
112 
113 
119 
123  public bool stateOfTimeslot(int t)
124  {
125  //if (t < timeslots.Length && t >= 0) {
126  return timeslots[t];
127  //}
128  //else
129  //{
130  // throw new Exception("Timeslot " + t + " does not exist.");
131  //}
132 
133  }
134 
139 
144  public void changeStateOfTimeslot(int t)
145  {
146  timeslots[t] = !timeslots[t];
147  foreach (MachineCB m in machines)
148  {
149  m.changeStateOfTimeslot(t, timeslots[t]);
150  }
151  }
152 
157 
161  public void setNumberOfTimeslots(int num)
162  {
163  timeslots = new bool[num];
164  for (int i = 0; i < timeslots.Length; i++)
165  {
166  timeslots[i] = true;
167  }
168  }
169 
174 
178  public void addMachine(MachineCB m)
179  {
180  if (!machines.Contains(m))
181  {
182  machines.Add(m);
183  }
184  }
185 
190  public List<MachineCB> getMachines()
191  {
192  return machines;
193  }
194 
199 
203  public void addToolkit(Toolkit t)
204  {
205  if (!toolkits.Contains(t))
206  {
207  toolkits.Add(t);
208  }
209  }
210 
215  public List<Toolkit> getToolkits()
216  {
217  return toolkits;
218  }
219 
225 
229  public List<String> extendProducableProducts(List<String> l)
230  {
231  foreach (MachineCB m in machines)
232  {
233  m.extendProductList(l);
234  }
235  return l;
236  }
237  }
238 }
double allChildrenChecked()
Check if every machine belonging to the location is checked.
Definition: LocationCB.cs:98
void addMachine(MachineCB m)
Add a machine to this location.
Definition: LocationCB.cs:178
bool[] timeslots
An array that stores for each timeslot if the location is available on this time. ...
Definition: LocationCB.cs:28
A wrapper class for toolkits.
Definition: Toolkit.cs:16
List< String > extendProducableProducts(List< String > l)
Extends the List of products that can be produced.
Definition: LocationCB.cs:229
A wrapper class for locations.
Definition: LocationCB.cs:19
void addToolkit(Toolkit t)
Add a toolkit to this location.
Definition: LocationCB.cs:203
List< String > extendProductList(List< String > l)
Extends the List of products that can be produced.
Definition: MachineCB.cs:203
List< MachineCB > machines
A list of machines that belong to this location.
Definition: LocationCB.cs:24
List< Toolkit > toolkits
A list of toolkits that belong to this location.
Definition: LocationCB.cs:36
void setNumberOfTimeslots(int num)
Sets the number of timeslots to a certain amount.
Definition: LocationCB.cs:161
void changeStateOfTimeslot(int t)
Change the availability of this machine at timeslot t.
Definition: MachineCB.cs:158
LocationCB(String name, double penalty)
The Constructor.
Definition: LocationCB.cs:46
void changeStateOfTimeslot(int t)
Change the availability of this location at timeslot t.
Definition: LocationCB.cs:144
void uncheckAllMachines()
Uncheck all the machine Checkboxes that belong to this location.
Definition: LocationCB.cs:81
A wrapper class for machines.
Definition: MachineCB.cs:18
bool stateOfTimeslot(int t)
Get the availability of this location at timeslot t.
Definition: LocationCB.cs:123
void checkAllMachines()
Check all the machine Checkboxes that belong to this location.
Definition: LocationCB.cs:65
double Penalty
A number that describes the estimated penalty for the dalayed production of one product (in Euro)...
Definition: LocationCB.cs:32
List< MachineCB > getMachines()
Grants access to the list of machines that belong to the location.
Definition: LocationCB.cs:190
List< Toolkit > getToolkits()
Grants access to the list of toolkits that belong to the location.
Definition: LocationCB.cs:215