pengliangyang 2年前
コミット
287d6604c7
34個のファイルの変更2182行の追加739行の削除
  1. バイナリ
     
  2. +79
    -0
      BPASmartClient.CustomResource/RecDictionarys/RecToggleButton.xaml
  3. +83
    -0
      BPASmartClient.Model/大炒/FryPotMessages.cs
  4. +14
    -0
      BPASmartClient.Model/大炒/LocalFryPotMessage.cs
  5. +32
    -0
      BPASmartClient.Model/大炒/RobotActionModel.cs
  6. +281
    -15
      BPASmartClient.MorkBF/Control_MorkBF.cs
  7. +127
    -0
      BPASmartClient.MorkBF/Convert/FryActionToVisibilityConverter.cs
  8. +48
    -14
      BPASmartClient.MorkBF/GVL_MorkBF.cs
  9. +31
    -1
      BPASmartClient.MorkBF/Model/BF_Food.cs
  10. +14
    -0
      BPASmartClient.MorkBF/Model/Global.cs
  11. +32
    -6
      BPASmartClient.MorkBF/VIew/DebugView.xaml
  12. +9
    -1
      BPASmartClient.MorkBF/VIew/DebugView.xaml.cs
  13. +58
    -33
      BPASmartClient.MorkBF/VIew/FoodManagerView.xaml
  14. +18
    -1
      BPASmartClient.MorkBF/VIew/FoodManagerView.xaml.cs
  15. +39
    -5
      BPASmartClient.MorkBF/ViewModel/DebugViewModel.cs
  16. +93
    -0
      BPASmartClient.MorkBF/ViewModel/FoodManagerViewModel.cs
  17. +1
    -1
      BPASmartClient.MorkBF/ViewModel/MonitorViewModel.cs
  18. +446
    -200
      BPASmartClient.MorkF/Control_MorkF.cs
  19. +14
    -1
      BPASmartClient.MorkF/GVL_MorkF.cs
  20. +27
    -0
      BPASmartClient.MorkF/MaterialOperation.cs
  21. +20
    -2
      BPASmartClient.MorkF/View/DebugView.xaml
  22. +54
    -1
      BPASmartClient.MorkF/ViewModel/DebugViewModel.cs
  23. +1
    -1
      BPASmartClient.MorkS/BPASmartClient.MorkS.csproj
  24. +53
    -0
      BPASmartClient.MorkS/Control_Morks.cs
  25. +5
    -3
      BPASmartClient.MorkS/DataServer.cs
  26. +3
    -5
      BPASmartClient.S7Net/EntityClassResolution.cs
  27. +2
    -3
      BPASmartClient.S7Net/SiemensHelper.cs
  28. +1
    -2
      BPASmartClient.ViewModel/FoodMenuViewModel.cs
  29. +1
    -11
      DosingSystem/Model/DeviceInquire.cs
  30. +9
    -3
      DosingSystem/View/CommParSetView.xaml
  31. +466
    -409
      DosingSystem/View/ManualControlView.xaml
  32. +38
    -12
      DosingSystem/View/RecipeControlView.xaml
  33. +39
    -0
      DosingSystem/ViewModel/ManualControlViewModel.cs
  34. +44
    -9
      DosingSystem/ViewModel/RecipeControlViewModel.cs

バイナリ
ファイルの表示


+ 79
- 0
BPASmartClient.CustomResource/RecDictionarys/RecToggleButton.xaml ファイルの表示

@@ -137,4 +137,83 @@
</Setter>
</Style>
<!--#endregion-->

<!--#region 切换开关 ToggleButton 样式-->
<Style x:Key="SwitchToggleButtonStyle1" TargetType="{x:Type ToggleButton}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Viewbox>
<Grid x:Name="gr" Opacity="0.8">
<Border
x:Name="border2"
Width="{TemplateBinding Width}"
Height="{TemplateBinding Height}"
HorizontalAlignment="Left"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Background="Red"
BorderBrush="{TemplateBinding BorderBrush}"
CornerRadius="15">
<ContentPresenter
Margin="{TemplateBinding Padding}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
Visibility="Collapsed" />
</Border>

<Ellipse
Name="ell"
Width="{TemplateBinding Height}"
Height="{TemplateBinding Height}"
Margin="0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Fill="#ddd" />

<TextBlock
Name="tb"
Margin="10,0,10,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Foreground="White"
Text="{TemplateBinding Content}" />

</Grid>
</Viewbox>
<ControlTemplate.Triggers>
<!-- 控件选中 -->
<Trigger Property="IsChecked" Value="true">
<Setter TargetName="ell" Property="HorizontalAlignment" Value="Right" />
<Setter TargetName="border2" Property="Background" Value="#00c2f4" />
<Setter TargetName="tb" Property="Margin" Value="0,0,15,0" />
</Trigger>

<!-- 控件未选中 -->
<Trigger Property="IsChecked" Value="false">
<Setter TargetName="border2" Property="Background" Value="gray" />
<Setter TargetName="tb" Property="Margin" Value="15,0,0,0" />
</Trigger>

<!-- 鼠标进入 -->
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="gr" Property="Opacity" Value="1" />
</Trigger>

<!-- 控件禁用 -->
<Trigger Property="IsEnabled" Value="false">
<Setter TargetName="gr" Property="Opacity" Value="0.5" />
</Trigger>

<!-- 控件启用 -->
<Trigger Property="IsEnabled" Value="True">
<Setter TargetName="gr" Property="Opacity" Value="0.8" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!--#endregion-->
</ResourceDictionary>

+ 83
- 0
BPASmartClient.Model/大炒/FryPotMessages.cs ファイルの表示

@@ -0,0 +1,83 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmartClient.Model.大炒
{
public class FryPotMessages
{
public string GoodName { get; set; }
public string GoodKey { get; set; }
public List<FryPotProcess> fryPotProcesses { get; set; } = new List<FryPotProcess>();
}

public class FryPotProcess
{
/// <summary>
/// 步骤
/// </summary>
public int FryTime { get; set; }
/// <summary>
/// 动作
/// </summary>
public FryAction fryActions { get; set; }
/// <summary>
/// 加热时间 单位s
/// </summary>
public int FryDuration { get; set; } = 0;
/// <summary>
/// 加热挡位 1-5
/// </summary>
public int FryGear { get; set; } = 0;
/// <summary>
/// 搅拌挡位 小炒1-10 大炒1-5
/// </summary>
public int StirGear { get; set; } = 0;
/// <summary>
/// 翻转速度0到800
/// </summary>
public int TurnSpeed { get; set; }= 0;
/// <summary>
/// 炒制位置1到4
/// </summary>
public int FryPosition { get; set; }
/// <summary>
/// 辅料,调料,或者菜品集合
/// </summary>
public List<Accessories> accessories { get; set; } = new List<Accessories>();

}

public class Accessories
{
/// <summary>
/// 位置
/// </summary>
public int Loc { get; set; }
/// <summary>
/// 重量
/// </summary>
public int Qry { get; set; }
}

public enum FryAction
{
冷锅加热,
热油,
加调料,
加辅料,
炒制菜品,
}

public enum FryRepot
{
开始,
热锅,
炒菜,
出餐,
完成,
}
}

+ 14
- 0
BPASmartClient.Model/大炒/LocalFryPotMessage.cs ファイルの表示

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmartClient.Model.大炒
{
public class LocalFryPotMessage
{
public ObservableCollection<FryPotMessages> FryPotMessage { get; set; } = new ObservableCollection<FryPotMessages>();
}
}

+ 32
- 0
BPASmartClient.Model/大炒/RobotActionModel.cs ファイルの表示

@@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmartClient.Model.大炒
{
public class RobotAction_Pot
{
public int Pot { get; set; }
public RobotActionModel robotActionModel { get; set; }
}

public enum RobotActionModel
{
无任务,
取1号炒锅荤菜盆倒1号炒锅,
取1号炒锅素菜盆1倒1号炒锅,
取1号炒锅素菜盆2倒1号炒锅,
取1号炒锅调料盆倒入1号炒锅,
取1号炒锅辅料盆1倒入1号炒锅,
取1号空盆出餐,

取2号炒锅荤菜盆1倒2号炒锅 = 20,
取2号炒锅素菜盆1倒2号炒锅 = 21,
取2号炒锅素菜盆2倒2号炒锅 =22,
取2号炒锅调料盆倒入2号炒锅 =23,
取2号炒锅辅料盆1倒入2号炒锅 =24,
取2号空盆出餐 =25,
}
}

+ 281
- 15
BPASmartClient.MorkBF/Control_MorkBF.cs ファイルの表示

@@ -1,10 +1,13 @@
using BPA.Message;
using BPA.Helper;
using BPA.Message;
using BPA.Message.Enum;
using BPASmartClient.Business;
using BPASmartClient.Device;
using BPASmartClient.EventBus;
using BPASmartClient.Helper;
using BPASmartClient.Model;
using BPASmartClient.Model.大炒;
using BPASmartClient.MorkBF.Model;
using BPASmartClient.MorkBF.ViewModel;
using System;
using System.Collections.Generic;
@@ -13,6 +16,9 @@ using System.Text;
using System.Threading;
using System.Threading.Tasks;
using static BPASmartClient.EventBus.EventBus;
using static BPASmartClient.Model.大炒.FryPotMessages;
using ActionManage = BPA.Helper.ActionManage;
using ThreadManage = BPA.Helper.ThreadManage;

namespace BPASmartClient.MorkBF
{
@@ -24,7 +30,8 @@ namespace BPASmartClient.MorkBF

public override void DoMain()
{

IsHealth = true;
BPASmartClient.Helper.Json<LocalFryPotMessage>.Read();
MonitorViewModel.DeviceId = DeviceId;
CommandRegist();//调试
ServerInit();
@@ -44,8 +51,6 @@ namespace BPASmartClient.MorkBF
OrderCount++;
DeviceProcessLogShow($"接收到{OrderCount}次订单");

}

});
@@ -60,7 +65,6 @@ namespace BPASmartClient.MorkBF
if (@event is MaterialDeliveryEvent material)
{
orderMaterialDelivery = material.orderMaterialDelivery;

}
});

@@ -132,11 +136,55 @@ namespace BPASmartClient.MorkBF

public override void MainTask()
{
if(morkBF.FirePan1_Order.Count>0&& morkBF.FirePot1_InitCompleted&&morkBF.FirePot2_IsAuto&&!morkBF.FirePan1_Busy)
{
ThreadManage.GetInstance().Start(FirePot1_Process, "炒锅1流程");
}

if(morkBF.RobotActinQueue.Count>0&&! morkBF.Robot_Origin)//机器人在原点为
{
if( morkBF.RobotActinQueue.TryDequeue(out RobotAction_Pot robotAction))
{
morkBF.Robot_IsBusy =true;
RobotProcess(robotAction);
}
}
}

private void FirePot1_Process()
{
if(morkBF.FirePan1_Order.TryDequeue(out FryPotMessages result))
{
morkBF.FirePan1_Busy = true;
foreach (var item in result.fryPotProcesses)
{
switch (item.fryActions)
{
case FryAction.冷锅加热:
FirePot_PotPerHeat(item, 1);
break;

case FryAction.热油:
FirePot_HeatOil(item,1);
break;

case FryAction.加调料:
FirePot_AddSeasoning(item, 1);
break;
case FryAction.加辅料:
break;
case FryAction.炒制菜品:
FirePot_FryFood(item,1);
break;

default:
break;
}
}
}
}

private void FirePot2_Process()
@@ -144,6 +192,192 @@ namespace BPASmartClient.MorkBF
}


#region 炒锅流程功能
/// <summary>
/// 冷锅预热
/// </summary>
private void FirePot_PotPerHeat(FryPotProcess item,int i)
{
if(i == 1)//炒锅1
{
FirePot1_SetFireGear(item.FryGear);
FirePot1_StartFire(true);
}
else if(i == 2)//炒锅2
{
FirePot2_SetFireGear(item.FryGear);
FirePot2_StartFire(true);
}
Thread.Sleep(item.FryDuration);
}

/// <summary>
/// 热油
/// </summary>
private void FirePot_HeatOil(FryPotProcess item, int i)
{
if (item.FryGear != 0)
{
FirePot1_SetFireGear(item.FryGear);//设定加热挡位
FirePot1_StartFire(true);//开启加热
}
if (item.StirGear != 0)
{
FirePot1_SetStirGear(item.StirGear);//设定搅拌挡位
FirePot1_StartFire(true);//开启搅拌
}
Thread.Sleep(item.FryDuration);//加热时间;
}

/// <summary>
/// 加调料
/// </summary>
private void FirePot_AddSeasoning(FryPotProcess item,int i)
{
if(i == 1)
{
morkBF.RobotActinQueue.Enqueue(new RobotAction_Pot { Pot =1,robotActionModel = RobotActionModel.取1号炒锅调料盆倒入1号炒锅});
Thread.Sleep(item.FryDuration);

}

else if(i == 2)
{
morkBF.RobotActinQueue.Enqueue(new RobotAction_Pot { Pot = 2, robotActionModel = RobotActionModel.取2号炒锅调料盆倒入2号炒锅 });
Thread.Sleep(item.FryDuration);
}
}

/// <summary>
/// 加辅料
/// </summary>
private void FirePot_AddAccessories(FryPotProcess item, int i)
{
if (i == 1)
{

morkBF.RobotActinQueue.Enqueue(new RobotAction_Pot { Pot = 1, robotActionModel = RobotActionModel.取1号炒锅辅料盆1倒入1号炒锅 });
Thread.Sleep(item.FryDuration);

}

else if (i == 2)
{
morkBF.RobotActinQueue.Enqueue(new RobotAction_Pot { Pot = 2, robotActionModel = RobotActionModel.取2号炒锅辅料盆1倒入2号炒锅 });
Thread.Sleep(item.FryDuration);
}

}

/// <summary>
/// 炒制菜品
/// </summary>
private void FirePot_FryFood(FryPotProcess item, int i)
{
if (i == 1)
{
morkBF.RobotActinQueue.Enqueue(new RobotAction_Pot { Pot = 1, robotActionModel = (RobotActionModel)item.accessories[0].Loc });
while (!morkBF.FirePot1_CompleteSingle[item.accessories[0].Loc])//取菜信号是否完成
{
Thread.Sleep(100);
}
Thread.Sleep(item.FryDuration);

}

else if (i == 2)
{
morkBF.RobotActinQueue.Enqueue(new RobotAction_Pot { Pot = 2, robotActionModel = (RobotActionModel)(item.accessories[0].Loc+19) });//炒制菜品位置
while (!morkBF.FirePot2_CompleteSingle[item.accessories[0].Loc])//取菜信号是否完成
{
Thread.Sleep(100);
}
Thread.Sleep(item.FryDuration);
}
}
#endregion

/// <summary>
/// 机器人进程
/// </summary>
/// <param name="robotAction"></param>
private void RobotProcess(RobotAction_Pot robotAction)
{
Robot_Write("GI0",(int)robotAction.robotActionModel);
while (morkBF.Robot_ActionCallback != (int)robotAction.robotActionModel)//机器人动作执行完动作反馈
{
Thread.Sleep(100);
}
if(robotAction.Pot == 1)//炒锅1
{
if (robotAction.robotActionModel == RobotActionModel.取1号空盆出餐)
{
Robot_Write("GM521", true);//炒锅去投料位置
while(!morkBF.Robot_ArriveFirePot1)//机器人到位,请求1#炒锅倒菜
{
Thread.Sleep(100);
}
FirePot_Write("M11.6", true);//炒锅去出餐倒料位置
while (!morkBF.FirePot1_PotOnOutFoodPosition)//炒锅在出餐倒料位置反馈
{
Thread.Sleep(1000);
}
Thread.Sleep(20 * 1000);//等待20s出餐

}
else
{
FirePot_Write("M11.7", true);//炒锅去投料位置
while (!morkBF.FirePot1_PotOnIntoFoodPosition)//等待炒锅允许倒料
{
Thread.Sleep(100);
}
Robot_Write("GM520", true);//机器人投料
}
}
else if (robotAction.Pot == 2)
{
if (robotAction.robotActionModel == RobotActionModel.取1号空盆出餐)
{
Robot_Write("GM531", true);//炒锅去投料位置
while (!morkBF.Robot_ArriveFirePot2)//机器人到位,请求1#炒锅倒菜
{
Thread.Sleep(100);
}
FirePot_Write("M16.6", true);//炒锅去出餐倒料位置
while (!morkBF.FirePot2_PotOnOutFoodPosition)//炒锅在出餐倒料位置反馈
{
Thread.Sleep(1000);
}
Thread.Sleep(20 * 1000);//等待20s出餐

}
else
{
FirePot_Write("M16.7", true);
while (!morkBF.FirePot2_PotOnIntoFoodPosition)
{
Thread.Sleep(100);
}
Robot_Write("GM530", true);
}
}
while(!morkBF.Robot_Origin)
{
Thread.Sleep(1000);
}
morkBF.Robot_IsBusy = false;
MessageLog.GetInstance.Show($"机器人完成[{robotAction.robotActionModel.ToString()}]任务");
}

