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

CAS Communication Library Eng 191017

The CAS Communication Library (CASPRTC V2.5.2) provides a structured framework for communication between retail scales and applications, consisting of a manager module, interpreter module, and communication module. It details the communication methods, procedures, and data structures necessary for effective data transfer, including various interfaces for sending and receiving specific data types like PLU, discounts, and nutritional information. Additionally, the document includes file structures, initialization procedures, and configuration options for optimizing communication with scales.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

CAS Communication Library Eng 191017

The CAS Communication Library (CASPRTC V2.5.2) provides a structured framework for communication between retail scales and applications, consisting of a manager module, interpreter module, and communication module. It details the communication methods, procedures, and data structures necessary for effective data transfer, including various interfaces for sending and receiving specific data types like PLU, discounts, and nutritional information. Additionally, the document includes file structures, initialization procedures, and configuration options for optimizing communication with scales.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 200

CAS Communication Library

CASPRTC V2.5.2

Copyright CAS
201710/17

1
INDEX
1. CAS CommLib........................................................................................................ 6
1.1 Concept....................................................................................................... 6
1.1.1 CommLib Structure..........................................................................6
1.1.2 CommLib communication method.................................................6
1.1.3 CommLib communication procedure............................................8
1.1.4 File structure....................................................................................9
1.1.5 CLInterpreter DATAOPTION.INI......................................................9
1.1.6 Define value....................................................................................12
1.1.7 int gRecvProc(TD_ST_TRANSDATA_V02 tdData)........................15
1.1.8 int gStateProc(TD_ST_TRANSDATA_V02 tdData).......................17
1.2 CASPRTC................................................................................................... 19
1.2.1 CASPRTC.DLL Diagram..................................................................19
1.2.2 Interface – CASPRTC......................................................................20
1.2.2.1 CASPRTC : SetRecvWindow()....................................................20
1.2.2.2 CASPRTC : SetCommLibrary()...................................................21
1.2.2.3 CASPRTC : AddInterpreter()......................................................22
1.2.2.4 CASPRTC : AddConnection().....................................................24
1.2.2.5 CASPRTC : AddConnectionEx().................................................26
1.2.2.6 CASPRTC : AddMsgConnection ().............................................28
1.2.2.7 CASPRTC : AddProcConnection()..............................................31
1.2.2.8 CASPRTC : AddProcConnectionEx()..........................................34
1.2.2.9 CASPRTC : DeleteConnection().................................................37
1.2.2.10 CASPRTC : Connect()................................................................38
1.2.2.11 CASPRTC : Disconnect()...........................................................39
1.2.2.12 CASPRTC : SendData().............................................................40
1.2.2.13 CASPRTC : SendDataEx().........................................................42
1.2.2.14 CASPRTC : IsConnect().............................................................45
1.2.3 Interface – Interpreter..................................................................46
1.2.3.1 Interpreter : Initialize()............................................................46
1.2.3.2 Interpreter : Interpret().............................................................47
1.2.3.2 Interpreter : Deinterpret()........................................................50
1.2.3.3 Interpreter : GetLibraryInfo()...................................................52
1.2.3.4 Interpreter : AddBuffer()...........................................................53
1.2.3.5 Interpreter : DeleteBuffer()......................................................55
1.2.4 Structure.........................................................................................57

2
1.2.4.1 _stTransData................................................................................57
1.2.4.2 _stTransDataV02.........................................................................61
1.2.4.3 _stSocketInfo...............................................................................66
1.2.4.4 _stSocketInfoV02........................................................................69
1.2.4.5 _stSerialInfo................................................................................73
1.2.4.6 _stDataPLUv06............................................................................76
1.2.4.7 _stDataDisc..................................................................................85
1.2.4.8 _stDataDept.................................................................................88
1.2.4.9 _stDataGroup..............................................................................89
1.2.4.10 _stDataTaxRate.........................................................................90
1.2.4.11 _stDataSaleMsg........................................................................91
1.2.4.12 _stDataOrigin............................................................................92
1.2.4.13 _stDataBarcode.........................................................................93
1.2.4.14 _stDataTare................................................................................94
1.2.4.15 _stPcsUnit..................................................................................95
1.2.4.16 _stDataIngredient.....................................................................96
1.2.4.17 _stDataNutrifact_V02...............................................................97
1.2.4.18 _stDataTrace..............................................................................99
1.2.4.19 _stDataCountry.......................................................................100
1.2.4.20 _stDataSlaught.......................................................................101
1.2.4.21 _stDataCut...............................................................................102
1.2.4.22 _stDataStore...........................................................................103
1.2.4.23 _stDataCustom........................................................................104
1.2.4.24 _stDataScrollMsg_v03............................................................105
1.2.4.25 _stDataSecurity......................................................................107
1.2.4.26 _stAck.......................................................................................108
1.2.4.27 _stDataState............................................................................109
1.2.3.28 _stScaleInfo.............................................................................110
1.2.4.29 _stScaleVersion.......................................................................112
2.FileTrans............................................................................................................... 114
2.1 Concept................................................................................................... 114
2.1.1 Structure.......................................................................................114
2.1.2 Interface........................................................................................114
2.1.3 Data structure..............................................................................115
2.1.3.1 PLU Data....................................................................................115
2.1.3.2 MESSAGE DATA..........................................................................117

3
2.1.3.3 ScaleInfo....................................................................................118
2.1.3.4 NUTRIFACT DATA.......................................................................118
2.1.3.5 VERSIONDATA...........................................................................118
2.1.3.6 DISCOUNT DATA.......................................................................118
2.2 Interface................................................................................................. 120
2.2.1 Interface – FileTrans....................................................................120
2.2.1.1 FileTrans : Connection()..........................................................120
2.2.1.2 FileTrans : ConnectionEx()......................................................121
2.2.1.3 FileTrans : AddPLU (PLUDATA)................................................122
2.2.1.4 FileTrans : AddMSG()...............................................................123
2.2.1.5 FileTrans : AddNutrifact()........................................................124
2.2.1.6 FileTrans : AddDiscount()........................................................126
2.2.1.7 FileTrans : SendPLU ()..............................................................127
2.2.1.8 FileTrans : SendMSG ()............................................................128
2.2.1.9 FileTrans : SendNutrifact ().....................................................129
2.2.1.10 FileTrans : SendDiscount ()...................................................130
2.2.1.11 FileTrans : RecvPLU ()............................................................131
2.2.1.12 FileTrans : RecvMSG ()...........................................................132
2.2.1.13 FileTrans : RecvNutrifact ()...................................................133
2.2.1.14 FileTrans : RecvDiscount ()...................................................134
2.2.1.15 FileTrans : RecvPLUData ()....................................................135
2.2.1.16 FileTrans : RecvMSGData ()..................................................136
2.2.1.17 FileTrans : RecvNutrifactData ()..........................................137
2.2.1.18 FileTrans : RecvDiscountData ()...........................................139
2.2.1.19 FileTrans : DeletePLU ().........................................................140
2.2.1.20 FileTrans : DeletePLUAll ()....................................................141
2.2.1.21 FileTrans : DeleteMSG ()........................................................142
2.2.1.22 FileTrans : DeleteNutrifact ()................................................143
2.2.1.23 FileTrans : DeleteDiscount ()................................................144
2.2.1.24 FileTrans : GetScaleInfo ()....................................................145
2.2.1.24 FileTrans : GetScaleInfoData ()............................................146
2.2.1.25 FileTrans : GetState ()...........................................................147
2.2.1.26 FileTrans : GetLibVersion ()..................................................148
2.2.1.27 FileTrans : DisconnectAll ()...................................................149
2.2.1.28 FileTrans : ReadPLU ()...........................................................150
2.2.1.29 FileTrans : ReadMSG ()..........................................................151

4
2.2.1.30 FileTrans : RecvVersion ().....................................................152
2.2.1.31 FileTrans : RecvVersionData ().............................................153
Appendix 1 – The available data by scale models..........................................................154
1. The available data by scale models......................................................154
2. The available PLU items by scale models............................................155
Appendix 2 -Tutorial.................................................................................................. 157
1. Start........................................................................................................... 157
2. Visual C++ Tutorial..................................................................................158
3. Delphi Tutorial..........................................................................................165

5
1. CAS CommLib
1.1 Concept
Module proceeding communication between scale and Application
Purpose of CommLib is that you can support any type of communication just when you know
interface provided by that.
1.1.1 CommLib Structure
CommLib Structure has 3 steps.
1st. Step – Manager module
2nd. Step – Interpreter module
3rd. Step – Communication module

Manager module provide the interface between Application and communication module and has
the function of controlling 2nd. and 3rd. functions.
Interpreter module interpret the data from application formatted data to scale formatted data or
otherwise.
Communication module transfer data from interpreter module to scale or otherwise.
Other modules than 1st. one are organized with more than one file. In the accordance of
communication type, you can add those files and develop.
Application (PC Application program)

1st. Step Manager module(CASPRTC.DLL)

Interface Manager
2nd. Step Interpreter module(CLInterpreter.DLL….)
Interpreter Manager
3 . Step
rd
Communication module (CASTCPIP.DLL, ….)
Socket…. Manager

Scale (All kinds of CAS retail scale)

1.1.2 CommLib communication method


You should use the provided structure when data communication between Application and
communication module. Data structure for data communication has two levels of the structure
between Modules and the data structure. Interpreter of CommLib proceeds data from module to
scale or otherwise.

6
(1) Data structure between Application and Module(TD_ST_TRANSDATA_V02)
Name Type and size(Byte) Description
shScaleID short int (2) Connection original number
lpIP LPSTR IP or identification code
btCommType BYTE(1) Communication type
(TCP/IP, ….)
btSendType BYTE(1) Communication method
(Broadcast, ….)
btDataType BYTE(1) Data type (PLU, ….)
wdScaleType WORD(2) Scale type (LP, ….)
wdScaleModel WORD(2) Model type (CL5000, ….)
wdAction WORD(2) Communication purpose
(Upload, ….)
wdDataSize WORD(2) Communication data size
*pData void Data structure pointer
dwScaleMainVersion DWORD Main Version of Scale
dwScaleSubVersion DWORD Sub Version of Scale
dwScaleCountry DWORD Country
dwScaleDataVersion DWORD Version of Data
dwReserveVersion DWORD Reserve
*pReserve void Reserve

(2) Data structure types


Name Model Description
LOWDATA ETC Send Raw data
PLU LP1v1.6,CL5000, Send PLU data
CL5000J,CL7200
DISCOUNT CL5000,CL7200 Send Sale information
DEPARTMENT CL5000,CL7200 Send Department
information
GROUP CL5000,CL7200 Send Group information
TAX RATE CL5000,CL7200 Send TAX rate
SALE MESSAGE LP1v1.6, Send Advertisement
CL5000,CL7200
ORIGIN CL5000, Send Origin

7
CL5000J,CL7200
BARCODE CL5000, Send Barcode
CL5000J,CL7200
TARE CL5000, Send Tare
CL5000J,CL7200
PCSUNIT CL5000,CL7200 Send PCS UNIT
INGREDIENT LP1v1.6,CL5000, Send Ingredient
CL5000J,CL7200
NUTRIFACT CL5000,CL7200 Send Nutrition Factor
TRACE CL5000,CL7200 Send Traceability
COUNTRY CL5000,CL7200 Send Country
SLAUGHT CL5000,CL7200 Send Slaughter house
CUT CL5000,CL7200 Send Cut in house
STORE LP1v1.6,CL5000, Send Store information
CL5000J,CL7200
CUSTOM CL5000,CL7200 Send User information
SCROLL MESSAGE CL5000,CL7200 Send Scroll Message
SECURITY CL5000,CL7200 Send Security information
PARAMETER CL5000J Send Scale Setting Info.

1.1.3 CommLib communication procedure


Check module initialization procedure before communication
1. Configure communication library(communication type)  2. Data interpreter configuration 
3. Add connection  4. Connect  5. Send/Recv  6. Disconnect  7. Delete Connection

1. Configuration of communication library is the confirmation of what type of


communication it communicates with. In this step, select TCP/IP or RS232C.
2. Configuration of data interpreter is the registration of the interpreters needed for
this communication.
You should register the interpreter fit to scale type. You can use more than one
interpreter.
3. Procedure for configuration of ‘Add connection’ line. That is the procedure of
confirmation how many scales communicate with.
4. Connection procedure
5. Transferring Data procedure

8
6. Release connection procedure
7. Deleting Connection procedure

1.1.4 File structure


1. CASPRTC.H
2. CASPRTC.LIB
3. CASPRTC.DLL
4. CASPRTC.PAS
5. CASTCPIP.DLL
6. CASSERIAL.DLL
7. CLInterpreter.DLL
8. CLJRInterpreter.DLL
9. LPInterpreter.DLL
10. LPRUSInterpreter.DLL

1.1.5 CLInterpreter DATAOPTION.INI


CLInterpreter changes data structure that the scale can interprete. In the communication with
the scale, you can use only the data that has been selected through the
DATAOPTION.INI file. The selected data communication is helpful for speed up.
If DATAOPTION.INI doesn’t exist in your library, you can transmit all data to scale at once.

(1) DATAOPTION.INI File structure

File scripture Description


[FILE_INFO]
File version. V1.0
FILE_VER = 1
File usage (1:Use, 0:Not use) Use
FILE_USE = 1
Target country(nation) United nation
COUNTRY_NAME = UN

Data numbers (1)


KEY_COUNT = 1
Data key (PLU_STRUCTURE)
KEY_LIST = PLU_STRUCTURE
Model numbers (1)
MODEL_COUNT = 1
Model (CL5000)
MODEL_LIST = 5000

Lower reference file information


[SUBSTRUCTURE_INFO]
Lower reference file Usage (1:Use, 0:Not use)

9
SUBSTRUCTURE_USE = 0 Lower reference file numbers (0)
SUBSTRUCTURE_COUNT = 0 Lower reference model
SUBSTRUCTURE_ITEM1_MODEL = Lower reference model file name
SUBSTRUCTURE_ITEM1_FILE =

[PLU_STRUCTURE_5000] PLU structure version


PLU_STRUCTURE_VER = 1 PLU structure usage (1:Use, 0:Not use)
PLU_STRUCTURE_USE = 1 Data code(1100:PLU)
PLU_STRUCTURE_CODE = 1100 Field numbers
PLU_STRUCTURE_ITEM_COUNT = 48
Field code
PLU_FIELD1_CODE = 1 Field code name
PLU_FIELD1_NAME = Department No Field memory size
PLU_FIELD1_SIZE = 2 Field length
PLU_FIELD1_LENG = 2 Field minimum value
PLU_FIELD1_MIN = 1 Field maximum value
PLU_FIELD1_MAX = 99 Float dot position
PLU_FIELD1_DEC = 0 User group level
PLU_FIELD1_LEVEL= 1 Default value
PLU_FIELD1_DEFAULT = 1 Base count information(2, 8, 10, 16)
PLU_FIELD1_DATATYPE = 10 Data class(1:char.,2:number,3:weight,4:price,
PLU_FIELD1_DATACLAS = 2 5:%,6:date,7:time)

…. * User group level


On downloading, fix the terms of the level of user.
PLU_FIELD48_CODE = 100 Through that level, it confirm if it use that in the
PLU_FIELD48_NAME = FixedWeight communication. That value should be lower than 255.
PLU_FIELD48_SIZE = 4 ex)
PLU_FIELD48_LENG = 5 0: Not use.
PLU_FIELD48_MIN = 0 1: Use the level of 1.
PLU_FIELD48_MAX = 99999 2: Use the level of 2 or all lower than 2.
PLU_FIELD48_DEC = 0 3: Use the level of 3 or all lower than 3.
PLU_FIELD48_LEVEL= 0 ….
PLU_FIELD48_DEFAULT = 0 255: Use the level of 255 or all lower than 255.
PLU_FIELD48_DATATYPE = 10

10
PLU_FIELD48_DATACLAS = 3

Reference :

DATAOPTION.INI file has two types. One for Russia and the other for United
nation.
DATAOPTION_RUS.INI is the Russian configuration file. If you want to use that file,
Delete that file and change name of DATAOPTION_RUS.INI to DATAOPTION.INI.
Communication module DLL should be located in the same path on your laptop
as the application program.
DATAOPTION.INI also should be located on that path.

11
1.1.6 Define value
Definition of Constants in DLL(Dynamic Linked Library)

Define Name Value Description


DF_SCALE_ETC 0 Communication type not related to scale
DF_SCALE_TYPE_LP 100 Communication type related to LP
DF_SCALE_TYPE_RW 200 Communication type related to RW
(Not used now)
DF_SCALE_TYPE_NT 300 Communication type related to NT
(Not used now)
DF_SCALE_TYPE_POS 400 Communication type related to POSCALE
(Not used now)
DF_SCALE_15 15 Communication type related to LP1-v15
DF_SCALE_16 16 Communication type related to LP1-v16
DF_SCALE_16RUS 161 Communication type related to LP1-v16Rus
DF_SCALE_17 17 Communication type related to LP1-v17
DF_SCALE_CL5000 5000 Communication type related to CL5000
DF_SCALE_CL5000JR 5010 Communication type related to CL5000J
DF_SCALE_CL5500 5500 Communication type related to CL5500
DF_SCALE_CL7200 7200 Communication type related to CL7200
DF_COMM_READ 10 Reading data procedure in communication
DF_COMM_WRITE 20 Writing data procedure in communication
DF_COMM_RECV 30 Receiving data procedure in communication
DF_COMM_ACK 40 Responding ACK procedure in communication
DF_DATA_LOWDATA 1 User defined data type for communication
DF_DATA_THIS 3 Module defined data type for communication
DF_DATA_STATE 4 State defined data type for communication
DF_DATA_TEST 5 Test defined data type for communication
DF_DATA_COMMAND 6 Command defined data type for communication
DF_STATE_CONNECT 1 Connection state for communication
DF_STATE_DISCONNECT 2 Disconnection state for communication
DF_STATE_CLOSE 3 Closure state for communication
DF_STATE_RECV 4 Data reception state for communication
DF_STATE_SEND 5 Data sending state for communication
DF_STATE_OUTOFBAND 6 Socket Out-of-band state
DF_STATE_RETRY 7 Retrying to send data state

12
DF_STATE_RETRYOVER 8 End state of retrying to send data
DF_COMMTYPE_ANY 0 Communication type for any
DF_COMMTYPE_TCPIP 1 TCP/IP communication type
DF_COMMTYPE_UDP 2 UDP communication type
DF_COMMTYPE_SERIAL 3 RS232 communication type
DF_SENDTYPE_NORMAL 1 Normal data sending state
DF_SENDTYPE_BROADCAST 2 Broadcasting(UDP) data state
DF_NOTIMEOUT 0 No timing out for communication
DF_RETRY_REPEAT 0 Retry to send data when it fails
DF_LOG_NO 0 Make no log file
DF_LOG_WRITE 1 Make/Write log file
DF_TRANSTYPE_PROC 0 Receiving data with call back type
DF_TRANSTYPE_MSG 1 Receiving data with Windows Message
DF_TRANSTYPE_INDV 8 Receiving data with individual process
DF_MODULE_TCPIP 1 TCP/IP communication module
DF_MODULE_SERIAL 2 RS232 serial module
DF_MODULE_PROTOCOL 3 Protocol module
DF_MODULE_SOCKET 4 (Combined) socket module
DF_MODULE_INTERPRETER 5 Interpretation module
DF_MODULE_USB 6 USB module
DF_CMDTYPE_COMM 1 Module command about communication
DF_CMDTYPE_LOCAL 2 Command for device management
DF_CMDTYPE_LIB 3 Command of communication module
DF_ACTION_NOTHING 0 No execution
DF_ACTION_GETINFO 1 Getting information
DF_ACTION_UPLOAD 2 Getting data from scale
DF_ACTION_DOWNLOAD 3 Sending data to scale
DF_ACTION_DELETE 4 Deleting data of scale
DF_ACTION_DELETEALL 5 Deleting all data of scale
DF_ACTION_READ 6 Reading data
DF_ACTION_WRITE 7 Writing data
DF_ACTION_INITSCALE 8 Initializing scale
DF_ACTION_RESET 9 Restarting scale
DF_ACTION_SET 10 Setting information of scale
DF_ACTION_NORMAL 11 Normal execution
DF_ACTION_SEND 12 Sending data

13
DF_INIT_SOCKET 1 Initializing communication socket
DF_INIT_SERIAL 2 Initializing serial port
DF_INIT_LIBCOMM 3 Initializing module
DF_INIT_INTERPRETER 4 Initializing sentence interpreter
DF_INIT_LIBPROTOCOL 5 Initializing protocol library
DF_INIT_ALL 6 Initializing all library
DF_SIZE_RECVBUFFER 8192+1 Receiving buffer size
DF_SIZE_IPBUFFER 25 IP address buffer size
DF_SIZE_LOGPATHBUFFER 512 Log file path buffer size
DF_NOTHING 0 Ready
DF_BEGIN 1 Start
DF_END 2 End
DF_NAME_LIBTCPIP - “CASTICIP.DLL”
DF_NAME_LIBSERIAL - “CASSERIAL.DLL”
DF_NAME_LIBUSB - “CASUSB.DLL”
DF_NAME_LIBPROTOCOL - “CASPRTC.DLL”
DF_DATA_PLU_V02 9 PLU data type for communication
DF_DATA_PLU_V06 98 PLU data type for communication
DF_DATA_DISC 11 Discount data type for communication
DF_DATA_DEPT 12 Department data type for communication
DF_DATA_GROUP 13 Group data type for communication
DF_DATA_TAXRATE 14 Tax rate data type for communication
DF_DATA_SALEMSG 15 Sale message data type for communication
DF_DATA_ORIGIN 16 Origin data type for communication
DF_DATA_BARCODE 17 Barcode type for communication
DF_DATA_TARE 18 Tare data type for communication
DF_DATA_PCSUNIT 19 PCS Unit type for communication
DF_DATA_INGREDIENT 20 Ingredient data type for communication
DF_DATA_NUTRIFACT_V03 197 Nutrition factor data type for communication
DF_DATA_TRACE 22 Traceability data type for communication
DF_DATA_COUNTRY 23 Country data type for communication
DF_DATA_SLAUGHT 24 Slaughter data type for communication
DF_DATA_CUT 25 Cutting hall data type for communication
DF_DATA_STORE 26 Store data type for communication
DF_DATA_CUSTOM 27 Custom data type for communication
DF_DATA_SCROLLMSG_V03 203 Scroll Message data type for communication

