@@ -57,14 +57,19 @@ namespace BPASmartClient.MorkF | |||
//传感器到菜品库的高度(坐标系) | |||
private const int materialLaserHigh = 34500; | |||
/// <summary> | |||
/// 菜品盒坐标系高度 | |||
/// </summary> | |||
private const int materialBoxHeight = 9500; | |||
//传感器1到菜品库的高度(厘米) | |||
private const int materialLaserHighCM_1 = 29; | |||
private const int materialLaserHighCM_1 = 22; | |||
//传感器2到菜品库的高度(厘米) | |||
private const int materialLaserHighCM_2 = 29; | |||
private const int materialLaserHighCM_2 = 27; | |||
//传感器3到菜品库的高度(厘米) | |||
private const int materialLaserHighCM_3 = 29; | |||
private const int materialLaserHighCM_3 = 31; | |||
/// <summary> | |||
/// 传感器到隔板的距离(坐标系) | |||
@@ -164,6 +169,12 @@ namespace BPASmartClient.MorkF | |||
{ | |||
MaterialCoordinate.GetInstance().dicNoMaterialCoordinate = materialCoordinate.dicNoMaterialCoordinate; | |||
MaterialCoordinate.GetInstance().MLCoordinateList = materialCoordinate.MLCoordinateList; | |||
MaterialCoordinate.GetInstance().distance_1 = materialCoordinate.distance_1; | |||
MaterialCoordinate.GetInstance().distance_2 = materialCoordinate.distance_2; | |||
MaterialCoordinate.GetInstance().distance_3 = materialCoordinate.distance_3; | |||
MaterialCoordinate.GetInstance().frying1 = materialCoordinate.frying1; | |||
MaterialCoordinate.GetInstance().frying2 = materialCoordinate.frying2; | |||
MaterialCoordinate.GetInstance().materialHeight = materialCoordinate.materialHeight; | |||
} | |||
////菜品库编号与坐标系对象存储 | |||
//SaveMaterialCoordinate(); | |||
@@ -555,6 +566,22 @@ namespace BPASmartClient.MorkF | |||
}), "StopStir"); | |||
}), "StopStir"); | |||
ActionManage.GetInstance.Register(new Action(() => | |||
{ | |||
ThreadManage.GetInstance().Start(new Action(() => | |||
{ | |||
MagnetOn(fryIndex); | |||
}), "MagnetOn"); | |||
}), "MagnetOn"); | |||
ActionManage.GetInstance.Register(new Action(() => | |||
{ | |||
ThreadManage.GetInstance().Start(new Action(() => | |||
{ | |||
MagnetOff(fryIndex); | |||
}), "MagnetOff"); | |||
}), "MagnetOff"); | |||
ActionManage.GetInstance.Register(new Action(() => | |||
{ | |||
ThreadManage.GetInstance().Start(new Action(() => | |||
@@ -855,15 +882,15 @@ namespace BPASmartClient.MorkF | |||
/// <param name="o">电磁阀启停:true:启动。false:停止。</param> | |||
public void PawExtend() | |||
{ | |||
//if (!ml_morkf.InitialComplete) | |||
//{ | |||
// MessageLog.GetInstance.ShowEx("爪子伸出错误,菜品库未初始化"); | |||
// return; | |||
//} | |||
if (!ml_morkf.InitialComplete) | |||
{ | |||
MessageLog.GetInstance.ShowEx("爪子伸出错误,菜品库未初始化"); | |||
return; | |||
} | |||
MaterailLibrary_Write("M0.6", true); | |||
//等待爪子伸出延时4s | |||
Thread.Sleep(4200); | |||
Thread.Sleep(6000); | |||
} | |||
/// <summary> | |||
/// 爪子收缩 | |||
@@ -871,15 +898,15 @@ namespace BPASmartClient.MorkF | |||
/// <param name="o">电磁阀启停:true:启动。false:停止。</param> | |||
public void PawShrink() | |||
{ | |||
//if (!ml_morkf.InitialComplete) | |||
//{ | |||
// MessageLog.GetInstance.ShowEx("爪子伸出错误,菜品库未初始化"); | |||
// return; | |||
//} | |||
if (!ml_morkf.InitialComplete) | |||
{ | |||
MessageLog.GetInstance.ShowEx("爪子伸出错误,菜品库未初始化"); | |||
return; | |||
} | |||
MaterailLibrary_Write("M0.7", true); | |||
//等待爪子收缩延时4s | |||
Thread.Sleep(4200); | |||
Thread.Sleep(6000); | |||
} | |||
/// <summary> | |||
/// 电磁阀启停 | |||
@@ -910,6 +937,9 @@ namespace BPASmartClient.MorkF | |||
MessageLog.GetInstance.Show("爪子去到1号位"); | |||
MaterailLibrary_Write("M1.0", true); | |||
Thread.Sleep(500); | |||
for (int i = 0; i < materialSleepCount && !ml_morkf.PawArrivePortOne; i++) | |||
{ | |||
Thread.Sleep(materialSleepTime); | |||
@@ -936,6 +966,9 @@ namespace BPASmartClient.MorkF | |||
MessageLog.GetInstance.Show("爪子去到2号位"); | |||
MaterailLibrary_Write("M1.1", true); | |||
Thread.Sleep(500); | |||
for (int i = 0; i < materialSleepCount && !ml_morkf.PawArrivePortTwo; i++) | |||
{ | |||
Thread.Sleep(materialSleepTime); | |||
@@ -962,6 +995,9 @@ namespace BPASmartClient.MorkF | |||
MessageLog.GetInstance.Show("爪子去到3号位"); | |||
MaterailLibrary_Write("M1.2", true); | |||
Thread.Sleep(500); | |||
for (int i = 0; i < materialSleepCount && !ml_morkf.PawArrivePortThree; i++) | |||
{ | |||
Thread.Sleep(materialSleepTime); | |||
@@ -993,6 +1029,8 @@ namespace BPASmartClient.MorkF | |||
MessageLog.GetInstance.Show("1号测距开启完成"); | |||
MessageLog.GetInstance.Show($"传感器的距离{ml_morkf.LaserDistance}"); | |||
ActionManage.GetInstance.Send("GetDistanceCallBack", new List<string> { "1",ml_morkf.LaserDistance.ToString() });//通知获取测距界面 | |||
return true; | |||
} | |||
public bool GetDistance_2() | |||
@@ -1009,6 +1047,9 @@ namespace BPASmartClient.MorkF | |||
MessageLog.GetInstance.Show("2号测距开启完成"); | |||
MessageLog.GetInstance.Show($"传感器的距离{ml_morkf.LaserDistance}"); | |||
ActionManage.GetInstance.Send("GetDistanceCallBack", new List<string> { "2", ml_morkf.LaserDistance.ToString() });//通知获取测距界面 | |||
return true; | |||
} | |||
public bool GetDistance_3() | |||
@@ -1025,9 +1066,21 @@ namespace BPASmartClient.MorkF | |||
MessageLog.GetInstance.Show("3号测距开启完成"); | |||
MessageLog.GetInstance.Show($"传感器的距离{ml_morkf.LaserDistance}"); | |||
ActionManage.GetInstance.Send("GetDistanceCallBack", new List<string> { "3", ml_morkf.LaserDistance.ToString() });//通知获取测距界面 | |||
return true; | |||
} | |||
/// <summary> | |||
/// 写入传感器距离 | |||
/// </summary> | |||
/// <param name="distance"></param> | |||
public void WriteDistance(int distance) | |||
{ | |||
MaterailLibrary_Write("VW270", distance); | |||
} | |||
/// <summary> | |||
/// 根据x坐标获取传感器距离 | |||
/// </summary> | |||
@@ -1220,24 +1273,27 @@ namespace BPASmartClient.MorkF | |||
//获取传感器的距离,转换成坐标系的点 | |||
int laserHigh = ml_morkf.LaserDistance; | |||
//秦工要求读取后置0 | |||
WriteDistance(0); | |||
MessageLog.GetInstance.Show($"传感器的距离{laserHigh}"); | |||
if (laserHigh > 29) | |||
{ | |||
MessageLog.GetInstance.Show("错误:传感器获取数据大于隔板与传感器之间的距离"); | |||
return false; | |||
} | |||
//if (laserHigh > 29) | |||
//{ | |||
// MessageLog.GetInstance.Show("错误:传感器获取数据大于隔板与传感器之间的距离"); | |||
// return false; | |||
//} | |||
int moveX = 0; | |||
if (LaserDistance2Coordinate(laserHigh, x, out moveX) != Laser2CoordinateState.MaterialNormal) | |||
{ | |||
MessageLog.GetInstance.Show("错误:传感器距离转坐标值失败"); | |||
MessageLog.GetInstance.ShowEx("错误:传感器距离转坐标值失败"); | |||
return false; | |||
} | |||
if(x < moveX) | |||
{ | |||
MessageLog.GetInstance.Show("错误:传感器距离转坐标值大于当前x轴坐标"); | |||
MessageLog.GetInstance.ShowEx("错误:传感器距离转坐标值大于当前x轴坐标"); | |||
return false; | |||
} | |||
@@ -1260,15 +1316,15 @@ namespace BPASmartClient.MorkF | |||
#endif | |||
//伸出爪子 | |||
PawExtend(); | |||
//移动前开启电磁阀 | |||
Electromagnetism(new List<bool> { false }); | |||
Thread.Sleep(500); | |||
//伸出爪子 | |||
PawExtend(); | |||
//设置到该层菜品库最高处 | |||
if (!SetArmPosition(x - materialHigh, y)) | |||
//菜品盒子出菜品库,往上移动一个盒子的距离 | |||
if (!SetArmPosition(x - moveX - materialBoxHeight, y)) | |||
{ | |||
return false; | |||
} | |||
@@ -1300,13 +1356,13 @@ namespace BPASmartClient.MorkF | |||
//根据炒锅不同设置不同的出菜处 | |||
if (fryNum % 2 == 0) | |||
{ | |||
x = materialPutPositionXFry1; | |||
y = materialPutPositionYFry1; | |||
x = MaterialCoordinate.GetInstance().frying1.X; | |||
y = MaterialCoordinate.GetInstance().frying1.Y; | |||
} | |||
else | |||
{ | |||
x = materialPutPositionXFry2; | |||
y = materialPutPositionYFry2; | |||
x = MaterialCoordinate.GetInstance().frying2.X; | |||
y = MaterialCoordinate.GetInstance().frying2.Y; | |||
} | |||
//设置到炒锅1出菜处 | |||
@@ -1332,15 +1388,15 @@ namespace BPASmartClient.MorkF | |||
Electromagnetism(new List<bool> { true }); | |||
Thread.Sleep(300); | |||
//收缩爪子 | |||
PawShrink(); | |||
//设置到炒锅i出菜处 | |||
if (!SetArmPosition(x + materialToFryDistance, y)) | |||
{ | |||
return false; | |||
} | |||
//收缩爪子 | |||
PawShrink(); | |||
#if true | |||
//爪子回到2号位 | |||
if (!PawToPoint2()) | |||
@@ -1396,6 +1452,10 @@ namespace BPASmartClient.MorkF | |||
//获取传感器的距离 | |||
int laserHigh = ml_morkf.LaserDistance; | |||
//秦工要求读取后置0 | |||
WriteDistance(0); | |||
int surplus = 0; | |||
//根据距离算出菜品余量 | |||
Laser2CoordinateState state = LaserDistance2MaterialCount(laserHigh, out surplus); | |||
@@ -1425,117 +1485,139 @@ namespace BPASmartClient.MorkF | |||
/// <param name="distance"></param> | |||
/// <param name="x_high"></param> | |||
/// <returns></returns> | |||
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; | |||
int heightDifferent = 0; | |||
int boxCount = 0; | |||
//传感器高度小于6,无法移出,菜品库满 | |||
if (distance < 60) | |||
{ | |||
MessageLog.GetInstance.ShowEx("错误:传感器距离不满足出菜高度"); | |||
return Laser2CoordinateState.MaterialOverdo; | |||
} | |||
try | |||
{ | |||
if (x > 0 && x <= MaterialCoordinate.GetInstance().dicNoMaterialCoordinate["1"].X) | |||
{ | |||
//菜盒放多了 | |||
if (distance < 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; | |||
} | |||
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) | |||
{ | |||
//菜盒放多了 | |||
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; | |||
} | |||
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) | |||
{ | |||
//菜盒放多了 | |||
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; | |||
} | |||
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) | |||
{ | |||
MessageLog.GetInstance.ShowEx("错误:菜品量为空"); | |||
return Laser2CoordinateState.MaterialEmpty; | |||
} | |||
//盒子高度计算除去起始位置的那个盒子 | |||
x_high = boxCount * materialBoxHeight; | |||
return Laser2CoordinateState.MaterialNormal; | |||
} | |||
catch(Exception ex) | |||
@@ -1977,12 +2059,20 @@ namespace BPASmartClient.MorkF | |||
} | |||
} | |||
/// <summary> | |||
/// 开启磁吸 | |||
/// </summary> | |||
/// <param name="num"></param> | |||
public void MagnetOn(int num) | |||
{ | |||
FirePot_Write("LB8", false, num); | |||
Thread.Sleep(200); | |||
} | |||
/// <summary> | |||
/// 关闭磁吸 | |||
/// </summary> | |||
/// <param name="num"></param> | |||
public void MagnetOff(int num) | |||
{ | |||
FirePot_Write("LB8", true, num); | |||
@@ -2374,45 +2464,45 @@ namespace BPASmartClient.MorkF | |||
//炒锅取菜状态置为未取到 | |||
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 = "15"; | |||
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 | |||
//{ | |||
// 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); | |||
break; | |||
case nameof(StirFryPotActionEnum.开启搅拌): | |||
@@ -38,8 +38,21 @@ namespace BPASmartClient.MorkF.Model | |||
} | |||
} | |||
} | |||
//dicSpecificMaterialCoordinate.Add("MaterialHeight",new Coordinate() { X = 0,Y=0}); | |||
//dicSpecificMaterialCoordinate.Add("Fry1", new Coordinate() { X = 0, Y = 0 }); | |||
//dicSpecificMaterialCoordinate.Add("Fry2", new Coordinate() { X = 0, Y = 0 }); | |||
} | |||
public Coordinate frying1 { get; set; } = new Coordinate() { X = 0, Y = 0 }; | |||
public Coordinate frying2 { get; set; } = new Coordinate() { X = 0, Y = 0 }; | |||
public Coordinate materialHeight { get; set; } = new Coordinate() { X = 0, Y = 0 }; | |||
public int distance_1 { get; set; } = 0; | |||
public int distance_2 { get; set; } = 0; | |||
public int distance_3 { get; set; } = 0; | |||
/// <summary> | |||
/// 更新键值对 | |||
/// </summary> | |||
@@ -63,6 +76,10 @@ namespace BPASmartClient.MorkF.Model | |||
/// 每个取菜点的编号与坐标字典 | |||
/// </summary> | |||
public Dictionary<string, Coordinate> dicNoMaterialCoordinate { get; set; } = new Dictionary<string, Coordinate>(); | |||
/// <summary> | |||
/// 每个取菜点的编号与坐标字典 | |||
/// </summary> | |||
//public Dictionary<string, Coordinate> dicSpecificMaterialCoordinate { get; set; } = new Dictionary<string, Coordinate>(); | |||
//{ | |||
// {"A1",new Coordinate(){ X = 34500,Y=0} }, | |||
// {"A2",new Coordinate(){ X = 34500,Y=9000} }, | |||
@@ -140,57 +140,45 @@ | |||
</WrapPanel> | |||
</GroupBox> | |||
<GroupBox Header="炒锅" FontSize="15" Foreground="Aqua" VerticalAlignment="Center" Height="140"> | |||
<Grid> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="*"/> | |||
<RowDefinition Height="*"/> | |||
</Grid.RowDefinitions> | |||
<WrapPanel VerticalAlignment="Top" Margin="0,5,0,0"> | |||
<Button Content="注油" Command="{Binding AddOil}" Margin="10,0,10,0"></Button> | |||
<Button Content="加热启动" Command="{Binding StartFire}" Margin="10,0,10,0"></Button> | |||
<Button Content="加热停止" Command="{Binding StopFire}" Margin="10,0,10,0"></Button> | |||
<Button Content="搅拌启动" Command="{Binding StartStir}" Margin="10,0,10,0" Cursor="Hand"></Button> | |||
<Button Content="搅拌停止" Command="{Binding StopStir}" Margin="10,0,15,0" Cursor="Hand"></Button> | |||
<Button Content="倒菜启动" Command="{Binding OutFood}" Margin="10,0,15,0" Cursor="Hand"/> | |||
<Button Content="搅拌臂去原点位" Command="{Binding StirArmGoOrigin}" Margin="10,0,10,0"></Button> | |||
<Button Content="搅拌臂去炒制位" Command="{Binding StirArmGoWork}" Margin="10,0,10,0"></Button> | |||
<Button Content="HBOT放盒子到位" Command="{Binding HBOTGoWork}" Margin="10,0,10,0"></Button> | |||
<Button Content="出餐启动" Command="{Binding OutMeal}" Margin="10,0,10,0"></Button> | |||
</WrapPanel> | |||
<GroupBox Header="炒锅" FontSize="15" Foreground="Aqua" VerticalAlignment="Center" Height="140"> | |||
<Grid> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="*"/> | |||
<RowDefinition Height="*"/> | |||
<RowDefinition Height="*"/> | |||
</Grid.RowDefinitions> | |||
<WrapPanel VerticalAlignment="Top" Margin="0,5,0,0"> | |||
<Button Content="注油" Command="{Binding AddOil}" Margin="10,0,10,0"></Button> | |||
<Button Content="倒菜启动" Command="{Binding OutFood}" Margin="10,0,15,0" Cursor="Hand"/> | |||
<Button Content="搅拌臂去原点位" Command="{Binding StirArmGoOrigin}" Margin="10,0,10,0"></Button> | |||
<Button Content="搅拌臂去炒制位" Command="{Binding StirArmGoWork}" Margin="10,0,10,0"></Button> | |||
<Button Content="HBOT放盒子到位" Command="{Binding HBOTGoWork}" Margin="10,0,10,0"></Button> | |||
<Button Content="出餐启动" Command="{Binding OutMeal}" Margin="10,0,10,0"></Button> | |||
</WrapPanel> | |||
<WrapPanel Grid.Row="1" VerticalAlignment="Top" Margin="0,5,0,0"> | |||
<Button Content="加热启动" Command="{Binding StartFire}" Margin="10,0,10,0"></Button> | |||
<Button Content="加热停止" Command="{Binding StopFire}" Margin="10,0,10,0"></Button> | |||
<Button Content="搅拌启动" Command="{Binding StartStir}" Margin="10,0,10,0" Cursor="Hand"></Button> | |||
<Button Content="搅拌停止" Command="{Binding StopStir}" Margin="10,0,15,0" Cursor="Hand"></Button> | |||
<Button Content="开启磁吸" Command="{Binding MagnetOn}" Margin="10,0,15,0" Cursor="Hand"></Button> | |||
<Button Content="关闭磁吸" Command="{Binding MagnetOff}" Margin="10,0,15,0" Cursor="Hand"></Button> | |||
</WrapPanel> | |||
<WrapPanel Grid.Row="2"> | |||
<TextBlock Text="加热挡位:" Margin="10,0,0,0" /> | |||
<ComboBox ItemsSource="{Binding lstFire}" Width="80" Margin="10,0,10,0" HorizontalAlignment="Center" VerticalAlignment="Center" | |||
<WrapPanel Grid.Row="2"> | |||
<TextBlock Text="加热挡位:" Margin="10,0,0,0" /> | |||
<ComboBox ItemsSource="{Binding lstFire}" Width="80" Margin="10,0,10,0" HorizontalAlignment="Center" VerticalAlignment="Center" | |||
SelectedValue="{Binding FireGear}"/> | |||
<Button Content="设定" Margin="0,0,30,0" Command="{Binding SetFire}"/> | |||
<TextBlock Text="搅拌挡位:" Margin="10,0,0,0" /> | |||
<ComboBox ItemsSource="{Binding lstStir}" Width="80" Margin="10,0,10,0" HorizontalAlignment="Center" VerticalAlignment="Center" | |||
<Button Content="设定" Margin="0,0,30,0" Command="{Binding SetFire}"/> | |||
<TextBlock Text="搅拌挡位:" Margin="10,0,0,0" /> | |||
<ComboBox ItemsSource="{Binding lstStir}" Width="80" Margin="10,0,10,0" HorizontalAlignment="Center" VerticalAlignment="Center" | |||
SelectedValue="{Binding StirGear}"/> | |||
<Button Content="设定" Margin="0,0,30,0" Command="{Binding SetStir}"/> | |||
</WrapPanel> | |||
</Grid> | |||
<Button Content="设定" Margin="0,0,30,0" Command="{Binding SetStir}"/> | |||
</WrapPanel> | |||
</Grid> | |||
</GroupBox> | |||
<GroupBox Header="炒锅" FontSize="15" Foreground="Aqua" VerticalAlignment="Center" Height="140"> | |||
<WrapPanel VerticalAlignment="Top" Margin="0,5,0,0"> | |||
<Button Content="注油" Command="{Binding SecAddOil}" Margin="10,0,10,0"></Button> | |||
<Button Content="加热关闭" Command="{Binding SecTempTurnOff}" Margin="10,0,10,0"></Button> | |||
<Button Content="加热1挡" Command="{Binding SecOneBlock}" Margin="10,0,10,0"></Button> | |||
<Button Content="加热2挡" Command="{Binding SecTwoBlock}" Margin="10,0,10,0"></Button> | |||
<Button Content="加热3挡" Command="{Binding SecThreeBlock}" Margin="10,0,10,0"></Button> | |||
<Button Content="翻炒机关闭" Command="{Binding SecOverTurnOff}" Margin="10,0,10,0" Cursor="Hand"></Button> | |||
<Button Content="翻炒机上升" Command="{Binding SecOverGoOn}" Margin="10,0,15,0" Cursor="Hand"></Button> | |||
<Button Content="翻炒机下降" Command="{Binding SecOverGoDown}" Margin="10,0,10,0"></Button> | |||
<Button Content="翻炒机1挡" Command="{Binding SecOverOneBlock}" Margin="10,0,10,0"></Button> | |||
<Button Content="翻炒机2挡" Command="{Binding SecOverTwoBlock}" Margin="10,0,10,0"></Button> | |||
<Button Content="翻炒机3挡" Command="{Binding SecOverThreeBlock}" Margin="10,0,10,0"></Button> | |||
</WrapPanel> | |||
</GroupBox> | |||
</GroupBox> | |||
</StackPanel> | |||
</StackPanel> | |||
</Grid> | |||
</ScrollViewer> | |||
@@ -136,6 +136,8 @@ namespace BPASmartClient.MorkF.ViewModel | |||
public RelayCommand StopFire { get; set; } | |||
public RelayCommand StartStir { get; set; } | |||
public RelayCommand StopStir { get; set; } | |||
public RelayCommand MagnetOn { get; set; } | |||
public RelayCommand MagnetOff { get; set; } | |||
public RelayCommand OutFood { get; set; } | |||
public RelayCommand StirArmGoOrigin { get; set; } | |||
public RelayCommand StirArmGoWork { get; set; } | |||
@@ -269,6 +271,8 @@ namespace BPASmartClient.MorkF.ViewModel | |||
StopFire = new RelayCommand(() => { ActionManage.GetInstance.Send("StopFire"); });//加热停止 | |||
StartStir = new RelayCommand(() => { ActionManage.GetInstance.Send("StartStir"); });//搅拌启动 | |||
StopStir = new RelayCommand(() => { ActionManage.GetInstance.Send("StopStir"); });//搅拌停止 | |||
MagnetOn = new RelayCommand(() => { ActionManage.GetInstance.Send("MagnetOn"); });//磁吸开启 | |||
MagnetOff = new RelayCommand(() => { ActionManage.GetInstance.Send("MagnetOff"); });//磁吸开启 | |||
OutFood = new RelayCommand(() => { ActionManage.GetInstance.Send("OutFood"); });//倒菜启动 | |||
StirArmGoOrigin = new RelayCommand(() => { ActionManage.GetInstance.Send("StirArmGoOrigin"); });//搅拌臂去原点位 | |||
StirArmGoWork = new RelayCommand(() => { ActionManage.GetInstance.Send("StirArmGoWork"); });//搅拌臂去炒制位 | |||
@@ -231,7 +231,38 @@ namespace BPASmartClient.MorkF.ViewModel | |||
public int TwentySevenY { get { return _TwentySevenY; } set { _TwentySevenY = value; OnPropertyChanged(); } } | |||
private int _TwentySevenY; | |||
#endregion | |||
#region 菜品库高度测距点位 | |||
public bool PositionMaterialHeight { get { return _PositionMaterialHeight; } set { _PositionMaterialHeight = value; OnPropertyChanged(); } } | |||
private bool _PositionMaterialHeight; | |||
public int MaterialHeightX { get { return _MaterialHeightX; } set { _MaterialHeightX = value; OnPropertyChanged(); } } | |||
private int _MaterialHeightX; | |||
public int MaterialHeightY { get { return _MaterialHeightY; } set { _MaterialHeightY = value; OnPropertyChanged(); } } | |||
private int _MaterialHeightY; | |||
#endregion | |||
#region 炒锅1菜品交互位置 | |||
public bool PositionFrying1 { get { return _PositionFrying1; } set { _PositionFrying1 = value; OnPropertyChanged(); } } | |||
private bool _PositionFrying1; | |||
public int Frying1X { get { return _Frying1X; } set { _Frying1X = value; OnPropertyChanged(); } } | |||
private int _Frying1X; | |||
public int Frying1Y { get { return _Frying1Y; } set { _Frying1Y = value; OnPropertyChanged(); } } | |||
private int _Frying1Y; | |||
#endregion | |||
#region 炒锅2菜品交互位置 | |||
public bool PositionFrying2 { get { return _PositionFrying2; } set { _PositionFrying2 = value; OnPropertyChanged(); } } | |||
private bool _PositionFrying2; | |||
public int Frying2X { get { return _Frying2X; } set { _Frying2X = value; OnPropertyChanged(); } } | |||
private int _Frying2X; | |||
public int Frying2Y { get { return _Frying2Y; } set { _Frying2Y = value; OnPropertyChanged(); } } | |||
private int _Frying2Y; | |||
#endregion | |||
#region 菜品库各传感器高度临时值 | |||
public int Distance_1 { get { return _Distance_1; } set { _Distance_1 = value; OnPropertyChanged(); } } | |||
private int _Distance_1; | |||
public int Distance_2 { get { return _Distance_2; } set { _Distance_2 = value; OnPropertyChanged(); } } | |||
private int _Distance_2; | |||
public int Distance_3 { get { return _Distance_3; } set { _Distance_3 = value; OnPropertyChanged(); } } | |||
private int _Distance_3; | |||
#endregion | |||
public bool Up { get { return _Up; } set { _Up = value; OnPropertyChanged(); } } | |||
private bool _Up; | |||
@@ -251,14 +282,6 @@ namespace BPASmartClient.MorkF.ViewModel | |||
private string _str; | |||
public RelayCommand FoodLibInit { get; set; }//初始化 | |||
public RelayCommand StartElectromagnetism { get; set; }//电磁阀启动 | |||
public RelayCommand StopElectromagnetism { get; set; } | |||
public RelayCommand PawTurnFront { get; set; }//夹爪正转 | |||
public RelayCommand PawTurnBack { get; set; }//夹爪反转 | |||
public RelayCommand PawToPoint1 { get; set; }//感应测距1 | |||
public RelayCommand PawToPoint2 { get; set; }//感应测距2 | |||
public RelayCommand PawToPoint3 { get; set; }//感应测距3 | |||
/// <summary> | |||
/// 操作时,x轴移动的距离 | |||
/// </summary> | |||
@@ -309,6 +332,18 @@ namespace BPASmartClient.MorkF.ViewModel | |||
public RelayCommand SetNowDownPosition { get; set; }//设置机械臂基于当前坐标往下移动 | |||
public RelayCommand FoodLibInit { get; set; }//初始化 | |||
public RelayCommand StartElectromagnetism { get; set; }//电磁阀启动 | |||
public RelayCommand StopElectromagnetism { get; set; } | |||
public RelayCommand PawTurnFront { get; set; }//夹爪正转 | |||
public RelayCommand PawTurnBack { get; set; }//夹爪反转 | |||
public RelayCommand PawToPoint1 { get; set; }//感应测距1 | |||
public RelayCommand PawToPoint2 { get; set; }//感应测距2 | |||
public RelayCommand PawToPoint3 { get; set; }//感应测距3 | |||
public RelayCommand GetDistance_1 { get; set; }//感应测距1 | |||
public RelayCommand GetDistance_2 { get; set; }//感应测距2 | |||
public RelayCommand GetDistance_3 { get; set; }//感应测距3 | |||
private static object saveMaterialCoordinateLock = new object(); | |||
/// <summary> | |||
/// 保存当前的坐标系 | |||
@@ -434,8 +469,23 @@ namespace BPASmartClient.MorkF.ViewModel | |||
} | |||
} | |||
materialCoordinate.frying1.X = Frying1X; | |||
materialCoordinate.frying1.Y = Frying1Y; | |||
materialCoordinate.frying2.X = Frying2X; | |||
materialCoordinate.frying2.Y = Frying2Y; | |||
materialCoordinate.materialHeight.X = MaterialHeightX; | |||
materialCoordinate.materialHeight.Y = MaterialHeightY; | |||
materialCoordinate.distance_1 = Distance_1; | |||
materialCoordinate.distance_2 = Distance_2; | |||
materialCoordinate.distance_3 = Distance_3; | |||
Json<MaterialCoordinate>.Data = materialCoordinate; | |||
Json<MaterialCoordinate>.Save(); | |||
//更新当前的菜品库数据 | |||
MaterialCoordinate.GetInstance().frying1 = materialCoordinate.frying1; | |||
MaterialCoordinate.GetInstance().frying2 = materialCoordinate.frying2; | |||
MaterialCoordinate.GetInstance().materialHeight = materialCoordinate.materialHeight; | |||
MaterialCoordinate.GetInstance().dicNoMaterialCoordinate = materialCoordinate.dicNoMaterialCoordinate; | |||
} | |||
/// <summary> | |||
@@ -463,6 +513,11 @@ namespace BPASmartClient.MorkF.ViewModel | |||
{ | |||
MaterialCoordinate materialCoordinate = ReadMaterialCoordinate(); | |||
if(materialCoordinate == null) | |||
{ | |||
return; | |||
} | |||
if (materialCoordinate.dicNoMaterialCoordinate.Count == 27) | |||
{ | |||
foreach (var dicNoMaterialCoordinate in materialCoordinate.dicNoMaterialCoordinate) | |||
@@ -577,12 +632,33 @@ namespace BPASmartClient.MorkF.ViewModel | |||
TwentySevenX = dicNoMaterialCoordinate.Value.X; | |||
TwentySevenY = dicNoMaterialCoordinate.Value.Y; | |||
break; | |||
case "MaterialHeight": | |||
MaterialHeightX = materialCoordinate.materialHeight.X; | |||
MaterialHeightY = materialCoordinate.materialHeight.Y; | |||
break; | |||
case "Frying1": | |||
Frying1X = materialCoordinate.frying1.X; | |||
Frying1Y = materialCoordinate.frying1.Y; | |||
break; | |||
case "Frying2": | |||
Frying2X = materialCoordinate.frying2.X; | |||
Frying2Y = materialCoordinate.frying2.Y; | |||
break; | |||
default: | |||
break; | |||
} | |||
} | |||
} | |||
MaterialHeightX = materialCoordinate.materialHeight.X; | |||
MaterialHeightY = materialCoordinate.materialHeight.Y; | |||
Frying1X = materialCoordinate.frying1.X; | |||
Frying1Y = materialCoordinate.frying1.Y; | |||
Frying2X = materialCoordinate.frying2.X; | |||
Frying2Y = materialCoordinate.frying2.Y; | |||
Distance_1 = materialCoordinate.distance_1; | |||
Distance_2 = materialCoordinate.distance_2; | |||
Distance_3 = materialCoordinate.distance_3; | |||
} | |||
/// <summary> | |||
@@ -701,6 +777,18 @@ namespace BPASmartClient.MorkF.ViewModel | |||
TwentySevenX = TwentySevenX + OperationX; | |||
TwentySevenY = TwentySevenY + OperationY; | |||
break; | |||
case "MaterialHeight": | |||
MaterialHeightX = MaterialHeightX + OperationX; | |||
MaterialHeightY = MaterialHeightY + OperationY; | |||
break; | |||
case "Frying1": | |||
Frying1X = Frying1X + OperationX; | |||
Frying1Y = Frying1Y + OperationY; | |||
break; | |||
case "Frying2": | |||
Frying2X = Frying1X + OperationX; | |||
Frying2Y = Frying2Y + OperationY; | |||
break; | |||
default: | |||
break; | |||
} | |||
@@ -713,7 +801,8 @@ namespace BPASmartClient.MorkF.ViewModel | |||
//判断是否有选择下发的设备 | |||
if (!PositionOne && !PositionTwo && !PositionThree && !PositionFour && !PositionFive && !PositionSix && !PositionSeven && !PositionEight && !PositionNine | |||
&& !PositionTen && !PositionEleven && !PositionTwelve && !PositionThirteen && !PositionFourteen && !PositionFifteen && !PositionSixteen && !PositionSeventeen && !PositionEighteen | |||
&& !PositionNineteen && !PositionTwenty && !PositionTwentyOne && !PositionTwentyTwo && !PositionTwentyThree && !PositionTwentyFour && !PositionTwentyFive && !PositionTwentySix && !PositionTwentySeven) | |||
&& !PositionNineteen && !PositionTwenty && !PositionTwentyOne && !PositionTwentyTwo && !PositionTwentyThree && !PositionTwentyFour && !PositionTwentyFive && !PositionTwentySix && !PositionTwentySeven | |||
&& !PositionMaterialHeight && !PositionFrying1 && !PositionFrying2) | |||
{ | |||
MessageBox.Show("未选择点位"); | |||
return; | |||
@@ -827,6 +916,18 @@ namespace BPASmartClient.MorkF.ViewModel | |||
{ | |||
ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "27", TwentySevenX + OperationX, TwentySevenY + OperationY });//设定机械臂当前位置 | |||
} | |||
if (PositionMaterialHeight) | |||
{ | |||
ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "MaterialHeight", MaterialHeightX + OperationX, MaterialHeightY + OperationY });//设定机械臂当前位置 | |||
} | |||
if (PositionFrying1) | |||
{ | |||
ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "Frying1", Frying1X + OperationX, Frying1Y + OperationY });//设定机械臂当前位置 | |||
} | |||
if (PositionFrying2) | |||
{ | |||
ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "Frying2", Frying2X + OperationX, Frying2Y + OperationY });//设定机械臂当前位置 | |||
} | |||
} | |||
public MaterialCalibrationViewModel() | |||
@@ -840,6 +941,9 @@ namespace BPASmartClient.MorkF.ViewModel | |||
PawToPoint3 = new RelayCommand(() => { ActionManage.GetInstance.Send("PawToPoint3"); });//爪子去3号位 | |||
PawTurnFront = new RelayCommand(() => { ActionManage.GetInstance.Send("PawTurnFront"); });//夹爪正转 | |||
PawTurnBack = new RelayCommand(() => { ActionManage.GetInstance.Send("PawTurnBack"); });//夹爪反转 | |||
GetDistance_1 = new RelayCommand(() => { ActionManage.GetInstance.Send("GetDistance_1"); });//感应距离1 | |||
GetDistance_2 = new RelayCommand(() => { ActionManage.GetInstance.Send("GetDistance_2"); });//感应距离2 | |||
GetDistance_3 = new RelayCommand(() => { ActionManage.GetInstance.Send("GetDistance_3"); });//感应距离3 | |||
PhysicalMaterialCoordinate(); | |||
ActionManage.GetInstance.Register(new Action<object>((o) => | |||
@@ -852,6 +956,31 @@ namespace BPASmartClient.MorkF.ViewModel | |||
} | |||
}), "CalibrationCallBack"); | |||
}), "CalibrationCallBack"); | |||
ActionManage.GetInstance.Register(new Action<object>((o) => | |||
{ | |||
ThreadManage.GetInstance().Start(new Action(() => | |||
{ | |||
if (o is List<string> nums) | |||
{ | |||
int distance = 0; | |||
bool ret = false; | |||
ret = int.TryParse(nums[1], out distance); | |||
if (ret == false) { return; } | |||
if (nums[0] == "1") | |||
{ | |||
Distance_1= distance; | |||
} | |||
else if (nums[0] == "2") | |||
{ | |||
Distance_2 = distance; | |||
} | |||
else if (nums[0] == "3") | |||
{ | |||
Distance_3 = distance; | |||
} | |||
} | |||
}), "GetDistanceCallBack"); | |||
}), "GetDistanceCallBack"); | |||
SetNowPosition = new RelayCommand(() => | |||
{ | |||
if(!Point && !Left && !Right && !Down && !Up) | |||