Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
RC1250-AssemblyLine
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 4d18eddc
由
LN
编写于
2020-01-02 16:48:54 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
1
1 个父辈
73248902
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
390 行增加
和
0 行删除
source/DeviceLibrary/DeviceLibrary.csproj
source/DeviceLibrary/assemblyLine/EquipBase.cs
source/DeviceLibrary/assemblyLine/LineBean.cs
source/DeviceLibrary/deviceLibrary/RFID/RFID.cs
source/DeviceLibrary/deviceLibrary/RFID/RFIDManager.cs
source/DeviceLibrary/deviceLibrary/RFID/RFIDReader.cs
source/DeviceLibrary/DeviceLibrary.csproj
查看文件 @
4d18edd
...
@@ -95,6 +95,8 @@
...
@@ -95,6 +95,8 @@
<Compile Include="deviceLibrary\PanasonicServo\ACServerManager.cs" />
<Compile Include="deviceLibrary\PanasonicServo\ACServerManager.cs" />
<Compile Include="deviceLibrary\PanasonicServo\ACServerManager_Partial.cs" />
<Compile Include="deviceLibrary\PanasonicServo\ACServerManager_Partial.cs" />
<Compile Include="assemblyLine\EquipBase.cs" />
<Compile Include="assemblyLine\EquipBase.cs" />
<Compile Include="deviceLibrary\RFID\RFID.cs" />
<Compile Include="deviceLibrary\RFID\RFIDReader.cs" />
<Compile Include="model\LineAlarm.cs">
<Compile Include="model\LineAlarm.cs">
<SubType>Code</SubType>
<SubType>Code</SubType>
</Compile>
</Compile>
...
...
source/DeviceLibrary/assemblyLine/EquipBase.cs
查看文件 @
4d18edd
...
@@ -225,6 +225,7 @@ namespace OnlineStore.DeviceLibrary
...
@@ -225,6 +225,7 @@ namespace OnlineStore.DeviceLibrary
/// </summary>
/// </summary>
internal
virtual
void
OpenStopCylinder
()
internal
virtual
void
OpenStopCylinder
()
{
{
preRWTime
=
DateTime
.
Now
;
if
(
baseConfig
.
DType
.
Equals
(
DeviceType
.
MoveEquip
)
||
baseConfig
.
DType
.
Equals
(
DeviceType
.
ProvidingEquip
))
if
(
baseConfig
.
DType
.
Equals
(
DeviceType
.
MoveEquip
)
||
baseConfig
.
DType
.
Equals
(
DeviceType
.
ProvidingEquip
))
{
{
LogInfo
(
"OpenStopCylinder: 下降阻挡气缸,上下气缸上升,顶升气缸下降"
);
LogInfo
(
"OpenStopCylinder: 下降阻挡气缸,上下气缸上升,顶升气缸下降"
);
...
@@ -240,6 +241,49 @@ namespace OnlineStore.DeviceLibrary
...
@@ -240,6 +241,49 @@ namespace OnlineStore.DeviceLibrary
Thread
.
Sleep
(
30
);
Thread
.
Sleep
(
30
);
}
}
}
}
internal
virtual
bool
OpenStopCylinderOk
(
TimeSpan
span
)
{
TimeSpan
rwSpan
=
DateTime
.
Now
-
preRWTime
;
if
(
baseConfig
.
DType
.
Equals
(
DeviceType
.
MoveEquip
)
||
baseConfig
.
DType
.
Equals
(
DeviceType
.
ProvidingEquip
))
{
if
(
IOValue
(
IO_Type
.
StopCylinder_Down1
).
Equals
(
IO_VALUE
.
HIGH
)
&&
IOValue
(
IO_Type
.
StopCylinder_Down2
).
Equals
(
IO_VALUE
.
HIGH
))
{
return
true
;
}
else
if
(
rwSpan
.
TotalSeconds
>
5
&&
span
.
TotalSeconds
>
6
&&
span
.
TotalMilliseconds
<
LineManager
.
Config
.
IOSingle_TimerOut
*
2
)
{
preRWTime
=
DateTime
.
Now
;
IOMove
(
IO_Type
.
StopCylinder_Down1
,
IO_VALUE
.
HIGH
);
IOMove
(
IO_Type
.
StopCylinder_Down2
,
IO_VALUE
.
HIGH
);
}
}
else
if
(
baseConfig
.
DType
.
Equals
(
DeviceType
.
DischargeLine
))
{
return
true
;
}
else
if
(
baseConfig
.
DType
.
Equals
(
DeviceType
.
FeedingEquip
))
{
if
(
DeviceID
.
Equals
(
102
))
{
if
(
IOValue
(
IO_Type
.
FL_StopCylinder_Down1
).
Equals
(
IO_VALUE
.
HIGH
)
&&
IOValue
(
IO_Type
.
FL_StopCylinder_Down2
).
Equals
(
IO_VALUE
.
HIGH
))
{
return
true
;
}
else
if
(
rwSpan
.
TotalSeconds
>
5
&&
span
.
TotalSeconds
>
6
&&
span
.
TotalMilliseconds
<
LineManager
.
Config
.
IOSingle_TimerOut
*
2
)
{
IOMove
(
IO_Type
.
FL_StopCylinder_Down1
,
IO_VALUE
.
HIGH
);
IOMove
(
IO_Type
.
FL_StopCylinder_Down2
,
IO_VALUE
.
HIGH
);
}
}
else
{
return
true
;
}
}
return
false
;
}
internal
virtual
void
CloseCylinderStop
()
internal
virtual
void
CloseCylinderStop
()
{
{
if
(
baseConfig
.
DType
.
Equals
(
DeviceType
.
MoveEquip
)
||
baseConfig
.
DType
.
Equals
(
DeviceType
.
ProvidingEquip
))
if
(
baseConfig
.
DType
.
Equals
(
DeviceType
.
MoveEquip
)
||
baseConfig
.
DType
.
Equals
(
DeviceType
.
ProvidingEquip
))
...
...
source/DeviceLibrary/assemblyLine/LineBean.cs
查看文件 @
4d18edd
...
@@ -904,6 +904,17 @@ namespace OnlineStore.DeviceLibrary
...
@@ -904,6 +904,17 @@ namespace OnlineStore.DeviceLibrary
{
{
if
(
moveEquip
.
IsDebug
)
if
(
moveEquip
.
IsDebug
)
{
{
TimeSpan
span
=
DateTime
.
Now
-
MoveInfo
.
LastSetpTime
;
if
(!
moveEquip
.
OpenStopCylinderOk
(
span
))
{
if
(
span
.
TotalSeconds
>
LineManager
.
Config
.
IOSingle_TimerOut
)
{
SetWarnMsg
(
moveEquip
.
Name
+
"下降阻挡气缸超时,已等待"
+
FormUtil
.
GetSpanStr
(
span
));
LogUtil
.
error
(
moveEquip
.
Name
+
"下降阻挡气缸超时,已等待"
+
FormUtil
.
GetSpanStr
(
span
),
112
);
}
isOk
=
false
;
break
;
}
continue
;
continue
;
}
}
if
(
moveEquip
.
runStatus
.
Equals
(
LineRunStatus
.
HomeMoving
)
||
moveEquip
.
runStatus
.
Equals
(
LineRunStatus
.
Reset
)
||
moveEquip
.
runStatus
.
Equals
(
LineRunStatus
.
Wait
))
if
(
moveEquip
.
runStatus
.
Equals
(
LineRunStatus
.
HomeMoving
)
||
moveEquip
.
runStatus
.
Equals
(
LineRunStatus
.
Reset
)
||
moveEquip
.
runStatus
.
Equals
(
LineRunStatus
.
Wait
))
...
@@ -926,6 +937,10 @@ namespace OnlineStore.DeviceLibrary
...
@@ -926,6 +937,10 @@ namespace OnlineStore.DeviceLibrary
if
(
isOk
)
if
(
isOk
)
{
{
if
(
WarnMsg
.
Contains
(
"下降阻挡气缸超时"
))
{
SetWarnMsg
(
""
);
}
PreIsHasProcess
=
false
;
PreIsHasProcess
=
false
;
//打开流水线
//打开流水线
WriteDrivetMotorRun
(
IO_VALUE
.
HIGH
);
WriteDrivetMotorRun
(
IO_VALUE
.
HIGH
);
...
...
source/DeviceLibrary/deviceLibrary/RFID/RFID.cs
0 → 100644
查看文件 @
4d18edd
using
log4net
;
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
string
IP
=
""
;
private
byte
addr
;
private
int
portIndex
;
private
bool
IsConnect
=
false
;
private
byte
[]
lastData
=
new
byte
[
8
];
/// <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
StopAutoScan
()
{
LOGGER
.
Info
(
"Close RFID ["
+
IP
+
"]"
);
IsConnect
=
false
;
byte
scanMode
=
0
;
return
SetAutoScanMode
(
addr
,
scanMode
);
}
public
int
StartAutoScan
(
Received_Event
OnReceive
)
{
if
(
IsConnect
)
{
LOGGER
.
Warn
(
" RFID ["
+
IP
+
"] is already connected, no need to start again"
);
return
0
;
}
this
.
Received
=
OnReceive
;
//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
);
if
(
ErrCode
==
0
)
{
ErrCode
=
OpenAutoScanMode
(
addr
);
LOGGER
.
Info
(
" ["
+
IP
+
"] Open Auto Scan Mode:"
+
ErrCode
);
Task
.
Factory
.
StartNew
(
AutoScan
);
}
return
ErrCode
;
}
private
int
SetAutoScanMode
(
byte
addr
,
byte
scanMode
)
{
byte
[]
scanModeData
=
new
byte
[
11
];
//bit0: 0停止扫描,1开始扫描
//bit1: 0正常数据扫描,1EAS扫描
//bit2: 0正常灵敏度,1高灵敏度
//bit3: 0禁止输入同步,1允许输入同步
//bit4: 0禁止指令同步,1允许指令同步
//bit5: 0禁止扫描提示,1允许扫描提示
//bit6: 0禁止EAS探测提示,1允许EAS探测提示
//bit7: 0禁止EAS消息输出提示,1允许EAS消息输出提示
scanModeData
[
0
]
=
scanMode
;
//bit0: 0不发送comAddr,1发送comAddr
//bit1: 0不带UID,1带UID
//bit2: 0不包含指定块,1包含指定块
//bit3: 0不带安全状态字,1带安全状态字
//bit4: 0 ASCII,1 HEX
//bit5: 0不进行开关射频场,1进行开关射频场
//bit6: 0无操作,1停止扫描关闭射频场
//bit7: 0无,1鸣叫闪烁
scanModeData
[
1
]
=
255
;
scanModeData
[
2
]
=
0
;
//起始块号
scanModeData
[
3
]
=
2
;
//块总数 之前是28
scanModeData
[
4
]
=
1
;
//块的起始字节
scanModeData
[
5
]
=
4
;
//块的字节数
//1 CR+LF 0x0D 0x0A
//2 CR 0x0D
//4 LF 0x0A
//8 BEL 0x07
//16 :(分号) 0x3B
//32 ,(逗号) 0x2C
//64 " "(空格) 0x20
//128 自定义
scanModeData
[
6
]
=
8
;
//间隔符
scanModeData
[
7
]
=
0
;
//自定义间隔符,[6] = 128
//1 CR+LF 0x0D 0x0A
//2 CR 0x0D
//4 LF 0x0A
//8 BEL 0x07
//16 :(分号) 0x3B
//32 ,(逗号) 0x2C
//64 " "(空格) 0x20
//128 自定义
scanModeData
[
8
]
=
8
;
//结束符
scanModeData
[
9
]
=
0
;
//自定义间隔符,[8] = 128
scanModeData
[
10
]
=
0x00
;
int
ErrCode
=
ReaderA
.
StaticClassReaderA
.
SetScanMode
(
ref
addr
,
scanModeData
,
portIndex
);
return
ErrCode
;
}
private
void
AutoScan
()
{
IsConnect
=
true
;
while
(
IsConnect
)
{
try
{
byte
[]
data
=
new
byte
[
100
];
int
len
=
0
;
int
ErrCode
=
ReaderA
.
StaticClassReaderA
.
ReadScanModeData
(
data
,
ref
len
,
portIndex
);
if
(
ErrCode
==
0
)
{
string
dataStr
=
byteToStr
(
data
,
len
);
LOGGER
.
Debug
(
IP
+
" Receive Code: "
+
ErrCode
+
" Len: "
+
len
+
" Data:"
+
dataStr
);
byte
[]
bb
=
new
byte
[
10
];
int
idx
=
-
1
;
bool
start
=
false
;
bool
end
=
false
;
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
byte
b
=
data
[
i
];
if
(
b
==
0x5A
)
{
start
=
true
;
idx
=
0
;
//bb[idx++] = result;
}
else
if
(
b
==
0x4A
&&
start
)
{
start
=
false
;
end
=
true
;
bb
[
idx
++]
=
b
;
}
if
(
start
)
{
if
(
idx
+
1
==
bb
.
Length
)
{
start
=
false
;
end
=
false
;
}
else
{
bb
[
idx
++]
=
b
;
}
}
if
(
end
)
{
byte
[]
_buff
=
new
byte
[
8
];
_buff
[
0
]
=
bb
[
0
];
_buff
[
1
]
=
bb
[
1
];
_buff
[
2
]
=
bb
[
2
];
_buff
[
3
]
=
bb
[
3
];
_buff
[
4
]
=
bb
[
5
];
_buff
[
5
]
=
bb
[
6
];
_buff
[
6
]
=
0
;
_buff
[
7
]
=
0
;
end
=
false
;
string
itemStr
=
byteToStr
(
_buff
,
_buff
.
Length
);
lastData
=
_buff
;
LOGGER
.
Debug
(
"["
+
IP
+
"] Item:"
+
itemStr
);
Received
?.
Invoke
(
IP
,
_buff
);
}
}
}
System
.
Threading
.
Thread
.
Sleep
(
60
);
}
catch
(
Exception
e
)
{
LOGGER
.
Error
(
"ReadScanModeData Error:"
,
e
);
}
}
}
public
byte
[]
ReadAndClear
()
{
byte
[]
data
=
lastData
;
lastData
=
new
byte
[
8
];
LOGGER
.
Info
(
"Read and clear RFID["
+
IP
+
"] data:"
+
byteToStr
(
data
,
data
.
Length
));
return
data
;
}
public
byte
[]
Read
()
{
return
lastData
;
}
private
int
OpenAutoScanMode
(
byte
addr
)
{
byte
scanMode
=
1
;
return
SetAutoScanMode
(
addr
,
scanMode
);
}
private
string
byteToStr
(
byte
[]
data
,
int
len
)
{
string
s
=
""
;
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
s
+=
data
[
i
].
ToString
(
"X2"
)
+
" "
;
}
return
s
;
}
}
}
source/DeviceLibrary/deviceLibrary/RFID/RFIDManager.cs
deleted
100644 → 0
查看文件 @
7324890
此文件的差异被折叠,
点击展开。
source/DeviceLibrary/deviceLibrary/RFID/RFIDReader.cs
0 → 100644
查看文件 @
4d18edd
using
log4net
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
using
static
Asa
.
RFID
.
RFID
;
namespace
Asa.RFID
{
public
class
RFIDReader
{
public
static
readonly
ILog
LOGGER
=
LogManager
.
GetLogger
(
"TheRFID"
);
private
Dictionary
<
string
,
RFID
>
rfidMap
=
new
Dictionary
<
string
,
RFID
>();
/// <summary>
/// 打开所有
/// </summary>
/// <param name="ipArr"></param>
/// <param name="OnReceive"></param>
/// <param name="ip"></param>
public
void
Open
(
Received_Event
OnReceive
,
params
string
[]
ipArr
)
{
foreach
(
var
ip
in
ipArr
)
{
if
(
rfidMap
.
ContainsKey
(
ip
))
{
rfidMap
[
ip
].
StopAutoScan
(
OnReceive
);
}
else
{
RFID
rfid
=
new
RFID
(
ip
);
rfid
.
StartAutoScan
(
OnReceive
);
rfidMap
.
Add
(
ip
,
rfid
);
}
}
}
/// <summary>
/// 获取最后读到的标签并清理
/// </summary>
/// <param name="ip"></param>
/// <returns></returns>
public
byte
[]
ReadAndClear
(
string
ip
)
{
if
(
rfidMap
.
ContainsKey
(
ip
))
{
return
rfidMap
[
ip
].
ReadAndClear
();
}
return
null
;
}
/// <summary>
/// 获取最后读到的标签
/// </summary>
/// <param name="ip"></param>
/// <returns></returns>
public
byte
[]
Read
(
string
ip
)
{
if
(
rfidMap
.
ContainsKey
(
ip
))
{
return
rfidMap
[
ip
].
Read
();
}
return
null
;
}
/// <summary>
/// 关闭所有
/// </summary>
public
void
CloseAll
()
{
foreach
(
var
rfid
in
rfidMap
.
Values
)
{
rfid
.
StopAutoScan
();
}
}
}
}
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论