Commit 8fb3faf1 几米阳光

serialBean改为Monitor加锁

1 个父辈 3de4897c
...@@ -226,53 +226,53 @@ namespace OnlineStore.Common ...@@ -226,53 +226,53 @@ namespace OnlineStore.Common
#endregion #endregion
#region 发送数据string类型 #region 发送数据string类型
public void SendData(string data) //public void SendData(string data)
{ //发送数据 //{ //发送数据
if (_serialPort.IsOpen) // if (_serialPort.IsOpen)
{ // {
lock (lockObj) // lock (lockObj)
{ // {
_serialPort.Write(data); // _serialPort.Write(data);
System.Threading.Thread.Sleep(10); // System.Threading.Thread.Sleep(10);
} // }
} // }
} //}
#endregion #endregion
#region 发送数据byte类型 #region 发送数据byte类型
/// <summary> ///// <summary>
/// 数据发送 ///// 数据发送
/// </summary> ///// </summary>
/// <param name="data">要发送的数据字节</param> ///// <param name="data">要发送的数据字节</param>
public void SendData(byte[] data, int offset, int count) //public void SendData(byte[] data, int offset, int count)
{ //{
string strSend = ""; // string strSend = "";
for (int i = 0; i < data.Length; i++) // for (int i = 0; i < data.Length; i++)
{ // {
strSend += string.Format("{0:X2} ", data[i]); // strSend += string.Format("{0:X2} ", data[i]);
} // }
LOGGER.Debug("【" + _serialPort.PortName + "】发送数据【" + strSend + "】"); // LOGGER.Debug("【" + _serialPort.PortName + "】发送数据【" + strSend + "】");
lock (lockObj) // lock (lockObj)
{ // {
try // try
{ // {
if (_serialPort.IsOpen) // if (_serialPort.IsOpen)
{ // {
_serialPort.DiscardInBuffer();//清空接收缓冲区 // _serialPort.DiscardInBuffer();//清空接收缓冲区
_serialPort.Write(data, offset, count); // _serialPort.Write(data, offset, count);
System.Threading.Thread.Sleep(10); // System.Threading.Thread.Sleep(10);
} // }
} // }
catch (Exception ex) // catch (Exception ex)
{ // {
_serialPort.DiscardOutBuffer(); // _serialPort.DiscardOutBuffer();
LogUtil.error(LOGGER, "SendData ERROR:" + ex.ToString(), 21); // LogUtil.error(LOGGER, "SendData ERROR:" + ex.ToString(), 21);
} // }
} // }
} //}
#endregion #endregion
#region 发送命令 #region 发送命令
/// <summary> /// <summary>
...@@ -287,8 +287,10 @@ namespace OnlineStore.Common ...@@ -287,8 +287,10 @@ namespace OnlineStore.Common
isOk = false; isOk = false;
if (_serialPort.IsOpen) if (_serialPort.IsOpen)
{ {
lock (lockObj) //lock (lockObj)
if(Monitor.TryEnter(lockObj,10))
{ {
//Monitor.Enter(lockObj);
try try
{ {
_serialPort.DiscardInBuffer(); //清空接收缓冲区 _serialPort.DiscardInBuffer(); //清空接收缓冲区
...@@ -323,8 +325,16 @@ namespace OnlineStore.Common ...@@ -323,8 +325,16 @@ namespace OnlineStore.Common
isOk = false; isOk = false;
LogUtil.error(LOGGER, "SendCommand ERROR:" + ex.ToString(), 20); LogUtil.error(LOGGER, "SendCommand ERROR:" + ex.ToString(), 20);
} }
finally
{
Monitor.Exit(lockObj);
}
} }
else
{
LogUtil.error(PortName + " 发送数据" + ByteToString(SendData) + "失败,未得到锁");
}
} }
return -1; return -1;
} }
...@@ -348,8 +358,9 @@ namespace OnlineStore.Common ...@@ -348,8 +358,9 @@ namespace OnlineStore.Common
if (_serialPort.IsOpen) if (_serialPort.IsOpen)
{ {
lock (lockObj) if (Monitor.TryEnter(lockObj, 10))
{ {
//Monitor.Enter(lockObj);
try try
{ {
_serialPort.DiscardInBuffer(); //清空接收缓冲区 _serialPort.DiscardInBuffer(); //清空接收缓冲区
...@@ -384,11 +395,18 @@ namespace OnlineStore.Common ...@@ -384,11 +395,18 @@ namespace OnlineStore.Common
} }
catch (Exception ex) catch (Exception ex)
{ {
LogUtil.error(PortName + " 发送数据" + ByteToString(SendData) + " 出错:"+ex.ToString());
//throw ex;
} }
finally
{
Monitor.Exit(lockObj);
}
}
else
{
LogUtil.error(PortName + " 发送数据" + ByteToString(SendData) + "失败,未得到锁");
} }
} }
return -1; return -1;
} }
......
...@@ -238,15 +238,15 @@ namespace OnlineStore.DeviceLibrary ...@@ -238,15 +238,15 @@ namespace OnlineStore.DeviceLibrary
public void SetShuokeSpeed() public void SetShuokeSpeed()
{ {
ShuoKeControls.SetSpeed(Config.CompressAxis_Slv, ShuoKeCMD.SetAddSpeed, Config.CompressAxis_AddSpeed); ShuoKeControls.SetSpeed(Config.CompressAxis_Slv, ShuoKeCMD.SetAddSpeed, Config.CompressAxis_AddSpeed);
Thread.Sleep(100); Thread.Sleep(60);
ShuoKeControls.SetSpeed(Config.CompressAxis_Slv, ShuoKeCMD.SetDelSpeed, Config.CompressAxis_DelSpeed); ShuoKeControls.SetSpeed(Config.CompressAxis_Slv, ShuoKeCMD.SetDelSpeed, Config.CompressAxis_DelSpeed);
Thread.Sleep(100); Thread.Sleep(60);
ShuoKeControls.SetSpeed(Config.CompressAxis_Slv, ShuoKeCMD.SetEndSpeed, Config.CompressAxis_EndSpeed); ShuoKeControls.SetSpeed(Config.CompressAxis_Slv, ShuoKeCMD.SetEndSpeed, Config.CompressAxis_EndSpeed);
Thread.Sleep(100); Thread.Sleep(60);
ShuoKeControls.SetSpeed(Config.CompressAxis_Slv, ShuoKeCMD.SetHomeSpeed, Config.CompressAxis_HomeSpeed); ShuoKeControls.SetSpeed(Config.CompressAxis_Slv, ShuoKeCMD.SetHomeSpeed, Config.CompressAxis_HomeSpeed);
Thread.Sleep(100); Thread.Sleep(60);
ShuoKeControls.SetSpeed(Config.CompressAxis_Slv, ShuoKeCMD.SetMaxSpeed, Config.CompressAxis_MaxSpeed); ShuoKeControls.SetSpeed(Config.CompressAxis_Slv, ShuoKeCMD.SetMaxSpeed, Config.CompressAxis_MaxSpeed);
Thread.Sleep(100); Thread.Sleep(60);
ShuoKeControls.SetSpeed(Config.CompressAxis_Slv, ShuoKeCMD.SetStartSpeed, Config.CompressAxis_StartSpeed); ShuoKeControls.SetSpeed(Config.CompressAxis_Slv, ShuoKeCMD.SetStartSpeed, Config.CompressAxis_StartSpeed);
} }
public void MoveToP1() public void MoveToP1()
...@@ -389,8 +389,8 @@ namespace OnlineStore.DeviceLibrary ...@@ -389,8 +389,8 @@ namespace OnlineStore.DeviceLibrary
StoreMove.NextMoveStep(StoreMoveStep.BOX_H_OtherAxisBack); StoreMove.NextMoveStep(StoreMoveStep.BOX_H_OtherAxisBack);
if (IsHasCompress_Axis) if (IsHasCompress_Axis)
{ {
ShuoKeControls.HomeMove(Config.CompressAxis_Slv, 1);
StoreMove.WaitList.Add(WaitResultInfo.WaitShuoKe(Config.CompressAxis_Slv, 0, true)); StoreMove.WaitList.Add(WaitResultInfo.WaitShuoKe(Config.CompressAxis_Slv, 0, true));
ShuoKeControls.HomeMove(Config.CompressAxis_Slv, 1);
} }
ACAxisHomeMove(Config.Middle_Axis); ACAxisHomeMove(Config.Middle_Axis);
ACAxisHomeMove(Config.UpDown_Axis); ACAxisHomeMove(Config.UpDown_Axis);
...@@ -419,8 +419,8 @@ namespace OnlineStore.DeviceLibrary ...@@ -419,8 +419,8 @@ namespace OnlineStore.DeviceLibrary
LogUtil.info(LOGGER, StoreName + "到待机状态,压紧轴回原点,关闭舱门"); LogUtil.info(LOGGER, StoreName + "到待机状态,压紧轴回原点,关闭舱门");
if (IsHasCompress_Axis) if (IsHasCompress_Axis)
{ {
ShuoKeControls.HomeMove(Config.CompressAxis_Slv, 1);
StoreMove.WaitList.Add(WaitResultInfo.WaitShuoKe(Config.CompressAxis_Slv, 1, true)); StoreMove.WaitList.Add(WaitResultInfo.WaitShuoKe(Config.CompressAxis_Slv, 1, true));
ShuoKeControls.HomeMove(Config.CompressAxis_Slv, 1);
} }
//关闭舱门 //关闭舱门
CloseDoorAndWait(); CloseDoorAndWait();
...@@ -452,8 +452,8 @@ namespace OnlineStore.DeviceLibrary ...@@ -452,8 +452,8 @@ namespace OnlineStore.DeviceLibrary
if (IsHasCompress_Axis) if (IsHasCompress_Axis)
{ {
LogUtil.debug("压紧轴绝对运动目标位置:"+targetPosition); LogUtil.debug("压紧轴绝对运动目标位置:"+targetPosition);
ShuoKeControls.AbsMove(Config.CompressAxis_Slv, targetPosition);
StoreMove.WaitList.Add(WaitResultInfo.WaitShuoKe(Config.CompressAxis_Slv, targetPosition, false)); StoreMove.WaitList.Add(WaitResultInfo.WaitShuoKe(Config.CompressAxis_Slv, targetPosition, false));
ShuoKeControls.AbsMove(Config.CompressAxis_Slv, targetPosition);
Thread.Sleep(100); Thread.Sleep(100);
} }
...@@ -519,8 +519,8 @@ namespace OnlineStore.DeviceLibrary ...@@ -519,8 +519,8 @@ namespace OnlineStore.DeviceLibrary
StoreMove.NextMoveStep(StoreMoveStep.BOX_H_OtherAxisBack); StoreMove.NextMoveStep(StoreMoveStep.BOX_H_OtherAxisBack);
if (IsHasCompress_Axis) if (IsHasCompress_Axis)
{ {
ShuoKeControls.HomeMove(Config.CompressAxis_Slv, 1);
StoreMove.WaitList.Add(WaitResultInfo.WaitShuoKe(Config.CompressAxis_Slv, 0, true)); StoreMove.WaitList.Add(WaitResultInfo.WaitShuoKe(Config.CompressAxis_Slv, 0, true));
ShuoKeControls.HomeMove(Config.CompressAxis_Slv, 1);
} }
ACAxisHomeMove(Config.Middle_Axis); ACAxisHomeMove(Config.Middle_Axis);
ACAxisHomeMove(Config.UpDown_Axis); ACAxisHomeMove(Config.UpDown_Axis);
...@@ -665,11 +665,10 @@ namespace OnlineStore.DeviceLibrary ...@@ -665,11 +665,10 @@ namespace OnlineStore.DeviceLibrary
autoNext = false; autoNext = false;
IoCheckTimer.Enabled = false; IoCheckTimer.Enabled = false;
serverConnectTimer.Enabled = false; serverConnectTimer.Enabled = false;
StopMove(); StopMove(true);
storeRunStatus = StoreRunStatus.Wait; storeRunStatus = StoreRunStatus.Wait;
mainTimer.Enabled = false; mainTimer.Enabled = false;
CloseAllAxis();
TimeSpan span = DateTime.Now - StartTime; TimeSpan span = DateTime.Now - StartTime;
IsRun = false; IsRun = false;
...@@ -700,17 +699,15 @@ namespace OnlineStore.DeviceLibrary ...@@ -700,17 +699,15 @@ namespace OnlineStore.DeviceLibrary
{ {
LogUtil.error(LOGGER, StoreName + "轴报警,关闭刹车,停止运动,关闭轴,打开报警灯"); LogUtil.error(LOGGER, StoreName + "轴报警,关闭刹车,停止运动,关闭轴,打开报警灯");
KNDIOMove(IO_Type.Axis_Brake, IO_VALUE.LOW); KNDIOMove(IO_Type.Axis_Brake, IO_VALUE.LOW);
StopMove(); StopMove(true );
CloseAllAxis();
} }
else if (alarmType == StoreAlarmType.SuddenStop) else if (alarmType == StoreAlarmType.SuddenStop)
{ {
isInSuddenDown = true; isInSuddenDown = true;
LogUtil.error(LOGGER, StoreName + "收到急停信号,关闭刹车,停止运动,关闭轴,打开报警灯 "); LogUtil.error(LOGGER, StoreName + "收到急停信号,关闭刹车,停止运动,关闭轴,打开报警灯 ");
KNDIOMove(IO_Type.Axis_Brake, IO_VALUE.LOW); KNDIOMove(IO_Type.Axis_Brake, IO_VALUE.LOW);
StopMove();
CloseAllAxis();
StoreMove.EndMove(); StoreMove.EndMove();
StopMove(true);
storeStatus = StoreStatus.SuddenStop; storeStatus = StoreStatus.SuddenStop;
} }
else if (alarmType.Equals(StoreAlarmType.NoAirCheck)) else if (alarmType.Equals(StoreAlarmType.NoAirCheck))
...@@ -718,9 +715,8 @@ namespace OnlineStore.DeviceLibrary ...@@ -718,9 +715,8 @@ namespace OnlineStore.DeviceLibrary
isNoAirCheck = true; isNoAirCheck = true;
LogUtil.error(LOGGER, StoreName + " 未检测到气压信号 ,打开刹车,停止运动,关闭轴,打开报警灯 "); LogUtil.error(LOGGER, StoreName + " 未检测到气压信号 ,打开刹车,停止运动,关闭轴,打开报警灯 ");
KNDIOMove(IO_Type.Axis_Brake, IO_VALUE.LOW); KNDIOMove(IO_Type.Axis_Brake, IO_VALUE.LOW);
StopMove(); StoreMove.EndMove();
CloseAllAxis(); StopMove(true );
StoreMove.EndMove();
storeStatus = StoreStatus.SuddenStop; storeStatus = StoreStatus.SuddenStop;
} }
//if (alarmType != StoreAlarmType.IoSingleTimeOut) //if (alarmType != StoreAlarmType.IoSingleTimeOut)
...@@ -730,18 +726,20 @@ namespace OnlineStore.DeviceLibrary ...@@ -730,18 +726,20 @@ namespace OnlineStore.DeviceLibrary
} }
private bool InProcess = false; private bool InProcess = false;
private DateTime preProcessTime = DateTime.Now; private DateTime preProcessTime = DateTime.Now;
private bool IsChongfu = false;
protected override void timersTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) protected override void timersTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{ {
if (InProcess) if (InProcess)
{ {
TimeSpan span = DateTime.Now - preProcessTime; TimeSpan span = DateTime.Now - preProcessTime;
if (span.TotalMinutes < 1) if (span.TotalMinutes < 1)
{ {
return; return;
} }
else else
{ {
LogUtil.error("主定时器:InProcess已等待"+span.ToString()+"重新处理"); LogUtil.error("主定时器:InProcess已等待" + span.ToString() + "重新处理");
IsChongfu = true;
} }
} }
try try
...@@ -749,15 +747,31 @@ namespace OnlineStore.DeviceLibrary ...@@ -749,15 +747,31 @@ namespace OnlineStore.DeviceLibrary
InProcess = true; InProcess = true;
preProcessTime = DateTime.Now; preProcessTime = DateTime.Now;
IoCheckProcess(); IoCheckProcess();
TimerProcess(); ShowTimeLog("IoCheckProcess");
TimerProcess();
ShowTimeLog("TimerProcess");
//检查运动轴报警
if (storeRunStatus > StoreRunStatus.Wait && (!isInSuddenDown)&&(!isNoAirCheck))
{
ShowTimeLog("开始检测轴报警");
CheckAxisAlarm();
ShowTimeLog("轴报警检测完成");
}
} }
catch (Exception ex) catch (Exception ex)
{ {
LOGGER.Error(StoreName + "定时处理出错:" + ex.ToString()); LOGGER.Error(StoreName + "定时处理出错:" + ex.ToString());
} }
IsChongfu = false;
InProcess = false; InProcess = false;
} }
private void ShowTimeLog(string info)
{
if (IsChongfu)
{
LogUtil.info("【" + info + "】 处理完成,耗时:" + (DateTime.Now - preProcessTime).ToString());
}
}
private void LedProcess() private void LedProcess()
{ {
try try
...@@ -898,12 +912,15 @@ namespace OnlineStore.DeviceLibrary ...@@ -898,12 +912,15 @@ namespace OnlineStore.DeviceLibrary
} }
} }
} }
//检查运动轴报警 //ShowTimeLog("复位和启动按钮");
if (storeRunStatus > StoreRunStatus.Wait && (!isInSuddenDown) ) ////检查运动轴报警
{ //if (storeRunStatus > StoreRunStatus.Wait && (!isInSuddenDown) )
CheckAxisAlarm(); //{
} // ShowTimeLog("开始检测轴报警");
// CheckAxisAlarm();
// ShowTimeLog("轴报警检测完成");
//}
} }
private int NeedCheckSafetyLight = 0; private int NeedCheckSafetyLight = 0;
...@@ -942,8 +959,8 @@ namespace OnlineStore.DeviceLibrary ...@@ -942,8 +959,8 @@ namespace OnlineStore.DeviceLibrary
DateTime time = DateTime.Now; DateTime time = DateTime.Now;
if (StoreMove.MoveType != StoreMoveType.None) if (StoreMove.MoveType != StoreMoveType.None)
{ {
BusyMoveProcess(); BusyMoveProcess();
ShowTimeLog("BusyMoveProcess");
} }
else if (storeRunStatus.Equals(StoreRunStatus.Runing)) else if (storeRunStatus.Equals(StoreRunStatus.Runing))
{ {
...@@ -993,8 +1010,12 @@ namespace OnlineStore.DeviceLibrary ...@@ -993,8 +1010,12 @@ namespace OnlineStore.DeviceLibrary
isWaitScan = false; isWaitScan = false;
} }
} }
ShowTimeLog("判断是否需要出入库");
AutoResetProcess(); AutoResetProcess();
ShowTimeLog("AutoResetProcess");
IOTimeOutProcess(); IOTimeOutProcess();
ShowTimeLog("IOTimeOutProcess");
} }
} }
...@@ -1128,7 +1149,6 @@ namespace OnlineStore.DeviceLibrary ...@@ -1128,7 +1149,6 @@ namespace OnlineStore.DeviceLibrary
} }
else else
{ {
if (span.TotalSeconds < 3) if (span.TotalSeconds < 3)
{ {
return false; return false;
...@@ -1136,13 +1156,14 @@ namespace OnlineStore.DeviceLibrary ...@@ -1136,13 +1156,14 @@ namespace OnlineStore.DeviceLibrary
} }
checkAlarmTime = DateTime.Now; checkAlarmTime = DateTime.Now;
bool isInAlarm = false; bool isInAlarm = false;
//Task.Factory.StartNew(delegate
// {
foreach (ConfigMoveAxis axisInfo in moveAxisList) foreach (ConfigMoveAxis axisInfo in moveAxisList)
{ {
short axis = axisInfo.GetAxisValue(); short axis = axisInfo.GetAxisValue();
string deviceName = axisInfo.DeviceName; string deviceName = axisInfo.DeviceName;
AxisAlarmInfo info = AxisAlarmCodeMap[deviceName]; AxisAlarmInfo info = AxisAlarmCodeMap[deviceName];
int alarmIo = ACServerManager.GetAlarmStatus(deviceName, axis); int alarmIo = ACServerManager.GetAlarmStatus(deviceName, axis);
if (alarmIo == 1) if (alarmIo == 1)
...@@ -1162,15 +1183,16 @@ namespace OnlineStore.DeviceLibrary ...@@ -1162,15 +1183,16 @@ namespace OnlineStore.DeviceLibrary
} }
AxisAlarmCodeMap[deviceName] = info; AxisAlarmCodeMap[deviceName] = info;
} }
//});
//判断报警状态 //判断报警状态
return isInAlarm; return isInAlarm;
} }
/// <summary> /// <summary>
/// 停止所有运行 /// 停止所有运行
/// </summary> /// </summary>
public override void StopMove() public override void StopMove(bool IsCloseAxis)
{ {
HDevelopExport.CloseAllCamera();
//运动版停止 //运动版停止
ACServerManager.SuddenStop(Config.Middle_Axis.DeviceName, Config.Middle_Axis.GetAxisValue()); ACServerManager.SuddenStop(Config.Middle_Axis.DeviceName, Config.Middle_Axis.GetAxisValue());
ACServerManager.SuddenStop(Config.UpDown_Axis.DeviceName, Config.UpDown_Axis.GetAxisValue()); ACServerManager.SuddenStop(Config.UpDown_Axis.DeviceName, Config.UpDown_Axis.GetAxisValue());
...@@ -1188,9 +1210,14 @@ namespace OnlineStore.DeviceLibrary ...@@ -1188,9 +1210,14 @@ namespace OnlineStore.DeviceLibrary
KNDIOMove(IO_Type.LocationCylinder_Up, IO_VALUE.LOW); KNDIOMove(IO_Type.LocationCylinder_Up, IO_VALUE.LOW);
} }
} }
if (IsCloseAxis)
{
CloseAllAxis();
}
LogUtil.info(LOGGER, StoreName + "StopMove"); LogUtil.info(LOGGER, StoreName + "StopMove");
KNDIOMove(IO_Type.Door_Down, IO_VALUE.LOW); KNDIOMove(IO_Type.Door_Down, IO_VALUE.LOW);
KNDIOMove(IO_Type.Door_Up, IO_VALUE.LOW); KNDIOMove(IO_Type.Door_Up, IO_VALUE.LOW);
HDevelopExport.CloseAllCamera();
isInPro = false; isInPro = false;
} }
...@@ -1572,9 +1599,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -1572,9 +1599,7 @@ namespace OnlineStore.DeviceLibrary
LOGGER.Error(StoreName + "HumidityProcess出错:" + ex.ToString()); LOGGER.Error(StoreName + "HumidityProcess出错:" + ex.ToString());
} }
} }
#endregion #endregion
#region 与服务器通信定时器,每1秒向服务器通知一次状态,同时执行出库操作 #region 与服务器通信定时器,每1秒向服务器通知一次状态,同时执行出库操作
private bool isInProcess = false; private bool isInProcess = false;
public void server_connect_timer_Tick(object sender, EventArgs e) public void server_connect_timer_Tick(object sender, EventArgs e)
...@@ -1584,9 +1609,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -1584,9 +1609,7 @@ namespace OnlineStore.DeviceLibrary
return; return;
} }
//HumitureServer.RandomData(Config.GetTempAddrList()); //HumitureServer.RandomData(Config.GetTempAddrList());
HumitureController.QueryData();
HumidityProcess();
LedProcess();
isInProcess = true; isInProcess = true;
if (ACStoreManager.IsConnectServer) if (ACStoreManager.IsConnectServer)
{ {
...@@ -1599,6 +1622,9 @@ namespace OnlineStore.DeviceLibrary ...@@ -1599,6 +1622,9 @@ namespace OnlineStore.DeviceLibrary
LOGGER.Error("定时给服务器发送消息出错:", ex); LOGGER.Error("定时给服务器发送消息出错:", ex);
} }
} }
HumitureController.QueryData();
HumidityProcess();
LedProcess();
isInProcess = false; isInProcess = false;
} }
......
...@@ -29,8 +29,8 @@ namespace OnlineStore.DeviceLibrary ...@@ -29,8 +29,8 @@ namespace OnlineStore.DeviceLibrary
/// <summary> /// <summary>
/// 伺服运行时间列表,key=轴,key=开始时间,value=结束时间 /// 伺服运行时间列表,key=轴,key=开始时间,value=结束时间
/// </summary> /// </summary>
public Dictionary<int, Dictionary<DateTime, DateTime>> AxisRunTimeMap = new Dictionary<int, Dictionary<DateTime, DateTime>>(); //public Dictionary<int, Dictionary<DateTime, DateTime>> AxisRunTimeMap = new Dictionary<int, Dictionary<DateTime, DateTime>>();
public Dictionary<int, DateTime> AxisLastStartTime = new Dictionary<int, DateTime>(); //public Dictionary<int, DateTime> AxisLastStartTime = new Dictionary<int, DateTime>();
/// <summary> /// <summary>
/// 最后一次气压检测变为0的时间 /// 最后一次气压检测变为0的时间
...@@ -93,42 +93,42 @@ namespace OnlineStore.DeviceLibrary ...@@ -93,42 +93,42 @@ namespace OnlineStore.DeviceLibrary
return new TimeSpan(0); return new TimeSpan(0);
} }
} }
/// <summary> ///// <summary>
/// 获取轴已运行时间 ///// 获取轴已运行时间
/// </summary> ///// </summary>
/// <returns></returns> ///// <returns></returns>
public TimeSpan GetAxisRunTime(int axisNo) //public TimeSpan GetAxisRunTime(int axisNo)
{ //{
TimeSpan span = new TimeSpan(0); // TimeSpan span = new TimeSpan(0);
try // try
{ // {
if (AxisRunTimeMap.ContainsKey(axisNo)) // if (AxisRunTimeMap.ContainsKey(axisNo))
{ // {
Dictionary<DateTime, DateTime> moveMap = AxisRunTimeMap[axisNo]; // Dictionary<DateTime, DateTime> moveMap = AxisRunTimeMap[axisNo];
if (moveMap != null && moveMap.Count > 0) // if (moveMap != null && moveMap.Count > 0)
{ // {
foreach (DateTime key in moveMap.Keys) // foreach (DateTime key in moveMap.Keys)
{ // {
span += moveMap[key] - key; // span += moveMap[key] - key;
} // }
} // }
} // }
} // }
catch (Exception ex) // catch (Exception ex)
{ // {
LogUtil.error(LOGGER, ex.ToString()); // LogUtil.error(LOGGER, ex.ToString());
} // }
return span; // return span;
} //}
protected void AddAxisMoveTime(ConfigMoveAxis axis) protected void AddAxisMoveTime(ConfigMoveAxis axis)
{ {
int axisNo = axis.GetAxisValue(); //int axisNo = axis.GetAxisValue();
if (AxisLastStartTime.ContainsKey(axisNo)) //if (AxisLastStartTime.ContainsKey(axisNo))
{ //{
AxisLastStartTime.Remove(axisNo); // AxisLastStartTime.Remove(axisNo);
} //}
AxisLastStartTime.Add(axisNo, DateTime.Now); //AxisLastStartTime.Add(axisNo, DateTime.Now);
} }
...@@ -233,7 +233,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -233,7 +233,7 @@ namespace OnlineStore.DeviceLibrary
/// <summary> /// <summary>
/// 停止所有运动 /// 停止所有运动
/// </summary> /// </summary>
public abstract void StopMove(); public abstract void StopMove( bool IsCloseAxis);
/// <summary> /// <summary>
/// 重置处理 /// 重置处理
...@@ -248,12 +248,12 @@ namespace OnlineStore.DeviceLibrary ...@@ -248,12 +248,12 @@ namespace OnlineStore.DeviceLibrary
/// 松下伺服轴原点返回运动,等待收到反馈后才会返回 /// 松下伺服轴原点返回运动,等待收到反馈后才会返回
/// </summary> /// </summary>
protected void ACAxisHomeMove(ConfigMoveAxis moveAxis) protected void ACAxisHomeMove(ConfigMoveAxis moveAxis)
{ {
moveAxis.TargetPosition = 0; moveAxis.TargetPosition = 0;
LogUtil.debug(LOGGER, moveAxis.DisplayStr + "speed[" + moveAxis.TargetSpeed + "]开始原点返回"); LogUtil.debug(LOGGER, moveAxis.DisplayStr + "speed[" + moveAxis.TargetSpeed + "]开始原点返回");
StoreMove.WaitList.Add(WaitResultInfo.WaitAxis(moveAxis, true));
AddAxisMoveTime(moveAxis); AddAxisMoveTime(moveAxis);
ACServerManager.HomeMove(moveAxis.DeviceName, (short)moveAxis.GetAxisValue(), moveAxis.HomeHighSpeed); ACServerManager.HomeMove(moveAxis.DeviceName, (short)moveAxis.GetAxisValue(), moveAxis.HomeHighSpeed);
StoreMove.WaitList.Add(WaitResultInfo.WaitAxis(moveAxis, true));
} }
/// <summary> /// <summary>
...@@ -261,10 +261,10 @@ namespace OnlineStore.DeviceLibrary ...@@ -261,10 +261,10 @@ namespace OnlineStore.DeviceLibrary
/// </summary> /// </summary>
protected void ACAxisMove(ConfigMoveAxis moveAxis, int targetPosition, int targetSpeed) protected void ACAxisMove(ConfigMoveAxis moveAxis, int targetPosition, int targetSpeed)
{ {
StoreMove.WaitList.Add(WaitResultInfo.WaitAxis(moveAxis, targetPosition, targetSpeed));
moveAxis.TargetPosition = targetPosition; moveAxis.TargetPosition = targetPosition;
AddAxisMoveTime(moveAxis); AddAxisMoveTime(moveAxis);
ACServerManager.AbsMove(moveAxis.DeviceName, moveAxis.GetAxisValue(), targetPosition,targetSpeed); ACServerManager.AbsMove(moveAxis.DeviceName, moveAxis.GetAxisValue(), targetPosition,targetSpeed);
StoreMove.WaitList.Add(WaitResultInfo.WaitAxis(moveAxis, targetPosition, targetSpeed));
} }
/// <summary> /// <summary>
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!