14
DF_DATA_SECURITY 29 Security data type for communication
DF_DATA_REPORT 30 Report data type for communication
DF_DATA_LABEL 31 Label data type for communication
DF_DATA_IMAGE 32 Image data type for communication
DF_DATA_KEY 33 Keypad data type for communication
DF_DATA_PLUINFO 34 PLU Information data type for communication
DF_DATA_SCALECMD 35 Scale command data type for communication
DF_DATA_PARAMETER 38 Scale Setting data type (CL5000J)
DF_DATA_SCALEINFO 40 Scale information type for communication
DF_DATA_VERSION_TYPE1 61 Scale Version data type (CL5000J)
DF_DATA_VERSION_TYPE2 62 Scale Version data type (CL5000)
DF_LABEL_BEGIN 1 Start label data communication
DF_LABEL_HEADER 2 Label header communication
DF_LABEL_DATA 3 Label data communication
DF_LABEL_END 4 End label data communication
DF_IMAGE_BEGIN 5 Start image data communication
DF_IMAGE_HEADER 6 Image header communication
DF_IMAGE_DATA 7 Image data communication
DF_IMAGE_END 8 End image data communication
FLASH_PLU_STATUS_SIZE 50 Size of reading PLU state (LP16)
FLASH_PLU_STATUS 544 Address of PLU state (LP16)
EEP_ALL_SIZE 3153 EEP_ROM total size (LP16)
MESSAGE_ADDRESS 12961 Ingredient starting address (LP16)

1.1.7 int gRecvProc(TD_ST_TRANSDATA_V02 tdData)

If you declared Call back function when data communication, you can get data from
scale. Prototype of Call back function is gRecvProc function.
You can get that data of scale from TD_ST_TRANSDATA_V02 structured data.
If that procedure succeeds, that function returns TRUE, else that returns FALSE.
You should declared that function as global function and pass the pointer of that
function to AddProcConnection function as the argument.

tdDAta
TD_ST_TRANSDATA_V02 structured data. Refer to Structure Interface explanation.
Reference

15
LP typed scale have the original ID and Name.
For example, chName1 is used as dwPLU of TD_ST_PLU_V02(PLU data structure),
chName is used as btNo of TD_ST_DEPT(Department data structure).
If you succeed uploading data from scale, dwPLU and btNo are the numbers of that data.
Else that numbers are 0 or 0xFFFF. 0xFFFF means ‘No data’. 0 means communication
error occurrence on uploading.
You can identify the errors, if you checked the chName or chName1.

Error message
[Data type] + [‘:’] + [‘E’] + [Error number]
Error number
E99 : Data end (No data after that)
E98 : No data that assigned to that original number.
E97 : Data communication error
E95 : Data don’t exist
E84 : Data reception error
E82 : Original number interval error
ex> LP16:E99
R21:E99

If you succeeded to download data to scale, it returns the original numbered dwPLU or
btNo as TRUE, and chName or chName1 has the resulted sentence.
Else, it returns FALSE, and chName or chName1 has the resulted sentence.

Resulted sentence
[Data type] + [‘:’] + [Result code]
ex> w30:00001
w20:00001
Error code is same as the uploading procedure.

If it gets no response after time out limitation it will send request again. So you should
consider data double reception trouble.

Example
int gProcRecv(TD_ST_TRANSDATA_V02 tdData)

16
char chBuffer[1024];

CString csRecv;

CString csMsg;

memset(chBuffer, 0x0, 1024);

if (tdData.wdAction == DF_ACTION_UPLOAD)

switch(tdData.btDataType)

case DF_DATA_LOWDATA:

csRecv.Format("%s", (LPSTR)tdData.pData);

break;

default:

switch (g_dlgMain->JProcWriteData(tdData.btDataType, tdData))

case 0: // Upload End E99, E98

g_dlgMain->JProcEndUpload();

break;

case 1: // Upload Continue

case 2:

g_dlgMain->JProcUpload(TRUE);

break;

break;

return TRUE;

1.1.8 int gStateProc(TD_ST_TRANSDATA_V02 tdData)

If you declared Call back function when data communication, you can get data from
scale. Prototype of Call back function is gStateProc function.
You can get that data of scale from TD_ST_TRANSDATA_V02 structured data.

17
If that procedure succeeds, that function returns TRUE, else that returns FALSE.
You should declared that function as global function and pass the pointer of that
function to AddProcConnection function as the argument.

tdDAta
Refer to Structure Interface explanation. Use pData in TD_ST_TRANSDATA_V02 as
TD_ST_STATE.
Reference
Example
int gProcState(TD_ST_TRANSDATA_V02 tdData)

TD_ST_STATE *tdState;

CString csMsg;

CString csRecv;

tdState = (TD_ST_STATE*)tdData.pData;

csRecv.Format("%s", tdState->lpDescription);

csMsg = "- [STATE] ";

csMsg += csRecv;

g_dlgMain->JProcAddState(csMsg);

return 0;

18
1.2 CASPRTC
1.2.1 CASPRTC.DLL Diagram
Application
Application Program Level

CASPRTC.DLL

Socket Info RECV StatusProc

ProtocolRecvProc
Information 1 SetIPList
Interpreter
Socket ID
Connect
SendToUpward
Socket IP
Disconnect

Socket Port
SetTimeOut
SEND
Recv Proc
MainRecvProc SetRetry

TimeOut Time Deinterpreter


SetCommType

Retry Time Send Bufer


Buffer 1

Information 2 Buffer 2



Buffer n
Information n

CASTCPIP.DLL/CASSERIAL.DLL
Module for data communication between application
and scale

19
1.2.2 Interface – CASPRTC

1.2.2.1 CASPRTC : SetRecvWindow()

Function for setting Window handle for receiving data from scale during data transaction
process. When it succeeds indicate “TRUE,” and indicate “FALSE” for failure.

DF_APIEXPORT int SetRecvWindow(HWND hWnd)

hWnd
Window handle device for receiving data as message.
Reference
DF_APIEXPORT

Example
HINSTANCE hDll = LoadLibrary(“CASPRTC.DLL”);

if (hDll)

TD_LIB_SETRECVWINDOW *pSetRecvWindow = GetProcAddress(hDll, “SetRecvWindow”);

if (pSetRecvWindow != NULL)

pSetRecvWindow(this->m_hWnd);

20
1.2.2.2 CASPRTC : SetCommLibrary()

During communication process with scale, function user can directly initialize module. However,
interface of communication module must be set correctly.
When it succeeds converse into “TRUE,” otherwise “FALSE”

DF_APIEXPORT int SetCommLibrary(int iModuleID, LPSTR lpModuleName)

iModuleID
Type of Data Module
Value Description
DF_MODULE_TCPIP Module for TCP/IP
DF_MODULE_SERIAL Module for Serial
DF_MODULE_PROTOCOL Module for Protocol
No use
DF_MODULE_SOCKET Module for Socket communication
No use
DF_MODULE_INTERPRETER Module for interpretation

Defined values are arranged in CASPRTC.H section

lpModuleName
Setting Module name (File name)
Reference
DF_APIEXPORT
Example
HINSTANCE hDll = LoadLibrary(“CASPRTC.DLL”);

if (hDll)

TD_LIB_SETCOMMLIBRARYA *pSetCommLibrary =

(TD_LIB_SETCOMMLIBRARYA *)GetProcAddress(hDll, “SetCommLibrary”);

if (pSetCommLibrary!= NULL)

pSetCommLibrary (DF_MODULE_TCPIP, “CASTCPIP.DLL”);

21
1.2.2.3 CASPRTC : AddInterpreter()

This device initializes data interpreting module for communication process between application
part and hardware part during communication process with Scale.
When it succeeds converse to “TRUE,” and otherwise converse to “FALSE.”

DF_APIEXPORT int AddInterpreter(WORD wdScaleType,


WORD wdScaleModel,
LPSTR lpLibName)

wdScaleType
Setting scale type

Value Description
DF_SCALE_TYPE_LP Label Printer type scale
DF_SCALE_TYPE_RW Road weighing truck scale
DF_SCALE_TYPE_NT Indicator type
DF_SCALE_TYPE_POS Poscale type scale
DF_SCALE_ETC Non-specified or custom-made type

The above information is arranged in CASPRTC.H

wdScaleModel
Setting Scale Model
Value Description
DF_SCALE_15 LP-1 V15 Model
DF_SCALE_16 LP-1 V16 Model
DF_SCALE_16RUS LP-1V16Rus Russian Model
DF_SCALE_17 LP-1 V17 Model
DF_SCALE_20 LP-2 Model
DF_SCALE_CL5000 CL5000 Model
DF_SCALE_CL5000JR CL5000J Model
DF_SCALE_CL5500 CL5500 Model
DF_SCALE_CL7200 CL7200 Model

22
DF_SCALE_ETC Non-specified or custom-made model

lpLibName
Interpreter file name
The above information is defined in CASPRTC.H

Reference
It is important to know the type and model of scale for communication.
Original data might be applied if interpreter is defined primarily.
User can use Scale Type or ScaleModel as DF_SCALE_ETC for the need of independent
function.
User disregards defining interpreter if there is no need of interpretation of
communication.

Example
HINSTANCE hDll = LoadLibrary(“CASPRTC.DLL”);

if (hDll)

TD_LIB_ADDINTERPRETERA *pAddInterpreter;

pAddInterpreter = GetProcAddress(hDll, “AddInterpreter”);

if (pAddInterpreter != NULL)

pAddInterpreter (DF_SCALE_TYPE_LP, DF_SCALE_CL5000, “CLinterpreter.Dll”);

23
1.2.2.4 CASPRTC : AddConnection()

This device is for adding a connection for connection process.


When it succeeds converse into “TRUE” and otherwise converse to “FALSE.”
(This function is not effectice on RS232. It will be done afterwards.)
It configures retrying time out limit and retrying number. This process waits the answer on
the rule of retrying.
If you don’t want to use retrying function, set retrying time out limit and number as ‘0’.

DF_APIEXPORT int AddConnection(TD_ST_CONNECTION tdConnection)

tdConnection
Data connection configuration
It includes every function of connection.
Please refer to TD_ST_CONNECTION, or _stSocketInfo

Reference
In the case of LP1v1.6, you should set time out period unlimited to avoid a retrying.
Data communication speed of LP1v1.6 is slow and the communication structure is not
able to adopt retrying. If you want to make retrying transmission on that, you should
make it yourself on your application.

DF_APIEXPORT
TD_ST_CONNECTION

Example
int g_RecvProc(TD_ST_TRANSDATA_V02 tdData)

return 0;

int g_StateProc(TD_ST_TRANSDATA_V02 tdData)

return 0;

24
HINSTANCE hDll = LoadLibrary(“CASPRTC.DLL”);

if (hDll)

char chIP[] = {“10.10.0.80”};

char chLogFile = {“Logfile.log”};

TD_ST_CONNECTION tdConnection;

TD_LIB_ADDCONNECTIONA *pAddConnection;

pAddConnection = (TD_LIB_ADDCONNECTIONA*)GetProcAddress(hDll, “AddConnection”);

tdConnection.btCommType = DF_COMMTYPE_TCPIP;

tdConnection.btTransType = DF_TRANSTYPE_PROC;

tdConnection.btDataType = DF_DATA_TEST;

tdConnection.btSocketType = SOCK_STREAM;

tdConnection.wdScaleType = DF_SCALE_ETC;

tdConnection.wdScaleModel = DF_SCALE_ETC;

tdConnection.lpIP = chIP;

tdConnection. btLogStatus = TRUE;

tdConnection.lpLogFileName = chLogFile;

tdConnection.wdPort = 2000;

tdConnection.wdTimeOut = 1000;

tdConnection.wdRetryCount = 3;

tdConnection.pRecv = g_RecvProc;

tdConnection.pState = g_StateProc;

if (pAddConnection != NULL)

pAddConnection(tdConnection);

25
1.2.2.5 CASPRTC : AddConnectionEx()

AddConnection() Scale version is added.

DF_APIEXPORT int AddConnectionEx(TD_ST_CONNECTION_V02 tdConnection)

tdConnection
Structure of data connection.
It contains all the characters on connection.
Please refer to the TD_ST_CONNECTION_V02, 또는 _stSocketInfoV02

Referenece
DF_APIEXPORT
TD_ST_CONNECTION_V02

EX)
// Receive call back function

int g_RecvProc(TD_ST_TRANSDATA_V02 tdData)

return 0;

// Receive call back fuction for state

int g_StateProc(TD_ST_TRANSDATA_V02 tdData)

return 0;

HINSTANCE hDll = LoadLibrary(“CASPRTC.DLL”);

// TCP/IP communication example

if (hDll)

26
char chIP[] = {“10.10.0.80”};

char chLogFile = {“Logfile.log”};

int iMainVersion = 134;

int iSubVersion = 4;

int iCountry=5 // 5:Russia

int iDataVerison=15;

TD_ST_CONNECTION_V02 tdConnection;

TD_LIB_ADDCONNECTIONA *pAddConnection;

pAddConnection = (TD_LIB_ADDCONNECTIONA*)GetProcAddress(hDll, “AddConnectionEx”);

tdConnection.btCommType = DF_COMMTYPE_TCPIP;

tdConnection.btTransType = DF_TRANSTYPE_PROC;

tdConnection.btDataType = DF_DATA_TEST;

tdConnection.btSocketType = SOCK_STREAM;

tdConnection.wdScaleType = DF_SCALE_ETC;

tdConnection.wdScaleModel = DF_SCALE_ETC;

tdConnection.lpIP = chIP;

tdConnection. btLogStatus = TRUE;

tdConnection.lpLogFileName = chLogFile;

tdConnection.wdPort = 2000;

tdConnection.wdTimeOut = 1000;

tdConnection.wdRetryCount = 3;

tdConnection.pRecv = g_RecvProc;

tdConnection.pState = g_StateProc;

tdConnection.dwScaleMainVersion=iMainVersion;

tdConnection.dwScaleSubVersion=iSubVersion;

tdConnection.dwScaleCountry=iCountry;

tdConnection.dwScaleDataVersion=iDataVersion;

tdConnection.dwReserveVersion=0;

tdConnection.pReserve=NULL;

if (pAddConnection != NULL)

pAddConnection(tdConnection);

27
// Serial communication example

if (hDll)

WORD wdRecvTime = 10;

char chIP[] = {“COM1”};

char chLogFile = {“Logfile.log”};

int iMainVersion = 134;

int iSubVersion = 4;

int iCountry=5 // 5:Russia

int iDataVerison=15;

TD_ST_CONNECTION_V02 tdConnection;

TD_LIB_ADDCONNECTIONA *pAddConnection;

pAddConnection = (TD_LIB_ADDCONNECTIONA*)GetProcAddress(hDll, “AddConnectionEx”);

tdConnection.btCommType = DF_COMMTYPE_SERIAL;

tdConnection.btTransType = DF_TRANSTYPE_PROC;

tdConnection.btDataType = DF_DATA_TEST;

tdConnection.btSocketType = DF_SERIAL_TYPE_57600;

tdConnection.wdScaleType = DF_SCALE_ETC;

tdConnection.wdScaleModel = DF_SCALE_ETC;

tdConnection.lpIP = chIP;

tdConnection. btLogStatus = TRUE;

tdConnection.lpLogFileName = chLogFile;

tdConnection.wdPort = wdRecvTime;

tdConnection.wdTimeOut = 1000;

tdConnection.wdRetryCount = 3;

tdConnection.pRecv = g_RecvProc;

tdConnection.pState = g_StateProc;

tdConnection.dwScaleMainVersion=iMainVersion;

tdConnection.dwScaleSubVersion=iSubVersion;

tdConnection.dwScaleCountry=iCountry;

tdConnection.dwScaleDataVersion=iDataVersion;

tdConnection.dwReserveVersion=0;

28
if (pAddConnection != NULL)

pAddConnection(tdConnection);

29
1.2.2.6 CASPRTC : AddMsgConnection ()

This device is for adding a connection for delivering data from data communication
For data transaction process, it can be received through designated window message. When it
succeeds converse into “TRUE” and otherwise converse to “FALSE.”
It configures retrying time out limit and retrying number. This process waits the answer on
the rule of retrying.
If you don’t want to use retrying function, set retrying time out limit and number as ‘0’.
DF_APIEXPORT int AddMsgConnection(BYTE btCommType,
LPSTR lpTarget,
WORD wdPort,
WORD wdScaleType,
WORD wdScaleModel,
WORD wdTimeout,
WORD wdRetryCount,
BYTE btDataType,
DWORD dwRecvMsg,
DWORD dwStateMsg )

btCommType
Setting connection type
Value Description
DF_COMMTYPE_TCPIP Setting socket for TCP/IP
DF_COMMTYPE_UDP Setting socket for UDP
DF_COMMTYPE_SERIAL Setting port for Serial connection

lpTarget
Targer Ethernet IP number or Serial port name configuration
wdPort
Port number
wdScaleType
Currently communicating scale type

30
Value Description
DF_SCALE_TYPE_LP Label printer scale
DF_SCALE_TYPE_RW Truck Scale
DF_SCALE_TYPE_NT Indicator
DF_SCALE_TYPE_POS Poscale
DF_SCALE_TYPE_ETC Other scales and connection
wdScaleModel
Indicate model name (Scale type)
Value Description
DF_SCALE_15 LP-15
DF_SCALE_16 LP-16
DF_SCALE_16RUS LP-16(Russia)
DF_SCALE_17 LP-17
DF_SCALE_20 LP-2
DF_SCALE_5000 CL5000
DF_SCALE_5000JR CL5000J
DF_SCALE_5500 CL5500
DF_SCALE_CL7200 CL7200
wdTimeout
Set an time out option
In the case of LP1v1.6, you should not use this(Set it over 900000)
wdRetryCount
Set a function for a number of retry
btDataType
Set type of data for transaction

Value Description
DF_DATA_LOWDATA Data with no need of interpreter
DF_DATA_STATE Data of connection status
DF_DATA_TEST Test data
dwRecvMsg
Window message number for receiving data

dwStateMsg
Window message number for the status of connection

31
Reference
In the case of LP1v1.6, you should set time out period unlimited to avoid a retrying.
Data communication speed of LP1v1.6 is slow and the communication structure is not
able to adopt retrying. If you want to make retrying transmission on that, you should
make it yourself on your application.

DF_APIEXPORT
TD_ST_TRANSDATA_V02

Example
#define WM_CASRECV WM_USER+10

#define WM_CASSTATE WM_USER+20

int OnBtnAddconnect()

HINSTANCE hDll = LoadLibrary(“CASPRTC.DLL”);

if (hDll)

TD_LIB_ADDMSGCONNECTIONA *pAddConnt;

pAddConnt = (TD_LIB_ADDMSGCONNECTIONA *)GetProcAddress(hDll,

“AddMsgConnection”);

if (pAddConnt != NULL)

iRtn = pAddMsgConnection(btCommType,

m_csIP.GetBuffer(m_csIP.GetLength()),

atoi(m_csPort),

DF_SCALE_ETC,

DF_SCALE_ETC,

atoi(m_csTimeout),

atoi(m_csRetry),

DF_DATA_TEST,

WM_CASRECV,

WM_CASSTATE);

32
}

33
1.2.2.7 CASPRTC : AddProcConnection()

This device is for initializing interpreter module for middle data configuration that facilitate scale
and application program for data transaction.
When it succeeds converse to “TRUE,” and otherwise converse to “FALSE.”

DF_APIEXPORT int AddProcConnection(BYTE btCommType,


LPSTR lpTarget,
WORD wdPort,
WORD wdScaleType,
WORD wdScaleModel,
WORD wdTimeout,
WORD wdRetryCount,
BYTE btDataType,
TD_PROC_RECV *pRecvProc,
TD_PROC_STATE *pStateProc )

btCommType
Setting connection type
Value Description
DF_COMMTYPE_TCPIP Setting socket for TCP/IP connection
DF_COMMTYPE_UDP Setting socket for UDP connection
DF_COMMTYPE_SERIAL Setting port for Serial connection
lpTarget
Target Ethernet IP number or Serial port name configuration
wdPort
Port number
wdScaleType
Currently communicating scale type
Value Description
DF_SCALE_TYPE_LP Label printer scale
DF_SCALE_TYPE_RW Truck scale
DF_SCALE_TYPE_NT Indicator
DF_SCALE_TYPE_POS Poscale
DF_SCALE_TYPE_ETC Other scales and connection

34
wdScaleModel
Indicate model name (Scale type)
Value Description
DF_SCALE_15 LP-15
DF_SCALE_16 LP-16
DF_SCALE_16RUS LP-16(Russia)
DF_SCALE_17 LP-17
DF_SCALE_20 LP-2
DF_SCALE_5000 CL5000
DF_SCALE_5000JR CL5000J
DF_SCALE_5500 CL5500
DF_SCALE_CL7200 CL7200
wdTimeout
Set an time out option
In the case of LP1v1.6, you should not use this(Set it over 900000)
wdRetryCount
Set a function for a number of retry
btDataType
Set type of data for transaction
Value Description
DF_DATA_LOWDATA Data without interpreter
DF_DATA_STATE Status data of connection
DF_DATA_TEST Test data
pRecvProc
Function pointer for receiving data
int TD_PROC_RECV (TD_ST_TRANSDATA_V02 tdTransData);
pStateProc
Function pointer for status data of connection
int TD_PROC_STATE (TD_ST_TRANSDATA_V02 tdTransData);

Reference
In the case of LP1v1.6, you should set time out period unlimited to avoid a retrying.
Data communication speed of LP1v1.6 is slow and the communication structure is not
able to adopt retrying. If you want to make retrying transmission on that, you should
make it yourself on your application.

35
DF_APIEXPORT
TD_ST_TRANSDATA_V02

Example
#define WM_CASRECV WM_USER+10

#define WM_CASSTATE WM_USER+20

int g_DataRecv(TD_ST_TRANSDATA_V02 tdTransData)

int iRtn = 0;

return iRtn;

int g_StateRecv(TD_ST_TRANSDATA_V02 tdTransData)

int iRtn = 0;

return iRtn;

int OnBtnAddconnect()

HINSTANCE hDll = LoadLibrary(“CASPRTC.DLL”);

if (hDll)

TD_LIB_ADDPROCCONNECTIONA * pAddProcConnection;

pAddProcConnection= (TD_LIB_ADDPROCCONNECTIONA *)GetProcAddress(hDll,

“AddProcConnection”);

if (pAddConnt != NULL)

iRtn = pAddProcConnection (btCommType,

m_csIP.GetBuffer(m_csIP.GetLength()),

atoi(m_csPort),

DF_SCALE_ETC,

DF_SCALE_ETC,

atoi(m_csTimeout),

atoi(m_csRetry),

36
DF_DATA_TEST,

g_DataRecv,

g_StateRecv);

37
1.2.2.8 CASPRTC : AddProcConnectionEx()

On data transmission between scale and application program, it initializes the interpreter
module that translates data structure for being understandable to both sides.
If succeeded, it returns TRUE, or it returns FALSE.
It configures retrying time out limit and retrying number. This process waits the answer on
the rule of retrying.
If you don’t want to use retrying function, set retrying time out limit and number as ‘0’.

DF_APIEXPORT int AddProcConnectionEx(BYTE btCommType,


LPSTR lpTarget,
WORD wdPort,
WORD wdScaleType,
WORD wdScaleModel,
WORD wdTimeout,
WORD wdRetryCount,
BYTE btDataType,
TD_PROC_RECV *pRecvProc,
TD_PROC_STATE *pStateProc,
short shID,
short shFlag )

