使用TCP/IP为POS打印机创建手动配置.xml文件



我有2台Epson TM-T81热敏打印机,1个USB,1个以太网端口。到目前为止,我每次只使用一台打印机。

我已经构建了一个c#代码,它可以打印到特定的打印机。现在我想有2台打印机与我的程序相关联。为此,我发现我需要调整我所在位置的configuration.xml:

C: \ProgramData\Microsoft\服务点\配置\配置.xml

我现在需要做什么改变来配置USB打印机。但我的以太网打印机将直接连接到我的无线路由器,该路由器已经安装,但没有更新configuration.xml。

这是我的c#代码

    <code>
     try
     {
        //Create PosExplorer
        PosExplorer posExplorer = new PosExplorer();
        DeviceInfo deviceInfo = null;
        String strLogicalName="EpsonSale";
        try
        {
            deviceInfo = posExplorer.GetDevice(DeviceType.PosPrinter, strLogicalName);
            m_Printer = (PosPrinter)posExplorer.CreateInstance(deviceInfo);
        }
        catch (Exception)
        {
            //ChangeButtonStatus();
            return;
        }
        //Register OutputCompleteEventHandler.
        AddOutputComplete(m_Printer);
        //Open the device
        m_Printer.Open();
        try
        {
            //Get the exclusive control right for the opened device.
            //Then the device is disable from other application.
            m_Printer.Claim(1000);
            Console.WriteLine("Printer claimed");
        }
        catch (Exception e)
        {
            Console.WriteLine("Printer Not claimed");
        }
        //Enable the device.
        m_Printer.DeviceEnabled = true;
        //<<<step3>>>--Start
        //Output by the high quality mode
        m_Printer.RecLetterQuality = true;
       }
       catch(Exception){ Console.WriteLine("Printer Initialization failed.");}

包含服务对象的配置.xml文件:

 <code>
   <?xml version="1.0"?>
  <PointOfServiceConfig Version="1.0">
 <ServiceObject Type="PosPrinter" Name="TM-T81_203">
 <Device HardwarePath="ESDPRT001">
  <LogicalName Name="EpsonSale" />
  <Property Name="AsyncProcessingSize" Value="2" />
  <Property Name="AutoPowerOff" Value="0" />
  <Property Name="ConfigurationFile" Value="epson/xml/Setting/TM-T81_203Setting.xml" />
  <Property Name="Custom1Color" Value="0" />
  <Property Name="Cutter" Value="1" />
  <Property Name="DefaultCodePage" Value="997" />
  <Property Name="DefaultSlpClampTime" Value="0" />
  <Property Name="DeviceDesc" Value="EPSON TM-T81 POSPrinter" />
  <Property Name="DirectIOEventTimeout" Value="5000" />
  <Property Name="epson.trace.file" Value="trace.log" />
  <Property Name="epson.trace.max.size" Value="1000" />
  <Property Name="epson.tracing" Value="false" />
  <Property Name="EPurasSupport" Value="TRUE" />
  <Property Name="FirmLogFileName" Value="Firmware.log" />
  <Property Name="FirmLogFileSize" Value="1000" />
  <Property Name="FirmNotifyAllProgressEvents" Value="0" />
  <Property Name="FirmProgressRange" Value="10" />
  <Property Name="FirmRecordLog" Value="1" />
  <Property Name="Halftone" Value="0" />
  <Property Name="InitializeResponseTimeout" Value="5000" />
  <Property Name="InitializeThreadTime" Value="1000" />
  <Property Name="InputBufferSize" Value="4096" />
  <Property Name="InputTimeout" Value="1000" />
  <Property Name="KanjiTwoWaysPrint" Value="0" />
  <Property Name="LogicalName" Value="EpsonSale" />
  <Property Name="LogicalPortInterfaceName" Value="EPuras" />
  <Property Name="LogicalPortName" Value="pipe://TM/ESDPRT001" />
  <Property Name="LogObject" Value="" />
  <Property Name="MemorySwitch" Value="0" />
  <Property Name="NVRAMControlLevel" Value="1" />
  <Property Name="OfflineCount" Value="1" />
  <Property Name="OfflineRetryIntervalTime" Value="100" />
  <Property Name="OutputBufferSize" Value="32768" />
  <Property Name="OutputCompleteType" Value="2" />
  <Property Name="OutputErrorOption" Value="0" />
  <Property Name="OutputTimeout" Value="2000" />
  <Property Name="PageModeExt" Value="0" />
  <Property Name="Peeler" Value="0" />
  <Property Name="PhysicalDevice" Value="TM-T81_203" />
  <Property Name="PhysicalPrinterName" Value="TM-T81_203" />
  <Property Name="PortInterfaceName" Value="USB" />
  <Property Name="PortName" Value="ESDPRT001" />
  <Property Name="PortType" Value="3" />
  <Property Name="PrinterTransmitTimeout" Value="30000" />
  <Property Name="QueuingOfflineTimeout" Value="1000" />
  <Property Name="ReadThreadInterval" Value="-1" />
  <Property Name="RecCharactersPerLine" Value="48" />
  <Property Name="ReceiveRetryTime" Value="25" />
  <Property Name="ReceiveTimeout" Value="1000" />
  <Property Name="RecLineSpacing" Value="30" />
  <Property Name="RecMoreColumns" Value="0" />
  <Property Name="RecNearEndSensor" Value="1" />
  <Property Name="RecPaperType" Value="0" />
  <Property Name="SlpMoreColumns" Value="0" />
  <Property Name="SlpReverseEject" Value="0" />
  <Property Name="Stamp" Value="0" />
  <Property Name="StatusThreadInterval" Value="500" />
  <Property Name="SupportFirmware" Value="0" />
  <Property Name="SupportStatistics" Value="1" />
  <Property Name="TcpPort" Value="9100" />
  <Property Name="TransmitRetryTime" Value="100" />
  <Property Name="TransmitTimeout" Value="5000" />
  <Property Name="TwoByteCharacter" Value="5" />
  <Property Name="TwoColor" Value="0" />
  <Property Name="U375Compatible" Value="0" />
  <Property Name="UdpPort" Value="3289" />
  <Property Name="UdpReceiveTimeout" Value="1000" />
  <Property Name="UdpRetryCount" Value="2" />
  <Property Name="UdpRetryIntervalTime" Value="50" />
  <Property Name="UdpTransmitTimeout" Value="1000" />
  <Property Name="Upos.Spec_c" Value="false" />
  <Property Name="Upos.USB_Serial" Value="false" />
  <Property Name="UsedInterCharacterSet" Value="0" />
  <Property Name="UsedNVRAM" Value="0" />
  <Property Name="UsedPeeler" Value="0" />
  <Property Name="WriteThreadInterval" Value="-1" />
  </Device>
  </ServiceObject> 
  </PointOfServiceConfig>
  </code>

