@@ -1,14 +0,0 @@ | |||
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 GlobalFoodMenu | |||
{ | |||
public static ObservableCollection<FoodMenuModel> LocalFoodMenus = new ObservableCollection<FoodMenuModel>(); | |||
} | |||
} |
@@ -0,0 +1,15 @@ | |||
using BPA.Models; | |||
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 MaterialAndFryingTime | |||
{ | |||
public Dictionary<string, ObservableCollection<PotActions>> materials { get; set; } = new Dictionary<string, ObservableCollection<PotActions>>(); | |||
} | |||
} |
@@ -13,6 +13,7 @@ | |||
<ItemGroup> | |||
<ProjectReference Include="..\BPASmartClient.Business\BPASmartClient.Business.csproj" /> | |||
<ProjectReference Include="..\BPASmartClient.Device\BPASmartClient.Device.csproj" /> | |||
<ProjectReference Include="..\BPASmartClient.ViewModel\BPASmartClient.ViewModel.csproj" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
@@ -9,6 +9,7 @@ using BPASmartClient.Model; | |||
using BPASmartClient.Model.大炒; | |||
using BPASmartClient.MorkBF.Model; | |||
using BPASmartClient.MorkBF.ViewModel; | |||
using BPASmartClient.ViewModel; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
@@ -34,18 +35,18 @@ namespace BPASmartClient.MorkBF | |||
IsHealth = true; | |||
BPASmartClient.Helper.Json<LocalFryPotMessage>.Read(); | |||
MonitorViewModel.DeviceId = DeviceId; | |||
ActionManage.GetInstance.Register(new Action(() => | |||
{ | |||
GlobalFoodMenu.LocalFoodMenus.Clear(); | |||
if(BPASmartClient.Helper.Json<LocalFryPotMessage>.Data.FryPotMessage.Count>0) | |||
{ | |||
foreach (var item in BPASmartClient.Helper.Json<LocalFryPotMessage>.Data.FryPotMessage) | |||
{ | |||
GlobalFoodMenu.LocalFoodMenus.Add(new FoodMenuModel { GoodKey = item.GoodKey, GoodName = item.GoodName }); | |||
} | |||
} | |||
//ActionManage.GetInstance.Register(new Action(() => | |||
//{ | |||
// FoodMenuViewModel.GetInstance().FoodMenus.Clear(); | |||
// if(BPASmartClient.Helper.Json<LocalFryPotMessage>.Data.FryPotMessage.Count>0) | |||
// { | |||
// foreach (var item in BPASmartClient.Helper.Json<LocalFryPotMessage>.Data.FryPotMessage) | |||
// { | |||
// FoodMenuViewModel.GetInstance().FoodMenus.Add(new FoodMenuModel { GoodKey = item.GoodKey, GoodName = item.GoodName }); | |||
// } | |||
// } | |||
}), "更新菜单"); | |||
//}), "更新菜单"); | |||
CommandRegist();//调试 | |||
ServerInit(); | |||
DataParse();//数据解析 | |||
@@ -927,7 +928,7 @@ namespace BPASmartClient.MorkBF | |||
WorkStatus_1 = morkBF.FirePot1_Temperature > 0 ? WorkStatus.工作 : WorkStatus.待机, | |||
WorkStatus_2 = morkBF.FirePot2_Temperature > 0 ? WorkStatus.工作 : WorkStatus.待机, | |||
RobotStatu = WorkStatus.工作, | |||
Alarm = new List<AlarmModel>(), | |||
Alarm = new List<BPA.Message.AlarmModel>(), | |||
FailuresCount = 0, | |||
StatsCount = statsModels, | |||
MaxWok_Dishes_1 = "满汉全席", | |||
@@ -18,6 +18,7 @@ | |||
<ProjectReference Include="..\BPASmartClient.Device\BPASmartClient.Device.csproj" /> | |||
<ProjectReference Include="..\BPASmartClient.Modbus\BPASmartClient.Modbus.csproj" /> | |||
<ProjectReference Include="..\BPASmartClient.Model\BPASmartClient.Model.csproj" /> | |||
<ProjectReference Include="..\BPASmartClient.ViewModel\BPASmartClient.ViewModel.csproj" /> | |||
</ItemGroup> | |||
</Project> |
@@ -16,6 +16,8 @@ using System.Windows.Documents; | |||
using BPASmartClient.Business; | |||
using Microsoft.CodeAnalysis; | |||
using BPASmartClient.MorkF.ViewModel; | |||
using BPASmartClient.ViewModel; | |||
using System.Windows; | |||
namespace BPASmartClient.MorkF | |||
{ | |||
@@ -50,13 +52,13 @@ namespace BPASmartClient.MorkF | |||
/// <summary> | |||
/// 菜品盒下移高度,相对于坐标系 | |||
/// </summary> | |||
private const int materialBoxHigh = 4080; | |||
//private const int materialBoxHigh = 4080; | |||
//菜品库出餐高度 | |||
private const int materialHigh = 33000; | |||
////菜品库出餐高度 | |||
//private const int materialHigh = 33000; | |||
//传感器到菜品库的高度(坐标系) | |||
private const int materialLaserHigh = 34500; | |||
////传感器到菜品库的高度(坐标系) | |||
//private const int materialLaserHigh = 34500; | |||
/// <summary> | |||
/// 菜品盒坐标系高度 | |||
@@ -64,26 +66,26 @@ namespace BPASmartClient.MorkF | |||
private const int materialBoxHeight = 9700; | |||
//传感器1到菜品库的高度(厘米) | |||
private const int materialLaserHighCM_1 = 22; | |||
//private const int materialLaserHighCM_1 = 22; | |||
//传感器2到菜品库的高度(厘米) | |||
private const int materialLaserHighCM_2 = 27; | |||
////传感器2到菜品库的高度(厘米) | |||
//private const int materialLaserHighCM_2 = 27; | |||
//传感器3到菜品库的高度(厘米) | |||
private const int materialLaserHighCM_3 = 31; | |||
////传感器3到菜品库的高度(厘米) | |||
//private const int materialLaserHighCM_3 = 31; | |||
/// <summary> | |||
/// 传感器到隔板的距离(坐标系) | |||
/// </summary> | |||
private const int clapboardLaserHigh = 10000; | |||
//炒锅1倒菜的xy坐标 | |||
private const int materialPutPositionXFry1 = 70000; | |||
private const int materialPutPositionYFry1 = 40000; | |||
////炒锅1倒菜的xy坐标 | |||
//private const int materialPutPositionXFry1 = 70000; | |||
//private const int materialPutPositionYFry1 = 40000; | |||
//炒锅2倒菜的xy坐标 | |||
private const int materialPutPositionXFry2 = 70000; | |||
private const int materialPutPositionYFry2 = 40000; | |||
////炒锅2倒菜的xy坐标 | |||
//private const int materialPutPositionXFry2 = 70000; | |||
//private const int materialPutPositionYFry2 = 40000; | |||
//菜品库机械爪放置菜品距离 | |||
private const int materialToFryDistance = 10000; | |||
@@ -146,7 +148,7 @@ namespace BPASmartClient.MorkF | |||
/// <summary> | |||
/// 告警列表 | |||
/// </summary> | |||
private List<AlarmModel> alarmModel = new List<AlarmModel>(); | |||
private List<BPA.Message.AlarmModel> alarmModel = new List<BPA.Message.AlarmModel>(); | |||
/// <summary> | |||
/// | |||
@@ -201,7 +203,7 @@ namespace BPASmartClient.MorkF | |||
MaterialCoordinate.GetInstance().frying2 = materialCoordinate.frying2; | |||
MaterialCoordinate.GetInstance().materialHeight = materialCoordinate.materialHeight; | |||
MaterialCoordinate.GetInstance().MaterialOneX = materialCoordinate.MaterialOneX; | |||
MaterialCoordinate.GetInstance().MaterialTwoX = materialCoordinate.MaterialTwoX; | |||
MaterialCoordinate.GetInstance().MaterialTwoX = materialCoordinate.MaterialTwoX; | |||
MaterialCoordinate.GetInstance().MaterialThreeX = materialCoordinate.MaterialThreeX; | |||
} | |||
////菜品库编号与坐标系对象存储 | |||
@@ -404,7 +406,6 @@ namespace BPASmartClient.MorkF | |||
ActionManage.GetInstance.Register(PLCInite, "InitCommand"); | |||
ActionManage.GetInstance.Register(StartOrder, "StartOrder"); | |||
ActionManage.GetInstance.Register(StartOrderMain, "开始下单"); | |||
ActionManage.GetInstance.Register(StartLocalOrder, "StartLocalOrder"); | |||
ActionManage.GetInstance.Register(StopLocalOrder, "StopLocalOrder"); | |||
ActionManage.GetInstance.Register(new Action<object>((o) => | |||
{ | |||
@@ -725,7 +726,7 @@ namespace BPASmartClient.MorkF | |||
} | |||
/// <summary> | |||
/// 本地菜单下单 | |||
/// 根据菜品ID下单 | |||
/// </summary> | |||
private void StartOrder(object o) | |||
{ | |||
@@ -749,44 +750,42 @@ namespace BPASmartClient.MorkF | |||
} | |||
/// <summary> | |||
/// 本地菜单下单 | |||
/// 主界面本地菜单下单 | |||
/// </summary> | |||
private void StartOrderMain(object o) | |||
{ | |||
if (o == null) return; | |||
if (o is string goodId) | |||
if (o is FoodMenuModel good) | |||
{ | |||
var res = LocalstirFryGoods?.FirstOrDefault(p => p.GoodsKey.ToString() == goodId);//匹配订单对应制作流程 | |||
if (res != null) | |||
{ | |||
/* morkF.listStirBom.Add(res.StirFryBomInfo);*///添加订单制作流程 | |||
if (StirFryGoodsQuenes.Count > 0) return; | |||
StirFryGoodsQuenes.Enqueue(new OrderLocInfo() | |||
{ | |||
SuborderId = Guid.NewGuid().ToString(), | |||
StirPotActions = res.StirPotActions, | |||
GoodName = "本地菜品" | |||
}); | |||
MessageLog.GetInstance.Show($"添加本地订单{res.GoodsKey}"); | |||
} | |||
NewStartLocalOrder(good.GoodName); | |||
} | |||
} | |||
private void StartLocalOrder() | |||
{ | |||
if (StirFryGoodsQuenes.Count > 0) return;//只能一个一个做 | |||
if (Json<LocalPotStep>.Data.LocalstirFryGoods.StirPotActions.Count > 0) | |||
{ | |||
StirFryGoodsQuenes.Enqueue(new OrderLocInfo() | |||
{ | |||
SuborderId = Guid.NewGuid().ToString(), | |||
StirPotActions = Json<LocalPotStep>.Data.LocalstirFryGoods.StirPotActions, | |||
GoodName = "本地菜品" | |||
}); | |||
MessageLog.GetInstance.Show($"添加本地模拟的订单{Json<LocalPotStep>.Data.LocalstirFryGoods.GoodsKey}"); | |||
} | |||
//if (o == null) return; | |||
//if (o is string goodId) | |||
//{ | |||
// var res = LocalstirFryGoods?.FirstOrDefault(p => p.GoodsKey.ToString() == goodId);//匹配订单对应制作流程 | |||
// if (res != null) | |||
// { | |||
// /* morkF.listStirBom.Add(res.StirFryBomInfo);*///添加订单制作流程 | |||
// if (StirFryGoodsQuenes.Count > 0) return; | |||
// StirFryGoodsQuenes.Enqueue(new OrderLocInfo() | |||
// { | |||
// SuborderId = Guid.NewGuid().ToString(), | |||
// StirPotActions = res.StirPotActions, | |||
// GoodName = "本地菜品" | |||
// }); | |||
// MessageLog.GetInstance.Show($"添加本地订单{res.GoodsKey}"); | |||
// } | |||
//} | |||
} | |||
/// <summary> | |||
/// 本地配置的订单 | |||
/// </summary> | |||
/// <param name="materialName"></param> | |||
private void NewStartLocalOrder(string materialName) | |||
{ | |||
//if (StirFryGoodsQuenes.Count > 0) return;//只能一个一个做 | |||
@@ -821,6 +820,7 @@ namespace BPASmartClient.MorkF | |||
GoodName = materialName | |||
}); | |||
MessageLog.GetInstance.Show($"添加本地模拟的订单{Json<LocalPotStep>.Data.LocalstirFryGoods.GoodsKey}"); | |||
MessageBox.Show("下单成功"); | |||
} | |||
} | |||
@@ -1525,7 +1525,7 @@ namespace BPASmartClient.MorkF | |||
return false; | |||
} | |||
WriteSpeed(50000); | |||
WriteSpeed(50000);//移动速度 | |||
//ThreadManage.GetInstance().Start(new Action(() => | |||
//{ | |||
// //收缩爪子 | |||
@@ -2292,11 +2292,7 @@ namespace BPASmartClient.MorkF | |||
GoodsKey = item.GoodsKey, | |||
StirPotActions = OrderSort(item.StirPotActions), | |||
}); | |||
GlobalFoodMenu.LocalFoodMenus.Add(new FoodMenuModel | |||
{ | |||
GoodKey = item.GoodsKey.ToString(), | |||
GoodName = "", | |||
}); | |||
} | |||
} | |||
@@ -2433,9 +2429,9 @@ namespace BPASmartClient.MorkF | |||
/// </summary> | |||
/// <param name="subid"></param> | |||
/// <param name="oRDER_STATUS"></param> | |||
private void OrderChange(string subid, ORDER_STATUS oRDER_STATUS) | |||
private void OrderChange(string Id , string goodName, ORDER_STATUS oRDER_STATUS,int deviceId) | |||
{ | |||
EventBus.EventBus.GetInstance().Publish(new OrderStatusChangedEvent() { Status = oRDER_STATUS, SubOrderId = subid }); | |||
EventBus.EventBus.GetInstance().Publish(new OrderStatusChangedEvent() { Status = oRDER_STATUS, GoodName = goodName,DeviceId = deviceId, SubOrderId =Id }); | |||
} | |||
/// <summary> | |||
@@ -2563,13 +2559,14 @@ namespace BPASmartClient.MorkF | |||
if (morkFs[i].AutoMode && morkFs[i].FryPot1_InitialComplete && ml_morkf.InitialComplete && | |||
!morkFs[i].FryWorking)//炒锅在自动状态&&初始化完成&&菜品库初始化&&是否在炒菜中 | |||
{ | |||
Thread.Sleep(5000); | |||
Thread.Sleep(4000); | |||
lock(lock_MainProcessExcute) | |||
{ | |||
//待炒小炒队列出队列 | |||
if (StirFryGoodsQuenes.TryDequeue(out var res)) | |||
{ | |||
OrderChange(res.SuborderId, res.GoodName, ORDER_STATUS.WAIT, DeviceId = i); | |||
//设置当前炒制菜品 | |||
nowStirFryGood[i] = res; | |||
//炒锅工作状态置为正在工作中 | |||
@@ -2595,7 +2592,7 @@ namespace BPASmartClient.MorkF | |||
bool ret = true; | |||
MessageLog.GetInstance.Show($"炒锅{i}开始炒制菜品{res.GoodName}"); | |||
OrderChange(res.SuborderId, res.GoodName, ORDER_STATUS.COOKING, DeviceId = i); | |||
morkFs[i].GoodName = res.GoodName; | |||
Coordinate myCoordinate = new Coordinate(); | |||
@@ -2764,7 +2761,7 @@ namespace BPASmartClient.MorkF | |||
ret = OutFood(i, out error, true); | |||
if(ret == false) | |||
{ | |||
alarmModel.Add(new AlarmModel() { AlarmTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), AlarmMs = error }); | |||
alarmModel.Add(new BPA.Message.AlarmModel() { AlarmTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), AlarmMs = error }); | |||
} | |||
break; | |||
case nameof(StirFryPotActionEnum.炒制菜品): | |||
@@ -2782,7 +2779,7 @@ namespace BPASmartClient.MorkF | |||
} | |||
if (ret == false) | |||
{ | |||
alarmModel.Add(new AlarmModel() { AlarmTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), AlarmMs = error }); | |||
alarmModel.Add(new BPA.Message.AlarmModel() { AlarmTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), AlarmMs = error }); | |||
} | |||
MessageLog.GetInstance.Show(potActions.Actions); | |||
break; | |||
@@ -2799,9 +2796,9 @@ namespace BPASmartClient.MorkF | |||
Thread.Sleep(3000); | |||
//回原点位 | |||
StirArmGoOrigin(i); | |||
OrderChange(res.SuborderId, res.GoodName, ORDER_STATUS.COMPLETED_COOK, DeviceId = i); | |||
//同时只能允许有一个出餐 | |||
lock(lock_OutMeal) | |||
lock (lock_OutMeal) | |||
{ | |||
//出餐启动 | |||
OutMeal(i); | |||
@@ -55,16 +55,16 @@ | |||
<TextBlock Text="菜单编号:" Margin="10,0"/> | |||
<TextBox Text="{Binding FoodMenuID}" Width="100"/> | |||
<Button Content="下单" Margin="10,0" Command="{Binding StartOrder}" Cursor="Hand"/> | |||
<Button Content="本地模拟流程配置" Click="Button_Click"/> | |||
<Button Content="本地模拟流程下单" Margin="10,0" Command="{Binding StartLocalOrder}" Cursor="Hand"/> | |||
<Button Content="菜单编号下单下单" Margin="10,0" Command="{Binding StartOrder}" Cursor="Hand"/> | |||
<Button Content="本地菜单流程配置" Click="Button_Click"/> | |||
<Button Content="停止炒菜" Margin="10,0" Command="{Binding StopLocalOrder}" Cursor="Hand"/> | |||
<Button Content="{Binding ModeButten}" Margin="10,0" Command="{Binding ModeChange}" Cursor="Hand"/> | |||
<Button Content="{Binding ModeButten}" Margin="10,0" Command="{Binding ModeChange}" Cursor="Hand"/> | |||
</WrapPanel> | |||
</Grid> | |||
</GroupBox> | |||
<GroupBox Header="菜品选择" FontSize="15" Foreground="Aqua" Grid.Row="2" VerticalAlignment="Center" Height="190" > | |||
<!--<GroupBox Header="菜品选择" FontSize="15" Foreground="Aqua" Grid.Row="2" VerticalAlignment="Center" Height="190" > | |||
<Grid > | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="*"/> | |||
@@ -127,7 +127,7 @@ | |||
</WrapPanel> | |||
</Grid> | |||
</GroupBox> | |||
</GroupBox>--> | |||
<StackPanel Orientation="Vertical" Grid.Row="3"> | |||
<GroupBox Header="配料仓控制" FontSize="15" Foreground="Aqua" VerticalAlignment="Center" Height="65"> | |||
<WrapPanel Orientation="Horizontal" Grid.RowSpan="2" VerticalAlignment="Top" Margin="0,5,0,0" > | |||
@@ -7,7 +7,7 @@ | |||
xmlns:local="clr-namespace:BPASmartClient.MorkF.View" | |||
xmlns:vm="clr-namespace:BPASmartClient.MorkF.ViewModel" | |||
mc:Ignorable="d" | |||
Title="LocalMenu" Height="800" Width="800" WindowStartupLocation="CenterScreen" WindowStyle="None" AllowsTransparency="True" MouseLeftButtonDown="Window_MouseLeftButtonDown" Background="Gray" | |||
Title="LocalMenu" Height="900" Width="800" WindowStartupLocation="CenterScreen" WindowStyle="None" AllowsTransparency="True" MouseLeftButtonDown="Window_MouseLeftButtonDown" Background="Gray" | |||
> | |||
<Window.DataContext> | |||
<vm:LocalMenuViewModel/> | |||
@@ -22,7 +22,7 @@ | |||
<Setter Property="Template"> | |||
<Setter.Value> | |||
<ControlTemplate TargetType="{x:Type ListBoxItem}"> | |||
<Border BorderBrush="Black" BorderThickness="0" Background="Transparent"> | |||
<Border BorderBrush="Black" BorderThickness="0" Background="Transparent" Margin="5"> | |||
<Grid Width="600" HorizontalAlignment="Center" VerticalAlignment="Center" > | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition/> | |||
@@ -56,23 +56,29 @@ | |||
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/窗体样式/From/内部背景.png"/> | |||
</Grid.Background> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="80"/> | |||
<RowDefinition Height="80"/> | |||
<RowDefinition Height="50"/> | |||
<RowDefinition Height="*"/> | |||
</Grid.RowDefinitions> | |||
<StackPanel Margin="10,20,10,0" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center"> | |||
<ComboBox Name="Materials" Width="100" Height="40" SelectionChanged="Materials_SelectionChanged" ItemsSource="{Binding MaterialNames}" HorizontalAlignment="Center" VerticalAlignment="Center"/> | |||
<TextBox Text="{Binding MaterialName}" Width="80" Height="40" Margin="10,0"/> | |||
<Button Content="增加菜谱" Command="{Binding AddMaterial}" Width="80" Height="40" Margin="10,0"/> | |||
<Button Content="下单" Command="{Binding NewStartLocalMaterial}" Width="80" Height="40" Margin="10,0"/> | |||
<!--<Button Content="菜谱重命名" Command="{Binding RenameMaterial}" Width="80" Height="40" Margin="10,0"/> | |||
<Button Content="删除菜谱" Command="{Binding DeleteMaterial}" Width="80" Height="40" Margin="10,0"/>--> | |||
</StackPanel> | |||
<StackPanel Grid.Row="1" Margin="10,20,10,0" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center"> | |||
<ComboBox Name="Materials" Width="100" Height="40" SelectionChanged="Materials_SelectionChanged" SelectedIndex="0" IsReadOnly="True" | |||
ItemsSource="{Binding MaterialNames}" SelectedItem="{Binding SelectMaterialName}" HorizontalAlignment="Center" VerticalAlignment="Center"/> | |||
<!--<Button Content="下单" Command="{Binding NewStartLocalMaterial}" Width="80" Height="40" Margin="10,0" Cursor="Hand"/>--> | |||
<!--<Button Content="菜谱重命名" Command="{Binding RenameMaterial}" Width="80" Height="40" Margin="10,0"/>--> | |||
<Button Content="删除菜谱" Command="{Binding DeleteMaterial}" Width="80" Height="40" Margin="10,0"/> | |||
<Button Content="增加步骤" Command="{Binding AddFryTime}" Width="80" Height="40" Margin="10,0"/> | |||
<Button Content="保存" Command="{Binding Save}" Width="80" Height="40" Margin="10,0"/> | |||
<Button Content="退出" Click="Button_Click" Width="80" Height="40" Margin="10,0"/> | |||
</StackPanel> | |||
<Grid Grid.Row="1" Width="600" HorizontalAlignment="Center" VerticalAlignment="Center"> | |||
<Grid Grid.Row="2" Width="600" HorizontalAlignment="Center" VerticalAlignment="Center"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition/> | |||
<ColumnDefinition/> | |||
@@ -88,7 +94,7 @@ | |||
<TextBlock Grid.Column="4" Text="调料重量" HorizontalAlignment="Center"/> | |||
<TextBlock Grid.Column="5" Text="删除" HorizontalAlignment="Center"/> | |||
</Grid> | |||
<ListBox x:Name="listview1" Grid.Row="2" BorderBrush="Black" BorderThickness="0" HorizontalAlignment="Center" AllowDrop="True" | |||
<ListBox x:Name="listview1" Grid.Row="3" BorderBrush="Black" BorderThickness="0" HorizontalAlignment="Center" AllowDrop="True" | |||
ScrollViewer.HorizontalScrollBarVisibility="Disabled" ItemsSource="{Binding PotActionStep}" Margin=" 10" Background="Transparent" | |||
> | |||
@@ -233,7 +233,7 @@ namespace BPASmartClient.MorkF.View | |||
private void Materials_SelectionChanged(object sender, SelectionChangedEventArgs e) | |||
{ | |||
string str = Materials.SelectedValue.ToString(); | |||
string str = Materials.SelectedValue?.ToString(); | |||
if(str != string.Empty) | |||
{ | |||
ActionManage.GetInstance.Send("LoacMenuSelectMaterial", str); | |||
@@ -33,7 +33,7 @@ namespace BPASmartClient.MorkF.ViewModel | |||
public RelayCommand FoodPlcInite { get; set; } | |||
public RelayCommand Plc1Reset { get; set; } | |||
public RelayCommand StartOrder { get; set; } | |||
public RelayCommand StartLocalOrder { get; set; } | |||
public RelayCommand StopLocalOrder { get; set; } | |||
public RelayCommand ModeChange { get; set; } | |||
@@ -205,7 +205,6 @@ namespace BPASmartClient.MorkF.ViewModel | |||
PlcInite = new RelayCommand(() => { ActionManage.GetInstance.Send("InitCommand"); }); | |||
Plc1Reset = new RelayCommand(() => { ActionManage.GetInstance.Send("Plc1Reset"); }); | |||
StartOrder = new RelayCommand(() => { ActionManage.GetInstance.Send("StartOrder", FoodMenuID); }); | |||
StartLocalOrder = new RelayCommand(() => { ActionManage.GetInstance.Send("StartLocalOrder"); }); | |||
StopLocalOrder = new RelayCommand(() => { ActionManage.GetInstance.Send("StopLocalOrder"); }); | |||
ModeChange = new RelayCommand(() => { | |||
ActionManage.GetInstance.Send("ModeChange"); | |||
@@ -1,6 +1,9 @@ | |||
using BPA.Models; | |||
using BPASmartClient.Helper; | |||
using BPASmartClient.Model; | |||
using BPASmartClient.Model.小炒机; | |||
using BPASmartClient.MorkF.Model; | |||
using BPASmartClient.ViewModel; | |||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||
using Microsoft.Toolkit.Mvvm.Input; | |||
using System; | |||
@@ -17,20 +20,33 @@ namespace BPASmartClient.MorkF.ViewModel | |||
partial class LocalMenuViewModel:ObservableObject | |||
{ | |||
/// <summary> | |||
/// 单个菜品流程 | |||
/// </summary> | |||
public ObservableCollection<PotActions> PotActionStep { get { return _PotActionStep; } | |||
set { _PotActionStep = value; OnPropertyChanged(); } } | |||
private ObservableCollection<PotActions> _PotActionStep = new ObservableCollection<PotActions>(); | |||
public string MaterialName { get; set; } | |||
public string SelectMaterialName { get; set; } | |||
/// <summary> | |||
/// 选中的菜品 | |||
/// </summary> | |||
public string SelectMaterialName { get { return _selectMaterialName; } set { _selectMaterialName = value; OnPropertyChanged(); } } | |||
private string _selectMaterialName; | |||
/// <summary> | |||
/// 菜品combox集合 | |||
/// </summary> | |||
public ObservableCollection<string> MaterialNames { get; set; } = new ObservableCollection<string>(); | |||
/// <summary> | |||
/// 动作名称combox集合 | |||
/// </summary> | |||
public ObservableCollection<string> strPotActions { get; set; } = new ObservableCollection<string>(); | |||
public MaterialAndFryingTime materialAndFryingTime { get; set; } = new MaterialAndFryingTime(); | |||
/// <summary> | |||
/// 全部菜品流程集合 | |||
/// </summary> | |||
public MaterialAndFryingTime materialAndFryingTime { get; set; } = Json<MaterialAndFryingTime>.Data; | |||
public RelayCommand<object> Delete { get; set; } | |||
public RelayCommand AddFryTime { get; set; } | |||
@@ -106,34 +122,33 @@ namespace BPASmartClient.MorkF.ViewModel | |||
else | |||
{ | |||
MaterialNames.Add(MaterialName); | |||
SelectMaterialName = MaterialName; | |||
} | |||
}); | |||
DeleteMaterial = new RelayCommand(() => | |||
{ | |||
//尝试是否能找到 | |||
if (MaterialNames.FirstOrDefault(o => o == SelectMaterialName) == SelectMaterialName) | |||
if (materialAndFryingTime.materials.ContainsKey(SelectMaterialName)) | |||
{ | |||
MaterialNames.Remove(SelectMaterialName); | |||
if(materialAndFryingTime.materials.ContainsKey(SelectMaterialName)) | |||
{ | |||
materialAndFryingTime.materials.Remove(SelectMaterialName); | |||
} | |||
} | |||
}); | |||
RenameMaterial = new RelayCommand(() => | |||
{ | |||
//尝试是否能找到 | |||
if (MaterialNames.FirstOrDefault(o => o == SelectMaterialName) == SelectMaterialName) | |||
{ | |||
MaterialNames.Remove(SelectMaterialName); | |||
MaterialNames.Add(MaterialName); | |||
if (materialAndFryingTime.materials.ContainsKey(SelectMaterialName)) | |||
{ | |||
materialAndFryingTime.materials.Add(MaterialName, materialAndFryingTime.materials[SelectMaterialName]); | |||
materialAndFryingTime.materials.Remove(SelectMaterialName); | |||
} | |||
materialAndFryingTime.materials.Remove(SelectMaterialName); | |||
} | |||
MaterialNames.Remove(SelectMaterialName); | |||
PotActionStep.Clear(); | |||
}); | |||
//RenameMaterial = new RelayCommand(() => | |||
//{ | |||
// //尝试是否能找到 | |||
// if (MaterialNames.FirstOrDefault(o => o == SelectMaterialName) == SelectMaterialName) | |||
// { | |||
// MaterialNames.Remove(SelectMaterialName); | |||
// MaterialNames.Add(MaterialName); | |||
// if (materialAndFryingTime.materials.ContainsKey(SelectMaterialName)) | |||
// { | |||
// materialAndFryingTime.materials.Add(MaterialName, materialAndFryingTime.materials[SelectMaterialName]); | |||
// materialAndFryingTime.materials.Remove(SelectMaterialName); | |||
// } | |||
// } | |||
//}); | |||
Save = new RelayCommand(new Action(() => | |||
{ | |||
if(PotActionStep.Count > 0) | |||
@@ -155,8 +170,9 @@ namespace BPASmartClient.MorkF.ViewModel | |||
//Json<LocalPotStep>.Data.LocalstirFryGoods.GoodsKey = 11; | |||
//Json<LocalPotStep>.Data.LocalstirFryGoods.StirPotActions = new List<PotActions>(PotActionStep); | |||
//Json<LocalPotStep>.Save(); | |||
Json<MaterialAndFryingTime>.Data.materials = materialAndFryingTime.materials; | |||
//Json<MaterialAndFryingTime>.Data.materials = materialAndFryingTime.materials; | |||
Json<MaterialAndFryingTime>.Save(); | |||
//ActionManage.GetInstance.Send("LocalMenuClose"); | |||
})); | |||
@@ -209,8 +225,5 @@ namespace BPASmartClient.MorkF.ViewModel | |||
} | |||
} | |||
partial class MaterialAndFryingTime | |||
{ | |||
public Dictionary<string, ObservableCollection<PotActions>> materials { get; set; } = new Dictionary<string, ObservableCollection<PotActions>>(); | |||
} | |||
} |
@@ -1,5 +1,6 @@ | |||
using BPASmartClient.Helper; | |||
using BPASmartClient.Model; | |||
using BPASmartClient.Model.小炒机; | |||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||
using Microsoft.Toolkit.Mvvm.Input; | |||
using System; | |||
@@ -13,17 +14,23 @@ namespace BPASmartClient.ViewModel | |||
{ | |||
public class FoodMenuViewModel: ObservableObject | |||
{ | |||
public ObservableCollection<FoodMenuModel> FoodMenus { get; set; } = GlobalFoodMenu.LocalFoodMenus; | |||
/// <summary> | |||
/// 菜单 | |||
/// </summary> | |||
public ObservableCollection<FoodMenuModel> FoodMenus { get; set; } = new ObservableCollection<FoodMenuModel>(); | |||
public RelayCommand<object> StartOrder { get; set; } | |||
public FoodMenuViewModel() | |||
{ | |||
Json<MaterialAndFryingTime>.Data.materials?.Keys?.ToList().ForEach(key => FoodMenus.Add(new FoodMenuModel { GoodName = key })); | |||
StartOrder = new RelayCommand<object>((o) => | |||
{ | |||
ActionManage.GetInstance.Send("开始下单", o); | |||
}); | |||
} | |||
} | |||
} |
@@ -6,10 +6,8 @@ | |||
xmlns:local="clr-namespace:Control" | |||
xmlns:vm="clr-namespace:BPASmartClient.ViewModel;assembly=BPASmartClient.ViewModel" | |||
mc:Ignorable="d" | |||
d:DesignHeight="450" d:DesignWidth="800"> | |||
<UserControl.DataContext> | |||
<vm:FoodMenuViewModel/> | |||
</UserControl.DataContext> | |||
d:DesignHeight="850" d:DesignWidth="800"> | |||
<UserControl.Resources> | |||
<ResourceDictionary> | |||
<ResourceDictionary.MergedDictionaries> | |||
@@ -23,6 +21,7 @@ | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="50"/> | |||
<RowDefinition Height="*"/> | |||
<RowDefinition Height="0.6*"/> | |||
</Grid.RowDefinitions> | |||
<Grid HorizontalAlignment="Center"> | |||
<Grid.ColumnDefinitions> | |||
@@ -47,11 +46,12 @@ | |||
<TextBlock Grid.Column="1" FontSize="18" Text="{Binding GoodName}" VerticalAlignment="Center" HorizontalAlignment="Center"/> | |||
<Button Grid.Column="2" Width="120" Content="下单" HorizontalAlignment="Center" VerticalAlignment="Center" Height="30" | |||
Command="{Binding DataContext.StartOrder, RelativeSource={RelativeSource AncestorType=UserControl,Mode=FindAncestor}}" | |||
CommandParameter="{Binding GoodKey}"/> | |||
CommandParameter="{Binding .}"/> | |||
</Grid> | |||
</DataTemplate> | |||
</ListBox.ItemTemplate> | |||
</ListBox> | |||
</Grid> | |||
@@ -1,4 +1,5 @@ | |||
using System; | |||
using BPASmartClient.ViewModel; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Text; | |||
using System.Windows; | |||
@@ -21,6 +22,7 @@ namespace BPASmartClient.Control | |||
public FoodMenuView() | |||
{ | |||
InitializeComponent(); | |||
this.DataContext = new FoodMenuViewModel(); | |||
} | |||
} | |||
} |