gpt4 book ai didi

ios - 我如何知道哪台打印机连接到钱箱。(EPSON SDK)

转载 作者:行者123 更新时间:2023-11-29 05:50:45 24 4
gpt4 key购买 nike

我正在使用 Epson 的 ePOS2 SDK 与收据打印机 TM-M30 进行通信。我能够成功连接到打印机并打印一些数据。但我需要打开现金抽屉。所以目前我不知道连接了哪台打印机钱箱。所以目前我添加了 for 循环并检查所有打印机。请检查我的代码

NSMutableArray *SelectedPrinter=[[NSUSERDEFAULTS valueForKey:@"SelectedPrinter"] mutableCopy];
for (int i=0; i<SelectedPrinter.count; i++)
{
[self printdataWithTarget:[[SelectedPrinter objectAtIndex:i] valueForKey:@"modelName"] withDeviceName:[[SelectedPrinter objectAtIndex:i] valueForKey:@"portName"]];
}

-(void)printdataWithTarget:(NSString*)target withDeviceName:(NSString *)deviceName
{
[[MPOSPrinter sharedManager] disconnectPrinter];
double delayInSeconds = 0.1;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
dispatch_after(popTime, dispatch_get_main_queue(), ^(void)
{
[[MPOSPrinter sharedManager] disconnectPrinter];
if ([[MPOSPrinter sharedManager] initializePrinter:deviceName])
{
if (![[MPOSPrinter sharedManager] connectPrinterWithPort:target])
{
[MBProgressHUD hideHUDForView:[APPDELEGATE window] animated:YES];
dispatch_async(dispatch_get_main_queue(), ^{
[MBProgressHUD hideHUDForView:[APPDELEGATE window] animated:YES];
[[UIApplication sharedApplication] endIgnoringInteractionEvents];
});
//showAlert(@"",@"Please ensure your device is connected with the Printer and you have selected this hardware from the settings menu.");
}
else
{
if ([[MPOSPrinter sharedManager] isPrintable:[[[MPOSPrinter sharedManager] printer] getStatus]])
{
[[[MPOSPrinter sharedManager] printer] addTextAlign:1];
[[[MPOSPrinter sharedManager] printer] addText:@""];
[[[MPOSPrinter sharedManager] printer] forceStopSound:0];

[[[MPOSPrinter sharedManager] printer] setReceiveEventDelegate:self];
[[[MPOSPrinter sharedManager] printer] addPulse:EPOS2_DRAWER_HIGH time:EPOS2_PULSE_100];
[[[MPOSPrinter sharedManager] printer] sendData:EPOS2_PARAM_DEFAULT];

}
else{
[MBProgressHUD hideHUDForView:[APPDELEGATE window] animated:YES];
}
}
}
else
{
[MBProgressHUD hideHUDForView:[APPDELEGATE window] animated:YES];
NSLog(@"Not Initialize");
}
});
}

最佳答案

我建议您“getStatus”,然后检查抽屉是否处于“未知”状态。如果已连接,则应报告“打开”或“关闭”。

参见getStatus documentation .

关于ios - 我如何知道哪台打印机连接到钱箱。(EPSON SDK),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55688425/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com