Parcourir la source

morkBF

样式分支
NXX il y a 2 ans
Parent
révision
26162921fb
8 fichiers modifiés avec 908 ajouts et 34 suppressions
  1. +2
    -0
      BPASmartClient.Device/BaseDevice.cs
  2. +53
    -6
      BPASmartClient.Modbus/ModbusTcp.cs
  3. +1
    -1
      BPASmartClient.MorkBF/BPASmartClient.MorkBF.csproj
  4. +478
    -1
      BPASmartClient.MorkBF/Control_MorkBF.cs
  5. +60
    -26
      BPASmartClient.MorkBF/VIew/DebugView.xaml
  6. +312
    -0
      BPASmartClient.MorkBF/ViewModel/DebugViewModel.cs
  7. +1
    -0
      BPASmartClient.MorkF/BPASmartClient.MorkF.csproj
  8. +1
    -0
      BPASmartClient.MorkF/Control_MorkF.cs

+ 2
- 0
BPASmartClient.Device/BaseDevice.cs Voir le fichier

@@ -98,6 +98,8 @@ namespace BPASmartClient.Device
/// </summary>
protected ConcurrentDictionary<string, object> peripheralStatus = new ConcurrentDictionary<string, object>();

protected

/// <summary>
/// 外设设备集合
/// </summary>


+ 53
- 6
BPASmartClient.Modbus/ModbusTcp.cs Voir le fichier

@@ -132,7 +132,24 @@ namespace BPASmartClient.Modbus
}
}
}
if (address.ToUpper().Contains("LB") && address.Length >= 3)
else if (address.ToUpper().Contains("GM") && address.Length >= 3)
{
var res = address.Remove(0,2);
if (res != null && res.Length > 0)
{
return int.Parse(res) + 4096;
}
}

else if (address.ToUpper().Contains("GI") && address.Length >= 3)
{
var res = address.Remove(0, 2);
if (res != null && res.Length > 0)
{
return int.Parse(res);
}
}
else if(address.ToUpper().Contains("LB") && address.Length >= 3)
{
var res = address.Substring(2);
if (res != null && res.Length > 0)
@@ -143,8 +160,7 @@ namespace BPASmartClient.Modbus
}
}
}

