Browse Source

菜品库优化

样式分支
yahaha 2 years ago
parent
commit
69a8799139
4 changed files with 309 additions and 179 deletions
  1. +232
    -133
      BPASmartClient.MorkF/Control_MorkF.cs
  2. +2
    -2
      BPASmartClient.MorkF/View/DebugView.xaml
  3. +22
    -14
      BPASmartClient.MorkF/View/MaterialCalibration.xaml
  4. +53
    -30
      BPASmartClient.MorkF/ViewModel/MaterialCalibrationViewModel.cs

+ 232
- 133
BPASmartClient.MorkF/Control_MorkF.cs View File

@@ -51,29 +51,20 @@ namespace BPASmartClient.MorkF
/// </summary>
private const int materialBoxHigh = 4080;

//菜品库一层的高度
private const int materialHigh = 34500;

/// <summary>
/// 菜品库第一层的起始基点,为最下层盒子的中间点
/// </summary>
private const int materialOne = 34500;

/// <summary>
/// 菜品库第二层的起始基点,为最下层盒子的中间点
/// </summary>
private const int materialTwo = 34500;

/// <summary>
/// 菜品库第三层的起始基点,为最下层盒子的中间点
/// </summary>
private const int materialThree = 34500;
//菜品库出餐高度
private const int materialHigh = 33000;

//传感器到菜品库的高度(坐标系)
private const int materialLaserHigh = 34500;

//传感器到菜品库的高度(厘米)
private const int materialLaserHighCM = 29;
//传感器1到菜品库的高度(厘米)
private const int materialLaserHighCM_1 = 29;

//传感器2到菜品库的高度(厘米)
private const int materialLaserHighCM_2 = 29;

//传感器3到菜品库的高度(厘米)
private const int materialLaserHighCM_3 = 29;

