2424
2525 .section {
2626 display : flex;
27- flex-direction : column;
28- gap : 15px ;
27+ flex-direction : row;
28+ justify-content : space-between;
29+ align-items : flex-start;
2930 padding : 20px ;
3031 border : 1px solid # ccc ;
3132 border-radius : 8px ;
4647 display : flex;
4748 align-items : center;
4849 font-size : 4rem ;
49-
50- /* Set uniform font size */
5150 }
5251
5352 .axis-label {
6867 margin-left : 10px ;
6968 }
7069
70+ .led-container {
71+ display : flex;
72+ flex-direction : column;
73+ align-items : flex-start;
74+ gap : 15px ;
75+ margin-left : 20px ;
76+ }
77+
78+ .led-wrapper {
79+ display : flex;
80+ align-items : center;
81+ gap : 10px ;
82+ }
83+
84+ .led {
85+ width : 25px ;
86+ height : 25px ;
87+ background-color : # 555 ;
88+ border-radius : 50% ;
89+ box-shadow : inset -2px -2px 4px rgba (0 , 0 , 0 , 0.4 ), inset 2px 2px 4px rgba (255 , 255 , 255 , 0.7 );
90+ }
91+
92+ .led .on {
93+ background-color : # 00d207 ;
94+ /* Green color when on */
95+ box-shadow : inset -2px -2px 4px rgba (0 , 0 , 0 , 0.4 ), inset 2px 2px 4px rgba (255 , 255 , 255 , 0.7 ), 0 0 8px # 69fa6e ;
96+ /* Glow */
97+ }
98+
99+ .led-label {
100+ font-weight : normal;
101+ text-transform : uppercase;
102+ }
103+
71104 .motor-container {
72105 display : grid;
73106 grid-template-columns : repeat (4 , 1fr );
84117 flex-direction : column;
85118 gap : 5px ;
86119 font-family : 'Roboto' , sans-serif;
87- /* Uniform font */
88120 font-size : 1rem ;
89- /* Uniform font size */
90121 position : relative;
91122 }
92123
121152 .torque-bar {
122153 height : 100% ;
123154 background-color : # 4caf50 ;
124- /* Green bar */
125155 width : 0% ;
126- /* Dynamic width based on torque */
127156 transition : width 0.3s ease;
128- /* Smooth transition */
129157 }
130158 </ style >
131159</ head >
132160
133161< body >
134-
135- <!-- Position Display Section -->
162+ <!-- Position Display and LED Indicators Section -->
136163 < div class ="section ">
137164 < div class ="position-display ">
138165 < div class ="position-row ">
151178 < div class ="unit "> mm</ div >
152179 </ div >
153180 </ div >
181+
182+ <!-- LED Indicators Column -->
183+ < div class ="led-container ">
184+ < div class ="led-wrapper ">
185+ < div class ="led " id ="led-deadman-switch "> </ div >
186+ < div class ="led-label "> Deadman Switch</ div >
187+ </ div >
188+ < div class ="led-wrapper ">
189+ < div class ="led " id ="led-motors-enabled "> </ div >
190+ < div class ="led-label "> Motors Enabled</ div >
191+ </ div >
192+ < div class ="led-wrapper ">
193+ < div class ="led " id ="led-emergency-stop "> </ div >
194+ < div class ="led-label "> Emergency Stop</ div >
195+ </ div >
196+ < div class ="led-wrapper ">
197+ < div class ="led " id ="led-rapid-traverse "> </ div >
198+ < div class ="led-label "> Rapid Traverse</ div >
199+ </ div >
200+ < div class ="led-wrapper ">
201+ < div class ="led " id ="led-fine-control "> </ div >
202+ < div class ="led-label "> Fine Control</ div >
203+ </ div >
204+ < div class ="led-wrapper ">
205+ < div class ="led " id ="led-machine-mode "> </ div >
206+ < div class ="led-label "> Machine Mode</ div >
207+ </ div >
208+ </ div >
154209 </ div >
155210
156211 <!-- Motor Control Section -->
195250 const socket = io ( ) ;
196251 const maxTorque = 100 ; // Define maximum torque value for scaling
197252
198- // Update the positions and motor metrics when data is received from the server
253+ // Update the positions, motor metrics, and LED indicators when data is received from the server
199254 socket . on ( 'update' , function ( data ) {
200255 const parsedData = JSON . parse ( data ) ;
201256
202- // Display raw values for position
257+ // Update LED indicators based on data (accept True/False, true/false, or 1/0 as inputs)
258+ function parseBoolean ( value ) {
259+ return value === true || value === 1 || value === "True" || value === "true" ;
260+ }
261+
262+ document . getElementById ( 'led-deadman-switch' ) . className = parseBoolean ( parsedData [ 'deadman_switch' ] ) ? 'led on' : 'led off' ;
263+ document . getElementById ( 'led-motors-enabled' ) . className = parseBoolean ( parsedData [ 'motors_enabled' ] ) ? 'led on' : 'led off' ;
264+ document . getElementById ( 'led-emergency-stop' ) . className = parseBoolean ( parsedData [ 'emergency_stop' ] ) ? 'led on' : 'led off' ;
265+ document . getElementById ( 'led-rapid-traverse' ) . className = parseBoolean ( parsedData [ 'rapid_traverse' ] ) ? 'led on' : 'led off' ;
266+ document . getElementById ( 'led-fine-control' ) . className = parseBoolean ( parsedData [ 'fine_control' ] ) ? 'led on' : 'led off' ;
267+ document . getElementById ( 'led-machine-mode' ) . className = parseBoolean ( parsedData [ 'machine_mode' ] ) ? 'led on' : 'led off' ;
268+
269+ // Update position values
203270 document . getElementById ( 'posX' ) . textContent = parsedData [ 'position_x' ] ;
204271 document . getElementById ( 'posY' ) . textContent = parsedData [ 'position_y' ] ;
205272 document . getElementById ( 'posZ' ) . textContent = parsedData [ 'position_z' ] ;
228295 }
229296 } ) ;
230297 </ script >
231-
232298</ body >
233299
234300</ html >
0 commit comments