else if (address.ToUpper().Contains("VW") && address.Length >= 3)
else if (address.ToUpper().Contains("VW")|| address.ToUpper().Contains("VD") && address.Length >= 3)
{
var res = address.Substring(2);
if (res != null && int.TryParse(res, out int tempAddress))
@@ -241,16 +257,27 @@ namespace BPASmartClient.Modbus
CommandType commandType = CommandType.Coils;
try
{
if (address.ToUpper().Contains("M"))
if (address.ToUpper().Contains("M") || address.ToUpper().Contains("GM"))
{
commandType = CommandType.Coils;
return master.ReadCoils(slaveAddress, startAddress, len);
}
else if (address.ToUpper().Contains("VW") || address.ToUpper().Contains("LW") || address.ToUpper().Contains("D"))
else if (address.ToUpper().Contains("VW") || address.ToUpper().Contains("LW") || address.ToUpper().Contains("D") || address.ToUpper().Contains("GI"))
{
commandType = CommandType.HoldingRegisters;
return master.ReadHoldingRegisters(slaveAddress, startAddress, len);
}
else if (address.ToUpper().Contains("VD"))
{
commandType = CommandType.HoldingRegisters;
var var1 = master.ReadHoldingRegisters(slaveAddress, startAddress, len);
var var2 = master.ReadHoldingRegisters(slaveAddress, (ushort)(startAddress+2), len);
int dest = 0;
dest |= (var2[0] & 0x0000ffff);
dest = (dest << 16) | (var1[0] & 0x0000ffff);
return dest;

}
else if (address.ToUpper().Contains("I"))
{
commandType = CommandType.Inputs;
@@ -325,6 +352,14 @@ namespace BPASmartClient.Modbus
else if (value is bool[] boolsValue)
master.WriteMultipleCoils(slaveAddress, startAddress, boolsValue);
}
if (address.ToUpper().Contains("GM") && address.Length >= 3)
{
commandType = CommandType.Coils;
if (value is bool boolValue)
master.WriteSingleCoil(slaveAddress, startAddress, boolValue);
else if (value is bool[] boolsValue)
master.WriteMultipleCoils(slaveAddress, startAddress, boolsValue);
}
else if(address.ToUpper().Contains("LB"))
{
commandType = CommandType.Coils;
@@ -333,7 +368,19 @@ namespace BPASmartClient.Modbus
else if (value is bool[] boolsValue)
master.WriteMultipleCoils(slaveAddress, startAddress, boolsValue);
}
else if (address.ToUpper().Contains("VW") || address.ToUpper().Contains("LW") || address.ToUpper().Contains("D"))
else if (address.ToUpper().Contains("VD"))
{
commandType = CommandType.HoldingRegisters;
if (value is int intValue)
{
var val1 = (UInt16)intValue;
var val2 = Convert.ToUInt16(intValue >> 16 & 0x0000ffff);
master.WriteSingleRegister(slaveAddress, startAddress, val1);
master.WriteSingleRegister(slaveAddress, (ushort)(startAddress + 1), val2);
}
}
else if (address.ToUpper().Contains("VW") || address.ToUpper().Contains("LW") || address.ToUpper().Contains("D") || address.ToUpper().Contains("GI"))
{
commandType = CommandType.HoldingRegisters;
if (value is ushort ushortValue)


+ 1
- 1
BPASmartClient.MorkBF/BPASmartClient.MorkBF.csproj Voir le fichier

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

<ItemGroup>
<Folder Include="ViewModel\" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.0.0" />
</ItemGroup>

<ItemGroup>


+ 478
- 1
BPASmartClient.MorkBF/Control_MorkBF.cs Voir le fichier

@@ -21,6 +21,8 @@ namespace BPASmartClient.MorkBF

public override void DoMain()
{

CommandRegist();//调试
ServerInit();
DataParse();//数据解析
@@ -74,7 +76,54 @@ namespace BPASmartClient.MorkBF
/// <exception cref="NotImplementedException"></exception>
private void CommandRegist()
{
#region 炒锅1
ActionManage.GetInstance.Register(FirePot1_SetFireGear, "FirePot1_SetFireGear");//炒锅1设定加热挡位
ActionManage.GetInstance.Register(FirePot1_StartFire, "FirePot1_StartFire");//炒锅1加热启动
ActionManage.GetInstance.Register(FirePot1_StartFire, "FirePot1_StopFire");//炒锅1关闭加热
ActionManage.GetInstance.Register(FirePot1_SetStirGear, "FirePot1_SetStirGear");//炒锅1设定搅拌挡位
ActionManage.GetInstance.Register(FirePot1_StartStir, "FirePot1_StartStir");//炒锅1搅拌启动
ActionManage.GetInstance.Register(FirePot1_StartStir, "FirePot1_StopStir");//炒锅1搅拌停止
ActionManage.GetInstance.Register(FirePot1_SetTurnSpeed, "FirePot1_SetTurnSpeed");//炒锅1翻转频率设定
#endregion
#region 炒锅2
ActionManage.GetInstance.Register(FirePot2_SetFireGear, "FirePot2_SetFireGear");//炒锅2设定加热挡位
ActionManage.GetInstance.Register(FirePot2_StartFire, "FirePot2_StartFire");//炒锅2加热启动
ActionManage.GetInstance.Register(FirePot2_StartFire, "FirePot2_StopFire");//炒锅2关闭加热
ActionManage.GetInstance.Register(FirePot2_SetStirGear, "FirePot2_SetStirGear");//炒锅2设定搅拌挡位
ActionManage.GetInstance.Register(FirePot2_StartStir, "FirePot2_StartStir");//炒锅2搅拌启动
ActionManage.GetInstance.Register(FirePot2_StartStir, "FirePot2_StopStir");//炒锅2搅拌停止
ActionManage.GetInstance.Register(FirePot2_SetTurnSpeed, "FirePot2_SetTurnSpeed");//炒锅2翻转频率设定
#endregion
#region 炒锅通用
ActionManage.GetInstance.Register(FirePot_Reset, "FirePot_Reset");//复位;
ActionManage.GetInstance.Register(FirePot_PotGotoOrigin, "FirePot_PotGotoOrigin");//炒锅回原点
ActionManage.GetInstance.Register(FirePot_PotGotoP1, "FirePot_PotGotoP1");//炒锅去位置1
ActionManage.GetInstance.Register(FirePot_PotGotoP2, "FirePot_PotGotoP2");//炒锅去位置2
ActionManage.GetInstance.Register(FirePot_PotGotoP3, "FirePot_PotGotoP3");//炒锅去位置3
ActionManage.GetInstance.Register(FirePot_PotGotoP4, "FirePot_PotGotoP4");//炒锅去位置4
ActionManage.GetInstance.Register(FirePot_PotGotoOutFoodPositiong, "FirePot_PotGotoOutFoodPositiong");//炒锅去出餐位置
ActionManage.GetInstance.Register(FirePot_PotGotoInFoodPosition, "FirePot_PotGotoInFoodPosition");//炒锅去投料位置
ActionManage.GetInstance.Register(FirePot_StartOutFood, "FirePot_StartOutFood");//出餐启动
ActionManage.GetInstance.Register(FirePot_Clean, "FirePot_Clean");//清洗
ActionManage.GetInstance.Register(FirePot_StartPumpWater, "FirePot_StartPumpWater");//抽水启动
ActionManage.GetInstance.Register(FirePot_StartPumpOil, "FirePot_StartPumpOil");//抽油启动
#endregion
#region 机器人
ActionManage.GetInstance.Register(RobotStart, "RobotStart");//机器人启动
ActionManage.GetInstance.Register(RobotStop, "RobotStop");//机器人停止
ActionManage.GetInstance.Register(RobotReset, "RobotReset");//复位
ActionManage.GetInstance.Register(RobotProgramStart, "RobotProgramStart");//程序启动
ActionManage.GetInstance.Register(Robot_Pot1AllowInMaterail, "Robot_Pot1AllowInMaterail");//1号炒锅允许机器人投料
ActionManage.GetInstance.Register(Robot_Pot1OutFoodInSlowDown, "Robot_Pot1OutFoodInSlowDown");//1号炒锅出餐倒料到减速位
ActionManage.GetInstance.Register(Robot_Pot1OutFoodInSlowDown, "Robot_Pot1OutFoodInSlowDown");//1号炒锅出餐倒料完成
ActionManage.GetInstance.Register(Robot_Pot2AllowInMaterail, "Robot_Pot2AllowInMaterail");//2号炒锅允许机器人投料
ActionManage.GetInstance.Register(Robot_Pot2OutFoodInSlowDown, "Robot_Pot2OutFoodInSlowDown");//2号炒锅出餐倒料到减速位
ActionManage.GetInstance.Register(Robot_Pot2OutFood, "Robot_Pot2OutFood");//2号炒锅出餐倒料完成
ActionManage.GetInstance.Register(RobotActionStart, "Robot_Pot2OutFood");//2号炒锅出餐倒料完成


#endregion

}

public override void MainTask()
@@ -132,5 +181,433 @@ namespace BPASmartClient.MorkBF
{
}

#region 控制
private void FirePot_Write(string address, object value, int i = 0)
{
WriteControlExact(address, value, i);
}
#region 炒锅1

/// <summary>
/// 炒锅1设定加热挡位
/// </summary>
/// <param name="o"></param>
private void FirePot1_SetFireGear(object o)
{
if (o == null) return;
if (o is int value)
{
FirePot_Write("VW100", value);
}

}
/// <summary>
/// 炒锅1加热启停
/// </summary>
/// <param name="b"></param>
private void FirePot1_StartFire(object o)
{
if (o == null) return;
if (o is bool value)
{
FirePot_Write("M10.0", value);
}
}
/// <summary>
/// 炒锅1设置搅拌挡位
/// </summary>
/// <param name="o"></param>
private void FirePot1_SetStirGear(object o)
{
if (o == null) return;
if (o is int value)
{
FirePot_Write("VW102", value);
}
}
/// <summary>
/// 炒锅1搅拌启停
/// </summary>
/// <param name="o"></param>
private void FirePot1_StartStir(object o)
{
if (o == null) return;
if (o is bool value)
{
FirePot_Write("M10.1", value);
}
}
/// <summary>
/// 设置炒锅1翻转速度
/// </summary>
/// <param name="o"></param>
private void FirePot1_SetTurnSpeed(object o)
{
if (o == null) return;
if (o is int value)
{
FirePot_Write("VW104", value);
}
}
#endregion
#region 炒锅2
/// <summary>
/// 炒锅2设定加热挡位
/// </summary>
/// <param name="o"></param>
private void FirePot2_SetFireGear(object o)
{
if (o == null) return;
if (o is int value)
{
FirePot_Write("VW130", value);
}

}
/// <summary>
/// 炒锅2加热启停
/// </summary>
/// <param name="b"></param>
private void FirePot2_StartFire(object o)
{
if (o == null) return;
if (o is bool value)
{
FirePot_Write("M15.0", value);
}
}
/// <summary>
/// 炒锅2设置搅拌挡位
/// </summary>
/// <param name="o"></param>
private void FirePot2_SetStirGear(object o)
{
if (o == null) return;
if (o is int value)
{
FirePot_Write("VW132", value);
}
}
/// <summary>
/// 炒锅2搅拌启停
/// </summary>
/// <param name="o"></param>
private void FirePot2_StartStir(object o)
{
if (o == null) return;
if (o is bool value)
{
FirePot_Write("M15.1", value);
}
}
/// <summary>
/// 设置炒锅2翻转速度
/// </summary>
/// <param name="o"></param>
private void FirePot2_SetTurnSpeed(object o)
{
if (o == null) return;
if (o is int value)
{
FirePot_Write("VW134", value);
}
}

#endregion
#region 炒锅通用
/// <summary>
/// 炒锅复位
/// </summary>
/// <param name="o"></param>
private void FirePot_Reset(object o)
{
if (o == null) return;
if (o is int i)
{
if (i == 1)
{

}
else if (i == 2)
{

}
}


}
/// <summary>
/// 炒锅回原点
/// </summary>
/// <param name="o"></param>
private void FirePot_PotGotoOrigin(object o)
{
if (o == null) return;
if (o is int i)
{
if (i == 1)
{
FirePot_Write("M10.5", true);
}
else if (i == 2)
{
FirePot_Write("M15.5", true);
}
}
}
/// <summary>
/// 炒锅去位置1
/// </summary>
/// <param name="o"></param>
private void FirePot_PotGotoP1(object o)
{
if (o == null) return;
if (o is int i)
{
if (i == 1)
{
FirePot_Write("M11.2", true);
}
else if (i == 2)
{
FirePot_Write("M16.2", true);
}
}
}
/// <summary>
/// 炒锅去位置2
/// </summary>
/// <param name="o"></param>
private void FirePot_PotGotoP2(object o)
{
if (o == null) return;
if (o is int i)
{
if (i == 1)
{
FirePot_Write("M11.3", true);
}
else if (i == 2)
{
FirePot_Write("M16.3", true);
}
}
}
/// <summary>
/// 炒锅去位置3
/// </summary>
/// <param name="o"></param>
private void FirePot_PotGotoP3(object o)
{
if (o == null) return;
if (o is int i)
{
if (i == 1)
{
FirePot_Write("M11.4", true);
}
else if (i == 2)
{
FirePot_Write("M16.4", true);
}
}
}
/// <summary>
/// 炒锅去位置4
/// </summary>
/// <param name="o"></param>
private void FirePot_PotGotoP4(object o)
{
if (o == null) return;
if (o is int i)
{
if (i == 1)
{
FirePot_Write("M11.5", true);
}
else if (i == 2)
{
FirePot_Write("M16.5", true);
}
}
}
/// <summary>
/// 炒锅去出餐位置
/// </summary>
/// <param name="o"></param>
private void FirePot_PotGotoOutFoodPositiong(object o)
{
if (o == null) return;
if (o is int i)
{
if (i == 1)
{
FirePot_Write("M11.6", true);
}
else if (i == 2)
{
FirePot_Write("M16.6", true);
}
}
}
/// <summary>
/// 炒锅去投料位置
/// </summary>
/// <param name="o"></param>
private void FirePot_PotGotoInFoodPosition(object o)
{
if (o == null) return;
if (o is int i)
{
if (i == 1)
{
FirePot_Write("M11.7", true);
}
else if (i == 2)
{
FirePot_Write("M16.7", true);
}
}
}
/// <summary>
/// 出餐启动
/// </summary>
/// <param name="o"></param>
private void FirePot_StartOutFood(object o)
{
if (o == null) return;
if (o is int i)
{
if (i == 1)
{
FirePot_Write("M10.6", true);
}
else if (i == 2)
{
FirePot_Write("M15.6", true);
}

}
}
/// <summary>
/// 清洗
/// </summary>
/// <param name="o"></param>
private void FirePot_Clean(object o)
{
if (o == null) return;
if (o is int i)
{
if (i == 1)
{
FirePot_Write("M10.7", true);
}
else if (i == 2)
{
FirePot_Write("M15.7", true);
}
}
}
/// <summary>
/// 抽水启动
/// </summary>
/// <param name="o"></param>
private void FirePot_StartPumpWater(object o)
{
if (o == null) return;
if (o is int i)
{
if (i == 1)
{
FirePot_Write("M11.0", true);
}
else if (i == 2)
{
FirePot_Write("M16.0", true);
}
}
}
/// <summary>
/// 抽油启动
/// </summary>
/// <param name="o"></param>
private void FirePot_StartPumpOil(object o)
{
if (o == null) return;
if (o is int i)
{
if (i == 1)
{
FirePot_Write("M16.0", true);
}
else if (i == 2)
{
FirePot_Write("M16.1", true);
}
}
}
#endregion
#region 机器人
/// <summary>
/// 机器人启动
/// </summary>
private void RobotStart()
{

}
/// <summary>
/// 机器人停止
/// </summary>
private void RobotStop()
{

}
/// <summary>
/// 机器人复位
/// </summary>
private void RobotReset()
{

}
/// <summary>
/// 机器人程序重启
/// </summary>
private void RobotProgramStart()
{

}
/// <summary>
/// 1号炒锅允许机器人投料(炒锅在投料位给出)
/// </summary>
private void Robot_Pot1AllowInMaterail()
{

}
private void Robot_Pot1OutFoodInSlowDown()
{

}
private void Robot_Pot2AllowInMaterail()
{

}
private void Robot_Pot2OutFoodInSlowDown()
{

}
private void Robot_Pot2OutFood()
{

}
private void RobotActionStart()
{

}
#endregion



#endregion
}
}

+ 60
- 26
BPASmartClient.MorkBF/VIew/DebugView.xaml Voir le fichier

@@ -4,8 +4,12 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:BPASmartClient.MorkBF.VIew"
xmlns:vm="clr-namespace:BPASmartClient.MorkBF.ViewModel"
mc:Ignorable="d"
d:DesignHeight="900" d:DesignWidth="1600">
<UserControl.DataContext>
<vm:DebugViewModel/>
</UserControl.DataContext>
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
@@ -15,32 +19,62 @@
</ResourceDictionary>
</UserControl.Resources>
<Grid>
<GroupBox Header="本地菜品" FontSize="22">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="40"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Button Content="添加新菜谱" Width="120" HorizontalAlignment="Right" Margin="20,0"/>
<ListBox Grid.Row="1">
<ListBox.ItemTemplate>
<DataTemplate>
<Border>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200"/>
<ColumnDefinition Width="200"/>
<ColumnDefinition Width="200"/>
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding FoodName}"/>
<Button Grid.Column="1" Content="编辑" Command="EditFood"/>
<Button Grid.Column="2" Content="删除" Command="EditFood"/>
</Grid>
</Border>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<GroupBox Header="炒锅1" 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"/>
<ComboBox Width="80" ItemsSource="{Binding FireGear}" Margin="10,5" SelectedItem="{Binding FirePot1_FireGear}"/>
<Button Content="加热档位设定" Width="110" Margin="10,5" Command="{Binding FirePot1_SetFireGearCommand}"/>
<Button Content="加热启动" Width="80" Margin="10,5" Command="{Binding FirePot1_StartFireCommand}"/>
<Button Content="加热停止" Width="80" Margin="10,5,30,5" Command="{Binding FirePot1_StopFireCommand}"/>
<TextBlock Text="搅拌挡位" Margin="10,5"/>
<ComboBox Width="80" ItemsSource="{Binding StirGear}" SelectedItem="{Binding FirePot1_StirGear}" Margin="10,5"/>
<Button Content="搅拌档位设定" Width="110" Margin="10,5" Command="{Binding FirePot1_SetStirGearCommand}"/>
<Button Content="搅拌启动" Width="80" Margin="10,5" Command="{Binding FirePot1_StartStirCommand}"/>
<Button Content="搅拌停止" Width="80" Margin="10,5,30,5" Command="{Binding FirePot1_StopStirCommand}"/>
<TextBlock Text="翻转频率" Margin="10,5"/>
<TextBox Width="80" Text="{Binding FirePot1_TurnSpeed}" Margin="10,5"/>
<Button Content="翻转频率设定" Width="110" Margin="10,5" Command="{Binding FirePot1_SetTurnSpeedCommand}"/>
<Button Content="炒锅回原点" Width="110" Margin="10,5" Command="{Binding FirePot_PotGotoOriginCommand}" CommandParameter="1"/>
<Button Content="出餐启动" Width="110" Margin="10,5" Command="{Binding FirePot_StartOutFoodCommand}" CommandParameter="1"/>
<Button Content="单独清洗" Width="110" Margin="10,5" Command="{Binding FirePot_CleanCommand}" CommandParameter="1"/>
<Button Content="抽水启动" Width="110" Margin="10,5" Command="{Binding FirePot_StartPumpWaterCommand}" CommandParameter="1"/>
<Button Content="抽油启动" Width="110" Margin="10,5" Command="{Binding FirePot_StartPumpOilCommand}" CommandParameter="1"/>
<Button Content="炒锅去炒制位置1" Width="110" Margin="10,5" Command="{Binding FirePot_PotGotoP1Command}" CommandParameter="1"/>
<Button Content="炒锅去炒制位置2" Width="110" Margin="10,5" Command="{Binding FirePot_PotGotoP2Command}" CommandParameter="1"/>
<Button Content="炒锅去炒制位置3" Width="110" Margin="10,5" Command="{Binding FirePot_PotGotoP3Command}" CommandParameter="1"/>
<Button Content="炒锅去炒制位置4" Width="110" Margin="10,5" Command="{Binding FirePot_PotGotoP4Command}" CommandParameter="1"/>
<Button Content="炒锅去出餐倒料位置" Width="140" Margin="10,5" Command="{Binding FirePot_PotGotoOutFoodPositiongCommand}" CommandParameter="1"/>
<Button Content="炒锅去投料位置" Width="110" Margin="10,5" Command="{Binding FirePot_PotGotoInFoodPositionCommand}" CommandParameter="1"/>
</WrapPanel>

</GroupBox>
<GroupBox Grid.Row="1" Header="炒锅2" FontSize="22">

</GroupBox>
<GroupBox Grid.Row="3" 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}"/>
<Button Content="程序启动" Width="110" Margin="10,5" Command="{Binding RobotProgramStartCommand}"/>
<Button Content="机器人停止" Width="110" Margin="10,5" Command="{Binding RobotStopCommand}"/>
<Button Content="1号炒锅允许机器人投料" Width="160" Margin="10,5" Command="{Binding Robot_Pot1AllowInMaterailCommand}"/>
<Button Content="1号炒锅出餐倒料到减速位" Width="160" Margin="10,5" Command="{Binding Robot_Pot1OutFoodInSlowDownCommand}"/>
<Button Content="1号炒锅出餐倒料完成" Width="160" Margin="10,5" Command="{Binding Robot_Pot1OutFoodCommand}"/>
<Button Content="2号炒锅允许机器人投料" Width="160" Margin="10,5" Command="{Binding Robot_Pot2AllowInMaterailCommand}"/>
<Button Content="2号炒锅出餐倒料到减速位" Width="160" Margin="10,5" Command="{Binding Robot_Pot2OutFoodInSlowDownCommand}"/>
<Button Content="2号炒锅出餐倒料完成" Width="160" Margin="10,5" Command="{Binding Robot_Pot2OutFoodCommand}"/>
<TextBlock Text="机器人取菜出餐动作" Margin="10,5"/>
<ComboBox ItemsSource="{Binding RobotActions}" DisplayMemberPath="Value" SelectedValuePath="Key" SelectedValue="{Binding RobotAction}" Height="30" Width="200" Margin="10,0"/>
<Button Content="动作启动" Width="100" Margin="10,5" Command="{Binding RobotActionStartCommand}"/>
</WrapPanel>
</GroupBox>
</Grid>
</UserControl>

