Commit 58320050 张东亮

校准库位料盘顶起检查功能

1 个父辈 d98f9a8c
...@@ -84,6 +84,7 @@ ...@@ -84,6 +84,7 @@
<Compile Include="DeviceLibrary\ServerCommunication.cs" /> <Compile Include="DeviceLibrary\ServerCommunication.cs" />
<Compile Include="DeviceLibrary\AxisBean.cs" /> <Compile Include="DeviceLibrary\AxisBean.cs" />
<Compile Include="DeviceLibrary\ServerCommunication_AgvProcess.cs" /> <Compile Include="DeviceLibrary\ServerCommunication_AgvProcess.cs" />
<Compile Include="DeviceLibrary\VisionHelper.cs" />
<Compile Include="theMachine\BoxTransport.cs" /> <Compile Include="theMachine\BoxTransport.cs" />
<Compile Include="theMachine\Common.cs" /> <Compile Include="theMachine\Common.cs" />
<Compile Include="theMachine\JobList.cs" /> <Compile Include="theMachine\JobList.cs" />
......
...@@ -256,14 +256,14 @@ namespace DeviceLibrary ...@@ -256,14 +256,14 @@ namespace DeviceLibrary
if (moveInfo1.WaitList[0].WaitType == WaitEnum.W013_Action) if (moveInfo1.WaitList[0].WaitType == WaitEnum.W013_Action)
{ {
var wt = moveInfo1.WaitList[0]; var wt = moveInfo1.WaitList[0];
for (int i = 0; i < 1000; i++) for (int i = 0; i < 100; i++)
{ {
var w = wt.Action?.Invoke(moveInfo1.WaitList[0]); var w = wt.Action?.Invoke(moveInfo1.WaitList[0]);
if (w == null) if (w == null)
return; return;
if (w.Value) if (w.Value)
break; break;
Task.Delay(10).Wait(); Task.Delay(100).Wait();
} }
} }
} }
......
using Common;
using OnlineStore.Common;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.Eventing.Reader;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace DeviceLibrary
{
public class VisionHelper
{
static string visionUrl = ConfigHelper.Config.Get("VisionUrl", "http://localhost:8089/vision/eyem");
public static bool ReelStatusCheck()
{
string cameraName = ConfigHelper.Config.Get("MonitorCamName", "cam1");
string url = visionUrl + "/reelStatusCheck/cam?camName=" + cameraName;
try
{
CheckAndRunServer();
string json = HttpHelper.Get(url);
Result result = JsonHelper.DeserializeJsonToObject<Result>(json);
if (result != null && result.code == 0)
{
LogUtil.info("料盘放置正常");
return true;
}
else
{
LogUtil.info("料盘放置异常");
return false;
}
}
catch (Exception ex)
{
LogUtil.error("ReelStatusCheck", ex);
}
return false;
}
static Process EyemFeatureSet = new Process();
static int webclienttimeout = 30000;
public static void CheckAndRunServer()
{
lock (EyemFeatureSet)
{
Process[] processesByName = Process.GetProcessesByName("EyemFeatureSet");
if (processesByName.Length != 0)
{
return;
}
string text = "Modules\\EyemFeatureSet\\EyemFeatureSet.exe";
if (!File.Exists(text))
{
throw new Exception("找不到算法服务器文件");
}
EyemFeatureSet= ProcessUtil.StartProcess("EyemFeatureSet", Application.StartupPath+"\\Modules\\EyemFeatureSet\\");
int num = 5;
while (num > 0)
{
num--;
Thread.Sleep(1000);
MyWebClient myWebClient = new MyWebClient(webclienttimeout);
string text2 = myWebClient.DownloadString(visionUrl+"/alive");
if (text2.Trim() == "\"1\"")
{
return;
}
}
throw new Exception("算法服务器文件打开失败");
}
}
public class Result
{
/// <summary>
/// 状态码,0为正常
/// </summary>
public int code { get; set; } = 0;
/// <summary>
/// 返回数据
/// </summary>
public Dictionary<string, string> data { get; set; }
/// <summary>
/// 提示信息
/// </summary>
public string msg { get; set; } = "ok";
}
}
}
...@@ -30,13 +30,13 @@ namespace DeviceLibrary ...@@ -30,13 +30,13 @@ namespace DeviceLibrary
public event Action<string, StoreMoveType, bool> InOutEndProcessEvent; public event Action<string, StoreMoveType, bool> InOutEndProcessEvent;
public bool IsComplateOrFree { get => MoveInfo.MoveStep == MoveStep.Wait; } public bool IsComplateOrFree { get => MoveInfo.MoveStep == MoveStep.Wait; }
public bool IsTakedReel { get => MoveInfo.MoveStep >= MoveStep.StoreTS10; } public bool IsTakedReel { get => MoveInfo.MoveStep >= MoveStep.StoreTS10; }
public bool IsPutOnOut {get=> MoveInfo.MoveStep >= MoveStep.StoreTS16; } public bool IsPutOnOut { get => MoveInfo.MoveStep >= MoveStep.StoreTS16; }
public ReelTransport(Robot_Config _Config, MainMachine _mainMachine) public ReelTransport(Robot_Config _Config, MainMachine _mainMachine)
{ {
Config = _Config; Config = _Config;
mainMachine = _mainMachine; mainMachine = _mainMachine;
MoveInfo = new MoveInfo(crc.GetString(L.transfer_equipment, "出入库机构"),false); MoveInfo = new MoveInfo(crc.GetString(L.transfer_equipment, "出入库机构"), false);
#region 初始化伺服轴 #region 初始化伺服轴
Middle_Axis = _mainMachine.Middle_Axis; Middle_Axis = _mainMachine.Middle_Axis;
UpDown_Axis = _mainMachine.UpDown_Axis; UpDown_Axis = _mainMachine.UpDown_Axis;
...@@ -45,15 +45,20 @@ namespace DeviceLibrary ...@@ -45,15 +45,20 @@ namespace DeviceLibrary
#endregion #endregion
} }
public void Reset() { public void Reset()
{
MoveInfo.NewMove(MoveStep.Wait); MoveInfo.NewMove(MoveStep.Wait);
MoveInfo.log("执行重置"); MoveInfo.log("执行重置");
} }
StoreMoveType storeMoveType = StoreMoveType.None; StoreMoveType storeMoveType = StoreMoveType.None;
string WareCode=""; string WareCode = "";
int plateH = 0; int plateH = 0;
bool PreMove = false; bool PreMove = false;
public bool Start(BoxStorePosition from, BoxStorePosition to, StoreMoveType _storeMoveType, bool premove=false) /// <summary>
/// 料盘放置在校准库位是否正常
/// </summary>
bool reelStatusInFix = true;
public bool Start(BoxStorePosition from, BoxStorePosition to, StoreMoveType _storeMoveType, bool premove = false)
{ {
if (MoveInfo.MoveStep != MoveStep.Wait) if (MoveInfo.MoveStep != MoveStep.Wait)
...@@ -93,7 +98,8 @@ namespace DeviceLibrary ...@@ -93,7 +98,8 @@ namespace DeviceLibrary
//thread.Start(); //thread.Start();
} }
public bool ReadyToTakeBox() { public bool ReadyToTakeBox()
{
if (MoveInfo.MoveStep != MoveStep.StoreTS05) if (MoveInfo.MoveStep != MoveStep.StoreTS05)
return false; return false;
...@@ -173,14 +179,14 @@ namespace DeviceLibrary ...@@ -173,14 +179,14 @@ namespace DeviceLibrary
RobotManage.CameraA.CameraGrabOne(RobotManage.CameraA.GetFixtureStateFilename(From.posid, WareCode, storeMoveType, FixtureState.FromOut)); RobotManage.CameraA.CameraGrabOne(RobotManage.CameraA.GetFixtureStateFilename(From.posid, WareCode, storeMoveType, FixtureState.FromOut));
if (!IgnoreX09 && IOManager.IOValue(IO_Type.TrayCheck_Fixture).Equals(IO_VALUE.LOW)) if (!IgnoreX09 && IOManager.IOValue(IO_Type.TrayCheck_Fixture).Equals(IO_VALUE.LOW))
{ {
Msg.add(crc.GetString(L.out_store_not_detect_material, "取料前料叉X30没有检测到有物料无法继续,请检查."), MsgLevel.alarm,ErrInfo.X09_BoxNotDetect); Msg.add(crc.GetString(L.out_store_not_detect_material, "取料前料叉X30没有检测到有物料无法继续,请检查."), MsgLevel.alarm, ErrInfo.X09_BoxNotDetect);
//RobotManage.UserPause("出库时料叉X30没有检测到有物料无法继续,请检查"); //RobotManage.UserPause("出库时料叉X30没有检测到有物料无法继续,请检查");
} }
else else
{ {
Msg.add("", MsgLevel.info, ErrInfo.X09_Clear); Msg.add("", MsgLevel.info, ErrInfo.X09_Clear);
IgnoreX09 = false; IgnoreX09 = false;
if (To.posid== BoxStorePosition.strings && ConfigHelper.Config.Get("Device_Use_Fixpos",false) && Fix!=null) if (To.posid == BoxStorePosition.strings && ConfigHelper.Config.Get("Device_Use_Fixpos", false) && Fix != null)
MoveInfo.NextMoveStep(MoveStep.StoreFIX01); MoveInfo.NextMoveStep(MoveStep.StoreFIX01);
else else
MoveInfo.NextMoveStep(MoveStep.StoreTS10); MoveInfo.NextMoveStep(MoveStep.StoreTS10);
...@@ -206,14 +212,54 @@ namespace DeviceLibrary ...@@ -206,14 +212,54 @@ namespace DeviceLibrary
RobotManage.CameraA.CameraGrabOne(RobotManage.CameraA.GetFixtureStateFilename(To.posid, WareCode, storeMoveType, FixtureState.ToFix)); RobotManage.CameraA.CameraGrabOne(RobotManage.CameraA.GetFixtureStateFilename(To.posid, WareCode, storeMoveType, FixtureState.ToFix));
MoveInfo.NextMoveStep(MoveStep.StoreFIX04); MoveInfo.NextMoveStep(MoveStep.StoreFIX04);
Comp_Axis.AbsMove(MoveInfo, Fix.Comp_PH, Config.Comp_P2_speed); Comp_Axis.AbsMove(MoveInfo, Fix.Comp_PH, Config.Comp_P2_speed);
UpDown_Axis.AbsMove(MoveInfo, Fix.UpDown_PL, Config.UpDown_P3_speed/2); UpDown_Axis.AbsMove(MoveInfo, Fix.UpDown_PL, Config.UpDown_P3_speed / 2);
MoveInfo.log($"{storeMoveType}:压紧轴高点:{Fix.Comp_PH}"); MoveInfo.log($"{storeMoveType}:压紧轴高点:{Fix.Comp_PH}");
MoveInfo.log($"{storeMoveType}:上下轴到达目的地低点:{Fix.UpDown_PL}"); MoveInfo.log($"{storeMoveType}:上下轴到达目的地低点:{Fix.UpDown_PL}");
break; break;
case MoveStep.StoreFIX04: case MoveStep.StoreFIX04:
if (ConfigHelper.Config.Get("Func_CheckReelLocInFix", false))
{
MoveInfo.NextMoveStep(MoveStep.StoreFIX04_01_InoutBackToP1);
InOut_Axis.AbsMove(MoveInfo, Config.InOut_P1, Config.InOut_P1_speed);
MoveInfo.log($"{storeMoveType}:进出轴回到待机点");
}
else
{
MoveInfo.NextMoveStep(MoveStep.StoreFIX05); MoveInfo.NextMoveStep(MoveStep.StoreFIX05);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000)); MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
}
break; break;
#region 料盘放置位置检查
case MoveStep.StoreFIX04_01_InoutBackToP1:
MoveInfo.NextMoveStep(MoveStep.StoreFIX04_02_CheckLocation);
reelStatusInFix = VisionHelper.ReelStatusCheck();
break;
case MoveStep.StoreFIX04_02_CheckLocation:
if(reelStatusInFix)
{
MoveInfo.NextMoveStep(MoveStep.StoreFIX04_04_InoutToPos);
MoveInfo.log($"{storeMoveType}:料盘放置正常");
}
else
{
MoveInfo.NextMoveStep(MoveStep.StoreFIX04_03_ReloadPos);
MoveInfo.log($"{storeMoveType}:料盘放置异常,准备送到NG口");
}
break;
case MoveStep.StoreFIX04_03_ReloadPos:
MoveInfo.NextMoveStep(MoveStep.StoreFIX04_04_InoutToPos);
To = new BoxStorePosition(Config, StoreSide.NGDoor, To.Reel);
MoveInfo.log($"{storeMoveType}:更改料盘目的地为NG口");
break;
case MoveStep.StoreFIX04_04_InoutToPos:
MoveInfo.NextMoveStep(MoveStep.StoreFIX05);
MoveInfo.log($"{storeMoveType}:进出轴到达目的地");
InOut_Axis.AbsMove(MoveInfo, Fix.InOut_P2, Config.InOut_P2_speed);
InOut_Axis.MonitorAxisLoadRate();
break;
#endregion
case MoveStep.StoreFIX05: case MoveStep.StoreFIX05:
MoveInfo.NextMoveStep(MoveStep.StoreFIX06); MoveInfo.NextMoveStep(MoveStep.StoreFIX06);
Comp_Axis.AbsMove(MoveInfo, Fix.Comp_PL, Config.Comp_P2_speed); Comp_Axis.AbsMove(MoveInfo, Fix.Comp_PL, Config.Comp_P2_speed);
...@@ -235,7 +281,8 @@ namespace DeviceLibrary ...@@ -235,7 +281,8 @@ namespace DeviceLibrary
MoveInfo.log($"{storeMoveType}:上下轴到达目的地高点:{To.UpDown_PH}"); MoveInfo.log($"{storeMoveType}:上下轴到达目的地高点:{To.UpDown_PH}");
break; break;
case MoveStep.StoreTS11: case MoveStep.StoreTS11:
if (To.posid==BoxStorePosition.strings) { if (To.posid == BoxStorePosition.strings)
{
if (!mainMachine.IsPutReelReady) if (!mainMachine.IsPutReelReady)
{ {
//if (MoveInfo.IsTimeOut(20)) //if (MoveInfo.IsTimeOut(20))
...@@ -243,12 +290,13 @@ namespace DeviceLibrary ...@@ -243,12 +290,13 @@ namespace DeviceLibrary
MoveInfo.log($"等待料串准备好放料"); MoveInfo.log($"等待料串准备好放料");
return false; return false;
} }
}else if (To.posid == BoxStorePosition.ngdoor) }
else if (To.posid == BoxStorePosition.ngdoor)
{ {
if (mainMachine.ClampMoveInfo.MoveStep!=MoveStep.Wait) if (mainMachine.ClampMoveInfo.MoveStep != MoveStep.Wait)
{ {
//if (MoveInfo.IsTimeOut(20)) //if (MoveInfo.IsTimeOut(20))
Msg.add(crc.GetString(L.out_store_wait_ngdoor_ready,"等待单料口空闲."), MsgLevel.warning); Msg.add(crc.GetString(L.out_store_wait_ngdoor_ready, "等待单料口空闲."), MsgLevel.warning);
MoveInfo.log($"等待单料口空闲"); MoveInfo.log($"等待单料口空闲");
return false; return false;
} }
...@@ -278,7 +326,7 @@ namespace DeviceLibrary ...@@ -278,7 +326,7 @@ namespace DeviceLibrary
RobotManage.CameraA.CameraGrabOne(RobotManage.CameraA.GetFixtureStateFilename(To.posid, WareCode, storeMoveType, FixtureState.ToOut)); RobotManage.CameraA.CameraGrabOne(RobotManage.CameraA.GetFixtureStateFilename(To.posid, WareCode, storeMoveType, FixtureState.ToOut));
if (!IgnoreX09 && IOManager.IOValue(IO_Type.TrayCheck_Fixture).Equals(IO_VALUE.HIGH)) if (!IgnoreX09 && IOManager.IOValue(IO_Type.TrayCheck_Fixture).Equals(IO_VALUE.HIGH))
{ {
Msg.add(crc.GetString(L.in_store_detect_material,"放料后料叉X30上任然检测到物料,请检查."), MsgLevel.alarm, ErrInfo.X09_BoxNotDetect); Msg.add(crc.GetString(L.in_store_detect_material, "放料后料叉X30上任然检测到物料,请检查."), MsgLevel.alarm, ErrInfo.X09_BoxNotDetect);
//RobotManage.UserPause("入库后料叉X30上任然检测到物料,请检查"); //RobotManage.UserPause("入库后料叉X30上任然检测到物料,请检查");
} }
else else
...@@ -297,9 +345,10 @@ namespace DeviceLibrary ...@@ -297,9 +345,10 @@ namespace DeviceLibrary
) )
{ {
MoveInfo.log($"{storeMoveType}:库位测试模式,上下轴,旋转不返回待机点"); MoveInfo.log($"{storeMoveType}:库位测试模式,上下轴,旋转不返回待机点");
break; } break;
}
if (To.posid==BoxStorePosition.strings) if (To.posid == BoxStorePosition.strings)
UpDown_Axis.AbsMove(MoveInfo, Config.UpDown_P5, Config.UpDown_P1_speed); UpDown_Axis.AbsMove(MoveInfo, Config.UpDown_P5, Config.UpDown_P1_speed);
else else
UpDown_Axis.AbsMove(MoveInfo, Config.UpDown_P3, Config.UpDown_P1_speed); UpDown_Axis.AbsMove(MoveInfo, Config.UpDown_P3, Config.UpDown_P1_speed);
...@@ -327,7 +376,8 @@ namespace DeviceLibrary ...@@ -327,7 +376,8 @@ namespace DeviceLibrary
InOutEndProcessEvent?.Invoke(posid, storeMoveType, true); InOutEndProcessEvent?.Invoke(posid, storeMoveType, true);
} }
HIKCamera GetCamera(int pos) { HIKCamera GetCamera(int pos)
{
//return pos > 0 ? RobotManage.CameraA : RobotManage.CameraB; //return pos > 0 ? RobotManage.CameraA : RobotManage.CameraB;
return RobotManage.CameraA; return RobotManage.CameraA;
} }
......
...@@ -138,6 +138,10 @@ namespace DeviceLibrary ...@@ -138,6 +138,10 @@ namespace DeviceLibrary
StoreFIX02, StoreFIX02,
StoreFIX03, StoreFIX03,
StoreFIX04, StoreFIX04,
StoreFIX04_01_InoutBackToP1,
StoreFIX04_02_CheckLocation,
StoreFIX04_03_ReloadPos,
StoreFIX04_04_InoutToPos,
StoreFIX05, StoreFIX05,
StoreFIX06, StoreFIX06,
StoreTS10, StoreTS10,
......
...@@ -74,7 +74,7 @@ namespace TheMachine ...@@ -74,7 +74,7 @@ namespace TheMachine
b.Save(@"D:\rick\vs\SO1069MIMO_PLUS\11-57-09-156_11.bmp"); b.Save(@"D:\rick\vs\SO1069MIMO_PLUS\11-57-09-156_11.bmp");
*/ */
DeviceLibrary.VisionHelper.CheckAndRunServer();
_ = new Mutex(true, Application.ProductName, out bool ret); _ = new Mutex(true, Application.ProductName, out bool ret);
if (!ret) if (!ret)
......
...@@ -13,7 +13,7 @@ namespace TheMachine ...@@ -13,7 +13,7 @@ namespace TheMachine
internal class WindowManager internal class WindowManager
{ {
public static List<WindInfo> windInfos = new List<WindInfo>(); public static List<WindInfo> windInfos = new List<WindInfo>();
static string baseDir = @".\Modules\"; static string baseDir = Application.StartupPath + @"\Modules\";
public static void Start() public static void Start()
{ {
foreach (var item in windInfos) foreach (var item in windInfos)
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!