Commit 5bab452a 张东亮

1

2 个父辈 d2bbb096 9a16b822
......@@ -3,10 +3,7 @@ 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 DeviceLibrary
{
......@@ -22,7 +19,7 @@ namespace DeviceLibrary
/// <summary>
/// 干涉检测回调 from, to
/// </summary>
public event Func<int,int,(bool,string)> interference;
public event Func<int, int, (bool, string)> interference;
public string AxisName;
public AxisBean(ConfigMoveAxis axisConfig, string deviceName)
{
......@@ -126,7 +123,7 @@ namespace DeviceLibrary
else
{
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);
return false;
}
......@@ -192,7 +189,7 @@ namespace DeviceLibrary
int isAlarm = AxisManager.GetAlarmStatus(deviceName, axisNo);
if (isAlarm.Equals(1))
{
clearMsg = crc.GetString("Res0119.cbd5d752","清理报警,");
clearMsg = crc.GetString("Res0119.cbd5d752", "清理报警,");
AxisManager.AlarmClear(deviceName, axisNo);
Thread.Sleep(200);
AxisManager.ServoOn(deviceName, axisNo);
......@@ -204,7 +201,7 @@ namespace DeviceLibrary
AxisManager.SuddenStop(axis.DeviceName, axis.GetAxisValue());
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);
MoveInfo.CanWhileCount--;
Thread.Sleep(200);
......@@ -239,7 +236,7 @@ namespace DeviceLibrary
}
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);
}
}
......@@ -292,62 +289,76 @@ namespace DeviceLibrary
/// 判断轴运动是否安全
/// </summary>
/// <returns></returns>
public bool IsSafe(int Targetpos,out string msg){
public bool IsSafe(int Targetpos, out string msg)
{
msg = "";
if (interference == null)
return true;
bool result;
(result,msg) = interference.Invoke(GetAclPosition(), Targetpos);
(result, msg) = interference.Invoke(GetAclPosition(), Targetpos);
return !result;
}
#region 匀速上升处理
private System.Timers.Timer axisCheckTimer = null;
internal string TargetIoType = "";
//private System.Timers.Timer axisCheckTimer = null;
internal string TargetIoType;
internal IO_VALUE TargetIoValue = 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;
TargetIoType = targetIo;
axisCheckTimer.Start();
IsInProcess = true;
new Thread(() =>
{
CheckTimer_Elapsed();
})
{ IsBackground = true } // 按需设成后台线程
.Start();
return true;
}
public bool StopAxisCheckMove()
{
if (!(axisCheckTimer == null))
{
axisCheckTimer.Stop();
}
IsInProcess = false;
return true;
}
private void CheckTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
private bool IsInProcess = false;
private void CheckTimer_Elapsed()
{
while (IsInProcess)
{
Thread.Sleep(1);
try
{
if (TargetIoValue == IO_VALUE.HIGH)
{
if (IOManager.IOValue(TargetIoType).Equals(TargetIoValue))
{
SuddenStop();
StopAxisCheckMove();
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;
}
}
}
#endregion
......
......@@ -374,7 +374,7 @@ namespace DeviceLibrary
break;
case MoveStep.Lbl14:
LeftMoveInfo.NextMoveStep(MoveStep.L30_LabelFinish);
LabelMoveInfo.log("完成贴标.");
LeftMoveInfo.log("通知贴标完成");
LabelMoveInfo.NextMoveStep(MoveStep.Lbl01);
LabelMoveInfo.log("完成贴标.");
break;
......
......@@ -58,6 +58,8 @@ namespace DeviceLibrary
{
param.RightPulseHeight = PlwHight;
param.RightPlateHeight = PlwHight / Config.Right_Batch_ChangeValue;
if (param.RightPlateHeight <= 0)
param.RightPlateHeight = 8;
RightMoveInfo.log($"批量轴上升到P2位置到位,当前位置:{Uplast},uid={param.UID}, PlwHight:{param.RightPulseHeight},plateH:{param.RightPlateHeight}");
}
else
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!