Commit 6aec9051 刘韬

优化料串测高

1 个父辈 b833e3a7
...@@ -3,10 +3,7 @@ using OnlineStore.Common; ...@@ -3,10 +3,7 @@ using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary; using OnlineStore.LoadCSVLibrary;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading; using System.Threading;
using System.Threading.Tasks;
namespace DeviceLibrary namespace DeviceLibrary
{ {
...@@ -22,7 +19,7 @@ namespace DeviceLibrary ...@@ -22,7 +19,7 @@ namespace DeviceLibrary
/// <summary> /// <summary>
/// 干涉检测回调 from, to /// 干涉检测回调 from, to
/// </summary> /// </summary>
public event Func<int,int,(bool,string)> interference; public event Func<int, int, (bool, string)> interference;
public string AxisName; public string AxisName;
public AxisBean(ConfigMoveAxis axisConfig, string deviceName) public AxisBean(ConfigMoveAxis axisConfig, string deviceName)
{ {
...@@ -126,7 +123,7 @@ namespace DeviceLibrary ...@@ -126,7 +123,7 @@ namespace DeviceLibrary
else else
{ {
AxisManager.ServoOff(portName, slvAddr); AxisManager.ServoOff(portName, slvAddr);
msg = crc.GetString("Res0117.2bf5c941","打开轴") + Config.Explain + crc.GetString("Res0118.33d2a704","失败 "); msg = crc.GetString("Res0117.2bf5c941", "打开轴") + Config.Explain + crc.GetString("Res0118.33d2a704", "失败 ");
LogUtil.info(AxisName + msg); LogUtil.info(AxisName + msg);
return false; return false;
} }
...@@ -192,7 +189,7 @@ namespace DeviceLibrary ...@@ -192,7 +189,7 @@ namespace DeviceLibrary
int isAlarm = AxisManager.GetAlarmStatus(deviceName, axisNo); int isAlarm = AxisManager.GetAlarmStatus(deviceName, axisNo);
if (isAlarm.Equals(1)) if (isAlarm.Equals(1))
{ {
clearMsg = crc.GetString("Res0119.cbd5d752","清理报警,"); clearMsg = crc.GetString("Res0119.cbd5d752", "清理报警,");
AxisManager.AlarmClear(deviceName, axisNo); AxisManager.AlarmClear(deviceName, axisNo);
Thread.Sleep(200); Thread.Sleep(200);
AxisManager.ServoOn(deviceName, axisNo); AxisManager.ServoOn(deviceName, axisNo);
...@@ -204,7 +201,7 @@ namespace DeviceLibrary ...@@ -204,7 +201,7 @@ namespace DeviceLibrary
AxisManager.SuddenStop(axis.DeviceName, axis.GetAxisValue()); AxisManager.SuddenStop(axis.DeviceName, axis.GetAxisValue());
Thread.Sleep(100); Thread.Sleep(100);
} }
LogUtil.error($"{ MoveInfo.Name} {MoveInfo.MoveStep} {axis.DisplayStr}目标位置{targetPosition}当前位置{outCount},误差过大,{clearMsg}重新开始运动,剩余{MoveInfo.CanWhileCount}次"); LogUtil.error($"{MoveInfo.Name} {MoveInfo.MoveStep} {axis.DisplayStr}目标位置{targetPosition}当前位置{outCount},误差过大,{clearMsg}重新开始运动,剩余{MoveInfo.CanWhileCount}次");
AxisManager.AbsMove(axis.DeviceName, axis.GetAxisValue(), targetPosition, targetSpeed, targetSpeed * 4, targetSpeed * 4);// , axis.AddSpeed, axis.DelSpeed); AxisManager.AbsMove(axis.DeviceName, axis.GetAxisValue(), targetPosition, targetSpeed, targetSpeed * 4, targetSpeed * 4);// , axis.AddSpeed, axis.DelSpeed);
MoveInfo.CanWhileCount--; MoveInfo.CanWhileCount--;
Thread.Sleep(200); Thread.Sleep(200);
...@@ -239,7 +236,7 @@ namespace DeviceLibrary ...@@ -239,7 +236,7 @@ namespace DeviceLibrary
} }
else else
{ {
msg = MoveInfo.Name + " " + MoveInfo.MoveStep + axis.DisplayStr + crc.GetString("Res0120.405c5a9e",",收到原点完成信号,当前位置[") + outCount + crc.GetString("Res0121.6658614e","],误差过大,需要报警"); msg = MoveInfo.Name + " " + MoveInfo.MoveStep + axis.DisplayStr + crc.GetString("Res0120.405c5a9e", ",收到原点完成信号,当前位置[") + outCount + crc.GetString("Res0121.6658614e", "],误差过大,需要报警");
LogUtil.error(msg); LogUtil.error(msg);
} }
} }
...@@ -292,62 +289,76 @@ namespace DeviceLibrary ...@@ -292,62 +289,76 @@ namespace DeviceLibrary
/// 判断轴运动是否安全 /// 判断轴运动是否安全
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public bool IsSafe(int Targetpos,out string msg){ public bool IsSafe(int Targetpos, out string msg)
{
msg = ""; msg = "";
if (interference == null) if (interference == null)
return true; return true;
bool result; bool result;
(result,msg) = interference.Invoke(GetAclPosition(), Targetpos); (result, msg) = interference.Invoke(GetAclPosition(), Targetpos);
return !result; return !result;
} }
#region 匀速上升处理 #region 匀速上升处理
private System.Timers.Timer axisCheckTimer = null; //private System.Timers.Timer axisCheckTimer = null;
internal string TargetIoType = ""; internal string TargetIoType;
internal IO_VALUE TargetIoValue = IO_VALUE.HIGH; internal IO_VALUE TargetIoValue = IO_VALUE.HIGH;
public bool BatchAxisStartCheck(string targetIo, IO_VALUE value = IO_VALUE.HIGH) public bool BatchAxisStartCheck(string targetIo, IO_VALUE value = IO_VALUE.HIGH)
{ {
if (String.IsNullOrEmpty(targetIo))
{
targetIo = "";
}
if (axisCheckTimer == null)
{
axisCheckTimer = new System.Timers.Timer();
axisCheckTimer.AutoReset = true;
axisCheckTimer.Interval += 15;
axisCheckTimer.Elapsed += CheckTimer_Elapsed;
axisCheckTimer.Enabled = false;
}
TargetIoValue = value; TargetIoValue = value;
TargetIoType = targetIo; TargetIoType = targetIo;
axisCheckTimer.Start(); IsInProcess = true;
new Thread(() =>
{
CheckTimer_Elapsed();
})
{ IsBackground = true } // 按需设成后台线程
.Start();
return true; return true;
} }
public bool StopAxisCheckMove() public bool StopAxisCheckMove()
{ {
if (!(axisCheckTimer == null)) IsInProcess = false;
{
axisCheckTimer.Stop();
}
return true; return true;
} }
private void CheckTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) private bool IsInProcess = false;
{ private void CheckTimer_Elapsed()
try {
while (IsInProcess)
{ {
if (IOManager.IOValue(TargetIoType).Equals(TargetIoValue)) Thread.Sleep(1);
try
{ {
SuddenStop(); if (TargetIoValue == IO_VALUE.HIGH)
StopAxisCheckMove(); {
LogUtil.info(AxisName + "上料轴,检测到 " + TargetIoType + "=" + TargetIoValue + ",停止运动");
if (IOManager.IOValue(TargetIoType).Equals(TargetIoValue))
{
SuddenStop();
LogUtil.info(AxisName + "上料轴,检测到 " + TargetIoType + "=" + TargetIoValue + ",停止运动");
StopAxisCheckMove();
break;
}
}
else
{
if (IOManager.IOValue(TargetIoType).Equals(TargetIoValue))
{
SuddenStop();
LogUtil.info(AxisName + "上料轴,检测到 =" + TargetIoValue + ",停止运动");
StopAxisCheckMove();
break;
}
}
}
catch (Exception ex)
{
LogUtil.error("CheckTimer_Elapsed出错:", ex);
IsInProcess = false;
} }
}
catch (Exception ex)
{
LogUtil.error("CheckTimer_Elapsed出错:", ex);
} }
} }
#endregion #endregion
...@@ -382,7 +393,7 @@ namespace DeviceLibrary ...@@ -382,7 +393,7 @@ namespace DeviceLibrary
public static void CloseMultiAxis(List<AxisBean> axisArray) public static void CloseMultiAxis(List<AxisBean> axisArray)
{ {
foreach (AxisBean axis in axisArray) foreach (AxisBean axis in axisArray)
{ {
axis.ServoOff(); axis.ServoOff();
Thread.Sleep(10); Thread.Sleep(10);
} }
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!