Browse Source

小炒海科测试最终版本

样式分支
yahaha 1 year ago
parent
commit
f9a42afa8f
4 changed files with 105 additions and 96 deletions
  1. +1
    -1
      BPASmartClient.MORKSM.BK.PLC/PLCMachine.cs
  2. +2
    -2
      BPASmartClient.Modbus/ModbusTcp.cs
  3. +101
    -92
      BPASmartClient.MorkF/Control_MorkF.cs
  4. +1
    -1
      BPASmartClient.MorkF/ViewModel/MaterialCalibrationViewModel.cs

+ 1
- 1
BPASmartClient.MORKSM.BK.PLC/PLCMachine.cs View File

@@ -40,7 +40,7 @@ namespace BPASmartClient.PLC
}
}
}
Thread.Sleep(500);
Thread.Sleep(100);
}
Thread.Sleep(1000);
}), $"设备[{DeviceId}][{modbusTcp.IPAdress}]PLC读取线程", true);


+ 2
- 2
BPASmartClient.Modbus/ModbusTcp.cs View File

@@ -59,8 +59,8 @@ namespace BPASmartClient.Modbus
Connect();
if (Connected)
{
master.Transport.ReadTimeout = 2000;//读取超时时间
master.Transport.WriteTimeout = 2000;//写入超时时间
master.Transport.ReadTimeout = 3000;//读取超时时间
master.Transport.WriteTimeout = 3000;//写入超时时间
master.Transport.Retries = 10;//重试次数
ConnectOk?.Invoke();
Show?.Invoke($"设备【{ip}:{port}】连接成功");


+ 101
- 92
BPASmartClient.MorkF/Control_MorkF.cs View File

@@ -34,7 +34,7 @@ namespace BPASmartClient.MorkF
/// <summary>
/// 菜品库while循环最大sleep次数
/// </summary>
private const int materialSleepCount = 600;
private const int materialSleepCount = 900;

/// <summary>
/// 菜品库while循环每次sleep时间
@@ -1281,12 +1281,6 @@ namespace BPASmartClient.MorkF

MessageLog.GetInstance.Show($"传感器的距离{laserHigh}");

//if (laserHigh > 29)
//{
// MessageLog.GetInstance.Show("错误:传感器获取数据大于隔板与传感器之间的距离");
// return false;
//}

int moveX = 0;
if (LaserDistance2Coordinate(laserHigh, x, out moveX) != Laser2CoordinateState.MaterialNormal)
{
@@ -1310,14 +1304,12 @@ namespace BPASmartClient.MorkF
Electromagnetism(new List<bool> { true });
Thread.Sleep(500);

#if true
//爪子去1号位抓菜
if (!PawToPoint1())
{
return false;
}

#endif
//伸出爪子
PawExtend();

@@ -1325,8 +1317,6 @@ namespace BPASmartClient.MorkF
Electromagnetism(new List<bool> { false });
Thread.Sleep(500);


int heightDifferent = 0;
//根据x轴所在坐标系,计算高度差。
if( (x > 0 && x <= MaterialCoordinate.GetInstance().dicNoMaterialCoordinate["1"].X)&&
(MaterialCoordinate.GetInstance().MaterialOneX > 0 && MaterialCoordinate.GetInstance().MaterialOneX < x))
@@ -1361,13 +1351,12 @@ namespace BPASmartClient.MorkF
return false;
}

#if true
//爪子去2号位放菜
if (!PawToPoint2())
{
return false;
}
#endif
//收缩爪子
PawShrink();

@@ -1399,28 +1388,34 @@ namespace BPASmartClient.MorkF
y = MaterialCoordinate.GetInstance().frying2.Y;
}

//设置到炒锅1出菜处
if (!SetArmPosition(x, y))
//先设置到炒锅i出菜处上10000点
if (!SetArmPosition(x - materialToFryDistance, y))
{
return false;
}

#if true
//爪子去3号位放菜
if (!PawToPoint3())
{
return false;
}
#endif

//伸出爪子
PawExtend();

//开启磁吸
MagnetOn(fryNum);

Thread.Sleep(200);

//设置到炒锅1出菜处
if (!SetArmPosition(x, y))
{
return false;
}

//伸出爪子
PawExtend();

Thread.Sleep(300);

//关闭电磁阀
Electromagnetism(new List<bool> { true });
Thread.Sleep(300);
@@ -1434,13 +1429,11 @@ namespace BPASmartClient.MorkF
return false;
}