public override void ReadData()
{
GetStatus("M20.0",new Action<object>((o)=>
@@ -228,9 +462,10 @@ namespace BPASmartClient.MorkBF
if (o == null) return;
if (o is bool[] values && values.Length == 7)
{
morkBF.Robot_FirePot1OutMeal = values[0];
morkBF.Robot_FirePot1OutVegetables1 = values[1];
morkBF.Robot_FirePot1OutVegetables2 = values[2];

morkBF.FirePot1_CompleteSingle[0] = values[0];
morkBF.FirePot1_CompleteSingle[1] = values[1];
morkBF.FirePot1_CompleteSingle[2] = values[2];
morkBF.Robot_FirePot1OutSeasoning = values[3];
morkBF.Robot_FirePot1OutAccessories = values[4];
morkBF.Robot_ArriveFirePot1 = values[5];
@@ -243,9 +478,9 @@ namespace BPASmartClient.MorkBF
if (o == null) return;
if (o is bool[] values && values.Length == 7)
{
morkBF.Robot_FirePot2OutMeal = values[0];
morkBF.Robot_FirePot2OutVegetables1 = values[1];
morkBF.Robot_FirePot2OutVegetables2 = values[2];
morkBF.FirePot2_CompleteSingle[0] = values[0];
morkBF.FirePot2_CompleteSingle[1] = values[1];
morkBF.FirePot2_CompleteSingle[2] = values[2];
morkBF.Robot_FirePot2OutSeasoning = values[3];
morkBF.Robot_FirePot2OutAccessories = values[4];
morkBF.Robot_ArriveFirePot2 = values[5];
@@ -319,7 +554,7 @@ namespace BPASmartClient.MorkBF
{
FirePot_Write("VW100", value);
}
Thread.Sleep(200);
}
/// <summary>
/// 炒锅1加热启停
@@ -332,6 +567,7 @@ namespace BPASmartClient.MorkBF
{
FirePot_Write("M10.0", value);
}
Thread.Sleep(200);
}
/// <summary>
/// 炒锅1设置搅拌挡位
@@ -344,6 +580,7 @@ namespace BPASmartClient.MorkBF
{
FirePot_Write("VW102", value);
}
Thread.Sleep(200);
}
/// <summary>
/// 炒锅1搅拌启停
@@ -356,6 +593,7 @@ namespace BPASmartClient.MorkBF
{
FirePot_Write("M10.1", value);
}
Thread.Sleep(200);
}
/// <summary>
/// 设置炒锅1翻转速度
@@ -368,6 +606,7 @@ namespace BPASmartClient.MorkBF
{
FirePot_Write("VW104", value);
}
Thread.Sleep(200);
}
#endregion

@@ -383,7 +622,7 @@ namespace BPASmartClient.MorkBF
{
FirePot_Write("VW130", value);
}
Thread.Sleep(200);
}
/// <summary>
/// 炒锅2加热启停
@@ -396,6 +635,7 @@ namespace BPASmartClient.MorkBF
{
FirePot_Write("M15.0", value);
}
Thread.Sleep(200);
}
/// <summary>
/// 炒锅2设置搅拌挡位
@@ -408,6 +648,7 @@ namespace BPASmartClient.MorkBF
{
FirePot_Write("VW132", value);
}
Thread.Sleep(200);
}
/// <summary>
/// 炒锅2搅拌启停
@@ -420,6 +661,7 @@ namespace BPASmartClient.MorkBF
{
FirePot_Write("M15.1", value);
}
Thread.Sleep(200);
}
/// <summary>
/// 设置炒锅2翻转速度
@@ -432,6 +674,7 @@ namespace BPASmartClient.MorkBF
{
FirePot_Write("VW134", value);
}
Thread.Sleep(200);
}

#endregion
@@ -476,6 +719,7 @@ namespace BPASmartClient.MorkBF
FirePot_Write("M15.5", true);
}
}
Thread.Sleep(200);
}
/// <summary>
/// 炒锅去位置1
@@ -495,6 +739,7 @@ namespace BPASmartClient.MorkBF
FirePot_Write("M16.2", true);
}
}
Thread.Sleep(200);
}
/// <summary>
/// 炒锅去位置2
@@ -514,6 +759,7 @@ namespace BPASmartClient.MorkBF
FirePot_Write("M16.3", true);
}
}
Thread.Sleep(200);
}
/// <summary>
/// 炒锅去位置3
@@ -533,6 +779,7 @@ namespace BPASmartClient.MorkBF
FirePot_Write("M16.4", true);
}
}
Thread.Sleep(200);
}
/// <summary>
/// 炒锅去位置4
@@ -552,6 +799,7 @@ namespace BPASmartClient.MorkBF
FirePot_Write("M16.5", true);
}
}
Thread.Sleep(200);
}
/// <summary>
/// 炒锅去出餐位置
@@ -571,6 +819,7 @@ namespace BPASmartClient.MorkBF
FirePot_Write("M16.6", true);
}
}
Thread.Sleep(200);
}
/// <summary>
/// 炒锅去投料位置
@@ -590,6 +839,7 @@ namespace BPASmartClient.MorkBF
FirePot_Write("M16.7", true);
}
}
Thread.Sleep(200);
}
/// <summary>
/// 出餐启动
@@ -610,6 +860,7 @@ namespace BPASmartClient.MorkBF
}

}
Thread.Sleep(200);
}
/// <summary>
/// 清洗
@@ -622,13 +873,15 @@ namespace BPASmartClient.MorkBF
{
if (i == 1)
{
FirePot_Write("M10.7", true);
if(morkBF.FirePot1_OnOrigin) FirePot_Write("M10.7", true);

}
else if (i == 2)
{
FirePot_Write("M15.7", true);
if (morkBF.FirePot2_OnOrigin) FirePot_Write("M15.7", true);
}
}
Thread.Sleep(200);
}
/// <summary>
/// 抽水启动
@@ -648,6 +901,7 @@ namespace BPASmartClient.MorkBF
FirePot_Write("M16.0", true);
}
}
Thread.Sleep(200);
}
/// <summary>
/// 抽油启动
@@ -667,6 +921,7 @@ namespace BPASmartClient.MorkBF
FirePot_Write("M16.1", true);
}
}
Thread.Sleep(200);
}
#endregion

@@ -677,6 +932,7 @@ namespace BPASmartClient.MorkBF
private void RobotStart()
{
Robot_Write("GM600",true);
Thread.Sleep(200);
}
/// <summary>
/// 机器人停止
@@ -684,6 +940,7 @@ namespace BPASmartClient.MorkBF
private void RobotStop()
{
Robot_Write("GM601", true);
Thread.Sleep(200);
}
/// <summary>
/// 机器人复位
@@ -691,6 +948,7 @@ namespace BPASmartClient.MorkBF
private void RobotReset()
{
Robot_Write("GM602", true);
Thread.Sleep(200);
}
/// <summary>
/// 机器人程序重启
@@ -698,6 +956,7 @@ namespace BPASmartClient.MorkBF
private void RobotProgramStart()
{
Robot_Write("GM603", true);
Thread.Sleep(200);
}
/// <summary>
/// 1号炒锅允许机器人投料(炒锅在投料位给出)
@@ -705,6 +964,7 @@ namespace BPASmartClient.MorkBF
private void Robot_Pot1AllowInMaterail()
{
Robot_Write("GM520", true);
Thread.Sleep(200);
}
/// <summary>
/// 1号炒锅出餐倒料到减速位
@@ -712,6 +972,7 @@ namespace BPASmartClient.MorkBF
private void Robot_Pot1OutFoodInSlowDown()
{
Robot_Write("GM621", true);
Thread.Sleep(200);
}
/// <summary>
/// 1号炒锅出餐倒料完成
@@ -719,6 +980,7 @@ namespace BPASmartClient.MorkBF
private void Robot_Pot1OutFood()
{
Robot_Write("GM522", true);
Thread.Sleep(200);
}
/// <summary>
/// 2号炒锅允许机器人投料(炒锅在投料位给出)
@@ -726,6 +988,7 @@ namespace BPASmartClient.MorkBF
private void Robot_Pot2AllowInMaterail()
{
Robot_Write("GM530", true);
Thread.Sleep(200);
}
/// <summary>
/// 2号炒锅出餐倒料到减速位。开始倒菜
@@ -733,6 +996,7 @@ namespace BPASmartClient.MorkBF
private void Robot_Pot2OutFoodInSlowDown()
{
Robot_Write("GM531", true);
Thread.Sleep(200);
}
/// <summary>
/// 2号炒锅出餐倒料完成
@@ -740,6 +1004,7 @@ namespace BPASmartClient.MorkBF
private void Robot_Pot2OutFood()
{
Robot_Write("GM532", true);
Thread.Sleep(200);
}
/// <summary>
///
@@ -751,6 +1016,7 @@ namespace BPASmartClient.MorkBF
{
Robot_Write("GI0",value);
}
Thread.Sleep(200);
}
#endregion



+ 127
- 0
BPASmartClient.MorkBF/Convert/FryActionToVisibilityConverter.cs ファイルの表示

@@ -0,0 +1,127 @@
using BPASmartClient.Model.大炒;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;

namespace BPASmartClient.MorkBF.Convert
{
public class StirToVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
Visibility visibility = Visibility.Visible;
if (value != null && value is FryAction fryAction)
{
switch (fryAction)
{
case FryAction.冷锅加热:
visibility = Visibility.Collapsed;
break;
case FryAction.热油:
visibility = Visibility.Visible;
break;
case FryAction.加调料:
visibility = Visibility.Collapsed;
break;
case FryAction.加辅料:
visibility = Visibility.Collapsed;
break;
case FryAction.炒制菜品:
visibility = Visibility.Visible;
break;
default:
break;
}
}
return visibility;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}

public class FirePositionToVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
Visibility visibility = Visibility.Visible;
if (value != null && value is FryAction fryAction)
{
switch (fryAction)
{
case FryAction.冷锅加热:
visibility = Visibility.Visible;
break;
case FryAction.热油:
visibility = Visibility.Visible;
break;
case FryAction.加调料:
visibility = Visibility.Collapsed;
break;
case FryAction.加辅料:
visibility = Visibility.Collapsed;
break;
case FryAction.炒制菜品:
visibility = Visibility.Visible;
break;
default:
break;
}
}
return visibility;
}


public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}

public class AccessoriesToVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
Visibility visibility = Visibility.Visible;
if (value != null && value is FryAction fryAction)
{
switch (fryAction)
{
case FryAction.冷锅加热:
visibility = Visibility.Collapsed;
break;
case FryAction.热油:
visibility = Visibility.Collapsed;
break;
case FryAction.加调料:
visibility = Visibility.Visible;
break;
case FryAction.加辅料:
visibility = Visibility.Visible;
break;
case FryAction.炒制菜品:
visibility = Visibility.Visible;
break;
default:
break;
}
}
return visibility;
}


public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}


+ 48
- 14
BPASmartClient.MorkBF/GVL_MorkBF.cs ファイルの表示

@@ -1,4 +1,5 @@
using BPASmartClient.Device;
using BPASmartClient.Model.大炒;
using BPASmartClient.MorkBF.Model;
using System;
using System.Collections.Concurrent;
@@ -14,11 +15,15 @@ namespace BPASmartClient.MorkBF
/// <summary>
/// 炒锅1订单队列
/// </summary>
public ConcurrentQueue<BF_Food> FirePan1_Order { get; set; } = new ConcurrentQueue<BF_Food>();
public ConcurrentQueue<FryPotMessages> FirePan1_Order { get; set; } = new ConcurrentQueue<FryPotMessages>();
/// <summary>
/// 炒锅2订单队列
/// </summary>
public ConcurrentQueue<BF_Food> FirePan2_Order { get; set; } = new ConcurrentQueue<BF_Food>();
public ConcurrentQueue<FryPotMessages> FirePan2_Order { get; set; } = new ConcurrentQueue<FryPotMessages>();
/// <summary>
/// 机器人队列
/// </summary>
public ConcurrentQueue<RobotAction_Pot> RobotActinQueue { get; set; } = new ConcurrentQueue<RobotAction_Pot>();
/// <summary>
/// 炒锅1忙碌
/// </summary>
@@ -247,30 +252,39 @@ namespace BPASmartClient.MorkBF
#endregion

#region 机器人数据读取
public bool Robot_IsBusy;


/// <summary>
/// 机器人在原点位
/// </summary>
[VariableMonitor("机器人在原点位", "GM105", "4201")]
public bool Robot_Origin { get; set; }

/// <summary>
/// 1号锅倒荤菜完成
/// </summary>
[VariableMonitor("1号锅倒荤菜完成", "GM500", "4596")]
[VariableMonitor("机器人#1号锅倒荤菜完成", "GM500", "4596")]
public bool Robot_FirePot1OutMeal{ get; set; }
/// <summary>
/// 1号炒锅倒素菜1完成
/// </summary>
[VariableMonitor("1号炒锅倒素菜1完成", "GM501", "4597")]
[VariableMonitor("机器人#1号炒锅倒素菜1完成", "GM501", "4597")]
public bool Robot_FirePot1OutVegetables1{ get; set; }
/// <summary>
/// 1号炒锅倒素菜2完成
/// </summary>
[VariableMonitor("1号炒锅倒素菜2完成", "GM502", "4598")]
[VariableMonitor("机器人#1号炒锅倒素菜2完成", "GM502", "4598")]
public bool Robot_FirePot1OutVegetables2{ get; set; }
/// <summary>
/// 1号炒锅倒调料完成
/// </summary>
[VariableMonitor("1号炒锅倒调料完成", "GM503", "4599")]
[VariableMonitor("机器人#1号炒锅倒调料完成", "GM503", "4599")]
public bool Robot_FirePot1OutSeasoning{ get; set; }
/// <summary>
/// 1号炒锅倒辅料完成
/// </summary>
[VariableMonitor("1号炒锅倒辅料完成", "GM504", "4600")]
[VariableMonitor("机器人#1号炒锅倒辅料完成", "GM504", "4600")]
public bool Robot_FirePot1OutAccessories{ get; set; }
/// <summary>
/// 机器人到位,请求1#炒锅倒菜
@@ -280,7 +294,7 @@ namespace BPASmartClient.MorkBF
/// <summary>
/// 1号炒锅出餐完成
/// </summary>
[VariableMonitor("1号炒锅出餐完成", "GM506", "4602")]
[VariableMonitor("机器人#1号炒锅出餐完成", "GM506", "4602")]
public bool Robot_FirePot1OutFoodComplete{ get; set; }


