Commit 5e87868b 张东亮

添加打印回原完成后轴的状态

1 个父辈 ffef7a5f
using OnlineStore.Common; using HuichuanLibrary;
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary; using OnlineStore.LoadCSVLibrary;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
...@@ -21,7 +22,7 @@ namespace DeviceLibrary ...@@ -21,7 +22,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 bool ForceSafeCheck = false; public bool ForceSafeCheck = false;
public AxisBean(ConfigMoveAxis axisConfig, string deviceName) public AxisBean(ConfigMoveAxis axisConfig, string deviceName)
...@@ -112,7 +113,7 @@ namespace DeviceLibrary ...@@ -112,7 +113,7 @@ namespace DeviceLibrary
LogUtil.info("ServoOff【" + AxisName + "】"); LogUtil.info("ServoOff【" + AxisName + "】");
AxisManager.ServoOff(Config.DeviceName, Config.GetAxisValue()); AxisManager.ServoOff(Config.DeviceName, Config.GetAxisValue());
} }
public void HomeMove(MoveInfo MoveInfo,bool force=true) public void HomeMove(MoveInfo MoveInfo, bool force = true)
{ {
if (!force && AxisManager.GetHomeEndStatus(Config.DeviceName, (short)Config.GetAxisValue()) == 3) if (!force && AxisManager.GetHomeEndStatus(Config.DeviceName, (short)Config.GetAxisValue()) == 3)
{ {
...@@ -121,7 +122,7 @@ namespace DeviceLibrary ...@@ -121,7 +122,7 @@ namespace DeviceLibrary
} }
Config.TargetPosition = 0; Config.TargetPosition = 0;
LogUtil.info(AxisName + "speed[" + Config.HomeHighSpeed + "]开始原点返回"); LogUtil.info(AxisName + "speed[" + Config.HomeHighSpeed + "]开始原点返回");
if (MoveInfo!=null) if (MoveInfo != null)
MoveInfo.WaitList.Add(WaitResultInfo.WaitAxis(Config, true)); MoveInfo.WaitList.Add(WaitResultInfo.WaitAxis(Config, true));
var HomeLowSpeed = Config.HomeLowSpeed > 0 ? Config.HomeLowSpeed : Config.HomeHighSpeed / 10; var HomeLowSpeed = Config.HomeLowSpeed > 0 ? Config.HomeLowSpeed : Config.HomeHighSpeed / 10;
var HomeAddSpeed = Config.HomeAddSpeed > 0 ? Config.HomeAddSpeed : Config.HomeHighSpeed * 5; var HomeAddSpeed = Config.HomeAddSpeed > 0 ? Config.HomeAddSpeed : Config.HomeHighSpeed * 5;
...@@ -140,7 +141,7 @@ namespace DeviceLibrary ...@@ -140,7 +141,7 @@ namespace DeviceLibrary
return; return;
} }
if (ForceSafeCheck && !IsSafe(targetPosition,out string msg)) if (ForceSafeCheck && !IsSafe(targetPosition, out string msg))
{ {
Msg.add(msg, MsgLevel.alarm); Msg.add(msg, MsgLevel.alarm);
RobotManage.UserPause(msg); RobotManage.UserPause(msg);
...@@ -208,7 +209,7 @@ namespace DeviceLibrary ...@@ -208,7 +209,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}次");
var AddSpeed = axis.AddSpeed > 0 ? axis.AddSpeed : targetSpeed * 4; var AddSpeed = axis.AddSpeed > 0 ? axis.AddSpeed : targetSpeed * 4;
var DelSpeed = axis.DelSpeed > 0 ? axis.DelSpeed : targetSpeed * 4; var DelSpeed = axis.DelSpeed > 0 ? axis.DelSpeed : targetSpeed * 4;
AxisManager.AbsMove(axis.DeviceName, axis.GetAxisValue(), targetPosition, targetSpeed, AddSpeed, DelSpeed);// , axis.AddSpeed, axis.DelSpeed); AxisManager.AbsMove(axis.DeviceName, axis.GetAxisValue(), targetPosition, targetSpeed, AddSpeed, DelSpeed);// , axis.AddSpeed, axis.DelSpeed);
...@@ -229,7 +230,11 @@ namespace DeviceLibrary ...@@ -229,7 +230,11 @@ namespace DeviceLibrary
if (AxisManager.IsHomeMoveEnd(axis.DeviceName, axis.GetAxisValue()))// || AxisManager.AxisStsINP(axis.DeviceName, axis.GetAxisValue()).Equals(1)) if (AxisManager.IsHomeMoveEnd(axis.DeviceName, axis.GetAxisValue()))// || AxisManager.AxisStsINP(axis.DeviceName, axis.GetAxisValue()).Equals(1))
{ {
//原点完成并且位置=0 //原点完成并且位置=0
//编码器位置
int outCount = AxisManager.GetActualtPosition(axis.DeviceName, axis.GetAxisValue()); int outCount = AxisManager.GetActualtPosition(axis.DeviceName, axis.GetAxisValue());
//规划位置
int outTarget = AxisManager.GetTargetPosition(axis.DeviceName, axis.GetAxisValue());
AxisSts axisS = HCBoardManager.GetAxisSts(axis.GetAxisValue());
int errorCount = Math.Abs(outCount); int errorCount = Math.Abs(outCount);
if (errorCount <= axis.CanErrorCountMax) if (errorCount <= axis.CanErrorCountMax)
{ {
...@@ -238,14 +243,15 @@ namespace DeviceLibrary ...@@ -238,14 +243,15 @@ namespace DeviceLibrary
//判断是否需要重新运动 //判断是否需要重新运动
if (MoveInfo.CanWhileCount > 0) if (MoveInfo.CanWhileCount > 0)
{ {
LogUtil.error(MoveInfo.Name + axis.DisplayStr + "收到原点完成信号,当前位置[" + outCount + "],重新回原点,剩余[" + MoveInfo.CanWhileCount + "]次"); msg = $"{MoveInfo.Name} {axis.DisplayStr} 收到原点完成信号,当前位置{outCount},规划位置{outTarget},重新回原点,剩余[{MoveInfo.CanWhileCount}]]次。{axisS.ToStr()}";
LogUtil.error(msg);
//LogUtil.error( StoreName + moveAxis.DisplayStr + "重新回原点"); //LogUtil.error( StoreName + moveAxis.DisplayStr + "重新回原点");
AxisManager.HomeMove(axis.DeviceName, axis.GetAxisValue(), axis.HomeHighSpeed, axis.HomeLowSpeed, axis.HomeAddSpeed); AxisManager.HomeMove(axis.DeviceName, axis.GetAxisValue(), axis.HomeHighSpeed, axis.HomeLowSpeed, axis.HomeAddSpeed);
MoveInfo.CanWhileCount--; MoveInfo.CanWhileCount--;
} }
else else
{ {
msg = MoveInfo.Name + " " + MoveInfo.MoveStep + axis.DisplayStr + ",收到原点完成信号,当前位置[" + outCount + "],误差过大,需要报警"; msg =$"{MoveInfo.Name} {MoveInfo.MoveStep} {axis.DisplayStr} ,收到原点完成信号,当前位置[{outCount}],规划位置{outTarget},误差过大,需要报警。{axisS.ToStr()}";
LogUtil.error(msg); LogUtil.error(msg);
} }
} }
...@@ -316,7 +322,8 @@ namespace DeviceLibrary ...@@ -316,7 +322,8 @@ namespace DeviceLibrary
AxisManager.RelMove(Config.DeviceName, Config.GetAxisValue(), targetPos, (int)targetSpeed, AddSpeed, DelSpeed);// , Config.AddSpeed, Config.DelSpeed); AxisManager.RelMove(Config.DeviceName, Config.GetAxisValue(), targetPos, (int)targetSpeed, AddSpeed, DelSpeed);// , Config.AddSpeed, Config.DelSpeed);
} }
public bool IsBusy { public bool IsBusy
{
get => AxisManager.GetBusyStatus(Config.DeviceName, Config.GetAxisValue()) == 1; get => AxisManager.GetBusyStatus(Config.DeviceName, Config.GetAxisValue()) == 1;
} }
public bool IsServeoOn public bool IsServeoOn
...@@ -332,22 +339,26 @@ namespace DeviceLibrary ...@@ -332,22 +339,26 @@ 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;
var from = GetAclPosition(); var from = GetAclPosition();
(result,msg) = interference.Invoke(from, Targetpos); (result, msg) = interference.Invoke(from, Targetpos);
if (result) { if (result)
{
LogUtil.info(AxisName + $" 干涉:{msg},From:{from},To:{Targetpos}"); LogUtil.info(AxisName + $" 干涉:{msg},From:{from},To:{Targetpos}");
} }
return !result; return !result;
} }
public void MonitorAxisLoadRate(float maxloadrate) { public void MonitorAxisLoadRate(float maxloadrate)
Task.Run(() => { {
Task.Run(() =>
{
Task.Delay(200).Wait(); Task.Delay(200).Wait();
LogUtil.info($"{AxisName}-开始负载监控,最大负载阈值:{maxloadrate}"); LogUtil.info($"{AxisName}-开始负载监控,最大负载阈值:{maxloadrate}");
List<float> loadrate = new List<float>(); List<float> loadrate = new List<float>();
...@@ -355,15 +366,17 @@ namespace DeviceLibrary ...@@ -355,15 +366,17 @@ namespace DeviceLibrary
{ {
var loadval = ((HCAxisManager)AxisManager.instance).GetAxisLoadRate(Config.DeviceName, Config.GetAxisValue()); var loadval = ((HCAxisManager)AxisManager.instance).GetAxisLoadRate(Config.DeviceName, Config.GetAxisValue());
loadrate.Add(loadval); loadrate.Add(loadval);
if (loadval > maxloadrate) { if (loadval > maxloadrate)
{
LogUtil.info($"{AxisName}-{loadval}>{maxloadrate}超过负载,系统急停"); LogUtil.info($"{AxisName}-{loadval}>{maxloadrate}超过负载,系统急停");
SuddenStop(); SuddenStop();
Msg.add(AxisName+"-超过负载,系统急停", MsgLevel.alarm,ErrInfo.SuddenStop); Msg.add(AxisName + "-超过负载,系统急停", MsgLevel.alarm, ErrInfo.SuddenStop);
break; break;
} }
Task.Delay(50).Wait(); Task.Delay(50).Wait();
} }
if (loadrate.Count > 5) { if (loadrate.Count > 5)
{
loadrate.Sort(); loadrate.Sort();
int middleIndex = loadrate.Count / 2; int middleIndex = loadrate.Count / 2;
LogUtil.info($"{AxisName}-本次负载监控:最小值:{loadrate.Min()}, 平均值:{loadrate.Average()}, 最大值{loadrate.Max()},中位数:{loadrate[middleIndex]}, 最大阈值:{maxloadrate}"); LogUtil.info($"{AxisName}-本次负载监控:最小值:{loadrate.Min()}, 平均值:{loadrate.Average()}, 最大值{loadrate.Max()},中位数:{loadrate[middleIndex]}, 最大阈值:{maxloadrate}");
...@@ -456,7 +469,7 @@ namespace DeviceLibrary ...@@ -456,7 +469,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);
} }
......
...@@ -423,6 +423,7 @@ namespace DeviceLibrary ...@@ -423,6 +423,7 @@ namespace DeviceLibrary
break; break;
case MoveStep.StoreTS17: case MoveStep.StoreTS17:
//MoveInfo.NextMoveStep(MoveStep.StoreTS16); //MoveInfo.NextMoveStep(MoveStep.StoreTS16);
Msg.add("", MsgLevel.info, ErrInfo.X09_Clear);
MoveInfo.log($"{storeMoveType}:转移料盘完成"); MoveInfo.log($"{storeMoveType}:转移料盘完成");
MoveInfo.EndMove(); MoveInfo.EndMove();
ErrMsgTxt = ""; ErrMsgTxt = "";
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!