Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
李娜
/
SO664-AssemblyLine
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 0aff9dd7
由
张东亮
编写于
2023-11-24 14:17:59 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
timer改为线程
1 个父辈
7290c4f8
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
12 个修改的文件
包含
210 行增加
和
67 行删除
source/DeviceLibrary/DeviceLibrary.csproj
source/DeviceLibrary/assemblyLine/EquipBase.cs
source/DeviceLibrary/assemblyLine/FeedingEquip.cs
source/DeviceLibrary/assemblyLine/HY/HY_C1Line.cs
source/DeviceLibrary/assemblyLine/HY/HY_C1_SLStation.cs
source/DeviceLibrary/assemblyLine/HY/HY_Coveryor.cs
source/DeviceLibrary/assemblyLine/HY/HY_Coveryor_Partial.cs
source/DeviceLibrary/assemblyLine/HY/HY_OutLine.cs
source/DeviceLibrary/assemblyLine/LineBean.cs
source/DeviceLibrary/assemblyLine/MoveEquip.cs
source/DeviceLibrary/model/KTK_Store.cs
source/HuichuanLibrary/HCLogUtil.cs
source/DeviceLibrary/DeviceLibrary.csproj
查看文件 @
0aff9dd
...
...
@@ -49,6 +49,9 @@
<Reference Include="CodeLibrary">
<HintPath>..\..\dll\CodeLibrary.dll</HintPath>
</Reference>
<Reference Include="ConfigHelper">
<HintPath>..\..\..\..\..\..\SharedRefDll\Neotel\ConfigHelper\Debug\net461\ConfigHelper.dll</HintPath>
</Reference>
<Reference Include="halcondotnet">
<HintPath>..\..\dll\halcondotnet.dll</HintPath>
</Reference>
...
...
source/DeviceLibrary/assemblyLine/EquipBase.cs
查看文件 @
0aff9dd
此文件的差异被折叠,
点击展开。
source/DeviceLibrary/assemblyLine/FeedingEquip.cs
查看文件 @
0aff9dd
...
...
@@ -45,7 +45,8 @@ namespace OnlineStore.DeviceLibrary
RFIDIP
=
RFIDManager
.
GetRFIP
(
DeviceID
);
HasOutLine
=
config
.
DOList
.
ContainsKey
(
IO_Type
.
SL_OutLine_Run
);
addLastDI
(
IO_Type
.
SL_Reset_BTN
,
IO_VALUE
.
LOW
);
mainTimer
.
Enabled
=
true
;
//mainTimer.Enabled = true;
mainStart
();
}
public
override
bool
StartRun
(
bool
isDebug
=
false
)
...
...
@@ -68,7 +69,8 @@ namespace OnlineStore.DeviceLibrary
}
if
(
RunAxis
(
true
,
BatchAxis
)
&&
RunAxis
(
true
,
UpdownAxis
))
{
mainTimer
.
Enabled
=
false
;
//mainTimer.Enabled = false;
mainStop
();
MoveInfo
.
EndMove
();
SecondMoveInfo
.
EndMove
();
runStatus
=
LineRunStatus
.
HomeMoving
;
...
...
@@ -81,7 +83,8 @@ namespace OnlineStore.DeviceLibrary
if
(
isDebug
)
{
LogInfo
(
"开始调试,启动定时器 "
);
mainTimer
.
Start
();
//mainTimer.Start();
mainStart
();
}
return
true
;
}
...
...
@@ -335,10 +338,11 @@ namespace OnlineStore.DeviceLibrary
public
override
void
StopRun
()
{
runStatus
=
LineRunStatus
.
Wait
;
if
(
mainTimer
!=
null
)
{
mainTimer
.
Enabled
=
false
;
}
//if (mainTimer != null)
//{
// mainTimer.Enabled = false;
//}
mainStop
();
StopMove
();
CloseLed
();
AgvClient
.
SetStatus
(
Config
.
AgvInName
,
""
,
ClientAction
.
None
,
ClientLevel
.
Low
,
true
);
...
...
@@ -364,7 +368,8 @@ namespace OnlineStore.DeviceLibrary
if
(!
isOk
)
{
LogUtil
.
error
(
"启动失败,等待下次启动"
);
mainTimer
.
Enabled
=
true
;
// mainTimer.Enabled = true;
mainStart
();
}
}
return
;
...
...
source/DeviceLibrary/assemblyLine/HY/HY_C1Line.cs
查看文件 @
0aff9dd
...
...
@@ -28,14 +28,16 @@ namespace OnlineStore.DeviceLibrary
{
return
false
;
}
mainTimer
.
Enabled
=
false
;
//mainTimer.Enabled = false;
mainStop
();
MoveInfo
.
EndMove
();
runStatus
=
LineRunStatus
.
HomeMoving
;
MoveInfo
.
NewMove
(
LineMoveType
.
RHome
);
StartReset
();
if
(
isDebug
)
{
mainTimer
.
Enabled
=
true
;
//mainTimer.Enabled = true;
mainStart
();
}
return
true
;
}
...
...
@@ -132,10 +134,11 @@ namespace OnlineStore.DeviceLibrary
public
override
void
StopRun
()
{
if
(
mainTimer
!=
null
)
{
mainTimer
.
Enabled
=
false
;
}
//if (mainTimer != null)
//{
// mainTimer.Enabled = false;
//}
mainStop
();
StopMove
();
runStatus
=
LineRunStatus
.
Wait
;
...
...
source/DeviceLibrary/assemblyLine/HY/HY_C1_SLStation.cs
查看文件 @
0aff9dd
...
...
@@ -27,16 +27,18 @@ namespace OnlineStore.DeviceLibrary
if
(
CanStartRun
().
Equals
(
false
))
{
return
false
;
}
}
mainTimer
.
Enabled
=
false
;
//mainTimer.Enabled = false;
mainStop
();
MoveInfo
.
EndMove
();
runStatus
=
LineRunStatus
.
HomeMoving
;
MoveInfo
.
NewMove
(
LineMoveType
.
RHome
);
StartReset
();
if
(
isDebug
)
{
mainTimer
.
Enabled
=
true
;
//mainTimer.Enabled = true;
mainStart
();
}
return
true
;
}
...
...
@@ -126,10 +128,11 @@ namespace OnlineStore.DeviceLibrary
public
override
void
StopRun
()
{
if
(
mainTimer
!=
null
)
{
mainTimer
.
Enabled
=
false
;
}
//if (mainTimer != null)
//{
// mainTimer.Enabled = false;
//}
mainStop
();
StopMove
();
runStatus
=
LineRunStatus
.
Wait
;
...
...
source/DeviceLibrary/assemblyLine/HY/HY_Coveryor.cs
查看文件 @
0aff9dd
...
...
@@ -43,16 +43,18 @@ namespace OnlineStore.DeviceLibrary
{
return
false
;
}
mainTimer
.
Enabled
=
false
;
// mainTimer.Enabled = false;
mainStop
();
MoveInfo
.
EndMove
();
runStatus
=
LineRunStatus
.
HomeMoving
;
MoveInfo
.
NewMove
(
LineMoveType
.
RHome
);
StartReset
();
if
(
isDebug
)
{
mainTimer
.
Interval
=
300
;
mainTimer
.
Enabled
=
true
;
LogInfo
(
"StartRun 设置 Interval=180 ,启动定时器"
);
//mainTimer.Interval = 300;
//mainTimer.Enabled = true;
mainStart
();
LogInfo
(
"StartRun 设置 Interval=300,启动定时器"
);
}
return
true
;
}
...
...
@@ -120,12 +122,15 @@ namespace OnlineStore.DeviceLibrary
}
else
if
(
MoveInfo
.
IsStep
(
LineMoveStep
.
JHY_R05_ClampCheck
))
{
if
(!
mainTimer
.
Enabl
ed
)
if
(!
IsMainStart
ed
)
{
mainTimer
.
Enabled
=
true
;
//mainTimer.Enabled = true;
mainStart
();
SetInterval
(
180
);
LogInfo
(
"复位完成 设置 mainTimer.Enabled = true "
);
}
mainTimer
.
Interval
=
180
;
//mainTimer.Interval = 180;
SetInterval
(
180
);
LogInfo
(
"复位完成 设置 Interval=180 "
);
LogInfo
(
MoveInfo
.
MoveType
+
" 完成!"
);
MoveEndS
();
...
...
@@ -154,10 +159,11 @@ namespace OnlineStore.DeviceLibrary
}
public
override
void
StopRun
()
{
if
(
mainTimer
!=
null
)
{
mainTimer
.
Enabled
=
false
;
}
//if (mainTimer != null)
//{
// mainTimer.Enabled = false;
//}
mainStop
();
StopMove
();
//CheckAndMove(IO_Type.HY_ClampCylinder_Work, IO_VALUE.LOW);
//CheckAndMove(IO_Type.HY_ClampCylinder_Relax, IO_VALUE.LOW);
...
...
source/DeviceLibrary/assemblyLine/HY/HY_Coveryor_Partial.cs
查看文件 @
0aff9dd
...
...
@@ -93,8 +93,8 @@ namespace OnlineStore.DeviceLibrary
//CheckStopWatch(trayCheckWait, TrayWaitTime, false) &&
if
(
check2IsOk
&&
canpro
)
{
StartTrayCheck
();
//
StartTrayCheck();
Start_JHY_05_TrayCheck
();
}
}
// else
...
...
@@ -191,9 +191,8 @@ namespace OnlineStore.DeviceLibrary
SecondMoveInfo
.
NewMove
(
LineMoveType
.
Fixture
);
SecondMoveInfo
.
NextMoveStep
(
LineMoveStep
.
JHY_05_TrayCheck
);
CheckLog
(
"接驳台托盘"
+
SecondMoveInfo
.
SLog
+
"前阻挡下降1.2s,等待托盘到位 "
);
//IOMove(IO_Type.HY_FrontStopDown, IO_VALUE.LOW);
IOMove
(
IO_Type
.
HY_FrontStopDown
,
IO_VALUE
.
HIGH
,
1200
);
CheckLog
(
"接驳台托盘"
+
SecondMoveInfo
.
SLog
+
"前阻挡上升,等待托盘到位 "
);
IOMove
(
IO_Type
.
HY_FrontStopDown
,
IO_VALUE
.
LOW
);
SecondMoveInfo
.
WaitList
.
Add
(
WaitResultInfo
.
WaitIO
(
IO_Type
.
HY_FrontStopDown
,
IO_VALUE
.
LOW
));
SecondMoveInfo
.
WaitList
.
Add
(
WaitResultInfo
.
WaitIO
(
IO_Type
.
HY_TrayCheck
,
IO_VALUE
.
HIGH
));
...
...
source/DeviceLibrary/assemblyLine/HY/HY_OutLine.cs
查看文件 @
0aff9dd
...
...
@@ -24,14 +24,16 @@ namespace OnlineStore.DeviceLibrary
{
return
false
;
}
mainTimer
.
Enabled
=
false
;
//mainTimer.Enabled = false;
mainStop
();
MoveInfo
.
EndMove
();
runStatus
=
LineRunStatus
.
HomeMoving
;
MoveInfo
.
NewMove
(
LineMoveType
.
RHome
);
StartReset
();
if
(
isDebug
)
{
mainTimer
.
Enabled
=
true
;
//mainTimer.Enabled = true;
mainStart
();
}
return
true
;
}
...
...
@@ -95,10 +97,11 @@ namespace OnlineStore.DeviceLibrary
public
override
void
StopRun
()
{
if
(
mainTimer
!=
null
)
{
mainTimer
.
Enabled
=
false
;
}
//if (mainTimer != null)
//{
// mainTimer.Enabled = false;
//}
mainStop
();
StopMove
();
runStatus
=
LineRunStatus
.
Wait
;
...
...
source/DeviceLibrary/assemblyLine/LineBean.cs
查看文件 @
0aff9dd
此文件的差异被折叠,
点击展开。
source/DeviceLibrary/assemblyLine/MoveEquip.cs
查看文件 @
0aff9dd
...
...
@@ -70,7 +70,8 @@ namespace OnlineStore.DeviceLibrary
return
false
;
}
mainTimer
.
Enabled
=
false
;
//mainTimer.Enabled = false;
mainStop
();
MoveInfo
.
EndMove
();
SecondMoveInfo
.
EndMove
();
runStatus
=
LineRunStatus
.
HomeMoving
;
...
...
@@ -79,7 +80,8 @@ namespace OnlineStore.DeviceLibrary
StartReset
();
if
(
isDebug
)
{
mainTimer
.
Enabled
=
true
;
// mainTimer.Enabled = true;
mainStart
();
}
return
true
;
}
...
...
@@ -205,10 +207,11 @@ namespace OnlineStore.DeviceLibrary
public
override
void
StopRun
()
{
if
(
mainTimer
!=
null
)
{
mainTimer
.
Enabled
=
false
;
}
//if (mainTimer != null)
//{
// mainTimer.Enabled = false;
//}
mainStop
();
StopMove
();
//停止运行时,把所有IO 置零
//CheckAndMove(IO_Type.StopDown1, IO_VALUE.LOW);
...
...
source/DeviceLibrary/model/KTK_Store.cs
查看文件 @
0aff9dd
using
log4net
;
using
log4net
;
using
OnlineStore.Common
;
using
OnlineStore.LoadCSVLibrary
;
using
System
;
...
...
@@ -24,11 +24,30 @@ namespace OnlineStore.DeviceLibrary
public
int
DeviceID
{
get
;
set
;
}
protected
System
.
Timers
.
Timer
mainTimer
;
protected
Thread
mainThread
;
protected
bool
loop
;
protected
bool
pause
=
false
;
protected
int
threadInterval
=
300
;
private
bool
isInit
=
false
;
public
bool
mainTimerStart
{
get
=>
mainTimer
.
Enabled
;
}
/// <summary>
/// 使用timer定时器
/// </summary>
protected
bool
useTimer
=
ConfigHelper
.
Config
.
Get
(
"Device_MainThreadUseTimer"
,
true
);
public
bool
IsMainStarted
{
get
{
if
(
useTimer
)
{
return
mainTimer
.
Enabled
;
}
else
{
return
!
pause
;
}
}
}
//public bool mainTimerStart { get => mainTimer.Enabled; }
/// <summary>
/// 托盘检测信号需要持续时间
...
...
@@ -37,6 +56,62 @@ namespace OnlineStore.DeviceLibrary
public
KTK_Store
()
{
}
~
KTK_Store
()
{
if
(
useTimer
)
{
}
else
{
loop
=
false
;
}
}
/// <summary>
/// 主进程启动
/// </summary>
public
void
mainStart
()
{
if
(
useTimer
)
{
if
(
mainTimer
!=
null
)
{
mainTimer
.
Start
();
}
}
else
{
// pause = false;
}
}
public
void
SetInterval
(
int
interval
=
300
)
{
if
(
useTimer
)
{
if
(
mainTimer
!=
null
)
{
mainTimer
.
Interval
=
interval
;
}
}
else
{
threadInterval
=
interval
;
}
}
/// <summary>
/// 主进程停止
/// </summary>
public
void
mainStop
()
{
if
(
useTimer
)
{
mainTimer
?.
Stop
();
}
else
{
//pause = true;
}
}
/// <summary>
/// 开始运行的时间
/// </summary>
...
...
@@ -203,18 +278,60 @@ namespace OnlineStore.DeviceLibrary
{
if
(!
isInit
)
{
mainTimer
=
new
System
.
Timers
.
Timer
();
mainTimer
.
Enabled
=
false
;
mainTimer
.
Interval
=
300
;
mainTimer
.
Elapsed
+=
mainTimer_Elapsed
;
mainTimer
.
AutoReset
=
true
;
if
(
useTimer
)
{
mainTimer
=
new
System
.
Timers
.
Timer
();
mainTimer
.
Enabled
=
false
;
mainTimer
.
Interval
=
300
;
mainTimer
.
Elapsed
+=
mainTimer_Elapsed
;
mainTimer
.
AutoReset
=
true
;
}
else
{
mainThread
=
new
Thread
(
mainThread_Handle
);
mainThread
.
IsBackground
=
true
;
threadInterval
=
300
;
loop
=
true
;
GC
.
KeepAlive
(
mainThread
);
mainThread
.
Start
();
}
isInit
=
true
;
}
}
public
LineMoveInfo
MoveInfo
=
null
;
string
threadInfo
=
""
;
void
mainThread_Handle
()
{
while
(
loop
)
{
if
(
pause
)
{
Thread
.
Sleep
(
1000
);
}
else
{
mainThread_Process
();
Thread
.
Sleep
(
threadInterval
);
try
{
string
curStr
=
$
"{Name}-{DeviceID}:Thread ID: {Thread.CurrentThread.ManagedThreadId}"
;
if
(!
curStr
.
Equals
(
threadInfo
))
{
threadInfo
=
curStr
;
LogUtil
.
LOGGER
.
Info
(
curStr
);
}
}
finally
{
}
protected
abstract
void
mainTimer_Elapsed
(
object
sender
,
System
.
Timers
.
ElapsedEventArgs
e
);
}
}
}
protected
abstract
void
mainThread_Process
();
void
mainTimer_Elapsed
(
object
sender
,
System
.
Timers
.
ElapsedEventArgs
e
)
{
mainThread_Process
();
}
#
region
出库
/// <summary>
...
...
@@ -642,7 +759,8 @@ namespace OnlineStore.DeviceLibrary
warnParam
.
OperteType
=
""
;
}
}
}
catch
(
Exception
ex
)
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
"SetWarnMsg Error: "
+
ex
.
ToString
());
}
...
...
@@ -654,9 +772,9 @@ namespace OnlineStore.DeviceLibrary
try
{
SetWarnMsg
(
move
.
Name
+
"["
+
move
.
GetMoveType
()
+
"]["
+
move
.
SLog
+
"] "
+
alarmType
+
" ["
+
FormUtil
.
GetSpanStr
(
move
.
StepSpan
())
+
"]"
,
alarmType
,
move
);
Alarm
(
LineAlarmType
.
IoSingleTimeOut
);
Alarm
(
LineAlarmType
.
IoSingleTimeOut
);
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
{
}
...
...
@@ -689,7 +807,7 @@ namespace OnlineStore.DeviceLibrary
string
alarmTypeStr
=
stepDes
+
"_超时报警"
;
if
(
warnParam
.
AlarmType
.
Equals
(
alarmTypeStr
))
{
LogUtil
.
info
(
Name
+
$
"步骤{stepDes}结束,清理【{
WarnMsg
}】 "
);
LogUtil
.
info
(
Name
+
$
"步骤{stepDes}结束,清理【{
WarnMsg
}】 "
);
alarmType
=
LineAlarmType
.
None
;
SetWarnMsg
(
""
);
}
...
...
@@ -699,7 +817,7 @@ namespace OnlineStore.DeviceLibrary
string
alarmTypeStr
=
stepDes
+
"_轴运动报警"
;
if
(
warnParam
.
AlarmType
.
Equals
(
alarmTypeStr
))
{
LogUtil
.
info
(
Name
+
$
"步骤{stepDes}结束,清理【{
WarnMsg
}】 "
);
LogUtil
.
info
(
Name
+
$
"步骤{stepDes}结束,清理【{
WarnMsg
}】 "
);
alarmType
=
LineAlarmType
.
None
;
SetWarnMsg
(
""
);
}
...
...
@@ -732,4 +850,4 @@ namespace OnlineStore.DeviceLibrary
public
string
Barcode
=
""
;
}
}
source/HuichuanLibrary/HCLogUtil.cs
查看文件 @
0aff9dd
...
...
@@ -116,7 +116,7 @@ namespace HuichuanLibrary
}
else
{
LOGGER
.
Debug
(
"ShowLogPro【"
+
msg
+
"】失败,未得到锁"
);
//
LOGGER.Debug("ShowLogPro【" + msg + "】失败,未得到锁");
}
}
private
static
List
<
string
>
logList
=
new
List
<
string
>();
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论