完善分发收集续做、打印机状态查询与任务字段对齐
- 完成/失败态统一卡位13自动续做,修复主进程失败时 mode 被重置导致续做被拒 - 接入 SAPI_PrinterCheckstatus,Header 轻量刷状态,Init 后一次 GetPrinterInfo - print_flag 取自 soon.flag,path_file 目录级 staging,加密狗与格式化选项对齐 - 失败页并入运行页,移除独立 DistributeFailedView Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -95,14 +95,12 @@ export function startJobPoll(id: string): void {
|
||||
log.warn('GetJobStateById query failed', r.queryErrorCode)
|
||||
return
|
||||
}
|
||||
if (failed || cancelled) {
|
||||
stopJobPoll(true)
|
||||
} else if (finished) {
|
||||
if (failed || cancelled || finished) {
|
||||
stopJobPoll(false)
|
||||
}
|
||||
} catch (e) {
|
||||
log.error('job poll error', e)
|
||||
stopJobPoll(true)
|
||||
stopJobPoll(false)
|
||||
}
|
||||
})()
|
||||
}, POLL_INTERVAL_MS)
|
||||
@@ -115,7 +113,7 @@ export function startUsbPoll(): void {
|
||||
usbTimer = setInterval(() => {
|
||||
void pollUsbOnce(gen).catch((e) => {
|
||||
log.error('usb poll error', e)
|
||||
stopUsbPoll(true)
|
||||
stopUsbPoll(false)
|
||||
})
|
||||
}, POLL_INTERVAL_MS)
|
||||
}
|
||||
@@ -156,21 +154,24 @@ async function pollUsbOnce(gen: number): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
async function pollCardPositionOnce(): Promise<void> {
|
||||
try {
|
||||
const dll = await loadDllModule()
|
||||
if (!dll.isCardPositionApiAvailable()) return
|
||||
const r = dll.dllGetPrinterCardPosition()
|
||||
const tick = { queryCode: r.queryCode, position: r.position }
|
||||
emitTrace('[poll] card:position-tick', tick)
|
||||
send('card:position-tick', tick)
|
||||
} catch (e) {
|
||||
log.error('card position poll error', e)
|
||||
}
|
||||
}
|
||||
|
||||
export function startCardPositionPoll(): void {
|
||||
stopCardPositionPoll()
|
||||
void pollCardPositionOnce()
|
||||
cardTimer = setInterval(() => {
|
||||
void (async () => {
|
||||
try {
|
||||
const dll = await loadDllModule()
|
||||
if (!dll.isCardPositionApiAvailable()) return
|
||||
const r = dll.dllGetPrinterCardPosition()
|
||||
const tick = { queryCode: r.queryCode, position: r.position }
|
||||
emitTrace('[poll] card:position-tick', tick)
|
||||
send('card:position-tick', tick)
|
||||
} catch (e) {
|
||||
log.error('card position poll error', e)
|
||||
}
|
||||
})()
|
||||
void pollCardPositionOnce()
|
||||
}, POLL_INTERVAL_MS)
|
||||
}
|
||||
|
||||
|
||||
@@ -47,9 +47,12 @@ let SAPI_PrinterMovetousbreader: any = null
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
let SAPI_GetPrinterCardPosition: any = null
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
let SAPI_PrinterCheckstatus: any = null
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
let SAPI_UploadFile: any = null
|
||||
let hasRejectApi = false
|
||||
let hasCardPositionApi = false
|
||||
let hasCheckstatusApi = false
|
||||
let hasCancelApi = false
|
||||
let hasUploadApi = false
|
||||
let hasPrinterInfoEx = false
|
||||
@@ -179,13 +182,23 @@ function loadLibrary(): void {
|
||||
emitTrace('[dll] SAPI_GetPrinterCardPosition not in workDll (optional)')
|
||||
}
|
||||
|
||||
try {
|
||||
SAPI_PrinterCheckstatus = lib.func('int __stdcall SAPI_PrinterCheckstatus()')
|
||||
hasCheckstatusApi = true
|
||||
} catch {
|
||||
SAPI_PrinterCheckstatus = null
|
||||
hasCheckstatusApi = false
|
||||
emitTrace('[dll] SAPI_PrinterCheckstatus not in workDll (optional)')
|
||||
}
|
||||
|
||||
log.info('workDll loaded', {
|
||||
upload: hasUploadApi,
|
||||
printerInfoEx: hasPrinterInfoEx,
|
||||
cancel: hasCancelApi,
|
||||
reject: hasRejectApi,
|
||||
usbReader: hasUsbReaderApi,
|
||||
cardPosition: hasCardPositionApi
|
||||
cardPosition: hasCardPositionApi,
|
||||
checkstatus: hasCheckstatusApi
|
||||
})
|
||||
}
|
||||
|
||||
@@ -214,6 +227,11 @@ export function isCardPositionApiAvailable(): boolean {
|
||||
return hasCardPositionApi
|
||||
}
|
||||
|
||||
export function isPrinterCheckstatusApiAvailable(): boolean {
|
||||
loadLibrary()
|
||||
return hasCheckstatusApi
|
||||
}
|
||||
|
||||
export function dllInit(params: InitParams): number {
|
||||
return traceCall(
|
||||
'SAPI_Init',
|
||||
@@ -336,7 +354,6 @@ export function dllCopyFromUsb(destFolder: string, cardOutput: number): number {
|
||||
export function dllGetUsbCopyState(): {
|
||||
queryCode: number
|
||||
taskStatus: number
|
||||
/** copy_progress 0-100 */
|
||||
progress: number
|
||||
} {
|
||||
return traceCall('SAPI_GetUsbCopyState', undefined, () => {
|
||||
@@ -384,3 +401,11 @@ export function dllGetPrinterCardPosition(): { queryCode: number; position: numb
|
||||
return { queryCode, position: position[0] }
|
||||
})
|
||||
}
|
||||
|
||||
export function dllPrinterCheckstatus(): number {
|
||||
return traceCall('SAPI_PrinterCheckstatus', undefined, () => {
|
||||
loadLibrary()
|
||||
if (!SAPI_PrinterCheckstatus) throw new Error('CHECKSTATUS_API_UNAVAILABLE')
|
||||
return SAPI_PrinterCheckstatus!() as number
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user