CommJava API
CommJava API
Contents
㈜ CAS
4.2.1 Set PLU 11
4.2.2 Delete PLU 14
4.2.3 Delete all PLU 15
4.3 Parameter 16
4.3.1 Set Parameter 16
4.4 Keypad 18
4.4.1 Set Keypad 18
4.5 Ingredient 30
4.5.1 Set Ingredient 30
4.5.2 Delete Ingredient 31
4.5.3 Delete all Ingredient 32
4.6 Symbol 33
4.6.1 Set Unit Symbol 33
4.6.2 Delete Unit Symbol 34
4.6.3 Delete all Unit Symobl 35
4.7 Label 36
4.7.1 Set Label 36
4.8 Weight (Only Vietnam) 37
4.8.1 Set weight transmission property 37
5. How to check Result 39
5.1 Make the class to receive the result 39
5.2 How to Check result 39
2
1. CAS Java Library
1.1 Necessary file
To operate a program to communicate with CAS label scale, five file with application
program must be existed in the same route.
A. Java Library (JRE System Library)
a. JavaSE-1.7
B. Java Library (JRE System Library)
a. CasCommLib-1.0.10.jar
C. Other external libraray
a. commons-net-3.6.jar
b. netty-all-4.0.30.final.jar
c. log4j-1.2.17.jar
d. slf4j-api-1.7.25.jar
2. Packages
3
2.1 com.cas.CommonDefines
2.1.1 EmActionType
Element Code Description
Send 1 Send data to scale
SendAll 2 Send all data to scale
Take 3 Take data from scale
TakeAll 4 Take data from scale
Delete 5 Delete data
DeleteAll 6 Delete all data
2.1.2 EmDataType
Element Code Description
Keypad 3 Keypad
PLU 11 PLU
Symbol 21 Symbol
Ingredient 22 Ingredient
VersionInfo 58 Version Information
Parameter 1004 Parameter
2.1.3 EmCommType
Element Code Description
COMMTYPE_TCPI Tcp Tcp/Ip communication
P
COMMTYPE_SERI Serial Serial communication
AL
COMMTYPE_FTP Ftp Ftp communication
2.1.4 EmScaleModel
Element Code Description
CL5000 5000
CL5000J 5010
CL5200 5200 In china, It is called CL3000
CL5200J 5210
CL5500 5500
CL7200 7200
2.1.5 ScaleType
Element Code Description
Bench 1 Bench type
Pole 2 Pole type
2.1.6 CommState
Element Code Description
FAIL 0 Fail transmission
SUCCSESS 1 Success transmission
CONNECTION_ERRO 2 Fail connection
R
SCALE_ERR_CHECKS 217 Checksum is wrong
UM
PACKET_ERR_WRON 501 Packet is wrong
G
4
2.2 com.cas.commlib
2.2.1 Class CasCommlib.java
: You can send data to a scale using this class
(1) Constructor
Description
CasCommLib()
: Create object and initialize member
Default properties file path : INSTALL_PATH + props/netty.properties
CasCommLib(String propFilePath)
: Create object and initialize member
Parameter:
propFilePath : path of “netty.properties”
(2) Method
Type Method and Description
void sendToScale(Map<String, String> scaleEnv, Object sendData,
Map<String, String> scaleInfo, ResultReceive resultReceive)
: Send data to a scale.
Parameter:
scaleEnv : Environment Information of this communication
work.
sendData: Data to transfer
scaleInfo : Scale Information
resultReceive : Class to receive the communication result
2.3 com.cas.code
2.3.1 Class CommonDefines.java
: There are definitions used in this library. Refer to provided source code
(1) Constructor
Method and Description
ResultReceiveData()
: Create object and initialize member
5
ResultReceiveData(IRepeat repeatCallback)
: Create object and initialize member and repeat callback method
Parameter:
repeatCallback: interface of IRepeat. It has repeat method
(2) Method
Type Method and Description
void setResultData(Map<String, String> scaleEnv, int workResult,
List<Map<String, String>> resultData, Object obSendList,
Map<String, String> scaleInfo)
: Receive the communication result through this method
Parameter:
scaleEnv : Environment Information of this communication work.
workResult: Result of this communication work
resultData : Detail result
obSendList : Data you tried to send
scaleInfo : Scale Information
3.2 scaleInfo
(1) Type: Map<String, String>
(2) Map Key
Refer com.cas.code.CommDefines.MapKeyScaleInfo class
key string Field in class Description
Ip MK_IP Set scale IP
Port MK_PORT Set scale port (20304)
Model MK_MODEL Set scale model code
Refer : 2.1.4 EmScaleModel
ScaleType MK_SCALETYPE Set scale type
6
Refer : 2.1.5 ScaleType
Version MK_VERSION Firmware Version of the Scale
3.3 resultReceive
(1) Type: interface ResultReceive
: You should input the class which implements the ResultReceive Interface to this
parameter.
You can receive the communication result through this parameter
3.4 WorkResult
(1) Type: int
: You can confirm the information of each communication result through this
parameter
Refer 5.How to check Result
7
4.2.1 Set PLU
(1) Set scaleEnv property
key string Value Description(refer enum)
string
Action 1 EmActionType.Send.getActionCode()
DataType 11 EmDataType.PLU.getDataType()
Encoding MS936 Depending on Language
or Ex) for china
EUC-CN -“MS936“ for windows
-“EUC-CN“ for unix/linux
CommType Tcp EmCommType.COMMTYPE_TCPIP.getCom
mType()
decimalPointPric 2 Price decimal point(0 ~ 5)
e In China, the decimal point is 2 digits
9
mType()
10
4.3 Parameter
4.3.1 Set Parameter
(1) Set scaleEnv property
key string Value string Description(refer enum)
Action 1 EmActionType.Send.getActionCode()
DataType 3 EmDataType.Keypad.getDataType()
Encoding MS936 Depending on Language
or Ex) for china
EUC-CN -“MS936“ for windows
-“EUC-CN“ for unix/linux
CommType Tcp EmCommType.COMMTYPE_TCPIP.getCom
mType()
11
DataType 3 EmDataType.Key.getDataType()
Encoding MS936 Depending on Language
or Ex) for china
EUC-CN -“MS936“ for windows
-“EUC-CN“ for unix/linux
CommType Tcp EmCommType.COMMTYPE_TCPIP.getCom
mType()
– The keypad consists of a normal and shift key. The PLU key can set both
normal key and shift key. On the other hand, the function key is set only for
the normal key.
12
The following picture is a KeyV1(Value Obejct) class diagram.
13
– There are five PLU Categories. There are five pages in one category. The
page1 for the normal keypad and the page2 is for the shift keypad.
– The configure of arrFunctionPage is as follos.
– The function page1 for the normal keypad and the page2 is for the shift
keypad.
– How to assignfunction key.
– To assign a function key to the first key.
1. Set the desired category.
2. Set function key send.
3. Set page, key, code.
14
– How to assign PLU key
– To assign a function key to second key.
1. Set the desired category
2. Set function key send
3. Set PLU key send.
4. Set category, page, key, code
18
Individuality15.getCode()
Individuality16 0x02D0 FunctionKeyIndividualityCode.
Individuality16.getCode()
19
SpecialUse13 0x070D FunctionKeySpecialUseCode.SpecialUse13.getCod
e()
SpecialUse14 0x070E FunctionKeySpecialUseCode.SpecialUse14.getCod
e()
SpecialUse15 0x070F FunctionKeySpecialUseCode.SpecialUse15.getCod
e()
SpecialUse16 0x0710 FunctionKeySpecialUseCode.SpecialUse16.getCod
e()
SpecialUse17 0x0711 FunctionKeySpecialUseCode.SpecialUse17.getCod
e()
SpecialUse18 0x0712 FunctionKeySpecialUseCode.SpecialUse18.getCod
e()
SpecialUse19 0x0713 FunctionKeySpecialUseCode.SpecialUse19.getCod
e()
SpecialUse20 0x0714 FunctionKeySpecialUseCode.SpecialUse20.getCod
e()
SpecialUse21 0x0715 FunctionKeySpecialUseCode.SpecialUse21.getCod
e()
SpecialUse22 0x0716 FunctionKeySpecialUseCode.SpecialUse22.getCod
e()
SpecialUse23 0x0717 FunctionKeySpecialUseCode.SpecialUse23.getCod
e()
SpecialUse24 0x0718 FunctionKeySpecialUseCode.SpecialUse24.getCod
e()
SpecialUse25 0x0719 FunctionKeySpecialUseCode.SpecialUse25.getCod
e()
SpecialUse26 0x071A FunctionKeySpecialUseCode.SpecialUse26.getCod
e()
SpecialUse27 0x071B FunctionKeySpecialUseCode.SpecialUse27.getCod
e()
SpecialUse28 0x071C FunctionKeySpecialUseCode.SpecialUse28.getCod
e()
SpecialUse29 0x071D FunctionKeySpecialUseCode.SpecialUse29.getCod
e()
SpecialUse30 0x071E FunctionKeySpecialUseCode.SpecialUse30.getCod
e()
SpecialUse31 0x071F FunctionKeySpecialUseCode.SpecialUse31.getCod
e()
SpecialUse32 0x0720 FunctionKeySpecialUseCode.SpecialUse32.getCod
e()
SpecialUse33 0x0721 FunctionKeySpecialUseCode.SpecialUse33.getCod
e()
SpecialUse34 0x0722 FunctionKeySpecialUseCode.SpecialUse34.getCod
e()
SpecialUse35 0x0723 FunctionKeySpecialUseCode.SpecialUse35.getCod
e()
SpecialUse36 0x0724 FunctionKeySpecialUseCode.SpecialUse36.getCod
e()
SpecialUse37 0x0725 FunctionKeySpecialUseCode.SpecialUse37.getCod
e()
SpecialUse38 0x0726 FunctionKeySpecialUseCode.SpecialUse38.getCod
e()
SpecialUse39 0x0727 FunctionKeySpecialUseCode.SpecialUse39.getCod
e()
SpecialUse40 0x0728 FunctionKeySpecialUseCode.SpecialUse40.getCod
e()
SpecialUse41 0x0729 FunctionKeySpecialUseCode.SpecialUse41.getCod
20
e()
SpecialUse42 0x072A FunctionKeySpecialUseCode.SpecialUse42.getCod
e()
SpecialUse43 0x072B FunctionKeySpecialUseCode.SpecialUse43.getCod
e()
SpecialUse44 0x072C FunctionKeySpecialUseCode.SpecialUse44.getCod
e()
SpecialUse45 0x072D FunctionKeySpecialUseCode.SpecialUse45.getCod
e()
SpecialUse46 0x072E FunctionKeySpecialUseCode.SpecialUse46.getCod
e()
SpecialUse47 0x072F FunctionKeySpecialUseCode.SpecialUse47.getCod
e()
SpecialUse48 0x0730 FunctionKeySpecialUseCode.SpecialUse48.getCod
e()
SpecialUse49 0x0731 FunctionKeySpecialUseCode.SpecialUse49.getCod
e()
SpecialUse50 0x0732 FunctionKeySpecialUseCode.SpecialUse50.getCod
e()
SpecialUse51 0x0733 FunctionKeySpecialUseCode.SpecialUse51.getCod
e()
SpecialUse52 0x0734 FunctionKeySpecialUseCode.SpecialUse52.getCod
e()
SpecialUse53 0x0735 FunctionKeySpecialUseCode.SpecialUse53.getCod
e()
SpecialUse54 0x0736 FunctionKeySpecialUseCode.SpecialUse54.getCod
e()
SpecialUse55 0x0737 FunctionKeySpecialUseCode.SpecialUse55.getCod
e()
SpecialUse56 0x0738 FunctionKeySpecialUseCode.SpecialUse56.getCod
e()
SpecialUse57 0x0739 FunctionKeySpecialUseCode.SpecialUse57.getCod
e()
SpecialUse58 0x073A FunctionKeySpecialUseCode.SpecialUse58.getCod
e()
SpecialUse59 0x073B FunctionKeySpecialUseCode.SpecialUse59.getCod
e()
SpecialUse60 0x073C FunctionKeySpecialUseCode.SpecialUse60.getCod
e()
SpecialUse61 0x073D FunctionKeySpecialUseCode.SpecialUse61.getCod
e()
SpecialUse62 0x073E FunctionKeySpecialUseCode.SpecialUse62.getCod
e()
SpecialUse63 0x073F FunctionKeySpecialUseCode.SpecialUse63.getCod
e()
SpecialUse64 0x0740 FunctionKeySpecialUseCode.SpecialUse64.getCod
e()
SpecialUse65 0x0741 FunctionKeySpecialUseCode.SpecialUse65.getCod
e()
SpecialUse66 0x0742 FunctionKeySpecialUseCode.SpecialUse66.getCod
e()
SpecialUse67 0x0743 FunctionKeySpecialUseCode.SpecialUse67.getCod
e()
SpecialUse68 0x0744 FunctionKeySpecialUseCode.SpecialUse68.getCod
e()
SpecialUse69 0x0745 FunctionKeySpecialUseCode.SpecialUse69.getCod
e()
21
SpecialUse70 0x0746 FunctionKeySpecialUseCode.SpecialUse70.getCod
e()
SpecialUse71 0x0747 FunctionKeySpecialUseCode.SpecialUse71.getCod
e()
SpecialUse72 0x0748 FunctionKeySpecialUseCode.SpecialUse72.getCod
e()
SpecialUse73 0x0749 FunctionKeySpecialUseCode.SpecialUse73.getCod
e()
SpecialUse74 0x074A FunctionKeySpecialUseCode.SpecialUse74.getCod
e()
SpecialUse75 0x074B FunctionKeySpecialUseCode.SpecialUse75.getCod
e()
SpecialUse76 0x074C FunctionKeySpecialUseCode.SpecialUse76.getCod
e()
SpecialUse77 0x074D FunctionKeySpecialUseCode.SpecialUse77.getCod
e()
SpecialUse78 0x074E FunctionKeySpecialUseCode.SpecialUse78.getCod
e()
SpecialUse79 0x074F FunctionKeySpecialUseCode.SpecialUse79.getCod
e()
SpecialUse80 0x0750 FunctionKeySpecialUseCode.SpecialUse80.getCod
e()
SpecialUse81 0x0751 FunctionKeySpecialUseCode.SpecialUse81.getCod
e()
SpecialUse82 0x0752 FunctionKeySpecialUseCode.SpecialUse82.getCod
e()
SpecialUse83 0x0753 FunctionKeySpecialUseCode.SpecialUse83.getCod
e()
SpecialUse84 0x0754 FunctionKeySpecialUseCode.SpecialUse84.getCod
e()
SpecialUse85 0x0755 FunctionKeySpecialUseCode.SpecialUse85.getCod
e()
SpecialUse86 0x0756 FunctionKeySpecialUseCode.SpecialUse86.getCod
e()
SpecialUse87 0x0757 FunctionKeySpecialUseCode.SpecialUse87.getCod
e()
SpecialUse88 0x0758 FunctionKeySpecialUseCode.SpecialUse88.getCod
e()
SpecialUse89 0x0759 FunctionKeySpecialUseCode.SpecialUse89.getCod
e()
SpecialUse90 0x075A FunctionKeySpecialUseCode.SpecialUse90.getCod
e()
SpecialUse91 0x075B FunctionKeySpecialUseCode.SpecialUse91.getCod
e()
SpecialUse92 0x075C FunctionKeySpecialUseCode.SpecialUse92.getCod
e()
SpecialUse93 0x075D FunctionKeySpecialUseCode.SpecialUse93.getCod
e()
SpecialUse94 0x075E FunctionKeySpecialUseCode.SpecialUse94.getCod
e()
SpecialUse95 0x075F FunctionKeySpecialUseCode.SpecialUse95.getCod
e()
SpecialUse96 0x0760 FunctionKeySpecialUseCode.SpecialUse96.getCod
e()
SpecialUse97 0x0761 FunctionKeySpecialUseCode.SpecialUse97.getCod
e()
SpecialUse98 0x0762 FunctionKeySpecialUseCode.SpecialUse98.getCod
22
e()
SpecialUse99 0x0763 FunctionKeySpecialUseCode.SpecialUse99.getCod
e()
SpecialUse100 0x0764 FunctionKeySpecialUseCode.SpecialUse100.getCo
de()
4.5 Ingredient
4.5.1 Set Ingredient
(1) Set scaleEnv property
key string Value string Description(refer enum)
Action 1 EmActionType.Send.getActionCode()
DataType 22 EmDataType.Ingredient.getDataType()
Encoding MS936 Depending on Language
or Ex) for china
EUC-CN -“MS936“ for windows
-“EUC-CN“ for unix/linux
CommType Tcp EmCommType.COMMTYPE_TCPIP.getCom
mType()
23
Ingredient Ingredient Ingredient text
24
EmScaleModel.CL5200.getModelCode()
ScaleType 2 Depending on Scale Type
1 : ScaleType.Bench
2 : ScaleType.Pole
3 : ScaleType.Hanging
4 : ScaleType.Self
5 : ScaleType.Double
6 : Scaletype.LP1
ScaleType.Pole.getTypecode()
4.6 Symbol
4.6.1 Set Unit Symbol
(1) Set scaleEnv property
key string Value string Description(refer enum)
Action 1 EmActionType.Send.getActionCode()
DataType 21 EmDataType.Symbol.getDataType()
Encoding MS936 Depending on Language
or Ex) for china
EUC-CN -“MS936“ for windows
-“EUC-CN“ for unix/linux
CommType Tcp EmCommType.COMMTYPE_TCPIP.getCom
mType()
25
4.6.2 Delete Unit Symbol
(1) Set scaleEnv property
key string Value string Description(refer enum)
Action 5 EmActionType.Delete.getActionCode()
DataType 21 EmDataType.Symbol.getDataType()
Encoding MS936 Depending on Language
or Ex) for china
EUC-CN -“MS936“ for windows
-“EUC-CN“ for unix/linux
CommType Tcp EmCommType.COMMTYPE_TCPIP.getCom
mType()
4.7 Label
4.7.1 Set Label
(1) Set scaleEnv property
key string Value string Description(refer enum)
Action 1 EmActionType.Send.getActionCode()
DataType 6 EmDataType.LabelInfo.getDataType()
Encoding MS936 Depending on Language
or Ex) for china
EUC-CN -“MS936“ for windows
-“EUC-CN“ for unix/linux
CommType Tcp EmCommType.COMMTYPE_TCPIP.getCom
mType()
27
4.8 Weight (Only Vietnam)
4.8.1 Set weight transmission property
(1) set scaleEnv property
key string Value string Description(refer enum)
Action 1 EmActionType.Send.getActionCode()
DataType 11000 EmDataType.Weight.getDataType()
Encoding MS936 Depending on Language
EUC-CN Ex) for china
or -“MS936“ for windows
Cp1258 -“EUC-CN“ for unix/linux
for vietnam
-“Cp1258”
CommType Tcp EmCommType.COMMTYPE_TCPIP.getCom
mType()
29