+ 312
- 0
BPASmartClient.MorkBF/ViewModel/DebugViewModel.cs Voir le fichier

@@ -0,0 +1,312 @@
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;

namespace BPASmartClient.MorkBF.ViewModel
{
[INotifyPropertyChanged]
partial class DebugViewModel
{
/// <summary>
/// 加热挡位
/// </summary>
public ObservableCollection<int> FireGear { get; set; } = new ObservableCollection<int>() { 1, 2, 3, 4, 5 };
/// <summary>
/// 搅拌挡位
/// </summary>
public ObservableCollection<int> StirGear { get; set; } = new ObservableCollection<int>() { 1, 2, 3, 4, 5 };

[ObservableProperty]
private int _firePot1_FireGear = 0;
[ObservableProperty]
private int _firePot2_FireGear = 0;
[ObservableProperty]
private int _firePot1_StirGear = 0;
[ObservableProperty]
private int _firePot2_StirGear = 0;
[ObservableProperty]
private int _firePot1_TurnSpeed;
#region 炒锅1
/// <summary>
/// 设定加热挡位
/// </summary>
[RelayCommand]
private void FirePot1_SetFireGear()
{
ActionManage.GetInstance.Send("FirePot1_SetFireGear",new List<int> { FirePot1_FireGear});
}
/// <summary>
/// 加热启动
/// </summary>
[RelayCommand]
private void FirePot1_StartFire()
{
ActionManage.GetInstance.Send("FirePot1_StartFire",true);
}
/// <summary>
/// 关闭加热
/// </summary>
[RelayCommand]
private void FirePot1_StopFire()
{
ActionManage.GetInstance.Send("FirePot1_StopFire",false);
}
/// <summary>
/// 设定搅拌挡位
/// </summary>
[RelayCommand]
private void FirePot1_SetStirGear()
{
ActionManage.GetInstance.Send("FirePot1_SetStirGear",new List<int> { FirePot1_StirGear});
}
/// <summary>
/// 搅拌启动
/// </summary>
[RelayCommand]
private void FirePot1_StartStir()
{
ActionManage.GetInstance.Send("FirePot1_StartStir",true);
}
/// <summary>
/// 搅拌停止
/// </summary>
[RelayCommand]
private void FirePot1_StopStir()
{
ActionManage.GetInstance.Send("FirePot1_StopStir",false);
}
/// <summary>
/// 翻转频率设定
/// </summary>
[RelayCommand]
private void FirePot1_SetTurnSpeed()
{
if (FirePot1_TurnSpeed > 800) FirePot1_TurnSpeed = 800;
ActionManage.GetInstance.Send("FirePot1_SetTurnSpeed",new List<int> { FirePot1_TurnSpeed});
}
#endregion
#region 炒锅2
#endregion
#region 炒锅通用
/// <summary>
/// 复位
/// </summary>
[RelayCommand]
private void FirePot_Reset(object o)
{
ActionManage.GetInstance.Send("FirePot1_Reset", o);
}
/// <summary>
/// 炒锅回原点
/// </summary>
[RelayCommand]
private void FirePot_PotGotoOrigin(object o)
{
ActionManage.GetInstance.Send("FirePot_PotGotoOrigin", o);
}
/// <summary>
/// 炒锅去位置1
/// </summary>
[RelayCommand]
private void FirePot_PotGotoP1(object o)
{
ActionManage.GetInstance.Send("FirePot_PotGotoP1", o);
}
/// <summary>
///炒锅去位置2
/// </summary>
[RelayCommand]
private void FirePot_PotGotoP2(object o)
{
ActionManage.GetInstance.Send("FirePot_PotGotoP2", o);
}
/// <summary>
/// 炒锅去位置3
/// </summary>
[RelayCommand]
private void FirePot_PotGotoP3(object o)
{
ActionManage.GetInstance.Send("FirePot_PotGotoP3", o);
}
/// <summary>
/// 炒锅去位置4
/// </summary>
[RelayCommand]
private void FirePot_PotGotoP4(object o)
{
ActionManage.GetInstance.Send("FirePot_PotGotoP4", o);
}
/// <summary>
/// 炒锅去出餐位置
/// </summary>
[RelayCommand]
private void FirePot_PotGotoOutFoodPositiong(object o)
{
ActionManage.GetInstance.Send("FirePot_PotGotoOutFoodPositiong", o);
}
/// <summary>
/// 炒锅去投料位置
/// </summary>
[RelayCommand]
private void FirePot_PotGotoInFoodPosition(object o)
{
ActionManage.GetInstance.Send("FirePot_PotGotoInFoodPosition", o);
}
/// <summary>
/// 出餐启动
/// </summary>
[RelayCommand]
private void FirePot_StartOutFood(object o)
{
ActionManage.GetInstance.Send("FirePot_StartOutFood", o);
}
/// <summary>
/// 清洗
/// </summary>
[RelayCommand]
private void FirePot_Clean(object o)
{
ActionManage.GetInstance.Send("FirePot_Clean",o);
}
/// <summary>
/// 抽水启动
/// </summary>
[RelayCommand]
private void FirePot_StartPumpWater(object o)
{
ActionManage.GetInstance.Send("FirePot_StartPumpWater", o);
}
/// <summary>
/// 抽油启动
/// </summary>
[RelayCommand]
private void FirePot_StartPumpOil(object o)
{
ActionManage.GetInstance.Send("FirePot_StartPumpOil", o);
}


#endregion


#region 机器人
public Dictionary<int,string> RobotActions { get; set; } = new Dictionary<int, string>()
{
{0, "无任务"},
{1, "取1号炒锅荤菜盆倒1号炒锅"},
{2, "取1号炒锅素菜盆1倒1号炒锅"},
{3, "取1号炒锅素菜盆2倒1号炒锅"},
{4, "取1号炒锅调料盆倒入1号炒锅"},
{5, "取1号炒锅辅料盆1倒入1号炒锅"},
{6, "取1号空盆出餐"},
{20, "取2号炒锅荤菜盆1倒1号炒锅"},
{21, "取2号炒锅素菜盆1倒1号炒锅"},
{22, "取2号炒锅素菜盆2倒1号炒锅"},
{23, "取2号炒锅调料盆倒入1号炒锅"},
{24, "取2号炒锅辅料盆1倒入1号炒锅"},
{25, "取2号空盆出餐"},
};

[ObservableProperty]
private int _robotAction;
/// <summary>
/// 机器人启动
/// </summary>
[RelayCommand]
private void RobotStart()
{
ActionManage.GetInstance.Send("RobotStart");
}
/// <summary>
/// 机器人停止
/// </summary>
[RelayCommand]
private void RobotStop()
{
ActionManage.GetInstance.Send("RobotStop");
}
/// <summary>
/// 复位
/// </summary>
[RelayCommand]
private void RobotReset()
{
ActionManage.GetInstance.Send("RobotReset");
}
/// <summary>
/// 程序启动
/// </summary>
[RelayCommand]
private void RobotProgramStart()
{
ActionManage.GetInstance.Send("RobotProgramStart");
}
/// <summary>
/// 1号炒锅允许机器人投料
/// </summary>
[RelayCommand]
private void Robot_Pot1AllowInMaterail()
{
ActionManage.GetInstance.Send("Robot_Pot1AllowInMaterail");
}
/// <summary>
/// 1号炒锅出餐倒料到减速位
/// </summary>
[RelayCommand]
private void Robot_Pot1OutFoodInSlowDown()
{
ActionManage.GetInstance.Send("Robot_Pot1OutFoodInSlowDown");
}
/// <summary>
/// 1号炒锅出餐倒料完成
/// </summary>
[RelayCommand]
private void Robot_Pot1OutFood()
{
ActionManage.GetInstance.Send("Robot_Pot1OutFood");
}
/// <summary>
/// 2号炒锅允许机器人投料
/// </summary>
[RelayCommand]
private void Robot_Pot2AllowInMaterail()
{
ActionManage.GetInstance.Send("Robot_Pot2AllowInMaterail");
}
/// <summary>
/// 2号炒锅出餐倒料到减速位
/// </summary>
[RelayCommand]
private void Robot_Pot2OutFoodInSlowDown()
{
ActionManage.GetInstance.Send("Robot_Pot2OutFoodInSlowDown");
}
/// <summary>
/// 2号炒锅出餐倒料完成
/// </summary>
[RelayCommand]
private void Robot_Pot2OutFood()
{
ActionManage.GetInstance.Send("Robot_Pot2OutFood");
}

/// <summary>
/// 机器人动作启动
/// </summary>
[RelayCommand]
private void RobotActionStart()
{
ActionManage.GetInstance.Send("RobotProgramStart",new List<int> {RobotAction });
}

#endregion
}
}

+ 1
- 0
BPASmartClient.MorkF/BPASmartClient.MorkF.csproj Voir le fichier

@@ -16,6 +16,7 @@
<ItemGroup>
<ProjectReference Include="..\BPASmartClient.Business\BPASmartClient.Business.csproj" />
<ProjectReference Include="..\BPASmartClient.Device\BPASmartClient.Device.csproj" />
<ProjectReference Include="..\BPASmartClient.Modbus\BPASmartClient.Modbus.csproj" />
<ProjectReference Include="..\BPASmartClient.Model\BPASmartClient.Model.csproj" />
</ItemGroup>



+ 1
- 0
BPASmartClient.MorkF/Control_MorkF.cs Voir le fichier

@@ -11,6 +11,7 @@ using static BPASmartClient.EventBus.EventBus;
using BPASmartClient.Model.小炒机;
using BPASmartClient.MorkF.Model;
using System.Text;
using BPASmartClient.Modbus;

namespace BPASmartClient.MorkF
{


Chargement…
Annuler
Enregistrer