Update line_connection.ts
This commit is contained in:
parent
b1b4f1b907
commit
dd32246f9f
|
|
@ -226,11 +226,11 @@ export default class LineConnection {
|
|||
data: message,
|
||||
ports: this.config.ports,
|
||||
})
|
||||
if (!this.config.inventory) {
|
||||
setTimeout(() => {
|
||||
setTimeout(() => {
|
||||
if (!this.config.inventory) {
|
||||
this.getInventory()
|
||||
}, 5000)
|
||||
}
|
||||
}
|
||||
}, 5000)
|
||||
appendLog(
|
||||
cleanData(message),
|
||||
this.config.stationId,
|
||||
|
|
@ -359,6 +359,7 @@ export default class LineConnection {
|
|||
`Run scenario "${script?.title}" to line ${this.config.lineNumber} of ${this.config.stationName}`
|
||||
)
|
||||
this.config.runningScenario = script?.title
|
||||
this.config.data = []
|
||||
this.socketIO.emit('running_scenario', {
|
||||
stationId: this.config.stationId,
|
||||
lineId: this.config.id,
|
||||
|
|
@ -442,6 +443,8 @@ export default class LineConnection {
|
|||
}, 5000)
|
||||
return
|
||||
} else clearTimeout(timeoutTimer)
|
||||
this.outputScenario += `\n---end-scenarios---${now}---${userName}---\n`
|
||||
this.outputBuffer = ''
|
||||
this.config.runningScenario = ''
|
||||
this.socketIO.emit('running_scenario', {
|
||||
stationId: this.config.stationId,
|
||||
|
|
@ -459,7 +462,9 @@ export default class LineConnection {
|
|||
['show inventory', 'sh inventory', 'show inv', 'sh inv'].includes(item.command)
|
||||
) {
|
||||
const dataInventory = JSON.parse(item.textfsm)[0]
|
||||
this.config.inventory = dataInventory
|
||||
this.config.inventory = this.config.inventory
|
||||
? { ...this.config.inventory, ...dataInventory }
|
||||
: dataInventory
|
||||
pid = dataInventory?.pid || ''
|
||||
this.addHistory(this.config.stationId, this.config.id, {
|
||||
id: this.config.id,
|
||||
|
|
@ -531,8 +536,8 @@ export default class LineConnection {
|
|||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
this.outputBuffer = ''
|
||||
this.outputScenario += `\n---end-scenarios---${now}---${userName}---\n`
|
||||
// this.outputBuffer = ''
|
||||
// this.outputScenario += `\n---end-scenarios---${now}---${userName}---\n`
|
||||
appendLog(
|
||||
`\n---end-scenarios---${now}---${userName}---\n`,
|
||||
this.config.stationId,
|
||||
|
|
@ -651,8 +656,6 @@ export default class LineConnection {
|
|||
const start = Date.now()
|
||||
// console.log('[EXPECT]', expect, timeout)
|
||||
while (Date.now() - start < timeout) {
|
||||
console.log(expect)
|
||||
console.log(this.outputBuffer)
|
||||
if (this.outputBuffer.includes(expect)) {
|
||||
this.outputBuffer = ''
|
||||
return true
|
||||
|
|
@ -673,12 +676,6 @@ export default class LineConnection {
|
|||
? { ...this.config.inventory, ...dataInventory }
|
||||
: dataInventory
|
||||
}
|
||||
if (['show version', 'sh version', 'show ver', 'sh ver'].includes(item.command)) {
|
||||
const dataVer = JSON.parse(item.textfsm)[0]
|
||||
this.config.inventory = this.config.inventory
|
||||
? { ...this.config.inventory, ...dataVer }
|
||||
: dataVer
|
||||
}
|
||||
item.textfsm = JSON.parse(item.textfsm)
|
||||
}
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in New Issue