SOCKET: Difference between revisions

From Commander4j
No edit summary
 
(11 intermediate revisions by the same user not shown)
Line 1: Line 1:
[[Category: Middleware4j]]
The SOCKET Connector can be used for sending data to a device via a TCP/IP Socket Connection.
The SOCKET Connector can be used for sending data to a device via a TCP/IP Socket Connection.


=SOCKET Map Configuration=
=SOCKET Map Configuration=
'''config.xml'''
'''config.xml'''
 
<syntaxhighlight lang="xml">
  <map id="map430" enabled="Y" description="GEN XML to SOCKET">
  <map id="map430" enabled="Y" description="GEN XML to SOCKET">
   <input id="in1" description="Read XML Document">
   <input id="in1" description="Read XML Document">
Line 23: Line 24:
   </output>
   </output>
  </map>
  </map>
</syntaxhighlight>


=Sample XML=
=Sample XML=
'''Socket Data.xml'''
'''Socket Data.xml'''
<?xml version="1.0" encoding="UTF-8"?>
<syntaxhighlight lang="xml">
  <data>
  <data>
     <line eol="cr">^XA</line>
     <line eol="cr">^XA</line>
Line 65: Line 67:
     <line eol="cr">^XZ</line>
     <line eol="cr">^XZ</line>
     <line>*EOF*</line>
     <line>*EOF*</line>
1234
  </data>
  </data>
</syntaxhighlight>


In this example the map assumes that the input document is in the correct format to be used by the connector. However you can read the data from a plain ASCII file or CSV and then apply a XSLT transformation to format the data into the format shown above.
In this example the map assumes that the input document is in the correct format to be used by the connector. However you can read the data from a plain ASCII file or CSV and then apply a XSLT transformation to format the data into the format shown above.
Line 76: Line 78:
=CSV to SOCKET Map Configuration=
=CSV to SOCKET Map Configuration=
'''config.xml'''
'''config.xml'''
<syntaxhighlight lang="xml">
  <map id="map430" enabled="Y" description="GEN XML to SOCKET">
  <map id="map430" enabled="Y" description="GEN XML to SOCKET">
   <input id="in1" description="Read XML Document">
   <input id="in1" description="Read XML Document">
Line 95: Line 98:
   </output>
   </output>
  </map>
  </map>
</syntaxhighlight>


The above illustration adds the following element `<XSLT>CSV_to_SOCKET.xsl</XSLT>` and it would need to transform the XML internal representation of the CSV data into the SOCKET message format.
The above illustration adds the following element `<XSLT>CSV_to_SOCKET.xsl</XSLT>` and it would need to transform the XML internal representation of the CSV data into the SOCKET message format.


For an exmaple of how CSV data is loaded into an intermediate XML document refer to the [[CSV Connector]] documentation
For an exmaple of how CSV data is loaded into an intermediate XML document refer to the [[CSV Connector]] documentation

Latest revision as of 11:27, 25 August 2024

The SOCKET Connector can be used for sending data to a device via a TCP/IP Socket Connection.

SOCKET Map Configuration

config.xml

 <map id="map430" enabled="Y" description="GEN XML to SOCKET">
   <input id="in1" description="Read XML Document">
       <type>XML</type>
       <path>./interface/input/430 (GEN XML to SOCKET)</path>
       <mask/>
       <pollingInterval>1000</pollingInterval>
       <XSLT/>
   </input>
   <output id="out1" enabled="Y" description="Send to Host">
       <path>./interface/output/430 (GEN XML to SOCKET)</path>
       <type>SOCKET</type>
       <host>
          <ip>127.0.0.1</ip>
          <socket>8000</socket>
       </host>
       <copies>2</copies>
       <XSLT/>
   </output>
 </map>

Sample XML

Socket Data.xml

 <data>
    <line eol="cr">^XA</line>
    <line eol="cr">^FX Top section with company logo, name and address.</line>
    <line eol="cr">^CF0,60</line>
    <line eol="cr">^FO50,50^GB100,100,100^FS</line>
    <line eol="cr">^FO75,75^FR^GB100,100,100^FS</line>
    <line eol="cr">^FO88,88^GB50,50,50^FS</line>
    <line eol="cr">^FO220,50^FDInternational Shipping, Inc.^FS</line>
    <line eol="cr">^CF0,40</line>
    <line eol="cr">^FO220,100^FD1000 Shipping Lane^FS</line>
    <line eol="cr">^FO220,135^FDShelbyville TN 38102^FS</line>
    <line eol="cr">^FO220,170^FDUnited States (USA)^FS</line>
    <line eol="cr">^FO50,250^GB700,1,3^FS</line>
    <line eol="cr">^FX Second section with recipient address and permit information.</line>
    <line eol="cr">^CFA,30</line>
    <line eol="cr">^FO50,300^FDJohn Doe^FS</line>
    <line eol="cr">^FO50,340^FD100 Main Street^FS</line>
    <line eol="cr">^FO50,380^FDSpringfield TN 39021^FS</line>
    <line eol="cr">^FO50,420^FDUnited States (USA)^FS</line>
    <line eol="cr">^CFA,15</line>
    <line eol="cr">^FO600,300^GB150,150,3^FS</line>
    <line eol="cr">^FO638,340^FDPermit^FS</line>
    <line eol="cr">^FO638,390^FD123456^FS</line>
    <line eol="cr">^FO50,500^GB700,1,3^FS</line>
    <line eol="cr">^FX Third section with barcode.</line>
    <line eol="cr">^BY5,2,270</line>
    <line eol="cr">^FO100,550^BC^FD12345678^FS</line>
    <line eol="cr">^FX Fourth section (the two boxes on the bottom).</line>
    <line eol="cr">^FO50,900^GB700,250,3^FS</line>
    <line eol="cr">^FO400,900^GB1,250,3^FS</line>
    <line eol="cr">^CF0,40</line>
    <line eol="cr">^FO100,960^FDShipping Ctr. X34B-1^FS</line>
    <line eol="cr">^FO100,1010^FDREF1 F00B47^FS</line>
    <line eol="cr">^FO100,1060^FDREF2 BL4H8^FS</line>
    <line eol="cr">^CF0,190</line>
    <line eol="cr">^FO485,965^FDCA^FS</line>
    <line eol="cr">^XZ</line>
    <line>*EOF*</line>
 </data>

In this example the map assumes that the input document is in the correct format to be used by the connector. However you can read the data from a plain ASCII file or CSV and then apply a XSLT transformation to format the data into the format shown above.

The actual commands being transmitted here are ZPL (Zebra Printer Language) used to print a barcode label.

Such an example would look something like this.

CSV to SOCKET Map Configuration

config.xml

 <map id="map430" enabled="Y" description="GEN XML to SOCKET">
   <input id="in1" description="Read XML Document">
       <type>XML</type>
       <path>./interface/input/430 (GEN XML to SOCKET)</path>
       <mask/>
       <pollingInterval>1000</pollingInterval>
       <XSLT>CSV_to_SOCKET.xsl</XSLT>
   </input>
   <output id="out1" enabled="Y" description="Send to Host">
       <path>./interface/output/430 (GEN XML to SOCKET)</path>
       <type>SOCKET</type>
       <host>
          <ip>127.0.0.1</ip>
          <socket>8000</socket>
       </host>
       <copies>2</copies>
       <XSLT/>
   </output>
 </map>

The above illustration adds the following element `<XSLT>CSV_to_SOCKET.xsl</XSLT>` and it would need to transform the XML internal representation of the CSV data into the SOCKET message format.

For an exmaple of how CSV data is loaded into an intermediate XML document refer to the CSV Connector documentation