|
|
@ -4730,6 +4730,53 @@ client.on('message', async (topic, message) => {
|
|
|
|
const inputConnection = motorTank.connections.inputConnections.find(conn => conn.motor_id === hw_Id); // Updated variable name
|
|
|
|
const inputConnection = motorTank.connections.inputConnections.find(conn => conn.motor_id === hw_Id); // Updated variable name
|
|
|
|
if (inputConnection) {
|
|
|
|
if (inputConnection) {
|
|
|
|
inputConnection.motor_status = status; // Update motor status
|
|
|
|
inputConnection.motor_status = status; // Update motor status
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (inputConnection.motor_stop_status === "1" && status === "2") {
|
|
|
|
|
|
|
|
console.log("got into forced manual")
|
|
|
|
|
|
|
|
console.log(inputConnection.motor_on_type,"before if motor on type")
|
|
|
|
|
|
|
|
// Check if motor_on_type is not already "forced_manual"
|
|
|
|
|
|
|
|
if (inputConnection.motor_on_type !== "forced_manual") {
|
|
|
|
|
|
|
|
inputConnection.motor_on_type = "forced_manual";
|
|
|
|
|
|
|
|
console.log("entered forced manual of if")
|
|
|
|
|
|
|
|
inputConnection.motor_stop_status = "2";
|
|
|
|
|
|
|
|
// Update startTime to the current time in the specified format
|
|
|
|
|
|
|
|
const currentTime = new Date();
|
|
|
|
|
|
|
|
const formattedTime = currentTime.toLocaleString('en-GB', {
|
|
|
|
|
|
|
|
day: '2-digit',
|
|
|
|
|
|
|
|
month: 'short',
|
|
|
|
|
|
|
|
year: 'numeric',
|
|
|
|
|
|
|
|
hour: '2-digit',
|
|
|
|
|
|
|
|
minute: '2-digit',
|
|
|
|
|
|
|
|
hour12: false,
|
|
|
|
|
|
|
|
}).replace(',', '');
|
|
|
|
|
|
|
|
inputConnection.startTime = formattedTime;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (inputConnection.motor_stop_status === "2" && status === "1") {
|
|
|
|
|
|
|
|
console.log("got into forced manual stop")
|
|
|
|
|
|
|
|
console.log(inputConnection.motor_on_type,"before if motor on type stop")
|
|
|
|
|
|
|
|
// Check if motor_on_type is not already "forced_manual"
|
|
|
|
|
|
|
|
if (inputConnection.motor_on_type = "forced_manual") {
|
|
|
|
|
|
|
|
inputConnection.motor_on_type = "manual";
|
|
|
|
|
|
|
|
console.log("entered forced manual of if of stop")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Update startTime to the current time in the specified format
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inputConnection.motor_stop_status = "1";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await motorTank.save(); // Save the updated tank
|
|
|
|
await motorTank.save(); // Save the updated tank
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|