@@ -290,12 +304,12 @@ namespace BPASmartClient.MorkBF
/// <summary>
/// 2号锅倒荤菜完成
/// </summary>
[VariableMonitor("2号锅倒荤菜完成", "GM510", "4606")]
[VariableMonitor("机器人#2号锅倒荤菜完成", "GM510", "4606")]
public bool Robot_FirePot2OutMeal { get; set; }
/// <summary>
/// 2号炒锅倒素菜1完成
/// </summary>
[VariableMonitor("2号炒锅倒素菜1完成", "GM511", "4607")]
[VariableMonitor("机器人#2号炒锅倒素菜1完成", "GM511", "4607")]
public bool Robot_FirePot2OutVegetables1{ get; set; }
/// <summary>
/// 2号炒锅倒素菜2完成
@@ -305,22 +319,22 @@ namespace BPASmartClient.MorkBF
/// <summary>
/// 2号炒锅倒调料完成
/// </summary>
[VariableMonitor("2号炒锅倒调料完成", "GM513", "4609")]
[VariableMonitor("机器人#2号炒锅倒调料完成", "GM513", "4609")]
public bool Robot_FirePot2OutSeasoning{ get; set; }
/// <summary>
/// 2号炒锅倒辅料完成
/// </summary>
[VariableMonitor("2号炒锅倒辅料完成", "GM514", "4610")]
[VariableMonitor("机器人#2号炒锅倒辅料完成", "GM514", "4610")]
public bool Robot_FirePot2OutAccessories{ get; set; }
/// <summary>
/// 机器人到位,请求1#炒锅倒菜
/// </summary>
[VariableMonitor("机器人到位,请求1#炒锅倒菜", "GM515", "4611")]
[VariableMonitor("机器人#机器人到位,请求1#炒锅倒菜", "GM515", "4611")]
public bool Robot_ArriveFirePot2{ get; set; }
/// <summary>
/// 2号炒锅出餐完成
/// </summary>
[VariableMonitor("2号炒锅出餐完成", "GM516", "4612")]
[VariableMonitor("机器人#2号炒锅出餐完成", "GM516", "4612")]
public bool Robot_FirePot2OutFoodComplete{ get; set; }
/// <summary>
/// 机器人动作反馈
@@ -330,7 +344,27 @@ namespace BPASmartClient.MorkBF

#endregion

public Dictionary<int, bool> FirePot1_CompleteSingle { get; set; }

public Dictionary<int, bool> FirePot2_CompleteSingle { get; set; }


public GVL_MorkBF()
{
FirePot1_CompleteSingle = new Dictionary<int, bool>
{
{1,Robot_FirePot1OutMeal },
{2,Robot_FirePot1OutVegetables1 },
{3,Robot_FirePot1OutVegetables2 },
};
FirePot2_CompleteSingle = new Dictionary<int, bool>
{
{1,Robot_FirePot2OutMeal },
{2,Robot_FirePot2OutVegetables1 },
{3,Robot_FirePot2OutVegetables2 },
};

}

public DateTime FirePan1_Date;
public DateTime FirePan2_Date;


+ 31
- 1
BPASmartClient.MorkBF/Model/BF_Food.cs ファイルの表示

@@ -17,6 +17,8 @@ namespace BPASmartClient.MorkBF.Model
/// </summary>
public string FoodID { get; set; }

public List<BF_PotAction> PotActions { get; set; } = new List<BF_PotAction>();

}

public class BF_PotAction
@@ -40,7 +42,7 @@ namespace BPASmartClient.MorkBF.Model
/// <summary>
/// 动作
/// </summary>
public string Actions
public PotAction Actions
{
get;
set;
@@ -62,4 +64,32 @@ namespace BPASmartClient.MorkBF.Model
set;
}
}


public enum PotAction
{
加热开启,
加热关闭,
搅拌开启,
搅拌关闭,

加调料,
加菜品,
加辅料,
加热时间,

抽油启动,
抽水启动,
出餐启动,

炒锅回原点,
炒制位置1,
炒制位置2,
炒制位置3,
炒制位置4,
炒锅去出餐倒料位置,
炒锅去投料位置,


}
}

+ 14
- 0
BPASmartClient.MorkBF/Model/Global.cs ファイルの表示

@@ -0,0 +1,14 @@
using BPASmartClient.Model.大炒;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmartClient.MorkBF.Model
{
public class Global
{
public static FryPotMessages GLoFryMessage { get; set; } = new FryPotMessages();
}
}

+ 32
- 6
BPASmartClient.MorkBF/VIew/DebugView.xaml ファイルの表示

@@ -21,14 +21,40 @@
</UserControl.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="40"/>
<RowDefinition Height="2*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<GroupBox Header="炒锅1" FontSize="22">


<WrapPanel Grid.Row="1" Orientation="Horizontal">
<Button Content="添加新菜品" Width="200" Click="Button_Click"/>
<ListBox Grid.Row="1" ItemsSource="{Binding fryPotMessages}">
<ListBox.Template>
<ControlTemplate TargetType="{x:Type ListBox}">
<WrapPanel Orientation="Horizontal" IsItemsHost="True"></WrapPanel>
</ControlTemplate>
</ListBox.Template>
<ListBox.ItemTemplate>
<DataTemplate>
<Border Margin="5,10">
<Border.Background>
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/矩形.png"/>
</Border.Background>
<StackPanel Orientation="Horizontal" Margin="10">
<TextBlock Text="{Binding GoodName}" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="18" Margin="10,0"/>
<Button Content="编辑" Command="{Binding DataContext.MenuEditCommand, RelativeSource={RelativeSource AncestorType=UserControl,Mode=FindAncestor}}"
CommandParameter="{Binding DataContext , RelativeSource={RelativeSource AncestorType=ListBoxItem,Mode=FindAncestor}}" Margin="10,0"/>
<Button Content="删除 " Command="{Binding DataContext.MenuDeleteCommand, RelativeSource={RelativeSource AncestorType=UserControl,Mode=FindAncestor}}"
CommandParameter="{Binding DataContext , RelativeSource={RelativeSource AncestorType=ListBoxItem,Mode=FindAncestor}}" Margin="10,0"/>
</StackPanel>
</Border>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<GroupBox Grid.Row="2" Header="炒锅1" FontSize="22">
<WrapPanel Orientation="Horizontal">
<Button Content="复位" Width="110" Margin="10,5" Command="{Binding FirePot_ResetCommand}" CommandParameter="1"/>
<TextBlock Text="加热挡位" Margin="10,5"/>
<ComboBox Width="80" ItemsSource="{Binding FireGear}" Margin="10,5" SelectedItem="{Binding FirePot1_FireGear}"/>
@@ -57,7 +83,7 @@
</WrapPanel>

</GroupBox>
<GroupBox Grid.Row="1" Header="炒锅2" FontSize="22">
<GroupBox Grid.Row="3" Header="炒锅2" FontSize="22">
<WrapPanel Grid.Row="1" Orientation="Horizontal">
<Button Content="复位" Width="110" Margin="10,5" Command="{Binding FirePot_ResetCommand}" CommandParameter="1"/>
<TextBlock Text="加热挡位" Margin="10,5"/>
@@ -86,7 +112,7 @@
<Button Content="炒锅去投料位置" Width="110" Margin="10,5" Command="{Binding FirePot_PotGotoInFoodPositionCommand}" CommandParameter="2"/>
</WrapPanel>
</GroupBox>
<GroupBox Grid.Row="3" Header="机器人" FontSize="22">
<GroupBox Grid.Row="4" Header="机器人" FontSize="22">
<WrapPanel Orientation="Horizontal">
<Button Content="机器人启动" Width="110" Margin="10,5" Command="{Binding RobotStartCommand}"/>
<Button Content="复位" Width="110" Margin="10,5" Command="{Binding RobotResetCommand}"/>


+ 9
- 1
BPASmartClient.MorkBF/VIew/DebugView.xaml.cs ファイルの表示

@@ -1,4 +1,5 @@
using System;
using BPASmartClient.MorkBF.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -24,5 +25,12 @@ namespace BPASmartClient.MorkBF.VIew
{
InitializeComponent();
}

private void Button_Click(object sender, RoutedEventArgs e)
{
Global.GLoFryMessage = null;
FoodManagerView foodManagerView = new FoodManagerView();
foodManagerView.ShowDialog();
}
}
}

+ 58
- 33
BPASmartClient.MorkBF/VIew/FoodManagerView.xaml ファイルの表示

@@ -4,47 +4,72 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:BPASmartClient.MorkBF.VIew"
xmlns:con="clr-namespace:BPASmartClient.MorkBF.Convert"
xmlns:vm ="clr-namespace:BPASmartClient.MorkBF.ViewModel"
mc:Ignorable="d"
Title="FoodManagerView" Height="450" Width="800" WindowStartupLocation="CenterScreen" ResizeMode="NoResize" WindowStyle="None" AllowsTransparency="True" Background="Transparent">
Title="FoodManagerView" Height="450" Width="1020" WindowStartupLocation="CenterScreen" ResizeMode="NoResize" WindowStyle="None" AllowsTransparency="True" Background="Transparent">
<Window.DataContext>
<vm:FoodManagerViewModel/>
</Window.DataContext>
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/GenricStyle.xaml" />
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/MyStyle.xaml" />
</ResourceDictionary.MergedDictionaries>
<con:StirToVisibilityConverter x:Key="StirToVisibilityConverter" />
<con:FirePositionToVisibilityConverter x:Key="FirePositionToVisibilityConverter" />
<con:AccessoriesToVisibilityConverter x:Key="AccessoriesToVisibilityConverter" />
</ResourceDictionary>
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="50"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center" Height="45">
<TextBlock Text="菜品名称:" Margin="10,0"/>
<TextBox Text="{Binding FoodName}" Width="160" Margin="10,0" FontSize="16"/>
<Button Content="添加新步骤" Margin="10,0" Style="{StaticResource ButtonStyle}" Height="36" />
<Button Content="保存" Margin="10,0" Style="{StaticResource ButtonStyle}" Height="36" Width="80"/>
<Button Content="退出" Margin="10,0" Style="{StaticResource ButtonStyle}" Height="36" Width="80"/>
</StackPanel>
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<ListBox >
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<ComboBox />
<Button Content="删除"/>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<Border CornerRadius="1,60,00,70" Background="#1E1E1E" >
<Grid MouseLeftButtonDown="Grid_MouseLeftButtonDown">
<Grid.Background>
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/不规则矩形.png"/>
</Grid.Background>
<Grid.RowDefinitions>
<RowDefinition Height="50"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center" Height="45">
<TextBlock Text="菜品名称:" Margin="10,0"/>
<TextBox Text="{Binding GoodName}" Width="160" Margin="10,0" FontSize="16"/>
<Button Content="添加新步骤" Margin="10,0" Style="{StaticResource ButtonStyle}" Height="36" Command="{Binding AddCommand}"/>
<Button Content="保存" Margin="10,0" Style="{StaticResource ButtonStyle}" Height="36" Width="80" Command="{Binding SaveCommand}"/>
<Button Content="退出" Margin="10,0" Style="{StaticResource ButtonStyle}" Height="36" Width="80" Click="Button_Click"/>
</StackPanel>
<Grid Grid.Row="1">
<ListBox ItemsSource="{Binding FryPotProcesses}" FontSize="15">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Margin="0,10">
<TextBlock Text="步骤--" Margin="10,0,2,0" VerticalAlignment="Center"/>
<TextBlock Text="{Binding FryTime}" VerticalAlignment="Center"/>
<TextBlock Text="加热时间--" Margin="10,0,2,0" VerticalAlignment="Center"/>
<TextBox Text="{Binding FryDuration}" Margin="10,0" Width="40" VerticalAlignment="Center"/>
<TextBlock Text="动作--" Margin="10,0,2,0" VerticalAlignment="Center"/>
<ComboBox ItemsSource="{Binding DataContext.FryAction,RelativeSource={RelativeSource AncestorType=Window,Mode=FindAncestor}}"
SelectedItem="{Binding fryActions}" Width="100" IsReadOnly="True" Margin="2,0,10,0"/>
<TextBlock Text="加热挡位--" Margin="10,0,2,0" VerticalAlignment="Center"/>
<ComboBox ItemsSource="{Binding DataContext.Gear,RelativeSource={RelativeSource AncestorType=Window,Mode=FindAncestor}}"
SelectedItem="{Binding FryGear}" Width="50" Margin="2,0,10,0" />
<TextBlock Text="搅拌挡位--" Margin="10,0,2,0" VerticalAlignment="Center"
Visibility="{Binding fryActions,Converter={StaticResource StirToVisibilityConverter}}"/>
<ComboBox ItemsSource="{Binding DataContext.Gear,RelativeSource={RelativeSource AncestorType=Window,Mode=FindAncestor}}" SelectedItem="{Binding StirGear}" Width="50" Margin="2,0,10,0"
Visibility="{Binding fryActions,Converter={StaticResource StirToVisibilityConverter}}"/>
<TextBlock Text="炒制位置--" Margin="10,0,2,0" VerticalAlignment="Center"
Visibility="{Binding fryActions,Converter={StaticResource FirePositionToVisibilityConverter}}"/>
<ComboBox ItemsSource="{Binding DataContext.PotPostion,RelativeSource={RelativeSource AncestorType=Window,Mode=FindAncestor} }" SelectedItem="{Binding FryPosition}" Width="50" Margin="2,0,10,0"
Visibility="{Binding fryActions,Converter={StaticResource FirePositionToVisibilityConverter}}"/>
<TextBlock Text="物料位置--" Margin="10,0,2,0" VerticalAlignment="Center"
Visibility="{Binding fryActions,Converter={StaticResource AccessoriesToVisibilityConverter}}"/>
<TextBox Text="{Binding accessories[0].Loc}" VerticalAlignment="Center" Width="50"
Visibility="{Binding fryActions,Converter={StaticResource AccessoriesToVisibilityConverter}}"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</Grid>
</Grid>
</Border>
</Window>

+ 18
- 1
BPASmartClient.MorkBF/VIew/FoodManagerView.xaml.cs ファイルの表示

@@ -1,4 +1,6 @@
using System;

using BPASmartClient.Helper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -22,6 +24,21 @@ namespace BPASmartClient.MorkBF.VIew
public FoodManagerView()
{
InitializeComponent();
ActionManage.GetInstance.CancelRegister("FoodManagerViewClose");
ActionManage.GetInstance.Register(new Action(()=>
{
this.Close();
}), "FoodManagerViewClose");
}

private void Button_Click(object sender, RoutedEventArgs e)
{
ActionManage.GetInstance.Send("FoodManagerViewClose");
}

private void Grid_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
this.DragMove();
}
}
}

+ 39
- 5
BPASmartClient.MorkBF/ViewModel/DebugViewModel.cs ファイルの表示

@@ -1,19 +1,50 @@
using System;
global using CommunityToolkit.Mvvm.ComponentModel;
global using CommunityToolkit.Mvvm.Input;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BPASmartClient.Helper;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using BPASmartClient.Model.大炒;
using BPASmartClient.MorkBF.Model;
using BPASmartClient.MorkBF.VIew;

namespace BPASmartClient.MorkBF.ViewModel
{
[INotifyPropertyChanged]
partial class DebugViewModel
{
{

public ObservableCollection<FryPotMessages> fryPotMessages { get; set; } = Json<LocalFryPotMessage>.Data.FryPotMessage;

[RelayCommand]
private void MenuEdit(object o)
{
if (o == null) return;
if(o is FryPotMessages value)
{
Global.GLoFryMessage = value;
FoodManagerView foodManagerView = new FoodManagerView();
foodManagerView.ShowDialog();
}
}

[RelayCommand]
private void MenuDelete(object o)
{
if (o == null) return;
if (o is FryPotMessages value)
{
fryPotMessages.Remove(value);
}
Json<LocalFryPotMessage>.Save();
}




/// <summary>
/// 加热挡位
/// </summary>
@@ -369,5 +400,8 @@ namespace BPASmartClient.MorkBF.ViewModel
}

#endregion


}
}

+ 93
- 0
BPASmartClient.MorkBF/ViewModel/FoodManagerViewModel.cs ファイルの表示

