|
@@ -33,7 +33,7 @@ namespace BPASmartClient.MorkF |
|
|
/// <summary> |
|
|
/// <summary> |
|
|
/// 菜品库while循环最大sleep次数 |
|
|
/// 菜品库while循环最大sleep次数 |
|
|
/// </summary> |
|
|
/// </summary> |
|
|
private const int materialSleepCount = 400; |
|
|
|
|
|
|
|
|
private const int materialSleepCount = 600; |
|
|
|
|
|
|
|
|
/// <summary> |
|
|
/// <summary> |
|
|
/// 菜品库while循环每次sleep时间 |
|
|
/// 菜品库while循环每次sleep时间 |
|
@@ -54,17 +54,17 @@ namespace BPASmartClient.MorkF |
|
|
private const int materialHigh = 34500; |
|
|
private const int materialHigh = 34500; |
|
|
|
|
|
|
|
|
/// <summary> |
|
|
/// <summary> |
|
|
/// |
|
|
|
|
|
|
|
|
/// 菜品库第一层的起始基点,为最下层盒子的中间点 |
|
|
/// </summary> |
|
|
/// </summary> |
|
|
private const int materialOne = 34500; |
|
|
private const int materialOne = 34500; |
|
|
|
|
|
|
|
|
/// <summary> |
|
|
/// <summary> |
|
|
/// |
|
|
|
|
|
|
|
|
/// 菜品库第二层的起始基点,为最下层盒子的中间点 |
|
|
/// </summary> |
|
|
/// </summary> |
|
|
private const int materialTwo = 34500; |
|
|
private const int materialTwo = 34500; |
|
|
|
|
|
|
|
|
/// <summary> |
|
|
/// <summary> |
|
|
/// |
|
|
|
|
|
|
|
|
/// 菜品库第三层的起始基点,为最下层盒子的中间点 |
|
|
/// </summary> |
|
|
/// </summary> |
|
|
private const int materialThree = 34500; |
|
|
private const int materialThree = 34500; |
|
|
|
|
|
|
|
@@ -153,6 +153,8 @@ namespace BPASmartClient.MorkF |
|
|
///初始化菜品库 |
|
|
///初始化菜品库 |
|
|
//FoodLibInit(); |
|
|
//FoodLibInit(); |
|
|
Task2ReadMaterialData(); |
|
|
Task2ReadMaterialData(); |
|
|
|
|
|
|
|
|
|
|
|
//Json<MaterialSurplus>.Read(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <summary> |
|
|
/// <summary> |
|
@@ -900,25 +902,43 @@ namespace BPASmartClient.MorkF |
|
|
/// <returns></returns> |
|
|
/// <returns></returns> |
|
|
public bool GetDistance(int x) |
|
|
public bool GetDistance(int x) |
|
|
{ |
|
|
{ |
|
|
|
|
|
bool ret = true; |
|
|
//是否在第一层菜品库 |
|
|
//是否在第一层菜品库 |
|
|
if (x > 0 && x <= materialLaserHigh) |
|
|
if (x > 0 && x <= materialLaserHigh) |
|
|
{ |
|
|
{ |
|
|
//获取传感器1的距离 |
|
|
//获取传感器1的距离 |
|
|
return GetDistance_1(); |
|
|
|
|
|
|
|
|
ret &= GetDistance_1(); |
|
|
|
|
|
|
|
|
|
|
|
Thread.Sleep(400); |
|
|
|
|
|
|
|
|
|
|
|
//获取传感器1的距离 |
|
|
|
|
|
ret &= GetDistance_1(); |
|
|
} |
|
|
} |
|
|
//是否在第二层菜品库 |
|
|
//是否在第二层菜品库 |
|
|
else if (x > materialLaserHigh && x <= (2 * materialLaserHigh + clapboardLaserHigh)) |
|
|
else if (x > materialLaserHigh && x <= (2 * materialLaserHigh + clapboardLaserHigh)) |
|
|
{ |
|
|
{ |
|
|
//获取传感器1的距离 |
|
|
|
|
|
return GetDistance_2(); |
|
|
|
|
|
|
|
|
//获取传感器2的距离 |
|
|
|
|
|
ret &= GetDistance_2(); |
|
|
|
|
|
|
|
|
|
|
|
Thread.Sleep(400); |
|
|
|
|
|
|
|
|
|
|
|
ret &= GetDistance_2(); |
|
|
} |
|
|
} |
|
|
//是否在第三层菜品库 |
|
|
//是否在第三层菜品库 |
|
|
else if (x > (2 * materialLaserHigh + clapboardLaserHigh) && x <= (3 * materialLaserHigh + 2 * clapboardLaserHigh)) |
|
|
else if (x > (2 * materialLaserHigh + clapboardLaserHigh) && x <= (3 * materialLaserHigh + 2 * clapboardLaserHigh)) |
|
|
{ |
|
|
{ |
|
|
//获取传感器1的距离 |
|
|
|
|
|
return GetDistance_3(); |
|
|
|
|
|
|
|
|
//获取传感器3的距离 |
|
|
|
|
|
ret &= GetDistance_3(); |
|
|
|
|
|
|
|
|
|
|
|
Thread.Sleep(400); |
|
|
|
|
|
|
|
|
|
|
|
ret &= GetDistance_3(); |
|
|
|
|
|
} |
|
|
|
|
|
if (!ret) |
|
|
|
|
|
{ |
|
|
|
|
|
MessageLog.GetInstance.Show($"错误:X轴:{x}获取传感器数据出错"); |
|
|
} |
|
|
} |
|
|
return false; |
|
|
|
|
|
|
|
|
return ret; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public void PawTurnFront() |
|
|
public void PawTurnFront() |
|
@@ -1055,26 +1075,18 @@ namespace BPASmartClient.MorkF |
|
|
/// <param name="x">取菜x轴坐标</param> |
|
|
/// <param name="x">取菜x轴坐标</param> |
|
|
/// <param name="y">取菜y轴坐标</param> |
|
|
/// <param name="y">取菜y轴坐标</param> |
|
|
/// <param name="fryNum">炒锅编号</param> |
|
|
/// <param name="fryNum">炒锅编号</param> |
|
|
public void GetMaterail(int x, int y, int fryNum = 0) |
|
|
|
|
|
|
|
|
public bool GetMaterail(int x, int y, int fryNum) |
|
|
{ |
|
|
{ |
|
|
//设置到抓菜处 |
|
|
//设置到抓菜处 |
|
|
if (!SetArmPosition(x, y)) |
|
|
if (!SetArmPosition(x, y)) |
|
|
{ |
|
|
{ |
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!GetDistance(x)) |
|
|
|
|
|
{ |
|
|
|
|
|
MessageLog.GetInstance.Show("错误:获取传感器数据出错"); |
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
Thread.Sleep(200); |
|
|
|
|
|
|
|
|
|
|
|
if (!GetDistance(x)) |
|
|
if (!GetDistance(x)) |
|
|
{ |
|
|
{ |
|
|
MessageLog.GetInstance.Show("错误:获取传感器数据出错"); |
|
|
MessageLog.GetInstance.Show("错误:获取传感器数据出错"); |
|
|
return; |
|
|
|
|
|
|
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
Thread.Sleep(1000); |
|
|
Thread.Sleep(1000); |
|
@@ -1087,26 +1099,26 @@ namespace BPASmartClient.MorkF |
|
|
if (laserHigh > 29) |
|
|
if (laserHigh > 29) |
|
|
{ |
|
|
{ |
|
|
MessageLog.GetInstance.Show("错误:传感器获取数据大于隔板与传感器之间的距离"); |
|
|
MessageLog.GetInstance.Show("错误:传感器获取数据大于隔板与传感器之间的距离"); |
|
|
return; |
|
|
|
|
|
|
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
int moveX = 0; |
|
|
int moveX = 0; |
|
|
if (LaserDistance2Coordinate(laserHigh, out moveX) != Laser2CoordinateState.MaterialNormal) |
|
|
if (LaserDistance2Coordinate(laserHigh, out moveX) != Laser2CoordinateState.MaterialNormal) |
|
|
{ |
|
|
{ |
|
|
MessageLog.GetInstance.Show("错误:传感器距离转坐标值失败"); |
|
|
MessageLog.GetInstance.Show("错误:传感器距离转坐标值失败"); |
|
|
return; |
|
|
|
|
|
|
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if(x < moveX) |
|
|
if(x < moveX) |
|
|
{ |
|
|
{ |
|
|
MessageLog.GetInstance.Show("错误:传感器距离转坐标值大于当前x轴坐标"); |
|
|
MessageLog.GetInstance.Show("错误:传感器距离转坐标值大于当前x轴坐标"); |
|
|
return; |
|
|
|
|
|
|
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//设置到传感器感应的距离处 |
|
|
//设置到传感器感应的距离处 |
|
|
if (!SetArmPosition(x - moveX, y)) |
|
|
if (!SetArmPosition(x - moveX, y)) |
|
|
{ |
|
|
{ |
|
|
return; |
|
|
|
|
|
|
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
////关闭电磁阀 |
|
|
////关闭电磁阀 |
|
@@ -1117,14 +1129,14 @@ namespace BPASmartClient.MorkF |
|
|
//爪子去1号位抓菜 |
|
|
//爪子去1号位抓菜 |
|
|
if (!PawToPoint1()) |
|
|
if (!PawToPoint1()) |
|
|
{ |
|
|
{ |
|
|
return; |
|
|
|
|
|
|
|
|
return false; |
|
|
} |
|
|
} |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
//设置到该层菜品库最高处 |
|
|
//设置到该层菜品库最高处 |
|
|
if (!SetArmPosition(x - materialHigh, y)) |
|
|
if (!SetArmPosition(x - materialHigh, y)) |
|
|
{ |
|
|
{ |
|
|
return; |
|
|
|
|
|
|
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
////移动前开启电磁阀 |
|
|
////移动前开启电磁阀 |
|
@@ -1135,13 +1147,13 @@ namespace BPASmartClient.MorkF |
|
|
//爪子去2号位放菜 |
|
|
//爪子去2号位放菜 |
|
|
if (!PawToPoint2()) |
|
|
if (!PawToPoint2()) |
|
|
{ |
|
|
{ |
|
|
return; |
|
|
|
|
|
|
|
|
return false; |
|
|
} |
|
|
} |
|
|
#endif |
|
|
#endif |
|
|
////判断炒锅是否可以放盒 |
|
|
////判断炒锅是否可以放盒 |
|
|
//for(int i = 0;materialSleepCount > i && !morkFs[fryIndex].FryPot1_HOBTPut;i++) |
|
|
|
|
|
|
|
|
//for (int i = 0; materialSleepCount > i && !morkFs[fryIndex].FryPot1_HOBTPut; i++) |
|
|
//{ |
|
|
//{ |
|
|
// Thread.Sleep(materialSleepTime); |
|
|
|
|
|
|
|
|
// Thread.Sleep(materialSleepTime); |
|
|
// if (i >= materialSleepCount - 1) |
|
|
// if (i >= materialSleepCount - 1) |
|
|
// { |
|
|
// { |
|
|
// MessageLog.GetInstance.Show("等待炒锅允许放盒超时"); |
|
|
// MessageLog.GetInstance.Show("等待炒锅允许放盒超时"); |
|
@@ -1169,14 +1181,14 @@ namespace BPASmartClient.MorkF |
|
|
//设置到炒锅1出菜处 |
|
|
//设置到炒锅1出菜处 |
|
|
if (!SetArmPosition(x, y)) |
|
|
if (!SetArmPosition(x, y)) |
|
|
{ |
|
|
{ |
|
|
return; |
|
|
|
|
|
|
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
#if true |
|
|
#if true |
|
|
//爪子去3号位放菜 |
|
|
//爪子去3号位放菜 |
|
|
if (!PawToPoint3()) |
|
|
if (!PawToPoint3()) |
|
|
{ |
|
|
{ |
|
|
return; |
|
|
|
|
|
|
|
|
return false; |
|
|
} |
|
|
} |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
@@ -1188,14 +1200,14 @@ namespace BPASmartClient.MorkF |
|
|
//设置到炒锅1出菜处 |
|
|
//设置到炒锅1出菜处 |
|
|
if (!SetArmPosition(x + materialToFryDistance, y)) |
|
|
if (!SetArmPosition(x + materialToFryDistance, y)) |
|
|
{ |
|
|
{ |
|
|
return; |
|
|
|
|
|
|
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
#if true |
|
|
#if true |
|
|
//爪子回到2号位 |
|
|
//爪子回到2号位 |
|
|
if (!PawToPoint2()) |
|
|
if (!PawToPoint2()) |
|
|
{ |
|
|
{ |
|
|
return; |
|
|
|
|
|
|
|
|
return false; |
|
|
} |
|
|
} |
|
|
#endif |
|
|
#endif |
|
|
////关闭电磁阀 |
|
|
////关闭电磁阀 |
|
@@ -1205,6 +1217,62 @@ namespace BPASmartClient.MorkF |
|
|
{ |
|
|
{ |
|
|
morkFs[fryNum].GetMaterialComplete = true; |
|
|
morkFs[fryNum].GetMaterialComplete = true; |
|
|
} |
|
|
} |
|
|
|
|
|
return true; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
|
/// 更新菜品库存量 |
|
|
|
|
|
/// </summary> |
|
|
|
|
|
/// <returns></returns> |
|
|
|
|
|
public bool UpdateMaterialLibraryStock() |
|
|
|
|
|
{ |
|
|
|
|
|
try |
|
|
|
|
|
{ |
|
|
|
|
|
//判断是否初始化 |
|
|
|
|
|
if(!ml_morkf.InitialComplete) |
|
|
|
|
|
{ |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
foreach(var item in MaterialCoordinate.dicNoMaterialCoordinate) |
|
|
|
|
|
{ |
|
|
|
|
|
//设置到抓菜处 |
|
|
|
|
|
if (!SetArmPosition(item.Value.X, item.Value.Y)) |
|
|
|
|
|
{ |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//获取该处的距离 |
|
|
|
|
|
if (!GetDistance(item.Value.X)) |
|
|
|
|
|
{ |
|
|
|
|
|
MessageLog.GetInstance.Show("错误:获取传感器数据出错"); |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Thread.Sleep(1000); |
|
|
|
|
|
|
|
|
|
|
|
//获取传感器的距离 |
|
|
|
|
|
int laserHigh = ml_morkf.LaserDistance; |
|
|
|
|
|
int surplus = 0; |
|
|
|
|
|
//根据距离算出菜品余量 |
|
|
|
|
|
Laser2CoordinateState state = LaserDistance2MaterialCount(laserHigh, out surplus); |
|
|
|
|
|
if (state != Laser2CoordinateState.MaterialNormal || state != Laser2CoordinateState.MaterialEmpty) |
|
|
|
|
|
{ |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//更新菜品余量 |
|
|
|
|
|
if (!MaterialSurplusOperation.GetInstance().UpdateSurplus(item.Key, surplus)) |
|
|
|
|
|
{ |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return true; |
|
|
|
|
|
} |
|
|
|
|
|
catch(Exception ex) |
|
|
|
|
|
{ |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <summary> |
|
|
/// <summary> |
|
@@ -1259,50 +1327,86 @@ namespace BPASmartClient.MorkF |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
|
/// 传感器距离转为菜品数量 |
|
|
|
|
|
/// </summary> |
|
|
|
|
|
/// <param name="distance"></param> |
|
|
|
|
|
/// <param name="x"></param> |
|
|
|
|
|
/// <returns></returns> |
|
|
|
|
|
public Laser2CoordinateState LaserDistance2MaterialCount(int distance, out int count) |
|
|
|
|
|
{ |
|
|
|
|
|
count = 0; |
|
|
|
|
|
try |
|
|
|
|
|
{ |
|
|
|
|
|
//菜盒放多了 |
|
|
|
|
|
if (distance < 6) |
|
|
|
|
|
{ |
|
|
|
|
|
return Laser2CoordinateState.MaterialOverdo; |
|
|
|
|
|
} |
|
|
|
|
|
else if (distance >= 6 && distance < 10) |
|
|
|
|
|
{ |
|
|
|
|
|
count = 5; |
|
|
|
|
|
return Laser2CoordinateState.MaterialNormal; |
|
|
|
|
|
} |
|
|
|
|
|
else if (distance >= 10 && distance < 14) |
|
|
|
|
|
{ |
|
|
|
|
|
count = 4; |
|
|
|
|
|
return Laser2CoordinateState.MaterialNormal; |
|
|
|
|
|
} |
|
|
|
|
|
else if (distance >= 14 && distance < 19) |
|
|
|
|
|
{ |
|
|
|
|
|
count = 3; |
|
|
|
|
|
return Laser2CoordinateState.MaterialNormal; |
|
|
|
|
|
} |
|
|
|
|
|
else if (distance >= 19 && distance < 23) |
|
|
|
|
|
{ |
|
|
|
|
|
count = 2; |
|
|
|
|
|
return Laser2CoordinateState.MaterialNormal; |
|
|
|
|
|
} |
|
|
|
|
|
else if (distance >= 23 && distance < 28) |
|
|
|
|
|
{ |
|
|
|
|
|
count = 1; |
|
|
|
|
|
return Laser2CoordinateState.MaterialNormal; |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
count = 0; |
|
|
|
|
|
return Laser2CoordinateState.MaterialEmpty; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
catch (Exception ex) |
|
|
|
|
|
{ |
|
|
|
|
|
return Laser2CoordinateState.MaterialUnkown; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/// <summary> |
|
|
/// <summary> |
|
|
/// 获取菜品测试 |
|
|
/// 获取菜品测试 |
|
|
/// </summary> |
|
|
/// </summary> |
|
|
/// <param name="isGet"></param> |
|
|
/// <param name="isGet"></param> |
|
|
private void GetMaterailTest(Coordinate coordinate) |
|
|
|
|
|
|
|
|
private void GetMaterailTest(MaterialOperation materialOperation) |
|
|
{ |
|
|
{ |
|
|
ThreadManage.GetInstance().Start(new Action(() => { |
|
|
ThreadManage.GetInstance().Start(new Action(() => { |
|
|
//int x1 = 0, x2 = 0, y = 0; |
|
|
|
|
|
|
|
|
|
|
|
//if (getNum % 2 == 0) |
|
|
|
|
|
//{ |
|
|
|
|
|
// x2 = 35000; |
|
|
|
|
|
// y = 82000; |
|
|
|
|
|
|
|
|
|
|
|
//} |
|
|
|
|
|
//else if (getNum % 2 == 1) |
|
|
|
|
|
//{ |
|
|
|
|
|
// x2 = 35000; |
|
|
|
|
|
// y = 9000; |
|
|
|
|
|
//} |
|
|
|
|
|
//else |
|
|
|
|
|
//{ |
|
|
|
|
|
// MessageLog.GetInstance.Show("菜品库无效操作"); |
|
|
|
|
|
// return; |
|
|
|
|
|
//} |
|
|
|
|
|
|
|
|
bool ret = false; |
|
|
try |
|
|
try |
|
|
{ |
|
|
{ |
|
|
|
|
|
Coordinate myCoordinate = new Coordinate(); |
|
|
|
|
|
//获取坐标,根据菜品的位置信息 |
|
|
|
|
|
if (!NoMaterial2Coordinate(materialOperation.materialInfo.Loc, out myCoordinate)) |
|
|
|
|
|
{ |
|
|
|
|
|
MessageLog.GetInstance.Show($"炒锅{materialOperation.fryNum}获取菜品[{materialOperation.materialInfo.Name}]失败,找不到对应位置"); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
lock (lock_Materail) |
|
|
lock (lock_Materail) |
|
|
{ |
|
|
{ |
|
|
ml_morkf.MaterailIsWorking = true; |
|
|
ml_morkf.MaterailIsWorking = true; |
|
|
} |
|
|
} |
|
|
//取菜操作 |
|
|
//取菜操作 |
|
|
GetMaterail(coordinate.X, coordinate.Y); |
|
|
|
|
|
|
|
|
|
|
|
////机械臂回原点 |
|
|
|
|
|
//if (!SetArmPosition(0, 0)) |
|
|
|
|
|
//{ |
|
|
|
|
|
// MessageLog.GetInstance.Show("菜品库[机械臂操作失败]"); |
|
|
|
|
|
// return; |
|
|
|
|
|
//} |
|
|
|
|
|
|
|
|
ret =GetMaterail(myCoordinate.X, myCoordinate.Y, materialOperation.fryNum); |
|
|
} |
|
|
} |
|
|
catch (Exception ex) |
|
|
catch (Exception ex) |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
ret = false; |
|
|
} |
|
|
} |
|
|
finally |
|
|
finally |
|
|
{ |
|
|
{ |
|
@@ -1310,6 +1414,11 @@ namespace BPASmartClient.MorkF |
|
|
{ |
|
|
{ |
|
|
ml_morkf.MaterailIsWorking = false; |
|
|
ml_morkf.MaterailIsWorking = false; |
|
|
} |
|
|
} |
|
|
|
|
|
if (ret == true) |
|
|
|
|
|
{ |
|
|
|
|
|
//指定位置菜品减一 |
|
|
|
|
|
MaterialSurplusOperation.GetInstance().ReduceSurplus(materialOperation.materialInfo.Loc); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
}), $"菜品库操作"); |
|
|
}), $"菜品库操作"); |
|
@@ -1469,48 +1578,52 @@ namespace BPASmartClient.MorkF |
|
|
Thread.Sleep(200); |
|
|
Thread.Sleep(200); |
|
|
} |
|
|
} |
|
|
//倒菜 |
|
|
//倒菜 |
|
|
public void OutFood(int num) |
|
|
|
|
|
|
|
|
public void OutFood(int num,bool isMaterial = false) |
|
|
{ |
|
|
{ |
|
|
if (!morkFs.ContainsKey(num)) |
|
|
if (!morkFs.ContainsKey(num)) |
|
|
{ |
|
|
{ |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
int i = 0; |
|
|
int i = 0; |
|
|
//判断是否完成取菜 |
|
|
|
|
|
for (i = 0; i < sleepCount * 2 && !morkFs[num].GetMaterialComplete; i++) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(isMaterial) |
|
|
{ |
|
|
{ |
|
|
if (i == 3) |
|
|
|
|
|
|
|
|
//判断是否完成取菜 |
|
|
|
|
|
for (i = 0; i < materialSleepCount && !morkFs[num].GetMaterialComplete; i++) |
|
|
{ |
|
|
{ |
|
|
//停止搅拌 |
|
|
|
|
|
StopStir(num); |
|
|
|
|
|
//火力设置为2档 |
|
|
|
|
|
SetFire(new List<int> { 2 }, num); |
|
|
|
|
|
|
|
|
if (i == 10) |
|
|
|
|
|
{ |
|
|
|
|
|
//停止搅拌 |
|
|
|
|
|
StopStir(num); |
|
|
|
|
|
//火力设置为2档 |
|
|
|
|
|
SetFire(new List<int> { 2 }, num); |
|
|
|
|
|
} |
|
|
|
|
|
Thread.Sleep(materialSleepTime); |
|
|
|
|
|
if (i >= materialSleepCount - 1) |
|
|
|
|
|
{ |
|
|
|
|
|
MessageLog.GetInstance.Show($"炒锅{num}倒菜超时:未能等到取菜完成"); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
Thread.Sleep(sleepTime); |
|
|
|
|
|
if (i >= sleepCount * 2 - 1) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (i > 9) |
|
|
{ |
|
|
{ |
|
|
MessageLog.GetInstance.Show($"炒锅{num}倒菜超时:未能等到取菜完成"); |
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
//开启搅拌 |
|
|
|
|
|
StartStir(num); |
|
|
|
|
|
//火力设置回原本火力 |
|
|
|
|
|
SetFire(new List<int> { morkFs[num].Fire }, num); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (i > 3) |
|
|
|
|
|
{ |
|
|
|
|
|
//开启搅拌 |
|
|
|
|
|
StartStir(num); |
|
|
|
|
|
//火力设置回原本火力 |
|
|
|
|
|
SetFire(new List<int> { morkFs[num].Fire }, num); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
FirePot_Write("LB3", true, num); |
|
|
FirePot_Write("LB3", true, num); |
|
|
MessageLog.GetInstance.Show("倒菜启动"); |
|
|
MessageLog.GetInstance.Show("倒菜启动"); |
|
|
|
|
|
|
|
|
Thread.Sleep(200); |
|
|
|
|
|
|
|
|
Thread.Sleep(500); |
|
|
|
|
|
|
|
|
for (i = 0; i < sleepCount && !morkFs[num].FryPot1_MaterialIntoPot; i++) |
|
|
|
|
|
|
|
|
for (i = 0; i < materialSleepCount && !morkFs[num].FryPot1_MaterialIntoPot; i++) |
|
|
{ |
|
|
{ |
|
|
Thread.Sleep(sleepTime); |
|
|
|
|
|
if (i >= sleepCount - 1) |
|
|
|
|
|
|
|
|
Thread.Sleep(materialSleepTime); |
|
|
|
|
|
if (i >= materialSleepCount - 1) |
|
|
{ |
|
|
{ |
|
|
MessageLog.GetInstance.Show($"炒锅{num}倒菜超时"); |
|
|
MessageLog.GetInstance.Show($"炒锅{num}倒菜超时"); |
|
|
} |
|
|
} |
|
@@ -1519,6 +1632,7 @@ namespace BPASmartClient.MorkF |
|
|
FirePot_Write("LB3", false, num); |
|
|
FirePot_Write("LB3", false, num); |
|
|
Thread.Sleep(200); |
|
|
Thread.Sleep(200); |
|
|
MessageLog.GetInstance.Show("倒菜完成"); |
|
|
MessageLog.GetInstance.Show("倒菜完成"); |
|
|
|
|
|
morkFs[num].GetMaterialComplete = false; |
|
|
} |
|
|
} |
|
|
//搅拌臂去原点位 |
|
|
//搅拌臂去原点位 |
|
|
public void StirArmGoOrigin(int num) |
|
|
public void StirArmGoOrigin(int num) |
|
@@ -1645,7 +1759,17 @@ namespace BPASmartClient.MorkF |
|
|
FirePot_Write("LB8", true, num); |
|
|
FirePot_Write("LB8", true, num); |
|
|
Thread.Sleep(200); |
|
|
Thread.Sleep(200); |
|
|
} |
|
|
} |
|
|
#endregion |
|
|
|
|
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
|
|
private static object saveMaterialLock = new object(); |
|
|
|
|
|
private void SaveMaterialData() |
|
|
|
|
|
{ |
|
|
|
|
|
lock(saveMaterialLock) |
|
|
|
|
|
{ |
|
|
|
|
|
Json<MaterialSurplus>.Data = MaterialSurplusOperation.GetInstance().materialSurplus; |
|
|
|
|
|
Json<MaterialSurplus>.Save(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
bool isInitialArrive = false; |
|
|
bool isInitialArrive = false; |
|
|
|
|
|
|
|
@@ -1698,6 +1822,22 @@ namespace BPASmartClient.MorkF |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
if(stirFry.stirFrymessage.materials.Count > 0) |
|
|
|
|
|
{ |
|
|
|
|
|
MaterialSurplusOperation.GetInstance().UpdateSurplusAll(stirFry.stirFrymessage.materials); |
|
|
|
|
|
//foreach (var item in stirFry.stirFrymessage.materials) |
|
|
|
|
|
//{ |
|
|
|
|
|
// MaterialSurplusOperation.GetInstance().materialSurplus.dicSurplus.Add(new MaterialInfo |
|
|
|
|
|
// { |
|
|
|
|
|
// Id = item.Id, |
|
|
|
|
|
// Key = item.Key, |
|
|
|
|
|
// Name = item.Name, |
|
|
|
|
|
// Loc = item.Loc, |
|
|
|
|
|
// Qty = item.Qty, |
|
|
|
|
|
// }); |
|
|
|
|
|
//} |
|
|
|
|
|
SaveMaterialData(); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
MessageLog.GetInstance.Show("接收到小炒流程信息"); |
|
|
MessageLog.GetInstance.Show("接收到小炒流程信息"); |
|
@@ -2005,22 +2145,41 @@ namespace BPASmartClient.MorkF |
|
|
case nameof(StirFryPotActionEnum.取原料): |
|
|
case nameof(StirFryPotActionEnum.取原料): |
|
|
//炒锅取菜状态置为未取到 |
|
|
//炒锅取菜状态置为未取到 |
|
|
morkFs[i].GetMaterialComplete = false; |
|
|
morkFs[i].GetMaterialComplete = false; |
|
|
if(getMaterailNum == 0) |
|
|
|
|
|
|
|
|
if(potActions.MaterialLists != null) |
|
|
{ |
|
|
{ |
|
|
if (NoMaterial2Coordinate("A2", out myCoordinate)) |
|
|
|
|
|
|
|
|
foreach (var item in potActions.MaterialLists) |
|
|
{ |
|
|
{ |
|
|
materialOperationQuenes.Enqueue(new MaterialOperation() { fryNum = i, coordinate = myCoordinate }); |
|
|
|
|
|
getMaterailNum++; |
|
|
|
|
|
|
|
|
//通过ID获取有效的菜品对象 |
|
|
|
|
|
MaterialInfo materialInfo = MaterialSurplusOperation.GetInstance().GetVailedMaterial(item.MaterialId); |
|
|
|
|
|
if (materialInfo == null) |
|
|
|
|
|
{ |
|
|
|
|
|
MessageLog.GetInstance.Show($"炒锅{i}获取菜品[{materialInfo.Name}]失败,库存不足"); |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
materialOperationQuenes.Enqueue(new MaterialOperation { materialInfo = materialInfo, fryNum = i }); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
else if(getMaterailNum == 1) |
|
|
|
|
|
|
|
|
else |
|
|
{ |
|
|
{ |
|
|
if (NoMaterial2Coordinate("B2", out myCoordinate)) |
|
|
|
|
|
{ |
|
|
|
|
|
materialOperationQuenes.Enqueue(new MaterialOperation() { fryNum = i, coordinate = myCoordinate }); |
|
|
|
|
|
getMaterailNum++; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
MessageLog.GetInstance.Show($"炒锅{i}获取菜品失败,菜品列表为空"); |
|
|
} |
|
|
} |
|
|
|
|
|
//if(getMaterailNum == 0) |
|
|
|
|
|
//{ |
|
|
|
|
|
// if (NoMaterial2Coordinate(MaterialCoordinate.MLNumberList[1], out myCoordinate)) |
|
|
|
|
|
// { |
|
|
|
|
|
// materialOperationQuenes.Enqueue(new MaterialOperation() { fryNum = i, coordinate = myCoordinate }); |
|
|
|
|
|
// getMaterailNum++; |
|
|
|
|
|
// } |
|
|
|
|
|
//} |
|
|
|
|
|
//else if(getMaterailNum == 1) |
|
|
|
|
|
//{ |
|
|
|
|
|
// if (NoMaterial2Coordinate(MaterialCoordinate.MLNumberList[4], out myCoordinate)) |
|
|
|
|
|
// { |
|
|
|
|
|
// materialOperationQuenes.Enqueue(new MaterialOperation() { fryNum = i, coordinate = myCoordinate }); |
|
|
|
|
|
// getMaterailNum++; |
|
|
|
|
|
// } |
|
|
|
|
|
//} |
|
|
MessageLog.GetInstance.Show(potActions.Actions); |
|
|
MessageLog.GetInstance.Show(potActions.Actions); |
|
|
break; |
|
|
break; |
|
|
case nameof(StirFryPotActionEnum.开启搅拌): |
|
|
case nameof(StirFryPotActionEnum.开启搅拌): |
|
@@ -2047,7 +2206,7 @@ namespace BPASmartClient.MorkF |
|
|
MessageLog.GetInstance.Show(potActions.Actions); |
|
|
MessageLog.GetInstance.Show(potActions.Actions); |
|
|
break; |
|
|
break; |
|
|
case nameof(StirFryPotActionEnum.道菜启动): |
|
|
case nameof(StirFryPotActionEnum.道菜启动): |
|
|
OutFood(i); |
|
|
|
|
|
|
|
|
OutFood(i, true); |
|
|
break; |
|
|
break; |
|
|
case nameof(StirFryPotActionEnum.炒制菜品): |
|
|
case nameof(StirFryPotActionEnum.炒制菜品): |
|
|
Thread.Sleep(potActions.During * 1000); |
|
|
Thread.Sleep(potActions.During * 1000); |
|
@@ -2099,8 +2258,6 @@ namespace BPASmartClient.MorkF |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private int testNum = 0; |
|
|
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
/// <summary> |
|
|
/// 菜品库主流程 |
|
|
/// 菜品库主流程 |
|
|
/// </summary> |
|
|
/// </summary> |
|
@@ -2114,13 +2271,13 @@ namespace BPASmartClient.MorkF |
|
|
//待菜品库操作列出队列 |
|
|
//待菜品库操作列出队列 |
|
|
if (materialOperationQuenes.TryDequeue(out var res)) |
|
|
if (materialOperationQuenes.TryDequeue(out var res)) |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
ml_morkf.MaterailIsWorking = true; |
|
|
ml_morkf.MaterailIsWorking = true; |
|
|
MessageLog.GetInstance.Show("开始操作菜品库"); |
|
|
MessageLog.GetInstance.Show("开始操作菜品库"); |
|
|
//ThreadManage.GetInstance().Start(new Action(()=>{ |
|
|
//ThreadManage.GetInstance().Start(new Action(()=>{ |
|
|
// GetMaterail(res.x, res.y, res.fryNum); |
|
|
// GetMaterail(res.x, res.y, res.fryNum); |
|
|
//}),"菜品库操作"); |
|
|
//}),"菜品库操作"); |
|
|
GetMaterailTest(res.coordinate); |
|
|
|
|
|
testNum++; |
|
|
|
|
|
|
|
|
GetMaterailTest(res); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@@ -2194,9 +2351,9 @@ namespace BPASmartClient.MorkF |
|
|
|
|
|
|
|
|
try |
|
|
try |
|
|
{ |
|
|
{ |
|
|
if(dicNoMaterialCoordinate.ContainsKey(no)) |
|
|
|
|
|
|
|
|
if(MaterialCoordinate.dicNoMaterialCoordinate.ContainsKey(no)) |
|
|
{ |
|
|
{ |
|
|
coordinate = dicNoMaterialCoordinate[no]; |
|
|
|
|
|
|
|
|
coordinate = MaterialCoordinate.dicNoMaterialCoordinate[no]; |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
else |
|
|
else |
|
@@ -2214,43 +2371,6 @@ namespace BPASmartClient.MorkF |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
|
/// 每个取菜点的编号与坐标字典 |
|
|
|
|
|
/// </summary> |
|
|
|
|
|
private static Dictionary<string, Coordinate> dicNoMaterialCoordinate { get; set; } = new Dictionary<string, Coordinate>() |
|
|
|
|
|
{ |
|
|
|
|
|
{"A1",new Coordinate(){ X = 34500,Y=0} }, |
|
|
|
|
|
{"A2",new Coordinate(){ X = 34500,Y=9000} }, |
|
|
|
|
|
{"A3",new Coordinate(){ X = 34500,Y=0} }, |
|
|
|
|
|
{"B1",new Coordinate(){ X = 34500,Y=0} }, |
|
|
|
|
|
{"B2",new Coordinate(){ X = 34500,Y=83000} }, |
|
|
|
|
|
{"B3",new Coordinate(){ X = 34500,Y=0} }, |
|
|
|
|
|
{"C1",new Coordinate(){ X = 34500,Y=0} }, |
|
|
|
|
|
{"C2",new Coordinate(){ X = 34500,Y=0} }, |
|
|
|
|
|
{"C3",new Coordinate(){ X = 34500,Y=0} }, |
|
|
|
|
|
{"D1",new Coordinate(){ X = 0,Y=0} }, |
|
|
|
|
|
{"D2",new Coordinate(){ X = 0,Y=0} }, |
|
|
|
|
|
{"D3",new Coordinate(){ X = 0,Y=0} }, |
|
|
|
|
|
{"E1",new Coordinate(){ X = 0,Y=0} }, |
|
|
|
|
|
{"E2",new Coordinate(){ X = 0,Y=0} }, |
|
|
|
|
|
{"E3",new Coordinate(){ X = 0,Y=0} }, |
|
|
|
|
|
{"F1",new Coordinate(){ X = 0,Y=0} }, |
|
|
|
|
|
{"F2",new Coordinate(){ X = 0,Y=0} }, |
|
|
|
|
|
{"F3",new Coordinate(){ X = 0,Y=0} }, |
|
|
|
|
|
{"G1",new Coordinate(){ X = 0,Y=0} }, |
|
|
|
|
|
{"G2",new Coordinate(){ X = 0,Y=0} }, |
|
|
|
|
|
{"G3",new Coordinate(){ X = 0,Y=0} }, |
|
|
|
|
|
{"H1",new Coordinate(){ X = 0,Y=0} }, |
|
|
|
|
|
{"H2",new Coordinate(){ X = 0,Y=0} }, |
|
|
|
|
|
{"H3",new Coordinate(){ X = 0,Y=0} }, |
|
|
|
|
|
{"I1",new Coordinate(){ X = 0,Y=0} }, |
|
|
|
|
|
{"I2",new Coordinate(){ X = 0,Y=0} }, |
|
|
|
|
|
{"I3",new Coordinate(){ X = 0,Y=0} }, |
|
|
|
|
|
{"J1",new Coordinate(){ X = 0,Y=0} }, |
|
|
|
|
|
{"J2",new Coordinate(){ X = 0,Y=0} }, |
|
|
|
|
|
{"J3",new Coordinate(){ X = 0,Y=0} }, |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
public enum Laser2CoordinateState |
|
|
public enum Laser2CoordinateState |
|
|
{ |
|
|
{ |
|
|
MaterialOverdo = 0,//菜品过量 |
|
|
MaterialOverdo = 0,//菜品过量 |
|
|