这台打印机被正确地声明为USB打印机,但我如何为我的TCP/IP端口打印机添加服务对象?我在某个地方读到可以直接向该文件添加serviceObject,但我的属性是什么?此外,我使用的是TCP/IP端口,而不是"ESDPRT10xx"端口。我甚至尝试了Sean Liming的一个程序-SOMgr.exe来创建服务对象,但没有发现它有用。我无法使用posExplorer.GetDevice() 定位我的Epson打印机

此外,如果我在这篇文章的代码格式上有任何错误,我也很抱歉。

我不确定这是否会对您有所帮助。就我的情况而言,我使用JavaPOS而不是C#,并且我设法用以太网I/F卡打印到我的Epson TMU220。看看下面的xml配置文件。

<JposEntry logicalName="EpsonTMU220BEthernet">
    <creation factoryClass="jp.co.epson.uposcommon.util.EpsonJposServiceInstanceFactory" 
              serviceClass="jp.co.epson.upos.pntr.U220BService"/>
    <vendor name="SEIKO EPSON" url="http://www.epson.com"/>
    <jpos category="POSPrinter" version="1.11"/>
    <product description="EPSON TM-U220B Printer Device Service" 
             name="EPSON Services for JavaPOS(TM) Standard" 
             url="http://www.epson.com"/>
    <!--Other non JavaPOS required property 
    (mostly vendor properties and bus specific properties i.e. RS232 )-->
    <prop name="Halftone" type="String" value="0"/>
    <prop name="PhysicalPrinterName" type="String" value="TM-U220B"/>
    <prop name="NVRAMControlLevel" type="String" value="1"/>
    <prop name="Stamp" type="String" value="0"/>
    <prop name="OutputCompleteType" type="String" value="2"/>
    <prop name="StatusThreadInterval" type="String" value="500"/>
    <prop name="OutputTimeout" type="String" value="2000"/>
    <prop name="PortType" type="String" value="3"/>
    <prop name="OutputBufferSize" type="String" value="32768"/>
    <prop name="UsedNVRAM" type="String" value="0"/>
    <prop name="FirmRecordLog" type="String" value="1"/>
    <prop name="UdpRetryIntervalTime" type="String" value="50"/>
    <prop name="ReceiveTimeout" type="String" value="1000"/>
    <prop name="SlpReverseEject" type="String" value="0"/>
    <prop name="OfflineRetryIntervalTime" type="String" value="100"/>
    <prop name="PortName" type="String" value="192.168.12.192"/>
    <prop name="Upos.USB_Serial" type="String" value="false"/>
    <prop name="DefaultSlpClampTime" type="String" value="0"/>
    <prop name="epson.trace.file" type="String" value="trace.log"/>
    <prop name="AsyncProcessingSize" type="String" value="1"/>
    <prop name="KanjiTwoWaysPrint" type="String" value="0"/>
    <prop name="PulseStep" type="String" value="100"/>
    <prop name="PortInterfaceName" type="String" value="Ethernet"/>
    <prop name="U375Compatible" type="String" value="0"/>
    <prop name="preCutterFunction" type="String" value="0"/>
    <prop name="epson.tracing" type="String" value="false"/>
    <prop name="epson.trace.max.size" type="String" value="1000"/>
    <prop name="RecPaperSize" type="String" value="76"/>
    <prop name="DeviceDesc" type="String" 
          value="EPSON TM-U220B POSPrinter"/>
    <prop name="PageModeExt" type="String" value="0"/>
    <prop name="SupportStatistics" type="String" value="1"/>
    <prop name="FirmProgressRange" type="String" value="10"/>
    <prop name="OutputErrorOption" type="String" value="0"/>
    <prop name="UdpReceiveTimeout" type="String" value="1000"/>
    <prop name="SupportFirmware" type="String" value="0"/>
    <prop name="DeviceID" type="String" value="13"/>
    <prop name="InputTimeout" type="String" value="1000"/>
    <prop name="AutoPowerOff" type="String" value="0"/>
    <prop name="SlpMoreColumns" type="String" value="0"/>
    <prop name="RecPaperType" type="String" value="0"/>
    <prop name="MemorySwitch" type="String" value="0"/>
    <prop name="ReadThreadInterval" type="String" value="-1"/>
    <prop name="QueuingOfflineTimeout" type="String" value="1000"/>
    <prop name="InitializeThreadTime" type="String" value="1000"/>
    <prop name="TwoColor" type="String" value="1"/>
    <prop name="TwoByteCharacter" type="String" value="2"/>
    <prop name="UdpTransmitTimeout" type="String" value="1000"/>
    <prop name="FirmLogFileSize" type="String" value="1000"/>
    <prop name="Peeler" type="String" value="0"/>
    <prop name="ConfigurationFile" type="String" 
          value="epson/xml/Setting/TM-U220BSetting.xml"/>
    <prop name="Custom1Color" type="String" value="0xFF0000"/>
    <prop name="preEndorseFunction" type="String" value="0"/>
    <prop name="Upos.Spec_c" type="String" value="false"/>
    <prop name="UdpRetryCount" type="String" value="2"/>
    <prop name="FirmNotifyAllProgressEvents" type="String" value="0"/>
    <prop name="InitializeResponseTimeout" type="String" value="5000"/>
    <prop name="ReceiveRetryTime" type="String" value="25"/>
    <prop name="PrinterTransmitTimeout" type="String" value="30000"/>
    <prop name="RecMoreColumns" type="String" value="0"/>
    <prop name="UsedInterCharacterSet" type="String" value="0"/>
    <prop name="TcpPort" type="String" value="9100"/>
    <prop name="WriteThreadInterval" type="String" value="-1"/>
    <prop name="UdpPort" type="String" value="3289"/>
    <prop name="preORCBFunction" type="String" value="0"/>
    <prop name="RecNearEndSensor" type="String" value="0"/>
    <prop name="LogObject" type="String" value=""/>
    <prop name="Cutter" type="String" value="1"/>
    <prop name="PhysicalDevice" type="String" value="TM-U220B"/>
    <prop name="FirmLogFileName" type="String" value="Firmware.log"/>
    <prop name="UsedPeeler" type="String" value="0"/>
    <prop name="InputBufferSize" type="String" value="4096"/>
    <prop name="TransmitTimeout" type="String" value="5000"/>
    <prop name="EPurasSupport" type="String" value="TRUE"/>
    <prop name="OfflineCount" type="String" value="1"/>
    <prop name="TransmitRetryTime" type="String" value="100"/>
    <prop name="DirectIOEventTimeout" type="String" value="5000"/>
</JposEntry>  

我认为有一些值需要更改才能使其工作,例如:prop name="PortName"更改为"打印机IP地址",而不是"ESDPRT001"。工作愉快!

最新更新