@@ -0,0 +1,93 @@
using BPASmartClient.Helper;
using BPASmartClient.Model.大炒;
using BPASmartClient.MorkBF.Model;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmartClient.MorkBF.ViewModel
{
[INotifyPropertyChanged]
partial class FoodManagerViewModel
{
/// <summary>
/// 菜品步骤
/// </summary>
public ObservableCollection<FryPotProcess> FryPotProcesses { get; set; } =new ObservableCollection<FryPotProcess>();

public ObservableCollection<FryAction> FryAction { get; set; } = new ObservableCollection<FryAction>();

public ObservableCollection<int> Gear { get; set; } = new ObservableCollection<int>() { 0,1, 2, 3, 4, 5 };

public ObservableCollection<int> PotPostion { get; set; } = new ObservableCollection<int>() { 1, 2,3, 4 };

[ObservableProperty]
private string _goodName;
[RelayCommand]
private void Add()
{
FryPotProcesses.Add(new FryPotProcess() { FryTime = FryPotProcesses.Count + 1 });
}

[RelayCommand]
private void Save()
{
if (string.IsNullOrEmpty(GoodName)) return;
if (Global.GLoFryMessage != null)
{
var res = Json<LocalFryPotMessage>.Data.FryPotMessage.FirstOrDefault(p => p.GoodKey == Global.GLoFryMessage.GoodKey);
if (res != null)
{
res.GoodName = GoodName;
res.fryPotProcesses = FryPotProcesses.ToList();
}
}
else
{
if (Json<LocalFryPotMessage>.Data.FryPotMessage.FirstOrDefault(p => p.GoodName == _goodName) != null) return;
Json<LocalFryPotMessage>.Data.FryPotMessage.Add(new FryPotMessages
{
GoodName = GoodName,
GoodKey = new Guid().ToString(),
fryPotProcesses = FryPotProcesses.ToList()
});
}
Json<LocalFryPotMessage>.Save();
ActionManage.GetInstance.Send("FoodManagerViewClose");
}

[RelayCommand]
private void Delete(object o)
{
if (o == null) return;
if (o is FryPotProcess value)
{
FryPotProcesses.Remove(value);
}
}



public FoodManagerViewModel()
{
foreach(var item in Enum.GetValues(typeof(FryAction)))
{
FryAction.Add((FryAction)item);
}

if (Global.GLoFryMessage != null)//编辑
{
GoodName = Global.GLoFryMessage.GoodName;
FryPotProcesses = new ObservableCollection<FryPotProcess>(Global.GLoFryMessage.fryPotProcesses);
}
}
}
}

+ 1
- 1
BPASmartClient.MorkBF/ViewModel/MonitorViewModel.cs ファイルの表示

@@ -10,7 +10,7 @@ using System.Collections.ObjectModel;

namespace BPASmartClient.MorkBF.ViewModel
{
public class MonitorViewModel : ObservableObject
public class MonitorViewModel
{
public MonitorViewModel()
{


+ 446
- 200
BPASmartClient.MorkF/Control_MorkF.cs ファイルの表示

@@ -12,11 +12,13 @@ using BPASmartClient.Model.小炒机;
using BPASmartClient.MorkF.Model;
using System.Text;
using System.Collections.Concurrent;
using System.Windows.Documents;

namespace BPASmartClient.MorkF
{
public class Control_MorkF : BaseDevice
{
/// <summary>
/// while循环最大sleep次数
/// </summary>
@@ -32,6 +34,17 @@ namespace BPASmartClient.MorkF
/// </summary>
private int count = 2;

//
private const int materialHigh = 40000;

//炒锅1倒菜的xy坐标
private const int materialPutPositionXFry1 = -30000;
private const int materialPutPositionYFry1 = -20000;

//炒锅2倒菜的xy坐标
private const int materialPutPositionXFry2 = -30000;
private const int materialPutPositionYFry2 = -20000;

//当前炒锅,默认为1号炒锅
private int fryIndex = 0;

@@ -69,6 +82,11 @@ namespace BPASmartClient.MorkF
/// </summary>
private OrderLocInfo nowStirFryGood = null;

/// <summary>
/// 待取菜队列
/// </summary>
private ConcurrentQueue<MaterialOperation> materialOperationQuenes = new ConcurrentQueue<MaterialOperation>();

List<int> resultorder = new List<int>();//调试变量

/// <summary>
@@ -91,6 +109,8 @@ namespace BPASmartClient.MorkF
CommandRegist();//调试
ServerInit();
DeviceProcessLogShow("MORKF 设备初始化完成");
///初始化菜品库
FoodLibInit();
}

/// <summary>
@@ -170,6 +190,47 @@ namespace BPASmartClient.MorkF
}
}), "SetArmPosition");
}), "SetArmPosition");
ActionManage.GetInstance.Register(new Action<object>((list) =>
{
if (list is bool startOrStop)
{
ArmRunUp(startOrStop);
}
}), "ArmRunUp");
ActionManage.GetInstance.Register(new Action<object>((list) =>
{
if (list is bool startOrStop)
{
ArmRunDown(startOrStop);
}
}), "ArmRunDown");
ActionManage.GetInstance.Register(new Action<object>((list) =>
{
if (list is bool startOrStop)
{
ArmRunLeft(startOrStop);
}
}), "ArmRunLeft");
ActionManage.GetInstance.Register(new Action<object>((list) =>
{
if (list is bool startOrStop)
{
ArmRunRight(startOrStop);
}
}), "ArmRunRight");
ActionManage.GetInstance.Register(new Action<object>((list) =>
{
ThreadManage.GetInstance().Start(new Action(() =>
{
if (list is List<int> list_int)
{
if (list_int.Count == 2)
{
SetNowPosition(list_int[0], list_int[1]);
}
}
}), "SetNowPosition");
}), "SetNowPosition");
#endregion
//ActionManage.GetInstance.Register(PLCInite, "InitCommand");
#region 配料控制
@@ -622,33 +683,55 @@ namespace BPASmartClient.MorkF
/// </summary>
/// <param name="address"></param>
/// <param name="value"></param>
private void MaterailLibrary_Write(string address, object value,int num)
private void MaterailLibrary_Write(string address, object value,int num = 2)
{
WriteControlExact(address, value, num);
}
/// <summary>
/// 菜品库初始化
/// </summary>
public void FoodLibInit(int num = 2)
public bool FoodLibInit()
{
MaterailLibrary_Write("M0.2", true, num);
MaterailLibrary_Write("M0.2", true);

for (int i = 0; i < sleepCount && !ml_morkf.InitialComplete; i++)
{
Thread.Sleep(sleepTime);
if (i >= sleepCount - 1)
{
MessageLog.GetInstance.Show("菜品库初始化超时");
return false;
}
}

return true;
}
/// <summary>
/// 电磁阀启停
/// </summary>
/// <param name="o">电磁阀启停:true:启动。false:停止。</param>
public void Electromagnetism(object o,int num = 2)
public void Electromagnetism(object o)
{
if (!ml_morkf.InitialComplete)
{
return;
}

if (o == null) return;
if (o is List<bool> bs && bs.Count == 1)
{
MaterailLibrary_Write("M1.3", bs[0],num);
MaterailLibrary_Write("M1.3", bs[0]);
}
}
public bool GetDistance_1(int num = 2)
public bool GetDistance_1()
{
if (!ml_morkf.InitialComplete)
{
return false;
}

MessageLog.GetInstance.Show("爪子去到1号位");
MaterailLibrary_Write("M1.0", true, num);
MaterailLibrary_Write("M1.0", true);
for (int i = 0; i < sleepCount && !ml_morkf.PawArrivePortOne; i++)
{
Thread.Sleep(sleepTime);
@@ -658,13 +741,21 @@ namespace BPASmartClient.MorkF
return false;
}
}

Thread.Sleep(300);

MessageLog.GetInstance.Show("爪子去到1号位完成");
return true;
}
public bool GetDistance_2(int num = 2)
public bool GetDistance_2()
{
if (!ml_morkf.InitialComplete)
{
return false;
}

MessageLog.GetInstance.Show("爪子去到2号位");
MaterailLibrary_Write("M1.1", true, num);
MaterailLibrary_Write("M1.1", true);
for (int i = 0; i < sleepCount && !ml_morkf.PawArrivePortTwo; i++)
{
Thread.Sleep(sleepTime);
@@ -674,13 +765,21 @@ namespace BPASmartClient.MorkF
return false;
}
}

Thread.Sleep(300);

MessageLog.GetInstance.Show("爪子去到2号位完成");
return true;
}
public bool GetDistance_3(int num = 2)
public bool GetDistance_3()
{
if (!ml_morkf.InitialComplete)
{
return false;
}

MessageLog.GetInstance.Show("爪子去到3号位");
MaterailLibrary_Write("M1.2", true,num);
MaterailLibrary_Write("M1.2", true);
for (int i = 0; i < sleepCount && !ml_morkf.PawArrivePortThree; i++)
{
Thread.Sleep(sleepTime);
@@ -690,16 +789,19 @@ namespace BPASmartClient.MorkF
return false;
}
}

Thread.Sleep(300);

MessageLog.GetInstance.Show("爪子去到3号位完成");
return true;
}
public void PawTurnFront(int num = 2)
public void PawTurnFront()
{
MaterailLibrary_Write("", true, num);
MaterailLibrary_Write("", true);
}
public void PawTurnBack(int num = 2)
public void PawTurnBack()
{
MaterailLibrary_Write("", true, num);
MaterailLibrary_Write("", true);
}

/// <summary>
@@ -707,20 +809,25 @@ namespace BPASmartClient.MorkF
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
public bool SetArmPosition(int x, int y, int num = 2)
public bool SetArmPosition(int x, int y)
{
if(!ml_morkf.InitialComplete)
{
return false;
}

//取反
x -= 2 * x;
y -= 2 * y;
MaterailLibrary_Write("VD836", x, num);
MaterailLibrary_Write("VD836", x);
Thread.Sleep(100);
MaterailLibrary_Write("VD840", y, num);
MaterailLibrary_Write("VD840", y);

Thread.Sleep(200);

MessageLog.GetInstance.Show($"机械臂移动到[{x},{y}]");
//定位启动
MaterailLibrary_Write("M0.0", true, num);
MaterailLibrary_Write("M0.0", true);

for (int i = 0; i < sleepCount && !ml_morkf.ArriveComplete; i++)
{
@@ -739,15 +846,73 @@ namespace BPASmartClient.MorkF
return true;
}

/// <summary>
/// 设定机械臂的当前坐标
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
public void SetNowPosition(int x, int y)
{
//取反
x -= 2 * x;
y -= 2 * y;
MessageLog.GetInstance.Show($"设置机械臂当前坐标为[{x},{y}]");
MaterailLibrary_Write("VD828", x);
Thread.Sleep(200);
MaterailLibrary_Write("VD832", y);
Thread.Sleep(200);
}

/// <summary>
/// 机械臂向上移动开关
/// </summary>
/// <param name="startOrStop">true:开启,false:关闭</param>
public void ArmRunUp(bool startOrStop)
{
MaterailLibrary_Write("M5.3", startOrStop);
Thread.Sleep(200);
}

/// <summary>
/// 机械臂向下移动开关
/// </summary>
/// <param name="startOrStop">true:开启,false:关闭</param>
public void ArmRunDown(bool startOrStop)
{
MaterailLibrary_Write("M5.4", startOrStop);
Thread.Sleep(200);
}

/// <summary>
/// 机械臂向左移动开关
/// </summary>
/// <param name="startOrStop">true:开启,false:关闭</param>
public void ArmRunLeft(bool startOrStop)
{
MaterailLibrary_Write("M5.5", startOrStop);
Thread.Sleep(200);
}

/// <summary>
/// 机械臂向右移动开关
/// </summary>
/// <param name="startOrStop">true:开启,false:关闭</param>
public void ArmRunRight(bool startOrStop)
{
MaterailLibrary_Write("M5.6", startOrStop);
Thread.Sleep(200);
}

//菜品库锁
object lock_Materail = new object();

private const int up = 10000;

/// <summary>
/// 获取菜品
/// 取菜操作
/// </summary>
public void GetMaterail(int x,int y)
/// <param name="x">取菜x轴坐标</param>
/// <param name="y">取菜y轴坐标</param>
/// <param name="fryNum"></param>
public void GetMaterail(int x,int y,int fryNum = 0)
{
//设置到抓菜处
if(!SetArmPosition(x, y))
@@ -755,39 +920,72 @@ namespace BPASmartClient.MorkF
return;
}

//Thread.Sleep(2000);
//获取传感器的距离
int laserHigh = ml_morkf.LaserDistance;

//关闭电磁阀
Electromagnetism(new List<bool> { true });
Thread.Sleep(500);
//设置到传感器感应的距离处
if(!SetArmPosition(x+ laserHigh, y ))
{
return;
}

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

//爪子去1号位抓菜
if (!GetDistance_1())
{
return;
}
Thread.Sleep(500);

//移动前开启电磁阀
Electromagnetism(new List<bool> { false });
Thread.Sleep(500);
//设置到该层菜品库最高处
if (!SetArmPosition(x + materialHigh, y))
{
return;
}

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

//设置到出菜处,都在x轴-40000处出菜
if (!SetArmPosition(-40000, y))
//爪子去2号位放
if (!GetDistance_2())
{
return;
}

Thread.Sleep(500);
//根据炒锅不同设置不同的出菜处
if (fryNum == 0)
{
//设置到炒锅1出菜处
if (!SetArmPosition(materialPutPositionXFry1, materialPutPositionYFry1))
{
return;
}
}
else
{
//设置到炒锅2出菜处
if (!SetArmPosition(materialPutPositionXFry1, materialPutPositionYFry1))
{
return;
}
}

//爪子去3号位放菜
if (!GetDistance_3())
{
return;
}
Thread.Sleep(500);
////关闭电磁阀
//Electromagnetism(new List<bool> { false });
//Thread.Sleep(300);
if(morkFs.ContainsKey(fryNum))
{
morkFs[fryNum].GetMaterialComplete = true;
}
}

/// <summary>
@@ -836,23 +1034,9 @@ namespace BPASmartClient.MorkF
{
ml_morkf.MaterailIsWorking = true;
}
//菜品库去指定位置
if (!SetArmPosition(x1, y))
{
MessageLog.GetInstance.Show("菜品库[机械臂操作失败]");
return;
}
//取菜操作
GetMaterail(x2,y);


//机械臂去取菜放位
if (!SetArmPosition(-30000, -20000))
{
MessageLog.GetInstance.Show("菜品库[机械臂操作失败]");
return;
}

//机械臂回原点
if (!SetArmPosition(0, 0))
{
@@ -876,7 +1060,6 @@ namespace BPASmartClient.MorkF
}
#endregion


#region 炒锅PLC基本操作方法
/// <summary>
/// 炒锅写寄存器方法,num为炒锅对应编号,从0开始
@@ -1036,13 +1219,39 @@ namespace BPASmartClient.MorkF
{
return;
}
int i = 0;
//判断是否完成取菜
for (i = 0; i < sleepCount*2 && !morkFs[num].GetMaterialComplete; i++)
{
if(i == 3)
{
//停止搅拌
StopStir(num);
//火力设置为2档
SetFire(new List<int> { 2 }, num);
}
Thread.Sleep(sleepTime);
if (i >= sleepCount * 2 - 1)
{
MessageLog.GetInstance.Show($"炒锅{num}倒菜超时:未能等到取菜完成");
return;
}
}

if (i > 3)
{
//开启搅拌
StartStir(num);
//火力设置回原本火力
SetFire(new List<int> { morkFs[num].Fire }, num);
}

FirePot_Write("LB3", true, num);
MessageLog.GetInstance.Show("倒菜启动");

Thread.Sleep(400);
Thread.Sleep(200);

