Commit 5dc3d2f7 ke.sun

新增一个线程检测急停

1 个父辈 fee72540
......@@ -208,37 +208,19 @@ namespace OnlineStore.DeviceLibrary
if (data == null)
{
return;
}
//string strSend = "";
//for (int i = 0; i < data.Length; i++)
//{
// strSend += string.Format("{0:X2} ", data[i]);
//}
//if (strSend.Equals(""))
//{
// return;
//}
//if (IsShowMsg)
//{
// LogUtil.info( " 写入数据:" + strSend + "");
//}
//AcSerialBean bean = GetSerialBean(portName);
//if (bean == null)
//{
// LogUtil.debug("ACServerManager SendData 试图向未打开串口【" + portName + "】写入数据:" + strSend + "。");
// return;
//}
//bean.SendData(data, 0, data.Length);
}
byte[] returnData = SendCommand(portName, data, 50, 8);
string strSend = "";
for (int i = 0; i < returnData.Length; i++)
{
strSend += string.Format("{0:X2} ", returnData[i]);
}
if (IsShowMsg)
if (returnData!=null)
{
LogUtil.info( "串口" + portName + " 收到数据:" + strSend + "");
string strSend = "";
for (int i = 0; i < returnData.Length; i++)
{
strSend += string.Format("{0:X2} ", returnData[i]);
}
if (IsShowMsg)
{
LogUtil.info("串口" + portName + " 收到数据:" + strSend + "");
}
}
}
/// <summary>
......
......@@ -40,6 +40,7 @@ namespace OnlineStore.DeviceLibrary
public bool IsHasCompress_Axis = true;
public ScanSocket scanSocket = new ScanSocket();
private System.Timers.Timer serverConnectTimer = new System.Timers.Timer();
private System.Timers.Timer IoCheckTimer = new System.Timers.Timer();
public AC_SA_BoxBean(AC_SA_Config config)
{
Init();
......@@ -48,6 +49,11 @@ namespace OnlineStore.DeviceLibrary
serverConnectTimer.AutoReset = true;
serverConnectTimer.Enabled = false;
serverConnectTimer.Elapsed += server_connect_timer_Tick;
IoCheckTimer = new System.Timers.Timer();
IoCheckTimer.Interval = 200;
IoCheckTimer.AutoReset = true;
IoCheckTimer.Enabled = false;
IoCheckTimer.Elapsed += IoCheckTimer_Elapsed;
//添加调试
if (config.IsInDebug == 1)
{
......@@ -92,6 +98,26 @@ namespace OnlineStore.DeviceLibrary
KNDIOMove(IO_Type.RunSign_HddLed, IO_VALUE.HIGH);
}
private void IoCheckTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
//判断急停
if (storeRunStatus >= StoreRunStatus.HomeMoving)
{
if (KNDIOValue(IO_Type.SuddenStop_BTN).Equals(IO_VALUE.LOW))
{
if (isInSuddenDown.Equals(false))
{
isInSuddenDown = true;
LogUtil.error(LOGGER, StoreName + "收到急停信号,报警急停");
WarnMsg = StoreName + "收到急停信号,报警急停";
//报警时会关闭所有轴
Alarm(StoreAlarmType.SuddenStop, "1", WarnMsg, StoreMoveType.None);
}
}
}
}
private void CheckPositionLimit(ACStorePosition position)
{
try
......@@ -232,27 +258,28 @@ namespace OnlineStore.DeviceLibrary
//急停按钮和气压检测需要一起判断
IO_VALUE suddenBtn = KNDIOValue(IO_Type.SuddenStop_BTN);
//IO_VALUE airCheck = KNDIOValue(IO_Type.Airpressure_Check);
IO_VALUE airCheck = KNDIOValue(IO_Type.Airpressure_Check);
if (suddenBtn == IO_VALUE.HIGH )
//if (suddenBtn == IO_VALUE.HIGH && airCheck == IO_VALUE.HIGH)
//if (suddenBtn == IO_VALUE.HIGH)
if (suddenBtn == IO_VALUE.HIGH && airCheck == IO_VALUE.HIGH)
{
//lastAirValue = airCheck;
lastAirCloseTime = DateTime.Now;
if (!RunAxis(true ))
lastAirCloseTime = DateTime.Now;
if (!RunAxis(true))
{
return false;
}
}
//TODO 启动时先所有轴远点返回,测试暂时关闭
storeRunStatus = StoreRunStatus.HomeMoving;
//启动温湿度服务器
//HumitureServer.StartTemperateServer(Config.TemperateServer_Port);
scanSocket.ConnectScanner(Config.Scanner_Ip,Config.Scanner_Port );
scanSocket.ConnectScanner(Config.Scanner_Ip, Config.Scanner_Port);
ReturnHome();
StartTime = DateTime.Now;
timersTimer.Enabled = true;
IoCheckTimer.Enabled = true;
serverConnectTimer.Enabled = true;
IsRun = true;
return true;
......@@ -306,8 +333,7 @@ namespace OnlineStore.DeviceLibrary
LogUtil.info(LOGGER, StoreName + "到待机状态,进出轴到P1,判断叉子没有料盘");
ACAxisMove(Config.InOut_Axis, Config.InOutAxis_P1_Position, Config.InOutAxis_P1_Speed );
//判断叉子没有料盘
StoreMove.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.TrayCheck_Fixture, IO_VALUE.LOW));
//StoreMove.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.TrayCheck_4, IO_VALUE.LOW));
StoreMove.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.TrayCheck_Fixture, IO_VALUE.LOW));
}
public override void Reset()
{
......@@ -366,6 +392,8 @@ namespace OnlineStore.DeviceLibrary
StoreMove.NextMoveStep(StoreMoveStep.BOX_H_LocationCylinderBack);
LocationDownAndWait();
}
InProcess = false;
isInPro = false;
}
/// <summary>
......@@ -669,6 +697,7 @@ namespace OnlineStore.DeviceLibrary
{
WarnMsg = "";
autoNext = false;
IoCheckTimer.Enabled = false;
serverConnectTimer.Enabled = false;
StopMove();
......@@ -699,10 +728,7 @@ namespace OnlineStore.DeviceLibrary
return;
}
LogUtil.error(LOGGER, StoreName + " 报警,报警类型:" + alarmType);
if (alarmType != StoreAlarmType.IoSingleTimeOut)
{
StopMove();
}
this.alarmType = alarmType;
if (alarmType == StoreAlarmType.AxisAlarm)
{
......@@ -713,8 +739,7 @@ namespace OnlineStore.DeviceLibrary
{
isInSuddenDown = true;
LogUtil.error(LOGGER, StoreName + "收到急停信号,关闭所有轴卡,关闭所有IO,停止所有运动");
CloseAllAxis();
CloseAllAxis();
StoreMove.EndMove();
storeStatus = StoreStatus.SuddenStop;
}
......@@ -727,6 +752,10 @@ namespace OnlineStore.DeviceLibrary
StoreMove.EndMove();
storeStatus = StoreStatus.SuddenStop;
}
if (alarmType != StoreAlarmType.IoSingleTimeOut)
{
StopMove();
}
}
private bool InProcess = false;
protected override void timersTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
......@@ -854,14 +883,15 @@ namespace OnlineStore.DeviceLibrary
//急停按钮
if (suddenBtn.Equals(IO_VALUE.LOW))
{
if (isInSuddenDown.Equals(false))
{
isInSuddenDown = true;
LogUtil.error(LOGGER, StoreName + "收到急停信号,报警急停");
WarnMsg = StoreName + "收到急停信号,报警急停";
//报警时会关闭所有轴
Alarm(StoreAlarmType.SuddenStop, "1", WarnMsg, StoreMoveType.None);
}
//if (isInSuddenDown.Equals(false))
//{
// isInSuddenDown = true;
// LogUtil.error(LOGGER, StoreName + "收到急停信号,报警急停");
// WarnMsg = StoreName + "收到急停信号,报警急停";
// //报警时会关闭所有轴
// Alarm(StoreAlarmType.SuddenStop, "1", WarnMsg, StoreMoveType.None);
//}
}
else if (resetBtn.Equals(IO_VALUE.HIGH))
{
......@@ -1167,7 +1197,7 @@ namespace OnlineStore.DeviceLibrary
}
else
{
if (Config.IsHasLocationCylinder)
if (Config.IsHasLocationCylinder>=1)
{
//定位气缸停止
KNDIOMove(IO_Type.LocationCylinder_Down, IO_VALUE.LOW);
......@@ -1176,7 +1206,8 @@ namespace OnlineStore.DeviceLibrary
}
LogUtil.info(LOGGER, StoreName + "StopMove");
KNDIOMove(IO_Type.Door_Down, IO_VALUE.LOW);
KNDIOMove(IO_Type.Door_Up, IO_VALUE.LOW);
KNDIOMove(IO_Type.Door_Up, IO_VALUE.LOW);
isInPro = false;
}
......
......@@ -620,6 +620,8 @@ namespace OnlineStore.DeviceLibrary
ACAxisMove(Config.Middle_Axis, moveP.Middle_P1, Config.MiddleAxis_P1_Speed);
//此处需要等待box门口没有盘
StoreMove.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.TrayCheck_Door, IO_VALUE.LOW));
//打开舱门
OpenDoorAndWait();
//StoreMove.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.TrayCheck_2, IO_VALUE.LOW));
}
......@@ -689,7 +691,7 @@ namespace OnlineStore.DeviceLibrary
private void LocationUpAndWait()
{
if (Config.IsHasLocationCylinder)
if (Config.IsHasLocationCylinder>=1)
{
KNDIOMove(IO_Type.LocationCylinder_Up, IO_VALUE.HIGH);
KNDIOMove(IO_Type.LocationCylinder_Down, IO_VALUE.LOW);
......@@ -699,7 +701,7 @@ namespace OnlineStore.DeviceLibrary
}
private void LocationDownAndWait()
{
if (Config.IsHasLocationCylinder)
if (Config.IsHasLocationCylinder>=1)
{
KNDIOMove(IO_Type.LocationCylinder_Down, IO_VALUE.HIGH);
KNDIOMove(IO_Type.LocationCylinder_Up, IO_VALUE.LOW);
......
......@@ -143,8 +143,6 @@ namespace OnlineStore.DeviceLibrary
return;
}
isInPro = true;
switch (StoreMove.MoveType)
{
case StoreMoveType.InStore:
......
......@@ -51,7 +51,7 @@ namespace OnlineStore.LoadCSVLibrary
/// PRO 是否使用定位气缸 IsHasLocationCylinder 0
/// </summary>
[ConfigProAttribute("IsHasLocationCylinder")]
public bool IsHasLocationCylinder { get; set; }
public int IsHasLocationCylinder { get; set; }
/// <summary>
/// PRO 扫码枪IP Scanner_Ip 192.168.200.13
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!