#if true
//爪子回到2号位
if (!PawToPoint2())
{
return false;
}
#endif

//开启电磁阀
Electromagnetism(new List<bool> { false });
@@ -1472,9 +1465,43 @@ namespace BPASmartClient.MorkF
return false;
}

//关闭电磁阀
Electromagnetism(new List<bool> { true });

//爪子收回
PawShrink();

//爪子去2号点位
if(!PawToPoint2())
{
return false;
}

//开启电磁阀
Electromagnetism(new List<bool> { false });

//遍历坐标系与位置,并根据位置更新菜品余量
foreach(var item in MaterialCoordinate.GetInstance().dicNoMaterialCoordinate)
foreach (var item in MaterialCoordinate.GetInstance().dicNoMaterialCoordinate)
{
bool ret = true;
switch (item.Key)
{
//遇到1 9 10 18 19 27号位置跳过不检测,因为这6个位置不放菜品
case "1":
case "9":
case "10":
case "18":
case "19":
case "27":
ret = false;
break;
}

if (!ret)
{
continue;
}

//设置到抓菜处
if (!SetArmPosition(item.Value.X, item.Value.Y))
{
@@ -1499,7 +1526,7 @@ namespace BPASmartClient.MorkF
int surplus = 0;
//根据距离算出菜品余量
Laser2CoordinateState state = LaserDistance2MaterialCount(laserHigh, item.Value.X, out surplus);
if (state != Laser2CoordinateState.MaterialNormal || state != Laser2CoordinateState.MaterialEmpty)
if (state != Laser2CoordinateState.MaterialNormal && state != Laser2CoordinateState.MaterialEmpty)
{
return false;
}
@@ -1507,7 +1534,7 @@ namespace BPASmartClient.MorkF
//更新菜品余量
if (!MaterialSurplusOperation.GetInstance().UpdateSurplus(item.Key, surplus))
{
return false;
//return false;
}
}

@@ -1528,40 +1555,9 @@ namespace BPASmartClient.MorkF
public Laser2CoordinateState LaserDistance2Coordinate(int distance, int x, out int x_high)
{
x_high = 0;
//int heightDifferent = 0;
int boxCount = 0;
////传感器高度小于6,无法移出,菜品库满
//if (distance < 60)
//{
// MessageLog.GetInstance.ShowEx("错误:传感器距离不满足出菜高度");
// return Laser2CoordinateState.MaterialOverdo;
//}
try
{
////根据x轴所在坐标系,计算高度差。
//if (x > 0 && x <= MaterialCoordinate.GetInstance().dicNoMaterialCoordinate["1"].X)
//{
// heightDifferent = MaterialCoordinate.GetInstance().distance_1 - distance;
//}
//else if (x <= MaterialCoordinate.GetInstance().dicNoMaterialCoordinate["10"].X && x > MaterialCoordinate.GetInstance().dicNoMaterialCoordinate["1"].X)
//{
// heightDifferent = MaterialCoordinate.GetInstance().distance_2 - distance;
//}
//else if (x > MaterialCoordinate.GetInstance().dicNoMaterialCoordinate["10"].X && x <= MaterialCoordinate.GetInstance().dicNoMaterialCoordinate["20"].X)
//{
// heightDifferent = MaterialCoordinate.GetInstance().distance_3 - distance;
//}
//else
//{
// return Laser2CoordinateState.MaterialOverdo;
//}
////盒子高度为45,但是需要考虑到误差,因此除以50
//boxCount = heightDifferent / 50;
//if (heightDifferent <= 20)
//{
// MessageLog.GetInstance.ShowEx("错误:菜品量为空");
// return Laser2CoordinateState.MaterialEmpty;
//}
Laser2CoordinateState laser2CoordinateState = LaserDistance2MaterialCount(distance, x, out boxCount);
if (laser2CoordinateState == Laser2CoordinateState.MaterialNormal)
{
@@ -1613,6 +1609,12 @@ namespace BPASmartClient.MorkF
{
return Laser2CoordinateState.MaterialOverdo;
}

if(heightDifferent < 0)
{
MessageLog.GetInstance.ShowEx($"菜品库检测{x}处的菜品量时,传感器获取的高度差为负数,请校准该层高度");
}

//盒子高度为45,但是需要考虑到误差,不足35,则认为为空
int boxCount = heightDifferent / 35;
count = boxCount;
@@ -1623,7 +1625,7 @@ namespace BPASmartClient.MorkF
}
else if(count > 6)
{
MessageLog.GetInstance.Show("菜品库数量超量");
MessageLog.GetInstance.ShowEx("菜品库数量超量");
return Laser2CoordinateState.MaterialOverdo;
}
else
@@ -2342,7 +2344,7 @@ namespace BPASmartClient.MorkF
//遍历炒锅,找到合适、空闲的炒锅
for(int i = 0;i<morkFs.Count;i++)
{
if (morkFs[i].AutoMode && morkFs[i].FryPot1_InitialComplete && ml_morkf.InitialComplete &&
if (/*morkFs[i].AutoMode && morkFs[i].FryPot1_InitialComplete && ml_morkf.InitialComplete &&*/
!morkFs[i].FryWorking)//炒锅在自动状态&&初始化完成&&菜品库初始化&&是否在炒菜中
{
Thread.Sleep(5000);
@@ -2465,45 +2467,52 @@ namespace BPASmartClient.MorkF
//炒锅取菜状态置为未取到
morkFs[i].GetMaterialComplete = false;

if (testi % 2 == 0)
if (true)
{
MaterialInfo materialInfo = new MaterialInfo();
materialInfo.Loc = "5";
materialInfo.Qty = 10;
materialInfo.Name = "肉片";
materialInfo.Id = "1232131";
materialOperationQuenes.Enqueue(new MaterialOperation { materialInfo = materialInfo, fryNum = i });
///测试用代码
if (testi % 2 == 0)
{
MaterialInfo materialInfo = new MaterialInfo();
materialInfo.Loc = "5";
materialInfo.Qty = 10;
materialInfo.Name = "肉片";
materialInfo.Id = "1232131";
materialOperationQuenes.Enqueue(new MaterialOperation { materialInfo = materialInfo, fryNum = i });
}
else
{
MaterialInfo materialInfo = new MaterialInfo();
materialInfo.Loc = "24";
materialInfo.Qty = 10;
materialInfo.Name = "青椒";
materialInfo.Id = "1232131";
materialOperationQuenes.Enqueue(new MaterialOperation { materialInfo = materialInfo, fryNum = i });
}
testi++;
}
else
{
MaterialInfo materialInfo = new MaterialInfo();
materialInfo.Loc = "24";
materialInfo.Qty = 10;
materialInfo.Name = "青椒";
materialInfo.Id = "1232131";
materialOperationQuenes.Enqueue(new MaterialOperation { materialInfo = materialInfo, fryNum = i });
if (potActions.MaterialLists != null)
{
foreach (var item in potActions.MaterialLists)
{
//通过ID获取有效的菜品对象
MaterialInfo materialInfo = MaterialSurplusOperation.GetInstance().GetVailedMaterial(item.MaterialId);
if (materialInfo == null)
{
MessageLog.GetInstance.ShowEx($"炒锅{i}获取菜品[{item.MaterialId}]失败,库存不足");
continue;
}

materialOperationQuenes.Enqueue(new MaterialOperation { materialInfo = materialInfo, fryNum = i });
}
}
else
{
MessageLog.GetInstance.ShowEx($"炒锅{i}获取菜品失败,菜品列表为空");
}
}
testi++;

//if (potActions.MaterialLists != null)
//{
// foreach (var item in potActions.MaterialLists)
// {
// //通过ID获取有效的菜品对象
// MaterialInfo materialInfo = MaterialSurplusOperation.GetInstance().GetVailedMaterial(item.MaterialId);
// if (materialInfo == null)
// {
// MessageLog.GetInstance.ShowEx($"炒锅{i}获取菜品[{item.MaterialId}]失败,库存不足");
// continue;
// }

// materialOperationQuenes.Enqueue(new MaterialOperation { materialInfo = materialInfo, fryNum = i });
// }
//}
//else
//{
// MessageLog.GetInstance.ShowEx($"炒锅{i}获取菜品失败,菜品列表为空");
//}

MessageLog.GetInstance.Show(potActions.Actions);
break;
case nameof(StirFryPotActionEnum.开启搅拌):


+ 1
- 1
BPASmartClient.MorkF/ViewModel/MaterialCalibrationViewModel.cs View File

@@ -464,7 +464,7 @@ namespace BPASmartClient.MorkF.ViewModel
break;
case "23":
dicNoMaterialCoordinate.Value.X = TwentyThreeX;
dicNoMaterialCoordinate.Value.Y = TwentyThreeX;
dicNoMaterialCoordinate.Value.Y = TwentyThreeY;
break;
case "24":
dicNoMaterialCoordinate.Value.X = TwentyFourX;


Loading…
Cancel
Save