for (int i = 0; i < sleepCount && !morkFs[num].FryPot1_MaterialIntoPot; i++)
for (i = 0; i < sleepCount && !morkFs[num].FryPot1_MaterialIntoPot; i++)
{
Thread.Sleep(sleepTime);
if (i >= sleepCount - 1)
@@ -1178,7 +1387,6 @@ namespace BPASmartClient.MorkF

#endregion


bool isInitialArrive = false;

bool isInitialPaw = false;
@@ -1439,7 +1647,7 @@ namespace BPASmartClient.MorkF
//遍历炒锅,找到合适、空闲的炒锅
for(int i = 0;i<morkFs.Count;i++)
{
if (/*morkFs[i].AutoMode && morkFs[i].FryPot1_InitialComplete &&*/
if (morkFs[i].AutoMode && morkFs[i].FryPot1_InitialComplete &&
!morkFs[i].FryWorking)//炒锅在自动状态&&初始化完成&&是否在炒菜中
{
lock(lock_MainProcessExcute)
@@ -1447,161 +1655,175 @@ namespace BPASmartClient.MorkF
//待炒小炒队列出队列
if (StirFryGoodsQuenes.TryDequeue(out var res))
{
//设置当前炒制菜品
nowStirFryGood = res;
//炒锅工作状态置为正在工作中
morkFs[i].FryWorking = true;
//空闲炒锅入队列
morkFs[i].StirFryGoodsQuenes.Enqueue(res);
MessageLog.GetInstance.Show($"炒锅{i}开始炒制菜品{res.GoodName}");

//开启线程进行炒制
ThreadManage.GetInstance().Start(new Action(() =>
//设置当前炒制菜品
nowStirFryGood = res;
//炒锅工作状态置为正在工作中
morkFs[i].FryWorking = true;
//空闲炒锅入队列
morkFs[i].StirFryGoodsQuenes.Enqueue(res);
//炒锅取菜状态置为未取到
morkFs[i].GetMaterialComplete = false;
MessageLog.GetInstance.Show($"炒锅{i}开始炒制菜品{res.GoodName}");

//开启线程进行炒制
ThreadManage.GetInstance().Start(new Action(() =>
{
try
{
try
int getMaterailNum = 0;
foreach (var potActions in res.StirPotActions)
{
int getMaterailNum = 0;
foreach (var potActions in res.StirPotActions)
if (ThreadManage.GetInstance().IsCanncel(String.Format(striConst, i.ToString(), nowStirFryGood.GoodName)))
{
if (ThreadManage.GetInstance().IsCanncel(String.Format(striConst, i.ToString(), nowStirFryGood.GoodName)))
{
return;
}

switch (potActions.Actions)
{
case nameof(StirFryPotActionEnum.加热开启):
StartFire(i);
MessageLog.GetInstance.Show(potActions.Actions);
break;
case nameof(StirFryPotActionEnum.设置加热挡位1):
SetFire(new List<int> { 1 }, i);
MessageLog.GetInstance.Show(potActions.Actions);
break;
case nameof(StirFryPotActionEnum.设置加热挡位2):
SetFire(new List<int> { 2 }, i);
MessageLog.GetInstance.Show(potActions.Actions);
break;
case nameof(StirFryPotActionEnum.设置加热挡位3):
SetFire(new List<int> { 3 }, i);
MessageLog.GetInstance.Show(potActions.Actions);
break;
case nameof(StirFryPotActionEnum.设置加热挡位4):
SetFire(new List<int> { 4 }, i);
MessageLog.GetInstance.Show(potActions.Actions);
break;
case nameof(StirFryPotActionEnum.设置加热挡位5):
SetFire(new List<int> { 5 }, i);
MessageLog.GetInstance.Show(potActions.Actions);
break;
case nameof(StirFryPotActionEnum.设置加热挡位6):
SetFire(new List<int> { 6 }, i);
MessageLog.GetInstance.Show(potActions.Actions);
break;
case nameof(StirFryPotActionEnum.设置加热挡位7):
SetFire(new List<int> { 7 }, i);
MessageLog.GetInstance.Show(potActions.Actions);
break;
case nameof(StirFryPotActionEnum.设置加热挡位8):
SetFire(new List<int> { 8 }, i);
MessageLog.GetInstance.Show(potActions.Actions);
break;
case nameof(StirFryPotActionEnum.设置加热挡位9):
SetFire(new List<int> { 9 }, i);
MessageLog.GetInstance.Show(potActions.Actions);
break;
case nameof(StirFryPotActionEnum.设置加热挡位10):
SetFire(new List<int> { 10 }, i);
MessageLog.GetInstance.Show(potActions.Actions);
break;
case nameof(StirFryPotActionEnum.停止加热):
StopFire(i);
MessageLog.GetInstance.Show(potActions.Actions);
break;
case nameof(StirFryPotActionEnum.加调料):
OutSeasonings(potActions.SeasoningLists, i);
MessageLog.GetInstance.Show(potActions.Actions);
break;
case nameof(StirFryPotActionEnum.取原料):
GetMaterailTest(getMaterailNum);
getMaterailNum++;
MessageLog.GetInstance.Show(potActions.Actions);
break;
case nameof(StirFryPotActionEnum.开启搅拌):
StartStir(i);
MessageLog.GetInstance.Show(potActions.Actions);
break;
case nameof(StirFryPotActionEnum.设置搅拌挡位1):
SetStir(new List<int> { 1 }, i);
MessageLog.GetInstance.Show(potActions.Actions);
break;
case nameof(StirFryPotActionEnum.设置搅拌挡位2):
SetStir(new List<int> { 2 }, i);
MessageLog.GetInstance.Show(potActions.Actions);
break;
case nameof(StirFryPotActionEnum.设置搅拌挡位3):
SetStir(new List<int> { 3 }, i);
MessageLog.GetInstance.Show(potActions.Actions);
break;
case nameof(StirFryPotActionEnum.关闭搅拌):
StopStir(i);
MessageLog.GetInstance.Show(potActions.Actions);
break;
case nameof(StirFryPotActionEnum.出餐启动):
MessageLog.GetInstance.Show(potActions.Actions);
break;
case nameof(StirFryPotActionEnum.道菜启动):
OutFood(i);
break;
case nameof(StirFryPotActionEnum.炒制菜品):
Thread.Sleep(potActions.During * 1000);
break;
case nameof(StirFryPotActionEnum.搅拌臂原点位):
StirArmGoOrigin(i);
MessageLog.GetInstance.Show(potActions.Actions);
break;
case nameof(StirFryPotActionEnum.搅拌臂炒制位):
StirArmGoWork(i);
MessageLog.GetInstance.Show(potActions.Actions);
break;
case nameof(StirFryPotActionEnum.洗锅):
MessageLog.GetInstance.Show(potActions.Actions);
break;
default:
break;

}
return;
}

switch (potActions.Actions)
{
case nameof(StirFryPotActionEnum.加热开启):
StartFire(i);
MessageLog.GetInstance.Show(potActions.Actions);
break;
case nameof(StirFryPotActionEnum.设置加热挡位1):
morkFs[i].Fire = 1;
SetFire(new List<int> { 1 }, i);
MessageLog.GetInstance.Show(potActions.Actions);
break;
case nameof(StirFryPotActionEnum.设置加热挡位2):
morkFs[i].Fire = 2;
SetFire(new List<int> { 2 }, i);
MessageLog.GetInstance.Show(potActions.Actions);
break;
case nameof(StirFryPotActionEnum.设置加热挡位3):
morkFs[i].Fire = 3;
SetFire(new List<int> { 3 }, i);
MessageLog.GetInstance.Show(potActions.Actions);
break;
case nameof(StirFryPotActionEnum.设置加热挡位4):
morkFs[i].Fire = 4;
SetFire(new List<int> { 4 }, i);
MessageLog.GetInstance.Show(potActions.Actions);
break;
case nameof(StirFryPotActionEnum.设置加热挡位5):
morkFs[i].Fire = 5;
SetFire(new List<int> { 5 }, i);
MessageLog.GetInstance.Show(potActions.Actions);
break;
case nameof(StirFryPotActionEnum.设置加热挡位6):
morkFs[i].Fire = 6;
SetFire(new List<int> { 6 }, i);
MessageLog.GetInstance.Show(potActions.Actions);
break;
case nameof(StirFryPotActionEnum.设置加热挡位7):
morkFs[i].Fire = 7;
SetFire(new List<int> { 7 }, i);
MessageLog.GetInstance.Show(potActions.Actions);
break;
case nameof(StirFryPotActionEnum.设置加热挡位8):
morkFs[i].Fire = 8;
SetFire(new List<int> { 8 }, i);
MessageLog.GetInstance.Show(potActions.Actions);
break;
case nameof(StirFryPotActionEnum.设置加热挡位9):
morkFs[i].Fire = 9;
SetFire(new List<int> { 9 }, i);
MessageLog.GetInstance.Show(potActions.Actions);
break;
case nameof(StirFryPotActionEnum.设置加热挡位10):
morkFs[i].Fire = 10;
SetFire(new List<int> { 10 }, i);
MessageLog.GetInstance.Show(potActions.Actions);
break;
case nameof(StirFryPotActionEnum.停止加热):
StopFire(i);
MessageLog.GetInstance.Show(potActions.Actions);
break;
case nameof(StirFryPotActionEnum.加调料):
OutSeasonings(potActions.SeasoningLists, i);
MessageLog.GetInstance.Show(potActions.Actions);
break;
case nameof(StirFryPotActionEnum.取原料):
//炒锅取菜状态置为未取到
morkFs[i].GetMaterialComplete = false;
materialOperationQuenes.Enqueue(new MaterialOperation() { fryNum = i, x = 0, y = 0 });
getMaterailNum++;
MessageLog.GetInstance.Show(potActions.Actions);
break;
case nameof(StirFryPotActionEnum.开启搅拌):
StartStir(i);
MessageLog.GetInstance.Show(potActions.Actions);
break;
case nameof(StirFryPotActionEnum.设置搅拌挡位1):
SetStir(new List<int> { 1 }, i);
MessageLog.GetInstance.Show(potActions.Actions);
break;
case nameof(StirFryPotActionEnum.设置搅拌挡位2):
SetStir(new List<int> { 2 }, i);
MessageLog.GetInstance.Show(potActions.Actions);
break;
case nameof(StirFryPotActionEnum.设置搅拌挡位3):
SetStir(new List<int> { 3 }, i);
MessageLog.GetInstance.Show(potActions.Actions);
break;
case nameof(StirFryPotActionEnum.关闭搅拌):
StopStir(i);
MessageLog.GetInstance.Show(potActions.Actions);
break;
case nameof(StirFryPotActionEnum.出餐启动):
MessageLog.GetInstance.Show(potActions.Actions);
break;
case nameof(StirFryPotActionEnum.道菜启动):
OutFood(i);
break;
case nameof(StirFryPotActionEnum.炒制菜品):
Thread.Sleep(potActions.During * 1000);
break;
case nameof(StirFryPotActionEnum.搅拌臂原点位):
StirArmGoOrigin(i);
MessageLog.GetInstance.Show(potActions.Actions);
break;
case nameof(StirFryPotActionEnum.搅拌臂炒制位):
StirArmGoWork(i);
MessageLog.GetInstance.Show(potActions.Actions);
break;
case nameof(StirFryPotActionEnum.洗锅):
MessageLog.GetInstance.Show(potActions.Actions);
break;
default:
break;

Plc1Reset(i);//复位
Thread.Sleep(3000);
//回原点位
StirArmGoOrigin(i);
}
}

//while (!morkFs[i].ArmOnOrigin)
//{
// Thread.Sleep(100);
//}
//出餐
//OutMeal(i);
MessageLog.GetInstance.Show($"菜品{res.GoodName}完成");

Plc1Reset(i);//复位
Thread.Sleep(3000);
//回原点位
StirArmGoOrigin(i);

}
catch (Exception ex)
{
ThreadManage.GetInstance().StopTask($"炒锅{i}{res.GoodName}炒制线程");
MessageLog.GetInstance.Show($"炒锅{i}炒制菜品{res.GoodName}出错,错误信息:" + ex.Message);
}
finally
{
nowStirFryGood = null;
//炒完后出队列
morkFs[i].StirFryGoodsQuenes.TryDequeue(out var orderQueue);
morkFs[i].FryWorking = false;
}
}), String.Format(striConst, i.ToString(), nowStirFryGood.GoodName)/*$"炒锅{i}炒制{res.GoodName}线程"*/);
//while (!morkFs[i].ArmOnOrigin)
//{
// Thread.Sleep(100);
//}
//出餐
//OutMeal(i);
MessageLog.GetInstance.Show($"菜品{res.GoodName}完成");


}
catch (Exception ex)
{
ThreadManage.GetInstance().StopTask($"炒锅{i}{res.GoodName}炒制线程");
MessageLog.GetInstance.Show($"炒锅{i}炒制菜品{res.GoodName}出错,错误信息:" + ex.Message);
}
finally
{
nowStirFryGood = null;
//炒完后出队列
morkFs[i].StirFryGoodsQuenes.TryDequeue(out var orderQueue);
morkFs[i].FryWorking = false;
}
}), String.Format(striConst, i.ToString(), nowStirFryGood.GoodName)/*$"炒锅{i}炒制{res.GoodName}线程"*/);
}
}
break;
@@ -1610,6 +1832,30 @@ namespace BPASmartClient.MorkF
}
}

/// <summary>
/// 菜品库主流程
/// </summary>
private void MainProcessMaterial()
{
if(materialOperationQuenes.Count > 0)
{
//判断是否初始化与是否在工作中
if (ml_morkf.InitialComplete && !ml_morkf.MaterailIsWorking)
{
//待菜品库操作列出队列
if (materialOperationQuenes.TryDequeue(out var res))
{
ml_morkf.MaterailIsWorking = true;
MessageLog.GetInstance.Show("开始操作菜品库");
//ThreadManage.GetInstance().Start(new Action(()=>{
// GetMaterail(res.x, res.y, res.fryNum);
//}),"菜品库操作");
GetMaterailTest(res.fryNum);
}
}
}
}

/// <summary>
/// 信号处理
/// </summary>


+ 14
- 1
BPASmartClient.MorkF/GVL_MorkF.cs ファイルの表示

@@ -18,7 +18,15 @@ namespace BPASmartClient.MorkF

public bool IsAuto = true;

#region 炒锅1
#region 炒锅
/// <summary>
/// 炒锅上一次搅拌档位
/// </summary>
public int Stir { set; get; }
/// <summary>
/// 炒锅上一次火力
/// </summary>
public int Fire { get; set; }
/// <summary>
/// 炒锅是否在工作状态中
/// </summary>
@@ -73,6 +81,11 @@ namespace BPASmartClient.MorkF
/// </summary>
public bool PotOnOrigin { get; set; }

/// <summary>
/// 获取菜品是否完成
/// </summary>
public bool GetMaterialComplete { get; set; }

#endregion

#region 调料通道


+ 27
- 0
BPASmartClient.MorkF/MaterialOperation.cs ファイルの表示

@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmartClient.MorkF
{
/// <summary>
/// 菜品库操作类
/// </summary>
internal class MaterialOperation
{
/// <summary>
/// x轴坐标
/// </summary>
public int x;
/// <summary>
/// y轴坐标
/// </summary>
public int y;
/// <summary>
/// 炒锅编号
/// </summary>
public int fryNum;
}
}

+ 20
- 2
BPASmartClient.MorkF/View/DebugView.xaml ファイルの表示

@@ -22,7 +22,7 @@
<Grid.RowDefinitions>
<RowDefinition Height="81" ></RowDefinition>
<RowDefinition Height="81" ></RowDefinition>
<RowDefinition Height="285"></RowDefinition>
<RowDefinition Height="325"></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<GroupBox Header="设备控制" FontSize="15" Foreground="Aqua" VerticalAlignment="Center" >
@@ -65,6 +65,8 @@
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<WrapPanel Orientation="Horizontal" >
<TextBlock Text="取料手臂实时位置" Margin="0,0,10,0"/>
@@ -94,13 +96,29 @@
<Button Content="感应器3测距" Margin="5,0" Command="{Binding GetDistance_3}"/>
<TextBox Text="{Binding SensingDistance_3}" Margin="5,0" Width="60" IsReadOnly="True"/>
</WrapPanel>
<WrapPanel Grid.Row="2" Orientation="Horizontal" >
<WrapPanel Grid.Row="2" Orientation="Horizontal" >
<TextBlock Text="设定手臂当前位置" Margin="0,0,10,0"/>
<TextBlock Text="X:" Margin="5,0"/>
<TextBox Text="{Binding SettingNowX}" Width="70" Margin="5,0" VerticalAlignment="Center" />
<TextBlock Text="Y:" Margin="5,0"/>
<TextBox Text="{Binding SettingNowY}" Width="70" Margin="5,0" VerticalAlignment="Center" />
<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"/>
<RadioButton Content="位置1" Margin="5,0" IsEnabled="True" IsChecked="{Binding PawPositon1}" Command="{Binding GetDistance_1}" GroupName="PawTurn"/>
<RadioButton Content="位置2" Margin="5,0" IsEnabled="True" IsChecked="{Binding PawPositon2}" Command="{Binding GetDistance_2}" GroupName="PawTurn"/>
<RadioButton Content="位置3" Margin="5,0 " IsEnabled="True" IsChecked="{Binding PawPositon3}" Command="{Binding GetDistance_3}" GroupName="PawTurn"/>
</WrapPanel>
<WrapPanel Grid.Row="4" Orientation="Horizontal" >
<RadioButton Content="上" Margin="5,0" IsEnabled="{Binding ArmRunEnable}" IsChecked="{Binding ArmRunUp}" Command="{Binding GetDistance_1}" GroupName="ArmRun"/>
<RadioButton Content="下" Margin="5,0" IsEnabled="{Binding ArmRunEnable}" IsChecked="{Binding ArmRunDown}" Command="{Binding GetDistance_2}" GroupName="ArmRun"/>
<RadioButton Content="左" Margin="5,0 " IsEnabled="{Binding ArmRunEnable}" IsChecked="{Binding ArmRunLeft}" Command="{Binding GetDistance_3}" GroupName="ArmRun"/>
<RadioButton Content="右" Margin="5,0 " IsEnabled="{Binding ArmRunEnable}" IsChecked="{Binding ArmRunRight}" Command="{Binding GetDistance_3}" GroupName="ArmRun"/>
<Button Content="{Binding ArmButtonName}" Command="{Binding ArmRun}" Margin="5,0" Cursor="Hand">
</Button>
</WrapPanel>
</Grid>