btCommType
Configure connection type
Value Description
DF_COMMTYPE_TCPIP Configure socket for TCP/IP communicaiton
DF_COMMTYPE_UDP Configure socket for UDP communicaiton
DF_COMMTYPE_SERIAL Configure socket for Serial communicaiton
lpTarget
Connection target Ethernet IP number or Serial port name string
wdPort
Port number
wdScaleType
Currently communicated scale type
Value Description
DF_SCALE_TYPE_LP Label printer scale

38
DF_SCALE_TYPE_RW Truck scale
DF_SCALE_TYPE_NT Indicator
DF_SCALE_TYPE_POS Poscale
DF_SCALE_TYPE_ETC Other typed scale
wdScaleModel
Scale model name
Value Description
DF_SCALE_15 LP-15
DF_SCALE_16 LP-16
DF_SCALE_16RUS LP-16(Russia)
DF_SCALE_17 LP-17
DF_SCALE_20 LP-2
DF_SCALE_5000 CL5000
DF_SCALE_5000JR CL5000J
DF_SCALE_5500 CL5500
DF_SCALE_CL7200 CL7200
wdTimeout
Configure Retrying time out limit.
wdRetryCount
Configure Retrying number.
btDataType
Configure what data will be sent
Value Description
DF_DATA_LOWDATA Interpreter needless data
DF_DATA_STATE Connection state information data
DF_DATA_TEST Test data
pRecvProc
Pointer of function that receives data
int TD_PROC_RECV (TD_ST_TRANSDATA_V02 tdTransData);
pStateProc
Pointer of function that receives connection state information
int TD_PROC_STATE (TD_ST_TRANSDATA_V02 tdTransData);

shID
Configure scale ID.(Only for LP16RUS)
shFlag

39
Configuration option (Not confirmed)

Reference
If needed user can develop manually on the Application level.

DF_APIEXPORT
TD_ST_TRANSDATA_V02

Example
#define WM_CASRECV WM_USER+10

#define WM_CASSTATE WM_USER+20

int g_DataRecv(TD_ST_TRANSDATA_V02 tdTransData)

int iRtn = 0;

return iRtn;

int g_StateRecv(TD_ST_TRANSDATA_V02 tdTransData)

int iRtn = 0;

return iRtn;

int OnBtnAddconnect()

HINSTANCE hDll = LoadLibrary(“CASPRTC.DLL”);

if (hDll)

TD_LIB_ADDPROCCONNECTIONEXA *pAddProcConnt;

pAddProcConnt = (TD_LIB_ADDPROCCONNECTIONA *)GetProcAddress(hDll,

“AddProcConnectionEx”);

if (pAddConnt != NULL)

iRtn = pAddProcConnt (btCommType,

m_csIP.GetBuffer(m_csIP.GetLength()),

40
atoi(m_csPort),

DF_SCALE_ETC,

DF_SCALE_ETC,

atoi(m_csTimeout),

atoi(m_csRetry),

DF_DATA_TEST,

g_DataRecv,

g_StateRecv,

1, 0);

41
1.2.2.9 CASPRTC : DeleteConnection()

This device is for deleting connection for communication with scale. When it succeeds converse
to “TRUE,” and otherwise converse to “FALSE.”

DF_APIEXPORT int DeleteConnection(LPSTR lpTarget, short shID)

lpTarget
Target name for adding connection (ip, port name)
shID
Connection ID: set -1 if connection ID is not applied

Reference
Converse to “FALSE” when IpTarget and shID are both applied and are not matched.
DF_APIEXPORT

Example
int iRtn = 0;

TD_LIB_DELETECONNECTIONA *pDelete;

HINSTANCE hDll = LoadLibrary(“CASPRTC.DLL”);

if (hDll != NULL)

pDelete = (TD_LIB_DELETECONNECTIONA*) GetProcAddress(hDll, “DeleteConnection”);

if (pDelete != NULL)

iRtn = pDelete(csIP.GetBuffer(csIP.GetLength()), -1);

42
1.2.2.10 CASPRTC : Connect()

This device is for connecting an additive connection. When it succeeds converse to “TRUE,”
and otherwise converse to “FALSE.”

DF_APIEXPORT int Connect(LPSTR lpTarget, short shID)

lpTarget
Target name for adding connection (ip, port name)
shID
Connection ID: set -1 if connection ID is not applied

Reference
Converse to “FALSE” when IpTarget and shID are both applied and are not matched.
DF_APIEXPORT

Exmaple
int iRtn = 0;

CString csIP = “”;

TD_LIB_CONNECTA *pConnect;

HINSTANCE hDll = LoadLibrary(“CASPRTC.DLL”);

if (hDll != NULL)

GetDlgItemText(IDC_EDT_IP, csIP);

pConnect = (TD_LIB_CONNECTA*) GetProcAddress(hDll, “Connect”);

if (pConnect != NULL)

iRtn = pConnect(csIP.GetBuffer(csIP.GetLength()), -1);

43
1.2.2.11 CASPRTC : Disconnect()

This device is for initializing Interpreter module which converse data configuration into a
system for facilitating data transaction between scale and application program.
When it succeeds converse to “TRUE,” and otherwise converse to “FALSE.”

DF_APIEXPORT int Disconnect(LPSTR lpTarget, short shID)

lpTarget
Target name for adding connection (ip, port name)
shID
Connection ID: set -1 if connection ID is not applied

Reference
Converse to “FALSE” when IpTarget and shID are both applied and are not matched.
DF_APIEXPORT
TD_ST_TRANSDATA_V02

Example
int iRtn = 0;

CString csIP = “”;

TD_LIB_DISCONNECTA *pDisconnect;

HINSTANCE hDll = LoadLibrary(“CASPRTC.DLL”);

if (hDll != NULL)

GetDlgItemText(IDC_EDT_IP, csIP);

pDisonnect = (TD_LIB_DISCONNECTA*) GetProcAddress(hDll, “Disconnect”);

if (pDisconnect != NULL)

iRtn = pDisconnect(csIP.GetBuffer(csIP.GetLength()), -1);

44
1.2.2.12 CASPRTC : SendData()

In order to communicate with scale, it requires communication network for sending data. The
following series is mandatory option for sending data. When it succeeds converse to
“TRUE,” and otherwise converse to “FALSE.”

DF_APIEXPORT int SendData(TD_ST_TRANSDATA tdData)

tdData
Sending data structure
Configure data and partially give point to void *pData. After giving data size to
wdDataSize, complete configuration process and sending data.

Reference
Sending btDataType of tdData also influences receiving btDataType of tdData Sent
data type set as a receiving data type. It is important that btDataType becomes
standard for interpretation process during data transaction process.
While data communication are doing, communication module directly send data
when it calls SendData function and directly proceed received data when it calls
gRecvProc(). But you should consider the procedure reading data from scale and
writing data to scale are time consuming procedure.
In the case of LPv1.6, it already has the structure which internally proceed that thing. But
CL5000 maybe would have the duplication of data when it goes on high speed data
communication.
DF_APIEXPORT
TD_ST_TRANSDATA

Example
int iRtn = 0;

CString csIP = “”;

TD_ST_TRANSDATA tdData;

TD_LIB_SENDATAA *pSendData;

HINSTANCE hDll = LoadLibrary(“CASPRTC.DLL”);

if (hDll != NULL)

45
GetDlgItemText(IDC_EDT_IP, csIP);

pSendData = (TD_LIB_SENDDATAA*) GetProcAddress(hDll, “SendData”);

if (pSendData != NULL)

tdData.btCommType = DF_COMMTYPE_TCPIP;

tdData.btDataType = DF_DATA_TEST;

tdData.btSendType = DF_SENDTYPE_NORMAL;

tdData.wdScaleType = DF_SCALE_ETC;

tdData.wdScaleModel= DF_SCALE_ETC;

tdData.shScaleID = -1;

tdData.lpIP= csIP.GetBuffer(csIP.GetLength());

tdData.wdDataSize = csData.GetLength();

tdData.pData = csData.GetBuffer(csData.GetLength());

iRtn = pSendData(tdData);

46
1.2.2.13 CASPRTC : SendDataEx()

This function includes scale version other data than SendData() function has.

DF_APIEXPORT int SendDataEx(TD_ST_TRANSDATA_V02 tdData)

tdData
Transmitted data structure
Make the data and assign the pointer of that data to void *pData and input data size to
wdDataSize.
After all configuration, you can transmit that data to the scale.

typedef struct _stTransData {

short shScaleID; // Scale id

LPSTR lpIP; // Scale IP, Serial name

BYTE btCommType; // Communication type TCP/IP, SERIAL...

BYTE btSendType; // SendType NORMAL, BROADCAST

BYTE btDataType; // Data Type PLU, DEPT, COUNRTY...

WORD wdScaleType; // Scale Type LP, RW, NT...

WORD wdScaleModel; // Scale Model LP-15, LP-16...

WORD wdAction; // Command upload, download, delete, deleteall

WORD wdDataSize; // DataSize

void *pData; // Data

DWORD dwScaleMainVersion;

DWORD dwScaleSubVersion;

DWORD dwScaleCountry;

DWORD dwScaleDataVersion;

DWORD dwReserveVersion;

void *pReserve;

} TD_ST_TRANSDATA_V02;

void *pData is the pointer of real tansmitted data.

wdAction
DF_ACTION_NOTHING 0
DF_ACTION_GETINFO 1

47
DF_ACTION_UPLOAD 2
DF_ACTION_DOWNLOAD 3
DF_ACTION_DELETE 4
DF_ACTION_DELETEALL 5 Relating to only
CL5000
DF_ACTION_READ 6
DF_ACTION_WRITE 7
DF_ACTION_INITSCALE 8
DF_ACTION_RESET 9
DF_ACTION_SET 10
DF_ACTION_NORMAL 11
DF_ACTION_SEND 12
DF_ACTION_ADDCONNECTION 13
DF_ACTION_CONNECT 14
DF_ACTION_DISCONNECT 15
DF_ACTION_DELETECONNECTION 16
DF_ACTION_CONNECTALL 17
DF_ACTION_CONNECTONE 18
DF_ACTION_CANCEL 19
DF_ACTION_RESETCONNECTINFO 20

Reference
Sending btDataType of tdData also influences receiving btDataType of tdData Sent
data type set as a receiving data type. It is important that btDataType becomes
standard for interpretation process during data transaction process.
While data communication are doing, communication module directly send data
when it calls SendData function and directly proceed received data when it calls
gRecvProc(). But you should consider the procedure reading data from scale and
writing data to scale are time consuming procedure.
In the case of LPv1.6, it already has the structure which internally proceed that thing. But
CL5000 maybe would have the duplication of data when it goes on high speed data
communication.
DF_APIEXPORT
TD_ST_TRANSDATA_V02

DF_ACTION_DELETEALL

48
That is used for all PLU data.
Proceeded result data is received as written below.

If that operation was succeeded,


1. dwPLU is TRUE, and chName1 is <“C016:S”><Size [4,S,H]><0x0A[1,B,H]>.
It is successful reception message for PLU deletion.
2. dwPLU is TRUE, and chName1 is <“C016:N”><Size [4,S,H]><0x0A[1,B,H]>.
It is state information message while proceeding PLU deletion.
3. dwPLU is TRUE, and chName1 is <”W02:O001”>.
It is PLU deleting completion message.

Fail
1. <“W02:E”><Size [2,S,H]><0x0A[1,B,H]>

Example
int iRtn = 0;

CString csIP = “”;

TD_ST_TRANSDATA_V02 tdData;

TD_LIB_SENDATAA *pSendData;

HINSTANCE hDll = LoadLibrary(“CASPRTC.DLL”);

if (hDll != NULL)

GetDlgItemText(IDC_EDT_IP, csIP);

pSendData = (TD_LIB_SENDDATAA*) GetProcAddress(hDll, “SendDataEx”);

if (pSendData != NULL)

tdData.btCommType = DF_COMMTYPE_TCPIP;

tdData.btDataType = DF_DATA_TEST;

tdData.btSendType = DF_SENDTYPE_NORMAL;

tdData.wdScaleType = DF_SCALE_ETC;

tdData.wdScaleModel= DF_SCALE_ETC;

tdData.shScaleID = -1;

tdData.lpIP= csIP.GetBuffer(csIP.GetLength());

tdData.wdDataSize = csData.GetLength();

tdData.pData = csData.GetBuffer(csData.GetLength());

tdData.dwScaleMainVersion = dwScaleMainVersion;

49
tdData.dwScaleSubVersion = dwScaleSubVersion;

tdData.dwScaleCountry = dwScaleCountry;

iRtn = pSendData(tdData);

50
1.2.2.14 CASPRTC : IsConnect()

If you finished adding connection and tried to connect, you can send data to scale.
But maybe you get the time to check if the scale connect or not. At that time you can use
IsConnect function. If the scale connected, that returned TRUE. Else it returned FALSE.

DF_APIEXPORT int IsConnect(LPSTR lpTarget, short shID)

lpTarget
It configures the NULL sentence and the identification sentence of IP that you want to
check whether connects.

shID
It configure the original identification number that you want to check whether connects.
Set this value -1 for no use, or higher than -1 for use.

Reference
If you want to check connection state, you should finish to add connection with
AddConnection() function before.
If you inputted lpTarget and shID simultaneously, lpTarget is superior than shID.
If you can check just shID, when you set lpTarget, NULL.

Example
int iRtn = 0;

CString csIP = “”;

TD_LIB_ISCONNECTA *pIsConnect;

HINSTANCE hDll = LoadLibrary(“CASPRTC.DLL”);

if (hDll != NULL)

GetDlgItemText(IDC_EDT_IP, csIP);

pIsConnect = (TD_LIB_ISCONNECTA*) GetProcAddress(hDll, “IsConnect”);

if (pIsConnect != NULL)

iRtn = pIsConnect((LPSTR)csIP, -1);

51
1.2.3 Interface – Interpreter

1.2.3.1 Interpreter : Initialize()

This device is an Initializing interpreter module for data configuration facilitates data transaction
between scale and application program.

DF_APIEXPORT int Initialize(TD_PROC_RECV *pRecv)

pRecv
Data sending pointer after the completion of data transaction

Original Function form

int TD_PROC_RECV (TD_ST_TRANSDATA_V02 tdTransData);

Reference
DF_APIEXPORT
TD_ST_TRANSDATA_V02

Example
TD_PROC_RECV *pRecvProc;

int Initialize(TD_PROC_RECV *pRecv)

int iRtn = 0;

pRecvProc = pRecv;

if (pRecvProc == pRecv)

iRtn = TRUE;

return iRtn;

52
1.2.3.2 Interpreter : Interpret()

User Part
If data from an upper application program is successfully converted, return the
reconfigured data size when it fails, converse into 0. Data becomes a factor while
rearranging and analyzing pData, then transfer initialized data.

Module developer
As a part of interpreter module, it converts data configuration that facilitates
transfer data from scale. After receiving data, analyze it into factor of tdData->pData.
When all of data is received, reform into TD_ST_TRANSDATA_V02 as an initialized
function. DataType configuration must be double checked during data transaction. More
detailed information, please refer to TD_ST_TRANSDATA_V02.

DF_APIEXPORT int Interpret(TD_ST_TRANSDATA_V02 *tdData)

tdData
Configuration structure combining original data received from scale
TD_ST_TRANSDATA_V02 original configuration.
Original form
struct _stTransData {

short shScaleID;

LPSTR lpIP;

BYTE btCommType;

BYTE btSendType;

BYTE btDataType;

WORD wdScaleType;

WORD wdScaleModel;

WORD wdDataSize;

void *pData;

DWORD dwScaleMainVersion;

DWORD dwScaleSubVersion;

DWORD dwScaleCountry;

DWORD dwScaleDataVersion;

DWORD dwReserveVersion;

void *pReserve;

53
} TD_ST_TRANSDATA_V02;

Reference
Argument tdData has the function that transfer data and return the result of
transference.
Data recept from scale are returned with string pointer in tdData.pData.
Interpreter compromise this returned data and rearrange that, put it on
tdData.pData
Stucture of tdData.pData is below
[8 Byte proceeded result information] + [Separate data structure pointer]
tdData.wdDataSize is the value that includes sizes of data above.
So after composing data like above, CASPRTC cuts off 8 byte from those data,
and sends remained real data to the Application.

Proceedure Result 8 Bytes composition


<Result[2,Dec,Asc]><State[3,Dec,Asc]><Reserve[2,Dec,Asc]><’/’[1,Chr,Asc]>
Result
1 : Failed
2 : Succeeded
3 : Continuous data transmission(Internal circular data process)
State
100~199 : Code of success
200~299 : Code of error
Reserve
0~99 : Not confirmed
‘/’ : Final separation character
DF_APIEXPORT
TD_ST_TRANSDATA_V02

Example
int Interpret(TD_ST_TRANSDATA_V02 tdData)

int iRtn = 0;

switch (tdData.btCommType)

