Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
RC1250-ACPackingStore
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit ccb39bb3
由
LN
编写于
2020-02-16 11:07:26 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
rfid修改
1 个父辈
d2c26239
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
67 行增加
和
47 行删除
source/ACPackingStore/FrmRFIPEdit.cs
source/ACPackingStore/FrmStore.cs
source/DeviceLibrary/device/RFID/RFIDAuto.cs
source/DeviceLibrary/device/RFID/RFIDAutoReader.cs
source/DeviceLibrary/device/RFID/RFIDManager.cs
source/ACPackingStore/FrmRFIPEdit.cs
查看文件 @
ccb39bb
...
@@ -16,9 +16,9 @@ using System.Windows.Forms;
...
@@ -16,9 +16,9 @@ using System.Windows.Forms;
namespace
OnlineStore.ACPackingStore
namespace
OnlineStore.ACPackingStore
{
{
internal
partial
class
FrmRFIPEdit
:
FrmBase
internal
partial
class
FrmRFIPEdit
:
FrmBase
{
{
internal
FrmRFIPEdit
(
)
internal
FrmRFIPEdit
()
{
{
InitializeComponent
();
InitializeComponent
();
}
}
private
Dictionary
<
string
,
string
>
rfMap
=
new
Dictionary
<
string
,
string
>();
private
Dictionary
<
string
,
string
>
rfMap
=
new
Dictionary
<
string
,
string
>();
...
@@ -32,7 +32,7 @@ namespace OnlineStore.ACPackingStore
...
@@ -32,7 +32,7 @@ namespace OnlineStore.ACPackingStore
rfMap
.
Add
(
key
,
value
);
rfMap
.
Add
(
key
,
value
);
comboxType
.
Items
.
Add
(
key
);
comboxType
.
Items
.
Add
(
key
);
}
}
comboxType
.
SelectedIndex
=
0
;
comboxType
.
SelectedIndex
=
0
;
comType
.
SelectedIndex
=
0
;
comType
.
SelectedIndex
=
0
;
...
@@ -41,13 +41,9 @@ namespace OnlineStore.ACPackingStore
...
@@ -41,13 +41,9 @@ namespace OnlineStore.ACPackingStore
if
(
StoreManager
.
Store
.
storeRunStatus
<=
StoreRunStatus
.
Wait
)
if
(
StoreManager
.
Store
.
storeRunStatus
<=
StoreRunStatus
.
Wait
)
{
{
Task
.
Factory
.
StartNew
(
delegate
RFIDManager
.
Open
(
List
.
ToArray
());
{
LogUtil
.
info
(
Name
+
"RFIDManager.Open"
);
RFIDManager
.
Open
(
List
.
ToArray
());
});
}
}
}
}
private
void
btnBack_Click
(
object
sender
,
EventArgs
e
)
private
void
btnBack_Click
(
object
sender
,
EventArgs
e
)
{
{
...
@@ -73,7 +69,7 @@ namespace OnlineStore.ACPackingStore
...
@@ -73,7 +69,7 @@ namespace OnlineStore.ACPackingStore
}
}
lblResult
.
Text
=
resul
;
lblResult
.
Text
=
resul
;
MessageBox
.
Show
(
"读取到数据:"
+
resul
);
MessageBox
.
Show
(
"读取到数据:"
+
resul
);
}
}
private
void
comboxType_SelectedIndexChanged
(
object
sender
,
EventArgs
e
)
private
void
comboxType_SelectedIndexChanged
(
object
sender
,
EventArgs
e
)
...
@@ -91,11 +87,7 @@ namespace OnlineStore.ACPackingStore
...
@@ -91,11 +87,7 @@ namespace OnlineStore.ACPackingStore
{
{
if
(
StoreManager
.
Store
.
storeRunStatus
<=
StoreRunStatus
.
Wait
)
if
(
StoreManager
.
Store
.
storeRunStatus
<=
StoreRunStatus
.
Wait
)
{
{
Task
.
Factory
.
StartNew
(
delegate
RFIDManager
.
Close
();
{
LogUtil
.
info
(
Name
+
"RFIDManager.Close"
);
RFIDManager
.
Close
();
});
}
}
}
}
}
}
...
...
source/ACPackingStore/FrmStore.cs
查看文件 @
ccb39bb
...
@@ -234,15 +234,20 @@ namespace OnlineStore.ACPackingStore
...
@@ -234,15 +234,20 @@ namespace OnlineStore.ACPackingStore
return
;
return
;
}
}
LogUtil
.
info
(
LOGGER
,
"开始启动"
);
LogUtil
.
info
(
LOGGER
,
"开始启动"
);
startTimer
.
Interval
=
1
;
startTimer
.
Interval
=
300
;
startTimer
.
Elapsed
+=
timer_Elapsed
;
startTimer
.
Elapsed
+=
timer_Elapsed
;
startTimer
.
AutoReset
=
false
;
startTimer
.
AutoReset
=
false
;
startTimer
.
Enabled
=
true
;
startTimer
.
Enabled
=
true
;
}
}
private
delegate
void
ShowFormDelegate
();
private
delegate
void
ShowFormDelegate
();
void
timer_Elapsed
(
object
sender
,
System
.
Timers
.
ElapsedEventArgs
e
)
void
timer_Elapsed
(
object
sender
,
System
.
Timers
.
ElapsedEventArgs
e
)
{
{
startTimer
.
Enabled
=
false
;
startTimer
.
Enabled
=
false
;
if
(
store
.
storeRunStatus
>
StoreRunStatus
.
Wait
)
{
return
;
}
if
(
store
.
StartRun
())
if
(
store
.
StartRun
())
{
{
BeginInvoke
(
new
ShowFormDelegate
(
ShowStatus
));
BeginInvoke
(
new
ShowFormDelegate
(
ShowStatus
));
...
...
source/DeviceLibrary/device/RFID/RFIDAuto.cs
查看文件 @
ccb39bb
using
log4net
;
using
log4net
;
using
OnlineStore.Common
;
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Linq
;
using
System.Text
;
using
System.Text
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
namespace
Asa.RFID
namespace
Asa.RFID
{
{
public
class
RFIDAuto
public
class
RFIDAuto
{
{
public
static
readonly
ILog
LOGGER
=
LogManager
.
GetLogger
(
"TheRFID"
);
public
static
readonly
ILog
LOGGER
=
LogManager
.
GetLogger
(
"TheRFID"
);
...
@@ -57,14 +60,15 @@ namespace Asa.RFID
...
@@ -57,14 +60,15 @@ namespace Asa.RFID
{
{
if
(
IsConnect
)
if
(
IsConnect
)
{
{
LOGGER
.
Warn
(
" RFID ["
+
IP
+
"] is already connected, no need to start again"
);
LOGGER
.
Warn
(
" RFID ["
+
IP
+
"] is already connected, no need to start again"
);
return
0
;
return
0
;
}
}
this
.
Received
=
OnReceive
;
this
.
Received
=
OnReceive
;
//IP合法
//IP合法
string
pattern
=
@"^((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)$"
;
string
pattern
=
@"^((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)$"
;
bool
rtn
=
System
.
Text
.
RegularExpressions
.
Regex
.
IsMatch
(
IP
,
pattern
);
bool
rtn
=
System
.
Text
.
RegularExpressions
.
Regex
.
IsMatch
(
IP
,
pattern
);
if
(!
rtn
)
{
if
(!
rtn
)
{
LOGGER
.
Error
(
IP
+
" is error"
);
LOGGER
.
Error
(
IP
+
" is error"
);
return
-
1
;
return
-
1
;
}
}
...
@@ -79,15 +83,26 @@ namespace Asa.RFID
...
@@ -79,15 +83,26 @@ namespace Asa.RFID
int
port
=
6000
+
Convert
.
ToInt32
(
arr
[
3
]);
int
port
=
6000
+
Convert
.
ToInt32
(
arr
[
3
]);
portIndex
=
0
;
portIndex
=
0
;
int
ErrCode
=
ReaderA
.
StaticClassReaderA
.
OpenNetPort
(
port
,
IP
,
ref
addr
,
ref
portIndex
);
int
ErrCode
=
0
;
LOGGER
.
Info
(
"Connect ["
+
IP
+
"] :"
+
ErrCode
);
for
(
int
i
=
1
;
i
<=
3
;
i
++)
if
(
ErrCode
==
0
)
{
{
ErrCode
=
OpenAutoScanMode
(
addr
);
ErrCode
=
ReaderA
.
StaticClassReaderA
.
OpenNetPort
(
port
,
IP
,
ref
addr
,
ref
portIndex
);
LOGGER
.
Info
(
" ["
+
IP
+
"] Open Auto Scan Mode:"
+
ErrCode
);
LOGGER
.
Info
(
"Connect ["
+
IP
+
"] ["
+
i
+
"] :"
+
ErrCode
);
Task
.
Factory
.
StartNew
(
AutoScan
);
if
(
ErrCode
==
0
)
{
ErrCode
=
OpenAutoScanMode
(
addr
);
LOGGER
.
Info
(
" ["
+
IP
+
"] Open Auto Scan Mode:"
+
ErrCode
);
Task
.
Factory
.
StartNew
(
AutoScan
);
break
;
}
else
{
StopAutoScan
();
}
Thread
.
Sleep
(
10
);
}
}
return
ErrCode
;
return
ErrCode
;
}
}
private
int
SetAutoScanMode
(
byte
addr
,
byte
scanMode
)
private
int
SetAutoScanMode
(
byte
addr
,
byte
scanMode
)
...
@@ -238,7 +253,7 @@ namespace Asa.RFID
...
@@ -238,7 +253,7 @@ namespace Asa.RFID
else
if
(
ErrCode
==
14
&&
IsConnect
)
else
if
(
ErrCode
==
14
&&
IsConnect
)
{
{
LOGGER
.
Error
(
IP
+
" Receive Code: "
+
ErrCode
+
" 进行重连"
);
LOGGER
.
Error
(
IP
+
" Receive Code: "
+
ErrCode
+
" 进行重连"
);
//
LogUtil.error(IP + " Receive Code: " + ErrCode + " 进行重连");
LogUtil
.
error
(
IP
+
" Receive Code: "
+
ErrCode
+
" 进行重连"
);
StopAutoScan
();
StopAutoScan
();
StartAutoScan
(
this
.
Received
);
StartAutoScan
(
this
.
Received
);
break
;
break
;
...
@@ -267,7 +282,7 @@ namespace Asa.RFID
...
@@ -267,7 +282,7 @@ namespace Asa.RFID
{
{
byte
[]
data
=
lastData
;
byte
[]
data
=
lastData
;
lastData
=
new
byte
[
8
];
lastData
=
new
byte
[
8
];
LOGGER
.
Info
(
"Read and clear RFID["
+
IP
+
"] data:"
+
byteToStr
(
data
,
data
.
Length
));
LOGGER
.
Debug
(
"Read and clear RFID["
+
IP
+
"] data:"
+
byteToStr
(
data
,
data
.
Length
));
return
data
;
return
data
;
}
}
...
@@ -281,7 +296,7 @@ namespace Asa.RFID
...
@@ -281,7 +296,7 @@ namespace Asa.RFID
byte
scanMode
=
1
;
byte
scanMode
=
1
;
return
SetAutoScanMode
(
addr
,
scanMode
);
return
SetAutoScanMode
(
addr
,
scanMode
);
}
}
private
string
byteToStr
(
byte
[]
data
,
int
len
)
private
string
byteToStr
(
byte
[]
data
,
int
len
)
{
{
string
s
=
""
;
string
s
=
""
;
...
...
source/DeviceLibrary/device/RFID/RFIDAutoReader.cs
查看文件 @
ccb39bb
...
@@ -20,9 +20,9 @@ namespace Asa.RFID
...
@@ -20,9 +20,9 @@ namespace Asa.RFID
/// <param name="ipArr"></param>
/// <param name="ipArr"></param>
/// <param name="OnReceive"></param>
/// <param name="OnReceive"></param>
/// <param name="ip"></param>
/// <param name="ip"></param>
public
static
void
Open
(
Received_Event
OnReceive
,
params
string
[]
ipArr
)
public
static
void
Open
(
Received_Event
OnReceive
,
params
string
[]
ipArr
)
{
{
foreach
(
var
ip
in
ipArr
)
foreach
(
var
ip
in
ipArr
)
{
{
if
(
rfidMap
.
ContainsKey
(
ip
))
if
(
rfidMap
.
ContainsKey
(
ip
))
{
{
...
@@ -71,10 +71,10 @@ namespace Asa.RFID
...
@@ -71,10 +71,10 @@ namespace Asa.RFID
/// </summary>
/// </summary>
public
static
void
CloseAll
()
public
static
void
CloseAll
()
{
{
foreach
(
var
rfid
in
rfidMap
.
Values
)
foreach
(
var
rfid
in
rfidMap
.
Values
)
{
{
rfid
.
StopAutoScan
();
rfid
.
StopAutoScan
();
}
}
}
}
}
}
}
}
source/DeviceLibrary/device/RFID/RFIDManager.cs
查看文件 @
ccb39bb
...
@@ -15,14 +15,18 @@ namespace OnlineStore.DeviceLibrary
...
@@ -15,14 +15,18 @@ namespace OnlineStore.DeviceLibrary
{
{
public
static
void
Open
(
string
[]
iparray
)
public
static
void
Open
(
string
[]
iparray
)
{
{
try
Task
.
Factory
.
StartNew
(
delegate
{
{
RFIDAutoReader
.
Open
(
null
,
iparray
);
LogUtil
.
info
(
"RFIDManager.Open"
);
}
try
catch
(
Exception
ex
)
{
{
RFIDAutoReader
.
Open
(
null
,
iparray
);
LogUtil
.
error
(
"Open 出错:"
+
ex
.
ToString
());
}
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
"Open 出错:"
+
ex
.
ToString
());
}
});
}
}
public
static
RFIDData
ReadRFID
(
string
ip
,
bool
isClear
=
false
)
public
static
RFIDData
ReadRFID
(
string
ip
,
bool
isClear
=
false
)
...
@@ -60,14 +64,18 @@ namespace OnlineStore.DeviceLibrary
...
@@ -60,14 +64,18 @@ namespace OnlineStore.DeviceLibrary
public
static
void
Close
()
public
static
void
Close
()
{
{
try
Task
.
Factory
.
StartNew
(
delegate
{
{
RFIDAutoReader
.
CloseAll
();
LogUtil
.
info
(
"RFIDManager.Close"
);
}
try
catch
(
Exception
ex
)
{
{
RFIDAutoReader
.
CloseAll
();
LogUtil
.
error
(
"关闭RFID出错:"
+
ex
.
ToString
());
}
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
"关闭RFID出错:"
+
ex
.
ToString
());
}
});
}
}
}
}
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论