</GroupBox>


+ 54
- 1
BPASmartClient.MorkF/ViewModel/DebugViewModel.cs ファイルの表示

@@ -50,6 +50,11 @@ namespace BPASmartClient.MorkF.ViewModel
public int SettingY { get { return _settingY; } set { _settingY = value; OnPropertyChanged(); } }
private int _settingY = 0;

public int SettingNowX { get { return _settingNowX; } set { _settingNowX = value; OnPropertyChanged(); } }
private int _settingNowX = 0;
public int SettingNowY { get { return _settingNowY; } set { _settingNowY = value; OnPropertyChanged(); } }
private int _settingNowY = 0;

public int MoveSpeed { get { return _moveSpeed; } set { _moveSpeed = value; OnPropertyChanged(); } }
private int _moveSpeed;
public string SensingDistance_1 { get { return _sensingDistance_1; } set { _sensingDistance_1 = value; OnPropertyChanged(); } }
@@ -65,7 +70,21 @@ namespace BPASmartClient.MorkF.ViewModel
public bool PawPositon3 { get { return _pawPositon3; } set { _pawPositon3 = value; OnPropertyChanged(); } }
private bool _pawPositon3;

public bool ArmRunUp { get { return _armRunUp; } set { _armRunUp = value; OnPropertyChanged(); } }
private bool _armRunUp;
public bool ArmRunDown { get { return _armRunDown; } set { _armRunDown = value; OnPropertyChanged(); } }
private bool _armRunDown;
public bool ArmRunLeft { get { return _armRunLeft; } set { _armRunLeft = value; OnPropertyChanged(); } }
private bool _armRunLeft;
public bool ArmRunRight { get { return _armRunRight; } set { _armRunRight = value; OnPropertyChanged(); } }
private bool _armRunRight;
public bool ArmRunEnable { get { return _ArmRunEnable; } set { _ArmRunEnable = value; OnPropertyChanged(); } }
private bool _ArmRunEnable = true;

public string ArmButtonName { get { return _ArmButtonName; } set { _ArmButtonName = value; OnPropertyChanged(); } }
private string _ArmButtonName = "启动";

public RelayCommand SetNowPosition { get; set; }//设置机械臂当前坐标
public RelayCommand FoodLibInit { get; set; }//初始化
public RelayCommand StartElectromagnetism { get; set; }//电磁阀启动
public RelayCommand StopElectromagnetism { get; set; }
@@ -76,9 +95,10 @@ namespace BPASmartClient.MorkF.ViewModel
public RelayCommand PawTurnFront { get; set; }//夹爪正转
public RelayCommand PawTurnBack { get; set; }//夹爪反转
public RelayCommand SetArmPosition { get; set; }//机器臂位置设定
public RelayCommand ArmRun { get; set; }//机械臂运动

#endregion

#region 配料仓控制
public List<string> PassageWays { get; set; } = new List<string>()
@@ -195,6 +215,39 @@ namespace BPASmartClient.MorkF.ViewModel
PawTurnFront = new RelayCommand(() => { ActionManage.GetInstance.Send("PawTurnFront"); });//夹爪正转
PawTurnBack = new RelayCommand(() => { ActionManage.GetInstance.Send("PawTurnBack"); });//夹爪反转
SetArmPosition = new RelayCommand(() => { ActionManage.GetInstance.Send("SetArmPosition", new List<int> { SettingX, SettingY }); });//设定机械臂位置
SetNowPosition = new RelayCommand(() => { ActionManage.GetInstance.Send("SetNowPosition", new List<int> { SettingX, SettingY }); });//设定机械臂当前位置
ArmRun = new RelayCommand(() => {
//判断是否都未点击
if(!ArmRunDown&&!ArmRunUp&&!ArmRunLeft&&!ArmRunRight)
{
return;
}
ArmRunEnable = !ArmRunEnable;
if(ArmRunEnable)
{
ArmButtonName = "启动";
}
else
{
ArmButtonName = "停止";
}
if(ArmRunUp)
{
ActionManage.GetInstance.Send("ArmRunUp", !ArmRunEnable);
}
else if(ArmRunDown)
{
ActionManage.GetInstance.Send("ArmRunDown", !ArmRunEnable);
}
else if (ArmRunLeft)
{
ActionManage.GetInstance.Send("ArmRunLeft", !ArmRunEnable);
}
else if(ArmRunRight)
{
ActionManage.GetInstance.Send("ArmRunRight", !ArmRunEnable);
}
});//设定机械臂位置
#endregion

#region 配料仓控制


+ 1
- 1
BPASmartClient.MorkS/BPASmartClient.MorkS.csproj ファイルの表示

@@ -9,7 +9,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BPA.Message" Version="1.0.72" />
<PackageReference Include="BPA.Message" Version="1.0.77" />
<PackageReference Include="BPA.Models" Version="1.0.34" />
<PackageReference Include="Microsoft.Toolkit.Mvvm" Version="7.1.2" />
<PackageReference Include="System.Speech" Version="6.0.0" />


+ 53
- 0
BPASmartClient.MorkS/Control_Morks.cs ファイルの表示

@@ -136,7 +136,43 @@ namespace BPASmartClient.MorkS
goodName = res.MorkOrder.GoodsName;
SortNum = res.MorkOrder.SortNum.ToString();
}

EventBus.EventBus.GetInstance().Publish(new OrderStatusChangedEvent() { SortNum = SortNum, GoodName = goodName, Status = oRDER_STATUS, SubOrderId = subid, deviceClientType = DeviceType });

var index = DataServer.GetInstance.morkS.MakeOrder.FindIndex(p => p.SortNum == SortNum);
if (index >= 0 && index < DataServer.GetInstance.morkS.MakeOrder.Count)
{
if (oRDER_STATUS == ORDER_STATUS.COMPLETED_COOK)
{
DataServer.GetInstance.morkS.MakeOrder.RemoveAt(index);
DataServer.GetInstance.morkS.MakeOrderOver.Add(new OrderMakeModel()
{
Status = oRDER_STATUS,
GoodName = goodName,
SortNum = SortNum,
StopTime = DateTime.Now.ToString("HH:mm:ss")
});
}
else if (oRDER_STATUS == ORDER_STATUS.COMPLETED_TAKE)
{
var temp = DataServer.GetInstance.morkS.MakeOrderOver.FirstOrDefault(p => p.SortNum == SortNum);
if (temp != null) DataServer.GetInstance.morkS.MakeOrderOver.Remove(temp);
}
else
{
DataServer.GetInstance.morkS.MakeOrder.ElementAt(index).Status = oRDER_STATUS;
}
}
else
{
DataServer.GetInstance.morkS.MakeOrder.Add(new OrderMakeModel()
{
Status = oRDER_STATUS,
GoodName = goodName,
SortNum = SortNum,
StartTime = DateTime.Now.ToString("HH:mm:ss")
});
}
}

private void GetStatus(string key, Action<object> action)
@@ -152,6 +188,16 @@ namespace BPASmartClient.MorkS

public override void ReadData()
{
DataServer.GetInstance.morkS.Alarm.Clear();
alarms.ForEach(item =>
{
DataServer.GetInstance.morkS.Alarm.Add(new AlarmModel()
{
AlarmTime = $"{item.Date} {item.Time}",
AlarmMs = item.Info
});
});

GetStatus("M230.0", new Action<object>((obj) =>
{
if (obj is bool[] bools && bools.Length > 0 && bools.Length <= 24)
@@ -213,6 +259,11 @@ namespace BPASmartClient.MorkS
mORKS.TurntableUpLimit = bools[13];
mORKS.FeedComplete = bools[14];
mORKS.TurntableMoveInPlace = bools[15];
DataServer.GetInstance.morkS.MorkS_Temp = mORKS.TemperatureReached;
DataServer.GetInstance.morkS.Morks_SiloMeasUp = mORKS.TurntableUpLimit;
DataServer.GetInstance.morkS.Morks_SiloMeasDown = mORKS.TurntableLowerLimit;
DataServer.GetInstance.morkS.MorkS_NoBowMeas1 = mORKS.MissingBowl;
DataServer.GetInstance.morkS.MorkS_NoBowMeas2 = mORKS.MissingBowlSignal2;
}

}));
@@ -245,6 +296,7 @@ namespace BPASmartClient.MorkS
for (int i = 0; i < 6; i++)
{
mORKS.CookNoodlesComplete[i] = bools[i];
DataServer.GetInstance.morkS.Morks_NoodleUpOrDown[i] = bools[i];
}
}

@@ -254,6 +306,7 @@ namespace BPASmartClient.MorkS
{
if (obj is ushort[] UshortValue && UshortValue.Length > 0 && UshortValue.Length <= 1)
mORKS.TurntableFeedbackloc = UshortValue[0];
DataServer.GetInstance.morkS.MorkS_BinLocation = mORKS.TurntableFeedbackloc;
}));
}



+ 5
- 3
BPASmartClient.MorkS/DataServer.cs ファイルの表示

@@ -20,23 +20,25 @@ namespace BPASmartClient.MorkS

public ScreenModelMorkS morkS { get; set; } = new ScreenModelMorkS();

MQTTProxy mQTTProxy = new MQTTProxy();
public void Init()
{
MQTTProxy mQTTProxy = new MQTTProxy();
mQTTProxy.Connected = new Action(() =>
{
mQTTProxy.Subscrib(ScreenTOPIC.GetInstance.GetTopic(ScreenDeviceType.煮面机));
ThreadManage.GetInstance().StartLong(new Action(() =>
{
morkS.MorkS_OrderCount = Json<OrderStatistics>.Data.Count;
mQTTProxy.Publish(ScreenTOPIC.GetInstance.GetTopic(ScreenDeviceType.煮面机), morkS.ToJSON());
SendScreenDataModel sendScreenDataModel = new SendScreenDataModel();
sendScreenDataModel.Name = ScreenDeviceType.煮面机;
sendScreenDataModel.Value = morkS.ToJSON();
mQTTProxy.Publish(ScreenTOPIC.GetInstance.GetTopic(ScreenDeviceType.煮面机), sendScreenDataModel.ToJSON());
Thread.Sleep(100);
}), "海科食堂大屏监听");
});
mQTTProxy.Connect("UserName", "Password", "Host", 1883, $"MORKS 设备监听数据{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
}


//订单信息(正在制作,等待制作,制作完成)
//煮面炉上下状态(6个煮面炉上或下)
//温度状态(煮面炉温度是否到达)


+ 3
- 5
BPASmartClient.S7Net/EntityClassResolution.cs ファイルの表示

@@ -55,9 +55,9 @@ namespace BPASmartClient.S7Net
numBytes += len;
break;
default:
numBytes = GetClassSize(Activator.CreateInstance(type), numBytes, isInnerProperty: true);
if (type.IsClass) IncrementToEven(ref numBytes);
else if (!type.IsPrimitive && !type.IsEnum && type.IsValueType) IncrementToEven(ref numBytes);
numBytes = GetClassSize(Activator.CreateInstance(type), numBytes, isInnerProperty: true);
break;
}

@@ -221,15 +221,13 @@ namespace BPASmartClient.S7Net
break;
default:
{
object obj2 = Activator.CreateInstance(propertyType);
numBytes = FromBytes(obj2, bytes, numBytes);

numBytes = Math.Ceiling(numBytes);
if (numBytes / 2.0 - Math.Floor(numBytes / 2.0) > 0.0)
{
numBytes += 1.0;
}

object obj2 = Activator.CreateInstance(propertyType);
numBytes = FromBytes(obj2, bytes, numBytes);
obj = obj2;
break;
}


+ 2
- 3
BPASmartClient.S7Net/SiemensHelper.cs ファイルの表示

@@ -2,7 +2,6 @@
using System.Net;
using System.Text;
using BPASmartClient.S7Net;
using System.Text;

namespace BPASmartClient.S7Net
{
@@ -107,11 +106,11 @@ namespace BPASmartClient.S7Net
}
}

public void WriteString(int db,string txt, int startAddress = 0)
public void WriteString(int db, string txt, int startAddress = 0)
{
var temp = Encoding.ASCII.GetBytes(txt);
var bytes = S7.Net.Types.S7String.ToByteArray(txt, temp.Length);
myPlc.WriteBytes(DataType.DataBlock,db, startAddress, bytes);
myPlc.WriteBytes(DataType.DataBlock, db, startAddress, bytes);

}
public TResult ReadClass<TResult>(int db, int startByteAdr = 0) where TResult : class, new()


+ 1
- 2
BPASmartClient.ViewModel/FoodMenuViewModel.cs ファイルの表示

@@ -19,8 +19,7 @@ namespace BPASmartClient.ViewModel