54
{

case DF_COMMTYPE_TCPIP:

case DF_COMMTYPE_SERIAL:

switch(tdData.btDataType)

case DF_DATA_PLU:

break;

case DF_DATA_TEST:

iRtn = TestInterpret(&tdData);

if (pRecvProc != NULL)

pRecvProc(tdData);

else

iRtn = 0;

break;

break;

case DF_COMMTYPE_UDP:

iRtn = tdData.wdDataSize;

if (pRecvProc != NULL)

pRecvProc(tdData);

else

iRtn = 0;

break;

return iRtn;

int TestInterpret(TD_ST_TRANSDATA_V02 *tdData)

int iRtn = 0;

int iSize = 0;

BYTE *pData;

BYTE btBuffer[DF_SIZE_RECVBUFFER];

pData = (BYTE*)tdData->pData;

55
iSize = tdData->wdDataSize;

memset(btBuffer, 0x0, DF_SIZE_RECVBUFFER);

memcpy(btBuffer, pData, iSize);

memset(pData, 0x0, iSize);

for (int i = 0; i < iSize; i++)

pData[i] = btBuffer[i];

strcpy((char*)&pData[i], "-Interpret");

iRtn = i + 10;

tdData->wdDataSize = (WORD)iRtn;

return iRtn;

56
1.2.3.2 Interpreter : Deinterpret()

USER
During data transaction process between Application Program and Scale, it
reconfigures data into recognizable data for scale.
Return the date size when it succeeds, otherwise converse into “0”

Module Developer
Inserting Transferred Data to Scale and received Data into IpBuffer and convert.
It must be careful not to send initialized function pointer.

DF_APIEXPORT int Deinterpret(TD_ST_TRANSDATA_V02 *tdData, LPSTR lpBuffer)

tdData
Configuration structure combining original data received from scale
TD_ST_TRANSDATA Original form
struct _stTransData {

short shScaleID;

LPSTR lpIP;

BYTE btCommType;

BYTE btSendType;

BYTE btDataType;

WORD wdScaleType;

WORD wdScaleModel;

WORD wdDataSize;

void *pData;

DWORD dwScaleMainVersion;

DWORD dwScaleSubVersion;

DWORD dwScaleCountry;

DWORD dwScaleDataVersion;

DWORD dwReserveVersion;

void *pReserve;

DWORD dwScaleMainVersion;

DWORD dwScaleSubVersion;

DWORD dwScaleCountry;

DWORD dwScaleDataVersion;

57
DWORD dwReserveVersion;

void *pReserve;

} TD_ST_TRANSDATA_V02;

lpBuffer
Pointer factor for process original data and transferring reconfigured data
lpBuffer returns ([Proceeding result 8 Byte]+[Converted data]).
If error occurred, it returns just proceeding result.
If error occurred, it sends the previous tdData.pData data to the upper level.

ex> When uploading, error occurred.


_dataStructure.wdNo = 0;
_dataSturcture.chName = “LP16:E99"

Reference
DF_APIEXPORT
TD_ST_TRANSDATA_V02

Example
int Deinterpret(TD_ST_TRANSDATA_V02 tdData, LPSTR lpBuffer)

int iRtn = 0;

switch(tdData.btCommType)

case DF_COMMTYPE_TCPIP:

case DF_COMMTYPE_SERIAL:

switch(tdData.btDataType)

case DF_DATA_PLU:

break;

case DF_DATA_TEST:

iRtn = TestDeinterpret(tdData, lpBuffer);

break;

break;

58
case DF_COMMTYPE_UDP:

memcpy(lpBuffer, tdData.pData, tdData.wdDataSize);

iRtn = tdData.wdDataSize;

break;

return iRtn;

int TestDeinterpret(TD_ST_TRANSDATA_V02 tdData, LPSTR lpBuffer)

int iRtn = 0;

BYTE *pData;

pData = (BYTE*)tdData.pData;

if (lpBuffer != NULL)

for (int i = 0; i < tdData.wdDataSize; i++)

lpBuffer[i] = pData[i];

strcpy((char*)&lpBuffer[i], "-Deinterpret");

iRtn = i + 12;

return iRtn;

59
1.2.3.3 Interpreter : GetLibraryInfo()

It stores interpreter version data into configuration pointer that informing module data.

DF_APIEXPORT int GetLibraryInfo(TD_ST_THIS *ptdLibInfo)

ptdLibInfo
Structure pointer for receiving moduel version information

Reference
DF_APIEXPORT
TD_ST_THIS

Example
int GetLibraryInfo(TD_ST_THIS *ptdInfo)

int iRtn = 0;

ptdInfo->btMainVer = 0;

ptdInfo->btSubVer = 1;

ptdInfo->btModifyYear = 5;

ptdInfo->btModifyMonth = 10;

ptdInfo->btModifyDay = 20;

iRtn = TRUE;

return iRtn;

60
1.2.3.4 Interpreter : AddBuffer()

This interface is called when one connection is added in the level of CASPRTC.
Use this interface when you assign the memory to the separate added connection or do some
works those need initialization.

int AddBuffer(char *pchIP, int iPort, int iScaleID, int iDataType)

pchIP
The final IP string(Null) in the added connection
That’s used for the case of TCP/IP communication, and “ ”(space) is used for
the other cases.
iPort
This is used for Ethernet Port # in the case of TCP/IP communication, and used
for Serial Port # in the case of RS232.
And in the other cases, this is used for the identification #.
iScaleID
The original number of the scale
iDataType
Data type
Definition Explanation
DF_DATA_PLU_V02 Plu Structure data
DF_DATA_DISC Discount Structure data
DF_DATA_DEPT Department Structure data
DF_DATA_GROUP Group Structure data
DF_DATA_TAXRATE Tax Rate Structure data
DF_DATA_SALEMSG Sale Message Structure data
DF_DATA_ORIGIN Origin Structure data
DF_DATA_BARCODE Barcode Structure data
DF_DATA_TARE Tare Structure data
DF_DATA_PCSUNIT Pcs Unit Structure data
DF_DATA_INGREDIENT Ingredient Structure data
DF_DATA_NUTRIFACT_V02 Nutrifact Structure data
DF_DATA_TRACE Trace Structure data
DF_DATA_COUNTRY Country Structure data
DF_DATA_SLAUGHT Slaught Structure data

61
DF_DATA_CUT Cutting hall Structure data
DF_DATA_STORE Store Structure data
DF_DATA_CUSTOM Customer Structure data
DF_DATA_SCROLLMSG_V03 Scroll Message Structure data
DF_DATA_SECURITY Security Structure data
DF_DATA_REPORT Report Structure data
DF_DATA_LABEL Label Structure data
DF_DATA_IMAGE Image Structure data
DF_DATA_KEY Keypad Structure data
DF_DATA_PLUINFO Plu status table Structure data
DF_DATA_SCALECMD Scale Command Structure data
DF_DATA_THIS This module Structure data
DF_DATA_SCALEINFO Scale information structure data
Reference

Example

62
1.2.3.5 Interpreter : DeleteBuffer()

This interface is called when one connection is deleted in the level of CASPRTC.
Use this interface when you release the memory to the separate added connection or do
initialization to the used data.

int DeleteBuffer(char *pchIP, int iPort, int iScaleID, int iDataType)

pchIP
The final IP string(Null) in the added connection
That’s used for the case of TCP/IP communication, and “ ”(space) is used for
the other cases.
iPort
This is used for Ethernet Port # in the case of TCP/IP communication, and used
for Serial Port # in the case of RS232.
And in the other cases, this is used for the identification #.
iScaleID
The original number of the scale
iDataType
Data type
Definition Explanation
DF_DATA_PLU_V02 Plu Structure data
DF_DATA_DISC Discount Structure data
DF_DATA_DEPT Department Structure data
DF_DATA_GROUP Group Structure data
DF_DATA_TAXRATE Tax Rate Structure data
DF_DATA_SALEMSG Sale Message Structure data
DF_DATA_ORIGIN Origin Structure data
DF_DATA_BARCODE Barcode Structure data
DF_DATA_TARE Tare Structure data
DF_DATA_PCSUNIT Pcs Unit Structure data
DF_DATA_INGREDIENT Ingredient Structure data
DF_DATA_NUTRIFACT_V02 Nutrifact Structure data
DF_DATA_TRACE Trace Structure data
DF_DATA_COUNTRY Country Structure data

63
DF_DATA_SLAUGHT Slaught Structure data
DF_DATA_CUT Cutting hall Structure data
DF_DATA_STORE Store Structure data
DF_DATA_CUSTOM Customer Structure data
DF_DATA_SCROLLMSG_V03 Scroll Message Structure data
DF_DATA_SECURITY Security Structure data
DF_DATA_REPORT Report Structure data
DF_DATA_LABEL Label Structure data
DF_DATA_IMAGE Image Structure data
DF_DATA_KEY Keypad Structure data
DF_DATA_PLUINFO Plu status table Structure data
DF_DATA_SCALECMD Scale Command Structure data
DF_DATA_THIS This module Structure data
DF_DATA_SCALEINFO Scale information structure data
Reference

Example

64
1.2.4 Structure

1.2.4.1 _stTransData
This structure is for exchanging data process. Application program and Protocol module use this
structure.
typedef struct _stTransData {
short shScaleID;
LPSTR lpIP;
BYTE btCommType;
BYTE btSendType;
BYTE btDataType;
WORD wdScaleType;
WORD wdScaleModel;
WORD wdAction;
WORD wdDataSize;
void *pData;
} TD_ST_TRANSDATA;

btScaleID
Original number of Scale
lpIP
IP number string of Scale – need to be segmented
EX> 10.10.1.80
btCommType
Data communication type
Value Description
DF_COMMTYPE_TCPIP TCP/IP Socket Communication
DF_COMMTYPE_UDP UDP Socket Communication
DF_COMMTYPE_SERIAL Serial communication

btSendType
Set the type of data for transfer
Value Description
DF_SENDTYPE_NORMAL Basic Setting
DF_SENDTYPE_BROADCAST Relay every scale with UDP
Only UDP Socket can be used

65
btDataType
Communication Data type
Value Description
DF_DATA_PLU_V02 Data of Plu Structure
DF_DATA_DISC Data of Discount Structure
DF_DATA_DEPT Data of Department structure
DF_DATA_GROUP Data of Group Structure
DF_DATA_TAXRATE Data of Tax Rate Structure
DF_DATA_SALEMSG Data of Sale Message structure
DF_DATA_ORIGIN Data of Origin Structure
DF_DATA_BARCODE Data of Barcode Structure
DF_DATA_TARE Data of Tare Structure
DF_DATA_PCSUNIT Data of Pcs Unit structure
DF_DATA_INGREDIENT Data of Ingredient Structure
DF_DATA_NUTRIFACT_V02 Data of Nutrifact structure
DF_DATA_TRACE Data of Trace structure
DF_DATA_COUNTRY Data of Country Structure
DF_DATA_SLAUGHT Data of Slaught structure
DF_DATA_CUT Data of Cutting hall structure
DF_DATA_STORE Data of Store Structure
DF_DATA_CUSTOM Data of Customer structure
DF_DATA_SCROLLMSG_V03 Data of Scroll Message structure
DF_DATA_SECURITY Data of Security structure
DF_DATA_REPORT Data of Report structure
DF_DATA_LABEL Data of Label structure
DF_DATA_IMAGE Data of Image structure
DF_DATA_KEY Data of Keypad structure
DF_DATA_PLUINFO Data of Plu status table structure
DF_DATA_SCALECMD Data of Scale Command structure
DF_DATA_THIS Data of this module structure
DF_DATA_SCALEINFO Scale information structure data
shScaleType
Currently communicating scale type
Value Description
DF_SCALE_TYPE_LP Label printer scale
DF_SCALE_TYPE_RW Truck Scale

66
DF_SCALE_TYPE_NT Indicator
DF_SCALE_TYPE_POS Poscale
DF_SCALE_TYPE_ETC Other scales and connection

shScaleModel
Indicate the type of mode within scale type
Value Description
DF_SCALE_15 LP-15
DF_SCALE_16 LP-16
DF_SCALE_17 LP-17
DF_SCALE_20 LP-2
DF_SCALE_5000 CL5000
DF_SCALE_5000JR CL5000J
DF_SCALE_5500 CL5500
DF_SCALE_CL7200 CL7200
wdAction
Input the Argument defining the characteristic of data being transferred.
Value Description
DF_ACTION_NOTHING Communicating simple data
DF_ACTION_GETINFO Getting Information
DF_ACTION_UPLOAD Receiving data from scale
DF_ACTION_DOWNLOAD Sending data from PC to scale
DF_ACTION_DELETE Deleting data in the scale
DF_ACTION_DELETEALL Deleting all data in the scale
DF_ACTION_READ Reading data from the scale
DF_ACTION_WRITE Writing data to the scale
DF_ACTION_INITSCALE Initializing the scale
DF_ACTION_RESET Resetting the scale
DF_ACTION_SET Setting the scale
DF_ACTION_NORMAL Communication normal data
DF_ACTION_SEND Transferring simple data
wdDataSize
Setting the size of pData size

*pData
Data void point for actual transfer and receive

67
Value Data structure
DF_DATA_PLU_V02 _stDataPLU
DF_DATA_DISC _stDataDisc
DF_DATA_DEPT _stDataDept
DF_DATA_GROUP _stDataGroup
DF_DATA_TAXRATE _stDataTaxRate
DF_DATA_SALEMSG _stDataSaleMsg
DF_DATA_ORIGIN _stDataOrigin
DF_DATA_BARCODE _stDataBarcode
DF_DATA_TARE _stDataTare
DF_DATA_PCSUNIT _stDataPcsUnit
DF_DATA_INGREDIENT _stDataIngredient
DF_DATA_NUTRIFACT_V02 _stDataNutrifact
DF_DATA_TRACE _stDataTrace
DF_DATA_COUNTRY _stDataCountry
DF_DATA_SLAUGHT _stDataSlaught
DF_DATA_CUT _stDataCut
DF_DATA_STORE _stDataStore
DF_DATA_CUSTOM _stDataCustom
DF_DATA_SCROLLMSG_V03 _stDataScrollMsg
DF_DATA_SECURITY _stDataSecurity
DF_DATA_REPORT _stDataReport
DF_DATA_LABEL _stDataLabel
DF_DATA_IMAGE _stDataImage
DF_DATA_KEY _stDataKey
DF_DATA_PLUINFO _stDataPluInfoTable
DF_DATA_SCALECMD _stDataScaleCommand
DF_DATA_THIS _stThisModule
DF_DATA_SCALEINFO Scale information structure data
Reference
typedef int TD_LIB_SENDDATATCPIP(TD_ST_TRANSDATA tdTransData);

Example

68
1.2.4.2 _stTransDataV02
Version of scale is added to _stTransData
typedef struct _stTransDataV02 {
short shScaleID;
LPSTR lpIP;
BYTE btCommType;
BYTE btSendType;
BYTE btDataType;
WORD wdScaleType;
WORD wdScaleModel;
WORD wdAction;
WORD wdDataSize;
void *pData;
DWORD dwScaleMainVersion;
DWORD dwScaleSubVersion;
DWORD dwScaleCountry;
DWORD dwScaleDataVersion;
DWORD dwReserveVersion;
void *pReserve;
} TD_ST_TRANSDATA_V02;

btScaleID
Original number of Scale
lpIP
IP number string of Scale – need to be segmented
EX> 10.10.1.80
btCommType
Data communication type
Value Description
DF_COMMTYPE_TCPIP TCP/IP Socket Communication
DF_COMMTYPE_UDP UDP Socket Communication
DF_COMMTYPE_SERIAL Serial communication

btSendType
Set the type of data for transfer
Value Description

69
DF_SENDTYPE_NORMAL Basic Setting
DF_SENDTYPE_BROADCAST Relay every scale with UDP
Only UDP Socket can be used
btDataType
Communication Data type
Value Description
DF_DATA_PLU_V02 Data of Plu Structure
DF_DATA_DISC Data of Discount Structure
DF_DATA_DEPT Data of Department structure
DF_DATA_GROUP Data of Group Structure
DF_DATA_TAXRATE Data of Tax Rate Structure
DF_DATA_SALEMSG Data of Sale Message structure
DF_DATA_ORIGIN Data of Origin Structure
DF_DATA_BARCODE Data of Barcode Structure
DF_DATA_TARE Data of Tare Structure
DF_DATA_PCSUNIT Data of Pcs Unit structure
DF_DATA_INGREDIENT Data of Ingredient Structure
DF_DATA_NUTRIFACT_V02 Data of Nutrifact structure
DF_DATA_TRACE Data of Trace structure
DF_DATA_COUNTRY Data of Country Structure
DF_DATA_SLAUGHT Data of Slaught structure
DF_DATA_CUT Data of Cutting hall structure
DF_DATA_STORE Data of Store Structure
DF_DATA_CUSTOM Data of Customer structure
DF_DATA_SCROLLMSG_V03 Data of Scroll Message structure
DF_DATA_SECURITY Data of Security structure
DF_DATA_REPORT Data of Report structure
DF_DATA_LABEL Data of Label structure
DF_DATA_IMAGE Data of Image structure
DF_DATA_KEY Data of Keypad structure
DF_DATA_PLUINFO Data of Plu status table structure
DF_DATA_SCALECMD Data of Scale Command structure
DF_DATA_THIS Data of this module structure
DF_DATA_SCALEINFO Scale information structure data
shScaleType
Currently communicating scale type

70
Value Description
DF_SCALE_TYPE_LP Label printer scale
DF_SCALE_TYPE_RW Truck Scale
DF_SCALE_TYPE_NT Indicator
DF_SCALE_TYPE_POS Poscale
DF_SCALE_TYPE_ETC Other scales and connection

shScaleModel
Indicate the type of mode within scale type
Value Description
DF_SCALE_15 LP-15
DF_SCALE_16 LP-16
DF_SCALE_17 LP-17
DF_SCALE_20 LP-2
DF_SCALE_5000 CL5000
DF_SCALE_5000JR CL5000J
DF_SCALE_5500 CL5500
DF_SCALE_CL7200 CL7200
wdAction
Input the Argument defining the characteristic of data being transferred.
Value Description
DF_ACTION_NOTHING Communicating simple data
DF_ACTION_GETINFO Getting Information
DF_ACTION_UPLOAD Receiving data from scale
DF_ACTION_DOWNLOAD Sending data from PC to scale
DF_ACTION_DELETE Deleting data in the scale
DF_ACTION_DELETEALL Deleting all data in the scale
DF_ACTION_READ Reading data from the scale
DF_ACTION_WRITE Writing data to the scale
DF_ACTION_INITSCALE Initializing the scale
DF_ACTION_RESET Resetting the scale
DF_ACTION_SET Setting the scale
DF_ACTION_NORMAL Communication normal data
DF_ACTION_SEND Transferring simple data
wdDataSize
Setting the size of pData size

71
*pData
Data void point for actual transfer and receive

Value Data structure


DF_DATA_PLU_V02 _stDataPLU
DF_DATA_DISC _stDataDisc
DF_DATA_DEPT _stDataDept
DF_DATA_GROUP _stDataGroup
DF_DATA_TAXRATE _stDataTaxRate
DF_DATA_SALEMSG _stDataSaleMsg
DF_DATA_ORIGIN _stDataOrigin
DF_DATA_BARCODE _stDataBarcode
DF_DATA_TARE _stDataTare
DF_DATA_PCSUNIT _stDataPcsUnit
DF_DATA_INGREDIENT _stDataIngredient
DF_DATA_NUTRIFACT_V02 _stDataNutrifact
DF_DATA_TRACE _stDataTrace
DF_DATA_COUNTRY _stDataCountry
DF_DATA_SLAUGHT _stDataSlaught
DF_DATA_CUT _stDataCut
DF_DATA_STORE _stDataStore
DF_DATA_CUSTOM _stDataCustom
DF_DATA_SCROLLMSG_V03 _stDataScrollMsg
DF_DATA_SECURITY _stDataSecurity
DF_DATA_REPORT _stDataReport
DF_DATA_LABEL _stDataLabel
DF_DATA_IMAGE _stDataImage
DF_DATA_KEY _stDataKey
DF_DATA_PLUINFO _stDataPluInfoTable
DF_DATA_SCALECMD _stDataScaleCommand
DF_DATA_THIS _stThisModule
DF_DATA_SCALEINFO Scale information structure data
dwScaleMainVersion
Main version of Scale
dwScaleSubVersion

72
Sub version of Scale
dwScaleDataVersion
Data Version
dwScaleCountry
Country
dwReserveVersion
Reserve
*pReserve
Reserve

Reference
typedef int TD_LIB_SENDDATATCPIP(TD_ST_TRANSDATA_V02 tdTransData);

Example

73
1.2.4.3 _stSocketInfo
Configuration form for initializing, confirming and setting socket information
typedef struct _stSocketInfo {
short shScaleID;
LPSTR lpIP;
WORD wdPort;
WORD wdScaleType;
WORD wdScaleModel;
WORD wdTimeOut;
WORD wdRetryCount;
BYTE btCommType;
BYTE btTransType;
BYTE btSocketType;
BYTE btDataType;
DWORD dwMsgNo;
DWORD dwStateMsgNo;
BYTE btLogStatus;
LPSTR lpLogFileName;
TD_PROC_RECV *pRecvProc;
TD_PROC_STATE *pStateProc;
} TD_ST_SOCKETINFO;

shScaleID
Serial number of Scale
lpIP
IP number string of Scale – need to be segmented

EX> 10.10.1.80
wdPort
Setting IP port number
wdScaleType
Currently communicating scale type

Vaule Description
DF_SCALE_TYPE_LP Label printer scale
DF_SCALE_TYPE_RW Truck scale

74
DF_SCALE_TYPE_NT Indicator
DF_SCALE_TYPE_POS Poscale
DF_SCALE_TYPE_ETC Other scales and connection
wdScaleModel
Indicate the type of mode within scale type
Value Description
DF_SCALE_15 LP-15
DF_SCALE_16 LP-16
DF_SCALE_17 LP-17
DF_SCALE_20 LP-2
DF_SCALE_5000 CL5000
DF_SCALE_5000JR CL5000J
DF_SCALE_5500 CL5500
DF_SCALE_CL7200 CL7200
wdTimeOut
Setting time out time

wdRetryCount
Setting number of retrial

btCommType
Setting Communication type. Setting SockType compared to CommType
Value Description
DF_COMMTYPE_TCPIP Setting Socket for TCP/IP communication
DF_COMMTYPE_UDP Setting Socket for UDP communication
DF_COMMTYPE_SERIAL Setting port for Serial communication

btTransType
Setting a receiving method for data through communication with application
program

Value Description
DF_TRANSTYPE_PROC Sending function pointer of RecvProc of SocketInfo
properties
DF_TRANSTYPE_MSG Sendig MsgNo message from SocketInfo proferties

75
btSocketType
Primarily set a Socket type. If setting goes through CommType, it needs to decide
whether to use UDP or TCP/IP in Socket type.

Value Description
SOCK_STREAM Use TCP/IP
SOCK_DGRAM Use UDP
iMsgNo
Sending received data to application program as set message number
dwStateMsgNo
Sending Communication status data to application program as set message number
btLogStatus
Setting whether to report communication status or not
lpLogFileName
Setting Log report file name
pRecvProc
Setting function pointer for processing received data
Function form
int (*pRecvProc)(TD_ST_TRANSDATA_V02 *pData);
pStateProc
Setting function pointer for processing communication status info
Function form
int (*pRecvProc)(TD_ST_TRANSDATA_V02*pData);

pData-> pData is (void*) type and convert into (TD_ST_STATE*) as it proceeds

Reference
DF_APIEXPORT int AddConnection(TD_ST_CONNECTION tdConnection)

Example
-

76
1.2.4.4 _stSocketInfoV02
Configuration form for initializing, confirming and setting socket information
typedef struct _stSocketInfo {
short shScaleID;
LPSTR lpIP;
WORD wdPort;
WORD wdScaleType;
WORD wdScaleModel;
WORD wdTimeOut;
WORD wdRetryCount;
BYTE btCommType;
BYTE btTransType;
BYTE btSocketType;
BYTE btDataType;
DWORD dwMsgNo;
DWORD dwStateMsgNo;
BYTE btLogStatus;
LPSTR lpLogFileName;
TD_PROC_RECV *pRecvProc;
TD_PROC_STATE *pStateProc;
DWORD dwScaleMainVersion;
DWORD dwScaleSubVersion;
DWORD dwScaleCountry;
DWORD dwScaleDataVersion;
DWORD dwReserveVersion;
void *pReserve;
} TD_ST_SOCKETINFO_V02;

shScaleID
Serial number of Scale
lpIP
IP number string of Scale – need to be segmented

EX> 10.10.1.80
wdPort
Setting IP port number

77
wdScaleType
Currently communicating scale type

Vaule Description
DF_SCALE_TYPE_LP Label printer scale
DF_SCALE_TYPE_RW Truck scale
DF_SCALE_TYPE_NT Indicator
DF_SCALE_TYPE_POS Poscale
DF_SCALE_TYPE_ETC Other scales and connection
wdScaleModel
Indicate the type of mode within scale type
Value Description
DF_SCALE_15 LP-15
DF_SCALE_16 LP-16
DF_SCALE_17 LP-17
DF_SCALE_20 LP-2
DF_SCALE_5000 CL5000
DF_SCALE_5000JR CL5000J
DF_SCALE_5500 CL5500
DF_SCALE_CL7200 CL7200
wdTimeOut
Setting time out time

wdRetryCount
Setting number of retrial

btCommType
Setting Communication type. Setting SockType compared to CommType
Value Description
DF_COMMTYPE_TCPIP Setting Socket for TCP/IP communication
DF_COMMTYPE_UDP Setting Socket for UDP communication
DF_COMMTYPE_SERIAL Setting port for Serial communication

btTransType
Setting a receiving method for data through communication with application
program

78
Value Description
DF_TRANSTYPE_PROC Sending function pointer of RecvProc of SocketInfo
properties
DF_TRANSTYPE_MSG Sendig MsgNo message from SocketInfo proferties

btSocketType
Primarily set a Socket type. If setting goes through CommType, it needs to decide
whether to use UDP or TCP/IP in Socket type.

Value Description
SOCK_STREAM Use TCP/IP
SOCK_DGRAM Use UDP
iMsgNo
Sending received data to application program as set message number
dwStateMsgNo
Sending Communication status data to application program as set message number
btLogStatus
Setting whether to report communication status or not
lpLogFileName
Setting Log report file name
pRecvProc
Setting function pointer for processing received data
Function form
int (*pRecvProc)(TD_ST_TRANSDATA_V02 *pData);
pStateProc
Setting function pointer for processing communication status info
Function form
int (*pRecvProc)(TD_ST_TRANSDATA_V02*pData);

pData-> pData is (void*) type and convert into (TD_ST_STATE*) as it proceeds


dwScaleMainVersion
Main version of Scale
dwScaleSubVersion
Sub version of Scale
dwScaleDataVersion

79
Data Version
dwScaleCountry
Country
dwReserveVersion
Reserve
*pReserve
Reserve

Reference
DF_APIEXPORT int AddConnection(TD_ST_CONNECTION_V02 tdConnection)

Example
-

80
1.2.4.5 _stSerialInfo
Configuration form for initializing, confirming and setting socket information
typedef struct _stSerialInfo {
BYTE btScaleID;
short shPort;
int iBaudrate;
short shScaleType;
short shScaleModel;
short shTimeOut;
short shRetryCount;
BYTE btTransType;
int iMsgNo;
BYTE btLogStatus;
LPSTR lpLogFileName;
TD_RECV_PROC *pRecvProc;
} TD_ST_SERIALINFO;

btScaleID
Serial number of Scale
shPort
Setting Serial communication port
iBaudrate
Setting Serial communication speed

shScaleType
Currently communicating scale type

Value Description
DF_SCALE_TYPE_LP Label printer scale
DF_SCALE_TYPE_RW Truck Scale
DF_SCALE_TYPE_NT Indicator
DF_SCALE_TYPE_POS Poscale
DF_SCALE_TYPE_ETC Other scales and communication

shScaleModel
Indicate the type of mode within scale type

81
Value Description
DF_SCALE_15 LP-15
DF_SCALE_16 LP-16
DF_SCALE_17 LP-17
DF_SCALE_20 LP-2
DF_SCALE_5000 CL5000
DF_SCALE_5000JR CL5000J
DF_SCALE_5500 CL5500
DF_SCALE_CL7200 CL7200

shTimeOut
Setting Time out time

shRetryCount
Setting number of retrial

btTransType
Setting a receiving method for data through communication with application program

Value Description
DF_TRANSTYPE_PROC Sending function pointer of RecvProc of SocketInfo properties
DF_TRANSTYPE_MSG Sendig MsgNo message from SocketInfo proferties

iMsgNo
Sending received data to application program as set message number

btLogStatus
Sending Communication status data to application program as set message

lpLogFileName
Setting Log report file name
pRecvProc
Setting function pointer for processing received data

82
Function form
int (*pRecvProc)(TD_ST_TRANSDATA_V02 *pData);

83
1.2.4.6 _stDataPLUv06
This is a type of Data configuration of Data communication for exchanging PLU data. The main
focus is to exchange data between Protocol module and application. Protocol module converts
a received configuration into that of receivable configuration for scale. The configuration is sent
to communication module and communication module resend it to scale.

Reference: This configuration does not independently exchange data and included within
_stTransDataV02 for processing.
This data is for PLU network communication in both LP1 1.6v and CL5000 as well. All of the
unused fields should be se t to “0”

typedef struct _stDataPLU06 {


WORD wdDepart;
DWORD dwPLU;
BYTE btPLUType;
char chName1[100+1];
char chName2[100+1];
char chName3[100+1];
WORD wdGroup;
WORD wdLabel1;
WORD wdLabel2;
WORD wdOrigin;
BYTE btWeightUnit;
DWORD dwFixWeight;
char chPrefix[10+1];
DWORD dwItemCode;
WORD wdPieces;
BYTE btQuatSymbol;
BYTE btPriceType;
DWORD dwUnitPrice;
DWORD dwSpecialPrice;
WORD wdTaxNo;
DWORD dwTare;
WORD wdTareNo;
DWORD dwPerTare;
DWORD dwTareLimit;

84
WORD wdBarcode1;
WORD wdBarcode2;
WORD wdPicture;
WORD wdProduceDate;
WORD wdPackDate;
WORD wdPackTime;
DWORD dwSellDate;
WORD wdSellTime;
WORD wdCookDate;
WORD wdIngredient;
WORD wdTraceability;
WORD wdBonus;
WORD wdNutrifact;
WORD wdSaleMSG;
WORD wdRefPLUDept;
DWORD dwRefPLUNo;
WORD wdCouplePLUDept;
DWORD dwCouplePLUNo;
WORD wdLinkPLUCount;
WORD wdLinkPLUDept1;
DWORD dwLinkPLUNo1;
WORD wdLinkPLUDept2;
DWORD dwLinkPLUNo2;
BYTE btTotalFlag;
DWORD dwTotalCount;
DWORD dwTotalPrice;
DWORD dwTotalWeight;
char chReserve1[50+1];
char chReserve2[50+1];
char chReserve3[50+1];
WORD wdNo;
WORD wdDirectSize;
char chDirectIngredient[1024+1];
BYTE btPackedDateFlag;
BYTE btPackedTimeFlag;
BYTE btSellByDateFlag;

85
BYTE btSellByTimeFlag;
char chName4[100+1];
char chName5[100+1];
char chName6[100+1];
char chName7[100+1];
char chName8[100+1];
BYTE btNameFontSize1;
BYTE btNameFontSize2;
BYTE btNameFontSize3;
BYTE btNameFontSize4;
BYTE btNameFontSize5;
BYTE btNameFontSize6;
BYTE btNameFontSize7;
BYTE btNameFontSize8;
BYTE btTraceItemFlag;
BYTE btDtIngredientFlag;
BYTE btDtSaleMsgFlag;
BYTE btDtNutriFactFlag;
BYTE btDtOriginFlag;
char chPictureFile[50];

} TD_ST_PLU_V06;

wdDepart
Setting department data. Range is from 1 to 99.

dwPLU
Setting PLU number. Range is from 1 to 99999.
And Same way for both CL5000 & LP1v1.6
If error occurs on uploading, dwPLU is set to ‘0’ and chName1 was configured with the
description of the error.
btPLUType
Setting PLU type.
Value Description
1 Weight
2 Count

86
3 PCS

chName1
Setting Plu name
And Same way for both CL5000 & LP1v1.6

chName2
Setting Plu name
And Same way for both CL5000 & LP1v1.6

chName3
Setting Plu name

wdGroup
Setting Group number
And Same way for both CL5000 & LP1v1.6

wdLabel1
Setting Label number
wdLabel2
Setting Label number

wdOrigin
Setting original production number.

btWeightUnit
Setting an unit for weight
.
Value Description
1 100g
2 1kg

dwFixWeight
Setting Fixed Weight

chPrefix

87
Configure the fixed detected code in serial number.(Korean defined version).
dwItemCode
This is to set Item Code
And Same way for both CL5000 & LP1v1.6
wdPieces
Setting number for selling unit

btQuatSymbol
Select selling unit indication symbol

btPriceType
Select Price type

dwUnitPrice
Setting PLU weight unit price
And Same way for both CL5000 & LP1v1.6

dwSpecialPrice
Setting PLU special price

wdTaxNo
Setting Tax rate number

dwTare
Setting Tare weight
And Same way for both CL5000 & LP1v1.6

wdTareNo
Setting tare weight number

dwPerTare
Setting percentage of tare

dwTareLimit
Setting limit of tare

88
wdBarcode1
Setting Bar code

wdBarcode2
Setting Bar code
wdPicture
Currently not use (Use it with Logo no in LP1v16 Russian defined version)
wdProduceDate
Configuring Produced date.
wdPackDate
Configuring Packed date.
wdPackTime
Configuring Packed time.
dwSellDate
This is to set the Sell by Date (Valid Date)
And Same way for both CL5000, LP1v1.6
Same item as LIFE item of LP1v1.6

wdSellTime
Configuring Sell by time.
wdCookDate
Configuring Cook by date.
wdIngredient
This is to set the Ingredient for both of CL5000 and LP1 1.6v session
In case of LP1 1.6v, you can refer to the menu “Message”
wdTraceability
Configuring Traceability.
wdBonus
Configuring Bonus.
wdNutrifact
Configuring Nutrition facts.
wdSaleMSG
Configuring Label advertisement message.
wdRefPLUDept
Configuring Reference department.

89
dwRefPLUNo
Configuring Reference PLU number.
wdCouplePLUDept
Configuring Coupled department.
dwCouplePLUNo
Configuring Coupled PLU number.
wdLinkPLUCount
Configuring Linked PLU counts.
dwLinkPLUDept1
Configuring Linked Department 1.
dwLinkPLUNo1
Configuring Linked PLU number 1.
wdLinkPLUDept2
Configuring Linked Department 2.
dwLinkPLUNo2
Configuring Linked PLU number 2.
btTotalFlag
This is to set Total Flag and is only for LP1 1.6v
When downloading data, This is on whether you want to use
“dwTotalcount, dwTotalPrice, dwTotalWeight” or Not
If you set it to 1, this is available
If you set it to 0, this is unavailable and it will make whole TotalFlag setting
to Default.

dwTotalCount
This is to set Total Count and this is used only for LP1v1.6

dwTotalPrice
This is to set Total Price and is used only for LP1v1.6
dwTotalWeight
This is to set TotalWeight and is only for LP1v1.6
chReserve1
Reserved Space 1 (In the case of LP1v16 Russian version, it is used for
Logo name[8Byte])
chReserve2
Reserved Space 2

90
chReserve3
Reserved Space 3
wdNo

wdDirectSize
Data size of Direct Ingredient data
chDirectIngredient
Direct Ingredient data
btPackedDateFlag
It determines wheter or not to print the Packed Date
0:Depending on Scale configuration
1:Not print
2:Print
btPackedTimeFlag
It determines wheter or not to print the Packed Time
0:Depending on Scale configuration
1:Not print
2:Print
3:Print the specified time
btSellByDateFlag
It determines wheter or not to print the Sell by Date
0:Depending on Scale configuration
1:Not print
2:Print
btSellByTimeFlag
It determines wheter or not to print the Packed Time
0:Depending on Scale configuration
1:Not print
2:Print
3:Print the specified time
chName4[100+1]
PLU Name4
chName5[100+1]
PLU Name5
chName6[100+1]
PLU Name6

91
chName7[100+1]
PLU Name7
chName8[100+1]
PLU Name8
btNameFontSize1
Size of the PLU Name1. It is for only GS Mart
btNameFontSize2
Size of the PLU Name2. It is for only GS Mart
btNameFontSize3
Size of the PLU Name3. It is for only GS Mart
btNameFontSize4
Size of the PLU Name4. It is for only GS Mart
btNameFontSize5
Size of the PLU Name5. It is for only GS Mart
btNameFontSize6
Size of the PLU Name6. It is for only GS Mart
btNameFontSize7
Size of the PLU Name7. It is for only GS Mart
btNameFontSize8
Size of the PLU Name8. It is for only GS Mart
btTraceItemFlag
Size of the PLU Name3. It is for only GS Mart
btDtIngredientFlag
btDtSaleMsgFlag
btDtNutriFactFlag
btDtOriginFlag
chPictureFile[50]
The file name of the the PLU image

92
1.2.4.7 _stDataDisc
This is a configuration for Data communication process. This is for exchanging Discount data
and data between Application program and Protocol module. It is not for independent usage and
must be added to _stTransData for transfer. Every data is not completely fulfilled through
downloading and uploading. Some of fields are not necessary. Please refer to following
categories.

typedef struct _stDataDisc {


WORD wdNo;
WORD wdDeptNo;
DWORD dwPLUNo;
char chName[100+1];
BYTE btPLUType;
BYTE btDiscType;
WORD wdTarget1;
DWORD dwValue1;
WORD wdTarget2;
DWORD dwValue2;
BYTE btStartDate;
BYTE btEndDate;
BYTE btStartTime;
BYTE btEndTime;
BYTE btWeek;
} TD_ST_DISC;
wdNo
Identification number of discount.
If error occurs on uploading, it is set to ‘0’ and chName is set to description of
error.
wdDeptNo
Setting a part of PLU for Discount setting
dwPLUNo
Setting a number of PLU for discount setting
chName
Name of PLU
If error occurs on uploading, chName is set to description of error.

93
btPLUType
Setting a type of PLU for discount setting
Value Description
1 Weight sale PLU
2 Counting sale PLU
3 Piece sale PLU

btDiscType
Setting discount form
Value Description
1 Unit price discount
2 % Unit price discount
3 Total price discount
4 % Total price discount
5 Fixed price
6 Free item
7 Free addition
8 Total price by total price
9 % Total price by total price
10 Unit price by total price
11 Extra by total price

wdTarget1
Setting the first discount point (weight or number)

dwValue1
Setting a discount price of the first discount point
wdTarget2
Setting the second point (weight or number)

dwValue2
Setting a discount price of the second discount point

btStartDate
Setting the Starting date of Discount

94
btEndDate
Setting the end date of Discount

btStartTime
Setting the starting time for discount

btEndTime
Setting the end date of discount

btWeek
Setting discount days

95
1.2.4.8 _stDataDept
This is a communication configuration form. It is used for exchanging department data and data
between application and protocol module. Protocol module converts data into that of receivable
to scale. This is combined with _stTransData insteadt of being used independently.

typedef struct _stSocketInfo {


WORD wdNo;
WORD wdSpeedKey;
char chName[100+1];
} TD_ST_DEPT;

wdNo
Configuring Department number.
If error occurs on uploading, it is set to ‘0’ and chName is set to description of
error.
wdSpeedKey
Configuring Speed key.
chName
Configuring name or description.
If error occurs on uploading, chName is set to description of error.

96
1.2.4.9 _stDataGroup
This is a communication configuration form. It is used for exchanging group data and data
between application and protocol module. Protocol module converts data into that of receivable
to scale. This is combined with _stTransData instead of being used independently.

typedef struct _stDataGroup {


WORD wdNo;
char chName[100+1];
} TD_ST_GROUP;

wdNo
Configuring Group number.
If error occurs on uploading, it is set to ‘0’ and chName is set to description of
error.

chName
Input name or description.
If error occurs on uploading, chName is set to description of error.

97
1.2.4.10 _stDataTaxRate
This is a communication configuration form. It is used for exchanging tax rate data and data
between application and protocol module. Protocol module converts data into that of receivable
to scale. This is combined with _stTransData insteadt of being used independently.

typedef struct _stDataTaxRate {


WORD wdNo;
BYTE btType;
char chName[100+1];
WORD wdValue;
} TD_ST_TAXRATE;

wdNo
Configuring Tax rate number.
If error occurs on uploading, it is set to ‘0’ and chName is set to description of
error.

btType
Configuring Tax-rate type.

chName
Configuring name or description.
If error occurs on uploading, chName is set to description of error.

wdValue
Configuring value.

98
1.2.4.11 _stDataSaleMsg
This is a communication configuration form. It is used for exchanging sales message data and
data between application and protocol module. Protocol module converts data into that of
receivable to scale. This is combined with _stTransData insteadt of being used independently.
This data is for PLU network communication in both LP1 1.6v and CL5000 as well. All of the
unused fields should be se t to “0”
This is for Advertising Sales scroll message data.

typedef struct _stSaleMsg {


WORD wdNo;
char chName[100+1];
} TD_ST_SALEMSG;

wdNo
This is to set Sale message Number in both LP1 1.6v and CL5000
If error occurs on uploading, it is set to ‘0’ and chName is set to description of
error.
chName
This is to set the name of Sales message and description in
both LP1v1.6 & CL5000
If error occurs on uploading, chName is set to description of error.

99
1.2.4.12 _stDataOrigin
This is a communication configuration form. It is used for exchanging original production place
data and data between application and protocol module. Protocol module converts data into
that of receivable to scale. This is combined with _stTransData insteadt of being used
independently.

typedef struct _stDataOrigin {


WORD wdNo;
char chName[100+1];
} TD_ST_ORIGIN;

wdNo
Setting Origin number.
If error occurs on uploading, it is set to ‘0’ and chName is set to description of
errors
chName
Setting Origin name or description.
If error occurs on uploading, chName is set to description of error.

100
1.2.4.13 _stDataBarcode
This is a communication configuration form. It is used for exchanging barcode data and data
between application and protocol module. Protocol module converts data into that of receivable
to scale. This is combined with _stTransData insteadt of being used independently.

typedef struct _stDataBarcode {


WORD wdNo;
BYTE btType;
BYTE btFormatNo;
char chFormat[50+1];
char chName[100+1];
} TD_ST_BARCODE;

wdNo
Setting Barcode number.
If error occurs on uploading, it is set to ‘0’ and chName is set to description of
error.
btType
Setting Barcode type.
btFormatNo
Setting Barcode format number.
chFormat
Setting Barcode format string.
chName
Setting Barcode name or description.
If error occurs on uploading, chName is set to description of error.

101
1.2.4.14 _stDataTare
This is a communication configuration form. It is used for exchanging tare data and data
between application and protocol module. Protocol module converts data into that of receivable
to scale. This is combined with _stTransData insteadt of being used independently.

typedef struct _ststDataTare {


WORD wdNo;
BYTE btType;
WORD wdValue;
char chName[100+1];
} TD_ST_TARE;

btNo
Setting Tare number.
If error occurs on uploading, it is set to ‘0’ and chName is set to description of
error.
btType
Setting Tare type.
wdValue
Setting Tare weight.
chName
Setting Tare name or description.
If error occurs on uploading, it is set to ‘0’ and chName is set to description of
error.

102
1.2.4.15 _stPcsUnit
This is a communication configuration form. It is used for exchanging PCS Symbol data and
data between application and protocol module. Protocol module converts data into that of
receivable to scale. This is combined with _stTransData insteadt of being used independently.

typedef struct _stPcsUnit{


WORD wdNo;
char chName[100+1];
} TD_ST_PCSUNIT;

wdNo
Setting PCS unit number.
If error occurs on uploading, it is set to ‘0’ and chName is set to description of
error.

chName
Setting PCS unit name or description.
If error occurs on uploading, chName is set to description of error.

103
1.2.4.16 _stDataIngredient
This is a communication configuration form. It is used for exchanging ingredient data and data
between application and protocol module. Protocol module converts data into that of receivable
to scale. This is combined with _stTransData insteadt of being used independently.
This data is for PLU network communication in both LP1 1.6v and CL5000 as well. All of the
unused fields should be se t to “0”
This is for Message data.

typedef struct _stDataIngredient {


WORD wdNo;
char chName[1024+1];
} TD_ST_INGREDIENT;

wdNo
This is to set the Number of Ingredient in both LP1 1.6 & CL5000
If error occurs on uploading, it is set to ‘0’ and chName is set to description of
error.

chName
This is to set the Name of Ingredient and Discription in both LP1 1.6v & CL5000
If error occurs on uploading, chName is set to description of error.

104
1.2.4.17 _stDataNutrifact_V02
This is a communication configuration form. It is used for exchanging nutrition data and data
between application and protocol module. Protocol module converts data into that of receivable
to scale. This is combined with _stTransData insteadt of being used independently.
Use this structure when the data type is DF_DATA_NUTRIFACT_V03 or
DF_DATA_NUTRIFACT_V02.

typedef struct _stDataNutrifact_v02 {


WORD wdNo;
BYTE btType;
char chName[100+1];
char chServingSize[50+1];
char chServingPer[50+1];
DWORD dwValue[20];
DWORD dwBaseSize;
DWORD dwServingSize;
DWORD dwServingUnit;
} TD_ST_NUTRIFACT_V02;

wdNo;
Setting Nutrition factor number.
If error occurs on uploading, it is set to ‘0’ and chName is set to description of
error.
btType
Setting Nutrition factor type.
chName
Setting Nutrition factor name or description.
If error occurs on uploading, it is set to ‘0’ and chName is set to description of
error.
chServingSize
Setting an amount(like an advised amount) (Including units).
chServingPer
Setting an amount per a total amount.
dwValue[20]
Nutrition fact list
Array Explanation

105
dwValue[0] Calories
dwValue[1] Calories from fat
dwValue[2] Total fat
dwValue[3] Saturated fat
dwValue[4] Trans fat
dwValue[5] Cholesterole
dwValue[6] Sodium
dwValue[7] Total carbohydrate
dwValue[8] Dietary fibers
dwValue[9] Sugars
dwValue[10] Protein
dwValue[11] Vitamin a
dwValue[12] Calcium
dwValue[13] Vitamin C
dwValue[14] Iron
dwValue[15] Salt
dwValue[16] Energy
dwValue[17] Added Sugars
dwValue[18] Vitamin D
dwValue[19] Potassium
dwBaseSize

dwServingSize

dwServingUnit

106
1.2.4.18 _stDataTrace
This is a communication configuration form. It is used for exchanging trace data and data
between application and protocol module. Protocol module converts data into that of receivable
to scale. This is combined with _stTransData insteadt of being used independently.

typedef struct _stDataTrace {


WORD wdNo;
char chName[100+1];
WORD wdBornCountry;
WORD wdBredCountry;
WORD wdSlaughtHouse;
WORD wdCuttingHall;
} TD_ST_TRACE;

wdNo
Setting Traceability number.
If error occurs on uploading, it is set to ‘0’ and chName is set to description of
error.
chName
Setting Tracebility name or description.
If error occurs on uploading, it is set to ‘0’ and chName is set to description of
error.
wdBornCountry
Setting Born in country number.
wdBredCountry
Setting Bred in country number.
wdSlaughtHouse
Setting Slaughter in country number.
wdCuttingHall
Setting Cut in country number.

107
1.2.4.19 _stDataCountry
This is a communication configuration form. It is used for exchanging country data and data
between application and protocol module. Protocol module converts data into that of receivable
to scale. This is combined with _stTransData insteadt of being used independently.

typedef struct _stDataCountry {


WORD wdNo;
char chName[100+1];
} TD_ST_COUNTRY;

wdNo
Setting Country number.
If error occurs on uploading, it is set to ‘0’ and chName is set to description of
error.

chName
Setting Country name or description.
If error occurs on uploading, chName is set to description of error.

108
1.2.4.20 _stDataSlaught
This is a communication configuration form. It is used for exchanging slaughter data and data
between application and protocol module. Protocol module converts data into that of receivable
to scale. This is combined with _stTransData insteadt of being used independently.

typedef struct _stDataSlaught {


WORD wdNo;
WORD wdCountry;
char chName[100+1];
} TD_ST_SLAUGHT;

wdNo
Setting Slaughter house number.
If error occurs on uploading, it is set to ‘0’ and chName is set to description of
error.

wdCountry
Setting Country number.

chName
Setting Slaughter house name or description.
If error occurs on uploading, chName is set to description of error.

109
1.2.4.21 _stDataCut
This is a communication configuration form. It is used for exchanging cutting process data and
data between application and protocol module. Protocol module converts data into that of
receivable to scale. This is combined with _stTransData insteadt of being used independently.

typedef struct _stDataCut {


WORD wdNo;
WORD wdCountry;
char chName[100+1];
} TD_ST_CUT;

wdNo
Setting Cut in No.
If error occurs on uploading, it is set to ‘0’ and chName is set to description of
error.
wdCountry
Setting Cut in Country No.

chName
Setting Cut in hall name or description.
If error occurs on uploading, it is set to ‘0’ and chName is set to description of
error.

110
1.2.4.22 _stDataStore
This is a communication configuration form. It is used for exchanging store data and data
between application and protocol module. Protocol module converts data into that of receivable
to scale. This is combined with _stTransData insteadt of being used independently.
This data is for PLU network communication in both LP1 1.6v and CL5000 as well. All of the
unused fields should be se t to “0”
This is for Head & Shop data.

typedef struct _stDataStore{


WORD wdNo;
char chName[100+1];
char chTel[50+1];
char chText[100+1];
} TD_ST_STORE;

wdNo
This is to set the Number of Store in both LP1 1.6v & CL5000
In LP1 1.6v, No 1~2 of btNo means 1st/2nd data of “Header”
In LP1 1.6v, No 3~4 of btNo means 3rd / 4th data of ”Shop”
If error occurs on uploading, it is set to ‘0’ and chName is set to description of
error.
chName
This is to set theh Name of Store in both LP1 1.6v & CL5000
If error occurs on uploading, chName is set to description of error.
chTel
Setting Telephone number.
chText
Setting description.

111
1.2.4.23 _stDataCustom
This is a communication configuration form. It is used for exchanging customer data and data
between application and protocol module. Protocol module converts data into that of receivable
to scale. This is combined with _stTransData insteadt of being used independently.

typedef struct _stDataCustom {


WORD wdNo;
char chName[100+1];
char chTel[50+1];
DWORD dwCreditLimit;
char chAddr1[50+1];
char chAddr2[50+1];
char chAddr3[50+1];
} TD_ST_CUSTOM;

wdNo
Setting Customer number.
If error occurs on uploading, it is set to ‘0’ and chName is set to description of
error.

chName
Setting Customer name.
If error occurs on uploading, chName is set to description of error.

chTel
Setting Telephone number.

dwCreditLimit
Setting Credit Limit.
chAddr1
Setting Address 1.
chAddr2
Setting Address 2.
chAddr3
Setting Address 3.

112
1.2.4.24 _stDataScrollMsg_v03
This is a communication configuration form. It is used for exchanging Scroll Message data and
data between application and protocol module. Protocol module converts data into that of
receivable to scale. This is combined with _stTransData insteadt of being used independently.

typedef struct _stDataScrollMsg_v03 {


WORD wdNo;
BYTE btEffect;
char chName[100+1];
char chMessage[100+1];
BYTE btDaily;
BYTE btWeek;
BYTE btStartDate[3];
BYTE btEndDate[3];
BYTE btStartTime[3];
BYTE btEndTime[3];
BYTE btUse;
BYTE btBlinkCount;
BYTE btFontSize;
BYTE btImageID;
BYTE btSpeed;
} TD_ST_SCROLLMSG_V03;

wdNo
Setting Scroll message number.
If error occurs on uploading, it is set to ‘0’ and chName is set to description of
error.
btEffect
Setting Scroll message effect.
chName
Setting Scroll message name or description.
If error occurs on uploading, chName is set to description of error.
chMessage
Setting Scroll message.
btDaily
Setting Scroll message period.

113
btWeek
Setting Scroll message shown week.
btStartDate[3]
Setting Start date(Year/Month/Day).
btEndDate[3]
Setting End date(Year/Month/Day).
btStartTime[3]
Setting Start time.
btEndTime[3]
Setting End time.
btUse

btBlinkCount

btFontSize

btImageID

btSpeed

114
1.2.4.25 _stDataSecurity
This is a communication configuration form. It is used for exchanging Security data and data
between application and protocol module. Protocol module converts data into that of receivable
to scale. This is combined with _stTransData insteadt of being used independently.

typedef struct _stDataSecurity {


WORD wdNo;
char chName[100+1];
char chNickname[50+1];
char chPassword[50+1];
BYTE btLevel;
} TD_ST_USER;

wdNo
Setting the number of User.
If error occurs on uploading, it is set to ‘0’ and chName is set to description of
error.
chName
Setting User name.
If error occurs on uploading, chName is set to description of error.

chNickname
Setting User nickname.

chPassword
Setting Password.

btLevel
Setting Security level.

115
1.2.4.26 _stAck
This is a communication configuration form. It is used for exchanging transaction result data and
data between application and protocol module. Protocol module converts data into that of
receivable to scale. This configuration form receives information that scale succeessfuly
receiving data from Application program. This sends data and sets data received from Scale.
This is combined with _stTransData insteadt of being used independently.

typedef struct _ stAckInfo {


char chIP [41];
BYTE btDataType;
WORD wdAction;
WORD wdRetryCount;
DWORD dwSendID;
DWORD dwRecvID;
DWORD dwPosition;
} TD_ST_ ACKINFO;

Reference :
Protocol part must setting _stAck. After sending data, immediately receive result and sending
the data to application program. After the completion of the process, the next communication
process can be proceeded.

116
1.2.4.27 _stDataState
Main structure is used when communication state data transmission. This structure is used in
the application program and the protocol module.

typedef struct _stDataState {


WORD wdState;
LPSTR lpDescription;
} TD_ST_STATE;

wdState
State #
#define DF_STATE_CONNECT 1
#define DF_STATE_DISCONNECT 2
#define DF_STATE_CLOSE 3
#define DF_STATE_RECV 4
#define DF_STATE_SEND 5
#define DF_STATE_OUTOFBAND 6
#define DF_STATE_RETRY 7
#define DF_STATE_RETRYOVER 8
lpDescription
State explanation

Reference
typedef int TD_LIB_SENDDATATCPIP(TD_ST_TRANSDATA_V02 tdTransData);

Example

117
1.2.3.28 _stScaleInfo
This is the structure that is used for getting scale state data. This is used between Application
program and Protocol.

typedef struct _stScaleInfo {


WORD wdNo;
char chName[100+1];
BYTE btLoadFlag;
BYTE btStableFlag;
BYTE btTareFlag;
BYTE btDualFlag;
BYTE btWeightUnit;
BYTE btWeightDecimalPoint;
BYTE btPriceDecimalPoint;
BYTE btReserved;
DWORD dwCurTare;
long iCurWeight;
long dwUnitPrice;
DWORD dwTotalPrice;
DWORD dwPLUno;
WORD wdDeptNo;
} TD_ST_SCALEINFO;

wdNo
chName[100+1]
btLoadFlag
0: Zero, 1: Non Zero, 2: Overload
btStableFlag
0: Unstable 1: Stable;
btTareFlag
0: No Tare, 1: Tare, 2: Percent Tare
btDualFlag
2: Dual Range
btWeightUnit
0: kg, 1: lb, 2:g
btWeightDecimalPoint

118
Weight floating position
btPriceDecimalPoint
Price floating position
btReserved

dwCurTare
Current Tare weight
iCurWeight
Current Weight
dwUnitPrice
Unit price
dwTotalPrice
Total price
dwPLUno
PLU number
wdDeptNo
Department number

Reference

Example

119
1.2.4.29 _stScaleVersion
This is the structure that is used for getting scale version.

typedef struct _stScaleVersion {


WORD wdNo;
char chName[100+1];
BYTE btScaleClass;
WORD wdScaleModel;
BYTE wdScaleType;
WORD wdScaleId;
DWORD dwMainVersion;
DWORD dwSubVersion;
WORD wdDataVersion;
WORD wdCountry;
WORD wdReserved;
} TD_ST_SCALEVERSION;

wdNo
chName[100+1]
btScaleClass
DF_SCALE_TYPE_SERVER 0
DF_SCALE_TYPE_LP 100
DF_SCALE_TYPE_RW 200
DF_SCALE_TYPE_NT 300
DF_SCALE_TYPE_POS 400
wdScaleModel
DF_SCALE_15 15
DF_SCALE_16 16
DF_SCALE_16RUS 161
DF_SCALE_17 17
DF_SCALE_20 20
DF_SCALE_CL5000 5000
DF_SCALE_CL5000JR 5010
wdScaleType
DF_SCALE_BENCH 1
DF_SCALE_POLE 2

120
DF_SCALE_HANGING 3
DF_SCALE_SELF 4
wdScaleId
ID of scale
dwMainVersion
Main version of scale
dwSubVersion
Sub version of scale
wdDataVersion
Data version
wdCountry
Country
wdReserved
Reserve

121
2.FileTrans
2.1 Concept

2.1.1 Structure
FileTrans.DLL the added module that provides the interface for the simple function. It is easy to
develop simple PLU transmission in your application program. Because of interface simplicity, it
doesn’t support all functions of the previous DLL. So, it’s just for the simple PLU communication.

Structure
Application (PC Application program)

FileTrans module(FileTrans.DLL)

1st step Manager module(CASPRTC.DLL)

Interface Manager
2nd step Interpreter module(CLInterpreter.DLL….)
Interpreter Manager
3rd step Communication module (CASTCPIP.DLL, ….)
Socket…. Manager

Scale (Scale Model)

Like above, using the previous communication library, it adds the FileTrans module between
Application program and 1st step interface module. Application can do data communication
through FileTrans module.

2.1.2 Interface
Connection(IP, PORT, SCALEID, MODEL)
ConnectionEx(IP, PORT, SCALEID, MODEL, VERSION)
AddPLU(PLUDATA)
AddMSG(MESSAGEDATA)
AddNutrifact (NUTRIFACTDATA)
SendPLU() – Just for Russian version
SendPLUEx() – For United nation(Functionally Same as SendPLU)
SendMSG()

122
SendNutrifact()
RecvPLU() – Just for Russian version
RecvPLUEx() – For United nation(Functionally Same as RecvPLU)
RecvMSG()
RecvNutrifact()
RecvVersion()
RecvPLUData(PLUDATA)
RecvMSGData(MESSAGEDATA)
RecvNutrifactData(NUTRIFACTDATA)
RecvVersionData(VERSIONDATA)
DeletePLU(DEPARTMENTNO,PLUNO)
DeleteMSG(MESSAGENO)
GetScaleInfo()
GetScaleInfoData(IP,INFO);
GetState()
GetLibVersion()
DisconnectAll()
ReadPLU(DepartmentNo,PluNo) – Just for Russian version
ReadPLUEx(DepartmentNo,PluNo) –For United nation(Functionally Same as SendPLU)
ReadMSG(MsgNo)
ReadNutrifact(NutrifactNo)

2.1.3 Data structure


Data structure has two types(one for Russia, and the other for United nation)
2.1.3.1 PLU Data
(1) Russian Structure
Order Name 1.6 ID Type Length C. type Dec
1 Dept no  1 N 4 ASCII 10
2 PLU no  2 N 6 ASCII 10
3 PLU type  4 N 2 ASCII 10
4 Unit weight  5 N 2 ASCII 10
5 Unit price  6 N 10 ASCII 10
6 Group no  9 N 4 ASCII 10
7 Item code  11 N 13 ASCII 10
8 Tare no  12 N 4 ASCII 10
9 Tare  13 N 10 ASCII 10
10 Pieces  14 N 6 ASCII 10
11 Qty unit no  15 N 2 ASCII 10
12 Sell by date  16 N 6 ASCII 10
13 Sell by time  17 N 6 ASCII 10

123
14 Pack date  18 N 6 ASCII 10
15 Pack time  19 N 6 ASCII 10
16 Produce date  20 N 6 ASCII 10
17 Ingredient no  25 N 6 ASCII 10
18 Use fixed price  26 N 2 ASCII 10
19 Traceability no  35 N 6 ASCII 10
20 Origin no  55 N 6 ASCII 10
21 Nutrifact  70 N 4 ASCII 10
22 Label no  80 N 4 ASCII 10
23 Aux label no  81 N 4 ASCII 10
24 Barcode no  85 N 4 ASCII 10
25 Barcode2 no  86 N 4 ASCII 10
26 Sale msg  90 N 4 ASCII 10
27 Special price  91 N 10 ASCII 10
28 Fixed weight  100 N 10 ASCII 10
29 Logo no  N 2 ASCII 10
30 Logo name  S 8 ASCII char
31 Plu name1  10 S 54 ASCII char
32 Plu name2  30 S 54 ASCII char
33 Plu name3  31 S 54 ASCII char
34 Directingredient  S 300 ASCII char

(2) United nation Structure

Order Name 1.6 ID Type Length C. type Dec


1 Dept no  1 N 4 ASCII 10
2 PLU no  2 N 6 ASCII 10
3 PLU type  4 N 2 ASCII 10
4 Unit weight  5 N 2 ASCII 10
5 Unit price  6 N 10 ASCII 10
6 Group no  9 N 4 ASCII 10
7 Item code  11 N 13 ASCII 10
8 Tare no  12 N 4 ASCII 10
9 Tare  13 N 10 ASCII 10
10 Pieces  14 N 6 ASCII 10
11 Qty unit no  15 N 2 ASCII 10
12 Sell by date  16 N 6 ASCII 10
13 Sell by time  17 N 6 ASCII 10
14 Pack date  18 N 6 ASCII 10
15 Pack time  19 N 6 ASCII 10
16 Produce date  20 N 6 ASCII 10
17 Cook date  22 N 6 ASCII 10
18 Tare Limit  23 N 6 ASCII 10
19 Per tare  24 N 6 ASCII 10
20 Ingredient no  25 N 6 ASCII 10
21 Use fixed price  26 N 2 ASCII 10
22 Traceability no  35 N 6 ASCII 10
23 Origin no  55 N 6 ASCII 10
24 Nutrifact  70 N 4 ASCII 10
25 Label no  80 N 4 ASCII 10
26 Aux label no  81 N 4 ASCII 10
27 Barcode no  85 N 4 ASCII 10
28 Barcode2 no  86 N 4 ASCII 10

124
29 Sale msg  90 N 4 ASCII 10
30 Special price  91 N 10 ASCII 10
31 Fixed weight  100 N 10 ASCII 10
32 Tax no  7 N 4 ASCII 10
33 Bonus  50 N 6 ASCII 10
34 Link Plu count  60 N 4 ASCII 10
35 Link Plu dept 1  61 N 4 ASCII 10
36 Link Plu dept 2  62 N 4 ASCII 10
37 Couple plu dept  64 N 4 ASCII 10
38 Ref Plu dept  71 N 4 ASCII 10
39 Link plu no 1  65 N 6 ASCII 10
40 Link plu no 2  62 N 6 ASCII 10
41 Couple plu no  68 N 6 ASCII 10
42 Ref plu no  69 N 6 ASCII 10
43 Picture  36 N 2 ASCII 10
44 Prefix  3 S 2 ASCII char
45 BarcodeEx  49 S 54 ASCII char
46 Plu name1  10 S 54 ASCII char
47 Plu name2  30 S 54 ASCII char
48 Plu name3  31 S 54 ASCII char
49 Directingredinet  S 300 ASCII char

2.1.3.2 MESSAGE DATA


(1) CL5000, CL5000J
Order Name ID Type Length Code type Dec
1 Message No 6 ASCII 10
2 Message Line1 1022 ASCII char

(2) LP1
Order Name ID Type Length Code type Dec
1 Message No 6 ASCII 10
2 Message Line1 54 ASCII char
3 Message Line2 54 ASCII char
4 Message Line3 54 ASCII char
5 Message Line4 54 ASCII char
6 Message Line5 54 ASCII char
7 Message Line6 54 ASCII char
8 Message Line7 54 ASCII char
9 Message Line8 54 ASCII char

2.1.3.3 ScaleInfo
Order Name Type Length C.type Dec
1 Current Dept no N 4 ASCII 10
2 Current PLU no N 6 ASCII 10
3 Tare On N 1
4 Load N 1 0,1,2
5 Stable/Overload N 1 1,2,3,

125
6 Weight N 10 ASCII 10
7 Tare N 10 ASCII 10
8 Unit price / -00002,+00002 N 10 ASCII 10
9 Total price/ -0002,+0002 N 10 ASCII 10
Tare On : 0= no tare, 1=tare, 2=percent tare

2.1.3.4 NUTRIFACT DATA


Order Name Type Length C.type Dec
1 Nutrifact No N 4 ASCII 10
2 Nutrifact type N 2 ASCII 10
3 Base Unit N 4 ASCII 10
4 Serving Size(Num) N 4 ASCII 10
5 Base Size N 4 ASCII 10
6 Calories N 4 ASCII 10
7 Calories From Fat N 4 ASCII 10
8 Total Fat N 4 ASCII 10
9 Saturated Fat N 4 ASCII 10
10 Trans Fat N 4 ASCII 10
11 Cholesterol N 4 ASCII 10
12 Sodium N 4 ASCII 10
13 Total Carbohydrate N 4 ASCII 10
14 Dietary Fibers N 4 ASCII 10
15 Sugars N 4 ASCII 10
16 Protein N 4 ASCII 10
17 Vitamin A N 4 ASCII 10
18 Calcium N 4 ASCII 10
19 Vitamin C N 4 ASCII 10
20 Iron N 4 ASCII 10
21 Description S 19 ASCII char
22 Serving Size(Text) S 19 ASCII char
23 Serving Per Container S 9 ASCII char
Base Unit : 0= g, 1= ml

2.1.3.5 VERSIONDATA
Order Name Type Length C.type Dec
1 Scale Version S 30 ASCII char

2.1.3.6 DISCOUNT DATA


Order Name Type Length C.type Dec
1 Discount No. N 4 ASCII 10
2 Dept No. N 4 ASCII 10
3 PLU No. N 6 ASCII 10
4 PLU type N 2 ASCII 10
5 Discount type N 4 ASCII 10
6 Target 1 N 10 ASCII 10
7 Value 1 N 10 ASCII 10
8 Target 2 N 10 ASCII 10
9 Value 2 N 10 ASCII 10
10 StartDate Year N 4 ASCII 10

126
11 StartDate Month N 2 ASCII 10
12 StartDate Day N 2 ASCII 10
13 EndDate Year N 4 ASCII 10
14 EndDate Month N 2 ASCII 10
15 EndDate Day N 2 ASCII 10
16 StartTime Hour N 2 ASCII 10
17 StartTime Minute N 2 ASCII 10
18 StartTime Second N 2 ASCII 10
19 EndTime Hour N 2 ASCII 10
20 EndTime Minute N 2 ASCII 10
21 EndTime Second N 2 ASCII 10
22 Week N 2 ASCII 10
23 PLU Name S 54 ASCII char

127
2.2 Interface

2.2.1 Interface – FileTrans

2.2.1.1 FileTrans : Connection()

Register the scale that connected to network.


Definition is included in FileTrans.DLL on Russian defined module.

int Connection(IP, PORT, SCALEID, MODEL);

IP
String, IP of the scale registered on network, ex) “192.168.1.1”
PORT
integer, Port Number of the separate scale
If this value is ‘0’, configure automatically to the separate scale.
If MODEL=5000, ‘20304’.
If MODEL=161, ‘8111’.
SCALEID
integer, Scale ID.
If scale is LP-1V1.6RUS, this value should not be ‘0’.
It should be same as SCALEID of the scale.
MODEL
integer
Model=16 , LP-1V1.6 ENGLISH
Model=161 , LP-1V1.6 RUSSIAN
Model=5000, CL5000
Return
integer
0 = Not registered
1 = Registered
2 = Already registered

