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
013d408b
Commit
013d408b
authored
Nov 16, 2022
by
tongzifang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.2.2
parent
eb25ae3d
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
16 additions
and
13 deletions
+16
-13
build.gradle
zqtoolkit/build.gradle
+1
-1
ScaleHub.kt
zqtoolkit/src/main/java/com/qmai/zqtoolkit/ScaleHub.kt
+2
-2
ScaleInfo.kt
zqtoolkit/src/main/java/com/qmai/zqtoolkit/ScaleInfo.kt
+1
-1
AclasScaleKit.kt
...it/src/main/java/com/qmai/zqtoolkit/base/AclasScaleKit.kt
+0
-2
ZqScaleKit.kt
...olkit/src/main/java/com/qmai/zqtoolkit/base/ZqScaleKit.kt
+2
-2
ScaleBaseKit.kt
...c/main/java/com/qmai/zqtoolkit/base/scale/ScaleBaseKit.kt
+10
-5
No files found.
zqtoolkit/build.gradle
View file @
013d408b
...
@@ -30,7 +30,7 @@ android {
...
@@ -30,7 +30,7 @@ android {
}
}
}
}
group
'com.qmai.android.zqtoolkit'
group
'com.qmai.android.zqtoolkit'
version
'1.2.
1.
2'
version
'1.2.2'
gradlePublish
{
gradlePublish
{
...
...
zqtoolkit/src/main/java/com/qmai/zqtoolkit/ScaleHub.kt
View file @
013d408b
...
@@ -175,10 +175,10 @@ object ScaleHub : ScaleBaseAction {
...
@@ -175,10 +175,10 @@ object ScaleHub : ScaleBaseAction {
weightJob
=
CoroutineScope
(
EmptyCoroutineContext
)
weightJob
=
CoroutineScope
(
EmptyCoroutineContext
)
}
}
connectJob
?.
launch
(
context
=
Dispatchers
.
IO
)
{
weightJob
?.
launch
(
context
=
Dispatchers
.
IO
)
{
scaleKit
?.
readData
()
collectWeightData
()
collectWeightData
()
}
}
scaleKit
?.
readData
()
}
}
private
suspend
fun
collectWeightData
()
{
private
suspend
fun
collectWeightData
()
{
...
...
zqtoolkit/src/main/java/com/qmai/zqtoolkit/ScaleInfo.kt
View file @
013d408b
...
@@ -13,6 +13,6 @@ data class ScaleInfo(
...
@@ -13,6 +13,6 @@ data class ScaleInfo(
var
buad
:
String
?
=
null
,
var
buad
:
String
?
=
null
,
var
brand
:
QmScaleBrandValue
?
=
null
,
var
brand
:
QmScaleBrandValue
?
=
null
,
var
model
:
QmScaleModelValue
?
=
null
,
var
model
:
QmScaleModelValue
?
=
null
,
var
connectType
:
Int
?
,
var
connectType
:
Int
?
=
1
,
// connectType 0串口 1usb
var
appType
:
Int
?
=
SHOP_ASSITANT_2C
var
appType
:
Int
?
=
SHOP_ASSITANT_2C
)
)
\ No newline at end of file
zqtoolkit/src/main/java/com/qmai/zqtoolkit/base/AclasScaleKit.kt
View file @
013d408b
...
@@ -43,7 +43,6 @@ object AclasScaleKit : ScaleBaseKit() {
...
@@ -43,7 +43,6 @@ object AclasScaleKit : ScaleBaseKit() {
override
fun
onRcvData
(
weght
:
AclasScaler
.
WeightInfoNew
?)
{
override
fun
onRcvData
(
weght
:
AclasScaler
.
WeightInfoNew
?)
{
updateScaleInfo
(
"$TAG :onRcvData "
+
TimeUtils
.
getNowString
()
+
" data: "
+
GsonUtils
.
toJson
(
weght
))
updateScaleInfo
(
"$TAG :onRcvData "
+
TimeUtils
.
getNowString
()
+
" data: "
+
GsonUtils
.
toJson
(
weght
))
Log
.
v
(
TAG
,
GsonUtils
.
toJson
(
weght
))
// getTare()
// getTare()
updateWeight
(
updateWeight
(
LivingWeight
(
LivingWeight
(
...
@@ -55,7 +54,6 @@ object AclasScaleKit : ScaleBaseKit() {
...
@@ -55,7 +54,6 @@ object AclasScaleKit : ScaleBaseKit() {
override
fun
onError
(
p0
:
Int
,
p1
:
String
?)
{
override
fun
onError
(
p0
:
Int
,
p1
:
String
?)
{
updateScaleInfo
(
"$TAG :onError "
+
TimeUtils
.
getNowString
()
+
" data: p0"
+
p0
+
" p1"
+
p1
)
updateScaleInfo
(
"$TAG :onError "
+
TimeUtils
.
getNowString
()
+
" data: p0"
+
p0
+
" p1"
+
p1
)
Log
.
v
(
TAG
,
"onError:$p0$p1"
)
}
}
override
fun
onUpdateProcess
(
p0
:
Int
,
p1
:
Int
)
{
override
fun
onUpdateProcess
(
p0
:
Int
,
p1
:
Int
)
{
...
...
zqtoolkit/src/main/java/com/qmai/zqtoolkit/base/ZqScaleKit.kt
View file @
013d408b
...
@@ -24,7 +24,7 @@ object ZqScaleKit : ScaleBaseKit() {
...
@@ -24,7 +24,7 @@ object ZqScaleKit : ScaleBaseKit() {
override
val
TAG
:
String
override
val
TAG
:
String
get
()
=
"ZqScaleKit"
get
()
=
"ZqScaleKit"
override
val
STABLE_COUNT
:
Int
override
val
STABLE_COUNT
:
Int
get
()
=
4
get
()
=
8
override
val
CONECT_CHECK_COUNT
:
Int
override
val
CONECT_CHECK_COUNT
:
Int
get
()
=
4
get
()
=
4
override
val
SCALE_TYPE
:
QmScaleBrand
override
val
SCALE_TYPE
:
QmScaleBrand
...
@@ -132,7 +132,7 @@ object ZqScaleKit : ScaleBaseKit() {
...
@@ -132,7 +132,7 @@ object ZqScaleKit : ScaleBaseKit() {
private
val
weightFlow
=
flow
{
private
val
weightFlow
=
flow
{
while
(
true
)
{
while
(
true
)
{
emit
(
Unit
)
emit
(
Unit
)
delay
(
8
0
)
delay
(
10
0
)
}
}
}
}
...
...
zqtoolkit/src/main/java/com/qmai/zqtoolkit/base/scale/ScaleBaseKit.kt
View file @
013d408b
package
com.qmai.zqtoolkit.base.scale
package
com.qmai.zqtoolkit.base.scale
import
android.content.Context
import
android.content.Context
import
android.util.Log
import
com.blankj.utilcode.util.GsonUtils
import
com.qmai.zqtoolkit.ConnectState
import
com.qmai.zqtoolkit.ConnectState
import
com.qmai.zqtoolkit.LivingWeight
import
com.qmai.zqtoolkit.LivingWeight
import
com.qmai.zqtoolkit.ScaleInfo
import
com.qmai.zqtoolkit.ScaleInfo
...
@@ -35,7 +37,7 @@ abstract class ScaleBaseKit : ScaleBaseAction, ScaleUpdateAction {
...
@@ -35,7 +37,7 @@ abstract class ScaleBaseKit : ScaleBaseAction, ScaleUpdateAction {
val
_scaleLog
=
MutableSharedFlow
<
String
>()
val
_scaleLog
=
MutableSharedFlow
<
String
>()
val
scaleLog
:
SharedFlow
<
String
>
=
_scaleLog
val
scaleLog
:
SharedFlow
<
String
>
=
_scaleLog
private
var
stableWeight
=
mutableListOf
<
String
>()
private
var
stableWeight
=
mutableListOf
<
LivingWeight
>()
var
connectCache
=
mutableListOf
<
Boolean
>()
var
connectCache
=
mutableListOf
<
Boolean
>()
...
@@ -71,24 +73,27 @@ abstract class ScaleBaseKit : ScaleBaseAction, ScaleUpdateAction {
...
@@ -71,24 +73,27 @@ abstract class ScaleBaseKit : ScaleBaseAction, ScaleUpdateAction {
}
}
override
fun
updateWeight
(
weight
:
LivingWeight
)
{
override
fun
updateWeight
(
weight
:
LivingWeight
)
{
GlobalScope
.
launch
(
context
=
Dispatchers
.
IO
)
{
GlobalScope
.
launch
{
//稳定状态且读数正常
//稳定状态且读数正常
if
(
weight
.
isStable
&&
!
weight
.
isReadErr
)
{
if
(
weight
.
isStable
&&
!
weight
.
isReadErr
)
{
readErrCache
.
clear
()
readErrCache
.
clear
()
when
{
when
{
stableWeight
.
size
==
STABLE_COUNT
->
{
stableWeight
.
size
==
STABLE_COUNT
->
{
if
(
stableWeight
.
toSet
().
size
==
1
)
{
var
single
=
stableWeight
.
distinctBy
{
it
.
weight
}
if
(
single
.
size
==
1
)
{
//给业务的unit要小写
//给业务的unit要小写
if
(
weight
.
unit
.
isNotEmpty
())
if
(
weight
.
unit
.
isNotEmpty
())
weight
.
unit
=
weight
.
unit
.
lowercase
()
weight
.
unit
=
weight
.
unit
.
lowercase
()
_livingWeight
.
emit
(
weight
)
single
.
firstOrNull
()
?.
let
{
_livingWeight
.
emit
(
it
)
}
}
}
stableWeight
.
clear
()
stableWeight
.
clear
()
}
}
stableWeight
.
size
>
STABLE_COUNT
->
{
stableWeight
.
size
>
STABLE_COUNT
->
{
stableWeight
.
clear
()
stableWeight
.
clear
()
}
}
else
->
stableWeight
.
add
(
weight
.
weight
)
else
->
stableWeight
.
add
(
weight
)
}
}
}
else
{
}
else
{
_livingWeight
.
emit
(
weight
)
_livingWeight
.
emit
(
weight
)
...
...
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