refactor(ocp): plc reading changes to disconnect and reconnect
it was found that there were some errors that spammed the log and caused the server to actually stop responding and crash weirdly so added a disconnect and reconnect back. so we can figure out whats going on.
This commit is contained in:
@@ -39,7 +39,7 @@ export const dycoConnect = async () => {
|
||||
"debug",
|
||||
"dyco",
|
||||
"ocp",
|
||||
"Skipping cycle: previous read still in progress."
|
||||
"Skipping cycle: previous read still in progress.",
|
||||
);
|
||||
return;
|
||||
}
|
||||
@@ -62,8 +62,14 @@ export const dycoConnect = async () => {
|
||||
"error",
|
||||
"dyco",
|
||||
"ocp",
|
||||
`Error reading PLC tag: ${error.message}`
|
||||
`Error reading PLC tag: ${error.message}`,
|
||||
);
|
||||
// if we error out we want to disconnect and reconnect
|
||||
closeDyco();
|
||||
setTimeout(() => {
|
||||
createLog("info", "dyco", "ocp", `Reconnecting to the dyco`);
|
||||
dycoConnect();
|
||||
}, 2 * 1000);
|
||||
} finally {
|
||||
isReading = false; // Reset flag
|
||||
}
|
||||
@@ -74,7 +80,7 @@ export const dycoConnect = async () => {
|
||||
"error",
|
||||
"dyco",
|
||||
"ocp",
|
||||
`There was an error in the dyco: ${error}`
|
||||
`There was an error in the dyco: ${error}`,
|
||||
);
|
||||
await PLC.disconnect();
|
||||
isDycoRunning = false;
|
||||
|
||||
Reference in New Issue
Block a user