Reference
DisconnectAll()

128
2.2.1.2 FileTrans : ConnectionEx()

Version of scale is added to Connection()

int ConnectionEx(IP, PORT, SCALEID, MODEL,VERSION);

IP
String, IP of Registered Scale in Network. ex) “192.168.1.1”
PORT
integer, Port Number of each scale
If the value is 0, it is set as MODEL.
IF the MODEL=5000, 20304
MODEL=161 8111
SCALEID
integer, SCALE ID value of scale
It should be match with SCALE ID.
MODEL
integer
Model=16 , LP-1V1.6 ENGLISH
Model=161 , LP-1V1.6 RUSSIA
Model=5000, CL5000
VERSION
String, Scale version
Return
integer
0 = It is not registered
1 = Normal registration
2 = Already registered
Reference
DisconnectAll()

129
2.2.1.3 FileTrans : AddPLU (PLUDATA)

Register PLU for transmission

int AddPLU(PLUDATA)

PLUDATA
String
Make PLU Data according to Table 4.1.

Ex)
- Russia
000100000101010000000001000100000000012340001000000000100000101000001
000001000001000001000001000001010000010000010001000100010001000100010
00000000100000000101 Apple 1

- United nation
000100000101010000000001000100000000012340001000000000100000101000001
000001000001000001000001000001000001000001000001010000010000010001000
100010001000100010000000001000000000100010000010001000100010001000100
00010000010000010000010101 Apple 1

