You are on page 1of 14

LIBRARY Tfhkaif

INTEGRATION MANUAL

Version 1.1
Mayo de 2018
The Factory HKA, C.A.

INTEGRATION MANUAL - LIBRARY Tfhkaif

VERSION 1.1

The Factory HKA


Support and Integration Department
integration@thefactoryhka.com
Review History

Review Date Affected Pages Comment


1.1 03/05/2018 All Translation from the spanish version
Table of Contents
Review History ................................................................................................................................... 7
Introduction ....................................................................................................................................... 5
Hardware requirements ............................................................................................................................ 5
Software requirements ............................................................................................................................. 5
Import and Declarations ..................................................................................................................... 6
Tfhkaif library functions...................................................................................................................... 9
OpenFpctrl ................................................................................................................................................. 9
CloseFpctrl ................................................................................................................................................. 9
CheckFprinter ............................................................................................................................................ 9
ReadFpStatus........................................................................................................................................... 10
SendCmd ................................................................................................................................................. 10
SendFileCmd ............................................................................................................................................ 10
UploadReportCmd ................................................................................................................................... 10
UploadStatusCmd .................................................................................................................................... 11
UploadReportDin..................................................................................................................................... 11
UploadStatusDin...................................................................................................................................... 12
Annexes ........................................................................................................................................... 13
Annex 1: List of status codes ................................................................................................................... 13
Annex 2: List of error codes..................................................................................................................... 14
Introduction
The library "Tfhkaif.dll" allows the integration with administrative systems developed under the Win 32
technology; as they are Delphi, FoxPro, PowerBuilder and Visual Basic 6.

The following pages describe the details of the application interface "Tfhkaif.dll", from the hardware
requirements, the reference to the integration library, the additional components such as dynamic
libraries and finally the structure of the compiled Class that contains the functions to send commands
and interact with any of the printers distributed by The Factory HKA through an administrative system
developed under Win 32.

Hardware requirements

 1GHz Processor or higher


 At least 50MB RAM Memory
 50MB of free space in the Hard Drive
 Physical Serial Port or USB 2.0

Software requirements

 Windows Operative System.


 IDE to handle a development in Delphi, FoxPro, PowerBuilder and Visual Basic 6.

5
Import and Declarations
In the downloaded SDK, you will find the three basic tools to perform the integration of the
administrative system with our fiscal printer; the integration library "Tfhkaif.dll", the manual of this
library and a functional demo with open source where the use of the library is exemplified in a practical
way.

Before starting to use the library in development, the first thing to do is include and reference the library
in our project. This is achieved by following the steps below:

 Unzip the contents of the downloaded SDK.

 Access the previously unpacked SDK folder and copy the "Tfhkaif.dll" library that is located
inside the Demo folder or in the Library folder.

6
 Paste the library in the Windows System32 folder and in the folder where it is located of the
project executable.

 Finally, create the control variables to work the library during the use of the entire
development and declare the different functions that make up the library.

 In Visual Basic 6:

7
 In Visual FoxPro:

 In Delphi:

8
 In Power Builder:

Then, we are ready to start using the functions contained in the library and send commands to the fiscal
printer through the API.

Tfhkaif library functions


OpenFpctrl

Allows opening the port for communicating with the printer. This method runs in the unique constructor
of the class, but can be ran again if required.

BOOLEAN OpenFpctrl(String lpPortName)

 Parameters:

String IpPortName: Name of the COM port to be opened.

 Return:

True: Port opened successfully.


False: Failure in opening the COM port.

CloseFpctrl

Allows to close the COM port that was previously opened:

VOID CloseFpctrl()

CheckFprinter

Allows to verify if the printer is connected.

BOOLEAN CheckFprinter()

9
 Return:

True: Printer connected.


False: Printer not connected.

ReadFpStatus

Allows to read the variables of status and error of the printer. When this method is ran, a value for the
string variable Estado is set. (See annex 1 and 2)

BOOLEAN ReadFpStatus()

 Return:

True: Method ran successfully.


False: Error in method execution

SendCmd

Allows to send commands to the printer, in ASCII characters format, just as described in the integration
manuals of each printers and in the TFHKA general protocol and commands manual.

BOOLEAN SendCmd(Status Long, Error Long, String Cmd)

 Parameters:

String Cmd: ASCII commands that will be sent to the printer.

 Return:

True: Method ran successfully.


False: Error in method execution.

SendFileCmd

Allows sending a file containing commands in different lines to the printer.

INT SendFileCmd(Status Long, Error Long, String rutaFile)

 Parameters:

String rutaFile: Path where is the file to be sent to the printer.

 Return:

INT, Number of lines in the file that were sent successfully.

UploadReportCmd

Allows to save a printer report in a text file.

10
BOOLEAN UploadReportCmd(Status Long, Error Long, String cmd, String file)

 Parameters:

