Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
RC1250-AssemblyLine
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 4925708c
由
LN
编写于
2020-05-26 09:22:37 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
皮带线停止增加事件触发。
1 个父辈
164fd4bf
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
166 行增加
和
110 行删除
source/AssemblyLineClient/FrmLineStore.cs
source/DeviceLibrary/assemblyLine/DischargeLine.cs
source/DeviceLibrary/assemblyLine/DischargeLine_Partial.cs
source/DeviceLibrary/assemblyLine/OutTrayLineBean.cs
source/DeviceLibrary/deviceLibrary/IO/AIOBOX/AIOBOXManager.cs
source/DeviceLibrary/deviceLibrary/IO/IOManager.cs
source/AssemblyLineClient/FrmLineStore.cs
查看文件 @
4925708
...
@@ -446,6 +446,7 @@ namespace OnlineStore.AssemblyLine
...
@@ -446,6 +446,7 @@ namespace OnlineStore.AssemblyLine
MessageBox
.
Show
(
"已复制日志到粘贴板!"
);
MessageBox
.
Show
(
"已复制日志到粘贴板!"
);
}
}
private
DateTime
lastLogTime
=
DateTime
.
Now
;
private
DateTime
lastLogTime
=
DateTime
.
Now
;
PerformanceCounter
curtime
=
null
;
private
void
LogM
()
private
void
LogM
()
{
{
try
try
...
@@ -454,23 +455,19 @@ namespace OnlineStore.AssemblyLine
...
@@ -454,23 +455,19 @@ namespace OnlineStore.AssemblyLine
if
(
sp
.
TotalMinutes
>
10
)
if
(
sp
.
TotalMinutes
>
10
)
{
{
lastLogTime
=
DateTime
.
Now
;
lastLogTime
=
DateTime
.
Now
;
Process
[]
processes
=
Process
.
GetProcesses
();
long
totalMemery
=
0
;
StringBuilder
sbResult
=
new
StringBuilder
();
var
prevCpuTime
=
TimeSpan
.
Zero
;
int
interval
=
1000
;
foreach
(
Process
process
in
processes
)
{
if
(
process
.
ProcessName
.
EndsWith
(
"AssemblyLine"
))
{
sbResult
.
AppendFormat
(
DateTime
.
Now
.
ToLongTimeString
()
+
", 名称:{0} 内存:{1}M "
,
process
.
ProcessName
,
process
.
PrivateMemorySize64
/
1024
/
1024F
);
totalMemery
+=
process
.
PrivateMemorySize64
/
1024
;
double
value
=
(
process
.
TotalProcessorTime
-
prevCpuTime
).
TotalMilliseconds
/
interval
/
Environment
.
ProcessorCount
;
sbResult
.
AppendFormat
(
" CPU : "
+
Math
.
Round
(
value
,
2
)
+
"%"
);
// string result = string.Format("进程总数 {0} 个,共占内存:{1}MB \n", processes.Length, totalMemery / 1024) + sbResult.ToString();
LogUtil
.
info
(
sbResult
.
ToString
());
}
Process
process
=
Process
.
GetCurrentProcess
();
if
(
curtime
==
null
)
{
curtime
=
new
PerformanceCounter
(
"Process"
,
"% Processor Time"
,
process
.
ProcessName
);
}
if
(
process
!=
null
)
{
StringBuilder
sbResult
=
new
StringBuilder
();
PerformanceCounter
pf1
=
new
PerformanceCounter
(
"Process"
,
"Working Set - Private"
,
process
.
ProcessName
);
sbResult
.
AppendFormat
(
DateTime
.
Now
.
ToLongTimeString
()
+
", 名称:{0} 内存:{1}M "
,
process
.
ProcessName
,
Math
.
Round
(
pf1
.
NextValue
()
/
1024
/
1024F
,
2
));
sbResult
.
AppendFormat
(
", CPU : {0} %"
,
curtime
.
NextValue
());
LogUtil
.
info
(
sbResult
.
ToString
());
}
}
}
}
}
}
...
@@ -478,7 +475,7 @@ namespace OnlineStore.AssemblyLine
...
@@ -478,7 +475,7 @@ namespace OnlineStore.AssemblyLine
{
{
LogUtil
.
error
(
"LogM Error: "
,
ex
);
LogUtil
.
error
(
"LogM Error: "
,
ex
);
}
}
}
}
private
void
timer1_Tick
(
object
sender
,
EventArgs
e
)
private
void
timer1_Tick
(
object
sender
,
EventArgs
e
)
{
{
LogM
();
LogM
();
...
...
source/DeviceLibrary/assemblyLine/DischargeLine.cs
查看文件 @
4925708
...
@@ -56,7 +56,7 @@ namespace OnlineStore.DeviceLibrary
...
@@ -56,7 +56,7 @@ namespace OnlineStore.DeviceLibrary
TrayLine1
=
new
OutTrayLineBean
(
330
+
((
id
-
1
)
*
3
+
1
),
"皮带线"
+
"_"
+
((
id
-
1
)
*
3
+
1
)
+
" "
,
IO_Type
.
ExitLocation_Check1
,
IO_Type
.
ExitTray_Check1
,
IO_Type
.
DLine_Run1
,
IO_Type
.
MiddleTray_Check3
,
this
.
DeviceID
);
TrayLine1
=
new
OutTrayLineBean
(
330
+
((
id
-
1
)
*
3
+
1
),
"皮带线"
+
"_"
+
((
id
-
1
)
*
3
+
1
)
+
" "
,
IO_Type
.
ExitLocation_Check1
,
IO_Type
.
ExitTray_Check1
,
IO_Type
.
DLine_Run1
,
IO_Type
.
MiddleTray_Check3
,
this
.
DeviceID
);
TrayLine2
=
new
OutTrayLineBean
(
330
+((
id
-
1
)
*
3
+
2
),
"皮带线"
+
"_"
+
((
id
-
1
)
*
3
+
2
)
+
" "
,
IO_Type
.
ExitLocation_Check2
,
IO_Type
.
ExitTray_Check2
,
IO_Type
.
DLine_Run2
,
IO_Type
.
EntryTray_Check3
,
this
.
DeviceID
);
TrayLine2
=
new
OutTrayLineBean
(
330
+((
id
-
1
)
*
3
+
2
),
"皮带线"
+
"_"
+
((
id
-
1
)
*
3
+
2
)
+
" "
,
IO_Type
.
ExitLocation_Check2
,
IO_Type
.
ExitTray_Check2
,
IO_Type
.
DLine_Run2
,
IO_Type
.
EntryTray_Check3
,
this
.
DeviceID
);
}
}
Line3Turn
=
new
LineTurnBean
(
DeviceID
);
Line3Turn
=
new
LineTurnBean
(
DeviceID
,
IO_Type
.
DLine_Run3
,
IO_Type
.
Location_Check3
);
if
((
DeviceID
%
100
).
Equals
(
1
))
if
((
DeviceID
%
100
).
Equals
(
1
))
{
{
Line3MaxPosition
=
13
;
Line3MaxPosition
=
13
;
...
@@ -423,7 +423,7 @@ namespace OnlineStore.DeviceLibrary
...
@@ -423,7 +423,7 @@ namespace OnlineStore.DeviceLibrary
//判断皮带三还有料盘,需要转动一个工位
//判断皮带三还有料盘,需要转动一个工位
UpdateLastP
();
UpdateLastP
();
LogUtil
.
debug
(
hengyiName
+
"空闲,且流水线还有料盘,转动一个工位"
);
LogUtil
.
debug
(
hengyiName
+
"空闲,且流水线还有料盘,转动一个工位"
);
Line3Turn
.
StartLineRun
(
IO_Type
.
DLine_Run3
,
IO_Type
.
Location_Check3
,
Line3EndProcess
);
Line3Turn
.
StartLineRun
(
Line3EndProcess
);
}
}
}
}
private
void
UpdateLastP
()
private
void
UpdateLastP
()
...
...
source/DeviceLibrary/assemblyLine/DischargeLine_Partial.cs
查看文件 @
4925708
...
@@ -318,7 +318,7 @@ namespace OnlineStore.DeviceLibrary
...
@@ -318,7 +318,7 @@ namespace OnlineStore.DeviceLibrary
MoveInfo
.
NextMoveStep
(
LineMoveStep
.
DON_05_LineRun
);
MoveInfo
.
NextMoveStep
(
LineMoveStep
.
DON_05_LineRun
);
LogUtil
.
info
(
hengyiName
+
MoveInfo
.
SLog
+
"送料,NG->接驳台,转动接驳台皮带"
);
LogUtil
.
info
(
hengyiName
+
MoveInfo
.
SLog
+
"送料,NG->接驳台,转动接驳台皮带"
);
// IOMove(IO_Type.SeparateDevice_Run, IO_VALUE.HIGH);
// IOMove(IO_Type.SeparateDevice_Run, IO_VALUE.HIGH);
Line3Turn
.
StartLineRun
(
IO_Type
.
DLine_Run3
,
IO_Type
.
Location_Check3
,
Line3EndProcess
);
Line3Turn
.
StartLineRun
(
Line3EndProcess
);
SeparateLineRun
(
MoveInfo
);
SeparateLineRun
(
MoveInfo
);
MoveInfo
.
WaitList
.
Add
(
WaitResultInfo
.
WaitTime
(
3000
));
MoveInfo
.
WaitList
.
Add
(
WaitResultInfo
.
WaitTime
(
3000
));
MoveInfo
.
WaitList
.
Add
(
WaitResultInfo
.
WaitIO
(
IO_Type
.
Location_Check3
,
IO_VALUE
.
HIGH
));
MoveInfo
.
WaitList
.
Add
(
WaitResultInfo
.
WaitIO
(
IO_Type
.
Location_Check3
,
IO_VALUE
.
HIGH
));
...
...
source/DeviceLibrary/assemblyLine/OutTrayLineBean.cs
查看文件 @
4925708
...
@@ -14,9 +14,9 @@ namespace OnlineStore.DeviceLibrary
...
@@ -14,9 +14,9 @@ namespace OnlineStore.DeviceLibrary
/// </summary>
/// </summary>
public
class
OutTrayLineBean
public
class
OutTrayLineBean
{
{
public
int
MaxPosition
=
5
;
public
int
MaxPosition
=
5
;
private
int
equipBeanId
=
301
;
private
int
equipBeanId
=
301
;
private
string
Line3_TrayCheck
=
""
;
private
string
Line3_TrayCheck
=
""
;
//出口定位信号
//出口定位信号
private
string
ExitLocation_Check
=
""
;
private
string
ExitLocation_Check
=
""
;
//出口料盘检测信号
//出口料盘检测信号
...
@@ -37,14 +37,14 @@ namespace OnlineStore.DeviceLibrary
...
@@ -37,14 +37,14 @@ namespace OnlineStore.DeviceLibrary
public
OutTrayLineBean
(
int
id
,
string
name
,
string
exitLocationS
,
string
exittrayS
,
string
lineRundo
,
string
line3checkDi
,
int
dId
)
public
OutTrayLineBean
(
int
id
,
string
name
,
string
exitLocationS
,
string
exittrayS
,
string
lineRundo
,
string
line3checkDi
,
int
dId
)
{
{
this
.
Id
=
id
;
this
.
Id
=
id
;
lineRun
=
new
LineTurnBean
(
dId
);
this
.
equipBeanId
=
dId
;
this
.
equipBeanId
=
dId
;
this
.
Name
=
name
;
this
.
Name
=
name
;
MoveInfo
=
new
LineMoveInfo
(
Id
,
name
);
MoveInfo
=
new
LineMoveInfo
(
Id
,
name
);
this
.
ExitLocation_Check
=
exitLocationS
;
this
.
ExitLocation_Check
=
exitLocationS
;
this
.
ExitTray_Check
=
exittrayS
;
this
.
ExitTray_Check
=
exittrayS
;
this
.
LineRun_Do
=
lineRundo
;
this
.
LineRun_Do
=
lineRundo
;
this
.
Line3_TrayCheck
=
line3checkDi
;
this
.
Line3_TrayCheck
=
line3checkDi
;
lineRun
=
new
LineTurnBean
(
dId
,
LineRun_Do
,
ExitLocation_Check
);
}
}
public
void
StopRun
()
public
void
StopRun
()
...
@@ -61,20 +61,20 @@ namespace OnlineStore.DeviceLibrary
...
@@ -61,20 +61,20 @@ namespace OnlineStore.DeviceLibrary
{
{
if
(
LastTrayPosition
<=
1
)
if
(
LastTrayPosition
<=
1
)
{
{
LogUtil
.
error
(
Name
+
" 启动送料【"
+
moveParam
.
ToStr
()
+
"】 失败,入口有料"
,
Id
*
1000
+
32
);
LogUtil
.
error
(
Name
+
" 启动送料【"
+
moveParam
.
ToStr
()
+
"】 失败,入口有料"
,
Id
*
1000
+
32
);
return
false
;
return
false
;
}
}
//MoveInfo.MoveParam = moveParam;
//MoveInfo.MoveParam = moveParam;
MoveInfo
.
NewMove
(
LineMoveType
.
OutStore
,
moveParam
);
MoveInfo
.
NewMove
(
LineMoveType
.
OutStore
,
moveParam
);
posId
=
moveParam
.
PosId
+
"["
+
moveParam
.
WareCode
+
"]["
+
moveParam
.
rfid
+
"]"
;
posId
=
moveParam
.
PosId
+
"["
+
moveParam
.
WareCode
+
"]["
+
moveParam
.
rfid
+
"]"
;
if
(
moveParam
.
InStoreNg
)
if
(
moveParam
.
InStoreNg
)
{
{
posId
=
moveParam
.
rfid
+
"NG料"
+
"["
+
moveParam
.
WareCode
+
"]"
;
posId
=
moveParam
.
rfid
+
"NG料"
+
"["
+
moveParam
.
WareCode
+
"]"
;
}
}
MoveInfo
.
NextMoveStep
(
LineMoveStep
.
DLO_01_NGBack
);
MoveInfo
.
NextMoveStep
(
LineMoveStep
.
DLO_01_NGBack
);
LogUtil
.
info
(
Name
+
"开始送料【"
+
moveParam
.
ToStr
()
+
"】:"
+
MoveInfo
.
SLog
+
"NG气缸后退"
);
LogUtil
.
info
(
Name
+
"开始送料【"
+
moveParam
.
ToStr
()
+
"】:"
+
MoveInfo
.
SLog
+
"NG气缸后退"
);
MoveInfo
.
WaitList
.
Add
(
WaitResultInfo
.
WaitTime
(
300
));
MoveInfo
.
WaitList
.
Add
(
WaitResultInfo
.
WaitTime
(
300
));
if
(
equipBeanId
.
Equals
(
302
)
)
if
(
equipBeanId
.
Equals
(
302
))
{
{
if
(
equipBean
.
CylinderIsOk
(
IO_Type
.
NGCylinder_Before
,
IO_Type
.
NGCylinder_After
))
if
(
equipBean
.
CylinderIsOk
(
IO_Type
.
NGCylinder_Before
,
IO_Type
.
NGCylinder_After
))
{
{
...
@@ -182,7 +182,7 @@ namespace OnlineStore.DeviceLibrary
...
@@ -182,7 +182,7 @@ namespace OnlineStore.DeviceLibrary
MoveInfo
.
NextMoveStep
(
LineMoveStep
.
DLO_07_LineRun
);
MoveInfo
.
NextMoveStep
(
LineMoveStep
.
DLO_07_LineRun
);
MoveInfo
.
WaitList
.
Add
(
WaitResultInfo
.
WaitTime
(
2000
));
MoveInfo
.
WaitList
.
Add
(
WaitResultInfo
.
WaitTime
(
2000
));
LogUtil
.
info
(
Name
+
"送料【"
+
posId
+
"】:"
+
MoveInfo
.
SLog
+
" ["
+
LastTrayPosition
+
"],转动到下个工位"
);
LogUtil
.
info
(
Name
+
"送料【"
+
posId
+
"】:"
+
MoveInfo
.
SLog
+
" ["
+
LastTrayPosition
+
"],转动到下个工位"
);
lineRun
.
StartLineRun
(
Line
Run_Do
,
ExitLocation_Check
,
Line
EndProcess
);
lineRun
.
StartLineRun
(
LineEndProcess
);
}
}
else
if
(
MoveInfo
.
MoveStep
.
Equals
(
LineMoveStep
.
DLO_07_LineRun
))
else
if
(
MoveInfo
.
MoveStep
.
Equals
(
LineMoveStep
.
DLO_07_LineRun
))
...
@@ -218,7 +218,7 @@ namespace OnlineStore.DeviceLibrary
...
@@ -218,7 +218,7 @@ namespace OnlineStore.DeviceLibrary
}
}
private
bool
LineTurnIsStop
()
private
bool
LineTurnIsStop
()
{
{
if
(
lineRun
.
InTurn
.
Equals
(
false
)
)
if
(
lineRun
.
InTurn
.
Equals
(
false
))
{
{
if
(
equipBean
.
IOValue
(
LineRun_Do
).
Equals
(
IO_VALUE
.
LOW
))
if
(
equipBean
.
IOValue
(
LineRun_Do
).
Equals
(
IO_VALUE
.
LOW
))
{
{
...
@@ -233,7 +233,7 @@ namespace OnlineStore.DeviceLibrary
...
@@ -233,7 +233,7 @@ namespace OnlineStore.DeviceLibrary
}
}
}
}
return
false
;
return
false
;
}
}
/// <summary>
/// <summary>
/// 转动结束,最后一盘料的位置+1
/// 转动结束,最后一盘料的位置+1
...
@@ -281,24 +281,23 @@ namespace OnlineStore.DeviceLibrary
...
@@ -281,24 +281,23 @@ namespace OnlineStore.DeviceLibrary
public
void
TimerPro
()
public
void
TimerPro
()
{
{
//皮带线1出口无料
//皮带线1出口无料
if
(
IsInTurn
().
Equals
(
false
)
&&
HasTray
()
&&
lineRun
.
CanStart
())
if
(
IsInTurn
().
Equals
(
false
)
&&
HasTray
()
&&
lineRun
.
CanStart
())
{
{
if
(
MoveInfo
.
MoveType
.
Equals
(
LineMoveType
.
None
)
&&
if
(
MoveInfo
.
MoveType
.
Equals
(
LineMoveType
.
None
)
&&
equipBean
.
IOValue
(
ExitTray_Check
).
Equals
(
IO_VALUE
.
LOW
))
equipBean
.
IOValue
(
ExitTray_Check
).
Equals
(
IO_VALUE
.
LOW
))
{
{
//皮带线1出口无料
//皮带线1出口无料
lineRun
.
StartLineRun
(
LineEndProcess
);
lineRun
.
StartLineRun
(
LineRun_Do
,
ExitLocation_Check
,
LineEndProcess
);
}
}
else
if
(
MoveInfo
.
MoveStep
<=
LineMoveStep
.
DLO_01_NGBack
&&
MoveInfo
.
IsInWait
.
Equals
(
false
)
&&
else
if
(
MoveInfo
.
MoveStep
<=
LineMoveStep
.
DLO_01_NGBack
&&
MoveInfo
.
IsInWait
.
Equals
(
false
)
&&
equipBean
.
IOValue
(
ExitTray_Check
).
Equals
(
IO_VALUE
.
HIGH
))
equipBean
.
IOValue
(
ExitTray_Check
).
Equals
(
IO_VALUE
.
HIGH
))
{
{
//皮带线1出口有料,皮带3入库无料,且在停止状态
//皮带线1出口有料,皮带3入库无料,且在停止状态
if
(
equipBean
.
Line3TurnIsStop
()
&&
equipBean
.
IOValue
(
Line3_TrayCheck
).
Equals
(
IO_VALUE
.
LOW
))
if
(
equipBean
.
Line3TurnIsStop
()
&&
equipBean
.
IOValue
(
Line3_TrayCheck
).
Equals
(
IO_VALUE
.
LOW
))
{
{
Line3CanRun
=
false
;
Line3CanRun
=
false
;
LogUtil
.
debug
(
Name
+
"出口有料,且"
+
Line3_TrayCheck
+
"=LOW,转动一个工位,["
+
LineRun_Do
+
"] ["
+
ExitLocation_Check
+
"]"
);
LogUtil
.
debug
(
Name
+
"出口有料,且"
+
Line3_TrayCheck
+
"=LOW,转动一个工位,["
+
LineRun_Do
+
"] ["
+
ExitLocation_Check
+
"]"
);
lineRun
.
StartLineRun
(
Line
Run_Do
,
ExitLocation_Check
,
Line
EndProcess
);
lineRun
.
StartLineRun
(
LineEndProcess
);
}
}
}
}
}
}
...
@@ -310,10 +309,14 @@ namespace OnlineStore.DeviceLibrary
...
@@ -310,10 +309,14 @@ namespace OnlineStore.DeviceLibrary
public
delegate
void
TurnEndDel
(
bool
result
);
public
delegate
void
TurnEndDel
(
bool
result
);
public
TurnEndDel
turnEnd
=
null
;
public
TurnEndDel
turnEnd
=
null
;
public
bool
InTurn
=
false
;
public
bool
InTurn
=
false
;
private
string
Last
MoveDO
=
""
;
private
string
MoveDO
=
""
;
private
string
Last
CheckDI
=
""
;
private
string
CheckDI
=
""
;
private
int
subType
=
0
;
private
int
subType
=
0
;
internal
DateTime
LastEndTime
=
DateTime
.
Now
;
internal
DateTime
LastEndTime
=
DateTime
.
Now
;
private
bool
WaitCheckDI_High
=
false
;
private
bool
CheckDIHigh
=
false
;
public
bool
CanStart
(
int
totalMS
=
1000
)
public
bool
CanStart
(
int
totalMS
=
1000
)
{
{
TimeSpan
span
=
DateTime
.
Now
-
LastEndTime
;
TimeSpan
span
=
DateTime
.
Now
-
LastEndTime
;
...
@@ -323,50 +326,83 @@ namespace OnlineStore.DeviceLibrary
...
@@ -323,50 +326,83 @@ namespace OnlineStore.DeviceLibrary
}
}
return
false
;
return
false
;
}
}
public
LineTurnBean
(
int
subType
,
string
moveDO
=
""
,
string
checkDI
=
""
)
public
LineTurnBean
(
int
subType
)
{
{
this
.
subType
=
subType
;
this
.
subType
=
subType
;
this
.
MoveDO
=
moveDO
;
this
.
CheckDI
=
checkDI
;
if
(!
moveDO
.
Equals
(
""
)
&&
(!
checkDI
.
Equals
(
""
)))
{
//添加事件
AIOBOXManager
.
AddDIEvent
(
checkDI
,
subType
,
DIChangePro
);
}
}
public
void
DIChangePro
(
string
ioIP
,
ushort
index
,
IO_VALUE
oldValue
,
IO_VALUE
newValue
)
{
if
(
WaitCheckDI_High
&&
InTurn
&&
(!
CheckDIHigh
)
&&
oldValue
.
Equals
(
IO_VALUE
.
LOW
)
&&
newValue
.
Equals
(
IO_VALUE
.
HIGH
))
{
ConfigIO
config
=
IOManager
.
GetDI
(
CheckDI
,
subType
);
if
(
config
.
IO_IP
.
Equals
(
ioIP
)
&&
config
.
GetIOAddr
().
Equals
(
index
))
{
LogUtil
.
info
(
"收到DIChangeDelegate["
+
ioIP
+
"]["
+
index
+
"]["
+
oldValue
+
"]["
+
newValue
+
"],更新CheckDIHigh=true "
);
CheckDIHigh
=
true
;
}
}
}
}
public
void
StopLineRun
()
public
void
StopLineRun
()
{
{
if
(
InTurn
)
if
(
InTurn
)
{
{
WaitCheckDI_High
=
false
;
CheckDIHigh
=
false
;
InTurn
=
false
;
InTurn
=
false
;
}
}
}
}
public
void
StartLineRun
(
TurnEndDel
endProcess
,
int
timeOutMS
=
30000
)
{
StartLineRun
(
MoveDO
,
CheckDI
,
endProcess
,
timeOutMS
);
}
private
int
canWhileCount
=
3
;
private
int
canWhileCount
=
3
;
public
void
StartLineRun
(
string
moveDO
,
string
checkDI
,
TurnEndDel
endProcess
,
int
timeOutMS
=
30000
)
public
void
StartLineRun
(
string
moveDO
,
string
checkDI
,
TurnEndDel
endProcess
,
int
timeOutMS
=
30000
)
{
{
MoveDO
=
moveDO
;
CheckDI
=
checkDI
;
InTurn
=
true
;
InTurn
=
true
;
this
.
turnEnd
=
endProcess
;
this
.
turnEnd
=
endProcess
;
Task
.
Factory
.
StartNew
(
delegate
Task
.
Factory
.
StartNew
(
delegate
{
{
canWhileCount
=
3
;
canWhileCount
=
3
;
LineRunAndWait
(
moveDO
,
checkDI
,
timeOutMS
);
LineRunAndWait
(
timeOutMS
);
});
});
}
}
private
string
LineRunAndWait
(
string
moveDO
,
string
checkDI
,
int
timeOutMS
=
30000
)
private
string
LineRunAndWait
(
int
timeOutMS
=
30000
)
{
{
LastMoveDO
=
moveDO
;
//MoveDO = moveDO;
LastCheckDI
=
checkDI
;
//CheckDI = checkDI;
LogUtil
.
debug
(
subType
+
"开始转动:"
+
moveDO
+
",等待信号:"
+
checkDI
+
""
);
string
logName
=
"LineTurn["
+
subType
+
"]["
+
MoveDO
+
"]["
+
CheckDI
+
"] "
;
IOManager
.
IOMove
(
moveDO
,
IO_VALUE
.
HIGH
,
subType
);
LogUtil
.
debug
(
"开始转动:"
+
logName
);
IOManager
.
IOMove
(
MoveDO
,
IO_VALUE
.
HIGH
,
subType
);
InTurn
=
true
;
InTurn
=
true
;
DateTime
startTime
=
DateTime
.
Now
;
DateTime
startTime
=
DateTime
.
Now
;
string
result
=
""
;
string
result
=
""
;
bool
isStop
=
false
;
bool
isStop
=
false
;
WaitCheckDI_High
=
false
;
CheckDIHigh
=
false
;
//先等待信号灭一次,然后再亮时停止
//先等待信号灭一次,然后再亮时停止
while
(
true
)
while
(
true
)
{
{
Thread
.
Sleep
(
20
);
Thread
.
Sleep
(
20
);
TimeSpan
span
=
DateTime
.
Now
-
startTime
;
TimeSpan
span
=
DateTime
.
Now
-
startTime
;
if
(
span
.
TotalSeconds
>
1
&&
IOManager
.
IOValue
(
m
oveDO
,
subType
).
Equals
(
IO_VALUE
.
LOW
))
if
(
span
.
TotalSeconds
>
1
&&
IOManager
.
IOValue
(
M
oveDO
,
subType
).
Equals
(
IO_VALUE
.
LOW
))
{
{
LogUtil
.
error
(
subType
+
" LineRunAndWait1 转动["
+
moveDO
+
"]["
+
checkDI
+
"],已等待["
+
FormUtil
.
GetSpanStr
(
span
)
+
"],重写IO:"
+
moveDO
);
LogUtil
.
error
(
logName
+
"转动,已等待["
+
FormUtil
.
GetSpanStr
(
span
)
+
"],重写DO"
);
IOManager
.
IOMove
(
m
oveDO
,
IO_VALUE
.
HIGH
,
subType
);
IOManager
.
IOMove
(
M
oveDO
,
IO_VALUE
.
HIGH
,
subType
);
}
}
if
(!
InTurn
)
if
(!
InTurn
)
{
{
...
@@ -379,7 +415,7 @@ namespace OnlineStore.DeviceLibrary
...
@@ -379,7 +415,7 @@ namespace OnlineStore.DeviceLibrary
result
=
"转动超时"
;
result
=
"转动超时"
;
}
}
//判断Buzy及位置是否结束
//判断Buzy及位置是否结束
else
if
(
IOManager
.
IOValue
(
c
heckDI
,
subType
).
Equals
(
IO_VALUE
.
LOW
))
else
if
(
IOManager
.
IOValue
(
C
heckDI
,
subType
).
Equals
(
IO_VALUE
.
LOW
))
{
{
isStop
=
true
;
isStop
=
true
;
}
}
...
@@ -387,27 +423,29 @@ namespace OnlineStore.DeviceLibrary
...
@@ -387,27 +423,29 @@ namespace OnlineStore.DeviceLibrary
{
{
if
(
result
.
Equals
(
""
))
if
(
result
.
Equals
(
""
))
{
{
LogUtil
.
debug
(
subType
+
"验证"
+
c
heckDI
+
"=Low结束:"
+
result
);
LogUtil
.
debug
(
logName
+
"验证"
+
C
heckDI
+
"=Low结束:"
+
result
);
}
}
else
else
{
{
LogUtil
.
info
(
subType
+
"["
+
moveDO
+
"] ["
+
checkDI
+
"] 验证"
+
c
heckDI
+
"=Low结束:"
+
result
);
LogUtil
.
info
(
logName
+
" 验证"
+
C
heckDI
+
"=Low结束:"
+
result
);
}
}
break
;
break
;
}
}
}
}
result
=
""
;
result
=
""
;
isStop
=
false
;
isStop
=
false
;
WaitCheckDI_High
=
true
;
CheckDIHigh
=
false
;
while
(
true
)
while
(
true
)
{
{
Thread
.
Sleep
(
10
);
Thread
.
Sleep
(
10
);
TimeSpan
span
=
DateTime
.
Now
-
startTime
;
TimeSpan
span
=
DateTime
.
Now
-
startTime
;
bool
isRestart
=
false
;
bool
isRestart
=
false
;
if
(
span
.
TotalSeconds
>
2
&&
IOManager
.
IOValue
(
m
oveDO
,
subType
).
Equals
(
IO_VALUE
.
LOW
))
if
(
span
.
TotalSeconds
>
2
&&
IOManager
.
IOValue
(
M
oveDO
,
subType
).
Equals
(
IO_VALUE
.
LOW
))
{
{
LogUtil
.
error
(
subType
+
" LineRunAndWait2 转动["
+
moveDO
+
"]["
+
checkDI
+
"],已等待["
+
FormUtil
.
GetSpanStr
(
span
)
+
"],重写IO:"
+
moveDO
);
LogUtil
.
error
(
logName
+
" 转动已等待["
+
FormUtil
.
GetSpanStr
(
span
)
+
"],重写DO"
);
IOManager
.
IOMove
(
m
oveDO
,
IO_VALUE
.
HIGH
,
subType
);
IOManager
.
IOMove
(
M
oveDO
,
IO_VALUE
.
HIGH
,
subType
);
}
}
if
(!
InTurn
)
if
(!
InTurn
)
{
{
...
@@ -420,14 +458,14 @@ namespace OnlineStore.DeviceLibrary
...
@@ -420,14 +458,14 @@ namespace OnlineStore.DeviceLibrary
result
=
"转动超时"
;
result
=
"转动超时"
;
}
}
//判断Buzy及位置是否结束
//判断Buzy及位置是否结束
else
if
(
IOManager
.
IOValue
(
checkDI
,
subType
).
Equals
(
IO_VALUE
.
HIGH
)
)
else
if
(
IOManager
.
IOValue
(
CheckDI
,
subType
).
Equals
(
IO_VALUE
.
HIGH
)
||
CheckDIHigh
)
{
{
if
(
canWhileCount
>
0
&&
span
.
TotalMilliseconds
<
800
)
if
(
canWhileCount
>
0
&&
span
.
TotalMilliseconds
<
800
)
{
{
isRestart
=
true
;
isRestart
=
true
;
canWhileCount
--;
canWhileCount
--;
LogUtil
.
info
(
subType
+
" 异常停止,重新开始转动:["
+
moveDO
+
"] ["
+
checkDI
+
"] 耗时 ["
+
FormUtil
.
GetSpanStr
(
span
)
+
"]["
+
canWhileCount
+
"]"
);
LogUtil
.
info
(
logName
+
" 异常停止,重新开始转动: 耗时 ["
+
FormUtil
.
GetSpanStr
(
span
)
+
"]["
+
canWhileCount
+
"]"
);
return
LineRunAndWait
(
moveDO
,
checkDI
,
timeOutMS
);
return
LineRunAndWait
(
timeOutMS
);
}
}
isStop
=
true
;
isStop
=
true
;
}
}
...
@@ -438,19 +476,19 @@ namespace OnlineStore.DeviceLibrary
...
@@ -438,19 +476,19 @@ namespace OnlineStore.DeviceLibrary
//正常4-5秒
//正常4-5秒
if
(
span
.
TotalSeconds
>=
1
&&
span
.
TotalSeconds
<=
6
)
if
(
span
.
TotalSeconds
>=
1
&&
span
.
TotalSeconds
<=
6
)
{
{
LogUtil
.
debug
(
subType
+
"停止运动:["
+
moveDO
+
"] ["
+
checkDI
+
"]
耗时 ["
+
FormUtil
.
GetSpanStr
(
span
)
+
"]["
+
canWhileCount
+
"]"
);
LogUtil
.
debug
(
logName
+
"停止运动:
耗时 ["
+
FormUtil
.
GetSpanStr
(
span
)
+
"]["
+
canWhileCount
+
"]"
);
}
}
else
else
{
{
LogUtil
.
info
(
subType
+
"停止运动:["
+
moveDO
+
"] ["
+
checkDI
+
"]
耗时 ["
+
FormUtil
.
GetSpanStr
(
span
)
+
"]["
+
canWhileCount
+
"]"
);
LogUtil
.
info
(
logName
+
"停止运动:
耗时 ["
+
FormUtil
.
GetSpanStr
(
span
)
+
"]["
+
canWhileCount
+
"]"
);
}
}
}
}
else
else
{
{
LogUtil
.
info
(
subType
+
"["
+
moveDO
+
"] ["
+
checkDI
+
"] 停止运动:"
+
result
+
" "
+
m
oveDO
);
LogUtil
.
info
(
logName
+
" 停止运动:"
+
result
+
" "
+
M
oveDO
);
}
}
LastEndTime
=
DateTime
.
Now
;
LastEndTime
=
DateTime
.
Now
;
IOManager
.
IOMove
(
m
oveDO
,
IO_VALUE
.
LOW
,
subType
);
IOManager
.
IOMove
(
M
oveDO
,
IO_VALUE
.
LOW
,
subType
);
if
(!
isRestart
)
if
(!
isRestart
)
{
{
Task
.
Factory
.
StartNew
(
delegate
Task
.
Factory
.
StartNew
(
delegate
...
@@ -459,11 +497,13 @@ namespace OnlineStore.DeviceLibrary
...
@@ -459,11 +497,13 @@ namespace OnlineStore.DeviceLibrary
});
});
}
}
InTurn
=
false
;
InTurn
=
false
;
WaitCheckDI_High
=
false
;
CheckDIHigh
=
false
;
return
result
;
return
result
;
}
}
}
}
}
}
}
}
}
}
source/DeviceLibrary/deviceLibrary/IO/AIOBOX/AIOBOXManager.cs
查看文件 @
4925708
...
@@ -28,19 +28,19 @@ namespace OnlineStore.DeviceLibrary
...
@@ -28,19 +28,19 @@ namespace OnlineStore.DeviceLibrary
private
object
DILock
=
""
;
private
object
DILock
=
""
;
private
object
DOLock
=
""
;
private
object
DOLock
=
""
;
public
override
void
ConnectionIOList
(
List
<
string
>
DIONameList
)
public
override
void
ConnectionIOList
(
List
<
string
>
DIONameList
)
{
{
foreach
(
string
ip
in
DIONameList
)
foreach
(
string
ip
in
DIONameList
)
{
{
ConnectionIP
(
ip
);
ConnectionIP
(
ip
);
}
}
}
}
private
bool
isProcess
=
false
;
private
bool
isProcess
=
false
;
private
DateTime
lastTime
=
DateTime
.
Now
;
private
DateTime
lastTime
=
DateTime
.
Now
;
public
void
ConnectionIP
(
string
ioIp
)
public
void
ConnectionIP
(
string
ioIp
)
{
{
AIOBOX
aioBox
=
null
;
AIOBOX
aioBox
=
null
;
...
@@ -97,29 +97,29 @@ namespace OnlineStore.DeviceLibrary
...
@@ -97,29 +97,29 @@ namespace OnlineStore.DeviceLibrary
aioBox
=
new
AIOBOX
(
Asa
.
IOModule
.
Box_Type
.
DI
,
DILength
,
Asa
.
IOModule
.
Box_Type
.
DO
,
DOLength
);
aioBox
=
new
AIOBOX
(
Asa
.
IOModule
.
Box_Type
.
DI
,
DILength
,
Asa
.
IOModule
.
Box_Type
.
DO
,
DOLength
);
aioBox
.
IP
=
ioIp
;
aioBox
.
IP
=
ioIp
;
aioBox
.
Upload
=
true
;
aioBox
.
Upload
=
true
;
aioBox
.
DI_Changed_Event
+=
AioBox_DI_Changed_Event
;
;
aioBox
.
DI_Changed_Event
+=
AioBox_DI_Changed_Event
;
;
aioBox
.
DO_Changed_Event
+=
AioBox_DO_Changed_Event
;
aioBox
.
DO_Changed_Event
+=
AioBox_DO_Changed_Event
;
LogUtil
.
info
(
"开始连接:"
+
logName
+
":"
+
aioBox
.
ErrInfo
);
LogUtil
.
info
(
"开始连接:"
+
logName
+
":"
+
aioBox
.
ErrInfo
);
aioBox
.
Connect
();
aioBox
.
Connect
();
AIOMap
.
Add
(
ioIp
,
aioBox
);
AIOMap
.
Add
(
ioIp
,
aioBox
);
Thread
.
Sleep
(
5
);
Thread
.
Sleep
(
5
);
//读取所有的DO
//读取所有的DO
ReadAllDI
(
ioIp
,
0
);
ReadAllDI
(
ioIp
,
0
);
Thread
.
Sleep
(
5
);
Thread
.
Sleep
(
5
);
GC
.
Collect
();
GC
.
Collect
();
}
}
catch
(
Exception
error
)
catch
(
Exception
error
)
{
{
LogUtil
.
error
(
LOGGER
,
"连接IO模块 "
+
logName
+
" 出错:"
+
error
.
ToString
());
LogUtil
.
error
(
LOGGER
,
"连接IO模块 "
+
logName
+
" 出错:"
+
error
.
ToString
());
}
}
}
}
private
DateTime
lastLogTime
=
DateTime
.
Now
;
private
DateTime
lastLogTime
=
DateTime
.
Now
;
private
void
AioBox_Log_Out_Event
(
AIOBOX
box
,
string
[]
s
)
private
void
AioBox_Log_Out_Event
(
AIOBOX
box
,
string
[]
s
)
{
{
foreach
(
string
str
in
s
)
foreach
(
string
str
in
s
)
...
@@ -202,17 +202,8 @@ namespace OnlineStore.DeviceLibrary
...
@@ -202,17 +202,8 @@ namespace OnlineStore.DeviceLibrary
if
(!(
oldList
[
i
].
Equals
(
newList
[
i
])))
if
(!(
oldList
[
i
].
Equals
(
newList
[
i
])))
{
{
needUpdate
=
true
;
needUpdate
=
true
;
//if (IsAxisCheckDI(ip, i))
//{
// // LogUtil.info("AIOBOXManager UpdateDI [" + ip + "][" + i + "],从" + oldList[i] + "变为" + newList[i]);
//}
break
;
break
;
}
}
//if (needUpdate && i >= 2)
//{
// break;
//}
}
}
}
}
if
(
needUpdate
)
if
(
needUpdate
)
...
@@ -225,6 +216,28 @@ namespace OnlineStore.DeviceLibrary
...
@@ -225,6 +216,28 @@ namespace OnlineStore.DeviceLibrary
}
}
DIValueMap
.
Add
(
ip
,
newList
);
DIValueMap
.
Add
(
ip
,
newList
);
}
}
try
{
if
(
oldList
!=
null
&&
newList
!=
null
)
{
foreach
(
ConfigIO
io
in
DIChangeMap
.
Keys
)
{
if
(
io
.
IO_IP
.
Equals
(
ip
))
{
IO_VALUE
oldV
=
GetBox_Value
(
oldList
[
io
.
GetIOAddr
()]);
IO_VALUE
newV
=
GetBox_Value
(
newList
[
io
.
GetIOAddr
()]);
if
(!
oldV
.
Equals
(
newV
))
{
DIChangeMap
[
io
].
Invoke
(
ip
,
io
.
GetIOAddr
(),
oldV
,
newV
);
}
}
}
}
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
"UpdateAllDI处理事件出错:"
+
ex
.
ToString
());
}
}
}
}
}
}
}
...
@@ -238,7 +251,7 @@ namespace OnlineStore.DeviceLibrary
...
@@ -238,7 +251,7 @@ namespace OnlineStore.DeviceLibrary
newList
.
AddRange
(
sta
);
newList
.
AddRange
(
sta
);
List
<
Box_Sta
>
oldList
=
null
;
List
<
Box_Sta
>
oldList
=
null
;
DOValueMap
.
TryGetValue
(
ip
,
out
oldList
);
DOValueMap
.
TryGetValue
(
ip
,
out
oldList
);
if
(
oldList
==
null
||
oldList
.
Count
.
Equals
(
newList
.
Count
).
Equals
(
false
))
if
(
oldList
==
null
||
oldList
.
Count
.
Equals
(
newList
.
Count
).
Equals
(
false
))
{
{
needUpdate
=
true
;
needUpdate
=
true
;
...
@@ -449,7 +462,8 @@ namespace OnlineStore.DeviceLibrary
...
@@ -449,7 +462,8 @@ namespace OnlineStore.DeviceLibrary
if
(
sta
.
Equals
(
Box_Sta
.
On
))
if
(
sta
.
Equals
(
Box_Sta
.
On
))
{
{
value
=
IO_VALUE
.
HIGH
;
value
=
IO_VALUE
.
HIGH
;
}
else
}
else
{
{
value
=
IO_VALUE
.
LOW
;
value
=
IO_VALUE
.
LOW
;
}
}
...
@@ -458,7 +472,7 @@ namespace OnlineStore.DeviceLibrary
...
@@ -458,7 +472,7 @@ namespace OnlineStore.DeviceLibrary
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
{
{
LogUtil
.
error
(
" 第【"
+
i
+
"】次 GetDIValue ["
+
ioIP
+
"] ["
+
StartAddress
+
"] 出错:"
,
ex
);
LogUtil
.
error
(
" 第【"
+
i
+
"】次 GetDIValue ["
+
ioIP
+
"] ["
+
StartAddress
+
"] 出错:"
,
ex
);
}
}
}
}
return
value
;
return
value
;
...
@@ -495,6 +509,18 @@ namespace OnlineStore.DeviceLibrary
...
@@ -495,6 +509,18 @@ namespace OnlineStore.DeviceLibrary
return
Box_Sta
.
Off
;
return
Box_Sta
.
Off
;
}
}
}
}
private
IO_VALUE
GetBox_Value
(
Box_Sta
onOff
)
{
if
(
onOff
.
Equals
(
Box_Sta
.
On
))
{
return
IO_VALUE
.
HIGH
;
}
else
{
return
IO_VALUE
.
LOW
;
}
}
private
AIOBOX
getAIO
(
string
ioIp
)
private
AIOBOX
getAIO
(
string
ioIp
)
{
{
...
...
source/DeviceLibrary/deviceLibrary/IO/IOManager.cs
查看文件 @
4925708
...
@@ -10,6 +10,17 @@ namespace OnlineStore.DeviceLibrary
...
@@ -10,6 +10,17 @@ namespace OnlineStore.DeviceLibrary
{
{
public
abstract
class
IOManager
public
abstract
class
IOManager
{
{
public
delegate
void
DIChangeDelegate
(
string
ioIP
,
ushort
index
,
IO_VALUE
oldValue
,
IO_VALUE
newValue
);
internal
static
Dictionary
<
ConfigIO
,
DIChangeDelegate
>
DIChangeMap
=
new
Dictionary
<
ConfigIO
,
DIChangeDelegate
>();
public
static
void
AddDIEvent
(
string
diType
,
int
subType
,
DIChangeDelegate
del
)
{
ConfigIO
Di
=
GetDI
(
diType
,
subType
);
if
(
Di
!=
null
)
{
DIChangeMap
.
Add
(
Di
,
del
);
}
}
public
static
IOManager
instance
=
null
;
public
static
IOManager
instance
=
null
;
public
abstract
void
ConnectionIOList
(
List
<
string
>
dIODeviceNameList
);
public
abstract
void
ConnectionIOList
(
List
<
string
>
dIODeviceNameList
);
...
@@ -21,25 +32,7 @@ namespace OnlineStore.DeviceLibrary
...
@@ -21,25 +32,7 @@ namespace OnlineStore.DeviceLibrary
{
{
ConfigIO
configIo
=
GetDO
(
ioType
,
subType
);
ConfigIO
configIo
=
GetDO
(
ioType
,
subType
);
if
(
configIo
!=
null
)
if
(
configIo
!=
null
)
{
{
//try
//{
// //如果是出料四阻挡下降,添加日志
// if ((configIo.IO_IP.Equals("192.168.101.49") || configIo.IO_IP.Equals("192.168.101.41")) && configIo.GetIOAddr().Equals(4))
// {
// if (ioValue.Equals(IO_VALUE.HIGH))
// {
// LogUtil.info("IOMove: ioValue= " + ioValue + ", [ " + subType + "] [" + ioType + "] [" + configIo.IO_IP + "][4]");
// }
// else if (instance.GetDOValue(configIo.IO_IP, configIo.SlaveID, configIo.GetIOAddr()).Equals(IO_VALUE.HIGH))
// { //如果上次是high,打印
// LogUtil.info("IOMove: ioValue= " + ioValue + ", [ " + subType + "] [" + ioType + "][" + configIo.IO_IP + "][4]");
// }
// }
//}catch(Exception ex)
//{
//}
instance
.
WriteSingleDO
(
configIo
.
IO_IP
,
configIo
.
SlaveID
,
configIo
.
GetIOAddr
(),
ioValue
);
instance
.
WriteSingleDO
(
configIo
.
IO_IP
,
configIo
.
SlaveID
,
configIo
.
GetIOAddr
(),
ioValue
);
Thread
.
Sleep
(
10
);
Thread
.
Sleep
(
10
);
}
}
...
@@ -105,7 +98,7 @@ namespace OnlineStore.DeviceLibrary
...
@@ -105,7 +98,7 @@ namespace OnlineStore.DeviceLibrary
}
}
return
ioValue
;
return
ioValue
;
}
}
private
static
ConfigIO
GetDI
(
string
ioType
,
int
subType
)
internal
static
ConfigIO
GetDI
(
string
ioType
,
int
subType
)
{
{
ConfigIO
configIo
=
null
;
ConfigIO
configIo
=
null
;
if
(
subType
<=
0
)
if
(
subType
<=
0
)
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论