Return
integer
Return the number of registered PLUs.

Reference
SendPLU()

130
2.2.1.4 FileTrans : AddMSG()

Register Message for transmission.

int AddMSG(MESSAGEDATA)

MESSAGEDATA
String
Make Message Data according to Table 4.2.
Ex)
000001MessageAz012345678901234567890123456789012345678901234
Message1 Line2
Return
integer
Return the number of the registered MESSAGE.

Reference
SendMSG()

131
2.2.1.5 FileTrans : AddNutrifact()

Register Nutrifact for transmission.

int AddNutrifact(NUTRIFACTDATA)

NUTRIFACTDATA
String
Make Nutrifact Data
Nutrifact no : 4Byte string  “0001”
Nutrifact Type : 2Byte string  “00”
Base unit : 4Byte string  “0001”
Serving Size : 4Byte string  “0001”
Base Size : 4Byte string  “0001”
Calories : 4Byte string  “0001”
Calories from fat : 4Byte string  “0001”
Total fat(g) : 4Byte string  “0001”
Saturated fat(g) : 4Byte string  “0001”
Trans fat(g) : 4Byte string  “0001”
Cholesterol(mg) : 4Byte string  “0001”
Sodium(mg) : 4Byte string  “0001”
Total Carbohydrates(g) : 4Byte string  “0001”
Dietary fibers(g) : 4Byte string  “0001”
Sugars(g) : 4Byte string  “0001”
Protein(g) : 4Byte string  “0001”
Vitamin A(%) : 4Byte string  “0001”
Calcium(%) : 4Byte string  “0001”
Vitamin C(%) : 4Byte string  “0001”
Iron(%) : 4Byte string  “0001”
Name : 20Byte string  “Nutrifact 1 “
Serving size(text) : “12 “
Serving per con : “1 “

Ex)
“000100000100020003000400050006000700080009001000110012001300140015
001600170018Nutrifact 1 12 1 “

132
Return
integer
Return the number of the registered Nutrifact.

Reference
SendNutrifact()

133
2.2.1.6 FileTrans : AddDiscount()

Register Message for transmission.

int AddMSG(DISCOUNTDATA)

DISCOUNTDATA
String
Make Message Data according to Table 4.7.
Return
integer
Return the number of the registered DISCOUNT.

Reference
SendDiscount()

134
2.2.1.7 FileTrans : SendPLU ()
(Russian defined version)

Send PLU already registered with AddPLU() to all scales.


In the case of United nation defined version, use SendPLUEx().

int SendPLU()

Return
Integer
If it’s not 0, start to send

Reference
AddPLU(),GetState()

135
2.2.1.8 FileTrans : SendMSG ()

Send Message already registered with AddMSG() to all scales.

int SendMSG()

Return
Integer
If it’s not ‘0’, start to send.

Reference
AddMSG(), GetState()

136
2.2.1.9 FileTrans : SendNutrifact ()

Send Nutrifact already registered with AddNutrifact() to all scales.

int SendNutrifact()

Return
Integer
If it’s not ‘0’, start to send.

Reference
AddNutrifact(), GetState()

137
2.2.1.10 FileTrans : SendDiscount ()

Send Discount already registered with AddDiscount() to all scales.

int SendDiscount()

Return
Integer
If it’s not ‘0’, start to send.

Reference
AddDiscount(), GetState()

138
2.2.1.11 FileTrans : RecvPLU ()
(Russian defined version)

Get PLUs from scale to PC.


It’s better to adjust just one connected scale.
PLUs those already had read exist in the internal buffer in DLL.
In the case of United nation defined version, use RecvPLUEx() function.

int RecvPLU()

Return
Integer
If it’s not ‘0’, start to receive.

Reference
RecvPLUData(),GetState()

139
2.2.1.12 FileTrans : RecvMSG ()

Get Messages from scale to PC.


It’s better to adjust just one connected scale.
Messages those already had read exist in the internal buffer in DLL.

int RecvMSG()

Return
Integer
If it’s not 0, start to receive

Reference
RecvMSGData(),GetState()

140
2.2.1.13 FileTrans : RecvNutrifact ()

Get Nutrifact from scale to PC.


It’s better to adjust just one connected scale.
Nutrifact those already had read exist in the internal buffer in DLL.

int RecvNutrifact()

Return
Integer
If it’s not 0, start to receive

Reference
RecvNutrifactData(),GetState()

141
2.2.1.14 FileTrans : RecvDiscount ()

Get Discount from scale to PC.


It’s better to adjust just one connected scale.
Discounts those already had read exist in the internal buffer in DLL.

int RecvDiscount()

Return
Integer
If it’s not 0, start to receive

Reference
RecvDiscountData(),GetState()

142
2.2.1.15 FileTrans : RecvPLUData ()

Read PLU data one by one.

int RecvPLUData(PLUDATA)

PLUDATA
String
PLU Data are returned according to Table 4.1.
Return
If ‘0’, it means the end of data, or it means returning counts

Reference
RecvPLU(), GetState()

143
2.2.1.16 FileTrans : RecvMSGData ()

Read Message data one by one.

int RecvMSGData(MESSAGEDATA)

MESSAGEDATA
String
Message Data are returned according to Table 4.2.
Return
If ‘0’, it means the end of data, or it means returning counts

Reference
RecvMSG (), GetState()

144
2.2.1.17 FileTrans : RecvNutrifactData ()

Read Nutrifact data one by one.

int RecvNutrifactData(NUTRIFACTDATA)

