Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
RC1250-ACPackingStore
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 7fb1e0a4
由
LN
编写于
2020-02-15 15:32:35 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
rfid修改
1 个父辈
c5ac6de8
显示空白字符变更
内嵌
并排
正在显示
9 个修改的文件
包含
382 行增加
和
32 行删除
dll/Client.dll
dll/Client.xml
dll/RFID/RFIDLibrary.dll
dll/RFID/ReadMe.txt
source/ACPackingStore/FrmRFIPEdit.Designer.cs
source/ACPackingStore/FrmRFIPEdit.cs
source/DeviceLibrary/DeviceLibrary.csproj
source/DeviceLibrary/device/RFID/RFIDManager.cs
source/DeviceLibrary/device/RFID/RFIDReader.cs
dll/Client.dll
查看文件 @
7fb1e0a
此文件类型无法预览
dll/Client.xml
查看文件 @
7fb1e0a
...
@@ -230,11 +230,6 @@
...
@@ -230,11 +230,6 @@
</summary>
</summary>
<param
name=
"s"
></param>
<param
name=
"s"
></param>
</member>
</member>
<member
name=
"E:Asa.Client2.GetRFID"
>
<summary>
服务端发送的RFID
</summary>
</member>
<member
name=
"E:Asa.Client2.Arrive"
>
<member
name=
"E:Asa.Client2.Arrive"
>
<summary>
<summary>
小车到达,仅包装料仓
小车到达,仅包装料仓
...
@@ -281,13 +276,6 @@
...
@@ -281,13 +276,6 @@
<param
name=
"action"
></param>
<param
name=
"action"
></param>
<param
name=
"level"
></param>
<param
name=
"level"
></param>
</member>
</member>
<member
name=
"M:Asa.Client2.Reconnect"
>
<summary>
发送RFID
</summary>
<param
name=
"name"
></param>
<param
name=
"content"
></param>
</member>
<member
name=
"M:Asa.Client2.Splice(Asa.ClientNode)"
>
<member
name=
"M:Asa.Client2.Splice(Asa.ClientNode)"
>
<summary>
<summary>
拼接命令
拼接命令
...
@@ -385,12 +373,12 @@
...
@@ -385,12 +373,12 @@
</member>
</member>
<member
name=
"F:Asa.ClientAction.MayEnter"
>
<member
name=
"F:Asa.ClientAction.MayEnter"
>
<summary>
<summary>
可以进入料架
(包装料仓)
可以进入料架
,Arrive事件使用,让小车开始对接
</summary>
</summary>
</member>
</member>
<member
name=
"F:Asa.ClientAction.MayLeave"
>
<member
name=
"F:Asa.ClientAction.MayLeave"
>
<summary>
<summary>
可以出去料架
(包装料仓)
可以出去料架
,Arrive事件使用,让小车开始对接
</summary>
</summary>
</member>
</member>
<member
name=
"F:Asa.ClientAction.NeedEnter"
>
<member
name=
"F:Asa.ClientAction.NeedEnter"
>
...
@@ -415,12 +403,12 @@
...
@@ -415,12 +403,12 @@
</member>
</member>
<member
name=
"F:Asa.ClientAction.Arrive"
>
<member
name=
"F:Asa.ClientAction.Arrive"
>
<summary>
<summary>
小车到达
小车到达
,到达包装料仓门口,等待开门
</summary>
</summary>
</member>
</member>
<member
name=
"F:Asa.ClientAction.Ready"
>
<member
name=
"F:Asa.ClientAction.Ready"
>
<summary>
<summary>
小车已准备
好
小车已准备
,已对接上流水线
</summary>
</summary>
</member>
</member>
<member
name=
"T:Asa.ClientLevel"
>
<member
name=
"T:Asa.ClientLevel"
>
...
...
dll/RFID/RFIDLibrary.dll
deleted
100644 → 0
查看文件 @
c5ac6de
此文件类型无法预览
dll/RFID/ReadMe.txt
0 → 100644
查看文件 @
7fb1e0a
1.0.0.0 2019-11-19
1、钉盘上传
\ No newline at end of file
\ No newline at end of file
source/ACPackingStore/FrmRFIPEdit.Designer.cs
查看文件 @
7fb1e0a
...
@@ -205,6 +205,7 @@
...
@@ -205,6 +205,7 @@
this
.
Icon
=
((
System
.
Drawing
.
Icon
)(
resources
.
GetObject
(
"$this.Icon"
)));
this
.
Icon
=
((
System
.
Drawing
.
Icon
)(
resources
.
GetObject
(
"$this.Icon"
)));
this
.
Name
=
"FrmRFIPEdit"
;
this
.
Name
=
"FrmRFIPEdit"
;
this
.
Text
=
"托盘编码"
;
this
.
Text
=
"托盘编码"
;
this
.
FormClosed
+=
new
System
.
Windows
.
Forms
.
FormClosedEventHandler
(
this
.
FrmRFIPEdit_FormClosed
);
this
.
Load
+=
new
System
.
EventHandler
(
this
.
FrmPwd_Load
);
this
.
Load
+=
new
System
.
EventHandler
(
this
.
FrmPwd_Load
);
((
System
.
ComponentModel
.
ISupportInitialize
)(
this
.
numNum
)).
EndInit
();
((
System
.
ComponentModel
.
ISupportInitialize
)(
this
.
numNum
)).
EndInit
();
this
.
groupBox2
.
ResumeLayout
(
false
);
this
.
groupBox2
.
ResumeLayout
(
false
);
...
...
source/ACPackingStore/FrmRFIPEdit.cs
查看文件 @
7fb1e0a
...
@@ -36,9 +36,17 @@ namespace OnlineStore.ACPackingStore
...
@@ -36,9 +36,17 @@ namespace OnlineStore.ACPackingStore
comboxType
.
SelectedIndex
=
0
;
comboxType
.
SelectedIndex
=
0
;
comType
.
SelectedIndex
=
0
;
comType
.
SelectedIndex
=
0
;
string
hostN
=
Dns
.
GetHostName
();
List
<
string
>
List
=
new
List
<
string
>
();
IPAddress
[]
addresss
=
Dns
.
GetHostAddresses
(
hostN
);
List
=
new
List
<
string
>(
rfMap
.
Values
);
if
(
StoreManager
.
Store
.
storeRunStatus
<=
StoreRunStatus
.
Wait
)
{
Task
.
Factory
.
StartNew
(
delegate
{
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
)
...
@@ -79,5 +87,16 @@ namespace OnlineStore.ACPackingStore
...
@@ -79,5 +87,16 @@ namespace OnlineStore.ACPackingStore
}
}
}
}
}
}
private
void
FrmRFIPEdit_FormClosed
(
object
sender
,
FormClosedEventArgs
e
)
{
if
(
StoreManager
.
Store
.
storeRunStatus
<=
StoreRunStatus
.
Wait
)
{
Task
.
Factory
.
StartNew
(
delegate
{
LogUtil
.
info
(
Name
+
"RFIDManager.Close"
);
RFIDManager
.
Close
();
});
}
}
}
}
}
}
source/DeviceLibrary/DeviceLibrary.csproj
查看文件 @
7fb1e0a
...
@@ -83,9 +83,8 @@
...
@@ -83,9 +83,8 @@
<Compile Include="device\PanasonicServo\ACCMDManager.cs" />
<Compile Include="device\PanasonicServo\ACCMDManager.cs" />
<Compile Include="device\PanasonicServo\ACServerManager.cs" />
<Compile Include="device\PanasonicServo\ACServerManager.cs" />
<Compile Include="device\PanasonicServo\ACServerManager_Partial.cs" />
<Compile Include="device\PanasonicServo\ACServerManager_Partial.cs" />
<Compile Include="device\RFID\RFIDAuto.cs" />
<Compile Include="device\RFID\RFIDManager.cs" />
<Compile Include="device\RFID\RFIDManager.cs" />
<Compile Include="device\RFID\RFID
Auto
Reader.cs" />
<Compile Include="device\RFID\RFIDReader.cs" />
<Compile Include="store\AutoInoutInfo.cs" />
<Compile Include="store\AutoInoutInfo.cs" />
<Compile Include="store\LineMoveP.cs" />
<Compile Include="store\LineMoveP.cs" />
<Compile Include="store\LineAlarm.cs">
<Compile Include="store\LineAlarm.cs">
...
...
source/DeviceLibrary/device/RFID/RFIDManager.cs
查看文件 @
7fb1e0a
...
@@ -17,8 +17,9 @@ namespace OnlineStore.DeviceLibrary
...
@@ -17,8 +17,9 @@ namespace OnlineStore.DeviceLibrary
{
{
try
try
{
{
RFIDAutoReader
.
Open
(
null
,
iparray
);
RFIDReader
.
Open
(
iparray
);
}
catch
(
Exception
ex
)
}
catch
(
Exception
ex
)
{
{
LogUtil
.
error
(
"Open 出错:"
+
ex
.
ToString
());
LogUtil
.
error
(
"Open 出错:"
+
ex
.
ToString
());
}
}
...
@@ -31,14 +32,9 @@ namespace OnlineStore.DeviceLibrary
...
@@ -31,14 +32,9 @@ namespace OnlineStore.DeviceLibrary
if
(
String
.
IsNullOrEmpty
(
ip
).
Equals
(
false
))
if
(
String
.
IsNullOrEmpty
(
ip
).
Equals
(
false
))
{
{
byte
[]
bdata
=
null
;
byte
[]
bdata
=
null
;
if
(
isClear
)
{
bdata
=
RFIDReader
.
Read
(
ip
,
isClear
);
bdata
=
RFIDAutoReader
.
ReadAndClear
(
ip
);
}
else
{
bdata
=
RFIDAutoReader
.
Read
(
ip
);
}
if
(
bdata
==
null
)
if
(
bdata
==
null
)
{
{
LogUtil
.
error
(
"RFID [ "
+
ip
+
" ] 读到数据=null"
);
LogUtil
.
error
(
"RFID [ "
+
ip
+
" ] 读到数据=null"
);
...
@@ -59,7 +55,7 @@ namespace OnlineStore.DeviceLibrary
...
@@ -59,7 +55,7 @@ namespace OnlineStore.DeviceLibrary
{
{
try
try
{
{
RFID
Auto
Reader
.
CloseAll
();
RFIDReader
.
CloseAll
();
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
{
{
...
@@ -77,7 +73,7 @@ namespace OnlineStore.DeviceLibrary
...
@@ -77,7 +73,7 @@ namespace OnlineStore.DeviceLibrary
public
int
Num
=
0
;
public
int
Num
=
0
;
public
RFIDData
(
int
num
=
0
,
int
t
=
0
)
public
RFIDData
(
int
num
=
0
,
int
t
=
0
)
{
{
if
(
t
<
65
)
if
(
t
<
65
)
{
{
...
...
source/DeviceLibrary/device/RFID/RFIDReader.cs
0 → 100644
查看文件 @
7fb1e0a
using
log4net
;
using
OnlineStore.Common
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
Asa.RFID
{
public
class
RFID
{
public
static
readonly
ILog
LOGGER
=
LogManager
.
GetLogger
(
"TheRFID"
);
private
System
.
Threading
.
Thread
tScan
;
private
bool
loop
;
private
string
IP
=
""
;
private
byte
addr
;
private
int
portIndex
;
private
bool
IsConnect
=
false
;
private
byte
[]
lastData
=
new
byte
[
8
];
internal
byte
[]
_buff
;
//8字节缓存
private
byte
[]
_uid
;
//卡片ID
public
bool
IsExist
=
false
;
public
int
ErrCode
=
0
;
/// <summary>
/// 接收事件
/// </summary>
/// <param name="ip"></param>
/// <param name="buff"></param>
public
delegate
void
Received_Event
(
string
ip
,
byte
[]
buff
);
/// <summary>
/// 接收数据
/// </summary>
public
event
Received_Event
Received
;
public
RFID
(
string
ip
)
{
this
.
IP
=
ip
;
}
public
int
Close
()
{
try
{
loop
=
false
;
IsConnect
=
false
;
int
ErrCode
=
ReaderA
.
StaticClassReaderA
.
CloseNetPort
(
portIndex
);
LOGGER
.
Info
(
"Close RFID ["
+
IP
+
"]:"
+
ErrCode
);
return
ErrCode
;
}
catch
(
Exception
e
)
{
LOGGER
.
Error
(
"Close RFID["
+
IP
+
"] has error"
,
e
);
}
return
-
1
;
}
public
int
Open
()
{
if
(
IsConnect
)
{
LOGGER
.
Warn
(
" RFID ["
+
IP
+
"] is already connected, no need to start again"
);
return
0
;
}
//IP合法
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
);
if
(!
rtn
)
{
LOGGER
.
Error
(
IP
+
" is error"
);
return
-
1
;
}
string
[]
arr
=
IP
.
Split
(
'.'
);
if
(
arr
.
Length
!=
4
)
{
LOGGER
.
Error
(
IP
+
" length is not 4"
);
return
-
1
;
}
addr
=
Convert
.
ToByte
(
arr
[
3
]);
int
port
=
6000
+
Convert
.
ToInt32
(
arr
[
3
]);
portIndex
=
0
;
int
ErrCode
=
ReaderA
.
StaticClassReaderA
.
OpenNetPort
(
port
,
IP
,
ref
addr
,
ref
portIndex
);
LOGGER
.
Info
(
"Connect ["
+
IP
+
"] :"
+
ErrCode
);
// 在 OpenNetPort 后面使用
System
.
Threading
.
Thread
.
Sleep
(
100
);
OpenCloseRF
(
false
);
System
.
Threading
.
Thread
.
Sleep
(
100
);
OpenCloseRF
(
true
);
return
ErrCode
;
}
public
void
FindMode
()
{
loop
=
true
;
tScan
=
new
System
.
Threading
.
Thread
(
new
System
.
Threading
.
ThreadStart
(
Scan
));
tScan
.
Start
();
}
private
void
Scan
()
{
while
(
loop
)
{
bool
rtn
=
FindRFID
();
if
(
rtn
)
{
ReadRFID
();
byte
[]
bb
=
new
byte
[]
{
_buff
[
0
],
_buff
[
1
],
_buff
[
2
]
};
string
dataStr
=
byteToStr
(
bb
,
bb
.
Length
);
LOGGER
.
Info
(
IP
+
" Scan Data:"
+
dataStr
);
Received
?.
Invoke
(
IP
,
bb
);
}
System
.
Threading
.
Thread
.
Sleep
(
100
);
}
}
private
void
OpenCloseRF
(
bool
rtn
)
{
if
(
rtn
)
ErrCode
=
ReaderA
.
StaticClassReaderA
.
OpenRf
(
ref
addr
,
portIndex
);
else
ErrCode
=
ReaderA
.
StaticClassReaderA
.
CloseRf
(
ref
addr
,
portIndex
);
}
/// <summary>
/// 查找电子标签,扫描模式不能使用
/// </summary>
/// <returns></returns>
public
bool
FindRFID
()
{
try
{
//0 不带AFI
//1 带AFI
//2 不带AFI,继续查询
//3 带AFI,继续查询
//6 不带AFI,新的查询
//7 带AFI,新的查询
byte
state
=
0
;
//Select模式需要AFI
byte
AFI
=
0
;
//输出,1字节DSFID,8字节UID
byte
[]
DSFIDAndUID
=
new
byte
[
9
];
//输出,标签数量
byte
cardNumber
=
0
;
if
(
_uid
==
null
)
{
_uid
=
new
byte
[
8
];
}
ErrCode
=
ReaderA
.
StaticClassReaderA
.
Inventory
(
ref
addr
,
ref
state
,
ref
AFI
,
DSFIDAndUID
,
ref
cardNumber
,
portIndex
);
if
(
ErrCode
==
0
)
{
//查询时间
//fCmdRet = StaticClassReaderA.GetInventoryTime(ref n_time, portIndex);
Array
.
Copy
(
DSFIDAndUID
,
1
,
_uid
,
0
,
8
);
IsExist
=
true
;
return
true
;
}
else
{
for
(
int
i
=
0
;
i
<
_uid
.
Length
;
i
++)
_uid
[
i
]
=
0
;
IsExist
=
false
;
}
}
catch
(
Exception
ex
)
{
LOGGER
.
Error
(
IP
+
"FindRFID Error:"
+
ex
.
ToString
());
}
return
false
;
}
public
byte
[]
Read
(
bool
isNeedFind
=
false
)
{
if
(
isNeedFind
)
{
FindRFID
();
}
if
(
IsExist
)
{
ReadRFID
();
return
_buff
;
}
else
{
LOGGER
.
Info
(
IP
+
" Read: IsExist=false "
);
}
return
null
;
}
private
void
ReadRFID
()
{
try
{
//0 不带AFI
//1 带AFI
//2 不带AFI,继续查询
//3 带AFI,继续查询
//6 不带AFI,新的查询
//7 带AFI,新的查询
byte
state
=
0
;
//起始块号
byte
blockNum
=
0
;
//块数量
byte
blockCount
=
2
;
//输出,块内安全信息,长度为BlockCount个字节
byte
[]
blockSecStatus
=
new
byte
[
blockCount
];
//输出,块内数据信息,长度为块的大小(4或8字节)乘以BlockCount个字节
byte
[]
data
=
new
byte
[
4
*
blockCount
];
//错误代码
byte
errorCode
=
0
;
if
(
_buff
==
null
)
{
_buff
=
new
byte
[
8
];
}
ErrCode
=
ReaderA
.
StaticClassReaderA
.
ReadMultipleBlock
(
ref
addr
,
ref
state
,
_uid
,
blockNum
,
blockCount
,
blockSecStatus
,
data
,
ref
errorCode
,
portIndex
);
if
(
ErrCode
==
0
)
{
Array
.
Copy
(
data
,
0
,
_buff
,
0
,
data
.
Length
);
string
dataStr
=
byteToStr
(
data
,
data
.
Length
);
LOGGER
.
Info
(
IP
+
" ReadMultipleBlock: Length: "
+
data
.
Length
+
" Data:"
+
dataStr
);
}
else
{
LOGGER
.
Info
(
IP
+
" ReadMultipleBlock: ErrCode: "
+
ErrCode
);
}
}
catch
(
Exception
ex
)
{
LOGGER
.
Error
(
IP
+
"ReadRFID Error:"
+
ex
.
ToString
());
}
}
private
string
byteToStr
(
byte
[]
data
,
int
len
)
{
string
s
=
""
;
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
s
+=
data
[
i
].
ToString
(
"X2"
)
+
" "
;
}
return
s
;
}
}
public
class
RFIDReader
{
public
static
readonly
ILog
LOGGER
=
LogManager
.
GetLogger
(
"TheRFID"
);
private
static
Dictionary
<
string
,
RFID
>
rfidMap
=
new
Dictionary
<
string
,
RFID
>();
private
static
Dictionary
<
string
,
byte
[
]>
LastRfidData
=
new
Dictionary
<
string
,
byte
[
]>
();
public
static
void
Open
(
params
string
[]
ipArr
)
{
try
{
foreach
(
var
ip
in
ipArr
)
{
if
(
rfidMap
.
ContainsKey
(
ip
))
{
rfidMap
[
ip
].
Open
();
rfidMap
[
ip
].
FindMode
();
}
else
{
RFID
rfid
=
new
RFID
(
ip
);
rfid
.
Received
+=
Rfid_Received
;
rfid
.
Open
();
rfid
.
FindMode
();
rfidMap
.
Add
(
ip
,
rfid
);
}
}
}
catch
(
Exception
ex
)
{
LOGGER
.
Error
(
"RFIDReader Open Error:"
+
ex
.
ToString
());
}
}
private
static
void
Rfid_Received
(
string
ip
,
byte
[]
buff
)
{
if
(
buff
==
null
)
{
return
;
}
string
dataStr
=
byteToStr
(
buff
,
buff
.
Length
);
LOGGER
.
Info
(
ip
+
" Rfid_Received 保存数据:"
+
dataStr
);
if
(
LastRfidData
.
ContainsKey
(
ip
))
{
LastRfidData
[
ip
]
=
buff
;
}
else
{
LastRfidData
.
Add
(
ip
,
buff
);
}
}
//public static bool FindRFID(string ip)
//{
// if (rfidMap.ContainsKey(ip))
// {
// return rfidMap[ip].FindRFID();
// }
// return false;
//}
public
static
byte
[]
Read
(
string
ip
,
bool
isClear
=
false
)
{
if
(
rfidMap
.
ContainsKey
(
ip
))
{
if
(
LastRfidData
.
ContainsKey
(
ip
))
{
byte
[]
data
=
LastRfidData
[
ip
];
if
(
isClear
)
{
LastRfidData
.
Remove
(
ip
);
}
return
data
;
}
// return rfidMap[ip].Read(isNeedFind);
}
return
null
;
}
public
static
void
CloseAll
()
{
foreach
(
var
rfid
in
rfidMap
.
Values
)
{
rfid
.
Close
();
}
}
private
static
string
byteToStr
(
byte
[]
data
,
int
len
)
{
string
s
=
""
;
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
s
+=
data
[
i
].
ToString
(
"X2"
)
+
" "
;
}
return
s
;
}
}
}
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论