public FoodMenuViewModel()
{
FoodMenus.Add(new FoodMenuModel { GoodKey = "1111", GoodName = "小炒肉" });
FoodMenus.Add(new FoodMenuModel { GoodKey = "222", GoodName = "大炒肉大炒肉大炒肉" });
StartOrder = new RelayCommand<object>((o) =>
{
ActionManage.GetInstance.Send("开始下单", o);


+ 1
- 11
DosingSystem/Model/DeviceInquire.cs ファイルの表示

@@ -197,12 +197,6 @@ namespace BPASmartClient.DosingSystem
DeviceLists[ip].modbusTcp.IsReconnect = false;
App.Current.Dispatcher.Invoke(new Action(() =>
{
//DeviceListViewModel.devices.Add(new Devices()
//{
// DeviceName = DeviceName,
// IpAddress = ip
//});//加入连接的(有名称的)设备列表

devices.Add(new Devices() { DeviceName = DeviceName, IpAddress = ip });

if (TopDeviceCurrentStatuses.Count <= 7)
@@ -244,20 +238,16 @@ namespace BPASmartClient.DosingSystem
DS.modbusTcp.ConnectFail = new Action(() =>
{
if (!InvalidIP.Contains(ip)) InvalidIP.Add(ip);
//MessageLog.GetInstance.ShowAlarmLog($"设备{ip}连接失败");
});

DS.modbusTcp.Disconnect = new Action(() =>
{
if (InvalidIP.Contains(ip)) InvalidIP.Remove(ip);
//var res = DeviceListViewModel.devices.FirstOrDefault(P => P.IpAddress == ip);
var res = devices.FirstOrDefault(P => P.IpAddress == ip);
//if (res != null && DeviceListViewModel.devices.Contains(res))
if (res != null && devices.Contains(res))
{
App.Current.Dispatcher.Invoke(new Action(() =>
{
//DeviceListViewModel.devices.Remove(res);
devices.Remove(res);
var item = Global.DeviceRawMaterials.FirstOrDefault(P => P.RawMaterialName == res.DeviceName);
if (item != null) Global.DeviceRawMaterials.Remove(item);
@@ -307,7 +297,6 @@ namespace BPASmartClient.DosingSystem
modbusTcp.ShowEx = new Action<string>((s) => { MessageNotify.GetInstance.ShowRunLog(s); });
this.DeviceName = DeviceName;
AlarmHelper<AlarmInfo>.Init();

if (modbusTcp.Connected)
{
ThreadManage.GetInstance().StartLong(new Action(() =>
@@ -353,6 +342,7 @@ namespace BPASmartClient.DosingSystem
{
modbusTcp.SetReal(DeviceAddress.WeightSet, Value);//写入配方量
modbusTcp.Write(DeviceAddress.Start, (ushort)1);//设备启动写入
MessageNotify.GetInstance.ShowRunLog($"{DeviceName},设置重量:{Value}");
//配料设备参数写入
var res = Json<DevicePar>.Data.deviceParModels.FirstOrDefault(p => p.MaterialName == DeviceName);
if (res != null)


+ 9
- 3
DosingSystem/View/CommParSetView.xaml ファイルの表示

@@ -125,7 +125,10 @@
Text="{Binding CommBaseParModel.BlockCylinderCount, UpdateSourceTrigger=PropertyChanged}" />
</Grid>

<Grid Background="Transparent" Width="350" Margin="5">
<Grid
Width="350"
Margin="5"
Background="Transparent">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
@@ -146,7 +149,10 @@
Text="{Binding CommBaseParModel.PalletCylinderCount, UpdateSourceTrigger=PropertyChanged}" />
</Grid>

<Grid Background="Transparent" Width="350" Margin="5">
<Grid
Width="350"
Margin="5"
Background="Transparent">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
@@ -171,7 +177,7 @@

<!--<Grid Grid.Row="2" Grid.ColumnSpan="4">
<ListView
Grid.Column="1"
Background="Transparent"
BorderBrush="#00BEFA"


+ 466
- 409
DosingSystem/View/ManualControlView.xaml ファイルの表示

@@ -52,417 +52,474 @@
<UserControl.DataContext>
<vm:ManualControlViewModel />
</UserControl.DataContext>
<ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Hidden">
<StackPanel Margin="8">

<!--#region 升降气缸-->
<Grid
Name="cy"
Grid.Row="0"
Margin="5"
Visibility="{Binding cylinderModels, Converter={StaticResource CountIsVisiableConvert}}">
<pry:ImageBorder
Grid.RowSpan="2"
Width="{Binding ElementName=cy, Path=ActualWidth}"
Height="{Binding ElementName=cy, Path=ActualHeight}" />

<StackPanel Background="Transparent">
<Grid Height="40">
<Image
Margin="2,3,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Source="/BPASmartClient.CustomResource;component/Image/标签.png" />
<TextBlock
Margin="10,10,0,0"
VerticalAlignment="Top"
FontSize="16"
Foreground="Aqua"
Text="升降气缸控制" />
</Grid>
<ListView
Name="list1"
Grid.Row="1"
Margin="0,0,0,20"
Background="Transparent"
BorderBrush="#00BEFA"
BorderThickness="0"
ItemsSource="{Binding cylinderModels}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled">
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal" ScrollViewer.HorizontalScrollBarVisibility="Disabled" />
</ItemsPanelTemplate>
</ListView.ItemsPanel>

<ListView.ItemTemplate>
<DataTemplate>
<Grid
Width="200"
Height="100"
Margin="0,0,0,15"
Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="30" />
<RowDefinition />
<RowDefinition Height="30" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.5*" />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>

<TextBlock
Grid.Column="1"
Grid.ColumnSpan="2"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Foreground="Aqua"
Text="{Binding Name}" />

<pry:Cylinder
Grid.Row="1"
Grid.ColumnSpan="3"

<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="40" />
<RowDefinition />
</Grid.RowDefinitions>

<StackPanel
Margin="0,0,10,0"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Orientation="Horizontal">

<ToggleButton
Width="100"
Height="30"
Margin="5,0,5,0"
Background="Transparent"
Command="{Binding SystemStart}"
Content="{Binding SystemControlText}"
FontSize="20"
Style="{StaticResource SwitchToggleButtonStyle1}" />

<ToggleButton
Width="100"
Height="30"
Margin="5,0,5,0"
Background="Transparent"
Command="{Binding ModelSwitch}"
Content="{Binding ModelSwitchText}"
FontSize="20"
Style="{StaticResource SwitchToggleButtonStyle1}" />

<!--<Button
Width="150"
Height="40"
Margin="10,0,10,0"
Command="{Binding SystemStart}"
Content="{Binding SystemControlText}"
FontSize="20"
Style="{StaticResource ImageButtonStyle}" />

<Button
Width="150"
Height="40"
Margin="10,0,10,0"
Command="{Binding ModelSwitch}"
Content="{Binding ModelSwitchText}"
FontSize="20"
Style="{StaticResource ImageButtonStyle}" />-->

</StackPanel>

<ScrollViewer
Grid.Row="1"
HorizontalScrollBarVisibility="Disabled"
VerticalScrollBarVisibility="Hidden">
<StackPanel Margin="8">

<!--#region 升降气缸-->
<Grid
Name="cy"
Grid.Row="0"
Margin="5"
Visibility="{Binding cylinderModels, Converter={StaticResource CountIsVisiableConvert}}">
<pry:ImageBorder
Grid.RowSpan="2"
Width="{Binding ElementName=cy, Path=ActualWidth}"
Height="{Binding ElementName=cy, Path=ActualHeight}" />

<StackPanel Background="Transparent">
<Grid Height="40">
<Image
Margin="2,3,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Source="/BPASmartClient.CustomResource;component/Image/标签.png" />
<TextBlock
Margin="10,10,0,0"
VerticalAlignment="Top"
FontSize="16"
Foreground="Aqua"
Text="升降气缸控制" />
</Grid>
<ListView
Name="list1"
Grid.Row="1"
Margin="0,0,0,20"
Background="Transparent"
BorderBrush="#00BEFA"
BorderThickness="0"
ItemsSource="{Binding cylinderModels}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled">
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal" ScrollViewer.HorizontalScrollBarVisibility="Disabled" />
</ItemsPanelTemplate>
</ListView.ItemsPanel>

<ListView.ItemTemplate>
<DataTemplate>
<Grid
Width="200"
Height="50"
HorizontalAlignment="Center"
VerticalAlignment="Center"
LeftTogIsChecked="{Binding LeftTog}"
RightTogIsChecked="{Binding RightTog}" />

<RadioButton
Grid.Row="2"
Grid.Column="1"
Command="{Binding DataContext.Open, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}"
CommandParameter="{Binding Name}"
Content="伸出"
Foreground="Aqua"
IsChecked="True"
Style="{StaticResource radioButtonStyle}" />

<RadioButton
Grid.Row="2"
Grid.Column="2"
Command="{Binding DataContext.Close, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}"
CommandParameter="{Binding Name}"
Content="缩回"
Foreground="Aqua"
IsChecked="False"
Style="{StaticResource radioButtonStyle}" />
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackPanel>
</Grid>
<!--#endregion-->
<!--#region 阻挡气缸-->
<Grid
Name="zd"
Grid.Row="1"
Margin="5"
Visibility="{Binding BlockCylinders, Converter={StaticResource CountIsVisiableConvert}}">
<pry:ImageBorder Width="{Binding ElementName=zd, Path=ActualWidth}" Height="{Binding ElementName=zd, Path=ActualHeight}" />
<StackPanel>
<Grid Height="40">
<Image
Margin="2,3,0,0"
HorizontalAlignment="Left"
Source="/BPASmartClient.CustomResource;component/Image/标签.png" />
<TextBlock
Margin="10,0,0,0"
VerticalAlignment="Center"
FontSize="16"
Foreground="Aqua"
Text="阻挡气缸控制" />
</Grid>
<ListView
Name="list2"
Grid.Row="1"
Margin="0,0,0,20"
Background="Transparent"
BorderBrush="#00BEFA"
BorderThickness="0"
ItemsSource="{Binding BlockCylinders}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled">
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListView.ItemsPanel>
<ListView.ItemTemplate>
<DataTemplate>
<Grid
Width="200"
Height="100"
Margin="0,0,0,15"
Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="30" />
<RowDefinition />
<RowDefinition Height="30" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.5*" />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<TextBlock
Grid.Column="1"
Grid.ColumnSpan="2"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Foreground="Aqua"
Text="{Binding Name}" />
<pry:Cylinder
Grid.Row="1"
Grid.ColumnSpan="3"
Height="100"
Margin="0,0,0,15"
Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="30" />
<RowDefinition />
<RowDefinition Height="30" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.5*" />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<TextBlock
Grid.Column="1"
Grid.ColumnSpan="2"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Foreground="Aqua"
Text="{Binding Name}" />
<pry:Cylinder
Grid.Row="1"
Grid.ColumnSpan="3"
Width="200"
Height="50"
HorizontalAlignment="Center"
VerticalAlignment="Center"
LeftTogIsChecked="{Binding LeftTog}"
RightTogIsChecked="{Binding RightTog}" />
<RadioButton
Grid.Row="2"
Grid.Column="1"
Command="{Binding DataContext.Open, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}"
CommandParameter="{Binding Name}"
Content="伸出"
Foreground="Aqua"
IsChecked="True"
Style="{StaticResource radioButtonStyle}" />
<RadioButton
Grid.Row="2"
Grid.Column="2"
Command="{Binding DataContext.Close, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}"
CommandParameter="{Binding Name}"
Content="缩回"
Foreground="Aqua"
IsChecked="False"
Style="{StaticResource radioButtonStyle}" />
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackPanel>
</Grid>
<!--#endregion-->
<!--#region 阻挡气缸-->
<Grid
Name="zd"
Grid.Row="1"
Margin="5"
Visibility="{Binding BlockCylinders, Converter={StaticResource CountIsVisiableConvert}}">
<pry:ImageBorder Width="{Binding ElementName=zd, Path=ActualWidth}" Height="{Binding ElementName=zd, Path=ActualHeight}" />
<StackPanel>
<Grid Height="40">
<Image
Margin="2,3,0,0"
HorizontalAlignment="Left"
Source="/BPASmartClient.CustomResource;component/Image/标签.png" />
<TextBlock
Margin="10,0,0,0"
VerticalAlignment="Center"
FontSize="16"
Foreground="Aqua"
Text="阻挡气缸控制" />
</Grid>
<ListView
Name="list2"
Grid.Row="1"
Margin="0,0,0,20"
Background="Transparent"
BorderBrush="#00BEFA"
BorderThickness="0"
ItemsSource="{Binding BlockCylinders}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled">
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListView.ItemsPanel>
<ListView.ItemTemplate>
<DataTemplate>
<Grid
Width="200"
Height="50"
HorizontalAlignment="Center"
VerticalAlignment="Center"
LeftTogIsChecked="{Binding LeftTog}"
RightTogIsChecked="{Binding RightTog}" />
<RadioButton
Grid.Row="2"
Grid.Column="1"
Command="{Binding DataContext.Open, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}"
CommandParameter="{Binding Name}"
Content="伸出"
Foreground="Aqua"
IsChecked="True"
Style="{StaticResource radioButtonStyle}" />
<RadioButton
Grid.Row="2"
Grid.Column="2"
Command="{Binding DataContext.Close, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}"
CommandParameter="{Binding Name}"
Content="缩回"
Foreground="Aqua"
IsChecked="False"
Style="{StaticResource radioButtonStyle}" />
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackPanel>
</Grid>
<!--#endregion-->
<!--#region 托盘气缸-->
<Grid
Name="tp"
Grid.Row="2"
Margin="5"
Visibility="{Binding PalletCylinders, Converter={StaticResource CountIsVisiableConvert}}">
<pry:ImageBorder
Grid.RowSpan="2"
Width="{Binding ElementName=tp, Path=ActualWidth}"
Height="{Binding ElementName=tp, Path=ActualHeight}" />
<StackPanel>
<Grid Height="40">
<Image
Margin="2,3,0,0"
HorizontalAlignment="Left"
Source="/BPASmartClient.CustomResource;component/Image/标签.png" />
<TextBlock
Margin="10,0,0,0"
VerticalAlignment="Center"
FontSize="16"
Foreground="Aqua"
Text="托盘气缸控制" />
</Grid>
<ListView
Name="list3"
Grid.Row="2"
Margin="0,0,0,20"
Background="Transparent"
BorderBrush="#00BEFA"
BorderThickness="0"
ItemsSource="{Binding PalletCylinders}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled">
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListView.ItemsPanel>
<ListView.ItemTemplate>
<DataTemplate>
<Grid
Width="200"
Height="100"
Margin="0,0,0,15"
Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="30" />
<RowDefinition />
<RowDefinition Height="30" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.5*" />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<TextBlock
Grid.Column="1"
Grid.ColumnSpan="2"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Foreground="Aqua"
Text="{Binding Name}" />
<pry:Cylinder
Grid.Row="1"
Grid.ColumnSpan="3"
Height="100"
Margin="0,0,0,15"
Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="30" />
<RowDefinition />
<RowDefinition Height="30" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.5*" />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<TextBlock
Grid.Column="1"
Grid.ColumnSpan="2"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Foreground="Aqua"
Text="{Binding Name}" />
<pry:Cylinder
Grid.Row="1"
Grid.ColumnSpan="3"
Width="200"
Height="50"
HorizontalAlignment="Center"
VerticalAlignment="Center"
LeftTogIsChecked="{Binding LeftTog}"
RightTogIsChecked="{Binding RightTog}" />
<RadioButton
Grid.Row="2"
Grid.Column="1"
Command="{Binding DataContext.Open, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}"
CommandParameter="{Binding Name}"
Content="伸出"
Foreground="Aqua"
IsChecked="True"
Style="{StaticResource radioButtonStyle}" />
<RadioButton
Grid.Row="2"
Grid.Column="2"
Command="{Binding DataContext.Close, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}"
CommandParameter="{Binding Name}"
Content="缩回"
Foreground="Aqua"
IsChecked="False"
Style="{StaticResource radioButtonStyle}" />
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackPanel>
</Grid>
<!--#endregion-->
<!--#region 托盘气缸-->
<Grid
Name="tp"
Grid.Row="2"
Margin="5"
Visibility="{Binding PalletCylinders, Converter={StaticResource CountIsVisiableConvert}}">
<pry:ImageBorder
Grid.RowSpan="2"
Width="{Binding ElementName=tp, Path=ActualWidth}"
Height="{Binding ElementName=tp, Path=ActualHeight}" />
<StackPanel>
<Grid Height="40">
<Image
Margin="2,3,0,0"
HorizontalAlignment="Left"
Source="/BPASmartClient.CustomResource;component/Image/标签.png" />
<TextBlock
Margin="10,0,0,0"
VerticalAlignment="Center"
FontSize="16"
Foreground="Aqua"
Text="托盘气缸控制" />
</Grid>
<ListView
Name="list3"
Grid.Row="2"
Margin="0,0,0,20"
Background="Transparent"
BorderBrush="#00BEFA"
BorderThickness="0"
ItemsSource="{Binding PalletCylinders}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled">
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListView.ItemsPanel>
<ListView.ItemTemplate>
<DataTemplate>
<Grid
Width="200"
Height="50"
HorizontalAlignment="Center"
VerticalAlignment="Center"
LeftTogIsChecked="{Binding LeftTog}"
RightTogIsChecked="{Binding RightTog}" />
<RadioButton
Grid.Row="2"
Grid.Column="1"
Command="{Binding DataContext.Open, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}"
CommandParameter="{Binding Name}"
Content="伸出"
Foreground="Aqua"
IsChecked="True"
Style="{StaticResource radioButtonStyle}" />
<RadioButton
Grid.Row="2"
Grid.Column="2"
Command="{Binding DataContext.Close, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}"
CommandParameter="{Binding Name}"
Content="缩回"
Foreground="Aqua"
IsChecked="False"
Style="{StaticResource radioButtonStyle}" />
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackPanel>
</Grid>
<!--#endregion-->
<!--#region 上下桶工位气缸-->
<Grid
Name="onGrid"
Grid.Row="2"
Margin="5"
Visibility="{Binding OtherHandCylinders, Converter={StaticResource CountIsVisiableConvert}}">
<pry:ImageBorder
Grid.RowSpan="2"
Width="{Binding ElementName=onGrid, Path=ActualWidth}"
Height="{Binding ElementName=onGrid, Path=ActualHeight}" />
<StackPanel>
<Grid Height="40">
<Image
Margin="2,3,0,0"
HorizontalAlignment="Left"
Source="/BPASmartClient.CustomResource;component/Image/标签.png" />
<TextBlock
Margin="10,0,0,0"
VerticalAlignment="Center"
FontSize="16"
Foreground="Aqua"
Text="上下桶工位气缸控制" />
</Grid>
<ListView
Name="list4"
Grid.Row="2"
Margin="0,0,0,20"
Background="Transparent"
BorderBrush="#00BEFA"
BorderThickness="0"
ItemsSource="{Binding OtherHandCylinders}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled">
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListView.ItemsPanel>
<ListView.ItemTemplate>
<DataTemplate>
<Grid
Width="200"
Height="100"
Margin="0,0,0,15"
Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="30" />
<RowDefinition />
<RowDefinition Height="30" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.5*" />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<TextBlock
Grid.Column="1"
Grid.ColumnSpan="2"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Foreground="Aqua"
Text="{Binding Name}" />
<pry:Cylinder
Grid.Row="1"
Grid.ColumnSpan="3"
Height="100"
Margin="0,0,0,15"
Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="30" />
<RowDefinition />
<RowDefinition Height="30" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.5*" />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<TextBlock
Grid.Column="1"
Grid.ColumnSpan="2"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Foreground="Aqua"
Text="{Binding Name}" />
<pry:Cylinder
Grid.Row="1"
Grid.ColumnSpan="3"
Width="200"
Height="50"
HorizontalAlignment="Center"
VerticalAlignment="Center"
LeftTogIsChecked="{Binding LeftTog}"
RightTogIsChecked="{Binding RightTog}" />
<RadioButton
Grid.Row="2"
Grid.Column="1"
Command="{Binding DataContext.Open, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}"
CommandParameter="{Binding Name}"
Content="伸出"
Foreground="Aqua"
IsChecked="True"
Style="{StaticResource radioButtonStyle}" />
<RadioButton
Grid.Row="2"
Grid.Column="2"
Command="{Binding DataContext.Close, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}"
CommandParameter="{Binding Name}"
Content="缩回"
Foreground="Aqua"
IsChecked="False"
Style="{StaticResource radioButtonStyle}" />
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackPanel>
</Grid>
<!--#endregion-->
<!--#region 上下桶工位气缸-->
<Grid
Name="onGrid"
Grid.Row="2"
Margin="5"
Visibility="{Binding OtherHandCylinders, Converter={StaticResource CountIsVisiableConvert}}">
<pry:ImageBorder
Grid.RowSpan="2"
Width="{Binding ElementName=onGrid, Path=ActualWidth}"
Height="{Binding ElementName=onGrid, Path=ActualHeight}" />
<StackPanel>
<Grid Height="40">
<Image
Margin="2,3,0,0"
HorizontalAlignment="Left"
Source="/BPASmartClient.CustomResource;component/Image/标签.png" />
<TextBlock
Margin="10,0,0,0"
VerticalAlignment="Center"
FontSize="16"
Foreground="Aqua"
Text="上下桶工位气缸控制" />
</Grid>
<ListView
Name="list4"
Grid.Row="2"
Margin="0,0,0,20"
Background="Transparent"
BorderBrush="#00BEFA"
BorderThickness="0"
ItemsSource="{Binding OtherHandCylinders}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled">
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListView.ItemsPanel>
<ListView.ItemTemplate>
<DataTemplate>
<Grid
Width="200"
Height="50"
HorizontalAlignment="Center"
VerticalAlignment="Center"
LeftTogIsChecked="{Binding LeftTog}"
RightTogIsChecked="{Binding RightTog}" />

<RadioButton
Grid.Row="2"
Grid.Column="1"
Command="{Binding DataContext.Open, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}"
CommandParameter="{Binding Name}"
Content="伸出"
Foreground="Aqua"
IsChecked="True"
Style="{StaticResource radioButtonStyle}" />

<RadioButton
Grid.Row="2"
Grid.Column="2"
Command="{Binding DataContext.Close, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}"
CommandParameter="{Binding Name}"
Content="缩回"
Foreground="Aqua"
IsChecked="False"
Style="{StaticResource radioButtonStyle}" />
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackPanel>


</Grid>
<!--#endregion-->

</StackPanel>
</ScrollViewer>
Height="100"
Margin="0,0,0,15"
Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="30" />
<RowDefinition />
<RowDefinition Height="30" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.5*" />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>

<TextBlock
Grid.Column="1"
Grid.ColumnSpan="2"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Foreground="Aqua"
Text="{Binding Name}" />

<pry:Cylinder
Grid.Row="1"
Grid.ColumnSpan="3"
Width="200"
Height="50"
HorizontalAlignment="Center"
VerticalAlignment="Center"
LeftTogIsChecked="{Binding LeftTog}"
RightTogIsChecked="{Binding RightTog}" />

<RadioButton
Grid.Row="2"
Grid.Column="1"
Command="{Binding DataContext.Open, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}"
CommandParameter="{Binding Name}"
Content="伸出"
Foreground="Aqua"
IsChecked="True"
Style="{StaticResource radioButtonStyle}" />

<RadioButton
Grid.Row="2"
Grid.Column="2"
Command="{Binding DataContext.Close, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}"
CommandParameter="{Binding Name}"
Content="缩回"
Foreground="Aqua"
IsChecked="False"
Style="{StaticResource radioButtonStyle}" />
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackPanel>


</Grid>
<!--#endregion-->

</StackPanel>
</ScrollViewer>
</Grid>
</UserControl>

+ 38
- 12
DosingSystem/View/RecipeControlView.xaml ファイルの表示

@@ -880,7 +880,7 @@
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="16"
Foreground="{Binding RecipStatus,Converter={StaticResource RecipeStatusConvert}}"
Foreground="{Binding RecipStatus, Converter={StaticResource RecipeStatusConvert}}"
Text="{Binding RecipStatus}" />
<Border
Grid.ColumnSpan="10"
@@ -912,26 +912,29 @@
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid>

<Grid.RowDefinitions>
<RowDefinition Height="30" />
<RowDefinition Height="30" />
<RowDefinition Height="auto" />
<RowDefinition Height="40" />
<RowDefinition Height="40" />
<RowDefinition />
<RowDefinition Height="10" />
</Grid.RowDefinitions>

<Image
Grid.RowSpan="3"
Source="/BPASmartClient.CustomResource;component/Image/组合边框2.1.png"
Grid.RowSpan="5"
Source="/BPASmartClient.CustomResource;component/Image/背景边框4.png"
Stretch="Fill" />
<Image
Grid.RowSpan="3"
<!--<Image
Grid.RowSpan="4"
Source="/BPASmartClient.CustomResource;component/Image/组合边框2.png"
Stretch="Fill" />
Stretch="Fill" />-->

<TextBlock
Grid.Row="0"
Margin="10,15,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Margin="0,5,0,0"
HorizontalAlignment="Center"
VerticalAlignment="Top"
FontSize="18"
Foreground="#FF2AB2E7"
Text="{Binding RecipeName}" />
@@ -939,7 +942,9 @@
<!--#region 表格标题栏设置-->
<Grid
Grid.Row="1"
Margin="5,8"
Height="30"
Margin="5,0"
VerticalAlignment="Top"
Background="#ff0C255F">

<Grid.ColumnDefinitions>
@@ -1011,6 +1016,27 @@
</ItemsControl.ItemTemplate>
</ItemsControl>

<Button
Grid.Row="3"
Height="40"
Margin="20,0,20,0"
VerticalContentAlignment="Center"
Command="{Binding DataContext.CancelRecipeCommand, RelativeSource={RelativeSource AncestorType=UserControl, Mode=FindAncestor}}"
CommandParameter="{Binding}"
Content="取消配料"
FontSize="16"
Style="{StaticResource ControlButtonStyle}" />

<!--<Button
Grid.Row="3"
Height="40"
Margin="5,0,5,0"
Command="{Binding CancelRecipeCommand}"
CommandParameter="{Binding}"
Content="取消配料"
FontSize="20"
Style="{StaticResource ImageButtonStyle}" />-->

</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>


+ 39
- 0
DosingSystem/ViewModel/ManualControlViewModel.cs ファイルの表示

@@ -6,6 +6,7 @@ using System.Threading.Tasks;
using BPA.Helper;
using System.Collections.ObjectModel;
using System.Threading;
using BPASmartClient.S7Net;

namespace BPASmartClient.DosingSystem.ViewModel
{
@@ -13,6 +14,7 @@ namespace BPASmartClient.DosingSystem.ViewModel
{
public ManualControlViewModel()
{
Init();
for (int i = 0; i < Json<DevicePar>.Data.BaseParModel.LiftCylinderCount; i++)
{
cylinderModels.Add(new CylinderModel()
@@ -98,6 +100,19 @@ namespace BPASmartClient.DosingSystem.ViewModel
}
});

SystemStart = new BPARelayCommand(() =>
{
SiemensDevice.GetInstance.MySiemens.Write("M10.0", SystemControlText == "停止" ? false : true);
var res = SiemensDevice.GetInstance.MySiemens.Read<bool>("M10.0");
SystemControlText = res ? "停止" : "启动";
});
ModelSwitch = new BPARelayCommand(() =>
{
SiemensDevice.GetInstance.MySiemens.Write("M10.1", ModelSwitchText == "手动" ? true : false);
var res = SiemensDevice.GetInstance.MySiemens.Read<bool>("M10.1");
ModelSwitchText = res ? "自动" : "手动";
});

ThreadManage.GetInstance().StartLong(new Action(() =>
{
for (int i = 0; i < cylinderModels.Count; i++)
@@ -115,10 +130,22 @@ namespace BPASmartClient.DosingSystem.ViewModel
OtherHandCylinders.ElementAt(1).RightTog = GlobalDevice.PlcData.UnderCylinderDetection.HomeSignal;
OtherHandCylinders.ElementAt(1).LeftTog = GlobalDevice.PlcData.UnderCylinderDetection.InPlaceSignal;

//SystemControlText = GlobalDevice.PlcData.SystemStartOrStop ? "停止系统" : "启动系统";
//ModelSwitchText = GlobalDevice.PlcData.HandOrAuto ? "自动" : "手动";

Thread.Sleep(100);
}), "手动气缸状态监控");
}

private void Init()
{
var res = SiemensDevice.GetInstance.MySiemens.Read<bool>("M10.0");
SystemControlText = res ? "停止" : "启动";

var res1 = SiemensDevice.GetInstance.MySiemens.Read<bool>("M10.1");
ModelSwitchText = res1 ? "自动" : "手动";
}

/// <summary>
/// 升降气缸
/// </summary>
@@ -143,6 +170,18 @@ namespace BPASmartClient.DosingSystem.ViewModel

public BPARelayCommand<object> Close { get; set; }

public BPARelayCommand SystemStart { get; set; }
public BPARelayCommand ModelSwitch { get; set; }


public string SystemControlText { get { return _mSystemControlText; } set { _mSystemControlText = value; OnPropertyChanged(); } }
private string _mSystemControlText;


public string ModelSwitchText { get { return _mModelSwitchText; } set { _mModelSwitchText = value; OnPropertyChanged(); } }
private string _mModelSwitchText;


}

public class CylinderModel : NotifyBase


+ 44
- 9
DosingSystem/ViewModel/RecipeControlViewModel.cs ファイルの表示

@@ -14,6 +14,8 @@ using BPASmartClient.CustomResource.UserControls;
using BPASmartClient.Model.柔性味魔方;
using BPASmartClient.Model;
using System.Diagnostics;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using System.Data.SqlClient;

namespace BPASmartClient.DosingSystem.ViewModel
{
@@ -25,10 +27,40 @@ namespace BPASmartClient.DosingSystem.ViewModel
{
StartCommand = new BPARelayCommand<object>(RecipeIssued);
ChangeRecipeStateCommand = new BPARelayCommand<object>(ChangeRecipeState);
CancelRecipeCommand = new BPARelayCommand<object>(CancelRecipe);
RecipeRun();
RecipeStatusInquire();
}

private async void CancelRecipe(object o)
{
if (o != null && o is RecipeModel recipe)
{
var res = MessageNotify.GetInstance.ShowDialog($"是否取消配方 【{recipe.RecipeName}】制作", DialogType.Warning);
if (res)
{
int index = Recipes.ToList().FindIndex(p => p.RecipeName == recipe.RecipeName);
if (index >= 0 && index < Recipes.Count)
{
await Task.Factory.StartNew(new Action(() =>
{

Recipes.ElementAt(index).IsEnable = true;
Json<LocaPar>.Data.Recipes.ElementAt(index).IsEnable = true;
Recipes.ElementAt(index).Are.Set();
App.Current.Dispatcher.Invoke(new Action(() => { recipeProcesses.Clear(); }));
SiemensDevice.GetInstance.MySiemens.Write("M10.5", true);
Thread.Sleep(1000);
SiemensDevice.GetInstance.MySiemens.Write("M10.5", false);
NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"配方 [{recipe.RecipeName}] 取消成功");
}));
}
}

}

}

/// <summary>
/// 配方下发
/// </summary>
@@ -45,11 +77,11 @@ namespace BPASmartClient.DosingSystem.ViewModel
{
string ip = Recipes.ElementAt(index).RawMaterials.ElementAt(i).DeviceIp;
var device = DeviceInquire.GetInstance.GetDevice(ip);
//if (!device.IsConnected)
//{
// MessageNotify.GetInstance.ShowDialog($"设备 【{device.DeviceName}】 未连接,不允许下发此配方", DialogType.Error);
// return;
//}
if (!device.IsConnected)
{
MessageNotify.GetInstance.ShowDialog($"设备 【{device.DeviceName}】 未连接,不允许下发此配方", DialogType.Error);
return;
}
}
}
Recipes.ElementAt(index).IsEnable = false;
@@ -112,7 +144,7 @@ namespace BPASmartClient.DosingSystem.ViewModel
int a = data.SetBitValue((byte)tInfo.ElementAt(i).ElementAt(m).Loc, true);
byte[] test1 = a.ToBytes(BPA.Helper.DataFormat.ABCD);
int item = test1.ToInt();
SiemensDevice.GetInstance.MySiemens.Write($"DB4.DBD{2 + (tempDevice.DeviceNum - 1) * 4}", item);
SiemensDevice.GetInstance.MySiemens.Write($"DB4.DBD{2 + (tempDevice.DeviceNum - 1) * 4}", item, 5);
MessageNotify.GetInstance.ShowRunLog($"下发配方DB4.DBD{2 + (tempDevice.DeviceNum - 1) * 4} :{item.ToBinString()}");
}
}
@@ -129,7 +161,7 @@ namespace BPASmartClient.DosingSystem.ViewModel
}
}
}
SiemensDevice.GetInstance.MySiemens.Write("DB4.DBD198", BarrelNum.Count);//配方使用桶数写入
SiemensDevice.GetInstance.MySiemens.Write("DB4.DBD198", BarrelNum.Count, 5);//配方使用桶数写入
/*if (recipeData.Count <= 0)
{
MessageNotify.GetInstance.ShowRunLog("配方数据解析失败");
@@ -453,8 +485,9 @@ namespace BPASmartClient.DosingSystem.ViewModel
int a = 0.SetBitValue((byte)(DeviceNum), true);
byte[] test1 = a.ToBytes(BPA.Helper.DataFormat.ABCD);
int item = test1.ToInt();
SiemensDevice.GetInstance.MySiemens.Write("DB4.DBD130", item);
MessageNotify.GetInstance.ShowRunLog($"DB4.DBD130:{item.ToBinString()}");
SiemensDevice.GetInstance.MySiemens.Write("DB4.DBD130", item, 5);
//MessageNotify.GetInstance.ShowRunLog($"DB4.DBD130:{item.ToBinString()}");
MessageNotify.GetInstance.ShowRunLog($"DB4.DBD130:{item}");
MessageNotify.GetInstance.ShowRunLog($"柔性味魔方{Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp},出料完成,状态复位");
}
}
@@ -538,6 +571,8 @@ namespace BPASmartClient.DosingSystem.ViewModel

public BPARelayCommand<object> ChangeRecipeStateCommand { get; set; }

public BPARelayCommand<object> CancelRecipeCommand { get; set; }

public static ObservableCollection<RecipeModel> Recipes { get; set; } = Json<LocaPar>.Data.Recipes;

public static string CurrentRecipeName { get { return _RecipeName; } set { _RecipeName = value; OnStaticPropertyChanged(); } }


読み込み中…
キャンセル
保存