NUTRIFACTDATA
String
<<Nutrifact Data are returned >>

Nutrifact no : 4Byte string  “0001”


Nutrifact Type : 2Byte string  “00”
Base unit : 4Byte string  “0001”
Serving Size : 4Byte string  “0001”
Base Size : 4Byte string  “0001”
Calories : 4Byte string  “0001”
Calories from fat : 4Byte string  “0001”
Total fat(g) : 4Byte string  “0001”
Saturated fat(g) : 4Byte string  “0001”
Trans fat(g) : 4Byte string  “0001”
Cholesterol(mg) : 4Byte string  “0001”
Sodium(mg) : 4Byte string  “0001”
Total Carbohydrates(g) : 4Byte string  “0001”
Dietary fibers(g) : 4Byte string  “0001”
Sugars(g) : 4Byte string  “0001”
Protein(g) : 4Byte string  “0001”
Vitamin A(%) : 4Byte string  “0001”
Calcium(%) : 4Byte string  “0001”
Vitamin C(%) : 4Byte string  “0001”
Iron(%) : 4Byte string  “0001”
Name : 20Byte string  “Nutrifact 1 “
Serving size(text) : “12 “
Serving per con : “1 “

Ex)
“000100000100020003000400050006000700080009001000110012001300140015

145
001600170018Nutrifact 1 12 1 “

Return
If ‘0’, it means the end of data, or it means returning counts

Reference
RecvNutrifact (), GetState()

146
2.2.1.18 FileTrans : RecvDiscountData ()

Read Discount data one by one.

int RecvDiscountData(DISCOUNTDATA)

DISCOUNTDATA
String
Discount data are returned according to Table 4.7.
Return
If ‘0’, it means the end of data, or it means returning counts

Reference
RecvDiscount (), GetState()

147
2.2.1.19 FileTrans : DeletePLU ()

Delete PLU of scale.

int DeletePLU(DEPARTMENTNO,PLUNO)

DEPARTMENTNO
integer
PLUNO
integer
Return
If it’s not ‘0’, start to delete.

Reference
GetState()

148
2.2.1.20 FileTrans : DeletePLUAll ()

Delete all PLU of scale.

int DeletePLUAll(DEPARTMENTNO,PLUNO)

DEPARTMENTNO
integer , 1
PLUNO
Integer ,1
Return
If it’s not ‘0’, start to delete.

Reference
GetState()

149
2.2.1.21 FileTrans : DeleteMSG ()

Delete Message of scale.

int DeleteMSG(MESSAGENO)

MESSAGENO
Integer
Return
If it’s not ‘0’, start to delete.

Reference
GetState()

150
2.2.1.22 FileTrans : DeleteNutrifact ()

Delete Nutrifact of scale.

int DeleteNutrifact(NUTRIFACTNO)

NUTRIFACTNO
Integer
Return
If it’s not ‘0’, start to delete.

Reference
GetState()

151
2.2.1.23 FileTrans : DeleteDiscount ()

Delete Discount of scale.

int DeleteDiscount(DISCOUNTNO)

DISCOUNTNO
Integer
Return
If it’s not ‘0’, start to delete.

Reference
GetState()

152
2.2.1.24 FileTrans : GetScaleInfo ()

Read the state information of the connected scale.


Read data were separated by IP and saved in the internal buffer of DLL.
Saved data must be read through GetScaleInfoData().

int GetScaleInfo()

Return
If it’s not ‘0’, read the state of the separate scale.

Reference
GetScaleInfoData()

153
2.2.1.24 FileTrans : GetScaleInfoData ()

Return the state information ,read through GetScaleInfo(), with String value.

int GetScaleInfoData(IP,INFO);

IP
String
IP of the scale that the state data will be got from.
On of IP addresses those already had registered through Connection().
INFO
String
Message Data are returned according to Table 4.3.

Return
integer
1: The value was returned.
99: It can’t find IP.

Reference
GetScaleInfo ()

154
2.2.1.25 FileTrans : GetState ()

Return the state of transferance.

int GetState()

Return
integer
0 disconnect + not start
1 connecting
11 reconnect
20 disconnection
30 send data
40 receive date
50 scale close
51 1:Success
52 2:Connect fail
53 3:Retry fail
54 4:Data error
55 5:Timeout
60 Send fail
70 -
80 send timeout
99 disconnect all

Reference
SendPLU(), SendMSG(), RecvPLU(), RecvMSG(), GetScaleInfo(),
DeletePLU(), DeleteMSG(),

155
2.2.1.26 FileTrans : GetLibVersion ()

It gets the verstion of DLL.

int GetLibVersion()

Return
integer
Version Number = 100

Reference
NONE

156
2.2.1.27 FileTrans : DisconnectAll ()

Close all connection of all scales.

int DisconnectAll ()

Return
integer , No meaning

Reference
Connection()

157
2.2.1.28 FileTrans : ReadPLU ()
(Russian defined version)

Call defined PLU.


In the case of United nation, use ReadPLUEx() behalf of that.

int ReadPLU(DepartmentNo,Pluno)

DepartmentNo
integer
PluNo
Integer
Return
Integer
No meaning.

Reference
Connection()

158
2.2.1.29 FileTrans : ReadMSG ()

Call defined Message.

int ReadMSG(MsgNo)

MsgNo
Integer
Return
integer
No meaning

Reference
Connection()

159
2.2.1.30 FileTrans : RecvVersion ()

Get Version Info. from scale to PC.


int RecvVersion()

Return
If it’s not ‘0’, start to receive

Reference
RecvVersionData(),GetState()

160
2.2.1.31 FileTrans : RecvVersionData ()

Read Version data one by one

int RecvVersionData(VERSIONDATA)

VERSIONDATA
String
Version Data is returned according to table of 4.6
Return
Meaningless

Reference
RecvVersion (), GetState()

161
Appendix 1 – The available data by scale models
1. The available data by scale models
Menu CL5000 CL5000JR LP17
PLU O O O
Discount O X X
Department O X X
Group O X O
Tax rate O X X
Sales message O O X
Table1
Orgin O O O
Barcode O O X
Tare O X X
PCS unit O O O
Ingredient O O O
NutriFact O X X
Traceability O X X
Table2
Country O X X
Slaughterhouse O X X
Cutting hall O X X
Store data O O O
Customer O X X
Store
Scroll message O O X
User/Security O X X
Scale O X X
PLU O O X
Group O O X
Deparment O O X
Report
Hourly O O X
Clerk O X X
Tax O X X
Total X O X
Label X X X

162
Label caption X X O
Keypad X X X
Version O O O

2. The available PLU items by scale models


번호 항목 CL5000 CL5000JR LP17
1 Department No. O O X
2 PLU No. O O O
3 PLU Type O O O
4 Name O O O
5 Name2 O O O
6 Name3 O O X
12 Group No. O O O
13 Ext. Barcode O X X
14 Label No. O O O
15 Aux. Label No. O O X
16 Origin No. O O O
17 Unit Weight O O X
18 FixedWeight O O X
19 Prefix O X X
20 ItemCode O O O
21 Pieces O O O
22 Qty Unit No. O O O
23 Use Fixed Price Type O O X
24 Price O O O
25 SpecialPrice O O X
26 TAX No. O X X
27 Tare O O O
28 Tare No. O O X
29 %Tare O X X
30 Tare % limit O X X
31 Barcode No. O O O
32 Barcode No2 O O X
33 ProducedDate O X O
34 Packed Date O O X

163
35 Packed Time O O O
36 Sell By Date O O O
37 Sell By Time O O O
38 CookByDate O X X
39 Ingredient No. O O O
40 Traceability No. O O X
41 Bonus O X X
42 NutriFact No. O O X
43 LabelMsg No. O O X
44 Reference Dept O X X
45 Reference PLU O X X
46 Coupled Dept O X X
47 Coupled PLU O X X
48 # of LinkPLU O X X
49 Link Dept1 O X X
50 Link PLU1 O X X
51 Link Dept2 O X X
52 Direct Ingredient O O X
53 Check Sell by date X X O

164
Appendix 2 -Tutorial
1. Start

Simple explanation for the usage of communication module.


Tool tip before the usage of that in Application program.

Library structure on folder is like below.


(1) Bin
(2) Include
(3) Library
Dynamic link library files for communication with scale are located Bin folder.
You need those files for the usual communication procedure.
Those file should be located on Application folder or Windows\System folder.
Before distribute Application program, be careful of those.

Interface definition file is located on Include folder for usage of Dll.


CASPRTC.H file and CASPRTC.PAS file are those.
If you are the developer of C/C++, refer to CASPRTC.H. Else if you are the developer of Delphi,
refer to CASPRTC.PAS.

At last Library folder has CASPRTC.LIB file.


C/C++ developer use that file to use an implicit connection.

You can refer to example of program source.


- If you are a VC++ 6.0 developer, refer to Visual C++ folder on Tutorial foler.
- If you are a Delphi developer, refer to Delphi folder on Tutorial foler.

165
2. Visual C++ Tutorial

Method to use CASPRTC.DLL


All communication DLL files should be located on the same folder. Also those are located on
the folder where Application program is located or Windows folder or Windows\System.

Method to upload PLU from CL5000 scale


(1) Create Dialog base project with the program named CommApplication.

(2) Execute Project / Project settings menu, click Object / Library module on the Link Tab
same as CASPRTC.LIB like the picture below.

166
(3) Declare #include header file name on the header file of CommApplication Dialog same
as CASPRTC.H like the picture below.

(4) Select Project / Add To Project / Files… menu, and add CASPRTC.H.
(5) It finished to ready for Application programming.
(6) Add 3 Edit Box, 1 List Box, and 3 Button Box on Dialog resource. Change Text of
Button controls to “Connect”, “Upload”, and Disconnect” separately. Deactivate Sort
function on List Box.

167
(7) Declare Control member variable on List box and declare that member variable on
Upload id.
ex>
CListBox m_lstState;
int m_iSendID;

(8) Add member function in the source file of CommApplication Dialog(.CPP).

168
ex>
int CCommApplicationDlg::CheckEnd(int iDataType, int iNo, CString csRecv)

int iRtn = 0;

int iPosition = 0;

CString csTemp;

if (!iNo)

iPosition = csRecv.Find(":", 0)+2;

csTemp = csRecv.Mid(iPosition, 2);

if (atoi(csTemp) == 99 || // data end

atoi(csTemp) == 95) // data empty

iRtn = 0;

else if (atoi(csTemp) == 98 || // data is not use(is empty)

atoi(csTemp) == 97 || // recv error-data

atoi(csTemp) == 84 || // data recv error

atoi(csTemp) == 82) // data rage error

iRtn = 2;

else

iRtn = 1;

else

iRtn = 1;

return iRtn;

(9) Declare CommApplication variable in source file of CommApplication (.CPP) as a


global variable.
ex >
CCommApplicationDlg *g_dlgMain;

169
(10)Definite the function that receive data on CommApplication Dialog source file (.CPP) as
a global function.
ex>
int gProcRecv(TD_ST_TRANSDATA_V02 tdData)

char chBuffer[1024];

CString csIP;

CString csRecv;

TD_ST_PLU_V02 tdPLU;

TD_ST_TRANSDATA_V02 tdSendData;

memset(chBuffer, 0x0, 1024);

if (tdData.wdAction == DF_ACTION_UPLOAD)

if (tdData.btDataType == DF_DATA_PLU)

switch (g_dlgMain->CheckEnd(tdData.btDataType,

((TD_ST_PLU_V02*)tdData.pData)->dwPLU,

((TD_ST_PLU_V02*)tdData.pData)->chName1))

case 0: // Upload End E99, E98

170
g_dlgMain->m_lstState.AddString("Upload End");

break;

case 1: // Upload Continue

case 2:

csRecv.Format("%d, %s",

((TD_ST_PLU_V02*)tdData.pData)->dwPLU,

((TD_ST_PLU_V02*)tdData.pData)->chName1);

g_dlgMain->m_lstState.AddString(csRecv);

memset(&tdPLU, 0x0, sizeof(tdPLU));

tdPLU.dwPLU = g_dlgMain->m_iSendID + 1;

tdPLU.btDepart = 1;

g_dlgMain->m_iSendID = tdPLU.dwPLU;

g_dlgMain->GetDlgItemText(IDC_EDIT1, csIP);

tdSendData.shScaleID = -1;

tdSendData.lpIP = csIP.GetBuffer(csIP.GetLength());

tdSendData.btCommType = tdData.btCommType;

tdSendData.btSendType = tdData.btSendType;

tdSendData.btDataType = tdData.btDataType;

tdSendData.wdScaleType = tdData.wdScaleType;

tdSendData.wdScaleModel = tdData.wdScaleModel;

tdSendData.wdAction = tdData.wdAction;

tdSendData.wdDataSize = sizeof(tdPLU);

tdSendData.pData = &tdPLU;

SendData(tdSendData);

break;

return TRUE;

(11)Definite the function that receive state data on CommApplication Dialog source file
(.CPP) as a global function.
ex>

171
int gProcState(TD_ST_TRANSDATA_V02 tdData)

TD_ST_STATE *tdState;

CString csMsg;

CString csRecv;

tdState = (TD_ST_STATE*)tdData.pData;

csRecv.Format("%s", tdState->lpDescription);

csMsg = "- [STATE] ";

csMsg += csRecv;

g_dlgMain->m_lstState.AddString(csMsg);

return 0;

(12)Modify OnInitialDialog function.


// TODO: Add extra initialization here

g_dlgMain = this;

SetDlgItemText(IDC_EDIT1, “10.10.3.33”);

SetDlgItemText(IDC_EDIT2, “20304”);

SetDlgItemText(IDC_EDIT3, “3000”);

SetCommLibrary(DF_MODULE_TCPIP, DF_NAME_LIBTCPIP);

AddInterpreter(DF_SCALE_TYPE_LP, DF_SCALE_CL5000, "CLInterpreter.dll");

(13)Add the clicking event function of Button1.


ex>
void CCommApplicationDlg::OnButton1()

// TODO: Add your control notification handler code here

CString csIP;

CString csPort;

CString csTimeout;

GetDlgItemText(IDC_EDIT1, csIP);

GetDlgItemText(IDC_EDIT2, csPort);

GetDlgItemText(IDC_EDIT3, csTimeout);

if (AddProcConnection(DF_COMMTYPE_TCPIP,

172
csIP.GetBuffer(csIP.GetLength()),

atoi(csPort),

DF_SCALE_TYPE_LP,

DF_SCALE_CL5000,

atoi(csTimeout),

3,

DF_DATA_PLU,

gProcRecv,

gProcState))

m_lstState.AddString("- AddProcConnection : TRUE");

if (Connect(csIP.GetBuffer(csIP.GetLength()), -1))

m_lstState.AddString ("- Connect : TRUE");

else

m_lstState.AddString ("- Connect : FALSE");

else

m_lstState.AddString ("- AddProcConnection : FALSE");

(14)Add the clicking event function of Button2.


ex>
void CCommApplicationDlg::OnButton2()

// TODO: Add your control notification handler code here

CString csIP;

TD_ST_PLU_V02 tdPLU;

TD_ST_TRANSDATA_V02 tdData;

GetDlgItemText(IDC_EDIT1, csIP);

memset(&tdData, 0x0, sizeof(tdData));

tdData.btCommType = DF_COMMTYPE_TCPIP;

tdData.btSendType = DF_SENDTYPE_NORMAL;

tdData.lpIP = csIP.GetBuffer(csIP.GetLength());

tdData.shScaleID = -1;

tdData.wdAction = DF_ACTION_UPLOAD;

173
tdData.wdScaleType = DF_SCALE_TYPE_LP;

tdData.wdScaleModel = DF_SCALE_CL5000;

memset(&tdPLU, 0x0, sizeof(tdPLU));

tdPLU.btDepart = 1;

m_iSendID = tdPLU.dwPLU = 1;

tdData.btDataType = DF_DATA_PLU_V02;

tdData.wdDataSize = sizeof(tdPLU);

tdData.pData = &tdPLU;

if (!SendData(tdData))

m_lstState.AddString("-SendData() fail");

(15)Add the clicking event function of Button3.


ex>
void CCommApplicationDlg::OnButton3()

// TODO: Add your control notification handler code here

CString csIP;

GetDlgItemText(IDC_EDIT1, csIP);

if (Disconnect(csIP.GetBuffer(csIP.GetLength()), -1))

m_lstState.AddString("- Disconnect : TRUE");

DeleteConnection("ALL", -1);

else

m_lstState.AddString ("- Disconnect : FALSE");

(16)Compile and execute that dialog based program.

174
175
3. Delphi Tutorial

DLL Interface declaration for Delphi


Refer to source file on Sample folder and CASPRTC.PAS file.
Sample source is developed with Delphi.

Interface declaration

unit CASPRTC;

interface
uses
Windows, Messages;

