Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
SocketDemo
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
朱世闯
SocketDemo
Commits
393af7a8
Commit
393af7a8
authored
3 years ago
by
UIUANG\Zsc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改传称
parent
3956d706
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
133 additions
and
72 deletions
+133
-72
vcs.xml
.idea/vcs.xml
+6
-0
build.gradle
DigiTransfer/build.gradle
+6
-5
DigiScaleTransfer.java
...main/java/com/wmdigit/digitransfer/DigiScaleTransfer.java
+9
-6
ObjectHandler.java
.../java/com/wmdigit/digitransfer/handler/ObjectHandler.java
+1
-1
Printer.java
...c/main/java/com/wmdigit/digitransfer/handler/Printer.java
+15
-0
ScalesApiHandler.java
...va/com/wmdigit/digitransfer/handler/ScalesApiHandler.java
+95
-60
build.gradle
app/build.gradle
+1
-0
No files found.
.idea/vcs.xml
0 → 100644
View file @
393af7a8
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"VcsDirectoryMappings"
>
<mapping
directory=
"$PROJECT_DIR$"
vcs=
"Git"
/>
</component>
</project>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
DigiTransfer/build.gradle
View file @
393af7a8
...
@@ -8,8 +8,8 @@ android {
...
@@ -8,8 +8,8 @@ android {
defaultConfig
{
defaultConfig
{
minSdkVersion
21
minSdkVersion
21
targetSdkVersion
31
targetSdkVersion
31
versionCode
1
versionCode
4
versionName
"1.0.
0
"
versionName
"1.0.
4
"
testInstrumentationRunner
"androidx.test.runner.AndroidJUnitRunner"
testInstrumentationRunner
"androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles
"consumer-rules.pro"
consumerProguardFiles
"consumer-rules.pro"
...
@@ -27,7 +27,7 @@ android {
...
@@ -27,7 +27,7 @@ android {
}
}
android
.
libraryVariants
.
all
{
variant
->
android
.
libraryVariants
.
all
{
variant
->
variant
.
outputs
.
all
{
variant
.
outputs
.
all
{
outputFileName
=
"${project.name}_v"
+
android
.
defaultConfig
.
versionName
+
'_sdk.
a
ar'
outputFileName
=
"${project.name}_v"
+
android
.
defaultConfig
.
versionName
+
'_sdk.
j
ar'
}
}
}
}
}
}
...
@@ -42,8 +42,9 @@ dependencies {
...
@@ -42,8 +42,9 @@ dependencies {
}
}
task
makeJar
(
type:
Copy
)
{
task
makeJar
(
type:
Copy
)
{
def
outAar
=
"${project.name}_v"
+
android
.
defaultConfig
.
versionName
+
"_sdk.jar"
//删除存在的
//删除存在的
delete
'build/libs/
myjar.jar'
delete
'build/libs/
'
+
outAar
//设置拷贝的文件
//设置拷贝的文件
from
(
'build/intermediates/aar_main_jar/release/'
)
from
(
'build/intermediates/aar_main_jar/release/'
)
//打进jar包后的文件目录
//打进jar包后的文件目录
...
@@ -53,7 +54,7 @@ task makeJar(type: Copy) {
...
@@ -53,7 +54,7 @@ task makeJar(type: Copy) {
//(我们只关心classes.jar这个文件)
//(我们只关心classes.jar这个文件)
include
(
'classes.jar'
)
include
(
'classes.jar'
)
//重命名
//重命名
rename
(
'classes.jar'
,
'myjar.jar'
)
rename
(
'classes.jar'
,
outAar
)
}
}
makeJar
.
dependsOn
(
build
)
makeJar
.
dependsOn
(
build
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
DigiTransfer/src/main/java/com/wmdigit/digitransfer/DigiScaleTransfer.java
View file @
393af7a8
...
@@ -5,6 +5,7 @@ import android.util.Log;
...
@@ -5,6 +5,7 @@ import android.util.Log;
import
com.wmdigit.digitransfer.exception.ErrCode
;
import
com.wmdigit.digitransfer.exception.ErrCode
;
import
com.wmdigit.digitransfer.exception.ScalesApiException
;
import
com.wmdigit.digitransfer.exception.ScalesApiException
;
import
com.wmdigit.digitransfer.handler.ObjectHandler
;
import
com.wmdigit.digitransfer.handler.ObjectHandler
;
import
com.wmdigit.digitransfer.handler.Printer
;
import
com.wmdigit.digitransfer.util.NetWorkUtils
;
import
com.wmdigit.digitransfer.util.NetWorkUtils
;
import
java.io.IOException
;
import
java.io.IOException
;
...
@@ -16,26 +17,28 @@ public class DigiScaleTransfer {
...
@@ -16,26 +17,28 @@ public class DigiScaleTransfer {
private
static
DigiScaleTransfer
instance
;
private
static
DigiScaleTransfer
instance
;
private
int
addressFour
;
private
int
addressFour
;
private
ObjectHandler
scalesApiHandler
;
private
ObjectHandler
scalesApiHandler
;
private
Printer
printer
;
private
final
String
TAG
=
DigiScaleTransfer
.
this
.
getClass
().
getSimpleName
();
private
final
String
TAG
=
DigiScaleTransfer
.
this
.
getClass
().
getSimpleName
();
private
ServerSocket
serverSocket
;
private
ServerSocket
serverSocket
;
public
static
DigiScaleTransfer
getInstance
(
ObjectHandler
scalesApiHandler
)
{
public
static
DigiScaleTransfer
getInstance
(
ObjectHandler
scalesApiHandler
,
Printer
printer
)
{
if
(
instance
==
null
)
{
if
(
instance
==
null
)
{
instance
=
new
DigiScaleTransfer
(
scalesApiHandler
);
instance
=
new
DigiScaleTransfer
(
scalesApiHandler
,
printer
);
}
}
return
instance
;
return
instance
;
}
}
private
DigiScaleTransfer
(
ObjectHandler
scalesApiHandler
)
{
private
DigiScaleTransfer
(
ObjectHandler
scalesApiHandler
,
Printer
printer
)
{
this
.
scalesApiHandler
=
scalesApiHandler
;
this
.
scalesApiHandler
=
scalesApiHandler
;
this
.
printer
=
printer
;
String
hostAddress
=
null
;
String
hostAddress
=
null
;
hostAddress
=
NetWorkUtils
.
getLocalIp
();
hostAddress
=
NetWorkUtils
.
getLocalIp
();
int
of
=
hostAddress
.
lastIndexOf
(
"."
);
int
of
=
hostAddress
.
lastIndexOf
(
"."
);
String
addressFourStr
=
hostAddress
.
substring
(
of
+
1
);
String
addressFourStr
=
hostAddress
.
substring
(
of
+
1
);
addressFour
=
Integer
.
parseInt
(
addressFourStr
);
addressFour
=
Integer
.
parseInt
(
addressFourStr
);
Log
.
i
(
"AT"
,
hostAddress
);
printer
.
d
(
"ip地址:"
+
hostAddress
);
}
}
...
@@ -55,8 +58,8 @@ public class DigiScaleTransfer {
...
@@ -55,8 +58,8 @@ public class DigiScaleTransfer {
try
{
try
{
socket
=
serverSocket
.
accept
();
socket
=
serverSocket
.
accept
();
int
localPort
=
serverSocket
.
getLocalPort
();
int
localPort
=
serverSocket
.
getLocalPort
();
Log
.
i
(
"port"
,
"端口号"
+
localPort
);
printer
.
i
(
"端口号"
+
localPort
);
scalesApiHandler
.
setSocket
(
socket
,
addressFour
);
scalesApiHandler
.
setSocket
(
socket
,
addressFour
,
printer
);
ThreadCacheManager
.
getExecutorService
().
execute
(
scalesApiHandler
);
ThreadCacheManager
.
getExecutorService
().
execute
(
scalesApiHandler
);
// Thread thread = new Thread(this.scalesApiHandler);
// Thread thread = new Thread(this.scalesApiHandler);
// thread.start();
// thread.start();
...
...
This diff is collapsed.
Click to expand it.
DigiTransfer/src/main/java/com/wmdigit/digitransfer/handler/ObjectHandler.java
View file @
393af7a8
...
@@ -10,6 +10,6 @@ public interface ObjectHandler extends Runnable{
...
@@ -10,6 +10,6 @@ public interface ObjectHandler extends Runnable{
void
downPlu
(
Commodity
commodity
);
void
downPlu
(
Commodity
commodity
);
void
setSocket
(
Socket
socket
,
int
addressFour
);
void
setSocket
(
Socket
socket
,
int
addressFour
,
Printer
printer
);
}
}
This diff is collapsed.
Click to expand it.
DigiTransfer/src/main/java/com/wmdigit/digitransfer/handler/Printer.java
0 → 100644
View file @
393af7a8
package
com
.
wmdigit
.
digitransfer
.
handler
;
public
interface
Printer
{
void
i
(
String
msg
);
void
v
(
String
msg
);
void
d
(
String
msg
);
void
w
(
String
msg
);
void
e
(
String
msg
);
// void v(String format, Object... args)
}
This diff is collapsed.
Click to expand it.
DigiTransfer/src/main/java/com/wmdigit/digitransfer/handler/ScalesApiHandler.java
View file @
393af7a8
...
@@ -15,6 +15,7 @@ import java.nio.ByteOrder;
...
@@ -15,6 +15,7 @@ import java.nio.ByteOrder;
public
abstract
class
ScalesApiHandler
implements
ObjectHandler
{
public
abstract
class
ScalesApiHandler
implements
ObjectHandler
{
private
Socket
socket
;
private
Socket
socket
;
private
int
addressFour
;
private
int
addressFour
;
private
Printer
printer
;
public
ScalesApiHandler
()
{
public
ScalesApiHandler
()
{
}
}
...
@@ -30,7 +31,7 @@ public abstract class ScalesApiHandler implements ObjectHandler {
...
@@ -30,7 +31,7 @@ public abstract class ScalesApiHandler implements ObjectHandler {
byteBuffer
.
put
(
mReceivedBuffer
,
0
,
read
);
byteBuffer
.
put
(
mReceivedBuffer
,
0
,
read
);
byteBuffer
.
order
(
ByteOrder
.
LITTLE_ENDIAN
).
flip
();
byteBuffer
.
order
(
ByteOrder
.
LITTLE_ENDIAN
).
flip
();
byte
[]
byteArray
=
byteBuffer
.
array
();
byte
[]
byteArray
=
byteBuffer
.
array
();
System
.
out
.
println
(
Hex2BytesUtils
.
bytesToHexString2
(
byteArray
));
printer
.
d
(
Hex2BytesUtils
.
bytesToHexString2
(
byteArray
));
switch
(
byteArray
[
0
])
{
switch
(
byteArray
[
0
])
{
case
(
byte
)
247
:
case
(
byte
)
247
:
String
hexString
=
Hex2BytesUtils
.
bytesToHexString
(
byteArray
);
String
hexString
=
Hex2BytesUtils
.
bytesToHexString
(
byteArray
);
...
@@ -38,10 +39,10 @@ public abstract class ScalesApiHandler implements ObjectHandler {
...
@@ -38,10 +39,10 @@ public abstract class ScalesApiHandler implements ObjectHandler {
String
hex2
;
String
hex2
;
if
(
addressFour
>
153
)
{
if
(
addressFour
>
153
)
{
hex2
=
"F74F00000"
+
addressFour
;
hex2
=
"F74F00000"
+
addressFour
;
}
else
{
}
else
{
hex2
=
"F74F000000"
+
hex
;
hex2
=
"F74F000000"
+
hex
;
}
}
System
.
out
.
println
(
hex2
);
printer
.
d
(
hex2
);
if
(
hexString
.
equals
(
"F74F00000000"
))
{
if
(
hexString
.
equals
(
"F74F00000000"
))
{
String
s1
=
"00 00 00 "
+
hex
+
" 00 b6 00 00 00 00 00 01 00 00 00 01 00 00 00 00 16 01 04 01 00 20 10 01 24 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 60 03 "
+
String
s1
=
"00 00 00 "
+
hex
+
" 00 b6 00 00 00 00 00 01 00 00 00 01 00 00 00 00 16 01 04 01 00 20 10 01 24 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 60 03 "
+
"77 5e e0 c0 a8 31 "
+
"77 5e e0 c0 a8 31 "
+
...
@@ -52,7 +53,7 @@ public abstract class ScalesApiHandler implements ObjectHandler {
...
@@ -52,7 +53,7 @@ public abstract class ScalesApiHandler implements ObjectHandler {
replyCommand
(
bytes1
);
replyCommand
(
bytes1
);
}
else
if
(
hexString
.
equals
(
hex2
))
{
}
else
if
(
hexString
.
equals
(
hex2
))
{
System
.
out
.
println
(
hex2
);
// printer.d
(hex2);
byte
[]
bytes1
=
new
byte
[
1
];
byte
[]
bytes1
=
new
byte
[
1
];
bytes1
[
0
]
=
(
byte
)
226
;
bytes1
[
0
]
=
(
byte
)
226
;
replyCommand
(
bytes1
);
replyCommand
(
bytes1
);
...
@@ -79,7 +80,7 @@ public abstract class ScalesApiHandler implements ObjectHandler {
...
@@ -79,7 +80,7 @@ public abstract class ScalesApiHandler implements ObjectHandler {
// System.out.println("条码格式BarcodeFormat:" + barcodeFormat);
// System.out.println("条码格式BarcodeFormat:" + barcodeFormat);
commodity
.
setBarcodeFormat
(
barcodeFormat
);
commodity
.
setBarcodeFormat
(
barcodeFormat
);
// byte[] bytes1 = subBytes(receivedBytes, 19, 1);
// byte[] bytes1 = subBytes(receivedBytes, 19, 1);
String
labelFormat1
=
ByteBufferUtils
.
bytesToString
(
byteBuffer
,
1
);
String
labelFormat1
=
ByteBufferUtils
.
bytesToString
(
byteBuffer
,
1
);
commodity
.
setLabelFormat1
(
labelFormat1
);
commodity
.
setLabelFormat1
(
labelFormat1
);
// System.out.println("条码前缀" + labelFormat1);
// System.out.println("条码前缀" + labelFormat1);
...
@@ -87,70 +88,55 @@ public abstract class ScalesApiHandler implements ObjectHandler {
...
@@ -87,70 +88,55 @@ public abstract class ScalesApiHandler implements ObjectHandler {
String
itemCode
=
ByteBufferUtils
.
bytesToString
(
byteBuffer
,
5
).
replaceAll
(
"(0)+$"
,
""
);
String
itemCode
=
ByteBufferUtils
.
bytesToString
(
byteBuffer
,
5
).
replaceAll
(
"(0)+$"
,
""
);
// System.out.println("项目代码:" + itemCode);
// System.out.println("项目代码:" + itemCode);
commodity
.
setItemCode
(
itemCode
);
commodity
.
setItemCode
(
itemCode
);
byteBuffer
.
position
(
byteBuffer
.
position
()
+
1
);
byteBuffer
.
position
(
byteBuffer
.
position
()
+
1
);
String
groupNo
=
String
.
valueOf
(
ByteBufferUtils
.
bytesToInteger
(
byteBuffer
,
2
));
String
groupNo
=
String
.
valueOf
(
ByteBufferUtils
.
bytesToInteger
(
byteBuffer
,
2
));
// System.out.println("MGNo 主组:" + groupNo);
// System.out.println("MGNo 主组:" + groupNo);
commodity
.
setMgNo
(
groupNo
);
commodity
.
setMgNo
(
groupNo
);
int
usedByDate
=
ByteBufferUtils
.
bytesToInteger
(
byteBuffer
,
2
);
int
usedByDate
=
ByteBufferUtils
.
bytesToInteger
(
byteBuffer
,
2
);
//
System.out.println("售出日期:UsedByDate:" + usedByDate);
System
.
out
.
println
(
"售出日期:UsedByDate:"
+
usedByDate
);
commodity
.
setUsedByDate
(
usedByDate
);
commodity
.
setUsedByDate
(
usedByDate
);
int
sellByDate
=
ByteBufferUtils
.
bytesToInteger
(
byteBuffer
,
2
);
int
sellByDate
=
ByteBufferUtils
.
bytesToInteger
(
byteBuffer
,
2
);
//
System.out.println("保质期:SellByDate:" + sellByDate);
System
.
out
.
println
(
"保质期:SellByDate:"
+
sellByDate
);
commodity
.
setSellByDate
(
sellByDate
);
commodity
.
setSellByDate
(
sellByDate
);
int
packedByDate
=
ByteBufferUtils
.
bytesToInteger
(
byteBuffer
,
2
);
int
packedByDate
=
ByteBufferUtils
.
bytesToInteger
(
byteBuffer
,
2
);
// System.out.println("包装日期,PackedByDate:" + packedByDate);
commodity
.
setPackedByDate
(
packedByDate
);
commodity
.
setPackedByDate
(
packedByDate
);
// System.out.println("包装日期,PackedByDate:" + packedByDate);
System
.
out
.
println
(
"包装日期,PackedByDate:"
+
packedByDate
);
byteBuffer
.
position
(
48
);
int
traceabilityFlag
=
ByteBufferUtils
.
bytesToInt
(
byteBuffer
);
int
traceabilityNo
=
ByteBufferUtils
.
bytesToInteger
(
byteBuffer
,
2
);
System
.
out
.
println
(
"追溯码开关"
+
traceabilityFlag
+
",追溯码内容"
+
traceabilityNo
);
commodity
.
setPackedByDate
(
packedByDate
);
commodity
.
setPackedByDate
(
packedByDate
);
byteBuffer
.
position
(
152
);
// int pos = 152;
int
commodity1Start
=
byteBuffer
.
get
();
// int i = 0;
if
(
commodity1Start
==
3
)
{
// boolean isResult = true;
int
commodity1Font
=
ByteBufferUtils
.
bytesToInt
(
byteBuffer
);
// while (isResult) {
System
.
out
.
println
(
"commodity1Font:"
+
commodity1Font
);
//
int
commodity1Length
=
ByteBufferUtils
.
bytesToInt
(
byteBuffer
);
// }
String
commodity1
=
ByteBufferUtils
.
bytesToHexString
(
byteBuffer
,
commodity1Length
);
for
(
int
pos
=
152
;
pos
>
0
;
pos
--)
{
commodity
.
setCommodity1
(
commodity1
);
printer
.
i
(
"pos:"
+
pos
);
int
commodity2Start
=
byteBuffer
.
get
();
byteBuffer
.
position
(
pos
);
if
(
commodity2Start
==
13
)
{
int
commodity1Start
=
byteBuffer
.
get
();
int
commodity2Font
=
ByteBufferUtils
.
bytesToInt
(
byteBuffer
);
printer
.
i
(
"commodity1Start= "
+
commodity1Start
);
System
.
out
.
println
(
"commodity2Font:"
+
commodity2Font
);
if
(
commodity1Start
==
3
)
{
int
commodity2Length
=
ByteBufferUtils
.
bytesToInt
(
byteBuffer
);
getCommodity
(
byteBuffer
,
commodity
);
String
commodity2
=
ByteBufferUtils
.
bytesToHexString
(
byteBuffer
,
commodity2Length
);
byteBuffer
.
position
(
pos
-
104
);
commodity
.
setCommodity2
(
commodity2
);
int
traceabilityFlag
=
ByteBufferUtils
.
bytesToInt
(
byteBuffer
);
int
commodity3Start
=
byteBuffer
.
get
();
int
traceabilityNo
=
ByteBufferUtils
.
bytesToInteger
(
byteBuffer
,
2
);
if
(
commodity3Start
==
13
)
{
printer
.
d
(
"追溯码开关"
+
traceabilityFlag
+
",追溯码内容"
+
traceabilityNo
);
int
commodity3Font
=
ByteBufferUtils
.
bytesToInt
(
byteBuffer
);
break
;
System
.
out
.
println
(
"commodity3Font:"
+
commodity3Font
);
int
commodity3Length
=
ByteBufferUtils
.
bytesToInt
(
byteBuffer
);
String
commodity3
=
ByteBufferUtils
.
bytesToHexString
(
byteBuffer
,
commodity3Length
);
commodity
.
setCommodity3
(
commodity3
);
byte
commodity4Start
=
byteBuffer
.
get
();
if
(
commodity4Start
==
13
)
{
int
commodity4Font
=
ByteBufferUtils
.
bytesToInt
(
byteBuffer
);
System
.
out
.
println
(
"commodity4Font:"
+
commodity4Font
);
int
commodity4Length
=
ByteBufferUtils
.
bytesToInt
(
byteBuffer
);
String
commodity4
=
ByteBufferUtils
.
bytesToHexString
(
byteBuffer
,
commodity4Length
);
commodity
.
setCommodity4
(
commodity4
);
byte
ingredient1Start
=
byteBuffer
.
get
();
if
(
ingredient1Start
==
12
)
{
getIngredient
(
byteBuffer
,
commodity
);
}
}
else
{
getIngredient
(
byteBuffer
,
commodity
);
}
}
else
{
getIngredient
(
byteBuffer
,
commodity
);
}
}
else
if
(
commodity1Start
==
12
)
{
getIngredient
(
byteBuffer
,
commodity
);
}
}
}
}
// else {
// byteBuffer.position(150);
// commodity1Start = byteBuffer.get();
// if (commodity1Start == 3) {
// getCommodity(byteBuffer, commodity);
// }else {
// byteBuffer.position(148);
// commodity1Start = byteBuffer.get();
// if (commodity1Start == 3) {
// getCommodity(byteBuffer, commodity);
// }
// }
// }
downPlu
(
commodity
);
downPlu
(
commodity
);
...
@@ -161,10 +147,10 @@ public abstract class ScalesApiHandler implements ObjectHandler {
...
@@ -161,10 +147,10 @@ public abstract class ScalesApiHandler implements ObjectHandler {
break
;
break
;
case
(
byte
)
176
:
case
(
byte
)
176
:
byteBuffer
.
position
(
12
);
byteBuffer
.
position
(
12
);
int
i
=
byteBuffer
.
array
().
length
-
1
-
12
;
int
i
=
byteBuffer
.
array
().
length
-
1
-
12
;
byte
[]
bytes
=
new
byte
[
i
];
byte
[]
bytes
=
new
byte
[
i
];
byteBuffer
.
get
(
bytes
);
byteBuffer
.
get
(
bytes
);
String
s
=
new
String
(
byteArray
,
"GBK"
);
String
s
=
new
String
(
byteArray
,
"GBK"
);
System
.
out
.
println
(
s
);
System
.
out
.
println
(
s
);
byte
[]
bytes4
=
new
byte
[
1
];
byte
[]
bytes4
=
new
byte
[
1
];
...
@@ -190,9 +176,54 @@ public abstract class ScalesApiHandler implements ObjectHandler {
...
@@ -190,9 +176,54 @@ public abstract class ScalesApiHandler implements ObjectHandler {
}
}
private
void
getCommodity
(
ByteBuffer
byteBuffer
,
Commodity
commodity
)
throws
UnsupportedEncodingException
{
int
commodity1Font
=
ByteBufferUtils
.
bytesToInt
(
byteBuffer
);
printer
.
d
(
"commodity1Font:"
+
commodity1Font
);
int
commodity1Length
=
ByteBufferUtils
.
bytesToInt
(
byteBuffer
);
String
commodity1
=
ByteBufferUtils
.
bytesToHexString
(
byteBuffer
,
commodity1Length
);
commodity
.
setCommodity1
(
commodity1
);
int
commodity2Start
=
byteBuffer
.
get
();
if
(
commodity2Start
==
13
)
{
int
commodity2Font
=
ByteBufferUtils
.
bytesToInt
(
byteBuffer
);
// System.out.println("commodity2Font:" + commodity2Font);
int
commodity2Length
=
ByteBufferUtils
.
bytesToInt
(
byteBuffer
);
String
commodity2
=
ByteBufferUtils
.
bytesToHexString
(
byteBuffer
,
commodity2Length
);
commodity
.
setCommodity2
(
commodity2
);
int
commodity3Start
=
byteBuffer
.
get
();
if
(
commodity3Start
==
13
)
{
int
commodity3Font
=
ByteBufferUtils
.
bytesToInt
(
byteBuffer
);
// System.out.println("commodity3Font:" + commodity3Font);
int
commodity3Length
=
ByteBufferUtils
.
bytesToInt
(
byteBuffer
);
String
commodity3
=
ByteBufferUtils
.
bytesToHexString
(
byteBuffer
,
commodity3Length
);
commodity
.
setCommodity3
(
commodity3
);
byte
commodity4Start
=
byteBuffer
.
get
();
if
(
commodity4Start
==
13
)
{
int
commodity4Font
=
ByteBufferUtils
.
bytesToInt
(
byteBuffer
);
// System.out.println("commodity4Font:" + commodity4Font);
int
commodity4Length
=
ByteBufferUtils
.
bytesToInt
(
byteBuffer
);
String
commodity4
=
ByteBufferUtils
.
bytesToHexString
(
byteBuffer
,
commodity4Length
);
commodity
.
setCommodity4
(
commodity4
);
byte
ingredient1Start
=
byteBuffer
.
get
();
if
(
ingredient1Start
==
12
)
{
getIngredient
(
byteBuffer
,
commodity
);
}
}
else
{
getIngredient
(
byteBuffer
,
commodity
);
}
}
else
{
getIngredient
(
byteBuffer
,
commodity
);
}
}
else
if
(
commodity2Start
==
12
)
{
getIngredient
(
byteBuffer
,
commodity
);
}
}
private
void
getIngredient
(
ByteBuffer
byteBuffer
,
Commodity
commodity
)
throws
UnsupportedEncodingException
{
private
void
getIngredient
(
ByteBuffer
byteBuffer
,
Commodity
commodity
)
throws
UnsupportedEncodingException
{
int
Ingredient1Font
=
ByteBufferUtils
.
bytesToInt
(
byteBuffer
);
int
Ingredient1Font
=
ByteBufferUtils
.
bytesToInt
(
byteBuffer
);
System
.
out
.
println
(
"Ingredient1Font:"
+
Ingredient1Font
);
System
.
out
.
println
(
"Ingredient1Font:"
+
Ingredient1Font
);
if
(
Ingredient1Font
==
0
)
{
return
;
}
int
ingredient1Length
=
ByteBufferUtils
.
bytesToInt
(
byteBuffer
);
int
ingredient1Length
=
ByteBufferUtils
.
bytesToInt
(
byteBuffer
);
String
ingredient1
=
ByteBufferUtils
.
bytesToHexString
(
byteBuffer
,
ingredient1Length
);
String
ingredient1
=
ByteBufferUtils
.
bytesToHexString
(
byteBuffer
,
ingredient1Length
);
commodity
.
setIngredient1
(
ingredient1
);
commodity
.
setIngredient1
(
ingredient1
);
...
@@ -240,7 +271,10 @@ public abstract class ScalesApiHandler implements ObjectHandler {
...
@@ -240,7 +271,10 @@ public abstract class ScalesApiHandler implements ObjectHandler {
private
void
getSpecialMessage
(
ByteBuffer
byteBuffer
,
Commodity
commodity
)
throws
UnsupportedEncodingException
{
private
void
getSpecialMessage
(
ByteBuffer
byteBuffer
,
Commodity
commodity
)
throws
UnsupportedEncodingException
{
int
SpecialMessage1Font
=
ByteBufferUtils
.
bytesToInt
(
byteBuffer
);
int
SpecialMessage1Font
=
ByteBufferUtils
.
bytesToInt
(
byteBuffer
);
System
.
out
.
println
(
"SpecialMessage1Font:"
+
SpecialMessage1Font
);
printer
.
d
(
"SpecialMessage1Font:"
+
SpecialMessage1Font
);
if
(
SpecialMessage1Font
==
0
)
{
return
;
}
int
specialMessage1Length
=
ByteBufferUtils
.
bytesToInt
(
byteBuffer
);
int
specialMessage1Length
=
ByteBufferUtils
.
bytesToInt
(
byteBuffer
);
String
specialMessage1
=
ByteBufferUtils
.
bytesToHexString
(
byteBuffer
,
specialMessage1Length
);
String
specialMessage1
=
ByteBufferUtils
.
bytesToHexString
(
byteBuffer
,
specialMessage1Length
);
commodity
.
setSpecialMessage1
(
specialMessage1
);
commodity
.
setSpecialMessage1
(
specialMessage1
);
...
@@ -275,9 +309,10 @@ public abstract class ScalesApiHandler implements ObjectHandler {
...
@@ -275,9 +309,10 @@ public abstract class ScalesApiHandler implements ObjectHandler {
}
}
@Override
@Override
public
void
setSocket
(
Socket
socket
,
int
addressFour
)
{
public
void
setSocket
(
Socket
socket
,
int
addressFour
,
Printer
printer
)
{
this
.
socket
=
socket
;
this
.
socket
=
socket
;
this
.
addressFour
=
addressFour
;
this
.
addressFour
=
addressFour
;
this
.
printer
=
printer
;
}
}
@Override
@Override
...
...
This diff is collapsed.
Click to expand it.
app/build.gradle
View file @
393af7a8
...
@@ -39,6 +39,7 @@ dependencies {
...
@@ -39,6 +39,7 @@ dependencies {
implementation
project
(
path:
':Transfer'
)
implementation
project
(
path:
':Transfer'
)
implementation
files
(
'libs\\wintecscales.jar'
)
implementation
files
(
'libs\\wintecscales.jar'
)
implementation
project
(
path:
':DigiTransfer'
)
implementation
project
(
path:
':DigiTransfer'
)
implementation
files
(
'libs\\DigiTransfer_v1.0.3_sdk.jar'
)
testImplementation
'junit:junit:4.+'
testImplementation
'junit:junit:4.+'
androidTestImplementation
'androidx.test.ext:junit:1.1.1'
androidTestImplementation
'androidx.test.ext:junit:1.1.1'
androidTestImplementation
'androidx.test.espresso:espresso-core:3.2.0'
androidTestImplementation
'androidx.test.espresso:espresso-core:3.2.0'
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment