Преглед на файлове

Station states for DSI/DSO corrected

anfeny преди 2 месеца
родител
ревизия
d82f1179ed
променени са 1 файла, в които са добавени 19 реда и са изтрити 8 реда
  1. 19 8
      dashboard/src/static/js/dashboard.js

+ 19 - 8
dashboard/src/static/js/dashboard.js

@@ -262,6 +262,15 @@ socket.on('station_update', function (data) {
     } else if (state.active === 1) {
         colorClass = "text-info";
         iconClass = "bi-building-fill-gear";
+    } else if ((state.station === "dsi" || state.station === "dso") && (state.active === 0 && state.code === 0)){
+        /*
+            DSI/DSO is special:
+            active => denotes activity
+            code = 0 => workpiece present
+            code = 1 => no workpiece present
+        */
+        colorClass = "text-success";
+        iconClass = "bi-building-fill-check";
     }
 
     // Get icon depending on type of station
@@ -270,17 +279,19 @@ socket.on('station_update', function (data) {
         stationIcon = `<i class='bi bi-square ${colorClass} io-station-icon'></i>`
     }
 
-    if(state.station === "dsi" && state.active === 1){
+    // Add workpiece icon if applicable
+    if(state.station === "dsi" && state.code === 0){
         workpiece_color = ""; // new item so reset color
     }
-    
-    // Add workpiece if station active
-    if (state.active === 1) {
-        let boxClasses = "h5 ms-1";
-        if (state.station === "dsi" || state.station === "dso") {
-            boxClasses = "stacked-icon";
+    if (state.station === "dsi" || state.station === "dso") {
+        // Add workpiece to DSI/DSO if occupied
+        if (state.code === 0){
+            stationIcon += `<i class='bi bi-box-seam-fill ${getWorkpieceColor()} stacked-icon'></i>`
         }
-        stationIcon += `<i class='bi bi-box-seam-fill ${getWorkpieceColor()} ${boxClasses}'></i>`
+    }
+    else if (state.active === 1) {
+        // Add workpiece if 'regular' station active
+        stationIcon += `<i class='bi bi-box-seam-fill ${getWorkpieceColor()} h5 ms-1'></i>`
     }
     
     const stationElement = document.getElementById(state.station + "-station");