From 04e3e394e4e5fcf9688b35e018cd6b94b81bdd63 Mon Sep 17 00:00:00 2001
From: lhiven <236881222@qq.com>
Date: Mon, 2 Oct 2023 14:15:54 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=90=AF=E5=8A=A8=E6=B5=81?=
=?UTF-8?q?=E7=A8=8B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Rs.SkyLine/Commom/Ops.cs | 179 +++++++++++++++--------------
Rs.SkyLine/Commom/Scheduling.cs | 16 ++-
Rs.SkyLine/Flow/AlarmConstID.cs | 66 +++++++++++
Rs.SkyLine/Flow/BaseFlow.cs | 1 +
Rs.SkyLine/Flow/MachineManage.cs | 27 +++++
Rs.SkyLine/Flow/Space/TrayTest.cs | 17 ++-
Rs.SkyLine/Flow/TestCenter.cs | 95 ++++++++++++---
Rs.SkyLine/Flow/WorkEnvironment.cs | 1 +
Rs.SkyLine/Flow/WorkFlow.cs | 5 +-
Rs.SkyLine/Rs.SkyLine.csproj | 1 +
10 files changed, 289 insertions(+), 119 deletions(-)
create mode 100644 Rs.SkyLine/Flow/AlarmConstID.cs
diff --git a/Rs.SkyLine/Commom/Ops.cs b/Rs.SkyLine/Commom/Ops.cs
index d5b17a0..55b20d1 100644
--- a/Rs.SkyLine/Commom/Ops.cs
+++ b/Rs.SkyLine/Commom/Ops.cs
@@ -24,104 +24,104 @@ namespace Rs.MotionPlat.Commom
SysConfigParam.Init();
int errNum = 0;
//Task.Run(() => {
- #region 初始化固高卡
- ErrorCode errCode = GugaoPulseCardManager.Instance.Init();
- if (errCode > ErrorCode.Ok)
- {
- errNum++;
- MessageQueue.Instance.Warn($"Gugao motion card load fail {errCode}");
- LogHelper.Debug($"Gugao motion card load fail {errCode}");
- }
- else
- {
- MessageQueue.Instance.Insert("Gugao motion card load success");
- }
- #endregion
+ #region 初始化固高卡
+ ErrorCode errCode = GugaoPulseCardManager.Instance.Init();
+ if (errCode > ErrorCode.Ok)
+ {
+ errNum++;
+ MessageQueue.Instance.Warn($"Gugao motion card load fail {errCode}");
+ LogHelper.Debug($"Gugao motion card load fail {errCode}");
+ }
+ else
+ {
+ MessageQueue.Instance.Insert("Gugao motion card load success");
+ }
+ #endregion
- #region 初始化ztm卡
- errCode = ZtmCardManager.Instance.Init();
- if (errCode > ErrorCode.Ok)
- {
- errNum++;
- MessageQueue.Instance.Warn($"rs motion card load fail {errCode}"); return;
- }
- else
- {
- MessageQueue.Instance.Insert("rs motion card load ok");
+ #region 初始化ztm卡
+ errCode = ZtmCardManager.Instance.Init();
+ if (errCode > ErrorCode.Ok)
+ {
+ errNum++;
+ MessageQueue.Instance.Warn($"rs motion card load fail {errCode}"); return;
+ }
+ else
+ {
+ MessageQueue.Instance.Insert("rs motion card load ok");
- }
- #endregion
+ }
+ #endregion
- #region 初始化IO
- IoManager.Instance.Init();
- #endregion
+ #region 初始化IO
+ IoManager.Instance.Init();
+ #endregion
- #region 链接相机
- //链接相机
- ECameraErrorCode ceCode = HikCamera.Instance.Init();
- if (ceCode > ECameraErrorCode.Ok)
+ #region 链接相机
+ //链接相机
+ ECameraErrorCode ceCode = HikCamera.Instance.Init();
+ if (ceCode > ECameraErrorCode.Ok)
+ {
+ errNum++;
+ MessageQueue.Instance.Warn(ceCode.ToString());
+ }
+ else
+ {
+ MessageQueue.Instance.Insert("Camera load ok!");
+
+ int ret = HikCamera.Instance.SetReverseX("upCamera", EDir.Y, false);
+ ret += HikCamera.Instance.SetReverseX("upCamera", EDir.X, false);
+ if (ret != 0)
{
- errNum++;
- MessageQueue.Instance.Warn(ceCode.ToString());
+ MessageQueue.Instance.Warn("Camera init error");
}
- else
+ ret = 0;
+ ret = HikCamera.Instance.SetReverseX("downCamera", EDir.X, true);
+ ret += HikCamera.Instance.SetReverseX("downCamera", EDir.Y, false);
+ if (ret != 0)
{
- MessageQueue.Instance.Insert("Camera load ok!");
-
- int ret = HikCamera.Instance.SetReverseX("upCamera", EDir.Y, false);
- ret += HikCamera.Instance.SetReverseX("upCamera", EDir.X, false);
- if (ret != 0)
- {
- MessageQueue.Instance.Warn("Camera init error");
- }
- ret = 0;
- ret = HikCamera.Instance.SetReverseX("downCamera", EDir.X, true);
- ret += HikCamera.Instance.SetReverseX("downCamera", EDir.Y, false);
- if (ret != 0)
- {
- MessageQueue.Instance.Warn("Camera init error");
- }
-
- ret = HikCamera.Instance.StartGrab("upCamera");
- if (ret != 0)
- {
- MessageQueue.Instance.Warn("Camera init error");
- }
- ret = HikCamera.Instance.StartGrab("locationCamera");
- if (ret != 0)
- {
- MessageQueue.Instance.Warn("Camera init error");
- }
+ MessageQueue.Instance.Warn("Camera init error");
+ }
- ret = HikCamera.Instance.StartGrab("scanCamera");
- if (ret != 0)
- {
- MessageQueue.Instance.Warn("Camera init error");
- }
+ ret = HikCamera.Instance.StartGrab("upCamera");
+ if (ret != 0)
+ {
+ MessageQueue.Instance.Warn("Camera init error");
}
- #endregion
-
- //使能所有轴卡
- AxisControl.AllEnable();
- SafeControl.Instance.Init();
- NozzleManager.Init();
- TestCenter.Instance.Init();
- TrayPointManager.LoadPoint();
- AxisControl.AllStop();
- if (errNum==0)
+ ret = HikCamera.Instance.StartGrab("locationCamera");
+ if (ret != 0)
{
- MessageQueue.Instance.Insert("Init finished");
+ MessageQueue.Instance.Warn("Camera init error");
}
- else
+
+ ret = HikCamera.Instance.StartGrab("scanCamera");
+ if (ret != 0)
{
- MessageQueue.Instance.Insert("Init fail");
+ MessageQueue.Instance.Warn("Camera init error");
}
- Ops.On("上下气缸电磁阀原位");
- Ops.Off("上下气缸电磁阀动位");
- Ops.Off("下左相机光源触发");
- Ops.Off("下右相机光源触发");
- Ops.Off("上相机光源触发");
-
+ }
+ #endregion
+
+ //使能所有轴卡
+ AxisControl.AllEnable();
+ SafeControl.Instance.Init();
+ NozzleManager.Init();
+ TestCenter.Instance.Init();
+ TrayPointManager.LoadPoint();
+ AxisControl.AllStop();
+ if (errNum == 0)
+ {
+ MessageQueue.Instance.Insert("Init finished");
+ }
+ else
+ {
+ MessageQueue.Instance.Insert("Init fail");
+ }
+ Ops.On("上下气缸电磁阀原位");
+ Ops.Off("上下气缸电磁阀动位");
+ Ops.Off("下左相机光源触发");
+ Ops.Off("下右相机光源触发");
+ Ops.Off("上相机光源触发");
+ TurnoverSlotOffset.Init();
MonitorSystemButton.Instance.Start();
//});
@@ -130,17 +130,18 @@ namespace Rs.MotionPlat.Commom
public static void Start()
{
+ TakeTrayFlow.Instance.Start();
+ StockManager.Instance.Start();
Task.Run(() => {
MachineManage.Instance.MachineStatus = EMachineStatus.Working;
- TakeTrayFlow.Instance.Start();
- StockManager.Instance.Start();
WorkEnvironment.Instance.Ready();
if (WorkEnvironment.Instance.EnvReadyOkEvent.WaitOne())
{
WorkFlow.Instance.Start();
TurnoverFlow.Instance.Start();
- MachineManage.Instance.RunState = ERunState.Waiting;
- MachineManage.Instance.MachineStatus = EMachineStatus.Working;
+ MachineManage.Instance.SetCenterMachineStatus(ERunStatus.Started);
+ MachineManage.Instance.SetLoadUnloadStatus(ERunState.Waiting);
+ MachineManage.Instance.SetLocalMachineStatus(EMachineStatus.Working);
}
});
}
diff --git a/Rs.SkyLine/Commom/Scheduling.cs b/Rs.SkyLine/Commom/Scheduling.cs
index bd62639..fe06ac5 100644
--- a/Rs.SkyLine/Commom/Scheduling.cs
+++ b/Rs.SkyLine/Commom/Scheduling.cs
@@ -365,7 +365,15 @@ namespace Rs.MotionPlat.Commom
///
/// 多功能仓
///
- Multifunction
+ Multifunction,
+ ///
+ /// 待测空盘
+ ///
+ EmptyInput,
+ ///
+ /// 已测空盘料仓
+ ///
+ EmptyOutput
}
public enum EMultifunctionType
{
@@ -431,7 +439,11 @@ namespace Rs.MotionPlat.Commom
///
/// 切回上一个
///
- Previous
+ Previous,
+ ///
+ /// 回收料盘
+ ///
+ Recycle
}
public enum ESiloStatus
diff --git a/Rs.SkyLine/Flow/AlarmConstID.cs b/Rs.SkyLine/Flow/AlarmConstID.cs
new file mode 100644
index 0000000..c817e31
--- /dev/null
+++ b/Rs.SkyLine/Flow/AlarmConstID.cs
@@ -0,0 +1,66 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Rs.MotionPlat.Flow
+{
+ ///
+ /// 报警常量
+ ///
+ public class AlarmConstID
+ {
+ ///
+ /// Tray盘取料失败报警
+ ///
+ public const int TrayTakeFailAlarm = 1;
+
+ ///
+ /// 周转盘取料失败报警
+ ///
+ public const int TurnoverTakeFailAlarm = 2;
+
+ ///
+ /// 测试盘取料失败报警
+ ///
+ public const int TestTakeFailAlarm = 3;
+
+
+ ///
+ /// 周转盘放料失败报警
+ ///
+ public const int TurnoverDumpFailAlarm = 4;
+
+ ///
+ /// 测试盘放料失败报警
+ ///
+ public const int TestDumpFailAlarm = 5;
+
+ ///
+ /// Empty1满料报警
+ ///
+ public const int Empty1FullAlarm = 6;
+
+ ///
+ /// Input盘缺料报警
+ ///
+ public const int InputNullAlarm = 7;
+ ///
+ /// OK盘满料报警
+ ///
+ public const int OkFullAlarm = 8;
+ ///
+ /// NG盘满料报警
+ ///
+ public const int NgFullAlarm = 9;
+ ///
+ /// 多功能盘满料报警
+ ///
+ public const int MultiFullAlarm = 10;
+ ///
+ /// Empty2缺料报警
+ ///
+ public const int Empty2NullAlarm = 11;
+ }
+}
diff --git a/Rs.SkyLine/Flow/BaseFlow.cs b/Rs.SkyLine/Flow/BaseFlow.cs
index 9393d89..a6b602e 100644
--- a/Rs.SkyLine/Flow/BaseFlow.cs
+++ b/Rs.SkyLine/Flow/BaseFlow.cs
@@ -13,6 +13,7 @@ namespace Rs.MotionPlat.Flow
protected bool b_IsRun = false;
protected bool b_IsStop = true;
private Task mainTask;
+ protected string logInfo = "";
protected int stopWaitTime = 10;
protected int sleepTime = 10;
public BaseFlow() {
diff --git a/Rs.SkyLine/Flow/MachineManage.cs b/Rs.SkyLine/Flow/MachineManage.cs
index e945a0e..fe6d094 100644
--- a/Rs.SkyLine/Flow/MachineManage.cs
+++ b/Rs.SkyLine/Flow/MachineManage.cs
@@ -92,5 +92,32 @@ namespace Rs.MotionPlat.Flow
public EAssignMode AssignMode { get; set; } = EAssignMode.Normal;
public bool NeedRestoreMove { get; set; } = false;
+
+ ///
+ /// 设置返回中控的运行状态
+ ///
+ ///
+ public void SetCenterMachineStatus(ERunStatus status)
+ {
+ RunStatus= status;
+ }
+
+ ///
+ /// 设置本地运行状态
+ ///
+ ///
+ public void SetLocalMachineStatus(EMachineStatus status)
+ {
+ MachineStatus= status;
+ }
+
+ ///
+ /// 设置上下料的状态
+ ///
+ ///
+ public void SetLoadUnloadStatus(ERunState status)
+ {
+ RunState= status;
+ }
}
}
diff --git a/Rs.SkyLine/Flow/Space/TrayTest.cs b/Rs.SkyLine/Flow/Space/TrayTest.cs
index 5e26bde..a1d082e 100644
--- a/Rs.SkyLine/Flow/Space/TrayTest.cs
+++ b/Rs.SkyLine/Flow/Space/TrayTest.cs
@@ -12,6 +12,7 @@ namespace Rs.AutoDischarge.V3.Flow
enum ETrayTestStep
{
等待命令,
+ 下料前料仓满料检测,
到下料降速位,
等待到下料降速位,
到下料结束位,
@@ -99,7 +100,6 @@ namespace Rs.AutoDischarge.V3.Flow
IAxis StockFlow = null;
IAxis StockZ=null;
Stopwatch timer = new Stopwatch();
- string loginfo = "";
public override void Run()
{
@@ -110,6 +110,7 @@ namespace Rs.AutoDischarge.V3.Flow
{
if (NeedUnload)
{
+ logInfo = $"{stockNo} 料仓收到下料任务";
Status = ETrayStatus.Unloading;
//下料
IoManager.Instance.WriteOut($"{stockNo}号料仓斜推气缸", 0);
@@ -119,7 +120,7 @@ namespace Rs.AutoDischarge.V3.Flow
Step = ETrayTestStep.到下料降速位;
}
- else if (NeedLoad)
+ else if (NeedLoad && (Status!= ETrayStatus.Loading))
{
if(!Ops.IsOn($"{stockNo}号料仓料盘到位光电检测") || m_bWholeLoad==false)
{
@@ -137,6 +138,7 @@ namespace Rs.AutoDischarge.V3.Flow
}
else
{
+ NeedLoad = false;
Msg.ShowError($"检测到{stockNo}号料仓处有料盘,不能重复送料盘");
MessageQueue.Instance.Warn($"检测到{stockNo}号料仓处有料盘,不能重复送料盘");
LogHelper.Debug($"检测到{stockNo}号料仓处有料盘,不能重复送料盘");
@@ -144,6 +146,9 @@ namespace Rs.AutoDischarge.V3.Flow
}
}
+ break;
+ case ETrayTestStep.下料前料仓满料检测:
+
break;
case ETrayTestStep.到下料降速位:
StockFlow.MoveOffset(SysConfigParam.GetValue("HighSpeedDistance"), GlobalVar.WholeSpeed);
@@ -315,10 +320,10 @@ namespace Rs.AutoDischarge.V3.Flow
else
{
timer.Stop();
- loginfo = $"料仓{stockNo}上料未到位,请手动处理后,点击确定";
- MessageQueue.Instance.Warn(loginfo);
- LogHelper.Debug(loginfo);
- Msg.ShowError(loginfo);
+ logInfo = $"料仓{stockNo}上料未到位,请手动处理后,点击确定";
+ MessageQueue.Instance.Warn(logInfo);
+ LogHelper.Debug(logInfo);
+ Msg.ShowError(logInfo);
timer.Restart();
}
break;
diff --git a/Rs.SkyLine/Flow/TestCenter.cs b/Rs.SkyLine/Flow/TestCenter.cs
index a0c4dd4..3a239ff 100644
--- a/Rs.SkyLine/Flow/TestCenter.cs
+++ b/Rs.SkyLine/Flow/TestCenter.cs
@@ -16,7 +16,7 @@ namespace Rs.MotionPlat.Flow
{
public class TestCenter
{
- TcpClientHelper client = new TcpClientHelper("127.0.0.1",2048);
+ TcpClientHelper client = new TcpClientHelper("10.86.15.67",2048);
SchedulingResult schedulResult = new SchedulingResult();
SchedulingMaterial sm;
public event Action ReciveTaskEvent;
@@ -80,25 +80,16 @@ namespace Rs.MotionPlat.Flow
switch (eInstructioneInstruction)
{
case EInstruction.InquireSiloStatus:
+ InquireSiloStatus(json);
+ break;
+ case EInstruction.RequestSwitchTray:
+
break;
case EInstruction.InquireConnectionInfo:
- SchedulingConnectionInfo info = JsonConvert.DeserializeObject(json);
- info.Type = SchedulingConnectionInfo.EType.Scheduling;
- client.Send(info.ToString());
- //LogHelper.Debug(info.ToString());
- ReplayTaskEvent?.Invoke(info.ToString());
+ InquireConnectionInfo(json);
break;
case EInstruction.LoadAndUnload:
- LogHelper.Debug("recive:" + json);
- MachineManage.Instance.RunState = ERunState.Busying;
- sm = JsonConvert.DeserializeObject(json);
- schedulResult = new SchedulingResult() { Instruction = sm.Instruction, State = ERunState.Busying, GroupID = sm.GroupID, TurnoverID = sm.TurnoverID };
- string buffer = schedulResult.ToString();
- client.Send(buffer);
- LogHelper.TestCenterLog(buffer);
- LoadAndUnloadTask.Instance.Add(sm);
- MessageQueue.Instance.Insert(sm.Instruction.ToString());
- ReplayTaskEvent?.Invoke(schedulResult.ToString());
+ LoadAndUnload(json);
break;
case EInstruction.CancelLoadAndUnload:
//schedulResult = new SchedulingResult() { Instruction = EInstruction.CancelLoadAndUnload, State = ERunState.Busying, GroupID = sm.GroupID, TurnoverID = sm.TurnoverID };
@@ -184,8 +175,6 @@ namespace Rs.MotionPlat.Flow
client.Send(schedulResult.ToString());
ReplayTaskEvent?.Invoke(schedulResult.ToString());
break;
- case EInstruction.RequestSwitchTray:
- break;
case EInstruction.BeginSwitchTray:
break;
case EInstruction.MoveScanner:
@@ -218,7 +207,69 @@ namespace Rs.MotionPlat.Flow
//string msg=Encoding.UTF8.GetString(data);
//LogHelper.TestCenterLog("接收:"+msg);
//ReciveTaskEvent?.Invoke(msg);
-
+
+ }
+
+
+ private void LoadAndUnload(string json)
+ {
+ LogHelper.Debug("recive:" + json);
+ MachineManage.Instance.RunState = ERunState.Busying;
+ sm = JsonConvert.DeserializeObject(json);
+ schedulResult = new SchedulingResult() { Instruction = sm.Instruction, State = ERunState.Busying, GroupID = sm.GroupID, TurnoverID = sm.TurnoverID };
+ string buffer = schedulResult.ToString();
+ client.Send(buffer);
+ LoadAndUnloadTask.Instance.Add(sm);
+ //MessageQueue.Instance.Insert(sm.Instruction.ToString());
+ //ReplayTaskEvent?.Invoke(schedulResult.ToString());
+ }
+ ///
+ /// 查询 状态
+ ///
+ ///
+ private void InquireConnectionInfo(string json)
+ {
+ SchedulingConnectionInfo info = JsonConvert.DeserializeObject(json);
+ info.Type = SchedulingConnectionInfo.EType.Scheduling;
+ TestCenter.instance.Send(info);
+ }
+ ///
+ /// 查询料仓状态
+ ///
+ ///
+ private void InquireSiloStatus(string json)
+ {
+ SchedulingSilo inquireSilo = JsonConvert.DeserializeObject(json);
+ switch (inquireSilo.SiloType)
+ {
+ case SchedulingSiloBase.ESiloType.ToBeTested:
+ inquireSilo.SiloStatus = SchedulingSilo.ESiloStatus.Standby;
+ break;
+ case SchedulingSiloBase.ESiloType.Passed:
+ inquireSilo.SiloStatus = SchedulingSilo.ESiloStatus.Standby;
+ break;
+ case SchedulingSiloBase.ESiloType.Failed:
+ inquireSilo.SiloStatus = SchedulingSilo.ESiloStatus.Standby;
+ break;
+ case SchedulingSiloBase.ESiloType.Multifunction:
+ inquireSilo.SiloStatus = SchedulingSilo.ESiloStatus.Standby;
+ break;
+ case SchedulingSiloBase.ESiloType.EmptyInput:
+ inquireSilo.SiloStatus = SchedulingSilo.ESiloStatus.Standby;// StockManager.Instance.GetStockStatus(EStockType.Empty1);
+ break;
+ case SchedulingSiloBase.ESiloType.EmptyOutput:
+ inquireSilo.SiloStatus = SchedulingSilo.ESiloStatus.Standby;
+ break;
+ }
+ TestCenter.instance.Send(inquireSilo);
+ //查询料仓状态
+ }
+ ///
+ /// 请求切盘
+ ///
+ private void RequestSwitchTray(string json)
+ {
+
}
///
@@ -282,6 +333,12 @@ namespace Rs.MotionPlat.Flow
return client.Send(content);
}
+ public int Send(Scheduling scheduing)
+ {
+ string content = JsonConvert.SerializeObject(scheduing, new StringEnumConverter());
+ return Send(content);
+ }
+
public void EndInput()
{
Scheduling s = new Scheduling();
diff --git a/Rs.SkyLine/Flow/WorkEnvironment.cs b/Rs.SkyLine/Flow/WorkEnvironment.cs
index 694d4e2..e4d06ac 100644
--- a/Rs.SkyLine/Flow/WorkEnvironment.cs
+++ b/Rs.SkyLine/Flow/WorkEnvironment.cs
@@ -38,6 +38,7 @@ namespace Rs.MotionPlat.Flow
}
public void Ready()
{
+ step = EStockCheckStep.Input料仓是否就绪;
EnvReadyOkEvent.Reset();
Task.Run(() =>
{
diff --git a/Rs.SkyLine/Flow/WorkFlow.cs b/Rs.SkyLine/Flow/WorkFlow.cs
index d1a6645..98ef0d0 100644
--- a/Rs.SkyLine/Flow/WorkFlow.cs
+++ b/Rs.SkyLine/Flow/WorkFlow.cs
@@ -121,7 +121,6 @@ namespace Rs.MotionPlat.Flow
int needGrabNum = 0;//需要拍照的吸嘴数量
int reGrabCount = 0;//重拍次数
ErrorCode errCode = ErrorCode.Ok;
- string logInfo = "";
List testLoadList = new List();
List testUnLoadList = new List();
public override void Run()
@@ -129,7 +128,7 @@ namespace Rs.MotionPlat.Flow
switch (flowStep)
{
case EWorkFlowStep.等待任务:
- if (LoadAndUnloadTask.Instance.Count > 0)
+ if (LoadAndUnloadTask.Instance.Count > 0 && WorkEnvironment.Instance.EnvironmentOk)
{
if(LoadAndUnloadTask.Instance.CanRunTask())
{
@@ -179,7 +178,7 @@ namespace Rs.MotionPlat.Flow
curSlotPoint = null;
if (curTask.FromType == TurnoverType.Turnover)
{
- logInfo = $"吸嘴{curTask.FromIndex + 1} 去周转盘 {curTask.FromIndex + 1} 号穴位取料";
+ logInfo = $"吸嘴 {curNozzle.NozzleIndex} 去周转盘 {curTask.FromIndex + 1} 号穴位取料";
curSlotPoint = TrayPointManager.GetSlotPoint(GlobalVar.CurRecipe, "Turnover", curTask.FromIndex + 1, EPointType.RUN);
MessageQueue.Instance.Insert(logInfo);
LogHelper.Debug(logInfo);
diff --git a/Rs.SkyLine/Rs.SkyLine.csproj b/Rs.SkyLine/Rs.SkyLine.csproj
index 5f4cc1a..5c49561 100644
--- a/Rs.SkyLine/Rs.SkyLine.csproj
+++ b/Rs.SkyLine/Rs.SkyLine.csproj
@@ -152,6 +152,7 @@
DebugMove.cs
+