@@ -175,6 +175,9 @@ namespace BPASmartClient.MorkF
MaterialCoordinate.GetInstance().frying1 = materialCoordinate.frying1;
MaterialCoordinate.GetInstance().frying1 = materialCoordinate.frying1;
MaterialCoordinate.GetInstance().frying2 = materialCoordinate.frying2;
MaterialCoordinate.GetInstance().frying2 = materialCoordinate.frying2;
MaterialCoordinate.GetInstance().materialHeight = materialCoordinate.materialHeight;
MaterialCoordinate.GetInstance().materialHeight = materialCoordinate.materialHeight;
MaterialCoordinate.GetInstance().MaterialOneX = materialCoordinate.MaterialOneX;
MaterialCoordinate.GetInstance().MaterialTwoX = materialCoordinate.MaterialTwoX;
MaterialCoordinate.GetInstance().MaterialThreeX = materialCoordinate.MaterialThreeX;
}
}
////菜品库编号与坐标系对象存储
////菜品库编号与坐标系对象存储
//SaveMaterialCoordinate();
//SaveMaterialCoordinate();
@@ -1291,7 +1294,7 @@ namespace BPASmartClient.MorkF
return false;
return false;
}
}
if(x < moveX)
if (x < moveX)
{
{
MessageLog.GetInstance.ShowEx("错误:传感器距离转坐标值大于当前x轴坐标");
MessageLog.GetInstance.ShowEx("错误:传感器距离转坐标值大于当前x轴坐标");
return false;
return false;
@@ -1315,7 +1318,6 @@ namespace BPASmartClient.MorkF
}
}
#endif
#endif
//伸出爪子
//伸出爪子
PawExtend();
PawExtend();
@@ -1323,13 +1325,42 @@ namespace BPASmartClient.MorkF
Electromagnetism(new List<bool> { false });
Electromagnetism(new List<bool> { false });
Thread.Sleep(500);
Thread.Sleep(500);
//菜品盒子出菜品库,往上移动一个盒子的距离
if (!SetArmPosition(x - moveX - materialBoxHeight, y))
int heightDifferent = 0;
//根据x轴所在坐标系,计算高度差。
if( (x > 0 && x <= MaterialCoordinate.GetInstance().dicNoMaterialCoordinate["1"].X)&&
(MaterialCoordinate.GetInstance().MaterialOneX > 0 && MaterialCoordinate.GetInstance().MaterialOneX < x))
{
//菜品盒子出菜品库,往上移动一个盒子的距离
if (!SetArmPosition(MaterialCoordinate.GetInstance().MaterialOneX, y))
{
return false;
}
}
else if( (x <= MaterialCoordinate.GetInstance().dicNoMaterialCoordinate["10"].X && x > MaterialCoordinate.GetInstance().dicNoMaterialCoordinate["1"].X)&&
(MaterialCoordinate.GetInstance().MaterialTwoX > 0 && MaterialCoordinate.GetInstance().MaterialTwoX < x))
{
//菜品盒子出菜品库,往上移动一个盒子的距离
if (!SetArmPosition(MaterialCoordinate.GetInstance().MaterialTwoX, y))
{
return false;
}
}
else if ((x > MaterialCoordinate.GetInstance().dicNoMaterialCoordinate["10"].X && x <= MaterialCoordinate.GetInstance().dicNoMaterialCoordinate["20"].X) &&
(MaterialCoordinate.GetInstance().MaterialThreeX > 0 && MaterialCoordinate.GetInstance().MaterialThreeX < x))
{
//菜品盒子出菜品库,往上移动一个盒子的距离
if (!SetArmPosition(MaterialCoordinate.GetInstance().MaterialThreeX, y))
{
return false;
}
}
else
{
{
MessageLog.GetInstance.ShowEx("错误:未设置当前菜品库出菜位置");
return false;
return false;
}
}
#if true
#if true
//爪子去2号位放菜
//爪子去2号位放菜
if (!PawToPoint2())
if (!PawToPoint2())
@@ -1337,16 +1368,19 @@ namespace BPASmartClient.MorkF
return false;
return false;
}
}
#endif
#endif
////判断炒锅是否可以放盒
//for (int i = 0; materialSleepCount > i && !morkFs[fryIndex].FryPot1_HOBTPut; i++)
//{
// Thread.Sleep(materialSleepTime);
// if (i >= materialSleepCount - 1)
// {
// MessageLog.GetInstance.Show("等待炒锅允许放盒超时");
// return;
// }
//}
//收缩爪子
PawShrink();
//判断炒锅是否可以放盒
for (int i = 0; materialSleepCount > i && !morkFs[fryIndex].FryPot1_HOBTPut; i++)
{
Thread.Sleep(materialSleepTime);
if (i >= materialSleepCount - 1)
{
MessageLog.GetInstance.Show("等待炒锅允许放盒超时");
return false;
}
}
//关闭启磁吸
//关闭启磁吸
MagnetOff(fryNum);
MagnetOff(fryNum);
@@ -1379,6 +1413,9 @@ namespace BPASmartClient.MorkF
}
}
#endif
#endif
//伸出爪子
PawExtend();
//开启磁吸
//开启磁吸
MagnetOn(fryNum);
MagnetOn(fryNum);
@@ -1388,15 +1425,15 @@ namespace BPASmartClient.MorkF
Electromagnetism(new List<bool> { true });
Electromagnetism(new List<bool> { true });
Thread.Sleep(300);
Thread.Sleep(300);
//收缩爪子
PawShrink();
//设置到炒锅i出菜处
//设置到炒锅i出菜处
if (!SetArmPosition(x + materialToFryDistance, y))
if (!SetArmPosition(x + materialToFryDistance, y))
{
{
return false;
return false;
}
}
//收缩爪子
PawShrink();
#if true
#if true
//爪子回到2号位
//爪子回到2号位
if (!PawToPoint2())
if (!PawToPoint2())
@@ -1404,6 +1441,9 @@ namespace BPASmartClient.MorkF
return false;
return false;
}
}
#endif
#endif
//开启电磁阀
Electromagnetism(new List<bool> { false });
if (morkFs.ContainsKey(fryNum))
if (morkFs.ContainsKey(fryNum))
{
{
morkFs[fryNum].GetMaterialComplete = true;
morkFs[fryNum].GetMaterialComplete = true;
@@ -1458,7 +1498,7 @@ namespace BPASmartClient.MorkF
int surplus = 0;
int surplus = 0;
//根据距离算出菜品余量
//根据距离算出菜品余量
Laser2CoordinateState state = LaserDistance2MaterialCount(laserHigh, out surplus);
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;
return false;
@@ -1488,136 +1528,47 @@ namespace BPASmartClient.MorkF
public Laser2CoordinateState LaserDistance2Coordinate(int distance, int x, out int x_high)
public Laser2CoordinateState LaserDistance2Coordinate(int distance, int x, out int x_high)
{
{
x_high = 0;
x_high = 0;
int heightDifferent = 0;
// int heightDifferent = 0;
int boxCount = 0;
int boxCount = 0;
//传感器高度小于6,无法移出,菜品库满
if (distance < 60)
{
MessageLog.GetInstance.ShowEx("错误:传感器距离不满足出菜高度");
return Laser2CoordinateState.MaterialOverdo;
}
//// 传感器高度小于6,无法移出,菜品库满
// if (distance < 60)
// {
// MessageLog.GetInstance.ShowEx("错误:传感器距离不满足出菜高度");
// return Laser2CoordinateState.MaterialOverdo;
// }
try
try
{
{
if (x > 0 && x <= MaterialCoordinate.GetInstance().dicNoMaterialCoordinate["1"].X)
{
heightDifferent = MaterialCoordinate.GetInstance().distance_1 - distance;
////菜盒放多了
//if (heightDifferent < 10)
//{
// return Laser2CoordinateState.MaterialOverdo;
//}
//else if (distance >= 10 && distance < 15)
//{
// x_high = 11441;
// return Laser2CoordinateState.MaterialNormal;
//}
//else if (distance >= 15 && distance < 19)
//{
// x_high = 5720;
// return Laser2CoordinateState.MaterialNormal;
//}
//else if (distance >= 19 && distance < 23)
//{
// x_high = 0;
// return Laser2CoordinateState.MaterialNormal;
//}
//else
//{
// return Laser2CoordinateState.MaterialEmpty;
//}
}
else if (x <= MaterialCoordinate.GetInstance().dicNoMaterialCoordinate["10"].X && x > MaterialCoordinate.GetInstance().dicNoMaterialCoordinate["1"].X)
{
heightDifferent = MaterialCoordinate.GetInstance().distance_2 - distance;
////菜盒放多了
//if (distance < 6)
//{
// return Laser2CoordinateState.MaterialOverdo;
//}
//else if (distance >= 6 && distance < 10)
//{
// x_high = 24882;
// return Laser2CoordinateState.MaterialNormal;
//}
//else if (distance >= 10 && distance < 15)
//{
// x_high = 18661;
// return Laser2CoordinateState.MaterialNormal;
//}
//else if (distance >= 15 && distance < 19)
//{
// x_high = 12441;
// return Laser2CoordinateState.MaterialNormal;
//}
//else if (distance >= 19 && distance < 23)
//{
// x_high = 6220;
// return Laser2CoordinateState.MaterialNormal;
//}
//else if (distance >= 23 && distance < 28)
//{
// x_high = 0;
// return Laser2CoordinateState.MaterialNormal;
//}
//else
//{
// return Laser2CoordinateState.MaterialEmpty;
//}
}
else if (x > MaterialCoordinate.GetInstance().dicNoMaterialCoordinate["10"].X && x <= MaterialCoordinate.GetInstance().dicNoMaterialCoordinate["20"].X)
{
heightDifferent = MaterialCoordinate.GetInstance().distance_3 - distance;
////菜盒放多了
//if (distance < 7)
//{
// return Laser2CoordinateState.MaterialOverdo;
//}
//else if (distance >= 7 && distance < 12)
//{
// x_high = 24882;
// return Laser2CoordinateState.MaterialNormal;
//}
//else if (distance >= 12 && distance < 17)
//{
// x_high = 18661;
// return Laser2CoordinateState.MaterialNormal;
//}
//else if (distance >= 17 && distance < 21)
//{
// x_high = 12441;
// return Laser2CoordinateState.MaterialNormal;
//}
//else if (distance >= 21 && distance < 26)
//{
// x_high = 6220;
// return Laser2CoordinateState.MaterialNormal;
//}
//else if (distance >= 26 && distance < 30)
//{
// x_high = 0;
// return Laser2CoordinateState.MaterialNormal;
//}
//else
//{
// return Laser2CoordinateState.MaterialEmpty;
//}
}
else
{
return Laser2CoordinateState.MaterialOverdo;
}
//盒子高度为45,但是需要考虑到误差,因此除以50
boxCount = heightDifferent / 50;
if (heightDifferent <= 20)
////根据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)
{
{
MessageLog.GetInstance.ShowEx("错误:菜品量为空");
return Laser2CoordinateState.MaterialEmpty ;
//盒子高度计算除去起始位置的那个盒子
x_high = (boxCount - 1) * materialBoxHeight;
}
}
//盒子高度计算除去起始位置的那个盒子
x_high = boxCount * materialBoxHeight;
return Laser2CoordinateState.MaterialNormal;
return laser2CoordinateState;
}
}
catch(Exception ex)
catch(Exception ex)
@@ -1632,46 +1583,94 @@ namespace BPASmartClient.MorkF
/// <param name="distance"></param>
/// <param name="distance"></param>
/// <param name="x"></param>
/// <param name="x"></param>
/// <returns></returns>
/// <returns></returns>
public Laser2CoordinateState LaserDistance2MaterialCount(int distance, out int count)
public Laser2CoordinateState LaserDistance2MaterialCount(int distance, int x, out int count)
{
{
count = 0;
count = 0;
try
try
{
{
//菜盒放多了
if (distance < 6 )
//传感器高度小于80mm,无法移出,菜品库满
if (distance < 80 )
{
{
MessageLog.GetInstance.ShowEx("错误:传感器距离不满足出菜高度");
return Laser2CoordinateState.MaterialOverdo;
return Laser2CoordinateState.MaterialOverdo;
}
}
else if (distance >= 6 && distance < 10)
int heightDifferent = 0;
//根据x轴所在坐标系,计算高度差。
if (x > 0 && x <= MaterialCoordinate.GetInstance().dicNoMaterialCoordinate["1"].X)
{
{
count = 5;
return Laser2CoordinateState.MaterialNormal;
heightDifferent = MaterialCoordinate.GetInstance().distance_1 - distance;
}
}
else if (distance >= 10 && distance < 14 )
else if (x <= MaterialCoordinate.GetInstance().dicNoMaterialCoordinate["10"].X && x > MaterialCoordinate.GetInstance().dicNoMaterialCoordinate["1"].X )
{
{
count = 4;
return Laser2CoordinateState.MaterialNormal;
heightDifferent = MaterialCoordinate.GetInstance().distance_2 - distance;
}
}
else if (distance >= 14 && distance < 19 )
else if (x > MaterialCoordinate.GetInstance().dicNoMaterialCoordinate["10"].X && x <= MaterialCoordinate.GetInstance().dicNoMaterialCoordinate["20"].X )
{
{
count = 3;
return Laser2CoordinateState.MaterialNormal;
heightDifferent = MaterialCoordinate.GetInstance().distance_3 - distance;
}
else
{
return Laser2CoordinateState.MaterialOverdo;
}
}
else if (distance >= 19 && distance < 23)
//盒子高度为45,但是需要考虑到误差,不足35,则认为为空
int boxCount = heightDifferent / 35;
count = boxCount;
if (count == 0)
{
{
count = 2;
return Laser2CoordinateState.MaterialNormal;
MessageLog.GetInstance.Show("菜品库为空") ;
return Laser2CoordinateState.MaterialEmpty ;
}
}
else if (distance >= 23 && distance < 28 )
else if(count > 6 )
{
{
count = 1 ;
return Laser2CoordinateState.MaterialNormal ;
MessageLog.GetInstance.Show("菜品库数量超量") ;
return Laser2CoordinateState.MaterialOverdo ;
}
}
else
else
{
{
count = 0;
return Laser2CoordinateState.MaterialEmpty;
return Laser2CoordinateState.MaterialNormal;
}
}
//if (heightDifferent <= 20)
//{
// MessageLog.GetInstance.ShowEx("错误:菜品量为空");
// return Laser2CoordinateState.MaterialEmpty;
//}
////菜盒放多了
//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)
catch (Exception ex)
{
{
@@ -1884,7 +1883,9 @@ namespace BPASmartClient.MorkF
}
}
int i = 0;
int i = 0;
if(isMaterial)
MessageLog.GetInstance.Show("倒菜启动开始");
if (isMaterial)
{
{
//判断是否完成取菜
//判断是否完成取菜
for (i = 0; i < materialSleepCount && !morkFs[num].GetMaterialComplete; i++)
for (i = 0; i < materialSleepCount && !morkFs[num].GetMaterialComplete; i++)
@@ -2341,7 +2342,7 @@ namespace BPASmartClient.MorkF
//遍历炒锅,找到合适、空闲的炒锅
//遍历炒锅,找到合适、空闲的炒锅
for(int i = 0;i<morkFs.Count;i++)
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)//炒锅在自动状态&&初始化完成&&菜品库初始化&&是否在炒菜中
!morkFs[i].FryWorking)//炒锅在自动状态&&初始化完成&&菜品库初始化&&是否在炒菜中
{
{
Thread.Sleep(5000);
Thread.Sleep(5000);
@@ -2464,45 +2465,45 @@ namespace BPASmartClient.MorkF
//炒锅取菜状态置为未取到
//炒锅取菜状态置为未取到
morkFs[i].GetMaterialComplete = false;
morkFs[i].GetMaterialComplete = false;
//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++;
if (potActions.MaterialLists != null)
if (testi % 2 == 0)
{
{
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 });
}
MaterialInfo materialInfo = new MaterialInfo();
materialInfo.Loc = "5";
materialInfo.Qty = 10;
materialInfo.Name = "肉片";
materialInfo.Id = "1232131";
materialOperationQuenes.Enqueue(new MaterialOperation { materialInfo = materialInfo, fryNum = i });
}
}
else
else
{
{
MessageLog.GetInstance.ShowEx($"炒锅{i}获取菜品失败,菜品列表为空");
MaterialInfo materialInfo = new MaterialInfo();
materialInfo.Loc = "24";
materialInfo.Qty = 10;
materialInfo.Name = "青椒";
materialInfo.Id = "1232131";
materialOperationQuenes.Enqueue(new MaterialOperation { materialInfo = materialInfo, fryNum = 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);
MessageLog.GetInstance.Show(potActions.Actions);
break;
break;
case nameof(StirFryPotActionEnum.开启搅拌):
case nameof(StirFryPotActionEnum.开启搅拌):