String cmd: Type of report to request. The reports that can be requested are the following (see the
integration manual of the respective printer for more details):

 In Venezuela the commands for reports are: U0X, U0Z, U1Z, U1X.
 In Panamá the commands for reports are: U0X, U0Z, U1Z, U1X.
 In Dominican Republic the commands for reports are: U0Z01, U0Z02, U0Z03, U0Z04, U0X01,
U0X02, U0X03, U0X04.
 In Curacao the commands for the reports are: U0Z01, U0Z02, U0Z03, U0Z04, UZ05, U0Z06
U0X01, U0X02, U0X03, U0X04, U0X05, U0X06

String file: Path of the file where the requested report will be saved.

 Return:

True: Method ran successfully.


False: Error in method execution.

UploadStatusCmd

This function allows a status of the printer to be stored in a simple text file.

BOOLEAN UploadStatusCmd(Status Long, Error Long, String cmd, String file)

 Parameters:

String cmd: Type of Status to request. The status that can be requested are the following (see Protocols
and Commands Manual):

 In Venezuela the commands for status are: S1, S2, S3, S4, S5, S8E, S8P.
 In Panamá the commands for reports are: S1, S2, S3, S4, S5, S8E, S8P.
 In Dominican Republic the commands for reports are: S1, S2, S3, S4, S5.
 In Curacao the commands for the reports are: S1, S2, S3, S4, S5

String file: File path where the requested Status will be stored.

 Return:

True: Method ran successfully.


False: Error in method execution.

UploadReportDin

This function allows you to store a printer report in a string.

BOOLEAN UploadReportDin(Status Long, Error Long, String cmd, String cadena)

11
 Parameters:

String cmd: type of report to request. The reports that may be requested are the following (see Manual
of Protocols and Commands):

 In Venezuela the commands for reports are: U0X, U0Z, U1Z, U1X.
 In Panamá the commands for reports are: U0X, U0Z, U1Z, U1X.
 In Dominican Republic the commands for reports are: U0Z01, U0Z02, U0Z03, U0Z04, U0X01,
U0X02, U0X03, U0X04.
 In Curacao the commands for the reports are: U0Z01, U0Z02, U0Z03, U0Z04, UZ05, U0Z06
U0X01, U0X02, U0X03, U0X04, U0X05, U0X06

String cadena: variable where the requested report will be stored.

 Return:

True: Method ran successfully.


False: Error in method execution.

UploadStatusDin

This function allows you to store a status of the printer in a string.

BOOLEAN UploadStatusDin(Status Long, Error Long, String cmd, String cadena)

Parameters: Type of Status to request. The status that can be requested are the following (see Protocols
and Commands Manual)

 In Venezuela the commands for status are: S1, S2, S3, S4, S5, S8E, S8P.
 In Panamá the commands for reports are: S1, S2, S3, S4, S5, S8E, S8P.
 In Dominican Republic the commands for reports are: S1, S2, S3, S4, S5.
 In Curacao the commands for the reports are: S1, S2, S3, S4, S5

String cadena: variable where the requested Status will be stored.

 Return:

True: Method ran successfully.


False: Error in method execution.

12
Annexes
Annex 1: List of status codes
STATUS
Return Return
Commentary
(Hex) (Decimal)
0 0 Unknow state.
1 1 In test and standby mode.
2 2 In test mode and issuance of tax documents.
3 3 In test mode and issuance of non-fiscal documents.
4 4 In fiscal mode and waiting.
5 5 In fiscal mode and issuance of tax documents.
6 6 In fiscal mode and issuance of non-fiscal documents.
7 7 In fiscal mode, close full charge of fiscal memory and
waiting.
8 8 In fiscal mode, close full charge of fiscal memory and
issuance of tax documents.
9 9 In fiscal mode, close full load of fiscal memory and issuance
of non-fiscal documents.
0A 10 In fiscal mode, full load of fiscal memory and waiting.
0B 11 In fiscal mode, full load of fiscal memory and issuance of
fiscal documents.
0C 12 In fiscal mode, full load of fiscal memory and issuance of
non-fiscal documents.

Note: The “TfhkaNet.dll” library returns this value in decimal.

13
Annex 2: List of error codes

ERROR
Return Return
Commentary
(Hex) (Decimal)
00 0 There is no error.
01 1 End in paper delivery.
02 2 Mechanical error in paper delivery.
03 3 End in paper delivery and mechanical error.
50 80 Invalid command or invalid value.
54 84 Invalid rate.
58 88 No directives assigned.
5C 92 Invalid command.
60 96 Fiscal Error.
64 100 Fiscal memory error.
6C 108 Fiscal memory full.
70 112 Full buffer (must send the reset command)
80 128 Communication error.
89 137 There is no answer.
90 144 LRC Error.
91 145 Internal error api.
99 153 Error opening the file.

14

You might also like