diff --git a/BACKEND/providers/socket_io_provider.ts b/BACKEND/providers/socket_io_provider.ts index e2485e8..82efbb6 100644 --- a/BACKEND/providers/socket_io_provider.ts +++ b/BACKEND/providers/socket_io_provider.ts @@ -625,7 +625,7 @@ export class WebSocketIo { // 👉 Bước 1: clear line trước khi connect if (line.lineClear && line.lineClear > 0) await this.clearLineBeforeConnect(station.id, line.lineClear) - + await sleep(500) this.lineMap.set(line.id, lineConn) await lineConn.connect() lineConn.writeCommand('\r\n\r\n') diff --git a/FRONTEND/src/components/Drawer/DrawerControl.tsx b/FRONTEND/src/components/Drawer/DrawerControl.tsx index d39c3b1..8666392 100644 --- a/FRONTEND/src/components/Drawer/DrawerControl.tsx +++ b/FRONTEND/src/components/Drawer/DrawerControl.tsx @@ -64,6 +64,28 @@ export const DrawerAPCControl: React.FC = ({ >([]); const [isSubmit, setIsSubmit] = useState(true); + useEffect(() => { + setListOutletSelected([]); + setListOutlet( + Array.from({ length: 16 }) + .map((_, index) => ({ + number: index / 8 < 1 ? index + 1 : index - 7, // Outlet numbers 1-8 for APC 1, 1-8 for APC 2 + name: `Outlet ${(index % 8) + 1}`, + status: "OFF", + apc: index / 8 < 1 ? 1 : 2, // Assuming two APCs, alternating outlets + })) + .map((el) => { + const line = findLineByOutlet(el); + if (!line) return el; + return { + ...el, + name: "Line " + line.lineNumber || el.name, + }; + }) + ); + setIsSubmit(true); + }, [stationId]); + const detectOutlet = ( apc: APCProps, lines: string[],