Printing Epson ePOS SDK实时检查打印机状态

Printing Epson ePOS SDK实时检查打印机状态,printing,printers,epson,receipt,epos,Printing,Printers,Epson,Receipt,Epos,如何实时检查爱普生收据打印机状态 目前,我正在使用定时计时器运行Epos2Discovery.start(每10秒启动一次),以检查打印机可用性 printerCheckTimer = Timer.scheduledTimer(timeInterval: 10, target: self, selector: #selector(checkPrinter), userInfo: nil, repeats: true) // Listen for printer connection @obj

如何实时检查爱普生收据打印机状态

目前,我正在使用定时计时器运行Epos2Discovery.start(每10秒启动一次),以检查打印机可用性

printerCheckTimer = Timer.scheduledTimer(timeInterval: 10, target: self, selector: #selector(checkPrinter), userInfo: nil, repeats: true)


// Listen for printer connection
@objc func checkPrinter() {
        // Stop previous epson printer discovery if any, and reset scanned epson printers array
        var result = EPOS2_SUCCESS.rawValue
        result = Epos2Discovery.stop()

        // Search for epson printers
        result = Epos2Discovery.start(filterOption, delegate: self)
        if result != EPOS2_SUCCESS.rawValue {
            print(result)
        }
}

// Delegate for epson printer discovery
func onDiscovery(_ deviceInfo: Epos2DeviceInfo!) {
    // Loop all the connected epson printers port, and see if they exists in the nearby ports
    for (printerId, connectedPrinterPort) in self.connectedEpsonPrinters {
        if connectedPrinterPort == deviceInfo.target {
            onlineEpsonPrinters[printerId] = Int(Date().timeIntervalSince1970)
        }
    }
}
此解决方案适用于较旧的TM-T82(序列号:UEHF…)。然而,对于TM-T82的较新版本(序列号:X4XQ…),这似乎是有问题的

运行Epos2Discovery.start计时器的并发设备的数量似乎会影响打印的性能

当使用1台设备时,它工作正常,打印速度也一样快。但是,对于2台设备,打印速度变慢(可能慢5秒)

使用3台设备时,打印机状态将在联机和脱机状态之间闪烁,一半的打印将以失败的打印错误提示结束。似乎在多个设备上同时运行Epos2Discovery(带有循环计时器)会导致打印机检测出现问题

这只发生在最新版本的TM型号上,对于我以前购买的旧打印机(TM-T88、TM-U220B、TM-T81),它工作得非常好


我想知道是否有其他方法可以实时检查打印机状态?

您解决了这个问题吗?我也在寻找类似的实现。sdk中有setReceiveEventDelegate,但它似乎不是实时的。