Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
张东亮
/
SO1037-LiftController
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 7e814187
由
张东亮
编写于
2023-12-07 14:26:26 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
使用confighelper
1 个父辈
aae14734
隐藏空白字符变更
内嵌
并排
正在显示
18 个修改的文件
包含
18 行增加
和
1941 行删除
LiftController/FrmIO.cs
source/Common/Common.csproj
source/Common/util/AppConfigHelper.cs
source/DeviceLibrary/Context/Context.cs
source/DeviceLibrary/Context/LiftContext.cs
source/DeviceLibrary/DeviceLibrary.csproj
source/DeviceLibrary/IO/AIOBOX/AIOBOXManager.cs
source/DeviceLibrary/IO/IOManager.cs
source/DeviceLibrary/Models/LiftInfo.cs
source/DeviceLibrary/bean/Line/LineBean.cs
source/DeviceLibrary/bean/Line/_system~.ini
source/DeviceLibrary/bean/LineMoveInfo.cs
source/DeviceLibrary/bean/MoveStep.cs
source/DeviceLibrary/bean/RobotBase.cs
source/DeviceLibrary/bean/WaitUtil.cs
source/DeviceLibrary/bean/_system~.ini
source/DeviceLibrary/bean/jobType/_system~.ini
source/DeviceLibrary/manager/LineManager.cs
LiftController/FrmIO.cs
查看文件 @
7e81418
...
...
@@ -23,7 +23,7 @@ namespace LiftController
InitializeComponent
();
groupBox4
.
Enabled
=
false
;
LoadIOList
(
config
);
string
[]
lifts
=
Common
.
AppConfigHelper
.
GetValue
(
Common
.
SettingString
.
Lift_Ids
).
Split
(
','
);
string
[]
lifts
=
Common
.
AppConfigHelper
.
GetValue
(
Common
.
SettingString
.
Lift_Ids
,
"LIFT_D2,LIFT_C1"
).
Split
(
','
);
comboBox1
.
Items
.
AddRange
(
lifts
);
if
(
comboBox1
.
Items
.
Count
>
0
)
comboBox1
.
SelectedIndex
=
0
;
...
...
source/Common/Common.csproj
查看文件 @
7e81418
...
...
@@ -32,6 +32,9 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="ConfigHelper">
<HintPath>..\..\..\..\..\..\SharedRefDll\Neotel\ConfigHelper\Debug\net462\ConfigHelper.dll</HintPath>
</Reference>
<Reference Include="log4net">
<HintPath>.\log4net.dll</HintPath>
</Reference>
...
...
source/Common/util/AppConfigHelper.cs
查看文件 @
7e81418
...
...
@@ -6,160 +6,15 @@ namespace Common
{
public
class
AppConfigHelper
{
public
static
System
.
Configuration
.
Configuration
config
=
System
.
Configuration
.
ConfigurationManager
.
OpenExeConfiguration
(
System
.
Configuration
.
ConfigurationUserLevel
.
None
);
public
static
string
GetValue
(
string
key
)
public
static
T
GetValue
<
T
>(
string
key
,
T
defalutVal
=
default
(
T
))
{
if
(
config
.
AppSettings
.
Settings
[
key
]
==
null
)
{
LogUtil
.
info
(
"未找到配置:"
+
key
+
",请检查配置是否完整!"
);
return
""
;
}
else
{
return
config
.
AppSettings
.
Settings
[
key
].
Value
;
}
return
ConfigHelper
.
Config
.
Get
(
key
,
defalutVal
);
}
public
static
decimal
GetNumValue
(
string
key
)
{
decimal
a
=
0
;
//System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
if
(
config
.
AppSettings
.
Settings
[
key
]
==
null
)
{
LogUtil
.
error
(
"未找到配置:"
+
key
+
",请检查配置是否完整!"
);
return
a
;
}
else
{
{
Decimal
.
TryParse
(
config
.
AppSettings
.
Settings
[
key
].
Value
,
out
a
);
}
}
return
a
;
}
public
static
int
GetIntValue
(
string
key
)
{
int
a
=
0
;
//System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
if
(
config
.
AppSettings
.
Settings
[
key
]
==
null
)
{
LogUtil
.
error
(
"未找到配置:"
+
key
+
",请检查配置是否完整!"
);
return
a
;
}
else
{
{
Int32
.
TryParse
(
config
.
AppSettings
.
Settings
[
key
].
Value
,
out
a
);
}
}
return
a
;
}
public
static
bool
GetBoolValue
(
string
key
)
{
bool
a
=
false
;
//System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
if
(
config
.
AppSettings
.
Settings
[
key
]
==
null
)
{
LogUtil
.
error
(
"未找到配置:"
+
key
+
",请检查配置是否完整!"
);
return
a
;
}
else
{
{
bool
.
TryParse
(
config
.
AppSettings
.
Settings
[
key
].
Value
,
out
a
);
}
}
return
a
;
}
public
static
void
SaveValue
(
string
key
,
int
value
)
{
SaveValue
(
key
,
value
.
ToString
());
}
public
static
void
SaveValue
(
string
key
,
bool
value
)
public
static
void
SetValue
<
T
>(
string
key
,
T
val
=
default
(
T
))
{
SaveValue
(
key
,
value
.
ToString
());
}
public
static
void
SaveValue
(
string
key
,
string
value
)
{
try
{
if
(
key
.
Equals
(
""
)
||
value
.
Equals
(
""
))
{
return
;
}
//增加的内容写在appSettings段下 <add key="RegCode" value="0"/>
//System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
if
(
config
.
AppSettings
.
Settings
[
key
]
==
null
)
{
SetValue
(
key
,
value
);
}
else
{
UpdateConfig
(
key
,
value
);
}
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
"SaveValue保存配置出错:AppKey="
+
key
+
",AppValue="
+
value
+
","
+
ex
.
StackTrace
);
}
}
/// <summary>
/// 更新配置文件信息
/// </summary>
/// <param name="name">配置文件字段名称</param>
/// <param name="Xvalue">值</param>
private
static
void
UpdateConfig
(
string
name
,
string
Xvalue
)
{
try
{
XmlDocument
doc
=
new
XmlDocument
();
doc
.
Load
(
Application
.
ExecutablePath
+
".config"
);
XmlNode
node
=
doc
.
SelectSingleNode
(
@"//add[@key='"
+
name
+
"']"
);
XmlElement
ele
=
(
XmlElement
)
node
;
ele
.
SetAttribute
(
"value"
,
Xvalue
);
doc
.
Save
(
Application
.
ExecutablePath
+
".config"
);
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
"UpdateConfig保存配置出错:name="
+
name
+
",Xvalue="
+
Xvalue
+
","
+
ex
.
StackTrace
);
}
ConfigHelper
.
Config
.
Set
(
key
,
val
);
}
///<summary>
///向.config文件的appKey结写入信息AppValue 保存设置
///</summary>
///<param name="AppKey">节点名</param>
///<param name="AppValue">值</param>
private
static
void
SetValue
(
String
AppKey
,
String
AppValue
)
{
try
{
XmlDocument
xDoc
=
new
XmlDocument
();
xDoc
.
Load
(
System
.
Windows
.
Forms
.
Application
.
ExecutablePath
+
".config"
);
XmlNode
xNode
;
XmlElement
xElem1
;
XmlElement
xElem2
;
xNode
=
xDoc
.
SelectSingleNode
(
"//appSettings"
);
xElem1
=
(
XmlElement
)
xNode
.
SelectSingleNode
(
"//add[@key='"
+
AppKey
+
"']"
);
if
(
xElem1
!=
null
)
xElem1
.
SetAttribute
(
"value"
,
AppValue
);
else
{
xElem2
=
xDoc
.
CreateElement
(
"add"
);
xElem2
.
SetAttribute
(
"key"
,
AppKey
);
xElem2
.
SetAttribute
(
"value"
,
AppValue
);
xNode
.
AppendChild
(
xElem2
);
}
xDoc
.
Save
(
System
.
Windows
.
Forms
.
Application
.
ExecutablePath
+
".config"
);
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
"SetValue保存配置出错:AppKey="
+
AppKey
+
",AppValue="
+
AppValue
+
","
+
ex
.
StackTrace
);
}
}
}
}
source/DeviceLibrary/Context/Context.cs
查看文件 @
7e81418
...
...
@@ -16,7 +16,7 @@ namespace DeviceLibrary.Context
}
public
void
Open
()
{
string
baseurl
=
AppConfigHelper
.
GetValue
(
SettingString
.
ServiceBaseUrl
);
string
baseurl
=
AppConfigHelper
.
GetValue
(
SettingString
.
ServiceBaseUrl
,
"http://127.0.0.1:8887"
);
serviceContext
.
Open
(
baseurl
);
}
public
void
Close
()
...
...
source/DeviceLibrary/Context/LiftContext.cs
查看文件 @
7e81418
...
...
@@ -15,8 +15,8 @@ namespace DeviceLibrary.Context
public
static
void
Init
()
{
string
[]
lifts
=
Common
.
AppConfigHelper
.
GetValue
(
Common
.
SettingString
.
Lift_Ids
).
Split
(
','
);
string
buff
=
Common
.
AppConfigHelper
.
GetValue
(
Common
.
SettingString
.
Lift_Buffs
);
string
[]
lifts
=
Common
.
AppConfigHelper
.
GetValue
(
Common
.
SettingString
.
Lift_Ids
,
"LIFT_D2,LIFT_C1"
).
Split
(
','
);
string
buff
=
Common
.
AppConfigHelper
.
GetValue
(
Common
.
SettingString
.
Lift_Buffs
,
""
);
elevatorInfos
=
Common
.
JsonHelper
.
DeserializeJsonToList
<
LiftInfo
>(
buff
);
if
(
elevatorInfos
==
null
)
{
...
...
@@ -92,7 +92,7 @@ namespace DeviceLibrary.Context
{
try
{
Common
.
AppConfigHelper
.
S
ave
Value
(
Common
.
SettingString
.
Lift_Buffs
,
Common
.
JsonHelper
.
SerializeObject
(
elevatorInfos
));
Common
.
AppConfigHelper
.
S
et
Value
(
Common
.
SettingString
.
Lift_Buffs
,
Common
.
JsonHelper
.
SerializeObject
(
elevatorInfos
));
}
catch
(
Exception
e
)
{
...
...
source/DeviceLibrary/DeviceLibrary.csproj
查看文件 @
7e81418
...
...
@@ -60,7 +60,6 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="bean\Line\LineBean.cs" />
<Compile Include="Context\Context.cs" />
<Compile Include="Context\LiftContext.cs" />
<Compile Include="Context\ServiceContext.cs" />
...
...
@@ -95,5 +94,6 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file
source/DeviceLibrary/IO/AIOBOX/AIOBOXManager.cs
查看文件 @
7e81418
...
...
@@ -65,12 +65,12 @@ namespace DeviceLibrary
{
DOValueMap
.
Remove
(
ioIp
);
}
int
DIMS
=
AppConfigHelper
.
Get
IntValue
(
"DIMS"
);
int
DIMS
=
AppConfigHelper
.
Get
Value
(
"DIMS"
,
20
);
if
(
DIMS
<
20
)
{
DIMS
=
20
;
}
int
DOMS
=
AppConfigHelper
.
Get
IntValue
(
"DOMS"
);
int
DOMS
=
AppConfigHelper
.
Get
Value
(
"DOMS"
,
20
);
if
(
DOMS
<
200
)
{
DOMS
=
200
;
...
...
source/DeviceLibrary/IO/IOManager.cs
查看文件 @
7e81418
...
...
@@ -117,7 +117,7 @@ namespace DeviceLibrary
#
endregion
public
static
void
Init
()
{
bool
isAIOBox
=
AppConfigHelper
.
Get
IntValue
(
SettingString
.
UseAIOBOX
).
Equals
(
1
);
bool
isAIOBox
=
AppConfigHelper
.
Get
Value
(
SettingString
.
UseAIOBOX
,
1
).
Equals
(
1
);
if
(
isAIOBox
)
{
instance
=
new
AIOBOXManager
();
...
...
source/DeviceLibrary/Models/LiftInfo.cs
查看文件 @
7e81418
...
...
@@ -12,7 +12,7 @@ using System.Threading.Tasks;
namespace
DeviceLibrary.Models
{
/// <summary>
/// 电梯
信息
/// 电梯
/// </summary>
public
class
LiftInfo
{
...
...
source/DeviceLibrary/bean/Line/LineBean.cs
deleted
100644 → 0
查看文件 @
aae1473
//using Asa;
//using Common;
//using LoadCSVLibrary;
//using System;
//using System.Collections.Generic;
//using System.Diagnostics;
//using System.Linq;
//using System.Text;
//using System.Threading;
//using System.Threading.Tasks;
//namespace DeviceLibrary
//{
// public partial class DoubleLineBean:RobotBase
// {
// public DoubleLineConfig Config;
// public RunStatus runStatus = RunStatus.Wait;
// public List<string> RfidIpList = new List<string>();
// public RobotMoveBean LeftRobot = null;
// public RobotMoveBean RightRobot = null;
// public LineMoveInfo SOneMoveInfo = null;
// public DoubleLineBean(DoubleLineConfig config) : base(config)
// {
// this.Config = config;
// mainTimer.Elapsed += timersTimer_Elapsed;
// ledTimer.Elapsed += Led_timer_Tick;
// LeftRobot = new RobotMoveBean(2, config.ABB2_IP, "左侧ABB", IO_Type.ABB2_TrayCheck);
// RightRobot = new RobotMoveBean(1, config.ABB1_IP, "右侧ABB", IO_Type.ABB1_TrayCheck);
// //添加调试
// IsDebug = ConfigAppSettings.GetIntValue(Setting_Init.IsInDebug).Equals(1);
// MoveInfo = new LineMoveInfo();
// SOneMoveInfo = new LineMoveInfo();
// Name = (" 双层线 ").ToUpper();
// IOManager.Init();
// IOManager.instance.ConnectionIOList(Config.DIODeviceNameList);
// mainTimer.Enabled = false;
// int isAuto = ConfigAppSettings.GetIntValue(Setting_Init.App_AutoRun);
// if (isAuto == 1)
// {
// mainTimer.Enabled = true;
// }
// RfidIpList = new List<string>(){
// config.L_Updown_Rfid,
// config.M_Updown_Rfid,
// config.R_Updown_Rfid,
// config.S1_Rfid,
// config.S2_Rfid,
// config.Pkg_Rfid,
// config.RHigh_Rfid
// };
// //benQ_AGV = new BenQ_AGV();
// // AgvClient.Init();
// Thread.Sleep(300);
// IOMove(IO_Type.Alarm_HddLed, IO_VALUE.LOW);
// IOMove(IO_Type.AutoRun_HddLed, IO_VALUE.LOW);
// }
// /// <summary>
// /// 开始运行
// /// </summary>
// public override bool StartRun()
// {
// LogUtil.info(Name + "开始启动,启动时间:" + DateTime.Now);
// WarnMsg = "";
// if (IOValue(IO_Type.SuddenStop_BTN).Equals(IO_VALUE.HIGH) )
// {
// if (ABBControl.GetControllerByIP(Config.ABB1_IP) == null)
// {
// SetWarnMsg("启动失败:机器人["+Config.ABB1_IP+"]加载失败");
// return false;
// }
// if (ABBControl.GetControllerByIP(Config.ABB2_IP) == null)
// {
// SetWarnMsg("启动失败:机器人[" + Config.ABB2_IP + "]加载失败");
// return false;
// }
// //if (ABBControl.GetControllerByIP(Config.ABB3_IP) == null)
// //{
// // SetWarnMsg("启动失败:机器人[" + Config.ABB3_IP + "]加载失败");
// // return false;
// //}
// S1_RightShelfId = "";
// S1_CurrShelfId = "";
// S1_LeftShelfId = "";
// RealRfidMap = new Dictionary<string, string>();
// mainTimer.Enabled = false ;
// // AgvClient.SetCancelState(false);
// RFIDManager.Open(RfidIpList.ToArray());
// runStatus = RunStatus.HomeMoving;
// LineManager.packageLine.StartRun();
// MoveInfo.NewMove(LineMoveType.ReturnHome);
// ReturnHome();
// return true;
// }
// //else if (IOValue(IO_Type.AirCheck).Equals(IO_VALUE.LOW))
// //{
// // SetWarnMsg("启动失败:气压未开");
// //}
// else
// {
// SetWarnMsg("启动失败:急停未开");
// }
// return false;
// }
// #region 原点返回和复位处理
// private void ReturnHome()
// {
// HighProcess = false;
// LowProcess = false;
// S1_ShelfTask = new ShelfTaskInfo();
// S2CanGetShelf = true;
// needNewShelf = "";
// NoAirCheck = false;
// isInSuddenDown = false;
// LeftRobot.NeedShelf = "";
// alarmType = AlarmType.None;
// SetWarnMsg("");
// //清理RFID
// RFIDManager.ReadRFID(Config.L_Updown_Rfid, true);
// RFIDManager.ReadRFID(Config.S1_Rfid, true);
// LeftRobot.Reset();
// RightRobot.Reset();
// SOneMoveInfo.EndMove();
// MoveInfo.NextMoveStep(MoveStep.H01_StopUp);
// ResetStopMove();
// //工位顶升下降
// CylinderMove(MoveInfo, IO_Type.S1_TopCylinderUp, IO_Type.S1_TopCylinderDown);
// CylinderMove(MoveInfo, IO_Type.S2_TopCylinderUp, IO_Type.S2_TopCylinderDown);
// mainTimer.Enabled = true;
// ledTimer.Enabled = true;
// }
// /// <summary>
// /// 复位时阻挡状态
// /// </summary>
// /// <param name="value"></param>
// /// <param name="moveInfo"></param>
// public void ResetStopMove(LineMoveInfo moveInfo = null)
// {
// //此阻挡默认下降
// CheckAndMove(IO_Type.LLow_StopCylinder1, IO_VALUE.HIGH);
// CheckAndMove(IO_Type.LHigh_StopCylinder1, IO_VALUE.HIGH);
// CheckAndMove(IO_Type.Left_Buf_Near_StopDown, IO_VALUE.HIGH);
// CheckAndMove(IO_Type.Left_Buf_Far_StopDown, IO_VALUE.HIGH);
// CheckAndMove(IO_Type.Right_Buf_Near_StopDown, IO_VALUE.HIGH);
// CheckAndMove(IO_Type.Right_Buf_Far_StopDown, IO_VALUE.HIGH);
// //工位1只上升2个阻挡
// CheckAndMove(IO_Type.S1_StopCylinder3, IO_VALUE.HIGH);
// CheckAndMove(IO_Type.S1_StopCylinder4, IO_VALUE.HIGH);
// CheckAndMove(IO_Type.M_RightStopCylinder, IO_VALUE.HIGH);
// IO_VALUE value = IO_VALUE.LOW;
// CheckAndMove(IO_Type.Line_StopCylinder, value);
// // IOMove(IO_Type.LLow_StopCylinder1, value);
// CheckAndMove(IO_Type.LLow_StopCylinder2, value);
// CheckAndMove(IO_Type.LLow_StopCylinder3, value);
// // IOMove(IO_Type.LHigh_StopCylinder1, value);
// CheckAndMove(IO_Type.LHigh_StopCylinder2, value);
// CheckAndMove(IO_Type.LHigh_StopCylinder3, value);
// CheckAndMove(IO_Type.Left_Tranverse_StopDown, value);
// CheckAndMove(IO_Type.Right_Tranverse_StopDown, value);
// CheckAndMove(IO_Type.M_LeftStopCylinder, value);
// CheckAndMove(IO_Type.S1_StopCylinder1, value);
// CheckAndMove(IO_Type.S1_StopCylinder2, value);
// CheckAndMove(IO_Type.S2_StopCylinder1, value);
// }
// public void AllLineMove(IO_VALUE value, LineMoveInfo moveInfo = null)
// {
// IOMove(IO_Type.L_InLineRun, value);
// IOMove(IO_Type.LLown_LineRun, value);
// IOMove(IO_Type.LHigh_LineRun, value);
// IOMove(IO_Type.M_LineRun, value);
// IOMove(IO_Type.Left_Buf_Run, value);
// IOMove(IO_Type.Right_Buf_Run, value);
// if (value.Equals(IO_VALUE.HIGH))
// {
// S1LineRun();
// }
// else
// {
// S1LineStop();
// }
// if (value.Equals(IO_VALUE.HIGH))
// {
// S2LineRun();
// }
// else
// {
// S2LineStop();
// }
// }
// public override void Reset()
// {
// if (IOValue(IO_Type.SuddenStop_BTN).Equals(IO_VALUE.HIGH) )
// {
// mainTimer.Enabled = false;
// runStatus = RunStatus.Reset;
// MoveInfo.NewMove(LineMoveType.StoreReset);
// ReturnHome();
// LineManager.packageLine.Reset();
// }
// //else if (IOValue(IO_Type.AirCheck).Equals(IO_VALUE.LOW))
// //{
// // SetWarnMsg("复位失败:气压未开");
// //}
// else
// {
// SetWarnMsg("复位失败:急停未开");
// }
// }
// /// <summary>
// /// 复位处理
// /// </summary>
// protected void ResetProcess()
// {
// if (MoveInfo.IsInWait)
// {
// CheckWait(MoveInfo);
// }
// if (MoveInfo.IsInWait)
// {
// return;
// }
// switch (MoveInfo.MoveStep)
// {
// case MoveStep.H01_StopUp:
// MoveInfo.NextMoveStep(MoveStep.H02_LineRun);
// LogUtil.info(Name + " 复位:线体转10秒");
// MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(10000));
// AllLineMove(IO_VALUE.HIGH);
// break;
// case MoveStep.H02_LineRun:
// MoveInfo.NextMoveStep(MoveStep.H03_UpoownDown);
// LogUtil.info(Name + " 复位:停止线体,提升机下降");
// AllLineMove(IO_VALUE.LOW);
// CheckAndMove(IO_Type.Left_Buf_Near_StopDown, IO_VALUE.LOW);
// CheckAndMove(IO_Type.Right_Buf_Near_StopDown, IO_VALUE.LOW);
// CylinderMove(MoveInfo, IO_Type.L_Updown_Up, IO_Type.L_Updown_Down);
// CylinderMove(MoveInfo, IO_Type.R_Updown_Up, IO_Type.R_Updown_Down);
// CylinderMove(MoveInfo, IO_Type.M_Updown_Up, IO_Type.M_Updown_Down);
// break;
// case MoveStep.H03_UpoownDown:
// if (IOValue(IO_Type.M_LeftStopCheck).Equals(IO_VALUE.HIGH) || IOValue(IO_Type.M_RightStopCheck).Equals(IO_VALUE.HIGH))
// {
// MoveInfo.NextMoveStep(MoveStep.H04_MStopDown);
// LogUtil.info(Name + " 复位:中间提升机有料架,转动料架到S1左侧");
// IOMove(IO_Type.M_LeftStopCylinder, IO_VALUE.HIGH);
// IOMove(IO_Type.M_RightStopCylinder, IO_VALUE.HIGH);
// IOMove(IO_Type.M_LineRun, IO_VALUE.HIGH);
// CheckAndMove(IO_Type.S1_StopCylinder1, IO_VALUE.LOW);
// CheckAndMove(IO_Type.S1_StopCylinder3, IO_VALUE.HIGH);
// CheckAndMove(IO_Type.S1_StopCylinder4, IO_VALUE.HIGH);
// S1LineRun(MoveInfo);
// MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.S1_StopCheck1, IO_VALUE.HIGH));
// }
// else
// {
// LogUtil.info(Name + " 复位完成,");
// MoveInfo.EndMove();
// runStatus = RunStatus.Runing;
// }
// break;
// case MoveStep.H04_MStopDown:
// MoveInfo.NextMoveStep(MoveStep.H05_MShlefToLeft);
// LogUtil.info(Name + " 复位:中间提升机有料架,等待料架到达S1左侧");
// MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
// MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.S1_StopCheck1, IO_VALUE.HIGH));
// break;
// case MoveStep.H05_MShlefToLeft:
// MoveInfo.NextMoveStep(MoveStep.H06_SaveLeft);
// S1_LeftShelfId = RFIDManager.ReadRFID(Config.M_Updown_Rfid, true).NumStr();
// LogUtil.info(Name + " 复位:停止转动,记录左侧料架信息:"+LeftSName);
// IOMove(IO_Type.M_LineRun, IO_VALUE.LOW);
// S1LineStop(MoveInfo);
// break;
// case MoveStep.H06_SaveLeft:
// MoveInfo.NextMoveStep(MoveStep.H06_SaveLeft);
// LogUtil.info(Name + " 复位完成,");
// MoveInfo.EndMove();
// runStatus = RunStatus.Runing;
// break;
// default: break;
// }
// }
// #endregion
// public override void StopRun()
// {
// WarnMsg = "";
// //AgvClient.SetCancelState(true);
// mainTimer.Enabled = false;
// ledTimer.Enabled = false;
// StopMove();
// LineManager.packageLine.StopRun();
// runStatus = RunStatus.Wait;
// IOManager.instance.CloseAllDO();
// LogUtil.info(Name + ",停止运行");
// }
// public override void Alarm(AlarmType alarmType)
// {
// if (this.alarmType.Equals(alarmType) && alarmType != AlarmType.SuddenStop)
// {
// return;
// }
// LogUtil.error(Name + " 报警,报警类型:" + alarmType);
// this.alarmType = alarmType;
// if (alarmType.Equals(AlarmType.SuddenStop))
// {
// isInSuddenDown = true;
// LogUtil.error(Name + "收到急停信号,停止运行 ");
// StopMove();
// }
// else if (alarmType.Equals(AlarmType.NoAirCheck))
// {
// NoAirCheck = true;
// LogUtil.error(Name + "无气压信号,停止运行 ");
// StopMove();
// }
// }
// public override void StopMove()
// {
// MoveInfo.EndMove();
// SOneMoveInfo.EndMove();
// AllLineMove(IO_VALUE.LOW);
// LeftRobot.StopMove();
// RightRobot.StopMove();
// LineManager.packageLine.StopMove();
// }
// private bool InProcess = false;
// private Stopwatch stopwatch = new Stopwatch();
// public bool MoveStop = false;
// static object s1ShelfLock = new object();
// protected void timersTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
// {
// if (runStatus >= RunStatus.HomeMoving )
// {
// LeftRobot.TimerProcess();
// RightRobot.TimerProcess();
// }
// if (MoveStop)
// {
// return;
// }
// if (InProcess && stopwatch.Elapsed.TotalSeconds < 3)
// {
// return;
// }
// try
// {
// InProcess = true;
// stopwatch.Restart();
// IoCheckProcess();
// if (runStatus >= RunStatus.HomeMoving)
// {
// try
// {
// DateTime time = DateTime.Now;
// if (MoveInfo.MoveType.Equals(LineMoveType.ReturnHome) || MoveInfo.MoveType.Equals(LineMoveType.StoreReset))
// {
// ResetProcess();
// }
// else
// {
// //LeftRobot.TimerProcess();
// //RightRobot.TimerProcess();
// if (MoveInfo.MoveType.Equals(LineMoveType.None))
// {
// WorkShelfCheck();
// ShelfCheckPro();
// }
// else if (MoveInfo.MoveType.Equals(LineMoveType.LTransWork2Buf))
// {
// LTransWork2BuffProcess();
// }
// else if (MoveInfo.MoveType.Equals(LineMoveType.LTransBuf2Work))
// {
// LTransBuff2WorkProcess();
// }
// else if (MoveInfo.MoveType.Equals(LineMoveType.LeftShelf))
// {
// ShelfMoveProcess();
// }
// if (SOneMoveInfo.MoveType.Equals(LineMoveType.None))
// {
// S1_ShelfCheck();
// if (S1_RightShelfId != "")
// {
// S2CanGetShelf = false;
// }
// else
// {
// S2CanGetShelf = true;
// }
// }
// else if (SOneMoveInfo.MoveType.Equals(LineMoveType.S1Shelf))
// {
// if(Monitor.TryEnter(s1ShelfLock))
// {
// try
// {
// S1_ShelfProcess();
// }
// catch(Exception ex)
// {
// LogUtil.error(Name+ " S1_ShelfProcess出错",ex);
// }
// finally
// {
// Monitor.Exit(s1ShelfLock);
// }
// }
// if (S1_RightShelfId != "" && S2CanGetShelf)
// {
// S2CanGetShelf = false;
// }
// }
// if (SOneMoveInfo.MoveType.Equals(LineMoveType.None) && MoveInfo.MoveType.Equals(LineMoveType.None) &&
// LeftRobot.MoveInfo.MoveType.Equals(LineMoveType.None) && RightRobot.MoveInfo.MoveType.Equals(LineMoveType.None))
// {
// runStatus = RunStatus.Runing;
// IOTimeOutProcess();
// }
// else
// {
// runStatus = RunStatus.Busy;
// }
// }
// }
// catch (Exception ex)
// {
// LogUtil.error(Name + "TimerProcess 定时处理出错", ex);
// }
// }
// }
// catch (Exception ex)
// {
// LogUtil.error(Name + "定时处理出错:" + ex.ToString());
// }
// finally { InProcess = false; }
// }
// private IO_VALUE LastResetValue = IO_VALUE.LOW;
// public void IoCheckProcess()
// {
// DateTime time = DateTime.Now;
// if (runStatus.Equals(RunStatus.Wait))
// {
// //取新的Io状态
// IO_VALUE autoSingle = IOValue(IO_Type.Reset_BTN);
// if (ConfigAppSettings.GetIntValue(Setting_Init.App_AutoRun).Equals(1))
// {
// if (autoSingle.Equals(IO_VALUE.HIGH) && LastResetValue.Equals(IO_VALUE.LOW))
// {
// //没有启动时收到复位按钮,相当于启动按钮
// LogUtil.info(Name + "没有启动时收到复位按钮,开始启动");
// bool result = StartRun();
// if (result.Equals(false))
// {
// LogUtil.error(Name+"启动失败,等待下次启动!");
// mainTimer.Enabled = true;
// }
// }
// LastResetValue = autoSingle;
// return;
// }
// LastResetValue = autoSingle;
// }
// //判断急停
// else if (runStatus >= RunStatus.HomeMoving)
// {
// //判断急停
// if (IOValue(IO_Type.SuddenStop_BTN).Equals(IO_VALUE.LOW))
// {
// if (isInSuddenDown.Equals(false))
// {
// isInSuddenDown = true;
// SetWarnMsg("收到急停信号,报警急停");
// //报警时会关闭所有轴
// Alarm(AlarmType.SuddenStop);
// }
// }
// else if (IOValue(IO_Type.SuddenStop_BTN).Equals(IO_VALUE.HIGH) && IOValue(IO_Type.Reset_BTN).Equals(IO_VALUE.HIGH))
// {
// //收到复位信号,若报警直接复位,若不报警且无操作,回到待机点
// if (alarmType.Equals(AlarmType.None) && isInSuddenDown.Equals(false))
// {
// if (MoveInfo.MoveType.Equals(LineMoveType.None))
// {
// LogUtil.info("收到复位信号,当前无报警,暂不复位");
// }
// else
// {
// LogUtil.info("收到复位信号,当前无报警, 在" + MoveInfo.MoveType + "处理中,暂不复位");
// }
// }
// else
// {
// //收到复位信号
// LogUtil.info("收到复位信号,自动复位");
// Reset();
// }
// }
// }
// }
// private DateTime preIoTimerOutTime = DateTime.Now;
// private void IOTimeOutProcess()
// {
// try
// {
// TimeSpan span = DateTime.Now - preIoTimerOutTime;
// if (span.TotalSeconds > 1)
// {
// preIoTimerOutTime = DateTime.Now;
// if (runStatus < RunStatus.Runing || isInSuddenDown)
// {
// return;
// }
// if (alarmType.Equals(AlarmType.IoSingleTimeOut) && MoveInfo.IsInWait == false)
// {
// LogUtil.info(Name + "之前有IO超时报警,清理报警:" + WarnMsg);
// alarmType = AlarmType.None;
// SetWarnMsg();
// }
// }
// }
// catch (Exception ex)
// {
// LogUtil.error(" IOTimeOutProcess 出错:" + ex.ToString());
// }
// }
// public override string GetRunInfo()
// {
// string s1Info = "";
// if (!S1_ShelfTask.rfid.Equals(""))
// {
// s1Info = S1_ShelfTask.ToStr();
// }
// string leftShelf = LeftUpdownRFID.Equals("") ? "" : " 左侧料架="+LeftUpdownRFID+" ";
// string msg = MoveInfo.MoveType + " " + MoveInfo.MoveStep + " "+ leftShelf + "\r\n" +
// "" + SOneMoveInfo.MoveType + " " + SOneMoveInfo.MoveStep + " \t" + AllTaskInfo.ToStr() + "\r\n"+
// "S1工位(" +(S1IsReady()?"可放料":"不可放料")+"): " + LeftSName + " " + S1SName + " " + RightSName + "" + " " + s1Info+" "+CurSName+"\r\n" +
// // "" + LeftRobot.Name + ":" + LeftRobot.MoveInfo.MoveType + " " + LeftRobot.MoveInfo.MoveStep + " [" + LeftRobot.CurrPoint + "]["+LeftRobot.NeedShelf+"] " + LeftRobot.CurrTray.ToStr() + "" + "\r\n" +
// //"" + RightRobot.Name + ":" + RightRobot.MoveInfo.MoveType + " " + RightRobot.MoveInfo.MoveStep + " [" + RightRobot.CurrPoint + "][" + RightRobot.NeedShelf + "] " + RightRobot.CurrTray.ToStr() + ""
// LeftRobot.GetRunInfo()+"\r\n" +
// RightRobot.GetRunInfo() + "\r\n"
// ;
// return msg;
// }
// private void S1LineRun(LineMoveInfo moveInfo=null )
// {
// if (moveInfo != null)
// {
// moveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.S1_LineBackRun, IO_VALUE.LOW));
// moveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.S1_LineRun, IO_VALUE.HIGH));
// }
// CheckAndMove(IO_Type.S1_LineBackRun, IO_VALUE.LOW);
// IOMove(IO_Type.S1_LineRun, IO_VALUE.HIGH);
// }
// private void S1BackRun(LineMoveInfo moveInfo = null)
// {
// if (moveInfo != null)
// {
// moveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.S1_LineRun, IO_VALUE.LOW));
// moveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.S1_LineBackRun, IO_VALUE.HIGH));
// }
// CheckAndMove(IO_Type.S1_LineRun, IO_VALUE.LOW);
// IOMove(IO_Type.S1_LineBackRun, IO_VALUE.HIGH);
// }
// private void S1LineStop(LineMoveInfo moveInfo = null)
// {
// if (moveInfo != null)
// {
// moveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.S1_LineBackRun, IO_VALUE.LOW));
// moveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.S1_LineRun, IO_VALUE.LOW));
// }
// CheckAndMove(IO_Type.S1_LineBackRun, IO_VALUE.LOW);
// CheckAndMove(IO_Type.S1_LineRun, IO_VALUE.LOW);
// }
// private void S2LineRun(LineMoveInfo moveInfo = null)
// {
// if (moveInfo != null)
// {
// moveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.S2_LineBackRun, IO_VALUE.LOW));
// moveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.S2_LineRun, IO_VALUE.HIGH));
// }
// CheckAndMove(IO_Type.S2_LineBackRun, IO_VALUE.LOW);
// IOMove(IO_Type.S2_LineRun, IO_VALUE.HIGH);
// }
// private void S2BackRun(LineMoveInfo moveInfo = null)
// {
// if (moveInfo != null)
// {
// moveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.S2_LineRun, IO_VALUE.LOW));
// moveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.S2_LineBackRun, IO_VALUE.HIGH));
// }
// CheckAndMove(IO_Type.S2_LineRun, IO_VALUE.LOW);
// IOMove(IO_Type.S2_LineBackRun, IO_VALUE.HIGH);
// }
// private void S2LineStop(LineMoveInfo moveInfo = null)
// {
// if (moveInfo != null)
// {
// moveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.S2_LineBackRun, IO_VALUE.LOW));
// moveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.S2_LineRun, IO_VALUE.LOW));
// }
// CheckAndMove(IO_Type.S2_LineBackRun, IO_VALUE.LOW);
// CheckAndMove(IO_Type.S2_LineRun, IO_VALUE.LOW);
// }
// }
//}
\ No newline at end of file
source/DeviceLibrary/bean/Line/_system~.ini
deleted
100644 → 0
查看文件 @
aae1473
文件属性发生变化
source/DeviceLibrary/bean/LineMoveInfo.cs
deleted
100644 → 0
查看文件 @
aae1473
using
OnlineStore.Common
;
using
OnlineStore.DeviceLibrary
;
using
OnlineStore.LoadCSVLibrary
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
namespace
OnlineStore.DeviceLibrary
{
/// <summary>
/// 双层流水线当前运动信息类(出入库状态,步骤记录)
/// </summary>
public
class
LineMoveInfo
{
private
string
msg
=
""
;
public
string
Msg
{
get
{
return
msg
;
}
set
{
if
(!
string
.
IsNullOrEmpty
(
value
))
{
//不为空,且与上一个消息不一样才打印
if
(!
value
.
Equals
(
msg
))
{
LogUtil
.
info
(
string
.
Format
(
"{0}"
,
value
));
}
}
msg
=
value
;
}
}
/// <summary>
/// 超时时间
/// </summary>
public
int
TimeOutSeconds
=
60
;
public
LineMoveInfo
(
)
{
moveType
=
LineMoveType
.
None
;
this
.
moveStep
=
MoveStep
.
Wait
;
IsInWait
=
false
;
}
public
DateTime
LastSetpTime
{
get
;
set
;
}
/// <summary>
/// =true表示满足一个等待条件,就可以完成此步骤的等待
/// </summary>
public
bool
OneWaitCanEndStep
=
false
;
/// <summary>
/// 操作类型
/// </summary>
private
LineMoveType
moveType
=
LineMoveType
.
None
;
public
LineMoveType
MoveType
{
get
{
return
moveType
;
}
}
public
bool
IsTimeOut
(
int
timeOutSeconds
=
60
)
{
TimeSpan
span
=
DateTime
.
Now
-
LastSetpTime
;
if
(
span
.
TotalSeconds
>
timeOutSeconds
)
{
return
true
;
}
return
false
;
}
public
string
SLog
{
get
{
return
" "
+
moveType
+
" "
+
MoveStep
+
" "
;
}
}
public
TimeSpan
StepSpan
()
{
TimeSpan
span
=
DateTime
.
Now
-
LastSetpTime
;
return
span
;
}
/// <summary>
/// 是否再当前步骤等待中
/// </summary>
public
bool
IsInWait
{
get
;
set
;
}
/// <summary>
/// 上一个执行步骤
/// </summary>
public
MoveStep
PreMoveStep
{
get
;
set
;
}
/// <summary>
/// 当前执行到的步骤
/// </summary>
private
MoveStep
moveStep
;
/// <summary>
/// 可以循环运动的次数(轴卡运动才需要)
/// </summary>
public
int
CanWhileCount
=
0
;
/// <summary>
/// 双层流水线运动步骤记录
/// </summary>
public
MoveStep
MoveStep
{
get
{
return
moveStep
;
}
}
/// <summary>
/// 是否可以重写IO
/// </summary>
public
bool
CanRMoveIO
=
true
;
public
void
NextMoveStep
(
MoveStep
step
)
{
PreMoveStep
=
moveStep
;
moveStep
=
step
;
LastSetpTime
=
DateTime
.
Now
;
IsInWait
=
true
;
WaitList
=
new
List
<
WaitResultInfo
>();
OneWaitCanEndStep
=
false
;
CanWhileCount
=
5
;
TimeOutSeconds
=
60
;
CanRMoveIO
=
true
;
}
/// <summary>
/// 当前步骤执行完成
/// </summary>
public
void
EndStepWait
()
{
IsInWait
=
false
;
WaitList
=
new
List
<
WaitResultInfo
>();
}
public
void
NewMove
(
LineMoveType
type
,
MoveStep
step
=
MoveStep
.
Wait
)
{
moveStep
=
step
;
this
.
moveType
=
type
;
LastSetpTime
=
DateTime
.
Now
;
IsInWait
=
true
;
WaitList
=
new
List
<
WaitResultInfo
>();
OneWaitCanEndStep
=
false
;
CanWhileCount
=
5
;
TimeOutSeconds
=
60
;
CanRMoveIO
=
true
;
}
public
void
EndMove
()
{
this
.
moveType
=
LineMoveType
.
None
;
// this.MoveParam = null;
moveStep
=
MoveStep
.
Wait
;
LastSetpTime
=
DateTime
.
Now
;
IsInWait
=
false
;
WaitList
=
new
List
<
WaitResultInfo
>();
CanWhileCount
=
0
;
}
public
LineMoveInfo
clone
()
{
return
(
LineMoveInfo
)
this
.
MemberwiseClone
();
}
public
List
<
WaitResultInfo
>
WaitList
=
new
List
<
WaitResultInfo
>();
/// <summary>
/// 重置之后继续出入库时,退回上一个步骤执行
/// </summary>
public
void
BackStep
()
{
moveStep
=
PreMoveStep
;
IsInWait
=
false
;
}
}
public
class
WaitResultInfo
{
private
WaitResultInfo
()
{
}
public
static
WaitResultInfo
WaitIO
(
string
ioType
,
IO_VALUE
ioValue
)
{
WaitResultInfo
wait
=
new
WaitResultInfo
();
wait
.
CanWhileMoveCount
=
0
;
wait
.
WaitType
=
2
;
wait
.
IoType
=
ioType
;
wait
.
IoValue
=
ioValue
;
return
wait
;
}
public
static
WaitResultInfo
WaitTime
(
int
MScends
)
{
WaitResultInfo
wait
=
new
WaitResultInfo
();
wait
.
CanWhileMoveCount
=
0
;
wait
.
WaitType
=
3
;
wait
.
TimeMSeconds
=
MScends
;
wait
.
IsEnd
=
false
;
return
wait
;
}
public
static
WaitResultInfo
WaitAbb
(
string
abbip
)
{
WaitResultInfo
wait
=
new
WaitResultInfo
();
wait
.
CanWhileMoveCount
=
0
;
wait
.
WaitType
=
7
;
wait
.
IoType
=
abbip
;
return
wait
;
}
public
string
ToStr
()
{
if
(
WaitType
==
1
)
{
}
else
if
(
WaitType
==
2
)
{
return
"IO["
+
IoType
+
"="
+
IoValue
+
"]"
;
}
else
if
(
WaitType
==
3
)
{
return
"Time["
+
TimeMSeconds
+
"ms]"
;
}
else
if
(
WaitType
==
7
)
{
return
"ABB["
+
IoType
+
"]"
;
}
else
{
return
"[WaitType="
+
WaitType
+
"]"
;
}
return
""
;
}
/// <summary>
/// 当未结束时可以重复运动的次数
/// </summary>
public
int
CanWhileMoveCount
{
get
;
set
;
}
/// <summary>
/// 等待结果,1=轴运动,2=IO运动,3=时间,4=电钢,5=硕科电机,6=等待轴原点信号
/// </summary>
public
int
WaitType
{
get
;
set
;
}
/// <summary>
/// IO类型
/// </summary>
public
String
IoType
{
get
;
set
;
}
/// <summary>
/// IO值
/// </summary>
public
IO_VALUE
IoValue
{
get
;
set
;
}
/// <summary>
/// 等待的毫秒
/// </summary>
public
int
TimeMSeconds
{
get
;
set
;
}
/// <summary>
/// 是否已经结束
/// </summary>
public
bool
IsEnd
{
get
;
set
;
}
}
internal
class
WaitEnum
{
/// <summary>
/// 伺服运动
/// </summary>
internal
static
int
W001_AxisMove
=
1
;
/// <summary>
/// 信号到达
/// </summary>
internal
static
int
W002_IOValue
=
2
;
/// <summary>
/// 时间等待
/// </summary>
internal
static
int
W003_Time
=
3
;
/// <summary>
/// 电钢运动
/// </summary>
internal
static
int
W004_StellMove
=
4
;
/// <summary>
/// 硕科电机
/// </summary>
internal
static
int
W005_ShuoKe
=
5
;
/// <summary>
/// 轴原点信号
/// </summary>
internal
static
int
W006_AxisOrg
=
6
;
/// <summary>
/// 等待机器人运动
/// </summary>
internal
static
int
W007_WaitAbb
=
7
;
}
public
enum
LineMoveType
{
/// <summary>
/// 没有任何操作
/// </summary>
None
=
0
,
/// <summary>
/// 料架入流水线处理
/// </summary>
LeftShelf
=
1
,
/// <summary>
/// S1工位料架处理
/// </summary>
S1Shelf
=
2
,
/// <summary>
/// 机器人放料
/// </summary>
PutTray
=
3
,
/// <summary>
/// 原点返回
/// </summary>
ReturnHome
=
4
,
/// <summary>
/// 重置
/// </summary>
StoreReset
=
5
,
/// <summary>
/// 左侧工作位到缓存
/// </summary>
LTransWork2Buf
,
/// <summary>
/// 左侧缓存到工作
/// </summary>
LTransBuf2Work
,
/// <summary>
/// 右侧工作位到缓存
/// </summary>
RTransWork2Buf
,
/// <summary>
/// 右侧缓存到工作
/// </summary>
RTransBuf2Work
,
}
}
source/DeviceLibrary/bean/MoveStep.cs
deleted
100644 → 0
查看文件 @
aae1473
using
log4net
;
using
OnlineStore.Common
;
using
OnlineStore.DeviceLibrary
;
using
OnlineStore.LoadCSVLibrary
;
using
System
;
using
System.Collections.Generic
;
using
System.Drawing
;
using
System.IO
;
using
System.IO.Ports
;
using
System.Linq
;
using
System.Text
;
using
System.Windows.Forms
;
namespace
OnlineStore.DeviceLibrary
{
/// <summary>
/// 等待启动/已经停止,初始化完成, 正常运行中,可以进行新的处理,忙碌,重置
/// </summary>
public
enum
RunStatus
{
/// <summary>
/// 等待启动/已经停止
/// </summary>
Wait
=
0
,
/// <summary>
/// 初始化 ,原点返回状态中
/// </summary>
HomeMoving
=
1
,
/// <summary>
/// 设备正在重置中,请稍后
/// </summary>
Reset
=
2
,
/// <summary>
/// 正常运行中,可以进行新的处理
/// </summary>
Runing
=
3
,
/// <summary>
/// 正在忙碌中,请稍后
/// </summary>
Busy
=
4
,
}
public
enum
MoveStep
{
/// <summary>
/// 无操作,等待状态
/// </summary>
Wait
=
0
,
#
region
双层流水线原点返回和重置步骤
/// <summary>
/// 复位:所有阻挡上升,工位定位下降
/// </summary>
H01_StopUp
=
011
,
/// <summary>
/// 复位:线体开始转动5秒
/// </summary>
H02_LineRun
=
012
,
/// <summary>
/// 复位:提升机下降
/// </summary>
H03_UpoownDown
=
013
,
/// <summary>
/// 复位:提升机已下架,如果提升机有料架,先转动到左侧,提升机阻挡下降
/// </summary>
H04_MStopDown
=
014
,
/// <summary>
/// 复位:提升机料架转动到左侧
/// </summary>
H05_MShlefToLeft
=
015
,
/// <summary>
/// 复位:保存左侧料架
/// </summary>
H06_SaveLeft
=
016
,
#
endregion
#
region
机器人取放料步骤
/// <summary>
/// 机器人取料
/// </summary>
T01_GetTray
=
101
,
/// <summary>
/// 机器人放料
/// </summary>
T02_PutTray
=
102
,
/// <summary>
/// 放料结束
/// </summary>
T03_PutFINISHED
=
103
,
/// <summary>
/// 等待putFinished结束
/// </summary>
T04_WaitEnd
=
104
,
#
endregion
#
region
料架从左侧入口进入轨道处理
/// <summary>
/// 料架入轨道: 等待料架完全进入左侧升降机
/// </summary>
SI01_ShelfInLeft
=
201
,
/// <summary>
/// 料架入轨道:读取RFID
/// </summary>
SI02_ReadRFID
=
202
,
/// <summary>
/// 料架入轨道:升降机上升或下降
/// </summary>
SI03_UpdownMove
=
203
,
/// <summary>
/// 料架入轨道:阻挡下降,线体正转
/// </summary>
SI04_InStopDown
=
204
,
/// <summary>
/// 料架入轨道:阻挡上升,等待检测1亮
/// </summary>
SI05_WaitCheck1High
,
/// <summary>
/// 料架入轨道:等待检测1灭,或者再等待6秒
/// </summary>
SI06_WaitCheck1Low
,
/// <summary>
/// 料架入轨道:等待升降机可以下降
/// </summary>
SI07_WaitCanDown
,
/// <summary>
/// 料架入轨道:升降机返回
/// </summary>
SI08_UpdownDown
,
/// <summary>
/// 料架入轨道:等待停止链条
/// </summary>
SI09_WaitStopRun
,
#
endregion
#
region
S1
工位料架处理
/// <summary>
/// S1工位需要一个新料架
/// </summary>
S1_NewShelf
=
1000
,
/// <summary>
/// C料架->S1:S1工位需要一个大料架
/// </summary>
S1_C01_GetC
=
1001
,
/// <summary>
/// C料架->S1::中间提升机下降
/// </summary>
S1_C02_MDown
=
1002
,
/// <summary>
/// C料架->S1::阻挡2下降,链条转动,开始放大料架过来
/// </summary>
S1_C03_MStopDown
=
1003
,
/// <summary>
/// C料架->S1::等待料架到达中间升降机
/// </summary>
S1_C04_DToLeft
,
/// <summary>
/// C料架->S1:判断S1是否有料架
/// </summary>
S1_C05_CheckS1
,
/// <summary>
/// C料架->S1:记录左侧料架信息
/// </summary>
S1_C06_SaveLeft
,
/// <summary>
///C料架->S1::等待料架到达
/// </summary>
S1_C07_ToS1
,
/// <summary>
/// D料架/右侧上层料架-> S1:S1工位需要一个小料架
/// </summary>
S1_D10_GetD
=
1010
,
/// <summary>
/// D料架-> S1:提升机上升
/// </summary>
S1_D11_MUp
=
1011
,
/// <summary>
/// D料架-> S1:上层阻挡下降,上层链条转,中间链条转
/// </summary>
S1_D12_LineRun
=
1012
,
/// <summary>
/// D料架-> S1:在转动3秒钟等待到位
/// </summary>
S1_D13_WaitCInM
=
1013
,
/// <summary>
///D料架-> S1: 料架到达中间提升机,两侧阻挡上升
/// </summary>
S1_D14_MStopUp
,
/// <summary>
///D料架-> S1: 提升机下降
/// </summary>
S1_D15_MDown
,
/// <summary>
/// D料架->S1::等待料架到达左侧
/// </summary>
S1_D16_CToLeft
,
/// <summary>
/// D料架->S1:判断S1是否有料架
/// </summary>
S1_D17_CheckS1
,
/// <summary>
/// D料架->S1:记录左侧料架信息
/// </summary>
S1_D18_SaveLeft
,
/// <summary>
///D料架-> S1: 转动工位链条等待料架到达
/// </summary>
S1_D19_ToS1
,
/// <summary>
/// S1 等待2秒钟后料架稳定,
/// </summary>
S1_21_WaitShelf
=
1021
,
/// <summary>
/// S1 读取料架号,
/// </summary>
S1_22_ReadRFID
=
1022
,
/// <summary>
/// S1 读取料架号,顶生气缸上升
/// </summary>
S1_23_ToReady
=
1023
,
/// <summary>
/// S1Ready
/// </summary>
S1_24_Ready
,
/// <summary>
/// S1 等待S1料架可以移动到右侧
/// </summary>
S1_26_WaitS1Go
,
/// <summary>
/// S1 放走当前料架
/// </summary>
S1_27_S1ShelfGo
,
/// <summary>
/// SI料架离开后,左侧料架转入S1
/// </summary>
S1_28_LeftToS1
,
/// <summary>
/// 左->S1切换 : 等待右侧无料架
/// </summary>
S1_30_WaitS1ToRight
=
1030
,
/// <summary>
/// 左->S1切换 : S1料架先到右侧
/// </summary>
S1_31_S1ToRight
=
1031
,
/// <summary>
/// 左->S1切换 : S1料架到达右侧,记录右侧信息,清空S1信息,左侧料架开始到S1
/// </summary>
S1_32_LeftToS1
,
/// <summary>
/// 左->S1切换 : 左侧料架到达S1
/// </summary>
S1_33_LeftOnS1
,
/// <summary>
/// 右->S1切换: 等待S1料架可以移动到左侧
/// </summary>
S1_40_WaitS1ToLeft
=
1040
,
/// <summary>
/// 右->S1切换: S1料架先到左侧
/// </summary>
S1_41_S1ToLeft
=
1041
,
/// <summary>
/// 右->S1切换: 等待S料架完全进入左侧
/// </summary>
S1_42_WaitInLeft
,
/// <summary>
/// 右->S1切换: S1料架到达左侧,记录左侧信息,清空S1信息,等待右侧料架可以到S1
/// </summary>
S1_43_WaitRightToS1
,
/// <summary>
/// 右->S1切换: 右侧料架开始到S1
/// </summary>
S1_44_RightToS1
,
/// <summary>
/// 右->S1切换: 等待料架完全进入S1
/// </summary>
S1_44_WaitShelfInS1
,
/// <summary>
/// 右->S1切换: 右侧料架到达S1
/// </summary>
S1_45_LeftOnS1
,
///// <summary>
///// 需要放一个新料架过来,等待S1料架可以到右侧
///// </summary>
//S1_50_WaitS1ToRight = 1050,
///// <summary>
///// 需要放一个新料架过来,S1的料架暂存到右侧
///// </summary>
//S1_51_S1ToRight,
/// <summary>
/// 使用左侧料架
/// </summary>
S1_GetShelfFromLeft
,
#
endregion
#
region
左侧上层工作位到缓存位
/// <summary>
/// 左侧上层缓存位需要料架
/// </summary>
SW2B_L1_GetShelf
,
/// <summary>
/// 左侧横移上升
/// </summary>
SW2B_L2_Tranverse_Up
,
/// <summary>
/// 左侧横移正传
/// </summary>
SW2B_L3_Tranverse_Run
,
/// <summary>
/// 料架到达横移缓存位置
/// </summary>
SW2B_L4_Shelf_To_Buf
,
/// <summary>
/// 横移下降
/// </summary>
SW2B_L5_Tranverse_Down
,
/// <summary>
/// 料架离开横移
/// </summary>
SW2B_L6_Shelf_Leave_Buf
,
/// <summary>
/// 横移料架结束
/// </summary>
SW2B_L7_Tranverse_Finish
,
#
endregion
#
region
左侧上层缓存位到工作位
/// <summary>
/// 左侧缓存料架运行到横移
/// </summary>
SB2W_L0_None
,
/// <summary>
/// 左侧缓存到位
/// </summary>
SB2W_L0_GetShelf
,
/// <summary>
/// 左侧工作位需要料架
/// </summary>
SB2W_L1_GetShelf
,
/// <summary>
/// 左侧缓存横移上升
/// </summary>
SB2W_L2_Tranverse_Up
,
/// <summary>
/// 左侧横移反传
/// </summary>
SB2W_L3_Tranverse_Run
,
/// <summary>
/// 料架到达横移工作位位置
/// </summary>
SB2W_L4_Shelf_To_Buf
,
/// <summary>
/// 横移下降
/// </summary>
SB2W_L5_Tranverse_Down
,
/// <summary>
/// 料架离开横移
/// </summary>
SB2W_L6_Shelf_Leave_Buf
,
/// <summary>
/// 横移料架结束
/// </summary>
SB2W_L7_Tranverse_Finish
,
#
endregion
}
public
enum
AlarmType
{
/// <summary>
/// 没有报警
/// </summary>
None
=
0
,
/// <summary>
/// io信号超时未收到
/// </summary>
IoSingleTimeOut
=
10
,
/// <summary>
/// io信号超时未收到
/// </summary>
ShelfError
=
100
,
/// <summary>
/// 收到急停
/// </summary>
SuddenStop
=
1000
,
/// <summary>
/// 没有气压信号
/// </summary>
NoAirCheck
=
1001
,
///// <summary>
///// 轴运动错误,没有达到指定脉冲,但是io判断已停止运动
///// </summary>
//AxisMoveError = 20,
}
}
source/DeviceLibrary/bean/RobotBase.cs
deleted
100644 → 0
查看文件 @
aae1473
using
OnlineStore.Common
;
using
OnlineStore.LoadCSVLibrary
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading
;
using
System.Threading.Tasks
;
namespace
OnlineStore.DeviceLibrary
{
public
class
RobotBase
{
public
LineMoveInfo
MoveInfo
=
null
;
public
AlarmType
alarmType
=
AlarmType
.
None
;
public
bool
IsDebug
=
false
;
public
bool
isInSuddenDown
=
false
;
public
bool
NoAirCheck
=
false
;
public
string
WarnMsg
=
""
;
protected
System
.
Timers
.
Timer
ledTimer
=
new
System
.
Timers
.
Timer
();
protected
System
.
Timers
.
Timer
mainTimer
=
new
System
.
Timers
.
Timer
();
public
string
Name
=
""
;
public
RobotConfig
baseConfig
=
null
;
public
RobotBase
(
RobotConfig
baseConfig
)
{
this
.
baseConfig
=
baseConfig
;
ledTimer
=
new
System
.
Timers
.
Timer
();
ledTimer
.
Interval
=
1000
;
ledTimer
.
AutoReset
=
true
;
ledTimer
.
Enabled
=
false
;
mainTimer
=
new
System
.
Timers
.
Timer
();
mainTimer
.
Interval
=
300
;
mainTimer
.
AutoReset
=
true
;
mainTimer
.
Enabled
=
false
;
}
public
bool
CylinderIsOk
(
string
IoLowType
,
string
IoHighType
)
{
if
(
IOManager
.
DIValue
(
IoLowType
).
Equals
(
IO_VALUE
.
LOW
)
&&
IOManager
.
DIValue
(
IoHighType
).
Equals
(
IO_VALUE
.
HIGH
))
{
return
true
;
}
return
false
;
}
public
void
CylinderMove
(
LineMoveInfo
moveInfo
,
string
IoLowType
,
string
IoHighType
,
bool
isCheckMove
=
false
)
{
try
{
if
(
moveInfo
!=
null
)
{
moveInfo
.
WaitList
.
Add
(
WaitResultInfo
.
WaitIO
(
IoLowType
,
IO_VALUE
.
LOW
));
moveInfo
.
WaitList
.
Add
(
WaitResultInfo
.
WaitIO
(
IoHighType
,
IO_VALUE
.
HIGH
));
MoveInfo
.
WaitList
.
Add
(
WaitResultInfo
.
WaitTime
(
200
));
}
if
(
isCheckMove
)
{
CheckAndMove
(
IoLowType
,
IO_VALUE
.
LOW
);
CheckAndMove
(
IoHighType
,
IO_VALUE
.
HIGH
);
}
else
{
IOMove
(
IoLowType
,
IO_VALUE
.
LOW
);
IOMove
(
IoHighType
,
IO_VALUE
.
HIGH
);
}
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
Name
+
"CylinderMove ["
+
IoLowType
+
"] ["
+
IoHighType
+
"] ["
+
isCheckMove
+
"] 出错:"
+
ex
.
ToString
());
}
}
public
void
CheckAndMove
(
string
IoType
,
IO_VALUE
value
)
{
if
(!
IOValue
(
IoType
).
Equals
(
value
))
{
IOMove
(
IoType
,
value
);
}
}
public
void
IOMove
(
string
IoType
,
IO_VALUE
value
,
int
msTime
=
0
)
{
if
(
msTime
<=
0
)
{
IOManager
.
IOMove
(
IoType
,
value
);
}
else
{
Task
.
Factory
.
StartNew
(
delegate
{
IOManager
.
IOMove
(
IoType
,
value
);
Thread
.
Sleep
(
msTime
);
IO_VALUE
tValue
=
value
.
Equals
(
IO_VALUE
.
HIGH
)
?
IO_VALUE
.
LOW
:
IO_VALUE
.
HIGH
;
LogUtil
.
info
(
msTime
+
"时间到,设置"
+
IoType
+
"="
+
tValue
);
IOManager
.
IOMove
(
IoType
,
tValue
);
});
}
}
public
IO_VALUE
IOValue
(
string
IoType
)
{
return
IOManager
.
IOValue
(
IoType
);
}
public
void
DebugInfo
(
string
logInfo
)
{
LogUtil
.
debug
(
Name
+
logInfo
);
}
public
void
LogInfo
(
string
logInfo
)
{
LogUtil
.
info
(
Name
+
logInfo
);
}
/// <summary>
/// 阻塞等待IO信号,等到返回true,未等到返回false
/// </summary>c
public
bool
WaitIo
(
string
ioType
,
IO_VALUE
value
,
int
timeOut
,
string
errName
=
""
)
{
try
{
return
WaitUtil
.
Wait
(
timeOut
,
delegate
()
{
return
value
.
Equals
(
IOValue
(
ioType
));
},
errName
);
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
Name
+
" 等待"
+
ioType
+
"="
+
value
+
"超时:"
+
ex
.
ToString
());
return
false
;
}
}
public
void
SetWarnMsg
(
string
msg
=
""
)
{
if
(
String
.
IsNullOrEmpty
(
msg
).
Equals
(
false
))
{
if
(
WarnMsg
.
Equals
(
msg
))
{
if
(
msg
.
StartsWith
(
Name
))
{
LogUtil
.
error
(
msg
,
105
);
}
else
{
LogUtil
.
error
(
Name
+
msg
,
105
);
}
}
else
{
if
(
msg
.
StartsWith
(
Name
))
{
LogUtil
.
error
(
msg
);
}
else
{
LogUtil
.
error
(
Name
+
msg
);
}
}
}
WarnMsg
=
msg
;
}
#
region
CheckWait
处理
private
DateTime
preCheckAxisTime
=
DateTime
.
Now
;
protected
DateTime
preRWTime
=
DateTime
.
Now
;
internal
void
CheckWait
(
LineMoveInfo
moveInfo
)
{
try
{
List
<
WaitResultInfo
>
list
=
moveInfo
.
WaitList
;
if
(
list
.
Count
<=
0
)
{
moveInfo
.
EndStepWait
();
return
;
}
//当等待超过一分钟时,需要打印提示
TimeSpan
span
=
DateTime
.
Now
-
moveInfo
.
LastSetpTime
;
string
NotOkMsg
=
""
;
bool
isOk
=
true
;
if
(
moveInfo
.
OneWaitCanEndStep
)
{
isOk
=
false
;
}
foreach
(
WaitResultInfo
wait
in
list
)
{
if
((!
wait
.
WaitType
.
Equals
(
WaitEnum
.
W002_IOValue
))
&&
wait
.
IsEnd
)
{
continue
;
}
NotOkMsg
=
" ["
+
wait
.
ToStr
()
+
"] "
;
if
(
wait
.
WaitType
.
Equals
(
WaitEnum
.
W001_AxisMove
))
{
}
else
if
(
wait
.
WaitType
.
Equals
(
WaitEnum
.
W002_IOValue
))
{
NotOkMsg
=
" ["
+
baseConfig
.
GetDisplayName
(
wait
.
IoType
)
+
"="
+
wait
.
IoValue
+
"]"
;
wait
.
IsEnd
=
IOValue
(
wait
.
IoType
).
Equals
(
wait
.
IoValue
);
if
(!
wait
.
IsEnd
)
{
if
(
wait
.
IoType
.
Equals
(
IO_Type
.
LHigh_LineRun
)
||
wait
.
IoType
.
Equals
(
IO_Type
.
LLown_LineRun
))
{
IOMove
(
wait
.
IoType
,
wait
.
IoValue
);
LogInfo
(
" ["
+
moveInfo
.
MoveType
+
"]["
+
moveInfo
.
MoveStep
+
"]重写DO: "
+
wait
.
ToStr
());
}
TimeSpan
rwSpan
=
DateTime
.
Now
-
preRWTime
;
//一分钟还未检测到
if
(
span
.
TotalSeconds
>
LineManager
.
Config
.
IOSingle_TimerOut
)
{
if
(
alarmType
.
Equals
(
AlarmType
.
None
))
{
ConfigIO
io
=
baseConfig
.
getWaitIO
(
wait
.
IoType
);
WarnMsg
=
Name
+
"["
+
moveInfo
.
MoveType
+
"]["
+
moveInfo
.
MoveStep
+
"] 等待"
+
NotOkMsg
+
" 超时 "
+
Math
.
Round
(
span
.
TotalSeconds
,
1
)
+
"秒"
;
LogUtil
.
error
(
Name
+
WarnMsg
,
13
);
Alarm
(
AlarmType
.
IoSingleTimeOut
);
}
}
else
if
(
rwSpan
.
TotalSeconds
>
5
&&
span
.
TotalSeconds
>
6
&&
span
.
TotalSeconds
<
LineManager
.
Config
.
IOSingle_TimerOut
*
2
)
{
if
(
moveInfo
.
CanRMoveIO
)
{
preRWTime
=
DateTime
.
Now
;
string
msg
=
Name
+
" ["
+
moveInfo
.
MoveType
+
"]["
+
moveInfo
.
MoveStep
+
"] "
+
NotOkMsg
+
"已等待 "
+
Math
.
Round
(
span
.
TotalSeconds
,
1
)
+
"秒,重写DO:"
;
bool
isLog
=
false
;
foreach
(
WaitResultInfo
ww
in
list
)
{
if
(
ww
!=
null
&&
ww
.
WaitType
.
Equals
(
2
)
&&
baseConfig
.
DOList
.
ContainsKey
(
ww
.
IoType
))
{
if
(
IOManager
.
DOValue
(
ww
.
IoType
).
Equals
(
ww
.
IoValue
).
Equals
(
false
))
{
isLog
=
true
;
IOMove
(
ww
.
IoType
,
ww
.
IoValue
);
msg
+=
ww
.
ToStr
()
+
","
;
}
}
}
if
(
isLog
)
{
LogUtil
.
error
(
msg
);
}
}
}
if
(!
moveInfo
.
OneWaitCanEndStep
)
{
isOk
=
false
;
break
;
}
}
}
else
if
(
wait
.
WaitType
.
Equals
(
WaitEnum
.
W003_Time
))
{
wait
.
IsEnd
=
(
span
.
TotalMilliseconds
>=
wait
.
TimeMSeconds
);
}
if
(
wait
.
IsEnd
)
{
if
(
moveInfo
.
OneWaitCanEndStep
)
{
isOk
=
true
;
break
;
}
}
else
{
if
(!
moveInfo
.
OneWaitCanEndStep
)
{
isOk
=
false
;
break
;
}
}
}
if
(
isOk
)
{
moveInfo
.
EndStepWait
();
}
else
if
(
span
.
TotalSeconds
>
moveInfo
.
TimeOutSeconds
)
{
WarnMsg
=
Name
+
"["
+
moveInfo
.
MoveType
+
"]["
+
moveInfo
.
MoveStep
+
"]等待"
+
NotOkMsg
+
"超时["
+
Math
.
Round
(
span
.
TotalSeconds
,
1
)
+
"]秒"
;
LogUtil
.
error
(
WarnMsg
,
1002
);
Alarm
(
AlarmType
.
IoSingleTimeOut
);
}
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
Name
+
" ["
+
moveInfo
.
MoveStep
+
"] CheckWait 出错:"
,
ex
);
}
}
public
virtual
string
GetRunInfo
()
{
return
""
;
}
#
endregion
public
virtual
bool
StartRun
()
{
return
false
;
}
public
virtual
void
StopRun
()
{
}
public
virtual
void
Reset
()
{
}
public
virtual
void
StopMove
()
{
}
public
virtual
void
Alarm
(
AlarmType
alarmType
)
{
}
}
}
source/DeviceLibrary/bean/WaitUtil.cs
deleted
100644 → 0
查看文件 @
aae1473
using
OnlineStore.Common
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading
;
using
System.Threading.Tasks
;
namespace
OnlineStore.DeviceLibrary
{
public
class
WaitUtil
{
public
delegate
bool
IsOk
();
/// <summary>
/// 使用异步委托检测超时,防止isOk方法不返回结果导致卡死的问题
/// </summary>
/// <param name="waitName"></param>
/// <param name="timeout"></param>
/// <param name="isOk"></param>
public
static
bool
Wait
(
int
timeout
,
IsOk
isOk
,
string
waitName
=
""
)
{
DateTime
startTime
=
System
.
DateTime
.
Now
;
TimeSpan
timoutSpan
=
TimeSpan
.
FromMilliseconds
(
timeout
);
TimeSpan
waitSpan
=
TimeSpan
.
FromMilliseconds
(
0
);
int
sleepTime
=
10
;
while
(
true
)
{
TimeSpan
remainTimes
=
timoutSpan
.
Subtract
(
waitSpan
);
if
(
remainTimes
.
TotalMilliseconds
<
0
)
{
//已经超时
throw
new
TimeoutException
(
waitName
+
"超时"
);
}
try
{
IAsyncResult
re
=
isOk
.
BeginInvoke
(
null
,
null
);
var
waitResult
=
re
.
AsyncWaitHandle
.
WaitOne
(
remainTimes
);
if
(
waitResult
)
{
bool
okResult
=
isOk
.
EndInvoke
(
re
);
if
(
okResult
)
{
return
true
;
}
}
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
"同步等待出现异常:"
,
ex
);
}
Thread
.
Sleep
(
sleepTime
);
waitSpan
=
System
.
DateTime
.
Now
.
Subtract
(
startTime
);
}
}
}
}
source/DeviceLibrary/bean/_system~.ini
deleted
100644 → 0
查看文件 @
aae1473
文件属性发生变化
source/DeviceLibrary/bean/jobType/_system~.ini
deleted
100644 → 0
查看文件 @
aae1473
文件属性发生变化
source/DeviceLibrary/manager/LineManager.cs
查看文件 @
7e81418
...
...
@@ -52,7 +52,7 @@ namespace DeviceLibrary
{
string
appPath
=
Application
.
StartupPath
;
string
linefilePath
=
appPath
+
"\\Config\\"
+
AppConfigHelper
.
GetValue
(
SettingString
.
Line_Config
);
string
linefilePath
=
appPath
+
"\\Config\\"
+
AppConfigHelper
.
GetValue
(
SettingString
.
Line_Config
,
"LineConfig.csv"
);
LogUtil
.
info
(
" 开始加载配置:"
+
linefilePath
);
RobotConfig
storeConfig
=
CSVConfigReader
.
LoadConfig
(
linefilePath
);
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论