From bbb5b314a8f3760c2b700ab36b3b1dfa5d19f075 Mon Sep 17 00:00:00 2001 From: NXX <447201003@qq> Date: Thu, 5 Jan 2023 10:45:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E7=82=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BPASmartClient.Modbus/ModbusTcp.cs | 16 ++++++++- BPASmartClient.MorkF/Control_MorkF.cs | 50 ++++++++++++++++++--------- BPASmartClient.MorkF/ML_MorkF.cs | 4 +++ 3 files changed, 53 insertions(+), 17 deletions(-) diff --git a/BPASmartClient.Modbus/ModbusTcp.cs b/BPASmartClient.Modbus/ModbusTcp.cs index 711c303c..132808f6 100644 --- a/BPASmartClient.Modbus/ModbusTcp.cs +++ b/BPASmartClient.Modbus/ModbusTcp.cs @@ -140,7 +140,21 @@ namespace BPASmartClient.Modbus } } } - + + else if (address.ToUpper().Contains("I") && address.Length >= 2) + { + var res = address.Substring(1).Split('.'); + if (res != null && res.Length == 2) + { + if (int.TryParse(res[0], out int firstAddress) && int.TryParse(res[1], out int ExitAddress)) + { + if (ExitAddress >= 0 && ExitAddress <= 7) + { + return (firstAddress * 8) + ExitAddress; + } + } + } + } else if (address.ToUpper().Contains("GI") && address.Length >= 3) { var res = address.Remove(0, 2); diff --git a/BPASmartClient.MorkF/Control_MorkF.cs b/BPASmartClient.MorkF/Control_MorkF.cs index 6093e261..2d687cdf 100644 --- a/BPASmartClient.MorkF/Control_MorkF.cs +++ b/BPASmartClient.MorkF/Control_MorkF.cs @@ -161,7 +161,7 @@ namespace BPASmartClient.MorkF /// /// 是否为本地炒菜模式,默认为联网的 /// - private bool isLocalFryingMode { get; set; } = false; + private bool isLocalFryingMode { get; set; } = true; /// /// 入口 @@ -201,7 +201,7 @@ namespace BPASmartClient.MorkF MaterialCoordinate.GetInstance().frying2 = materialCoordinate.frying2; MaterialCoordinate.GetInstance().materialHeight = materialCoordinate.materialHeight; MaterialCoordinate.GetInstance().MaterialOneX = materialCoordinate.MaterialOneX; - MaterialCoordinate.GetInstance().MaterialTwoX = materialCoordinate.MaterialTwoX; + MaterialCoordinate.GetInstance().MaterialTwoX = materialCoordinate.MaterialTwoX; MaterialCoordinate.GetInstance().MaterialThreeX = materialCoordinate.MaterialThreeX; } ////菜品库编号与坐标系对象存储 @@ -371,6 +371,17 @@ namespace BPASmartClient.MorkF } }), 2); + //抓手初始化完成 + GetStatus("I0.1", new Action((objects) => + { + if (objects is bool[] bools && bools.Length > 2) + { + ml_morkf.PawPositon_1 = bools[0]; + ml_morkf.PawPositon_2 = bools[1]; + ml_morkf.PawPositon_3 = bools[2]; + } + }), 2); + } public override void Stop() @@ -1041,8 +1052,9 @@ namespace BPASmartClient.MorkF return false; } - //MessageLog.GetInstance.Show("爪子去到2号位"); MaterailLibrary_Write("M1.1", true); + //MessageLog.GetInstance.Show("爪子去到2号位"); + Thread.Sleep(500); @@ -1055,7 +1067,7 @@ namespace BPASmartClient.MorkF return false; } } - + Thread.Sleep(300); //MessageLog.GetInstance.Show("爪子去到2号位完成"); @@ -1084,7 +1096,11 @@ namespace BPASmartClient.MorkF return false; } } - + if (!ml_morkf.PawPositon_3) + { + MaterailLibrary_Write("M1.2", true); + Thread.Sleep(3000); + } Thread.Sleep(300); //MessageLog.GetInstance.Show("爪子去到3号位完成"); @@ -1358,8 +1374,9 @@ namespace BPASmartClient.MorkF Thread.Sleep(1000); //获取传感器的距离,转换成坐标系的点 - int laserHigh = ml_morkf.LaserDistance; + //int laserHigh = ml_morkf.LaserDistance; + int laserHigh = 400; //秦工要求读取后置0 WriteDistance(0); @@ -1379,7 +1396,7 @@ namespace BPASmartClient.MorkF } //设置到传感器感应的距离处 - if (!SetArmPosition(x - moveX, y)) + if (!SetArmPosition(x, y)) { return false; } @@ -1436,6 +1453,7 @@ namespace BPASmartClient.MorkF MessageLog.GetInstance.ShowEx("错误:未设置当前菜品库出菜位置"); return false; } + //爪子去2号位放菜 if (!PawToPoint2()) @@ -1444,12 +1462,12 @@ namespace BPASmartClient.MorkF } WriteSpeed(50000); - - ThreadManage.GetInstance().Start(new Action(() => - { - //收缩爪子 - PawShrink(); - }), "GetMaterialPawShrink"); + //ThreadManage.GetInstance().Start(new Action(() => + //{ + // //收缩爪子 + // PawShrink(); + //}), "GetMaterialPawShrink"); + PawShrink(); //判断炒锅是否可以放盒 for (int i = 0; materialSleepCount > i && !morkFs[fryIndex].FryPot1_HOBTPut; i++) @@ -1465,7 +1483,7 @@ namespace BPASmartClient.MorkF //关闭启磁吸 MagnetOff(fryNum); - Thread.Sleep(200); + //Thread.Sleep(2000); //根据炒锅不同设置不同的出菜处 if (fryNum % 2 == 0) @@ -1494,7 +1512,7 @@ namespace BPASmartClient.MorkF //开启磁吸 MagnetOn(fryNum); - Thread.Sleep(200); + Thread.Sleep(500); //设置到炒锅1出菜处 if (!SetArmPosition(x, y)) @@ -1962,7 +1980,7 @@ namespace BPASmartClient.MorkF //搅拌设置为1档 SetStir(new List { 1 }, i); //火力设置为2档 - SetFire(new List { 1 }, num); + SetFire(new List { 3 }, num); } Thread.Sleep(materialSleepTime); if (i >= materialSleepCount * 2 - 1) diff --git a/BPASmartClient.MorkF/ML_MorkF.cs b/BPASmartClient.MorkF/ML_MorkF.cs index b7a6b624..993de6c1 100644 --- a/BPASmartClient.MorkF/ML_MorkF.cs +++ b/BPASmartClient.MorkF/ML_MorkF.cs @@ -109,6 +109,10 @@ namespace BPASmartClient.MorkF _PawArrivePortThree = value; } } + + public bool PawPositon_1 { get; set; } + public bool PawPositon_2 { get; set; } + public bool PawPositon_3 { get; set; } #endregion #region