Commit 2fff9226 LN

增加DeviceType

1 个父辈 459a7efc
此文件类型无法预览
......@@ -42,13 +42,18 @@ namespace OnlineStore.DeviceLibrary
BaseTimerProcess();
}
public override void Alarm(LineAlarmType alarmType, string alarmDetial, string alarmMsg, LineMoveType storeMoveType)
public override void Alarm(LineAlarmType alarmType )
{
if (this.alarmType.Equals(alarmType))
{
return;
}
this.alarmType = alarmType;
if (alarmType.Equals(LineAlarmType.SuddenStop) || alarmType.Equals(LineAlarmType.NoAirCheck))
{
StopMove();
}
}
/// <summary>
/// 运动处理
......@@ -106,13 +111,10 @@ namespace OnlineStore.DeviceLibrary
private void BaseTimerProcess()
{
if (isInPro)
TimeSpan span = DateTime.Now - lastProTimer;
if (isInPro && span.TotalSeconds < 20)
{
TimeSpan span = DateTime.Now - lastAirCloseTime;
if (span.TotalSeconds < 20)
{
return;
}
return;
}
isInPro = true;
lastProTimer = DateTime.Now;
......@@ -123,10 +125,7 @@ namespace OnlineStore.DeviceLibrary
isInPro = false;
return;
}
BusyMoveProcess();
TimerProcess();
IOTimeOutProcess();
}
catch (Exception ex)
{
......@@ -168,22 +167,25 @@ namespace OnlineStore.DeviceLibrary
}
public void ChangeDebug(bool isDebug)
{
if (isDebug)
if (baseConfig.DType.Equals(DeviceType.MoveEquip) || baseConfig.DType.Equals(DeviceType.ProvidingEquip))
{
IsDebug = true;
//两个阻挡气缸下降
lineStatus = LineStatus.Debugging;
IOMove(IO_Type.StopCylinder_Down1, IO_VALUE.HIGH);
IOMove(IO_Type.StopCylinder_Down2, IO_VALUE.HIGH);
LogInfo("从正常状态切换到调试状态!");
}
else if (lineStatus.Equals(LineStatus.Debugging))
{
IsDebug = false;
lineStatus = LineStatus.StoreOnline;
IOMove(IO_Type.StopCylinder_Down1, IO_VALUE.HIGH);
IOMove(IO_Type.StopCylinder_Down2, IO_VALUE.LOW);
LogInfo("从调试状态切换到正常状态!");
if (isDebug)
{
IsDebug = true;
//两个阻挡气缸下降
lineStatus = LineStatus.Debugging;
IOMove(IO_Type.StopCylinder_Down1, IO_VALUE.HIGH);
IOMove(IO_Type.StopCylinder_Down2, IO_VALUE.HIGH);
LogInfo("从正常状态切换到调试状态!");
}
else if (lineStatus.Equals(LineStatus.Debugging))
{
IsDebug = false;
lineStatus = LineStatus.StoreOnline;
IOMove(IO_Type.StopCylinder_Down1, IO_VALUE.HIGH);
IOMove(IO_Type.StopCylinder_Down2, IO_VALUE.LOW);
LogInfo("从调试状态切换到正常状态!");
}
}
}
......@@ -194,30 +196,36 @@ namespace OnlineStore.DeviceLibrary
/// </summary>
internal void OpenStopCylinder()
{
LogInfo("下降阻挡气缸,上下气缸上升,顶升气缸下降");
IOMove(IO_Type.StopCylinder_Down1, IO_VALUE.HIGH);
IOMove(IO_Type.StopCylinder_Down2, IO_VALUE.HIGH);
//上下气缸上升
if (UseAxis.Equals(false))
if (baseConfig.DType.Equals(DeviceType.MoveEquip) || baseConfig.DType.Equals(DeviceType.ProvidingEquip))
{
IOMove(IO_Type.UpDownCylinder_Down, IO_VALUE.LOW);
IOMove(IO_Type.UpDownCylinder_Up, IO_VALUE.HIGH);
LogInfo("下降阻挡气缸,上下气缸上升,顶升气缸下降");
IOMove(IO_Type.StopCylinder_Down1, IO_VALUE.HIGH);
IOMove(IO_Type.StopCylinder_Down2, IO_VALUE.HIGH);
//上下气缸上升
if (UseAxis.Equals(false))
{
IOMove(IO_Type.UpDownCylinder_Down, IO_VALUE.LOW);
IOMove(IO_Type.UpDownCylinder_Up, IO_VALUE.HIGH);
}
//顶升气缸下降
IOMove(IO_Type.TopCylinder_UP, IO_VALUE.LOW);
IOMove(IO_Type.TopCylinder_Down, IO_VALUE.HIGH);
}
//顶升气缸下降
IOMove(IO_Type.TopCylinder_UP, IO_VALUE.LOW);
IOMove(IO_Type.TopCylinder_Down, IO_VALUE.HIGH);
}
internal void CloseCylinderStop()
{
LogInfo("上升阻挡气缸,关闭上下气缸,顶升气缸IO");
IOMove(IO_Type.StopCylinder_Down1, IO_VALUE.LOW);
IOMove(IO_Type.StopCylinder_Down2, IO_VALUE.LOW);
//上下气缸上升
IOMove(IO_Type.UpDownCylinder_Down, IO_VALUE.LOW);
IOMove(IO_Type.UpDownCylinder_Up, IO_VALUE.LOW);
//顶升气缸下降
IOMove(IO_Type.TopCylinder_UP, IO_VALUE.LOW);
IOMove(IO_Type.TopCylinder_Down, IO_VALUE.LOW);
if (baseConfig.DType.Equals(DeviceType.MoveEquip) || baseConfig.DType.Equals(DeviceType.ProvidingEquip))
{
LogInfo("上升阻挡气缸,关闭上下气缸,顶升气缸IO");
IOMove(IO_Type.StopCylinder_Down1, IO_VALUE.LOW);
IOMove(IO_Type.StopCylinder_Down2, IO_VALUE.LOW);
//上下气缸上升
IOMove(IO_Type.UpDownCylinder_Down, IO_VALUE.LOW);
IOMove(IO_Type.UpDownCylinder_Up, IO_VALUE.LOW);
//顶升气缸下降
IOMove(IO_Type.TopCylinder_UP, IO_VALUE.LOW);
IOMove(IO_Type.TopCylinder_Down, IO_VALUE.LOW);
}
}
#region 伺服运动
......@@ -292,7 +300,7 @@ namespace OnlineStore.DeviceLibrary
ACServerManager.ServoOff(portName, slvAddr);
WarnMsg = Name + "打开轴" + axis.Explain + "失败 ";
LogUtil.info(Name + WarnMsg);
Alarm(LineAlarmType.AxisAlarm, 5.ToString(), WarnMsg, MoveInfo.MoveType);
Alarm(LineAlarmType.AxisAlarm );
return false;
}
}
......@@ -444,7 +452,7 @@ namespace OnlineStore.DeviceLibrary
{
isOk = false;
WarnMsg = msg;
Alarm(LineAlarmType.AxisMoveError, 5.ToString(), WarnMsg, moveInfo.MoveType);
Alarm(LineAlarmType.AxisMoveError );
break;
}
}
......@@ -474,7 +482,7 @@ namespace OnlineStore.DeviceLibrary
{
ConfigIO io = baseConfig.getWaitIO(wait.IoType);
WarnMsg = Name + "等待" + NotOkMsg + " 超时";
Alarm(LineAlarmType.IoSingleTimeOut, io.ElectricalDefinition, WarnMsg, MoveInfo.MoveType);
Alarm(LineAlarmType.IoSingleTimeOut );
LogUtil.error(MoveInfo.Name + WarnMsg, 13);
}
else if (rwSpan.TotalSeconds > 3 && span.TotalSeconds > 3)
......@@ -540,7 +548,7 @@ namespace OnlineStore.DeviceLibrary
WarnMsg = moveInfo.Name + "[" + moveInfo.MoveType + "][" + moveInfo.MoveStep + "]等待[" + NotOkMsg
+ "]超时[" + Math.Round(span.TotalSeconds, 1) + "]秒";
LogUtil.error(WarnMsg, 18);
Alarm(LineAlarmType.IoSingleTimeOut, "", WarnMsg, moveInfo.MoveType);
Alarm(LineAlarmType.IoSingleTimeOut );
}
}
......
......@@ -78,6 +78,7 @@ namespace OnlineStore.DeviceLibrary
public override void TimerProcess()
{
BusyMoveProcess();
//判断流水线打开了才可以运行
if (MoveInfo.MoveType.Equals(LineMoveType.None))
{
......@@ -88,6 +89,7 @@ namespace OnlineStore.DeviceLibrary
// StartCheckFixture();
}
}
IOTimeOutProcess();
}
......
......@@ -84,7 +84,8 @@ namespace OnlineStore.DeviceLibrary
public override void TimerProcess()
{
{
BusyMoveProcess();
//判断流水线打开了才可以运行
if (SecondMoveInfo.MoveType.Equals(LineMoveType.None))
{
......
......@@ -73,7 +73,8 @@ namespace OnlineStore.DeviceLibrary
}
public override void TimerProcess()
{
{
BusyMoveProcess();
//判断流水线打开了才可以运行
if (SecondMoveInfo.MoveType.Equals(LineMoveType.None))
{
......
......@@ -52,24 +52,35 @@ namespace OnlineStore.DeviceLibrary
conTimer.Start();
}
}
private bool isProcess = false;
private DateTime lastTime = DateTime.Now;
private void ConTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
TimeSpan span = DateTime.Now - lastTime;
if(span.TotalMinutes< IoIPLIst .Count&& isProcess)
{
return;
}
isProcess = true;
lastTime = DateTime.Now;
try
{
List<string> list = new List<string>(IoIPLIst);
if (list.Count > 0)
{
LogUtil.info("开始重连IO模块 ------------" );
foreach (string ip in list)
{
LogUtil.info("重连AOI :" + ip);
ConnectionIP(ip);
}
LogUtil.info("结束重连IO模块 ------------");
}
GC.Collect();
}catch(Exception ex)
{
LogUtil.error("AOI ConTimer_Elapsed 出错: " + ex.ToString());
}
isProcess = false;
}
public void ConnectionIP(string ioIp)
......@@ -127,7 +138,7 @@ namespace OnlineStore.DeviceLibrary
//aioBox.Log_RxTx_Event += AioBox_Log_RxTx_Event;
AIOMap.Add(ioIp, aioBox);
LogUtil.debug("开始连接" + logName + ",尝试重连5次");
LogUtil.debug("开始连接" + logName + ",尝试重连3次");
for (int i = 1; i <= 3; i++)
{
bool result = aioBox.Connect();
......@@ -147,7 +158,8 @@ namespace OnlineStore.DeviceLibrary
{
LogUtil.error("第【" + i + "】次连接 " + logName + " 失败:" + aioBox.ErrInfo + "");
}
Thread.Sleep(2);
Thread.Sleep(5);
GC.Collect();
}
}
......
......@@ -24,9 +24,9 @@ namespace OnlineStore.DeviceLibrary
/// <summary>
/// 初始化摄像机名称和二维码类型
/// </summary>
public static void LoadConfig( )
public static void LoadConfig()
{
// string nameStr = ConfigAppSettings.GetValue(Setting_Init.CameraName);
// string nameStr = ConfigAppSettings.GetValue(Setting_Init.CameraName);
string codeStr = ConfigAppSettings.GetValue(Setting_Init.CodeType);
// cameraNameList = new List<string>();
codeTypeList = new List<string>();
......@@ -36,43 +36,73 @@ namespace OnlineStore.DeviceLibrary
//string[] nameArray = nameStr.Split(spiltChar);
//foreach (string str in nameArray)
//{
// LogUtil.info("加载到配置摄像机名称:" + str.Trim());
// if (str.Trim().Equals(""))
// {
// continue;
// }
// //LogUtil.info("加载到配置摄像机名称:" + str.Trim());
// cameraNameList.Add(str.Trim());
//}
string[] codeArray = codeStr.Split(spiltChar);
foreach (string str in codeArray)
{
if (str.Trim().Equals(""))
{
continue;
}
LogUtil.info("加载到配置二维码类型:" + str.Trim());
codeTypeList.Add(str.Trim());
}
LoadCamera(false);
CodeLibrary.HDCodeLearnHelper.LoadConfig("", codeStr);
}
catch (Exception ex)
{
LogUtil.error("解析摄像机配置出错:" + ex.ToString());
LogUtil.error("解析摄像机配置出错:" + ex.StackTrace);
}
}
private static void LoadCamera(bool isReLoad)
{
if (isReLoad)
{
CodeLibrary.HIKCamera.Instance.Load();
CodeLibrary.BaslerCamera.Instance.Load();
try
{
CodeLibrary.HIKCamera.Instance.Load();
}
catch (Exception ex)
{
LogUtil.error("加载HIK相机出错:" + ex.ToString());
}
try
{
CodeLibrary.BaslerCamera.Instance.Load();
}
catch (Exception ex)
{
LogUtil.error("加载Basler相机出错:" + ex.ToString());
}
}
string[] names = CodeLibrary.HIKCamera.Instance.CameraName;
hikNameList.AddRange(names);
names = CodeLibrary.BaslerCamera.Instance.CameraName;
balserNameList.AddRange(names);
foreach (string name in hikNameList)
if (names != null)
{
LogUtil.info("加载到HIK相机:" + name);
hikNameList.AddRange(names);
foreach (string name in hikNameList)
{
LogUtil.info("加载到HIK相机:" + name);
}
}
foreach (string name in balserNameList)
names = CodeLibrary.BaslerCamera.Instance.CameraName;
if (names != null)
{
LogUtil.info("加载到Balser相机:" + name);
balserNameList.AddRange(names);
foreach (string name in balserNameList)
{
LogUtil.info("加载到Balser相机:" + name);
}
}
}
public static void CloseCamera()
......
......@@ -188,7 +188,7 @@ namespace OnlineStore.DeviceLibrary
/// 报警
/// </summary>
/// <param name="alarmType"></param>
public abstract void Alarm(LineAlarmType alarmType, string alarmDetial, string alarmMsg, LineMoveType storeMoveType);
public abstract void Alarm(LineAlarmType alarmType );
/// <summary>
/// 重置(夹料装置状态不变)
/// </summary>
......
......@@ -472,6 +472,23 @@ namespace OnlineStore.DeviceLibrary
PO_10_BeforeAfterCylinderAfter = 20010,
#endregion
#region 出料流水线处理,30000开始
/// <summary>
/// 出料流水线复位,定位气缸下降
/// </summary>
DL_R_CylinderDown=30001,
/// <summary>
/// 转动皮带开始运行
/// </summary>
DL_R_StartRun=30002,
/// <summary>
/// 皮带线检测处理
/// </summary>
DL_R_LineCheck=30100,
#endregion
}
public enum LineAlarmType
......
......@@ -16,8 +16,9 @@ namespace OnlineStore.LoadCSVLibrary
{
}
public DischargeLine_Config(int id, string cid, string type, string filepath)
: base(id, cid, type, filepath)
: base(id, cid, LoadCSVLibrary.DeviceType.DischargeLine, filepath)
{
}
......
......@@ -16,7 +16,7 @@ namespace OnlineStore.LoadCSVLibrary
{
}
public FeedingEquip_Config(int id, string cid, string type, string filepath)
: base(id, cid, type, filepath)
: base(id, cid, LoadCSVLibrary.DeviceType.FeedingEquip, filepath)
{
}
......
......@@ -331,6 +331,16 @@ namespace OnlineStore.LoadCSVLibrary
/// <summary>
/// DI 出料皮带线体1急停 DLine_SuddenStop X021
/// </summary>
public static string DLine_SuddenStop = "DLine_SuddenStop";
/// <summary>
/// DI 出料皮带线体1复位 DLine_Reset X022
/// </summary>
public static string DLine_Reset = "DLine_Reset";
/// <summary>
/// DI 皮带线1定位检测,Location_Check1, ,X021
/// </summary>
public static string Location_Check1 = "Location_Check1";
......@@ -381,21 +391,31 @@ namespace OnlineStore.LoadCSVLibrary
/// <summary>
/// DI 分盘装置1料盘检测,SeparateDevice_Check, ,X033
/// </summary>
public static string SeparateDevice_Check = "SeparateDevice_Check";
public static string SeparateDevice_Check = "SeparateDevice_Check";
/// <summary>
/// DI 出料皮带线体1运行状态 DLine_RunStatus Y021
/// </summary>
public static string DLine_RunStatus = "DLine_RunStatus";
/// <summary>
/// DI 出料皮带线体1故障状态 DLine_RunAlarm Y022
/// </summary>
public static string DLine_RunAlarm = "DLine_RunAlarm";
/// <summary>
/// DO 0 出料皮带线1运转 LineRun_1,Y021
/// DO 0 出料皮带线1运转 DLine_Run1,Y021
/// </summary>
public static string LineRun_1 = "LineRun_1";
public static string DLine_Run1 = "DLine_Run1";
/// <summary>
/// DO 0 出料皮带线2运转 LineRun_2,Y022
/// DO 0 出料皮带线2运转 DLine_Run2,Y022
/// </summary>
public static string LineRun_2 = "LineRun_2";
public static string DLine_Run2 = "DLine_Run2";
/// <summary>
/// DO 0 出料皮带线3运转 LineRun_3,Y023
/// DO 0 出料皮带线3运转 DLine_Run3,Y023
/// </summary>
public static string LineRun_3 = "LineRun_3";
public static string DLine_Run3 = "DLine_Run3";
/// <summary>
/// DO 0 分盘装置电机驱动 SeparateDevice_Run,Y024
/// </summary>
......
......@@ -25,7 +25,7 @@ namespace OnlineStore.LoadCSVLibrary
/// <param name="type">类型</param>
/// <param name="filepath">配置文件</param>
public Line_Config(int id, string cid, string type, string filepath)
: base(id, cid, type, filepath)
: base(id, cid, LoadCSVLibrary.DeviceType.Line, filepath)
{
}
......
......@@ -16,7 +16,7 @@ namespace OnlineStore.LoadCSVLibrary
{
}
public MoveEquip_Config(int id, string cid, string type, string filepath)
: base(id, cid, type, filepath)
: base(id, cid, LoadCSVLibrary.DeviceType.MoveEquip, filepath)
{
}
......
......@@ -16,7 +16,7 @@ namespace OnlineStore.LoadCSVLibrary
{
}
public ProvidingEquip_Config(int id, string cid, string type, string filepath)
: base(id, cid, type, filepath)
: base(id, cid, LoadCSVLibrary.DeviceType.ProvidingEquip, filepath)
{
}
......
......@@ -21,9 +21,9 @@ namespace OnlineStore.LoadCSVLibrary
/// </summary>
public string CID { get; set; }
/// <summary>
/// 料层类型
/// 设备类型
/// </summary>
public string StoreType { get; set; }
public string DType { get; set; }
/// <summary>
/// 配置文件路径
/// </summary>
......@@ -75,7 +75,7 @@ namespace OnlineStore.LoadCSVLibrary
MustHaveDOList = new List<string>();
this.Id = id;
this.CID = cid;
this.StoreType = type;
this.DType = type;
this.ConfigFilePath = filepath;
}
......@@ -300,4 +300,28 @@ namespace OnlineStore.LoadCSVLibrary
return io.DisplayStr;
}
}
public class DeviceType
{
/// <summary>
/// 流水线线体
/// </summary>
public static string Line = "Line";
/// <summary>
/// 出入库移栽
/// </summary>
public static string MoveEquip = "MoveEquip";
/// <summary>
/// 入料模块
/// </summary>
public static string FeedingEquip = "FeedingEquip";
/// <summary>
/// 出料模块
/// </summary>
public static string ProvidingEquip = "ProvidingEquip";
/// <summary>
/// 出料流水线
/// </summary>
public static string DischargeLine = "DischargeLine";
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!