This commit is contained in:
nguyentrungthat 2025-12-08 09:37:32 +07:00
parent 086c440386
commit a363883329
2 changed files with 23 additions and 1 deletions

View File

@ -625,7 +625,7 @@ export class WebSocketIo {
// 👉 Bước 1: clear line trước khi connect // 👉 Bước 1: clear line trước khi connect
if (line.lineClear && line.lineClear > 0) if (line.lineClear && line.lineClear > 0)
await this.clearLineBeforeConnect(station.id, line.lineClear) await this.clearLineBeforeConnect(station.id, line.lineClear)
await sleep(500)
this.lineMap.set(line.id, lineConn) this.lineMap.set(line.id, lineConn)
await lineConn.connect() await lineConn.connect()
lineConn.writeCommand('\r\n\r\n') lineConn.writeCommand('\r\n\r\n')

View File

@ -64,6 +64,28 @@ export const DrawerAPCControl: React.FC<DrawerProps> = ({
>([]); >([]);
const [isSubmit, setIsSubmit] = useState(true); 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 = ( const detectOutlet = (
apc: APCProps, apc: APCProps,
lines: string[], lines: string[],