Sample Project Manual For Ethernet Communication TUP-I
Sample Project Manual For Ethernet Communication TUP-I
HITACHI Printer
1
Fourth Editon
Contents
Precautions ............................................................................................................................................... 3
1. Development environment ................................................................................................................. 4
2. Sample project execution and functions ............................................................................................. 5
2.1. Connect/disconnect IJP .............................................................................................................. 6
2.2. Get IJP status.............................................................................................................................. 6
2.3. Get print data .............................................................................................................................. 6
2.4. Set print data ............................................................................................................................... 7
3. Sample code description .................................................................................................................... 8
3.1. Creation of object ........................................................................................................................ 8
3.2. Connect IJP ................................................................................................................................ 9
3.3. Disconnect from IJP .................................................................................................................... 9
3.4. Get IJP status............................................................................................................................ 10
3.5. Get print data ............................................................................................................................. 11
3.6. Set print data ............................................................................................................................. 12
4. Appendix .......................................................................................................................................... 13
4.1. Add reference to HitachiIJP.tlb file when creating new project for Visual Basic 6.0................... 13
4.2. Add reference to HitachiIJP.dll file when creating new project for Visual C#. ............................ 16
4.3. Wrapper class generation when creating new project (MFC) by Visual C++. ........................... 18
2
Fourth Editon
Precautions
The sample project code does not involve processing of errors or exceptions required as an application,
because it focuses on ease of understanding.
Hitachi offers no guarantee whatsoever concerning this sample project, and shall bear no responsibility
whatsoever concerning results of having used this sample project.
3
Fourth Editon
1. Development environment
Visual Basic 6.0, Visual C# and Visual C++ sample projects are provided as samples for using
the IJP Library.
The sample project development environment and application execution environment are as follows.
4
Fourth Editon
5
Fourth Editon
6
Fourth Editon
Fig. 7: Example of results of print data re-acquired after string setting (Visual Basic 6.0)
7
Fourth Editon
CIJP* m_pIJP;
8
Fourth Editon
pIJP.IPAddress = address
pIJP.Timeout = 5000
pIJP.Retry = 5
Call pIJP.Connect
this.ijp.IPAddress = ipAddress;
this.ijp.Timeout = timeout;
this.ijp.Retry = retry;
this.ijp.Connect ();
m_pIJP->put_IPAddress ( lpcszIPAddress );
m_pIJP->put_Timeout ( nTimeout );
m_pIJP->put_Retry ( nRetry );
m_pIJP->Connect ();
Call pIJP.Disconnect
Fig. 14: Disconnection from IJP (Visual Basic 6.0: DisconnectIJP function)
this.ijp.Disconnect ();
m_pIJP->Disconnect ();
9
Fourth Editon
Fig. 17: Get IJP status (Visual Basic 6.0: ShowStatus function)
10
Fourth Editon
byCharH = message.CharacterHeight
byHispeed = message.HiSpeedPrint
Fig. 20: Get print data (Visual Basic 6.0: ShowCurrentMessage function)
11
Fourth Editon
msgItem.Text = strNewText
pIJP.SetMessage (message)
Fig. 23: Set print data (Visual Basic 6.0: SetNewText function)
this.ijp.SetMessage ( message );
ijpMsgItem.put_Text ( lpcszNewText );
m_pIJP->SetMessage ( lpdisMessage );
12
Fourth Editon
4. Appendix
4.1. Addition of reference to HitachiIJP.tlb file when creating a new project by Visual Basic 6.0
Use the following procedure to add a reference to the “HitachiIJP.tlb” file. If no references are added,
class or enumeration type cannot be used for Visual Basic IDE.
① After creating a new project, select [References...] from the [Project] menu of Visual Basic 6.0.
13
Fourth Editon
③ Select the “HitachiIJP.tlb” file in the install destination folder (default: C:¥Program
Files¥HITACHI-IES¥IJP) of the IJP Library on the Add References dialog screen and press the [Open]
button.
14
Fourth Editon
④ Make sure a check is placed in the “HitachiIJP” checkbox on the References screen and press the
[OK] button.
* When creating the next new project, “HitachiIJP” will already be registered on the References
screen. Steps (2) and (3) of the procedure are not required.
15
Fourth Editon
4.2. Addition of reference to HitachiIJP.dll file when creating a new project by Visual C#
Use the following procedure to add a reference to the “HitachiIJP.dll” file. If no references are added,
class or enumeration type cannot be used for the project.
① After creating a new project, select [Add Reference...] from the [Project] menu of Visual Studio 2005.
16
Fourth Editon
② Select the [Browse] tab, select the “HitachiIJP.dll” file in the install destination folder (default: C:
¥Program Files¥HITACHI-IES¥IJP) of the IJP Library on the Add Reference screen and press the
[OK] button.
③ Make sure “HitachiIJP” has been added to References displayed by Solution Explorer of Visual Studio
2005.
17
Fourth Editon
4.3. Wrapper class generation when creating a new project (MFC) by Visual C++
When creating a new project, use the following procedure to create a wrapper class from the
“HitachiIJP.tlb” file.
* Properties of classes given in Help and specifications are defined as 2 functions for setting and
acquiring in wrapper class.
Example)
Class (interface) IJPMessage Wrapper class CIJPMessage
Property: CharacterWidth Acquisition function: get_CharacterWidth
Setting function: put_CharacterWidth
① After creating a new project, select [Add Class...] from the [Project] menu of Visual Studio 2005.
18
Fourth Editon
② Select “MFC Class From TypeLib” on the Add Class screen and press the [Add] button.
③ Set “Add class from” to “File” on the Add Class From Typelib Wizard screen and press the [Location]
button.
19
Fourth Editon
④ Select the “HitachiIJP.tlb” file in the install destination folder (default: C: ¥Program
Files¥HITACHI-IES¥IJP) of the IJP Library on the VS Wizard Select File screen and press the [Open]
button.
⑤ On the Add Class From Typelib Wizard screen, select an interface starting with “IIJP” from Interfaces
and press the [>] (add) button to add the wrapper class to Generated classes, then press the [Finish]
button.
20
Fourth Editon
⑥ Make sure a wrapper class header file has been added to Header Files displayed in Solution Explorer
of Visual Studio 2005.
21