Hitachi EtherNetIP Developer Guide
Hitachi EtherNetIP Developer Guide
EtherNet/IP
Library and Browser
1
Contents
1. Hitachi EtherNet/IP Library ..................................................................................................................................................... 4
2. Testing ..................................................................................................................................................................................... 5
2.1. The Program .................................................................................................................................................................... 5
2.2. The Results ...................................................................................................................................................................... 6
3. Passing Data ............................................................................................................................................................................ 9
3.1. Connection to the device ................................................................................................................................................ 9
3.2. Path to the data on the printer ....................................................................................................................................... 9
3.3. EtherNet/IP Traffic to the printer ................................................................................................................................. 10
4. Using Human Readable Parameters ..................................................................................................................................... 11
5. Hitachi Data Layout ............................................................................................................................................................... 13
5.1. Types of Data ................................................................................................................................................................ 13
5.2. Accessing EtherNet/IP Data Descriptors ....................................................................................................................... 14
6. One level deeper ................................................................................................................................................................... 14
7. The Browser .......................................................................................................................................................................... 15
8. XML (A work in progress) ...................................................................................................................................................... 16
8.1. Printer Section............................................................................................................................................................... 16
8.2. Message Section ........................................................................................................................................................... 16
8.3. Item Section .................................................................................................................................................................. 17
8.4. Date Sub-Section ........................................................................................................................................................... 17
8.5. Counter Sub-Section ..................................................................................................................................................... 17
8.6. XML Example ................................................................................................................................................................. 18
9. XML Browsing........................................................................................................................................................................ 19
10. XML Processing ................................................................................................................................................................. 20
10.1. To Printer .................................................................................................................................................................. 20
10.2. From Printer .............................................................................................................................................................. 20
10.3. Verify Contents ......................................................................................................................................................... 20
11. Serialization Processing..................................................................................................................................................... 20
11.1. To Printer .................................................................................................................................................................. 20
11.2. From Printer .............................................................................................................................................................. 20
12. Serialization (Full Definition) ............................................................................................................................................. 21
12.1. Root Class .................................................................................................................................................................. 21
12.2. Printer Class .............................................................................................................................................................. 21
12.3. Message Class ........................................................................................................................................................... 24
12.4. Counter Class ............................................................................................................................................................ 25
2
12.5. Date Class .................................................................................................................................................................. 26
13. Current Thoughts on Printer Composition........................................................................................................................ 28
13.1. Substitution Class ...................................................................................................................................................... 28
13.2. Logo Class .................................................................................................................................................................. 28
13.3. Printer Class .............................................................................................................................................................. 28
14. Current Thoughts on Message Composition .................................................................................................................... 28
14.1. Message Class ........................................................................................................................................................... 28
14.2. Column Class ............................................................................................................................................................. 28
14.3. Item Class. ................................................................................................................................................................. 29
14.4. Date Class .................................................................................................................................................................. 29
14.5. Shift Class .................................................................................................................................................................. 29
14.6. Counter Class ............................................................................................................................................................ 29
3
1. Hitachi EtherNet/IP Library
The interface to the Hitachi UX Model 161 printer is implemented using Microsoft Visual Studio 2017 and C# Version 7.3. The
forms are type Windows Application, the DLLs are type Class Library.
The source code, except for the “Test Drive” application, is not being released at this time.
1. EIP – A DLL that hides all the EtherNet/IP Protocol and the internal structure of the Hitachi UX Model 161 printer.
Since the I/O is Synchronous, it is useful for single printer applications.
2. Browser – A DLL that utilizes the EIP DLL to expose all the internal structure of the Hitachi UX Model 161 printer.
3. AsyncIO – A DLL that uses the EIP DLL to implement Concurrent Asynchronous I/O to one or more Hitachi printers.
4. Browser – The same functionality as item #2 but as a standalone application.
5. Test Drive – An application released in source form that will allow you to use the level 1, 2, and 3 DLLs above to build
and test your own application.
These services provide all the tools needed to take full advantage of the power of the Hitachi Printers. They go from Shrink
Wrapped to Custom Developed applications
4
2. Testing
So, how easy is it?
Once you have built your test application, you need to add a reference to the DLL and
some code for each of the buttons.
using System;
using System.Windows.Forms;
using EIP_Lib;
namespace H_EIP {
public partial class TestEIP : Form {
public TestEIP() {
InitializeComponent();
}
}
}
5
Here is an example of building a simple message. Just copy and paste it into
your sample application.
If you want to see what was required to accomplish the task, just click “View Traffic”. All traffic is saved in an Excel
Spreadsheet (You will need Microsoft Excel installed).
6
Access Class Attribute #In Data In Raw In #Out Data Out Raw Out
Get Print format Number Of Columns 1 5 05
Set Index Automatic reflection 1 1 01
Set Index Column 2 1 00 01
Service Print format Delete Column
Service Print format Delete Column
Service Print format Delete Column
Service Print format Delete Column
Set Index Item 2 1 00 01
Set Print format Line Count 1 1 01
Service Print format Add Column
Service Print format Add Column
Service Print format Add Column
Service Print format Add Column
Set Index Item 2 2 00 02
Set Print format Line Count 1 2 02
Set Index Item 2 4 00 04
Set Print format Line Count 1 2 02
Set Index Item 2 1 00 01
Set Print format Print Character String 2 "1" 31 00
Set Print format Dot Matrix 1 12x16 07
Set Index Item 2 2 00 02
Set Print format Print Character String 4 "2" 20 32 20 00
Set Print format Dot Matrix 1 5x8 03
Set Index Item 2 3 00 03
Set Print format Print Character String 4 "3" 20 33 20 00
Set Print format Dot Matrix 1 5x8 03
Set Index Item 2 4 00 04
Set Print format Print Character String 2 "4" 34 00
Set Print format Dot Matrix 1 12x16 07
Set Index Item 2 5 00 05
Set Print format Print Character String 4 "5" 20 35 20 00
Set Print format Dot Matrix 1 5x8 03
Set Index Item 2 6 00 06
Set Print format Print Character String 4 "6" 20 36 20 00
Set Print format Dot Matrix 1 5x8 03
Set Index Item 2 7 00 07
Set Print format Print Character String 2 "7" 37 00
Set Print format Dot Matrix 1 12x16 07
Set Index Automatic reflection 1 0 00
Set Index Start Stop Management Flag 1 2 02
Access, Class, and Attribute lets you know about the request. . “#Out”, “Data Out”, and “Raw Out” describe the data sent to
the printer. “#In”, “Data In”, and “Raw In” describe the response from the printer
There is actually much more information in the traffic spreadsheet. Here are the columns I deleted to make the previous
table appear on one page.
7
Date/Time Elapsed Count OK Data OK Status/Path
19/03/31 13:50:53.2478 1971.8931 N/A N/A Connection Open!
19/03/31 13:50:53.2487 1971.8941 N/A N/A Session Open!
19/03/31 13:50:53.2537 1971.8991 N/A N/A Forward Open!
19/03/31 13:50:53.2867 0.0330 True True 00 -- O.K. -- 33 67 01 66
19/03/31 13:50:53.3157 0.0290 True True 00 -- O.K. -- 32 7A 01 65
Deleted to save space
19/03/31 13:50:54.0243 0.0160 True True 00 -- O.K. -- 32 7A 01 65
19/03/31 13:50:54.0783 0.0540 True True 00 -- O.K. -- 32 7A 01 64
19/03/31 13:50:54.1083 0.8545 N/A N/A Forward Close!
19/03/31 13:50:54.1083 0.8595 N/A N/A Session Close!
19/03/31 13:50:54.1093 0.8615 N/A N/A Connection Close!
“Date/Time” reflect the time when the request was made. “Elapsed” is the time between I/O requests. “Count OK” and
“Data OK” indicates whether or not the request matched the EtherNet/IP specification for the printer. “Status/Path” shows
the command sent and the response from the printer. The “Elapsed” time for Forward/Session/Comnnection Close is the
time since the corresponding Open request.
• “using EIP_Lib;” After the DLLS have been added to the list of “References”, this allows references to the Class
Library without needing to specify the Class Library Name Space on each reference.
• “EIP = new EIP("192.168.0.1", 44818, @"C:\Temp\EIP");” Creates a new instance of the EtherNet/IP Class. The
three parameters are:
o IP Address – String for TCP/IPv4 address of the printer.
o IP Port – Int Port number.
o Traffic Folder – Folder to use for saving the traffic to and from the printer. The traffic is saved in a Microsoft
Excel Spreadsheet.
• “browser = new HitachiBrowser("192.168.0.1", 44818, @"C:\Temp\EIP")” Creates a new instance of the
Browser Class. The three parameters are the same as the EIP Class.
• “EIP.CloseExcelFile(true);” This call is used to manage access to the Excel Traffic file. The parameters are:
o true – Closes out the current traffic spreadsheet and opens it in Microsoft Excel. A new file will be opened
for any new traffic.
o false – Closes out the traffic Spreadsheet and throws it away. No new file is opened.
• “browser.ShowDialog()” Opens the Browser as a Windows Dialog Box.
The Browser and EIP can share the same traffic Excel Spreadsheet. Get the instance of EIP that the Browser generated.
// Comment out next line if browser not needed
browser = new Browser("192.168.0.1", 44818, @"C:\Temp\EIP");
if (browser == null) {
EIP = new EIP("192.168.0.1", 44818, @"C:\Temp\EIP");
} else {
EIP = browser.EIP;
}
You can add your own messages to the Excel Spreadsheet via:
EIP.FillInColData(“Your text”);
8
3. Passing Data
3.1. Connection to the device
EtherNet/IP Protocol defines two layers to control traffic to/from the device. They are the Session Layer and the Forward
Layer. Hitachi adds one more layer with Auto Reflection and Start Stop Management.
• Session Layer – Is the connection to the device. It can be kept open for long periods. EIP implements it as:
o StartSession() – Open a session and return the status.
o EndSession() – Close a session. If StartSession() is called, EndSession() is also required.
• Forward Layer -- Is the path to the data inside the device. It can be kept open for short bursts of traffic. EIP
implements it as:
o ForwardOpen() – Open a path to the data and return a status.
o ForwardClose() – Closes the path to the data. If ForwardOpen () is called, ForwardClose () is also
required.
• Auto-Reflection – With Auto-Reflection set to 0, Traffic to the printer is executed immediately. With Auto-
Reflection set to 1, the commands are “saved” and executed when Auto-Reflection is set to 0 and the Start Stop
Management flag is set to 2. Note: If a Get Request is issued when Auto-Reflection is set to 1, the Get is ignored.
There is no way for the EtherNet/IP Protocol to return the requested data later. Using Auto-Reflection to build a
message is 4-times faster than not using Auto-Reflection.
• If only one command will be issued, don’t bother with a Session of Forward. EIP will manage the Session/Forward for
you.
• If multiple commands are to be sent, open a Session and a Forward around the commands.
If Sessions and Forwards are “Stacked”. EIP manages the state of the layers. If a StartSession() call is made and a session is
already open, the open session is used. If an EndSession() call is made and the session was already open when the
corresponding StartSession() call was made, the Session is left open. The same applies to the Forward Layer.
private void cmdTest_Click(object sender, EventArgs e) {
if (EIP.StartSession()) { // Open a session
if (EIP.ForwardOpen()) { // open a data forwarding path
EIP.SetAttribute(ccIDX.Automatic_reflection, 0);
EIP.SetAttribute(ccIDX.Start_Stop_Management_Flag, 2);
}
EIP.ForwardClose(); // Must be outside the ForwardOpen if block
}
EIP.EndSession(); // Must be outside the StartSession if block
}
9
3.3. EtherNet/IP Traffic to the printer
The EtherNet/IP protocol defines four parameters for data passed through the Forward Layer. The Hitachi implementation of
EtherNet/IP is documented in” EtherNetIP_UsersManual_4th.pdf” available from your Hitachi Distributor.
• Service – For Hitachi EIP, these are Get, Set, and Service (Enum “AccessCode”)
• Class – For Hitachi, there are referred to as Class Codes (Enum “ClassCode”)
• Instance – For Hitachi EIP, this is always 1.
• Attribute – For Hitachi EIP, their Enum names are:
o ccPDM // 0x66 Print data management function
o ccPF // 0x67 Print format function
o ccPS // 0x68 Print specification function
o ccCal // 0x69 Calendar function
o ccUP // 0x6B User pattern function
o ccSR // 0x6C Substitution rules function
o ccES // 0x71 Environment setting function
o ccUI // 0x73 Unit Information function
o ccOM // 0x74 Operation management function
o ccIJP // 0x75 IJP operation function
o ccCount // 0x79 Count function
o ccIDX // 0x7A Index function
• Data – The data associated with a service request is in the form of a byte array and is defined in the Hitachi Protocol.
To shield the user from having to match the specification, the data format is all resolved by EIP. The user can build
the data stream if needed. Format routines are provided and will always match the level of the Hitachi EtherNet/IP
implementation.
EIP defines three methods to pass data to/from the Hitachi printer. It is up to the user to determine the best
Session/Forward layers controls:
Consider out test program. It has Get, Set, and Service requests:
• A Get -- “int cols = EIP.GetAttribute(ccPF.Number_Of_Columns);” – This simply returns the number of columns
by getting the data from the printer by specifying only the attribute “”. No need for the user to know what to send or
how to interpret the result.
• A Set – “EIP.SetAttribute(ccIDX.Automatic_reflection, 1);” – Again, sets the flag in the Index section of the
printer. Again, the data structure is hidden from the user.
• A Service – “EIP.ServiceAttribute(ccPF.Delete_Column);” – The whole point of this in the program is to repeat
the deleting of a certain column.
10
Further hiding of the data structure of the printer from the user. Consider something like setting the font. Depending on the
make and model of the printer, the index associated with the 5X8 font varies. The UX, UX TUPI and UX InterNet/IP all have
different mappings. EIP resolves that by allowing the following:
• EIP.SetAttribute(ccIDX.Item, i);
• EIP.SetAttribute(ccPF.Print_Character_String, $" {i} ");
• EIP.SetAttribute(ccPF.Dot_Matrix, "5x8");
11
The currently defined formats look like:
// Attribute DropDown conversion
static public string[][] DropDowns = new string[][] {
new string[] { }, // 0 - Just decimal values
new string[] { "Disable", "Enable" }, // 1 - Enable and disable
new string[] { "Disable", "Space Fill", "Character Fill" }, // 2 - Disable, space fill, character fill
new string[] { "TwentyFour Hour", "Twelve Hour" }, // 3 - 12 & 24 hour
new string[] { "Current Time", "Stop Clock" }, // 4 - Current time or stop clock
new string[] { "Off Line", "On Line" }, // 5 - Offline/Online
new string[] { "None", "Signal 1", "Signal 2" }, // 6 - None, Signal 1, Signal 2
new string[] { "Up", "Down" }, // 7 - Up/Down
new string[] { "None", "5X5", "5X7" }, // 8 - Readable Code 5X5 or 5X7
new string[] { "not used", "code 39", "ITF", "NW-7", "EAN-13", "DM8x32", "DM16x16", "DM16x36",
"DM16x48", "DM18x18", "DM20x20", "DM22x22", "DM24x24", "Code 128 (Code set B)",
"Code 128 (Code set C)", "UPC-A", "UPC-E", "EAN-8", "QR21x21", "QR25x25",
"QR29x29", "GS1 DataBar (Limited)", "GS1 DataBar (Omnidirectional)",
"GS1 DataBar (Stacked)", "DM14x14", },
// 9 - Barcode Types
new string[] { "Normal", "Reverse" }, // 10 - Normal/reverse
new string[] { "M 15%", "Q 25%" }, // 11 - M 15%, Q 25%
new string[] { "Edit Message", "Print Format" }, // 12 - Edit/Print
new string[] { "From Yesterday", "From Today" }, // 13 - From Yesterday/Today
new string[] { "4x5", "5x5", "5x8(5x7)", "9x8(9x7)", "7x10", "10x12", "12x16", "18x24", "24x32",
"11x11", "QR33", "30x40", "36x48", "5x3(Chimney)", "5x5(Chimney)", "7x5(Chimney)"},
// 14 - Font Types
new string[] { "Normal/Forward", "Normal/Reverse",
"Inverted/Forward", "Inverted/Reverse",}, // 15 - Orientation
new string[] { "None", "Encoder", "Auto" }, // 16 - Product speed matching
new string[] { "HM", "NM", "QM", "SM" }, // 17 - High Speed Print
new string[] { "Time Setup", "Until End of Print" }, // 18 - Target Sensor Filter
new string[] { "4x5", "5x5", "5x8(5x7)", "9x8(9x7)", "7x10", "10x12", "12x16", "18x24", "24x32",
"11x11", "5x3(Chimney)", "5x5(Chimney)", "7x5(Chimney)", "QR33", "30x40", "36x48" },
// 19 - User Pattern Font Types
new string[] { "Individual", "Overall", "Free Layout" }, // 20 - Message Layout
new string[] { "Standard", "Mixed", "Dot Mixed" }, // 21 - Charge Rule
new string[] { "5 Minutes", "6 Minutes", "10 Minutes", "15 Minutes", "20 Minutes", "30 Minutes" },
// 22 - Time Count renewal period
};
Should the Hitachi Mappings change, the table will also change. The symbolic references will remain correct.
Just add the Combo Box on your screen and add the following code to your application. To take
advantage of this table in your code, they can be referenced as follows:
cbFont.Items.AddRange(EIP.DropDowns[(int)fmtDD.FontType]);
The integer values returned by the printer are available in either the integer form or symbolic form.
But, be careful. If you use the integer value returned by the printer to reference something in one of
the lists, some entries are 0-origin index, others have 1-origin index. EIP can provide the origin value
(See the Min and Max attributes in the AttrData Class Described Later).
12
5. Hitachi Data Layout
5.1. Types of Data
There are 16 different known layouts of information sent to and from the printer. There are more just referred to a “Struct”
that I have not deciphered yet.
public enum DataFormats {
None = -1, // No formating
Decimal = 0, // Unsigned Decimal numbers up to 8 digits (Big Endian)
DecimalLE = 1, // Unsigned Decimal numbers up to 8 digits (Little Endian)
SDecimal = 2, // Signed Decimal numbers up to 8 digits (Big Endian)
SDecimalLE = 3, // Signed Decimal numbers up to 8 digits (Little Endian)
UTF8 = 4, // UTF8 characters followed by a Null character
UTF8N = 5, // UTF8 characters without the null character
Date = 6, // YYYY MM DD HH MM SS 6 2-byte values in Little Endian format
Bytes = 7, // Raw data in 2-digit hex notation
XY = 8, // x = 2 bytes, y = 1 byte
N2N2 = 9, // 2 2-byte numbers
N2Char = 10, // 2-byte number + UTF8 String + 0x00
ItemChar = 11, // 1-byte item number + UTF8 String + 0x00
Item = 12, // 1-byte item number
GroupChar = 13, // 1 byte group number + UTF8 String + 0x00
MsgChar = 14, // 2 byte message number + UTF8 String + 0x00
N1Char = 15, // 1-byte number + UTF8 String + 0x00
N1N1 = 16, // 2 1-byte numbers
}
The building of the byte arrays that are sent to/from the printer uses one of these formats specifications. The format might
vary for the Get and Set of an Attribute. However, this is all hidden from the user. For users that just must dig deeper, here
is how an Attribute is managed inside EIP.
Consider the Print Specification (Class Code 0x68) Attribute (Dot Matrix 0x74). Data within EIP is stored as:
new AttrData((byte)ccPF.Dot_Matrix, GSS.GetSet, false, 11, // Dot Matrix 0x74
new Prop(1, DataFormats.Decimal, 1, 16, fmtDD.FontType), // Data
new Prop(0, DataFormats.Decimal, 0, 0, fmtDD.None), // Get
new Prop(1, DataFormats.Decimal, 1, 16, fmtDD.FontType)), // Set
13
The same applies for service only functions. Consider the Print_data_management (Class Code 0x66) Attribute (Select
Message 0x64).
new AttrData((byte)ccPDM.Select_Message, GSS.Service, false, 9, // Select Message 0x64
new Prop(0, DataFormats.Decimal, 0, 0, fmtDD.None), // Data
new Prop(2, DataFormats.Decimal, 1, 2000, fmtDD.None)), // Service
To get all the information you might need about Getting/Setting the dot matrix for an item, use the following.
AttrData attr = EIP.GetAttrData(ccPF.Dot_Matrix);
This is an example of getting strings from different places to send to the printer in a single request. If the null character was
at the end of data1, it would cause the printer to stop processing the message.
14
7. The Browser
Now that your test drive worked, it is time to take a serious look into the printer. Click the “Start Browser” button to look
inside the printer
The index function is set to “1” so the Print Format display represents what you sent to Item 1 in the printer. The entries in
Pink just say that what the printer returned did not match the EtherNet/IP Spec. Generally because they have no meaning.
For example, the Layout is Individual so the X/Y coordinates are not used.
Play with it. You cannot hurt anything. There are 13 screens of Get/Set/Service buttons for experimenting. Just click a
button and see how the printer changes.
15
8. XML (A work in progress)
Extensible Markup Language (XML) is a markup language that defines a set of rules for encoding documents in a format that
is both human-readable and machine-readable.
The intent here is to describe a message that can be used to save a message from the printer as well as reload it into the
printer. The goal is to be able to save a message in a format that is independent of printer model.
• Printer == Describes the settings in the printer needed to print the message
• Message == Describes the items in the printer
<Label Version="1">
<Printer Make="Hitachi" Model="UX-D161W">
<!--- Description of all printer wide parameters -->
</Printer>
<Message Layout="Individual">
<!--- Description of all Items within the message -->
</Message>
</Label>
The Substitution Sub-Section contains the portions of the Substitution Rule file that are used in the message. The Logos Sub-
Section describe the User Patterns used in the message.
<Item>
<Font IncreasedWidth="1" InterCharacterSpace="1" DotMatrix="5x8(5x7)" />
<BarCode />
<Date Block="1">
<! Description of all settings in a Calendar Block -->
</Date>
<Counter Block="1">
<! Description of all settings in a Counter Block -->
</Counter>
<Text>Shift {{E}}</Text>
</Item>
The Item Section always contains a Font and Text Sub-Section. An optional Date Sub-Section or a Counter Sub-Section can
also be provided if needed. However, Date and Counter Sub-Sections cannot appear in the same Item.
The Date Sub-Section has multiple parts. However, the printer limits which ones can be used together in a single item.
<Date Block="1" SubstitutionRule="1" RuleName="">
<Offset Year="0" Month="0" Day="0" Hour="0" Minute="0" />
<ZeroSuppress Year="Disable" Month="Disable" Day="Space Fill" />
<Substitute Month="Enable" />
<Shift ShiftNumber="1" StartHour="0" StartMinute="0" ShiftCode="D" />
<TimeCount Interval="30 Minutes" Start="A1" End="X2" ResetTime="6" ResetValue="A1" />
</Date>
17
8.6. XML Example
The example shown in Section 2 would have the following representation in XML.
<Label Version="Serialization-1">
<Printer Make="Hitachi" Model="UX-D161W">
<PrintHead Orientation="Normal/Forward" />
<ContinuousPrinting RepeatInterval="0" PrintsPerTrigger="0" />
<TargetSensor Filter="Time Setup" SetupValue="50" Timer="0" />
<CharacterSize Width="90" Height="2" />
<PrintStartDelay Forward="0" Reverse="0" />
<EncoderSettings HighSpeedPrinting="HM" Divisor="1" ExternalEncoder="None" />
<InkStream InkDropUse="3" ChargeRule="Standard" />
</Printer>
<Message Layout="Individual">
<Column InterLineSpacing="0">
<Item>
<Font InterCharacterSpace="1" IncreasedWidth="1" DotMatrix="12x16" />
<BarCode />
<Text>1</Text>
</Item>
</Column>
<Column InterLineSpacing="0">
<Item>
<Font InterCharacterSpace="1" IncreasedWidth="1" DotMatrix="5x8(5x7)" />
<BarCode />
<Text> 2 </Text>
</Item>
<Item>
<Font InterCharacterSpace="0" IncreasedWidth="1" DotMatrix="5x8(5x7)" />
<BarCode />
<Text> 3 </Text>
</Item>
</Column>
<Column InterLineSpacing="0">
<Item>
<Font InterCharacterSpace="1" IncreasedWidth="1" DotMatrix="12x16" />
<BarCode />
<Text>4</Text>
</Item>
</Column>
<Column InterLineSpacing="0">
<Item>
<Font InterCharacterSpace="1" IncreasedWidth="1" DotMatrix="5x8(5x7)" />
<BarCode />
<Text> 5 </Text>
</Item>
<Item>
<Font InterCharacterSpace="0" IncreasedWidth="1" DotMatrix="5x8(5x7)" />
<BarCode />
<Text> 6 </Text>
</Item>
</Column>
<Column InterLineSpacing="0">
<Item>
<Font InterCharacterSpace="1" IncreasedWidth="1" DotMatrix="12x16" />
<BarCode />
<Text>7</Text>
</Item>
</Column>
</Message>
</Label>
18
9. XML Browsing
This section of the Hitachi Browser exposes the automation of the XML processing.
Controls:
19
10. XML Processing
XML files can be sent to the printer, retrieved from the printer, or verified that the XML in the printer matched an XML file.
10.1. To Printer
The XML file can be passed to the printer in one of three ways: File Name, XML Text, of XML Document.
bool success = EIP.SendXmlToPrinter(XMLFileName);
bool success = EIP.SendXmlToPrinter(XMLText);
using System.Xml;
XmlDocument xmlDoc = new XmlDocument() { PreserveWhitespace = true };
xmlDoc.LoadXml(XMLText);
bool success = EIP.SendXmlToPrinter(XMLDoc);
The verification process writes the results into the Excel Traffic Spreadsheet.
11.1. To Printer
bool success = EIP.SendXMLAsSerialization(XMLFileName);
bool success = EIP.SendXMLAsSerialization(XMLText);
using System.Xml;
using System.Xml.Serialization;
XmlSerializer serializer = new XmlSerializer(typeof(Lab));
using (TextReader reader = new StringReader(XMLText)) {
Lab Lab = (Lab)serializer.Deserialize(reader);
EIP.SendXMLAsSerialization(Lab);
}
20
12. Serialization (Full Definition)
12.1. Root Class
The root would be a “Label”.
[XmlRoot("Label", IsNullable = false)]
public class Lab {
[XmlAttribute]
public string Version; // Keep track of version to allow for changes
public Printer Printer; // Information that pertains to the printer
public Msg Message; // Information that pertains to the message
}
12.2. Printer Class
The printer section covers the printer setup for printing a message. It is broken into subsections (just because I did it that
way for cijConnect). They may need to be collapsed into the Printer Class.
public class Printer {
[XmlAttribute]
public string Make;
[XmlAttribute]
public string Model;
public PrintHead PrintHead;
public ContinuousPrinting ContinuousPrinting;
public TargetSensor TargetSensor;
public CharacterSize CharacterSize;
public PrintStartDelay PrintStartDelay;
public EncoderSettings EncoderSettings;
public InkStream InkStream;
public Substitution Substitution;
public Logos Logos;
}
When moving from printer to printer, the print head orientation may change.
public class PrintHead {
[XmlAttribute]
public string Orientation;
}
Divisor is only used for encoder based printing. Maybe width should be here
public class EncoderSettings {
[XmlAttribute]
public string HighSpeedPrinting;
[XmlAttribute]
public string Divisor;
[XmlAttribute]
public string ExternalEncoder;
}
I think there are more settings like Interlaced and Single Scan.
public class InkStream {
[XmlAttribute]
public string InkDropUse;
[XmlAttribute]
public string ChargeRule;
}
The intent here is to be aple to carry along all logos that are used by the message. Specifying the folder would allow the
handled to get a fresh copy of the logo. There is nowhere in the printer to store the folder name.
public class Logos {
[XmlAttribute]
public string Folder;
[XmlElement("Logo")]
public Logo[] Logo;
}
22
Substitution and Substitution Rule are a work-in-progress
[XmlElement("Rule")]
public SubstitutionRule[] SubRule;
The layout and location allow messages to be sent to the printer. If a messahe is retriened from the printer, the bitmaps
would be stored here.
public class Logo {
[XmlAttribute]
public string Layout;
[XmlAttribute]
public string Location;
[XmlAttribute]
public string RawData;
[XmlAttribute]
public string FileName;
}
23
12.3. Message Class
The message class describes the message. This layout only describes the “Individual” lauout. It may have to be expanded for
“Overall” layout. It definitely will need to be expanded for “Free” Layout.
The current implementation uses the “Add Column” to allocate a column and “Line Count” to set the number of items in the
column. The Column Number and Item Number is assigned by the printer so it is not included in the specification of a column
or item. There can be multiple columns in a message.
public class Msg {
[XmlAttribute]
public string Layout;
[XmlElement("Column")]
public Column[] Column;
}
A item contains all the information stored in the printer to descibe one item. Date and Counter Classes are Arrays to handle
the case where multiple calendar and count are included in a single text string. It might be a good idea to allow multiple Text
Classes to handle very long strings. .The Location objects is used for internal processing but is not included in the XML since
all the values are assigned by the printer and not by the use. The data and counter cannot appear in the same item.
public class Item {
[XmlAttribute]
public string Type;
public FontDef Font;
public BarCode BarCode;
[XmlElement("Date")]
public Date[] Date;
[XmlElement("Counter")]
public Counter[] Counter;
public string Text;
[XmlIgnore]
public Location Location;
}
The Location objects is used for internal processing but is not included in the XML since all the values are assigned by the
printer and not by the user.
24
The Font class describes the unique characteristics of the font.
public class FontDef {
[XmlAttribute]
public string IncreasedWidth;
[XmlAttribute]
public string InterCharacterSpace;
[XmlAttribute]
public string DotMatrix;
}
The Barcode Class is a work in progress. Maybe include it with Font Class?
public class BarCode {
[XmlAttribute]
public string HumanReadableFont;
[XmlAttribute]
public string EANPrefix;
[XmlAttribute]
public string DotMatrix;
}
12.4. Counter Class
The counter class is an object within an item. It was arbitrarily broken into sub-classes. All open for discussion.
public class Counter {
[XmlAttribute]
public int Block;
25
public class Reset {
[XmlAttribute]
public string Type;
[XmlAttribute]
public string Value;
}
26
public class ZeroSuppress {
[XmlAttribute]
public string Year;
[XmlAttribute]
public string Month;
[XmlAttribute]
public string Day;
[XmlAttribute]
public string Hour;
[XmlAttribute]
public string Minute;
[XmlAttribute]
public string Week;
[XmlAttribute]
public string DayOfWeek;
}
Shift was included as a sub-section of the Date Class since it results in a Calendat Object being generated..
public class Shift {
[XmlAttribute]
public int ShiftNumber;
[XmlAttribute]
public string StartHour;
[XmlAttribute]
public string StartMinute;
[XmlAttribute]
public string EndHour;
[XmlAttribute]
public string EndMinute;
[XmlAttribute]
public string ShiftCode;
}
27
Time Count was included as a sub-section of the Date Class since it results in a Calendar Object being generated..
public class TimeCount {
[XmlAttribute]
public string Interval;
[XmlAttribute]
public string Start;
[XmlAttribute]
public string End;
[XmlAttribute]
public string ResetTime;
[XmlAttribute]
public string ResetValue;
}
The Delimiter cannot be stored and retrieved from the printer so may need to be fixed.
The Start Year was placed as an attribute. Need a rational place to put it.
The Rule Class layout is just to allow the something like Month to be subdivided.
The Message Class only specifies Layout (Free, Overall, Individual). It contains the collection of Columns. If the Message
Class is included, there must be at least one column within the message. Within the printer, there is always at least one
Column and one Item.
28
Column Class only specifies Inter-line Spacing. You cannot specify a Column Number since the printer assigns column
numbers
The Item Class always contains a Font Class, A Barcode Class, and a Text Class. It might work to move the Font Information
into the Item Class as Attributes.
The Barcode Class could stay as it is or be moved into the Item Class as attributes.
The Text Class needs to be defined as a collection so very long text messages could be loaded. Care must be taken on
breaking the text into sections as that can cause messages text to be discarded in the printer.
The Block Number is a 1-origin index of the Calendar Blocks assigned to this Item Class. The Calendar Starting Block and the
number of blocks is assigned by the printer.
29