@@ -101,12 +101,12 @@ export function initRV6LClient() {
101101 client . on ( 'close' , async function ( ) {
102102 RV6L_STATE . rv6l_connected = false ;
103103 logEvent ( {
104- errorType : ErrorType . FATAL ,
104+ errorType : ErrorType . WARNING ,
105105 description : "RV6L connection closed unexpectedly. Reconnecting..." ,
106106 date : new Date ( ) . toString ( )
107107 } )
108108 sendStateToControlPanelClient ?.( ) ;
109- await new Promise ( resolve => setTimeout ( resolve , 5000 ) ) ; // Wait for 5 seconds before reconnecting
109+ await new Promise ( resolve => setTimeout ( resolve , 2000 ) ) ; // Wait for 5 seconds before reconnecting
110110 logEvent ( {
111111 errorType : ErrorType . INFO ,
112112 description : "Reconnecting to RV6L..." ,
@@ -128,7 +128,7 @@ export async function moveToBlue() {
128128 await wait ( 1000 ) ; // Simulate delay for mock
129129 } else {
130130 try {
131- await writeVariableInProc ( "IMOVE " , "1 " ) ;
131+ await writeVariableInProc ( "I_Aktion " , "11 " ) ;
132132 await movementDone ( ) ;
133133 } catch ( error ) {
134134 logEvent ( {
@@ -151,7 +151,7 @@ export async function moveToRed() {
151151 await wait ( 1000 ) ; // Simulate delay for mock
152152 } else {
153153 try {
154- await writeVariableInProc ( "IMOVE " , "2 " ) ;
154+ await writeVariableInProc ( "I_Aktion " , "21 " ) ;
155155 await movementDone ( ) ;
156156 } catch ( error ) {
157157 logEvent ( {
@@ -184,7 +184,8 @@ export async function moveToColumn(column: number) {
184184 await wait ( 1000 ) ; // Simulate delay for mock
185185 } else {
186186 try {
187- await writeVariableInProc ( "IMOVE" , ( 11 + column ) . toString ( ) ) ;
187+ await writeVariableInProc ( "IX_Schacht" , column . toString ( ) ) ;
188+ await writeVariableInProc ( "I_Aktion" , "31" ) ;
188189 await movementDone ( ) ;
189190 } catch ( error ) {
190191 logEvent ( {
@@ -206,7 +207,9 @@ export async function initChipPalletizing() {
206207 await wait ( 1000 ) ; // Simulate delay for mock
207208 } else {
208209 try {
209- await writeVariableInProc ( "IMOVE" , "3" ) ;
210+ await writeVariableInProc ( "I_Aktion" , "10" ) ;
211+ await movementDone ( )
212+ await writeVariableInProc ( "I_Aktion" , "20" ) ;
210213 await movementDone ( )
211214 } catch ( error ) {
212215 logEvent ( {
@@ -228,7 +231,7 @@ export async function moveToRefPosition() {
228231 await wait ( 1000 ) ; // Simulate delay for mock
229232 } else {
230233 try {
231- await writeVariableInProc ( "IMOVE " , "4 " ) ;
234+ await writeVariableInProc ( "I_Aktion " , "90 " ) ;
232235 await movementDone ( ) ;
233236 } catch ( error ) {
234237 logEvent ( {
@@ -242,9 +245,71 @@ export async function moveToRefPosition() {
242245 stopAction ( "MoveToRefPosition" ) ;
243246}
244247
248+ export async function removeFromField ( x : number , y :number ) {
249+ startAction ( "RemoveFromField" ) ;
250+ if ( RV6L_STATE . mock ) {
251+ await wait ( 1000 ) ; // Simulate delay for mock
252+ } else {
253+ try {
254+ await writeVariableInProc ( "IX_Feld" , x . toString ( ) ) ;
255+ await writeVariableInProc ( "IZ_Feld" , y . toString ( ) ) ;
256+ await writeVariableInProc ( "I_Aktion" , "41" ) ;
257+ await movementDone ( ) ;
258+ } catch ( error ) {
259+ logEvent ( {
260+ errorType : ErrorType . FATAL ,
261+ description : "Couldn't complete remove from field at position X:" + x + " Y:" + y ,
262+ date : new Date ( ) . toString ( )
263+ } ) ;
264+ }
265+ }
266+
267+ stopAction ( "RemoveFromField" ) ;
268+ }
269+
270+ export async function putBackToBlue ( ) {
271+ startAction ( "PutBackToBlue" ) ;
272+ if ( RV6L_STATE . mock ) {
273+ await wait ( 1000 ) ; // Simulate delay for mock
274+ } else {
275+ try {
276+ await writeVariableInProc ( "I_Aktion" , "12" ) ;
277+ await movementDone ( ) ;
278+ } catch ( error ) {
279+ logEvent ( {
280+ errorType : ErrorType . FATAL ,
281+ description : "Couldn't complete put back to blue" ,
282+ date : new Date ( ) . toString ( )
283+ } ) ;
284+ }
285+ }
286+ RV6L_STATE . blueChipsLeft ++ ;
287+ stopAction ( "PutBackToBlue" ) ;
288+ }
289+
290+ export async function putBackToRed ( ) {
291+ startAction ( "PutBackToRed" ) ;
292+ if ( RV6L_STATE . mock ) {
293+ await wait ( 1000 ) ; // Simulate delay for mock
294+ } else {
295+ try {
296+ await writeVariableInProc ( "I_Aktion" , "22" ) ;
297+ await movementDone ( ) ;
298+ } catch ( error ) {
299+ logEvent ( {
300+ errorType : ErrorType . FATAL ,
301+ description : "Couldn't complete put back to red" ,
302+ date : new Date ( ) . toString ( )
303+ } ) ;
304+ }
305+ }
306+ RV6L_STATE . redChipsLeft ++ ;
307+ stopAction ( "PutBackToRed" ) ;
308+ }
309+
245310async function movementDone ( ) {
246311 try {
247- await waitForVariablePolling ( "IMOVE " , "0" ) ;
312+ await waitForVariablePolling ( "I_Aktion " , "0" ) ;
248313 } catch ( error ) {
249314 logEvent ( {
250315 errorType : ErrorType . FATAL ,
@@ -305,7 +370,7 @@ async function waitForVariablePolling(variable: string, value: string) {
305370
306371async function readVariableInProc ( name : string ) : Promise < string > {
307372 let messageId = getNextMessageId ( ) ;
308- const getVariable = `<RSVCMD><clientStamp>${ messageId } </clientStamp><symbolApi><readSymbolValue><name>IMOVE </name></readSymbolValue></symbolApi></RSVCMD>`
373+ const getVariable = `<RSVCMD><clientStamp>${ messageId } </clientStamp><symbolApi><readSymbolValue><name>${ name } </name></readSymbolValue></symbolApi></RSVCMD>`
309374 client . write ( getVariable ) ;
310375
311376 const result = await waitForMessage ( messageId ) ;
0 commit comments