0% found this document useful (0 votes)
68 views

Sample Project Manual For Ethernet Communication TUP-I

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
68 views

Sample Project Manual For Ethernet Communication TUP-I

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

Fourth Editon

Instruction Manual for LAN Communication TUP-I

IJP Control Library Sample Project

HITACHI Printer

Thank you for purchasing Hitachi IJ Printer.


If the printer is improperly handled or maintained, it may not operate smoothly and may become
defective or cause an accident. It is therefore essential that you read this manual to gain a
complete understanding of the printer and use it correctly.
After thoroughly reading the manual, properly store it for future reference.
[Model RX/RX2/UX]

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.

Library specifications may be modified in the future.

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.

Table 1: Development environment (Visual Basic 6.0)


No. Item Description
1 Integrated development Microsoft Visual Basic 6.0 Service Pack 6
environment
2 Language Visual Basic 6.0
3 OS Windows XP Professional Service Pack3

Table 2: Development environment (Visual C#, Visual C++)


No. Item Description
1 Integrated development Microsoft Visual Studio 2005 Service Pack1
environment
2 Language Visual C#, Visual C++ (MFC)
3 OS Windows XP Professional Service Pack3

Table 3: Sample application execution environment


No. Item Description
1 OS Windows XP Professional Service Pack3
Windows 7 Professional Service Pack1
2 Framework .NET Framework 2.0
(Installed when setting up IJP Library)
3 Library IJP Library

"Ethernet" is a registered trademark of Xerox Corporation, USA.


"Windows", "Visual Studio", "Visual Basic", "Visual C#", "Visual C++", and ".NET Framework" are
registered trademarks of Microsoft Corporation, USA, in the USA and other countries.

4
Fourth Editon

2. Sample project execution and functions

Execute the sample project by the following procedure.


* The IJP Library must be installed in advance.

① Launch the sample project.


The sample project is stored in “HITACHI-IES¥IJP¥Sample Project in My Documents folder”.
② When “Build” is executed by the sample project, the following applications are launched.
The application implements the following functions.

Table 4: Function list


No. Function Overview
1 Connect/disconnect IJP Connects/disconnects IJP.
2 Get IJP status Acquires status from IJP.
3 Get print data Acquires print data from IJP.
4 Set print data Sets string of 2nd print item of print data for IJP.

Fig. 1: Application screen example (Visual Basic 6.0)

5
Fourth Editon

2.1. Connect/disconnect IJP


Input the IP address of the IJP and press the [Connect] button.

Fig. 2: Example of button to connect to IJP (Visual Basic 6.0)

When connected, the [Connect] button display changes to [Disconnect].


Pressing the [Disconnect] button disconnects the IJP.

Fig. 3: Example of button to disconnect IJP (Visual Basic 6.0)

2.2. Get IJP status


Pressing the [Get Status] button acquires status from the IJP.
The acquired status is also displayed on the screen.

Fig. 4: Example of screen to acquire status (Visual Basic 6.0)

2.3. Get print data


Pressing the [Get Message] button acquires print data from the IJP.
The acquired print data is also displayed on the screen.

Fig. 5: Example of screen to acquire print data (Visual Basic 6.0)

6
Fourth Editon

2.4. Set print data


Pressing the [Set Message] button acquires print data from the IJP and sets it for the IJP after the string
specified as the second print item is changed.
If there is no second print item, a print item is added.

Fig. 6: Example of specified print item string (Visual Basic 6.0)

Fig. 7: Example of results of print data re-acquired after string setting (Visual Basic 6.0)

7
Fourth Editon

3. Sample code description

The following is a description of the code used by the sample program.


Shows Visual Basic 6.0, Visual C#, Visual C++ code examples respectively.

3.1. Creation of object


IJP class objects that express the IJP are created by the following code.

Dim pIJP As IJP

Set pIJP = CreateObject("HIES.IJP.RX.IJP")

Fig. 8: Object creation (Visual Basic 6.0: ConnectIJP function)

private IJP ijp;

this.ijp = new IJP ();

Fig. 9: Object creation (Visual C#: ConnectIJP function)

CIJP* m_pIJP;

m_pIJP = new CIJP ();


m_pIJP->CreateDispatch ( "HIES.IJP.RX.IJP" )

Fig. 10: Object creation (Visual C++: ConnectIJP function)

8
Fourth Editon

3.2. Connect IJP


To connect to the IJP, create a connection parameter for IJP class object and execute the Connect
function.

pIJP.IPAddress = address
pIJP.Timeout = 5000
pIJP.Retry = 5
Call pIJP.Connect

Fig. 11: Connection to IJP (Visual Basic 6.0: ConnectIJP function)

this.ijp.IPAddress = ipAddress;
this.ijp.Timeout = timeout;
this.ijp.Retry = retry;
this.ijp.Connect ();

Fig. 12: Connection to IJP (Visual C#: ConnectIJP function)

m_pIJP->put_IPAddress ( lpcszIPAddress );
m_pIJP->put_Timeout ( nTimeout );
m_pIJP->put_Retry ( nRetry );
m_pIJP->Connect ();

Fig. 13: Connection to IJP (Visual C++: ConnectIJP function)

3.3. Disconnect from IJP


To disconnect from the IJP, execute the Disconnect function for IJP class object.

Call pIJP.Disconnect

Fig. 14: Disconnection from IJP (Visual Basic 6.0: DisconnectIJP function)

this.ijp.Disconnect ();

Fig. 15: Disconnection from IJP (Visual C#: DisconnectIJP function)

m_pIJP->Disconnect ();

Fig. 16: Disconnection from IJP (Visual C++: DisconnectIJP function)

9
Fourth Editon

3.4. Get IJP status


To acquire status from the IJP, execute the GetStatus function of the IJP class object.

Dim status As IJPStatus


Set status = pIJP.GetStatus

Dim byCommConn As Byte


byCommConn = status.CommunicationConnection

Fig. 17: Get IJP status (Visual Basic 6.0: ShowStatus function)

IJPStatus status = ( IJPStatus ) this.ijp.GetStatus ();

this.statusTextBox.Text = String.Format ( " Communication Connection 0x{0:X} ",


status.CommunicationConnection )

Fig. 18: Get IJP status (Visual C#: ShowStatus function)

LPDISPATCH lpDisp = m_pIJP->GetStatus ();


CIJPStatus ijpStatus ( lpDisp );

byte byCommConn = ijpStatus.get_CommunicationConnection ();

Fig. 19: Get IJP status (Visual C++: ShowStatus function)

10
Fourth Editon

3.5. Get print data


To acquire print data from the IJP, execute the GetMessage function of the IJP class object.

Dim message As IJPMessage


Set message = pIJP.GetMessage

Dim byCharH As Byte


Dim byHispeed As Byte

byCharH = message.CharacterHeight
byHispeed = message.HiSpeedPrint

Fig. 20: Get print data (Visual Basic 6.0: ShowCurrentMessage function)

IJPMessage message = ( IJPMessage ) this.ijp.GetMessage ();

msgBuilder.AppendFormat ( "Character Height : {0}",


message.CharacterHeight );

Fig. 21: Get print data (Visual C#: ShowCurrentMessage function)

LPDISPATCH lpdisMessage = m_pIJP->GetMessage ();


CIJPMessage ijpMsg ( lpdisMessage );

BYTE byCharH = ijpMsg.get_CharacterHeight ();

Fig. 22: Get print data (Visual C++: ShowCurrentMessage function)

11
Fourth Editon

3.6. Set print data


To set print data to the IJP, execute the SetMessage function of the IJP class object.

Set msgItem = itemCol(1)

msgItem.Text = strNewText

pIJP.SetMessage (message)

Fig. 23: Set print data (Visual Basic 6.0: SetNewText function)

message.Items[ 1 ].Text = newText;

this.ijp.SetMessage ( message );

Fig. 24: Set print data (Visual C#: SetNewText function)

LPDISPATCH lpdisItem = ijpItemCol.get_Item ( 1 );


CIJPMessageItem ijpMsgItem ( lpdisItem );

ijpMsgItem.put_Text ( lpcszNewText );

m_pIJP->SetMessage ( lpdisMessage );

Fig. 25: Set print data (Visual C++: SetNewText function)

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.

Fig. 26: Adding a reference

13
Fourth Editon

② Press the [Browse] button on the References screen.

Fig. 27: Library reference

③ 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.

Fig. 28: tlb file selection

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.

Fig. 29: Adding HitachiIJP reference

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.

Fig. 30: Adding a reference

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.

Fig. 31: Library reference

③ Make sure “HitachiIJP” has been added to References displayed by Solution Explorer of Visual Studio
2005.

Fig. 32: Adding HitachiIJP reference

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.

Fig. 33: Adding a class

18
Fourth Editon

② Select “MFC Class From TypeLib” on the Add Class screen and press the [Add] button.

Fig. 34: Adding a class

③ Set “Add class from” to “File” on the Add Class From Typelib Wizard screen and press the [Location]
button.

Fig. 35: Add class from Typelib Wizard

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.

Fig. 36: tlb file selection

⑤ 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.

Fig. 37: Selecting an interface

20
Fourth Editon

⑥ Make sure a wrapper class header file has been added to Header Files displayed in Solution Explorer
of Visual Studio 2005.

Fig. 38: Adding header file of wrapper class

⑦ Add the following to the end of the “stdafx.h” file:

#import "System.Drawing.tlb" no_namespace

21

You might also like