【问题标题】:using Ip address for Printer With PosExplorer Opos SDK.Net using C#使用 C# 使用带有 PosExplorer Opos SDK.Net 的打印机的 IP 地址
【发布时间】:2021-10-21 07:30:38
【问题描述】:

在使用打印机设备名称之前,我有这样的代码,但我们迁移了 现在在打印机上使用 ip 地址,我现有的代码看起来像这样

...

internal void ProcessInformation()
        {
            
            PosExplorer posExplorer = new PosExplorer();
            DeviceCollection receiptPrinterDevices = posExplorer.GetDevices(DeviceType.PosPrinter);
            DeviceInfo receiptPrinterDevice = posExplorer.GetDevice(DeviceType.PosPrinter, "SRP2");
            PosPrinter printer = (PosPrinter)posExplorer.CreateInstance(receiptPrinterDevice);

            printer.Open();
            printer.Claim(10000);
            printer.DeviceEnabled = true;
            printer.PrintNormal(PrinterStation.Receipt, "test print 1");

        }

...

我需要帮助才能开始,例如如何使用 PosExplorer 编写代码,使用 ip 地址将 api 连接到打印机并使用标题和正文格式进行打印?

【问题讨论】:

    标签: c# sdk azure-sdk-.net opos


    【解决方案1】:

    如何指定取决于打印机供应商提供的服务对象类型及其设置方式。

    似乎没有使用 POS for.NET API 的标准化通用方法。


    一种可能的方法是使用本机 POS for.NET 模块作为服务对象并使用PosCommon.DevicePath Property (POS for .NET v1.12 SDK Documentation)

    备注
    PosExplorer 类尝试使用以下算法将 DevicePath 属性初始化为物理设备的硬件路径:

    1和2是通过其他方式写入要预先设置的信息的方法。

    1. 如果物理硬件支持即插即用,并且服务对象通过 HardwareId 自定义属性或配置 XML 文件映射到特定硬件 ID,则 PosExplorer 类将 DevicePath 属性设置为物理设备的 HardwarePath 属性。服务对象通常可以使用此 DevicePath 属性直接访问设备。
    2. 如果设备不支持即插即用,但已通过 Posdm.exe 或 WMI 进行配置,则 DevicePath 属性将设置为配置设备时指定的路径。

    可以在应用程序执行时动态设置3。

    1. 如果设备不支持即插即用且未通过 Posdm.exe 或 WMI 进行配置,则 DevicePath 属性将设置为空字符串 (""),并且必须由可以调用基类中Open方法之前的Service Object。

    如果您对服务对象使用 OPOS,您可能需要更改 Windows 注册表设置,因此在运行应用程序时您无能为力。


    无论如何,请询问您的打印机供应商是否支持以及如何支持。

    【讨论】:

      猜你喜欢
      • 2011-10-16
      • 1970-01-01
      • 1970-01-01
      • 2010-12-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-09-20
      • 2014-01-25
      相关资源
      最近更新 更多