Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
Widget
Project
Project
Details
Activity
Releases
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
Android Widget
Widget
Commits
0e9173a4
Commit
0e9173a4
authored
Nov 21, 2022
by
王雷
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
适配巨隆秤,用顶尖的sdk 串口连接方式 发布v1.2.1.2
parent
e1761822
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
165 additions
and
5 deletions
+165
-5
build.gradle
zqtoolkit/build.gradle
+1
-1
ScaleHub.kt
zqtoolkit/src/main/java/com/qmai/zqtoolkit/ScaleHub.kt
+9
-0
GiLongScaleKit.kt
...t/src/main/java/com/qmai/zqtoolkit/base/GiLongScaleKit.kt
+152
-0
QmScaleBrand.kt
...t/src/main/java/com/qmai/zqtoolkit/config/QmScaleBrand.kt
+3
-4
No files found.
zqtoolkit/build.gradle
View file @
0e9173a4
...
...
@@ -30,7 +30,7 @@ android {
}
}
group
'com.qmai.android.zqtoolkit'
version
'1.2.1'
version
'1.2.1
.2
'
gradlePublish
{
...
...
zqtoolkit/src/main/java/com/qmai/zqtoolkit/ScaleHub.kt
View file @
0e9173a4
package
com.qmai.zqtoolkit
import
android.content.Context
import
android.os.Build
import
com.qmai.zqtoolkit.base.AclasScaleKit
import
com.qmai.zqtoolkit.base.GiLongScaleKit
import
com.qmai.zqtoolkit.base.SunmiScaleKit
import
com.qmai.zqtoolkit.base.ZqScaleKit
import
com.qmai.zqtoolkit.base.scale.ScaleBaseAction
...
...
@@ -15,6 +17,7 @@ import kotlinx.coroutines.flow.MutableSharedFlow
import
kotlinx.coroutines.flow.SharedFlow
import
kotlinx.coroutines.flow.collect
import
kotlinx.coroutines.launch
import
java.util.*
import
kotlin.coroutines.EmptyCoroutineContext
/**
...
...
@@ -46,6 +49,7 @@ object ScaleHub : ScaleBaseAction {
QmScaleBrand
.
ZQEB
.
brand
->
ZqScaleKit
QmScaleBrand
.
SUNMI
.
brand
->
SunmiScaleKit
QmScaleBrand
.
ACLAS
.
brand
->
AclasScaleKit
QmScaleBrand
.
GILONG
.
brand
->
GiLongScaleKit
else
->
null
}
}
...
...
@@ -73,6 +77,7 @@ object ScaleHub : ScaleBaseAction {
QmScaleBrand
.
ZQEB
.
brand
->
ZqScaleKit
QmScaleBrand
.
SUNMI
.
brand
->
SunmiScaleKit
QmScaleBrand
.
ACLAS
.
brand
->
AclasScaleKit
QmScaleBrand
.
GILONG
.
brand
->
GiLongScaleKit
else
->
null
}
}
...
...
@@ -96,6 +101,10 @@ object ScaleHub : ScaleBaseAction {
scale
.
run
{
port
=
if
(
scale
.
appType
==
SHOP_ASSITANT_2B
&&
ScaleChecker
.
isSUNMI
())
SunmiPort
.
find
()
//如果是GILONG (巨隆)
else
if
(
Build
.
MODEL
==
"rk3288"
){
"ttyS1"
}
else
"ttyS4"
buad
=
"9600"
}
...
...
zqtoolkit/src/main/java/com/qmai/zqtoolkit/base/GiLongScaleKit.kt
0 → 100644
View file @
0e9173a4
package
com.qmai.zqtoolkit.base
import
android.content.Context
import
android.util.Log
import
com.blankj.utilcode.util.GsonUtils
import
com.blankj.utilcode.util.TimeUtils
import
com.example.scaler.AclasScaler
import
com.example.scaler.AclasScaler.AclasScalerListener
import
com.qmai.zqtoolkit.ConnectState
import
com.qmai.zqtoolkit.LivingWeight
import
com.qmai.zqtoolkit.ScaleInfo
import
com.qmai.zqtoolkit.base.scale.ScaleBaseKit
import
com.qmai.zqtoolkit.config.QmScaleBrand
import
com.qmai.zqtoolkit.utils.ScaleChecker
/**
* 巨隆秤
* 用顶尖的sdk 串口连接方式
*/
object
GiLongScaleKit
:
ScaleBaseKit
()
{
override
val
TAG
:
String
get
()
=
"AclasScaleKit"
override
val
STABLE_COUNT
:
Int
get
()
=
4
override
val
CONECT_CHECK_COUNT
:
Int
get
()
=
0
override
val
SCALE_TYPE
:
QmScaleBrand
get
()
=
QmScaleBrand
.
GILONG
private
var
aclasScaler
:
AclasScaler
?
=
null
private
var
aclasScalerListener
=
object
:
AclasScalerListener
{
override
fun
onDisConnected
()
{
updateState
(
ConnectState
(
false
,
"打开失败"
))
}
override
fun
onConnected
()
{
updateState
(
ConnectState
(
true
,
"打开成功"
))
}
override
fun
onRcvData
(
weght
:
AclasScaler
.
WeightInfoNew
?)
{
Log
.
v
(
TAG
,
GsonUtils
.
toJson
(
weght
))
// getTare()
updateWeight
(
LivingWeight
(
weght
?.
isStable
?:
false
,
weght
.
toString
().
replace
(
weght
?.
unit
?:
""
,
""
),
weght
?.
unit
?:
""
,
weght
?.
tareWeight
?.
toString
()
?:
""
,
weght
?.
netWeight
==
null
)
)
}
override
fun
onError
(
p0
:
Int
,
p1
:
String
?)
{
Log
.
v
(
TAG
,
"onError:$p0$p1"
)
}
override
fun
onUpdateProcess
(
p0
:
Int
,
p1
:
Int
)
{
Log
.
v
(
TAG
,
"onUpdateProcess:$p0$p1"
)
}
}
override
fun
connect
(
cxt
:
Context
?,
scale
:
ScaleInfo
)
{
super
.
connect
(
cxt
,
scale
)
if
(
aclasScaler
==
null
)
{
cxt
?.
let
{
aclasScaler
=
AclasScaler
(
AclasScaler
.
Type_SerialPort
,
it
,
aclasScalerListener
)
}
}
//val usbConnectIndex = getAclasScaleIndex()
//val usbConnectIndex = 0
val
aclasConnect
=
aclasScaler
?.
AclasConnect
(
"/dev/${scale.port}"
,
(
scale
.
buad
?.
toIntOrNull
()
?:
9600
),
0
)
Log
.
v
(
TAG
,
"aclasConnect:$aclasConnect"
)
}
override
fun
disconnect
()
{
super
.
disconnect
()
aclasScaler
?.
AclasDisconnect
()
aclasScaler
=
null
}
override
fun
readData
()
{
}
override
fun
stopReadData
()
{
}
override
fun
setZero
()
{
if
(
isScaleSuccess
())
{
val
aclasZero
=
aclasScaler
?.
AclasZero
()
Log
.
v
(
TAG
,
"setZero:$aclasZero"
)
}
}
private
fun
getTare
()
{
if
(
isScaleSuccess
())
{
val
getTare
=
aclasScaler
?.
AclasReadTareValue
()
Log
.
v
(
TAG
,
"getTare:$getTare"
)
}
}
override
fun
setNetWeight
()
{
if
(
isScaleSuccess
())
{
val
aclasTare
=
aclasScaler
?.
AclasTare
()
Log
.
v
(
TAG
,
"setNetWeight:$aclasTare"
)
}
}
override
fun
setNetWeightByElec
(
tare
:
Double
)
{
if
(
isScaleSuccess
())
{
val
aclasSetPreTare
=
aclasScaler
?.
AclasSetPreTare
((
tare
*
1000.0f
).
toInt
())
Log
.
v
(
TAG
,
"setNetWeightByElec:$aclasSetPreTare"
)
}
}
//去除 除皮一个方法
override
fun
clearTare
()
{
if
(
isScaleSuccess
())
{
val
clearTare
=
aclasScaler
?.
AclasTare
()
Log
.
v
(
TAG
,
"clearTare:$clearTare"
)
}
}
override
fun
getParameter
():
Array
<
String
>
{
var
parameter
:
Array
<
String
>
=
arrayOf
()
if
(
isScaleSuccess
())
{
parameter
[
0
]
=
aclasScaler
?.
AclasSDKVersion
()
?:
""
parameter
[
1
]
=
aclasScaler
?.
AclasReadVersion
()
?:
""
parameter
[
2
]
=
aclasScaler
?.
AclasReadId
()
?:
""
}
return
parameter
}
override
fun
isScaleSuccess
():
Boolean
{
return
super
.
isScaleSuccess
()
&&
aclasScaler
?.
AclasIsConnect
()
==
true
}
private
fun
getAclasScaleIndex
():
Int
{
var
usbIndex
=
0
var
aclasPname
=
ScaleChecker
.
getAclasPname
()
if
(
aclasPname
.
isNotEmpty
())
{
var
comList
=
mutableListOf
<
String
>()
aclasScaler
?.
getCommList
(
comList
)
if
(!
comList
.
isNullOrEmpty
())
{
usbIndex
=
comList
.
indexOfFirst
{
name
->
name
.
contains
(
aclasPname
)
}
return
usbIndex
}
}
return
usbIndex
}
}
\ No newline at end of file
zqtoolkit/src/main/java/com/qmai/zqtoolkit/config/QmScaleBrand.kt
View file @
0e9173a4
...
...
@@ -7,8 +7,7 @@ package com.qmai.zqtoolkit.config
enum
class
QmScaleBrand
(
val
brand
:
String
,
)
{
SUNMI
(
"商米"
),
ZQEB
(
"中崎"
),
ACLAS
(
"顶尖"
);
SUNMI
(
"商米"
),
ZQEB
(
"中崎"
),
ACLAS
(
"顶尖"
),
GILONG
(
"巨隆"
);
companion
object
{
fun
list
():
List
<
QmScaleBrandValue
>
{
return
values
().
map
{
QmScaleBrandValue
(
it
)
}
...
...
@@ -31,8 +30,8 @@ enum class QmScaleModel(
OX2X
(
"OX2X"
,
QmScaleBrand
.
ACLAS
.
brand
),
PX1
(
"PX1"
,
QmScaleBrand
.
ACLAS
.
brand
),
DEFAULT_SUNMI
(
"商米通用"
,
QmScaleBrand
.
SUNMI
.
brand
),
S2_CC
(
"S2_CC"
,
QmScaleBrand
.
SUNMI
.
brand
)
;
S2_CC
(
"S2_CC"
,
QmScaleBrand
.
SUNMI
.
brand
)
,
DEFAULT_GILONG
(
"巨隆通用"
,
QmScaleBrand
.
GILONG
.
brand
);
companion
object
{
fun
list
(
sort
:
QmScaleBrandValue
):
List
<
QmScaleModelValue
>
{
return
values
().
filter
{
...
...
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