TrackedDataSet.java 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. package classes;
  2. import com.google.gson.annotations.Expose;
  3. import ui.controller.SingletonControl;
  4. import java.awt.*;
  5. public class TrackedDataSet {
  6. //Property Integers
  7. public static final int CONSUMPTION = 0;
  8. public static final int PRODUCTION = 1;
  9. public static final int ACTIVATED_ELEMENTS = 2;
  10. public static final int ON_OFF = 3;
  11. public static final int TOTAL_PRODUCTION = 4;
  12. public static final int TOTAL_CONSUMPTION = 5;
  13. public static final int PERCENT_SUPPLIED = 6;
  14. public static final int PERCENT_NOT_SUPPLIED = 7;
  15. public static final int PERCENT_PARTIAL_SUPPLIED = 8;
  16. public static final int GROUP_PRODUCTION = 9;
  17. public static final int GROUP_CONSUMPTION = 10;
  18. public static final int AMOUNT_HOLONS = 11;
  19. public static final int AMOUNT_CLOSED_SWITCHES = 12;
  20. public static final int AVG_AMOUNT_OBJECTS_IN_HOLONS = 13;
  21. public static final int AVG_AMOUNT_ELEMENTS_IN_HOLONS = 14;
  22. public static final int AVG_AMOUNT_PRODUCERS_IN_HOLONS = 15;
  23. public static final int AVG_CONSUMED_ENERGY_IN_HOLONS = 16;
  24. public static final int AVG_WASTED_ENERGY_IN_HOLONS = 17;
  25. public static final int AMOUNT_BROKEN_EDGES = 18;
  26. public static final int RATIO_PRODUCERS_CONSUMERS = 19;
  27. public static final int AVG_AMOUNT_CLOSED_SWITCHES_IN_HOLONS = 20;
  28. public static final int AVG_AMOUNT_ACTIVE_ELEMENTS_IN_HOLONS = 21;
  29. public static final int AVG_AMOUNT_INACTIVE_ELEMENTS_IN_HOLONS = 22;
  30. public static final int AVG_PRODUCED_ENERGY_IN_HOLONS = 23;
  31. public static final int WASTED_ENERGY = 24;
  32. //Variables of the Data Set
  33. private AbstractCanvasObject cps;
  34. @Expose
  35. private int property;
  36. @Expose
  37. private Color color;
  38. //Value for each timeStep
  39. private float values[];
  40. /**
  41. * Data Set for the StatisticGraoh
  42. *
  43. * @param cps
  44. * the cps Object
  45. * @param property
  46. * which value should be tracked
  47. * @param color
  48. * color of the line in the graph
  49. * @param timeStep
  50. * The time steps at the moment this object is created
  51. */
  52. public TrackedDataSet(AbstractCanvasObject cps, int property, Color color, int timeSteps) {
  53. this.cps = cps;
  54. this.property = property;
  55. this.color = color;
  56. this.values = new float[timeSteps];
  57. resetValues();
  58. }
  59. public AbstractCanvasObject getCpsObject() {
  60. return this.cps;
  61. }
  62. public int getProperty() {
  63. return this.property;
  64. }
  65. public Color getColor() {
  66. return this.color;
  67. }
  68. public float[] getValues() {
  69. return this.values;
  70. }
  71. public void setValAt(float val, int at){
  72. this.values[at] = val;
  73. }
  74. /**
  75. * Resets all values.
  76. */
  77. public void resetValues(){
  78. for (int i = 0; i < values.length; i++) {
  79. values[i] = -1;
  80. }
  81. }
  82. public void updateIterations() {
  83. float[] tmp=new float[
  84. SingletonControl.getInstance().getControl().getModel().getIterations()
  85. ];
  86. for(int i=0;i<tmp.length;i++)tmp[i]=(i<values.length)?values[i]:-1;
  87. values=tmp;
  88. }
  89. }