{$IFNDEF __CASPRTC_H}
{$DEFINE __CASPRTC_H}
{/// Dump of file casprtc.dll }

const
WM_RECEIVEDATA = WM_USER + 1; { CAS Interpreter On Receive Message }
WM_NETWORKSTATUS = WM_USER + 2; { CAS Interpreter Status Check Message }

DF_SCALE_ETC = 0;

DF_SCALE_TYPE_LP = 100;
DF_SCALE_TYPE_RW = 200;
DF_SCALE_TYPE_NT = 300;
DF_SCALE_TYPE_POS = 400;

DF_SCALE_15 = 15;
DF_SCALE_16 = 16;
DF_SCALE_17 = 17;
DF_SCALE_20 = 20;
DF_SCALE_CL5000 = 5000;

DF_COMM_READ = 10;

176
DF_COMM_WRITE = 20;
DF_COMM_RECV = 30;
DF_COMM_ACK = 40;

DF_DATA_LOWDATA = 1; {// it's not interpret}


DF_DATA_THIS = 3; {// not define}
DF_DATA_STATE = 4; {// socket state data}
DF_DATA_TEST = 5; {// test data}
DF_DATA_COMMAND = 6; {// command data}

DF_STATE_CONNECT = 1;
DF_STATE_DISCONNECT = 2;
DF_STATE_CLOSE = 3;
DF_STATE_RECV = 4;
DF_STATE_SEND = 5;
DF_STATE_OUTOFBAND = 6;
DF_STATE_RETRY = 7;
DF_STATE_RETRYOVER = 8;

DF_COMMTYPE_ANY = 0; {// just use senddata}


DF_COMMTYPE_TCPIP = 1;
DF_COMMTYPE_UDP = 2;
DF_COMMTYPE_SERIAL = 3;
DF_COMMTYPE_USB = 4;

DF_SENDTYPE_NORMAL = 1;
DF_SENDTYPE_BROADCAST = 2;

DF_NOTIMEOUT = 0;
DF_RETRY_REPEAT = 0;
DF_LOG_NO = 0;
DF_LOG_WRITE = 1;

DF_TRANSTYPE_PROC = 0;
DF_TRANSTYPE_MSG = 1;
DF_TRANSTYPE_INDV = 8;

177
DF_MODULE_TCPIP = 1;
DF_MODULE_SERIAL = 2;
DF_MODULE_PROTOCOL = 3;
DF_MODULE_SOCKET = 4;
DF_MODULE_INTERPRETER = 5;
DF_MODULE_USB = 6;

DF_CMDTYPE_COMM = 1;
DF_CMDTYPE_LOCAL = 2;
DF_CMDTYPE_LIB = 3;

DF_ACTION_NOTHING = 0; {// Just trans of data it's not need interpret}


DF_ACTION_GETINFO = 1;
DF_ACTION_UPLOAD = 2;
DF_ACTION_DOWNLOAD = 3;
DF_ACTION_DELETE = 4;
DF_ACTION_DELETEALL = 5;
DF_ACTION_READ = 6;
DF_ACTION_WRITE = 7;
DF_ACTION_INITSCALE = 8;
DF_ACTION_RESET = 9;
DF_ACTION_SET = 10;
DF_ACTION_NORMAL = 11;
DF_ACTION_SEND = 12;

DF_INIT_SOCKET = 1;
DF_INIT_SERIAL = 2;
DF_INIT_LIBCOMM = 3;
DF_INIT_INTERPRETER = 4;
DF_INIT_LIBPROTOCOL = 5;
DF_INIT_ALL = 6;

DF_SIZE_RECVBUFFER = 8192+1;
DF_SIZE_IPBUFFER = 25;
DF_SIZE_LOGPATHBUFFER = 512;

178
DF_NOTHING = 0;
DF_BEGIN = 1;
DF_END = 2;

DF_NAME_LIBTCPIP = 'CASTCPIP.DLL';
DF_NAME_LIBSERIAL = 'CASSERIA.DLL';
DF_NAME_LIBPROTOCOL = 'CASPRTC.DLL';
DF_NAME_LIBUSB = 'CASUSB.DLL';

DF_DATA_PLU_V02 = 9;
DF_DATA_PLU_V06 = 98;
DF_DATA_PLU = 10;
DF_DATA_DISC = 11;
DF_DATA_DEPT = 12;
DF_DATA_GROUP = 13;
DF_DATA_TAXRATE = 14;
DF_DATA_SALEMSG = 15;
DF_DATA_ORIGIN = 16;
DF_DATA_BARCODE = 17;
DF_DATA_TARE = 18;
DF_DATA_PCSUNIT = 19;
DF_DATA_INGREDIENT = 20;
DF_DATA_NUTRIFACT = 21;
DF_DATA_TRACE = 22;
DF_DATA_COUNTRY = 23;
DF_DATA_SLAUGHT = 24;
DF_DATA_CUT = 25;
DF_DATA_STORE = 26;
DF_DATA_CUSTOM = 27;
DF_DATA_SCROLLMSG = 28;
DF_DATA_SECURITY = 29;
DF_DATA_REPORT = 30;
DF_DATA_LABEL = 31;
DF_DATA_IMAGE = 32;
DF_DATA_KEY = 33;

179
DF_DATA_PLUINFO = 34;
DF_DATA_SCALECMD = 35;

DF_LABEL_BEGIN = 1;
DF_LABEL_HEADER = 2;
DF_LABEL_DATA = 3;
DF_LABEL_END = 4;

DF_IMAGE_BEGIN = 5;
DF_IMAGE_HEADER = 6;
DF_IMAGE_DATA = 7;
DF_IMAGE_END = 8;

FLASH_PLU_STATUS_SIZE = 50;
FLASH_PLU_STATUS = 544;
EEP_ALL_SIZE = 3153;
MESSAGE_ADDRESS = 12961;
EEP_PLU_PRTCAP = 2545;
EEP_PLU_PRTCAP_SIZE = 20;
EEP_HEADER_DATA = 193;
EEP_SHOP_DATA = 322;

type
_stTransData = record
shScaleID: SmallInt;
lpIP: PChar;
btCommType: BYTE;
btSendType: BYTE;
btDataType: BYTE;
wdScaleType: Word;
wdScaleModel: Word;
wdAction: Word;
wdDataSize: Word;
pData: Pointer;
end {_stTransData};
TTransData = _stTransData;

180
PTTransData = ^_stTransData;

_stTransDataV02 = record
shScaleID: SmallInt;
lpIP: PChar;
btCommType: BYTE;
btSendType: BYTE;
btDataType: BYTE;
wdScaleType: Word;
wdScaleModel: Word;
wdAction: Word;
wdDataSize: Word;
pData: Pointer;
dwScaleMainVersion: DWord;
dwScaleSubVersion: DWord;
dwScaleCountry: DWord;
dwScaleDataVersion: DWord;
dwReserveVersion: DWord;
pReserve: Pointer;
end {_stTransDataV02};
TTransDataV02 = _stTransDataV02;
PTTransDataV02 = ^_stTransDataV02;

_stTransDataEx = record
shScaleID: SmallInt;
chIP: Array[0..40]of Char;
btCommType: BYTE;
btSendType: BYTE;
btDataType: BYTE;
wdScaleType: Word;
wdScaleModel: Word;
wdAction: Word;
wdDataSize: Word;
chData: Array[0..DF_SIZE_RECVBUFFER] of Char;
end {_stTransDataEx};
TTransDataEx = _stTransDataEx;

181
PTTransDataEx = ^_stTransDataEx;

_stDataThisModule = record
btModule: BYTE;
btCommand: BYTE;
btMainVer: BYTE;
btSubVer: BYTE;
btModifyYear: BYTE;
btModifyMonth: BYTE;
btModifyDay: BYTE;
end {_stDataThisModule};
TVersion = _stDataThisModule;
PTVersion = ^_stDataThisModule;

_RecvProc = function(TransData: PTTransData): Integer; cdecl;


PRecvProc = ^_RecvProc;
_StateProc = function(TransData: PTTransData): Integer; cdecl;
PStateProc = ^_StateProc;

_stSocketInfo = record
shScaleID: SmallInt;
lpIP: PChar;
wdPort: Word;
wdScaleType: Word;
wdScaleModel: Word;
wdTimeOut: Word;
wdRetryCount: Word;
btCommType: BYTE;
btTransType: BYTE;
btSocketType: BYTE;
btDataType: BYTE;
dwMsgNo: LongInt;
dwStateMsgNo: LongInt;
btLogStatus: BYTE;
lpLogFileName: PChar;
pRecvProc: PRecvProc;

182
pStateProc: PStateProc;
end {_stSocketInfo};
TSocketInfo = _stSocketInfo;
TConectionInfo = _stSocketInfo;
PTSocketInfo = ^_stSocketInfo;
PTConnectionInfo = ^_stSocketInfo;

_stDataPluInfoTable = record
end {_stDataPluInfoTable};
TDataPLUInfoTable = _stDataPluInfoTable;
PTDataPLUInfoTable = ^_stDataPluInfoTable;

_stDataScaleCommand = record
btCmdType: BYTE;
btDataType: BYTE;
btMain: BYTE;
btSub: BYTE;
btModule: BYTE;
btParam: BYTE;
wdParam: Word;
dwParam: LongInt;
pParam: Pointer;
end {_stDataScaleCommand};
TDataScaleCommand = _stDataScaleCommand;
PTDataScaleCommand = ^_stDataScaleCommand;

_stDataState = record
wdState: Word;
lpDescription: PChar;
end {_stDataState};
TDataState = _stDataState;
PTDataState = ^_stDataState;

_stAckInfo = record
btIP: Array[0..19] of BYTE;
btDataType: BYTE;

183
wdAction: Word;
wdRetryCount: Word;
dwSendCount: DWord;
dwSendID: DWord;
dwRecvID: DWord;
dwPosition: DWord; // Reserve
end {TD_ST_ACKINFO;};
TAckInfo = _stAckInfo;
PTAckInfo = ^_stAckInfo;

_imageinfo = record
addr: LongInt;
size: LongInt;
id: Word;
width: Word;
height: Word;
end {_imageinfo};
TImageInfo = _imageinfo;
PTImageInfo = ^_imageinfo;

_lblheader = record
format: Array[0..6-1] of Char;
version: Array[0..2-1] of Char;
company: Array[0..10-1] of Char;
model: Array[0..4-1] of Char;
usage: Array[0..4-1] of Char;
id: Word;
width: Word;
height: Word;
name: Array[0..16-1] of BYTE;
size_label: LongInt;
item_addr: LongInt;
item_count: Word;
stImageIf: Array[0..5-1] of TImageInfo;
end {_lblheader};
TLabelHeader = _lblheader;

184
PTLabelHeader = ^_lblheader;

_stDataPLU = packed record


wdDepart: Word;
dwPLU: LongInt;
btPLUType: BYTE;
chName1: Array[0..100] of Char;
chName2: Array[0..100] of Char;
chName3: Array[0..100] of Char;
wdGroup: Word;
chBarcodeEx: Array[0..100] of Char;
wdLabel1: Word;
wdLabel2: Word;
wdOrigin: Word;
btWeightUnit: BYTE;
dwFixWeight: LongInt;
chPrefix: Array[0..10] of Char;
dwItemCode: LongInt;
wdPieces: Word;
btQuatSymbol: BYTE;
btPriceType: BYTE;
dwUnitPrice: LongInt;
dwSpecialPrice: LongInt;
wdTaxNo: Word;
dwTare: LongInt;
wdTareNo: Word;
dwPerTare: LongInt;
dwTareLimit: LongInt;
wdBarcode1: Word;
wdBarcode2: Word;
wdPicture: Word;
wdProduceDate: Word;
wdPackDate: Word;
wdPackTime: Word;
dwSellDate: LongInt;
wdSellTime: Word;

185
wdCookDate: Word;
wdIngredient: Word;
wdTraceability: Word;
wdBonus: Word;
wdNutrifact: Word;
wdSaleMSG: Word;
wdRefPLUDept: Word;
dwRefPLUNo: LongInt;
wdCouplePLUDept: Word;
dwCouplePLUNo: LongInt;
wdLinkPLUCount: Word;
wdLinkPLUDept1: Word;
dwLinkPLUNo1: LongInt;
wdLinkPLUDept2: Word;
dwLinkPLUNo2: LongInt;
btTotalFlag: BYTE;
dwTotalCount: LongInt;
dwTotalPrice: LongInt;
dwTotalWeight: LongInt;
chReserve1: Array[0..50] of Char;
chReserve2: Array[0..50] of Char;
chReserve3: Array[0..50] of Char;
end {_stDataPLU};
TDataPLU = _stDataPLU;
PTDataPLU = ^_stDataPLU;

_stDataPLUV02 = packed record


wdDepart: Word;
dwPLU: LongInt;
btPLUType: BYTE;
chName1: Array[0..100] of Char;
chName2: Array[0..100] of Char;
chName3: Array[0..100] of Char;
wdGroup: Word;
chBarcodeEx: Array[0..100] of Char;
wdLabel1: Word;

186
wdLabel2: Word;
wdOrigin: Word;
btWeightUnit: BYTE;
dwFixWeight: LongInt;
chPrefix: Array[0..10] of Char;
dwItemCode: LongInt;
wdPieces: Word;
btQuatSymbol: BYTE;
btPriceType: BYTE;
dwUnitPrice: LongInt;
dwSpecialPrice: LongInt;
wdTaxNo: Word;
dwTare: LongInt;
wdTareNo: Word;
dwPerTare: LongInt;
dwTareLimit: LongInt;
wdBarcode1: Word;
wdBarcode2: Word;
wdPicture: Word;
wdProduceDate: Word;
wdPackDate: Word;
wdPackTime: Word;
dwSellDate: LongInt;
wdSellTime: Word;
wdCookDate: Word;
wdIngredient: Word;
wdTraceability: Word;
wdBonus: Word;
wdNutrifact: Word;
wdSaleMSG: Word;
wdRefPLUDept: Word;
dwRefPLUNo: LongInt;
wdCouplePLUDept: Word;
dwCouplePLUNo: LongInt;
wdLinkPLUCount: Word;
wdLinkPLUDept1: Word;

187
dwLinkPLUNo1: LongInt;
wdLinkPLUDept2: Word;
dwLinkPLUNo2: LongInt;
btTotalFlag: BYTE;
dwTotalCount: LongInt;
dwTotalPrice: LongInt;
dwTotalWeight: LongInt;
chReserve1: Array[0..50] of Char;
chReserve2: Array[0..50] of Char;
chReserve3: Array[0..50] of Char;
wdNo: Word;
wdDirectSize: Word;
chDirectIngredient: Array[0..1024] of Char;
end {_stDataPLUV02};
TDataPLUV02 = _stDataPLUV02;
PTDataPLUV02 = ^_stDataPLUV02;

_stDataDisc = packed record


wdNo: Word;
wdDeptNo: Word;
dwPLUNo: LongInt;
chName: Array[0..100] of Char;
btPLUType: BYTE;
wdDiscType: Word;
wdTarget1: Word;
dwValue1: LongInt;
wdTarget2: Word;
dwValue2: LongInt;
btStartDate: Array[0..3-1] of BYTE;
btEndDate: Array[0..3-1] of BYTE;
btStartTime: Array[0..3-1] of BYTE;
btEndTime: Array[0..3-1] of BYTE;
btWeek: BYTE;
end {_stDataDisc};
TDataDisc = _stDataDisc;
PTDataDisc = ^_stDataDisc;

188
_stDataDept = packed record
wdNo: Word;
wdSpeedKey: Word;
chName: Array[0..100] of Char;
end {_stDataDept};
TDataDepartment = _stDataDept;
PTDataDepartment = ^_stDataDept;

_stDataGroup = packed record


wdNo: Word;
chName: Array[0..100] of Char;
end {_stDataGroup};
TDataGroup = _stDataGroup;
PTDataGroup = ^_stDataGroup;

_stDataTaxRate = packed record


wdNo: BYTE;
btType: BYTE;
chName: Array[0..100] of Char;
wdValue: Word;
end {_stDataTaxRate};
TDataTaxrate = _stDataTaxRate;
PTDataTaxrate = ^_stDataTaxRate;

_stDataSaleMsg = packed record


wdNo: Word;
chName: Array[0..100] of Char;
end {_stDataSaleMsg};
TDataSaleMsg = _stDataSaleMsg;
PTDataSaleMsg = ^_stDataSaleMsg;

_stDataOrigin = packed record


wdNo: Word;
chName: Array[0..100] of Char;
end {_stDataOrigin};

189
TDataOrigin = _stDataOrigin;
PTDataOrigin = ^_stDataOrigin;

_stDataBarcode = packed record


wdNo: Word;
btType: BYTE;
btFormatNo: BYTE;
chFormat: Array[0..50-1] of Char;
chName: Array[0..100-1] of Char;
end {_stDataBarcode};
TDataBarcode = _stDataBarcode;
PTDataBarcode = ^_stDataBarcode;

_stDataTare = packed record


wdNo: Word;
btType: BYTE;
wdValue: Word;
chName: Array[0..100] of Char;
end {_stDataTare};
TDataTare = _stDataTare;
PTDataTare = ^_stDataTare;

_stDataPcsUnit = packed record


wdNo: Word;
chName: Array[0..100] of Char;
end {_stDataPcsUnit};
TDatePCSUnit = _stDataPcsUnit;
PTDatePCSUnit = ^_stDataPcsUnit;

_stDataIngredient = packed record


wdNo: Word;
chName: Array[0..1024] of Char;
end {_stDataIngredient};
TDataIngredient = _stDataIngredient;
PTDataIngredient = ^_stDataIngredient;

190
_stDataNutrifact = packed record
wdNo: Word;
btType: BYTE;
chName: Array[0..100] of Char;
chServingSize: Array[0..50] of Char;
chServingPer: Array[0..50] of Char;
btaValue: Array[0..20] of BYTE;
end {_stDataNutrifact};
TDataNutrifact = _stDataNutrifact;
PTDataNutrifact = ^_stDataNutrifact;

_stDataTrace = packed record


wdNo: Word;
chName: Array[0..100] of Char;
wdBornCountry: Word;
wdBredCountry: Word;
wdSlaughtHouse: Word;
wdCuttingHall: Word;
end {_stDataTrace};
TDataTrace = _stDataTrace;
PTDataTrace = ^_stDataTrace;

_stDataCountry = packed record


wdNo: Word;
chName: Array[0..100] of Char;
end {_stDataCountry};
TDataCountry = _stDataCountry;
PTDataCountry = ^_stDataCountry;

_stDataSlaught = packed record


wdNo: Word;
wdCountry: Word;
chName: Array[0..100] of Char;
end {_stDataSlaught};
TDataSlaughter = _stDataSlaught;
PTDataSlaughter = ^_stDataSlaught;

191
_stDataCut = packed record
wdNo: Word;
wdCountry: Word;
chName: Array[0..100] of Char;
end {_stDataCut};
TDataCut = _stDataCut;
PTDataCut = ^_stDataCut;

_stDataStore = packed record


wdNo: Word;
chName: Array[0..100] of Char;
chTel: Array[0..50] of Char;
chText: Array[0..100] of Char;
end {_stDataStore};
TDataStore = _stDataStore;
PTDataStore = ^_stDataStore;

_stDataCustom = packed record


wdNo: Word;
chName: Array[0..100] of Char;
chTel: Array[0..50] of Char;
dwCreditLimit: LongInt;
chAddr1: Array[0..50] of Char;
chAddr2: Array[0..50] of Char;
chAddr3: Array[0..50] of Char;
end {_stDataCustom};
TDataCustom = _stDataCustom;
PTDataCustom = ^_stDataCustom;

_stDataScrollMsg = packed record


wdNo: Word;
btEffect: BYTE;
chName: Array[0..100] of Char;
chMessage: Array[0..100] of Char;
btDaily: BYTE;

192
btWeek: BYTE;
btStartDate: Array[0..3-1] of BYTE;
btEndDate: Array[0..3-1] of BYTE;
btStartTime: Array[0..3-1] of BYTE;
btEndTime: Array[0..3-1] of BYTE;
end {_stDataScrollMsg};
TDataScrollMsg = _stDataScrollMsg;
PTDataScrollMsg = ^_stDataScrollMsg;

_stDataSecurity = packed record


wdNo: Word;
chName: Array[0..100] of Char;
chNickname: Array[0..50] of Char;
chPassword: Array[0..50] of Char;
btLevel: BYTE;
end {_stDataSecurity};
TDataSecurity = _stDataSecurity;
PTDataSecurity = ^_stDataSecurity;

_stDataReport = packed record


end {_stDataReport};
TDataRepory = _stDataReport;
PTDataRepory = ^_stDataReport;

_stDataLabel = packed record


btNo: BYTE;
btSection: BYTE;
btSendCount: BYTE;
wdDataSize: Word;
pData: Pointer;
end {_stDataLabel};
TDataLabel = _stDataLabel;
PTDataLabel = ^_stDataLabel;

_stInterpreterBuffer = packed Record


btSendEnd: BYTE;

193
wdSendCount: Word;
wdSendSize: Word;
wdRecvCount: Word;
wdRecvHead: Word;
wdRecvSize: Word;
wdRecvExpactSize: Word;
wdStateCount:Word;
wdStatePosition: Word;
chStateBuffer: Array[0..100] of Char;
chRecvBackup: Array[0..DF_SIZE_RECVBUFFER] of Char;
tdRecvIngredient: TDataIngredient;
tdSendBackup: TTransDataEx;
end {_stInterpreterBuffer};
TInterpreterBuffer = _stInterpreterBuffer;
PTInterpreterBuffer = ^_stInterpreterBuffer;

function AddConnection(tdConnection: PTConnectionInfo): Integer; cdecl;


function AddInterpreter(wdScaleType: Word; wdScaleModel: Word; lpLibName: PChar): Integer;
cdecl;
function AddMsgConnection(btCommType: BYTE;
lpTarget: PChar;
wdPort: Word;
wdScaleType: Word;
wdScaleModel: Word;
wdTimeout: Word;
wdRetryCount: Word;
btDataType: BYTE;
dwRecvMsg: LongInt;
dwStateMsg: LongInt): Integer; cdecl;
function AddProcConnection(btCommType: BYTE;
lpTarget: PChar;
wdPort: Word;
wdScaleType: Word;
wdScaleModel: Word;
wdTimeout: Word;
wdRetryCount: Word;

194
btDataType: BYTE;
pRecvProc: PRecvProc;
pStateProc: PStateProc): Integer; cdecl;
function AddMsgConnectionEx(btCommType: BYTE;
lpTarget: PChar;
wdPort: Word;
wdScaleType: Word;
wdScaleModel: Word;
wdTimeout: Word;
wdRetryCount: Word;
btDataType: BYTE;
dwRecvMsg: LongInt;
dwStateMsg: LongInt;
shID: SmallInt;
shFlag: SmallInt): Integer; cdecl;
function AddProcConnectionEx(btCommType: BYTE;
lpTarget: PChar;
wdPort: Word;
wdScaleType: Word;
wdScaleModel: Word;
wdTimeout: Word;
wdRetryCount: Word;
btDataType: BYTE;
pRecvProc: PRecvProc;
pStateProc: PStateProc;
shID: SmallInt;
shFlag: SmallInt): Integer; cdecl;
function Connect(lpTarget: PChar; shID: SmallInt): Integer; cdecl;
function DeleteConnection(lpTarget: PChar; shID: SmallInt): Integer; cdecl;
function Disconnect(lpTarget: PChar; shID: SmallInt): Integer; cdecl;
function GetCommType(lpTarget: PChar; shID: SmallInt): Integer; cdecl;
function GetConnectionCount: Integer; cdecl;
function GetLibraryInfo(pVersion: PTVersion ; lpModuleName: PChar): Integer; cdecl;
function GetRetryCount(lpTarget: PChar; shID: SmallInt): Integer; cdecl;
function GetTimeout(lpTarget: PChar; shID: SmallInt): Integer; cdecl;
function GetTransType(lpTarget: PChar; shID: SmallInt): Integer; cdecl;

195
function Initialize(iFlag: Integer): Integer; cdecl;
function IsConnect(lpTarget: PChar; shID: SmallInt): Integer; cdecl;
function SendData(tdData: TTransData): Integer; cdecl;
function SendDataEx(tdData: TTransDataV02): Integer; cdecl;
function SetCommLibrary(iModuleID: Integer; lpModuleName: PChar): Integer; cdecl;
function SetRecvWindow(hWnd: HWND): Integer; cdecl;
function SetRetryCount(lpTarget: PChar; shID: SmallInt; iCount: Integer): Integer; cdecl;
function SetTimeout(lpTarget: PChar; shID: SmallInt; iInterval: Integer): Integer; cdecl;

{$ENDIF}

implementation

function AddConnection; external 'CASPRTC.DLL';


function AddInterpreter; external 'CASPRTC.DLL';
function AddMsgConnection; external 'CASPRTC.DLL';
function AddProcConnection; external 'CASPRTC.DLL';
function AddMsgConnectionEx; external 'CASPRTC.DLL';
function AddProcConnectionEx; external 'CASPRTC.DLL';
function Connect; external 'CASPRTC.DLL';
function DeleteConnection; external 'CASPRTC.DLL';
function Disconnect; external 'CASPRTC.DLL';
function GetCommType; external 'CASPRTC.DLL';
function GetConnectionCount; external 'CASPRTC.DLL';
function GetLibraryInfo; external 'CASPRTC.DLL';
function GetRetryCount; external 'CASPRTC.DLL';
function GetTimeout; external 'CASPRTC.DLL';
function GetTransType; external 'CASPRTC.DLL';
function Initialize; external 'CASPRTC.DLL';
function IsConnect; external 'CASPRTC.DLL';
function SendData; external 'CASPRTC.DLL';
function SendDataEx; external 'CASPRTC.DLL';
function SetCommLibrary; external 'CASPRTC.DLL';
function SetRecvWindow; external 'CASPRTC.DLL';
function SetRetryCount; external 'CASPRTC.DLL';
function SetTimeout; external 'CASPRTC.DLL';

196
end.

Example
procedure TForm1.FormCreate(Sender: TObject);

var

ret: Integer;

version: TVersion;

versionString: String;

begin

// Create Link Dlls

ret := SetCommLibrary(1, 'CASTCPIP.DLL');

ret := AddInterpreter(100, 5000, 'CLInterpreter.dll');

ret := AddInterpreter(DF_SCALE_TYPE_LP, DF_SCALE_16, 'LPInterpreter.dll');

version.btModule := 3;

GetLibraryInfo(@version, '');

versionString := Format('- %s Version %d.%d [%02d-%02d-%-02d]',

[DF_NAME_LIBTCPIP,

version.btMainVer,

version.btSubVer,

version.btModifyYear,

version.btModifyMonth,

version.btModifyDay] );

self.AddStatus(versionString);

Edit5.Text := 'PLU-Down.txt';

Edit6.Text := 'PLU-Up.txt';

end;

function TForm1.InitCommLib(): Integer;

var

res: Integer;

begin

res := AddProcConnection(DF_COMMTYPE_TCPIP, // Communication type

197
PChar(Edit1.Text), // IP

StrToInt(Edit2.Text), // Port

DF_SCALE_TYPE_LP, // Scale Type

DF_SCALE_CL5000, // Scale Model

StrToInt(Edit3.Text), // Timeout

StrToInt(Edit4.Text), // Retry count

DF_DATA_PLU_V02, // Data type

@OnDataReceived, // Recv proc

@OnNetworkState); // State proc

result := res;

end;

// Connect

procedure TForm1.Action1Execute(Sender: TObject);

var

ret: Integer;

IP: String;

begin

// CL Connect

ret := InitCommLib();

IP := Edit1.Text;

// ret := Connect(PChar(IP), Length(IP));

ret := Connect(PChar(IP), -1);

if (ret = 0) then

self.AddStatus('- Fail Connect')

else

self.AddStatus('- Success Connect');

end;

// Disconnect

procedure TForm1.Action2Execute(Sender: TObject);

198
var

ret: Integer;

msg: String;

begin

msg := Edit1.Text;

ret := Disconnect(PChar(msg), -1);

if (ret = 0) then

self.AddStatus('- Fail to Disconnect')

else

self.AddStatus('- Success to Disconect');

self.Abort;

end;

// Upload

procedure TForm1.UploadNextPLU(flag: Integer);

var

transData: TtransDataV02;

plu: TDataPLUV02;

ret: Integer;

begin

transData.shScaleID := -1;

transData.btCommType := DF_COMMTYPE_TCPIP;

transData.btDataType := DF_DATA_PLU_V02;

transData.lpIP := PChar(Edit1.Text);

transData.wdAction := DF_ACTION_UPLOAD;

transData.wdScaleType := DF_SCALE_TYPE_LP;

transData.wdScaleModel := DF_SCALE_CL5000;

FillMemory(@plu, sizeof(TDataPLUV02), $00);

plu.btDepart := 1;

if (flag = 0) then

199
begin

plu.dwPLU := 1;

end

else

begin

plu.dwPLU := FActionInfo.dwSendID + 1;

end;

transData.pData := @plu;

FActionInfo.dwSendID := plu.dwPLU;

ret := SendData(transData);

if (ret = 0) then

self.AddStatus('- Fail to Send data')

else

self.AddStatus('- Success to Send data');

end;

200

You might also like