Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
Kivii.Client.SampleInbounds.V4.0
Project
Overview
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
陶然
Kivii.Client.SampleInbounds.V4.0
Commits
8f6ab6a0
Commit
8f6ab6a0
authored
Jul 18, 2023
by
任天宇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化交接客户端性能
parent
a61aed47
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
89 additions
and
28 deletions
+89
-28
FrmMain.Designer.cs
Src/FrmMain.Designer.cs
+1
-1
FrmMain.cs
Src/FrmMain.cs
+83
-22
AssemblyInfo.cs
Src/Properties/AssemblyInfo.cs
+2
-2
Reader.cs
Src/Reader/Reader.cs
+2
-2
Talker.cs
Src/Reader/Talker.cs
+1
-1
No files found.
Src/FrmMain.Designer.cs
View file @
8f6ab6a0
...
...
@@ -838,7 +838,7 @@
this
.
Controls
.
Add
(
this
.
plLeft
);
this
.
Icon
=
((
System
.
Drawing
.
Icon
)(
resources
.
GetObject
(
"$this.Icon"
)));
this
.
Name
=
"FrmMain"
;
this
.
Text
=
"样品入库交接客户端 1.
2(23.7.6
)"
;
this
.
Text
=
"样品入库交接客户端 1.
3(23.7.18
)"
;
this
.
Load
+=
new
System
.
EventHandler
(
this
.
FrmMain_Load
);
this
.
plLeft
.
ResumeLayout
(
false
);
this
.
gbInfo
.
ResumeLayout
(
false
);
...
...
Src/FrmMain.cs
View file @
8f6ab6a0
...
...
@@ -36,6 +36,8 @@ namespace Kivii.Client.SampleInbounds
private
InventoryBuffer
currentInventoryBuffer
;
private
string
defaultPort
=
"COM1"
;
private
int
defaultBaudrate
=
115200
;
private
int
loopTimes
=
10
;
//扫描循环次数设置,根据这个扫描次数 超过这个次数就停止
private
int
currentLoops
=
0
;
private
bool
isConnected
=
false
;
//盘存操作前,需要先设置工作天线,用于标识当前是否在执行盘存操作
...
...
@@ -58,6 +60,7 @@ namespace Kivii.Client.SampleInbounds
#
region
界面控件默认值
private
void
initControls
()
{
currentLoops
=
0
;
dgvSamples
.
AutoGenerateColumns
=
false
;
dgvRfidSamples
.
AutoGenerateColumns
=
false
;
_currentLocation
=
null
;
...
...
@@ -179,22 +182,14 @@ namespace Kivii.Client.SampleInbounds
private
bool
connectReader
()
{
reader
=
new
Reader
();
currentSetting
=
new
ReaderSetting
();
currentInventoryBuffer
=
new
InventoryBuffer
();
//设置回调方法
reader
.
AnalyCallback
=
AnalyData
;
reader
.
GetFrequencyRegion
(
currentSetting
.
btReadId
);
//reader.ReceiveCallback = ReceiveData;
//reader.SendCallback = SendData;
//reader.GetFrequencyRegion(currentSetting.btReadId);
Thread
.
Sleep
(
50
);
currentInventoryBuffer
.
ClearInventoryPar
();
currentInventoryBuffer
.
btRepeat
=
Convert
.
ToByte
(
1
);
//设置每条命令盘存次数 1次
currentInventoryBuffer
.
bLoopCustomizedSession
=
false
;
currentInventoryBuffer
.
lAntenna
.
Add
(
0x00
);
//设置天线1
currentInventoryBuffer
.
lAntenna
.
Add
(
0x01
);
//设置天线2
currentInventoryBuffer
.
lAntenna
.
Add
(
0x02
);
//设置天线3
currentInventoryBuffer
.
lAntenna
.
Add
(
0x03
);
//设置天线4
string
exception
=
string
.
Empty
;
//IPAddress ipAddress = IPAddress.Parse("192.168.10.110");
//int nPort = Convert.ToInt32("4001");
...
...
@@ -208,6 +203,15 @@ namespace Kivii.Client.SampleInbounds
}
else
{
currentSetting
=
new
ReaderSetting
();
currentInventoryBuffer
=
new
InventoryBuffer
();
currentInventoryBuffer
.
ClearInventoryPar
();
currentInventoryBuffer
.
btRepeat
=
Convert
.
ToByte
(
1
);
//设置每条命令盘存次数 1次
currentInventoryBuffer
.
bLoopCustomizedSession
=
false
;
currentInventoryBuffer
.
lAntenna
.
Add
(
0x00
);
//设置天线1
currentInventoryBuffer
.
lAntenna
.
Add
(
0x01
);
//设置天线2
currentInventoryBuffer
.
lAntenna
.
Add
(
0x02
);
//设置天线3
currentInventoryBuffer
.
lAntenna
.
Add
(
0x03
);
//设置天线4
isConnected
=
true
;
outputMessage
(
$"当前连接:
{
Environment
.
NewLine
}{
defaultPort
}
@
{
defaultBaudrate
}
"
);
return
true
;
...
...
@@ -215,13 +219,31 @@ namespace Kivii.Client.SampleInbounds
}
private
void
disConnectReader
()
{
isConnected
=
false
;
//处理串口断开连接读写器
if
(
reader
!=
null
)
reader
.
CloseCom
();
//if (reader != null) reader.SignOut();
if
(
reader
!=
null
)
{
reader
.
CloseCom
();
//reader.SignOut();
}
reader
=
null
;
isConnected
=
false
;
outputMessage
(
"断开连接"
)
;
return
;
}
private
void
ReceiveData
(
byte
[]
btAryReceiveData
)
{
string
strLog
=
ReaderExtension
.
ByteArrayToString
(
btAryReceiveData
,
0
,
btAryReceiveData
.
Length
);
outputMessage
(
strLog
);
}
private
void
SendData
(
byte
[]
btArySendData
)
{
string
strLog
=
ReaderExtension
.
ByteArrayToString
(
btArySendData
,
0
,
btArySendData
.
Length
);
outputMessage
(
strLog
);
}
public
void
AnalyData
(
MessageTran
msgTran
)
{
if
(
msgTran
.
PacketType
!=
0xA0
)
...
...
@@ -250,16 +272,34 @@ namespace Kivii.Client.SampleInbounds
case
0x89
:
//读取Epc
var
epc
=
ReaderExtension
.
ProcessInventoryReal
(
msgTran
,
reader
,
currentInventoryBuffer
,
currentSetting
);
//outputMessage($"0x89:[EPC:{epc}]", false, false);
if
(
epc
.
IsNullOrEmpty
())
return
;
if
(
epc
.
IsNullOrEmpty
())
{
return
;
}
if
(
_currentTotalEpcs
.
IsNullOrEmpty
())
_currentTotalEpcs
=
new
List
<
string
>();
if
(!
_currentTotalEpcs
.
Contains
(
epc
))
{
currentLoops
=
0
;
_currentTotalEpcs
.
Add
(
epc
);
samplePreAssigning
(
null
,
epc
);
}
else
{
currentLoops
++;
}
if
(
currentLoops
>
loopTimes
)
{
scanEpcs
(
_currentTotalEpcs
);
btnRealTimeInventory_Stop
();
//foreach (var item in _currentTotalEpcs)
//{
// samplePreAssigning(null, item);
//}
}
break
;
case
0x74
:
ReaderExtension
.
ProcessSetWorkAntenna
(
msgTran
,
reader
,
currentInventoryBuffer
,
currentSetting
,
m_bInventory
);
break
;
}
}
...
...
@@ -289,13 +329,14 @@ namespace Kivii.Client.SampleInbounds
{
m_bInventory
=
false
;
currentInventoryBuffer
.
bLoopInventory
=
false
;
Thread
.
Sleep
(
500
);
//在这边需要sleep,否则停止太快会影响循环过程出错
this
.
Invoke
(
new
Action
(
delegate
{
btnScanRfid
.
Text
=
"开始扫描"
;
btnScanRfid
.
BackColor
=
Color
.
PapayaWhip
;
btnScanRfid
.
ForeColor
=
Color
.
Chocolate
;
}));
Thread
.
Sleep
(
50
)
;
currentLoops
=
0
;
disConnectReader
();
outputMessage
(
"停止扫描"
);
return
;
...
...
@@ -740,12 +781,25 @@ namespace Kivii.Client.SampleInbounds
outputMessage
(
$"设置箱号请求失败,TID:
{
tid
}
,EPC:
{
epcKvid
}
,
{
ex
.
GetResponseStatus
().
Message
}
"
,
false
,
true
);
}
}
private
void
scanEpcs
(
List
<
string
>
epcs
)
{
var
th
=
KiviiContext
.
NewThread
(()
=>
{
foreach
(
var
item
in
epcs
)
{
samplePreAssigning
(
null
,
item
);
}
});
th
.
Start
();
}
private
void
samplePreAssigning
(
string
tid
=
null
,
string
epc
=
null
,
string
bizId
=
null
)
{
if
(
tid
.
IsNullOrEmpty
()
&&
bizId
.
IsNullOrEmpty
()
&&
epc
.
IsNullOrEmpty
())
return
;
if
(
_currentPackage
==
null
)
{
MessageBox
.
Show
(
"未获取当前箱号."
);
outputMessage
(
"未获取当前箱号."
,
false
,
true
);
return
;
}
if
(
_currentPackage
.
Status
!=
(
int
)
PackageStatus
.
Full
)
...
...
@@ -871,6 +925,8 @@ namespace Kivii.Client.SampleInbounds
dgvRfidSamples
.
DataSource
=
_currentScanSamples
;
}));
}
if
(
_currentScanSamples
.
IsNullOrEmpty
())
btnClearCurrentPackage_Click
(
null
,
null
);
//rtns.AddRange(resp.Results);
}
catch
(
Exception
ex
)
...
...
@@ -912,7 +968,7 @@ namespace Kivii.Client.SampleInbounds
}));
}
}
if
(
_currentScanSamples
.
IsNullOrEmpty
())
btnClearCurrentPackage_Click
(
null
,
null
);
}
catch
(
Exception
ex
)
{
...
...
@@ -986,6 +1042,8 @@ namespace Kivii.Client.SampleInbounds
MessageBox
.
Show
(
$"扫描到
{
notCurrentPackageKvids
.
Count
}
条已经入其他箱子的样品,无法交接到当前箱内,若想交接入当前箱内,请先撤销入箱后到此客户端重新扫描."
);
}
if
(
_currentScanSamples
.
IsNullOrEmpty
())
btnClearCurrentPackage_Click
(
null
,
null
);
}
#
endregion
...
...
@@ -1087,7 +1145,11 @@ namespace Kivii.Client.SampleInbounds
private
void
btnClearCurrentPackage_Click
(
object
sender
,
EventArgs
e
)
{
btnRealTimeInventory_Stop
();
if
(
isConnected
&&
reader
!=
null
)
{
if
(
currentInventoryBuffer
.
bLoopInventory
)
btnRealTimeInventory_Stop
();
}
currentLoops
=
0
;
this
.
Invoke
(
new
Action
(
delegate
{
dgvSamples
.
DataSource
=
null
;
...
...
@@ -1199,7 +1261,6 @@ namespace Kivii.Client.SampleInbounds
MessageBox
.
Show
(
"读写器未连接,请查看是否读写器设备!"
);
return
;
}
Thread
.
Sleep
(
50
);
}
if
(
currentInventoryBuffer
.
bLoopInventory
)
{
...
...
Src/Properties/AssemblyInfo.cs
View file @
8f6ab6a0
...
...
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("5.4.2023.7
06
0")]
[assembly: AssemblyFileVersion("5.4.2023.7
06
0")]
[assembly: AssemblyVersion("5.4.2023.7
18
0")]
[assembly: AssemblyFileVersion("5.4.2023.7
18
0")]
Src/Reader/Reader.cs
View file @
8f6ab6a0
...
...
@@ -116,7 +116,7 @@ namespace Readers
}
catch
(
System
.
Exception
ex
)
{
//throw ex;
}
}
...
...
@@ -188,7 +188,7 @@ namespace Readers
}
catch
(
System
.
Exception
ex
)
{
//throw ex;
}
}
...
...
Src/Reader/Talker.cs
View file @
8f6ab6a0
...
...
@@ -68,7 +68,7 @@ namespace Readers
}
catch
(
System
.
Exception
ex
)
{
//throw ex;
}
}
...
...
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