/// <summary>
/// 传感器到隔板的距离(坐标系)
@@ -425,8 +416,8 @@ namespace BPASmartClient.MorkF
GetDistance_3();
}), "GetDistance_3");
}), "GetDistance_3");
ActionManage.GetInstance.Register(PawTurnFront, "PawTurnFront");
ActionManage.GetInstance.Register(PawTurnBack, "PawTurnBack");
ActionManage.GetInstance.Register(PawExtend, "PawTurnFront");
ActionManage.GetInstance.Register(PawShrink, "PawTurnBack");
ActionManage.GetInstance.Register(new Action<object>((list) =>
{
ThreadManage.GetInstance().Start(new Action(() =>
@@ -859,6 +850,38 @@ namespace BPASmartClient.MorkF
return true;
}
/// <summary>
/// 爪子伸出
/// </summary>
/// <param name="o">电磁阀启停:true:启动。false:停止。</param>
public void PawExtend()
{
//if (!ml_morkf.InitialComplete)
//{
// MessageLog.GetInstance.ShowEx("爪子伸出错误,菜品库未初始化");
// return;
//}

MaterailLibrary_Write("M0.6", true);
//等待爪子伸出延时4s
Thread.Sleep(4200);
}
/// <summary>
/// 爪子收缩
/// </summary>
/// <param name="o">电磁阀启停:true:启动。false:停止。</param>
public void PawShrink()
{
//if (!ml_morkf.InitialComplete)
//{
// MessageLog.GetInstance.ShowEx("爪子伸出错误,菜品库未初始化");
// return;
//}

MaterailLibrary_Write("M0.7", true);
//等待爪子收缩延时4s
Thread.Sleep(4200);
}
/// <summary>
/// 电磁阀启停
/// </summary>
/// <param name="o">电磁阀启停:true:启动。false:停止。</param>
@@ -965,9 +988,11 @@ namespace BPASmartClient.MorkF

MaterailLibrary_Write("M0.3", true);
MaterailLibrary_Write("M0.3", false);
Thread.Sleep(300);
Thread.Sleep(3000);

MessageLog.GetInstance.Show("1号测距开启完成");
MessageLog.GetInstance.Show($"传感器的距离{ml_morkf.LaserDistance}");

return true;
}
public bool GetDistance_2()
@@ -980,9 +1005,10 @@ namespace BPASmartClient.MorkF

MaterailLibrary_Write("M0.4", true);
MaterailLibrary_Write("M0.4", false);
Thread.Sleep(300);
Thread.Sleep(3000);

MessageLog.GetInstance.Show("2号测距开启完成");
MessageLog.GetInstance.Show($"传感器的距离{ml_morkf.LaserDistance}");
return true;
}
public bool GetDistance_3()
@@ -995,9 +1021,10 @@ namespace BPASmartClient.MorkF

MaterailLibrary_Write("M0.5", true);
MaterailLibrary_Write("M0.5", false);
Thread.Sleep(300);
Thread.Sleep(3000);

MessageLog.GetInstance.Show("3号测距开启完成");
MessageLog.GetInstance.Show($"传感器的距离{ml_morkf.LaserDistance}");
return true;
}

@@ -1010,7 +1037,7 @@ namespace BPASmartClient.MorkF
{
bool ret = true;
//是否在第一层菜品库
if (x > 0 && x <= materialLaserHigh)
if (x > 0 && x <= MaterialCoordinate.GetInstance().dicNoMaterialCoordinate["1"].X)
{
//获取传感器1的距离
ret &= GetDistance_1();
@@ -1021,7 +1048,7 @@ namespace BPASmartClient.MorkF
ret &= GetDistance_1();
}
//是否在第二层菜品库
else if (x > materialLaserHigh && x <= (2 * materialLaserHigh + clapboardLaserHigh))
else if (x > MaterialCoordinate.GetInstance().dicNoMaterialCoordinate["1"].X && x <= MaterialCoordinate.GetInstance().dicNoMaterialCoordinate["10"].X)
{
//获取传感器2的距离
ret &= GetDistance_2();
@@ -1031,7 +1058,7 @@ namespace BPASmartClient.MorkF
ret &= GetDistance_2();
}
//是否在第三层菜品库
else if (x > (2 * materialLaserHigh + clapboardLaserHigh) && x <= (3 * materialLaserHigh + 2 * clapboardLaserHigh))
else if (x > MaterialCoordinate.GetInstance().dicNoMaterialCoordinate["10"].X && x <= MaterialCoordinate.GetInstance().dicNoMaterialCoordinate["19"].X)
{
//获取传感器3的距离
ret &= GetDistance_3();
@@ -1047,15 +1074,6 @@ namespace BPASmartClient.MorkF
return ret;
}

public void PawTurnFront()
{
MaterailLibrary_Write("", true);
}
public void PawTurnBack()
{
MaterailLibrary_Write("", true);
}

/// <summary>
/// 设定机械臂的位置
/// </summary>
@@ -1211,7 +1229,7 @@ namespace BPASmartClient.MorkF
}

int moveX = 0;
if (LaserDistance2Coordinate(laserHigh, out moveX) != Laser2CoordinateState.MaterialNormal)
if (LaserDistance2Coordinate(laserHigh, x, out moveX) != Laser2CoordinateState.MaterialNormal)
{
MessageLog.GetInstance.Show("错误:传感器距离转坐标值失败");
return false;
@@ -1229,9 +1247,9 @@ namespace BPASmartClient.MorkF
return false;
}

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

#if true
//爪子去1号位抓菜
@@ -1239,17 +1257,22 @@ namespace BPASmartClient.MorkF
{
return false;
}

#endif

//移动前开启电磁阀
Electromagnetism(new List<bool> { false });
Thread.Sleep(500);

//伸出爪子
PawExtend();

//设置到该层菜品库最高处
if (!SetArmPosition(x - materialHigh, y))
{
return false;
}

////移动前开启电磁阀
//Electromagnetism(new List<bool> { false });
//Thread.Sleep(500);

#if true
//爪子去2号位放菜
@@ -1305,7 +1328,14 @@ namespace BPASmartClient.MorkF

Thread.Sleep(200);

//设置到炒锅1出菜处
//关闭电磁阀
Electromagnetism(new List<bool> { true });
Thread.Sleep(300);

//收缩爪子
PawShrink();

//设置到炒锅i出菜处
if (!SetArmPosition(x + materialToFryDistance, y))
{
return false;
@@ -1318,9 +1348,6 @@ namespace BPASmartClient.MorkF
return false;
}
#endif
////关闭电磁阀
//Electromagnetism(new List<bool> { false });
//Thread.Sleep(300);
if (morkFs.ContainsKey(fryNum))
{
morkFs[fryNum].GetMaterialComplete = true;
@@ -1336,12 +1363,12 @@ namespace BPASmartClient.MorkF
{
try
{
////判断是否初始化
//if (!ml_morkf.InitialComplete)
//{
// MessageLog.GetInstance.Show("更新菜品库存量出错,菜品库未初始化");
// return false;
//}
//判断是否初始化
if (!ml_morkf.InitialComplete)
{
MessageLog.GetInstance.Show("更新菜品库存量出错,菜品库未初始化");
return false;
}

if (MaterialCoordinate.GetInstance().dicNoMaterialCoordinate == null || MaterialCoordinate.GetInstance().dicNoMaterialCoordinate.Count != 27)
{
@@ -1396,47 +1423,120 @@ namespace BPASmartClient.MorkF
/// 传感器距离转为x轴坐标系
/// </summary>
/// <param name="distance"></param>
/// <param name="x"></param>
/// <param name="x_high"></param>
/// <returns></returns>
public Laser2CoordinateState LaserDistance2Coordinate(int distance,out int x)
public Laser2CoordinateState LaserDistance2Coordinate(int distance,int x,out int x_high)
{
x = 0;
x_high = 0;
try
{
//菜盒放多了
if (distance<6)
{
return Laser2CoordinateState.MaterialOverdo;
}
else if (distance >= 6 && distance < 10)
{
x = 24882;
return Laser2CoordinateState.MaterialNormal;
}
else if(distance>=10 && distance < 14)
{
x = 18661;
return Laser2CoordinateState.MaterialNormal;
}
else if(distance >= 14 && distance < 19)
if (x > 0 && x <= MaterialCoordinate.GetInstance().dicNoMaterialCoordinate["1"].X)
{
x = 12441;
return Laser2CoordinateState.MaterialNormal;
//菜盒放多了
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;
}
}
else if (distance >= 19 && distance < 23)
else if (x <= MaterialCoordinate.GetInstance().dicNoMaterialCoordinate["10"].X && x > MaterialCoordinate.GetInstance().dicNoMaterialCoordinate["1"].X)
{
x = 6220;
return Laser2CoordinateState.MaterialNormal;
//菜盒放多了
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 (distance >= 23 && distance < 28)
else if (x > MaterialCoordinate.GetInstance().dicNoMaterialCoordinate["10"].X && x <= MaterialCoordinate.GetInstance().dicNoMaterialCoordinate["20"].X)
{
x = 0;
return Laser2CoordinateState.MaterialNormal;
//菜盒放多了
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.MaterialEmpty;

return Laser2CoordinateState.MaterialOverdo;
}

}
catch(Exception ex)
{
@@ -1519,7 +1619,7 @@ namespace BPASmartClient.MorkF
ml_morkf.MaterailIsWorking = true;
}
//取菜操作
ret =GetMaterail(myCoordinate.X, myCoordinate.Y, materialOperation.fryNum);
ret = GetMaterail(myCoordinate.X, myCoordinate.Y, materialOperation.fryNum);
}
catch (Exception ex)
{
@@ -1657,11 +1757,6 @@ namespace BPASmartClient.MorkF
MessageLog.GetInstance.ShowEx($"炒锅{j}初始化超时");
}
}

//while (!morkFs[i].FryPot1_InitialComplete)
//{
// Thread.Sleep(500);
//}
FirePot_Write("LB0", false, i);
}
}
@@ -2156,7 +2251,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);
@@ -2179,6 +2274,7 @@ namespace BPASmartClient.MorkF
{
try
{
int testi = 0;
string error = string.Empty;
//初始化大屏
morkFs[i].ScreenInit();
@@ -2201,7 +2297,7 @@ namespace BPASmartClient.MorkF
if(ret == false)
{
MessageLog.GetInstance.ShowEx("上一步操作未成功");
break;
//break;
}

////调试大屏用代码
@@ -2277,25 +2373,46 @@ namespace BPASmartClient.MorkF
case nameof(StirFryPotActionEnum.取原料):
//炒锅取菜状态置为未取到
morkFs[i].GetMaterialComplete = false;
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 = "15";
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.开启搅拌):
@@ -2374,6 +2491,12 @@ namespace BPASmartClient.MorkF
}
catch (Exception ex)
{
nowStirFryGood[i] = null;
//炒完后出队列
morkFs[i].StirFryGoodsQuenes.TryDequeue(out var orderQueue);
morkFs[i].FryWorking = false;
//初始化大屏
morkFs[i].ScreenClear();
//异常菜品统计数量+1
morkFs[i].orderAbnormalCount++;
ThreadManage.GetInstance().StopTask($"炒锅{i}{res.GoodName}炒制线程");
@@ -2404,9 +2527,9 @@ namespace BPASmartClient.MorkF
{
if(materialOperationQuenes.Count > 0)
{
////判断是否初始化与是否在工作中
//if (ml_morkf.InitialComplete && !ml_morkf.MaterailIsWorking)
//{
//判断是否初始化与是否在工作中
if (ml_morkf.InitialComplete && !ml_morkf.MaterailIsWorking)
{
//待菜品库操作列出队列
if (materialOperationQuenes.TryDequeue(out var res))
{
@@ -2414,11 +2537,11 @@ namespace BPASmartClient.MorkF
ml_morkf.MaterailIsWorking = true;
MessageLog.GetInstance.Show("开始操作菜品库");
//ThreadManage.GetInstance().Start(new Action(()=>{
// GetMaterail(res.x, res.y, res.fryNum);
// GetMaterail(res.x_high, res.y, res.fryNum);
//}),"菜品库操作");
GetMaterailTest(res);
}
//}
}
}
}

@@ -2436,31 +2559,7 @@ namespace BPASmartClient.MorkF
LocalMqtt.GetInstance.Init(ScreenDeviceType.小炒);
ThreadManage.GetInstance().StartLong(new Action(() =>
{
statsModels.Add(new StatsModel() { Name = "帝王蟹", Count = 666 });
//int i = new Random().Next(0, 100);
//List<ProcessModel> processModels= new List<ProcessModel>();
//switch ((i / 5) % 6)
//{
// case 0:
// processModels = new List<ProcessModel>() { new ProcessModel() { Id = 1, Name = "启动", Status = ProcessStatus.正在执行 }, new ProcessModel() { Id = 1, Name = "热油", Status = ProcessStatus.未执行 }, new ProcessModel() { Id = 1, Name = "炒制", Status = ProcessStatus.未执行 }, new ProcessModel() { Id = 1, Name = "出餐", Status = ProcessStatus.未执行 }, new ProcessModel() { Id = 1, Name = "结束", Status = ProcessStatus.未执行 } };
// break;
// case 1:
// processModels = new List<ProcessModel>() { new ProcessModel() { Id = 1, Name = "启动", Status = ProcessStatus.执行完成 }, new ProcessModel() { Id = 1, Name = "热油", Status = ProcessStatus.正在执行 }, new ProcessModel() { Id = 1, Name = "炒制", Status = ProcessStatus.未执行 }, new ProcessModel() { Id = 1, Name = "出餐", Status = ProcessStatus.未执行 }, new ProcessModel() { Id = 1, Name = "结束", Status = ProcessStatus.未执行 } };
// break;
// case 2:
// processModels = new List<ProcessModel>() { new ProcessModel() { Id = 1, Name = "启动", Status = ProcessStatus.执行完成 }, new ProcessModel() { Id = 1, Name = "热油", Status = ProcessStatus.执行完成 }, new ProcessModel() { Id = 1, Name = "炒制", Status = ProcessStatus.正在执行 }, new ProcessModel() { Id = 1, Name = "出餐", Status = ProcessStatus.未执行 }, new ProcessModel() { Id = 1, Name = "结束", Status = ProcessStatus.未执行 } };
// break;
// case 3:
// processModels = new List<ProcessModel>() { new ProcessModel() { Id = 1, Name = "启动", Status = ProcessStatus.执行完成 }, new ProcessModel() { Id = 1, Name = "热油", Status = ProcessStatus.执行完成 }, new ProcessModel() { Id = 1, Name = "炒制", Status = ProcessStatus.执行完成 }, new ProcessModel() { Id = 1, Name = "出餐", Status = ProcessStatus.正在执行 }, new ProcessModel() { Id = 1, Name = "结束", Status = ProcessStatus.未执行 } };
// break;
// case 4:
// processModels = new List<ProcessModel>() { new ProcessModel() { Id = 1, Name = "启动", Status = ProcessStatus.执行完成 }, new ProcessModel() { Id = 1, Name = "热油", Status = ProcessStatus.执行完成 }, new ProcessModel() { Id = 1, Name = "炒制", Status = ProcessStatus.执行完成 }, new ProcessModel() { Id = 1, Name = "出餐", Status = ProcessStatus.执行完成 }, new ProcessModel() { Id = 1, Name = "结束", Status = ProcessStatus.正在执行 } };
// break;
// case 5:
// processModels = new List<ProcessModel>() { new ProcessModel() { Id = 1, Name = "启动", Status = ProcessStatus.执行完成 }, new ProcessModel() { Id = 1, Name = "热油", Status = ProcessStatus.执行完成 }, new ProcessModel() { Id = 1, Name = "炒制", Status = ProcessStatus.执行完成 }, new ProcessModel() { Id = 1, Name = "出餐", Status = ProcessStatus.执行完成 }, new ProcessModel() { Id = 1, Name = "结束", Status = ProcessStatus.执行完成 } };
// break;
// default: break;
//}
//statsModels.Add(new StatsModel() { Name = "帝王蟹", Count = 666 });
ScreenModelMinWok maxWok = new ScreenModelMinWok
{
IsRun = IsHealth ? IsRun.运行 : IsRun.停止,//new Random().Next(0, 2) == 0 ? IsRun.运行 : IsRun.停止, //设备是否运行


+ 2
- 2
BPASmartClient.MorkF/View/DebugView.xaml View File

@@ -110,8 +110,8 @@
<Button Content="设置" Margin="10,0,5,0" Command="{Binding SetNowPosition}"/>
</WrapPanel>
<WrapPanel Grid.Row="3" Orientation="Horizontal" >
<Button Content="夹爪正转" Command="{Binding PawTurnFront}" Margin="5,0" Cursor="Hand"/>
<Button Content="夹爪反转" Command="{Binding PawTurnBack}" Margin="5,0" Cursor="Hand"/>
<Button Content="夹爪伸出" Command="{Binding PawTurnFront}" Margin="5,0" Cursor="Hand"/>
<Button Content="夹爪收缩" Command="{Binding PawTurnBack}" Margin="5,0" Cursor="Hand"/>
<RadioButton Content="位置1" Margin="5,0" IsEnabled="True" IsChecked="{Binding PawPositon1}" Command="{Binding PawToPoint1}" GroupName="PawTurn"/>
<RadioButton Content="位置2" Margin="5,0" IsEnabled="True" IsChecked="{Binding PawPositon2}" Command="{Binding PawToPoint2}" GroupName="PawTurn"/>
<RadioButton Content="位置3" Margin="5,0 " IsEnabled="True" IsChecked="{Binding PawPositon3}" Command="{Binding PawToPoint3}" GroupName="PawTurn"/>


+ 22
- 14
BPASmartClient.MorkF/View/MaterialCalibration.xaml View File

@@ -660,24 +660,32 @@
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
</Grid.RowDefinitions>
<WrapPanel>
</Grid.RowDefinitions>
<WrapPanel>
<Button Content="菜品库初始化" Margin="10,0,5,0" Command="{Binding FoodLibInit}"/>
<Button Content="电磁阀启动" Margin="10,0,5,0" Command="{Binding StartElectromagnetism}"/>
<Button Content="电磁阀停止" Margin="10,0,5,0" Command="{Binding StopElectromagnetism}"/>
<Button Content="夹爪伸出" Command="{Binding PawTurnFront}" Margin="5,0" Cursor="Hand"/>
<Button Content="夹爪收缩" Command="{Binding PawTurnBack}" Margin="5,0" Cursor="Hand"/>
<RadioButton Content="位置1" Margin="5,0" IsEnabled="True" IsChecked="{Binding PawPositon1}" Command="{Binding PawToPoint1}" GroupName="PawTurn"/>
<RadioButton Content="位置2" Margin="5,0" IsEnabled="True" IsChecked="{Binding PawPositon2}" Command="{Binding PawToPoint2}" GroupName="PawTurn"/>
<RadioButton Content="位置3" Margin="5,0 " IsEnabled="True" IsChecked="{Binding PawPositon3}" Command="{Binding PawToPoint3}" GroupName="PawTurn"/>
</WrapPanel>
<WrapPanel Grid.Row="1">
<TextBlock Text="移动系数:"></TextBlock>
<TextBox
Style="{DynamicResource UserTextBoxStyle}"
Foreground="#a2c2e8" Text="{Binding Str}"/>
</WrapPanel>
<WrapPanel Grid.Row="1">
<TextBlock Text="移动方式:"></TextBlock>
<RadioButton Content="上" Margin="5,0" IsChecked="{Binding Up}" GroupName="ArmRun"/>
<RadioButton Content="下" Margin="5,0" IsChecked="{Binding Down}" GroupName="ArmRun"/>
<RadioButton Content="左" Margin="5,0 " IsChecked="{Binding Left}" GroupName="ArmRun"/>
<RadioButton Content="右" Margin="5,0 " IsChecked="{Binding Right}" GroupName="ArmRun"/>
<RadioButton Content="定点" Margin="5,0 " IsChecked="{Binding Point}" GroupName="ArmRun"/>
<Button Content="移动" Command="{Binding SetNowPosition}"/>
</WrapPanel>
<WrapPanel Grid.Row="2">
<Button Content="自动计算" Margin="20,0,50,0" Command="{Binding AutoCalculation}"/>
<TextBlock Text="移动方式:" Margin="50,0,0,0"></TextBlock>
<RadioButton Content="上" Margin="5,0" IsChecked="{Binding Up}" GroupName="ArmRun"/>
<RadioButton Content="下" Margin="5,0" IsChecked="{Binding Down}" GroupName="ArmRun"/>
<RadioButton Content="左" Margin="5,0 " IsChecked="{Binding Left}" GroupName="ArmRun"/>
<RadioButton Content="右" Margin="5,0 " IsChecked="{Binding Right}" GroupName="ArmRun"/>
<RadioButton Content="定点" Margin="5,0 " IsChecked="{Binding Point}" GroupName="ArmRun"/>
<Button Content="移动" Command="{Binding SetNowPosition}"/>
</WrapPanel>
<WrapPanel Grid.Row="2" Cursor="">
<Button Content="自动计算" Margin="20,0,50,0" Command="{Binding AutoCalculation}"/>
<Button Content="保存" Margin="20,0,50,0" Command="{Binding SaveCoordinate}"/>
<Button Content="读取" Command="{Binding ReadCoordinate}"/>
</WrapPanel>


+ 53
- 30
BPASmartClient.MorkF/ViewModel/MaterialCalibrationViewModel.cs View File

@@ -251,6 +251,14 @@ 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>
@@ -264,17 +272,22 @@ namespace BPASmartClient.MorkF.ViewModel
/// <summary>
/// Y轴大菜品库的间隙
/// </summary>
private const int bigMaterialClearanceY = 15000;
private const int bigMaterialClearanceY = 54000;

/// <summary>
/// Y轴小菜品库的间隙
/// </summary>
private const int smartMaterialClearanceY = 9000;
private const int smartMaterialClearanceY = 28000;

/// <summary>
/// X轴菜品库的间隙
/// </summary>
private const int materialClearanceX = 34500;
private const int materialClearanceX1 = 78000;

/// <summary>
/// X轴菜品库的间隙
/// </summary>
private const int materialClearanceX2 = 88000;

/// <summary>
/// 移动系数
@@ -716,7 +729,7 @@ namespace BPASmartClient.MorkF.ViewModel
}
if (PositionThree)
{
ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "3", + OperationX, ThreeY + OperationY });//设定机械臂当前位置
ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "3", ThreeX + OperationX, ThreeY + OperationY });//设定机械臂当前位置
}
if (PositionFour)
{
@@ -818,6 +831,16 @@ namespace BPASmartClient.MorkF.ViewModel

public MaterialCalibrationViewModel()
{
StartElectromagnetism = new RelayCommand(() => { ActionManage.GetInstance.Send("Electromagnetism", new List<bool> { false }); });//电磁阀启动
StopElectromagnetism = new RelayCommand(() => { ActionManage.GetInstance.Send("Electromagnetism", new List<bool> { true }); });//电磁阀关闭

FoodLibInit = new RelayCommand(() => { ActionManage.GetInstance.Send("FoodLibInit"); });//菜品库初始化
PawToPoint1 = new RelayCommand(() => { ActionManage.GetInstance.Send("PawToPoint1"); });//爪子去1号位
PawToPoint2 = new RelayCommand(() => { ActionManage.GetInstance.Send("PawToPoint2"); });//爪子去2号位
PawToPoint3 = new RelayCommand(() => { ActionManage.GetInstance.Send("PawToPoint3"); });//爪子去3号位
PawTurnFront = new RelayCommand(() => { ActionManage.GetInstance.Send("PawTurnFront"); });//夹爪正转
PawTurnBack = new RelayCommand(() => { ActionManage.GetInstance.Send("PawTurnBack"); });//夹爪反转

PhysicalMaterialCoordinate();
ActionManage.GetInstance.Register(new Action<object>((o) =>
{
@@ -895,40 +918,40 @@ namespace BPASmartClient.MorkF.ViewModel
#region 菜品库一层计算
//X轴改变
TwoX = ThreeX = FourX = FiveX = SixX = SevenX = EightX = NineX = OneX;
TwoY = OneY + smartMaterialClearanceY;
ThreeY = OneY + 2*smartMaterialClearanceY;
FourY = OneY + 2 * smartMaterialClearanceY + bigMaterialClearanceY;
FiveY = OneY + 3 * smartMaterialClearanceY + bigMaterialClearanceY;
SixY = OneY + 4 * smartMaterialClearanceY + bigMaterialClearanceY;
SevenY = OneY + 4 * smartMaterialClearanceY + 2*bigMaterialClearanceY;
EightY = OneY + 5 * smartMaterialClearanceY + 2 * bigMaterialClearanceY;
NineY = OneY + 6 * smartMaterialClearanceY + 2 * bigMaterialClearanceY;
TwoY = OneY + 1000;
ThreeY = OneY + 1000+smartMaterialClearanceY;
FourY = OneY + 1000 + smartMaterialClearanceY + bigMaterialClearanceY;
FiveY = OneY + 1000 + 2 * smartMaterialClearanceY + bigMaterialClearanceY;
SixY = OneY + 3 * smartMaterialClearanceY + bigMaterialClearanceY;
SevenY = OneY + 3 * smartMaterialClearanceY + 2*bigMaterialClearanceY;
EightY = OneY + 4 * smartMaterialClearanceY + 2 * bigMaterialClearanceY;
NineY = OneY + 5 * smartMaterialClearanceY + 2 * bigMaterialClearanceY;
#endregion
#region 菜品库二层计算
//X轴改变
TenX = ElevenX = TwelveX = ThirteenX = FourteenX = FifteenX = SixteenX = SeventeenX = EighteenX = (OneX + materialClearanceX);
TenX = ElevenX = TwelveX = ThirteenX = FourteenX = FifteenX = SixteenX = SeventeenX = EighteenX = (OneX + materialClearanceX1);
TenY = OneY;
ElevenY = OneY + smartMaterialClearanceY;
TwelveY = OneY + 2 * smartMaterialClearanceY;
ThirteenY = OneY + 2 * smartMaterialClearanceY + bigMaterialClearanceY;
FourteenY = OneY + 3 * smartMaterialClearanceY + bigMaterialClearanceY;
FifteenY = OneY + 4 * smartMaterialClearanceY + bigMaterialClearanceY;
SixteenY = OneY + 4 * smartMaterialClearanceY + 2 * bigMaterialClearanceY;
SeventeenY = OneY + 5 * smartMaterialClearanceY + 2 * bigMaterialClearanceY;
EighteenY = OneY + 6 * smartMaterialClearanceY + 2 * bigMaterialClearanceY;
ElevenY = OneY + 1000;
TwelveY = OneY + smartMaterialClearanceY;
ThirteenY = OneY + smartMaterialClearanceY + bigMaterialClearanceY;
FourteenY = OneY + 2 * smartMaterialClearanceY + bigMaterialClearanceY;
FifteenY = OneY + 3 * smartMaterialClearanceY + bigMaterialClearanceY;
SixteenY = OneY + 3 * smartMaterialClearanceY + 2 * bigMaterialClearanceY;
SeventeenY = OneY + 4 * smartMaterialClearanceY + 2 * bigMaterialClearanceY;
EighteenY = OneY + 5 * smartMaterialClearanceY + 2 * bigMaterialClearanceY;
#endregion
#region 菜品库三层计算
//X轴改变
NineteenX = TwentyX = TwentyOneX = TwentyTwoX = TwentyThreeX = TwentyFourX = TwentyFiveX = TwentySixX = TwentySevenX = (OneX + 2 * materialClearanceX);
NineteenX = TwentyX = TwentyOneX = TwentyTwoX = TwentyThreeX = TwentyFourX = TwentyFiveX = TwentySixX = TwentySevenX = (OneX + 2 * materialClearanceX2);
NineteenY = OneY;
TwentyY = OneY + smartMaterialClearanceY;
TwentyOneY = OneY + 2 * smartMaterialClearanceY;
TwentyTwoY = OneY + 2 * smartMaterialClearanceY + bigMaterialClearanceY;
TwentyThreeY = OneY + 3 * smartMaterialClearanceY + bigMaterialClearanceY;
TwentyFourY = OneY + 4 * smartMaterialClearanceY + bigMaterialClearanceY;
TwentyFiveY = OneY + 4 * smartMaterialClearanceY + 2 * bigMaterialClearanceY;
TwentySixY = OneY + 5 * smartMaterialClearanceY + 2 * bigMaterialClearanceY;
TwentySevenY = OneY + 6 * smartMaterialClearanceY + 2 * bigMaterialClearanceY;
TwentyY = OneY + 1000;
TwentyOneY = OneY + smartMaterialClearanceY;
TwentyTwoY = OneY + smartMaterialClearanceY + bigMaterialClearanceY;
TwentyThreeY = OneY + 2 * smartMaterialClearanceY + bigMaterialClearanceY;
TwentyFourY = OneY + 3 * smartMaterialClearanceY + bigMaterialClearanceY;
TwentyFiveY = OneY + 3 * smartMaterialClearanceY + 2 * bigMaterialClearanceY;
TwentySixY = OneY + 4 * smartMaterialClearanceY + 2 * bigMaterialClearanceY;
TwentySevenY = OneY + 5 * smartMaterialClearanceY + 2 * bigMaterialClearanceY;
#endregion
}



Loading…
Cancel
Save