Emit update_status_ready and filter ready lines
Emit a dedicated 'update_status_ready' event when a LineConnection becomes ready, and stop sending isReady in the 'line_output' payload. On the server side, normalize incoming run_all_dpelp data and filter lineIds to only include lines that are already ready; also bail out early if no eligible lines or station isn't configured to send wiki. On the frontend, initialize line state with isReady, stop deriving readiness from line_output, and listen for the new 'update_status_ready' event to update line readiness in the UI.
This commit is contained in:
parent
4b65611269
commit
d68eca64c8
|
|
@ -253,13 +253,17 @@ export default class LineConnection {
|
|||
this.config.output = this.config.output.slice(-15000)
|
||||
if (!this.isReady && canInputCommand(message)) {
|
||||
this.isReady = true
|
||||
this.socketIO.emit('update_status_ready', {
|
||||
stationId,
|
||||
lineId: id,
|
||||
isReady: true,
|
||||
})
|
||||
}
|
||||
this.socketIO.emit('line_output', {
|
||||
stationId,
|
||||
lineId: id,
|
||||
data: message,
|
||||
ports: this.config.ports,
|
||||
isReady: this.isReady ? true : canInputCommand(message),
|
||||
})
|
||||
setTimeout(() => {
|
||||
if (!this.config.inventory) {
|
||||
|
|
|
|||
|
|
@ -605,7 +605,7 @@ export class WebSocketIo {
|
|||
|
||||
socket.on('run_all_dpelp', async (data) => {
|
||||
try {
|
||||
const lineIds = data.lineIds
|
||||
const dataLines = data.lineIds || []
|
||||
const stationName = data.stationName || ''
|
||||
const stationId = data.stationId || ''
|
||||
const scenarioName = data.scenarioName || ''
|
||||
|
|
@ -613,9 +613,17 @@ export class WebSocketIo {
|
|||
// Check station is active
|
||||
const activeStation = await checkStationActive(stationId)
|
||||
if (!activeStation) return
|
||||
// Filter line is not ready
|
||||
let lineIds: number[] = []
|
||||
for (const lineId of dataLines) {
|
||||
const line = this.lineMap.get(lineId)
|
||||
if (line && line.isReady) {
|
||||
lineIds.push(lineId)
|
||||
}
|
||||
}
|
||||
// Check station sendWiki flag
|
||||
console.log('[DPELP] Received run all dpelp', lineIds)
|
||||
if (!station || !station?.send_wiki) return
|
||||
if (!station || !station?.send_wiki || lineIds?.length < 1) return
|
||||
|
||||
const results = await this.waitUntilAllReady(lineIds)
|
||||
const tableHTML = this.generateTable(results)
|
||||
|
|
|
|||
|
|
@ -257,6 +257,7 @@ function App() {
|
|||
output: "[CLEAR_TERMINAL_SCROLL_BACK]",
|
||||
listFeatureTested: [],
|
||||
latestScenario: undefined,
|
||||
isReady: false,
|
||||
},
|
||||
data?.stationId
|
||||
)
|
||||
|
|
@ -264,11 +265,11 @@ function App() {
|
|||
|
||||
socket?.on("line_output", (data) => {
|
||||
const { lineId, data: text } = data;
|
||||
updateValueLineStation(
|
||||
data?.lineId,
|
||||
{ isReady: data.isReady },
|
||||
data?.stationId
|
||||
);
|
||||
// updateValueLineStation(
|
||||
// data?.lineId,
|
||||
// { isReady: data.isReady },
|
||||
// data?.stationId
|
||||
// );
|
||||
|
||||
const buf = lineBuffersRef.current.get(lineId) || "";
|
||||
lineBuffersRef.current.set(lineId, buf + text);
|
||||
|
|
@ -279,6 +280,15 @@ function App() {
|
|||
}
|
||||
});
|
||||
|
||||
socket?.on("update_status_ready", (data) => {
|
||||
const { isReady } = data;
|
||||
updateValueLineStation(
|
||||
data?.lineId,
|
||||
{ isReady: isReady },
|
||||
data?.stationId
|
||||
);
|
||||
});
|
||||
|
||||
socket?.on("line_error", (data) => {
|
||||
updateValueLineStation(
|
||||
data?.lineId,
|
||||
|
|
|
|||
Loading…
Reference in New Issue