Selaa lähdekoodia

小炒

master
NXX 1 vuosi sitten
vanhempi
commit
edef6d6bed
14 muutettua tiedostoa jossa 174 lisäystä ja 146 poistoa
  1. +0
    -14
      BPASmartClient.Model/GlobalFoodMenu.cs
  2. +15
    -0
      BPASmartClient.Model/小炒机/MaterialAndFryingTime.cs
  3. +1
    -0
      BPASmartClient.MorkBF/BPASmartClient.MorkBF.csproj
  4. +13
    -12
      BPASmartClient.MorkBF/Control_MorkBF.cs
  5. +1
    -0
      BPASmartClient.MorkF/BPASmartClient.MorkF.csproj
  6. +60
    -63
      BPASmartClient.MorkF/Control_MorkF.cs
  7. +6
    -6
      BPASmartClient.MorkF/View/DebugView.xaml
  8. +14
    -8
      BPASmartClient.MorkF/View/LocalMenu.xaml
  9. +1
    -1
      BPASmartClient.MorkF/View/LocalMenu.xaml.cs
  10. +1
    -2
      BPASmartClient.MorkF/ViewModel/DebugViewModel.cs
  11. +45
    -32
      BPASmartClient.MorkF/ViewModel/LocalMenuViewModel.cs
  12. +9
    -2
      BPASmartClient.ViewModel/FoodMenuViewModel.cs
  13. +5
    -5
      BPASmartClient/Control/FoodMenuView.xaml
  14. +3
    -1
      BPASmartClient/Control/FoodMenuView.xaml.cs

+ 0
- 14
BPASmartClient.Model/GlobalFoodMenu.cs Näytä tiedosto

@@ -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>();
}
}

+ 15
- 0
BPASmartClient.Model/小炒机/MaterialAndFryingTime.cs Näytä tiedosto

@@ -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>>();
}
}

+ 1
- 0
BPASmartClient.MorkBF/BPASmartClient.MorkBF.csproj Näytä tiedosto

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


<ItemGroup> <ItemGroup>


+ 13
- 12
BPASmartClient.MorkBF/Control_MorkBF.cs Näytä tiedosto

@@ -9,6 +9,7 @@ using BPASmartClient.Model;
using BPASmartClient.Model.大炒; using BPASmartClient.Model.大炒;
using BPASmartClient.MorkBF.Model; using BPASmartClient.MorkBF.Model;
using BPASmartClient.MorkBF.ViewModel; using BPASmartClient.MorkBF.ViewModel;
using BPASmartClient.ViewModel;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@@ -34,18 +35,18 @@ namespace BPASmartClient.MorkBF
IsHealth = true; IsHealth = true;
BPASmartClient.Helper.Json<LocalFryPotMessage>.Read(); BPASmartClient.Helper.Json<LocalFryPotMessage>.Read();
MonitorViewModel.DeviceId = DeviceId; 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();//调试 CommandRegist();//调试
ServerInit(); ServerInit();
DataParse();//数据解析 DataParse();//数据解析
@@ -927,7 +928,7 @@ namespace BPASmartClient.MorkBF
WorkStatus_1 = morkBF.FirePot1_Temperature > 0 ? WorkStatus.工作 : WorkStatus.待机, WorkStatus_1 = morkBF.FirePot1_Temperature > 0 ? WorkStatus.工作 : WorkStatus.待机,
WorkStatus_2 = morkBF.FirePot2_Temperature > 0 ? WorkStatus.工作 : WorkStatus.待机, WorkStatus_2 = morkBF.FirePot2_Temperature > 0 ? WorkStatus.工作 : WorkStatus.待机,
RobotStatu = WorkStatus.工作, RobotStatu = WorkStatus.工作,
Alarm = new List<AlarmModel>(),
Alarm = new List<BPA.Message.AlarmModel>(),
FailuresCount = 0, FailuresCount = 0,
StatsCount = statsModels, StatsCount = statsModels,
MaxWok_Dishes_1 = "满汉全席", MaxWok_Dishes_1 = "满汉全席",


+ 1
- 0
BPASmartClient.MorkF/BPASmartClient.MorkF.csproj Näytä tiedosto

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


</Project> </Project>

+ 60
- 63
BPASmartClient.MorkF/Control_MorkF.cs Näytä tiedosto

@@ -16,6 +16,8 @@ using System.Windows.Documents;
using BPASmartClient.Business; using BPASmartClient.Business;
using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis;
using BPASmartClient.MorkF.ViewModel; using BPASmartClient.MorkF.ViewModel;
using BPASmartClient.ViewModel;
using System.Windows;


namespace BPASmartClient.MorkF namespace BPASmartClient.MorkF
{ {
@@ -50,13 +52,13 @@ namespace BPASmartClient.MorkF
/// <summary> /// <summary>
/// 菜品盒下移高度,相对于坐标系 /// 菜品盒下移高度,相对于坐标系
/// </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> /// <summary>
/// 菜品盒坐标系高度 /// 菜品盒坐标系高度
@@ -64,26 +66,26 @@ namespace BPASmartClient.MorkF
private const int materialBoxHeight = 9700; private const int materialBoxHeight = 9700;


//传感器1到菜品库的高度(厘米) //传感器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>
/// 传感器到隔板的距离(坐标系) /// 传感器到隔板的距离(坐标系)
/// </summary> /// </summary>
private const int clapboardLaserHigh = 10000; 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; private const int materialToFryDistance = 10000;
@@ -146,7 +148,7 @@ namespace BPASmartClient.MorkF
/// <summary> /// <summary>
/// 告警列表 /// 告警列表
/// </summary> /// </summary>
private List<AlarmModel> alarmModel = new List<AlarmModel>();
private List<BPA.Message.AlarmModel> alarmModel = new List<BPA.Message.AlarmModel>();


/// <summary> /// <summary>
/// ///
@@ -201,7 +203,7 @@ namespace BPASmartClient.MorkF
MaterialCoordinate.GetInstance().frying2 = materialCoordinate.frying2; MaterialCoordinate.GetInstance().frying2 = materialCoordinate.frying2;
MaterialCoordinate.GetInstance().materialHeight = materialCoordinate.materialHeight; MaterialCoordinate.GetInstance().materialHeight = materialCoordinate.materialHeight;
MaterialCoordinate.GetInstance().MaterialOneX = materialCoordinate.MaterialOneX; MaterialCoordinate.GetInstance().MaterialOneX = materialCoordinate.MaterialOneX;
MaterialCoordinate.GetInstance().MaterialTwoX = materialCoordinate.MaterialTwoX;
MaterialCoordinate.GetInstance().MaterialTwoX = materialCoordinate.MaterialTwoX;
MaterialCoordinate.GetInstance().MaterialThreeX = materialCoordinate.MaterialThreeX; MaterialCoordinate.GetInstance().MaterialThreeX = materialCoordinate.MaterialThreeX;
} }
////菜品库编号与坐标系对象存储 ////菜品库编号与坐标系对象存储
@@ -404,7 +406,6 @@ namespace BPASmartClient.MorkF
ActionManage.GetInstance.Register(PLCInite, "InitCommand"); ActionManage.GetInstance.Register(PLCInite, "InitCommand");
ActionManage.GetInstance.Register(StartOrder, "StartOrder"); ActionManage.GetInstance.Register(StartOrder, "StartOrder");
ActionManage.GetInstance.Register(StartOrderMain, "开始下单"); ActionManage.GetInstance.Register(StartOrderMain, "开始下单");
ActionManage.GetInstance.Register(StartLocalOrder, "StartLocalOrder");
ActionManage.GetInstance.Register(StopLocalOrder, "StopLocalOrder"); ActionManage.GetInstance.Register(StopLocalOrder, "StopLocalOrder");
ActionManage.GetInstance.Register(new Action<object>((o) => ActionManage.GetInstance.Register(new Action<object>((o) =>
{ {
@@ -725,7 +726,7 @@ namespace BPASmartClient.MorkF
} }


/// <summary> /// <summary>
/// 本地菜单下单
/// 根据菜品ID下单
/// </summary> /// </summary>
private void StartOrder(object o) private void StartOrder(object o)
{ {
@@ -749,44 +750,42 @@ namespace BPASmartClient.MorkF
} }


/// <summary> /// <summary>
/// 本地菜单下单
/// 主界面本地菜单下单
/// </summary> /// </summary>
private void StartOrderMain(object o) private void StartOrderMain(object o)
{ {
if (o == null) return; 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) private void NewStartLocalOrder(string materialName)
{ {
//if (StirFryGoodsQuenes.Count > 0) return;//只能一个一个做 //if (StirFryGoodsQuenes.Count > 0) return;//只能一个一个做
@@ -821,6 +820,7 @@ namespace BPASmartClient.MorkF
GoodName = materialName GoodName = materialName
}); });
MessageLog.GetInstance.Show($"添加本地模拟的订单{Json<LocalPotStep>.Data.LocalstirFryGoods.GoodsKey}"); MessageLog.GetInstance.Show($"添加本地模拟的订单{Json<LocalPotStep>.Data.LocalstirFryGoods.GoodsKey}");
MessageBox.Show("下单成功");
} }
} }


@@ -1525,7 +1525,7 @@ namespace BPASmartClient.MorkF
return false; return false;
} }


WriteSpeed(50000);
WriteSpeed(50000);//移动速度
//ThreadManage.GetInstance().Start(new Action(() => //ThreadManage.GetInstance().Start(new Action(() =>
//{ //{
// //收缩爪子 // //收缩爪子
@@ -2292,11 +2292,7 @@ namespace BPASmartClient.MorkF
GoodsKey = item.GoodsKey, GoodsKey = item.GoodsKey,
StirPotActions = OrderSort(item.StirPotActions), StirPotActions = OrderSort(item.StirPotActions),
}); });
GlobalFoodMenu.LocalFoodMenus.Add(new FoodMenuModel
{
GoodKey = item.GoodsKey.ToString(),
GoodName = "",
});
} }
} }


@@ -2433,9 +2429,9 @@ namespace BPASmartClient.MorkF
/// </summary> /// </summary>
/// <param name="subid"></param> /// <param name="subid"></param>
/// <param name="oRDER_STATUS"></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> /// <summary>
@@ -2563,13 +2559,14 @@ namespace BPASmartClient.MorkF
if (morkFs[i].AutoMode && morkFs[i].FryPot1_InitialComplete && ml_morkf.InitialComplete && if (morkFs[i].AutoMode && morkFs[i].FryPot1_InitialComplete && ml_morkf.InitialComplete &&
!morkFs[i].FryWorking)//炒锅在自动状态&&初始化完成&&菜品库初始化&&是否在炒菜中 !morkFs[i].FryWorking)//炒锅在自动状态&&初始化完成&&菜品库初始化&&是否在炒菜中
{ {
Thread.Sleep(5000);
Thread.Sleep(4000);


lock(lock_MainProcessExcute) lock(lock_MainProcessExcute)
{ {
//待炒小炒队列出队列 //待炒小炒队列出队列
if (StirFryGoodsQuenes.TryDequeue(out var res)) if (StirFryGoodsQuenes.TryDequeue(out var res))
{ {
OrderChange(res.SuborderId, res.GoodName, ORDER_STATUS.WAIT, DeviceId = i);
//设置当前炒制菜品 //设置当前炒制菜品
nowStirFryGood[i] = res; nowStirFryGood[i] = res;
//炒锅工作状态置为正在工作中 //炒锅工作状态置为正在工作中
@@ -2595,7 +2592,7 @@ namespace BPASmartClient.MorkF
bool ret = true; bool ret = true;
MessageLog.GetInstance.Show($"炒锅{i}开始炒制菜品{res.GoodName}"); MessageLog.GetInstance.Show($"炒锅{i}开始炒制菜品{res.GoodName}");
OrderChange(res.SuborderId, res.GoodName, ORDER_STATUS.COOKING, DeviceId = i);
morkFs[i].GoodName = res.GoodName; morkFs[i].GoodName = res.GoodName;


Coordinate myCoordinate = new Coordinate(); Coordinate myCoordinate = new Coordinate();
@@ -2764,7 +2761,7 @@ namespace BPASmartClient.MorkF
ret = OutFood(i, out error, true); ret = OutFood(i, out error, true);
if(ret == false) 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; break;
case nameof(StirFryPotActionEnum.炒制菜品): case nameof(StirFryPotActionEnum.炒制菜品):
@@ -2782,7 +2779,7 @@ namespace BPASmartClient.MorkF
} }
if (ret == false) 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); MessageLog.GetInstance.Show(potActions.Actions);
break; break;
@@ -2799,9 +2796,9 @@ namespace BPASmartClient.MorkF
Thread.Sleep(3000); Thread.Sleep(3000);
//回原点位 //回原点位
StirArmGoOrigin(i); StirArmGoOrigin(i);
OrderChange(res.SuborderId, res.GoodName, ORDER_STATUS.COMPLETED_COOK, DeviceId = i);
//同时只能允许有一个出餐 //同时只能允许有一个出餐
lock(lock_OutMeal)
lock (lock_OutMeal)
{ {
//出餐启动 //出餐启动
OutMeal(i); OutMeal(i);


+ 6
- 6
BPASmartClient.MorkF/View/DebugView.xaml Näytä tiedosto

@@ -55,16 +55,16 @@


<TextBlock Text="菜单编号:" Margin="10,0"/> <TextBlock Text="菜单编号:" Margin="10,0"/>
<TextBox Text="{Binding FoodMenuID}" Width="100"/> <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="停止炒菜" 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> </WrapPanel>
</Grid> </Grid>


</GroupBox> </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 >
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="*"/> <RowDefinition Height="*"/>
@@ -127,7 +127,7 @@
</WrapPanel> </WrapPanel>
</Grid> </Grid>


</GroupBox>
</GroupBox>-->
<StackPanel Orientation="Vertical" Grid.Row="3"> <StackPanel Orientation="Vertical" Grid.Row="3">
<GroupBox Header="配料仓控制" FontSize="15" Foreground="Aqua" VerticalAlignment="Center" Height="65"> <GroupBox Header="配料仓控制" FontSize="15" Foreground="Aqua" VerticalAlignment="Center" Height="65">
<WrapPanel Orientation="Horizontal" Grid.RowSpan="2" VerticalAlignment="Top" Margin="0,5,0,0" > <WrapPanel Orientation="Horizontal" Grid.RowSpan="2" VerticalAlignment="Top" Margin="0,5,0,0" >


+ 14
- 8
BPASmartClient.MorkF/View/LocalMenu.xaml Näytä tiedosto

@@ -7,7 +7,7 @@
xmlns:local="clr-namespace:BPASmartClient.MorkF.View" xmlns:local="clr-namespace:BPASmartClient.MorkF.View"
xmlns:vm="clr-namespace:BPASmartClient.MorkF.ViewModel" xmlns:vm="clr-namespace:BPASmartClient.MorkF.ViewModel"
mc:Ignorable="d" 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> <Window.DataContext>
<vm:LocalMenuViewModel/> <vm:LocalMenuViewModel/>
@@ -22,7 +22,7 @@
<Setter Property="Template"> <Setter Property="Template">
<Setter.Value> <Setter.Value>
<ControlTemplate TargetType="{x:Type ListBoxItem}"> <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 Width="600" HorizontalAlignment="Center" VerticalAlignment="Center" >
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition/> <ColumnDefinition/>
@@ -56,23 +56,29 @@
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/窗体样式/From/内部背景.png"/> <ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/窗体样式/From/内部背景.png"/>
</Grid.Background> </Grid.Background>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="80"/>
<RowDefinition Height="80"/> <RowDefinition Height="80"/>
<RowDefinition Height="50"/> <RowDefinition Height="50"/>
<RowDefinition Height="*"/> <RowDefinition Height="*"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<StackPanel Margin="10,20,10,0" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center"> <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"/> <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 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 AddFryTime}" Width="80" Height="40" Margin="10,0"/>
<Button Content="保存" Command="{Binding Save}" 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"/> <Button Content="退出" Click="Button_Click" Width="80" Height="40" Margin="10,0"/>
</StackPanel> </StackPanel>
<Grid Grid.Row="1" Width="600" HorizontalAlignment="Center" VerticalAlignment="Center">
<Grid Grid.Row="2" Width="600" HorizontalAlignment="Center" VerticalAlignment="Center">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition/> <ColumnDefinition/>
<ColumnDefinition/> <ColumnDefinition/>
@@ -88,7 +94,7 @@
<TextBlock Grid.Column="4" Text="调料重量" HorizontalAlignment="Center"/> <TextBlock Grid.Column="4" Text="调料重量" HorizontalAlignment="Center"/>
<TextBlock Grid.Column="5" Text="删除" HorizontalAlignment="Center"/> <TextBlock Grid.Column="5" Text="删除" HorizontalAlignment="Center"/>
</Grid> </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" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ItemsSource="{Binding PotActionStep}" Margin=" 10" Background="Transparent"
> >


+ 1
- 1
BPASmartClient.MorkF/View/LocalMenu.xaml.cs Näytä tiedosto

@@ -233,7 +233,7 @@ namespace BPASmartClient.MorkF.View


private void Materials_SelectionChanged(object sender, SelectionChangedEventArgs e) private void Materials_SelectionChanged(object sender, SelectionChangedEventArgs e)
{ {
string str = Materials.SelectedValue.ToString();
string str = Materials.SelectedValue?.ToString();
if(str != string.Empty) if(str != string.Empty)
{ {
ActionManage.GetInstance.Send("LoacMenuSelectMaterial", str); ActionManage.GetInstance.Send("LoacMenuSelectMaterial", str);


+ 1
- 2
BPASmartClient.MorkF/ViewModel/DebugViewModel.cs Näytä tiedosto

@@ -33,7 +33,7 @@ namespace BPASmartClient.MorkF.ViewModel
public RelayCommand FoodPlcInite { get; set; } public RelayCommand FoodPlcInite { get; set; }
public RelayCommand Plc1Reset { get; set; } public RelayCommand Plc1Reset { get; set; }
public RelayCommand StartOrder { get; set; } public RelayCommand StartOrder { get; set; }
public RelayCommand StartLocalOrder { get; set; }
public RelayCommand StopLocalOrder { get; set; } public RelayCommand StopLocalOrder { get; set; }
public RelayCommand ModeChange { get; set; } public RelayCommand ModeChange { get; set; }


@@ -205,7 +205,6 @@ namespace BPASmartClient.MorkF.ViewModel
PlcInite = new RelayCommand(() => { ActionManage.GetInstance.Send("InitCommand"); }); PlcInite = new RelayCommand(() => { ActionManage.GetInstance.Send("InitCommand"); });
Plc1Reset = new RelayCommand(() => { ActionManage.GetInstance.Send("Plc1Reset"); }); Plc1Reset = new RelayCommand(() => { ActionManage.GetInstance.Send("Plc1Reset"); });
StartOrder = new RelayCommand(() => { ActionManage.GetInstance.Send("StartOrder", FoodMenuID); }); StartOrder = new RelayCommand(() => { ActionManage.GetInstance.Send("StartOrder", FoodMenuID); });
StartLocalOrder = new RelayCommand(() => { ActionManage.GetInstance.Send("StartLocalOrder"); });
StopLocalOrder = new RelayCommand(() => { ActionManage.GetInstance.Send("StopLocalOrder"); }); StopLocalOrder = new RelayCommand(() => { ActionManage.GetInstance.Send("StopLocalOrder"); });
ModeChange = new RelayCommand(() => { ModeChange = new RelayCommand(() => {
ActionManage.GetInstance.Send("ModeChange"); ActionManage.GetInstance.Send("ModeChange");


+ 45
- 32
BPASmartClient.MorkF/ViewModel/LocalMenuViewModel.cs Näytä tiedosto

@@ -1,6 +1,9 @@
using BPA.Models; using BPA.Models;
using BPASmartClient.Helper; using BPASmartClient.Helper;
using BPASmartClient.Model;
using BPASmartClient.Model.小炒机;
using BPASmartClient.MorkF.Model; using BPASmartClient.MorkF.Model;
using BPASmartClient.ViewModel;
using Microsoft.Toolkit.Mvvm.ComponentModel; using Microsoft.Toolkit.Mvvm.ComponentModel;
using Microsoft.Toolkit.Mvvm.Input; using Microsoft.Toolkit.Mvvm.Input;
using System; using System;
@@ -17,20 +20,33 @@ namespace BPASmartClient.MorkF.ViewModel
partial class LocalMenuViewModel:ObservableObject partial class LocalMenuViewModel:ObservableObject
{ {
/// <summary>
/// 单个菜品流程
/// </summary>
public ObservableCollection<PotActions> PotActionStep { get { return _PotActionStep; } public ObservableCollection<PotActions> PotActionStep { get { return _PotActionStep; }
set { _PotActionStep = value; OnPropertyChanged(); } } set { _PotActionStep = value; OnPropertyChanged(); } }
private ObservableCollection<PotActions> _PotActionStep = new ObservableCollection<PotActions>(); private ObservableCollection<PotActions> _PotActionStep = new ObservableCollection<PotActions>();


public string MaterialName { get; set; } 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>(); public ObservableCollection<string> MaterialNames { get; set; } = new ObservableCollection<string>();



/// <summary>
/// 动作名称combox集合
/// </summary>
public ObservableCollection<string> strPotActions { get; set; } = new ObservableCollection<string>(); 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<object> Delete { get; set; }
public RelayCommand AddFryTime { get; set; } public RelayCommand AddFryTime { get; set; }
@@ -106,34 +122,33 @@ namespace BPASmartClient.MorkF.ViewModel
else else
{ {
MaterialNames.Add(MaterialName); MaterialNames.Add(MaterialName);
SelectMaterialName = MaterialName;
} }
}); });
DeleteMaterial = new RelayCommand(() => 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(() => Save = new RelayCommand(new Action(() =>
{ {
if(PotActionStep.Count > 0) if(PotActionStep.Count > 0)
@@ -155,8 +170,9 @@ namespace BPASmartClient.MorkF.ViewModel
//Json<LocalPotStep>.Data.LocalstirFryGoods.GoodsKey = 11; //Json<LocalPotStep>.Data.LocalstirFryGoods.GoodsKey = 11;
//Json<LocalPotStep>.Data.LocalstirFryGoods.StirPotActions = new List<PotActions>(PotActionStep); //Json<LocalPotStep>.Data.LocalstirFryGoods.StirPotActions = new List<PotActions>(PotActionStep);
//Json<LocalPotStep>.Save(); //Json<LocalPotStep>.Save();
Json<MaterialAndFryingTime>.Data.materials = materialAndFryingTime.materials;
//Json<MaterialAndFryingTime>.Data.materials = materialAndFryingTime.materials;
Json<MaterialAndFryingTime>.Save(); Json<MaterialAndFryingTime>.Save();
//ActionManage.GetInstance.Send("LocalMenuClose"); //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>>();
}
} }

+ 9
- 2
BPASmartClient.ViewModel/FoodMenuViewModel.cs Näytä tiedosto

@@ -1,5 +1,6 @@
using BPASmartClient.Helper; using BPASmartClient.Helper;
using BPASmartClient.Model; using BPASmartClient.Model;
using BPASmartClient.Model.小炒机;
using Microsoft.Toolkit.Mvvm.ComponentModel; using Microsoft.Toolkit.Mvvm.ComponentModel;
using Microsoft.Toolkit.Mvvm.Input; using Microsoft.Toolkit.Mvvm.Input;
using System; using System;
@@ -13,17 +14,23 @@ namespace BPASmartClient.ViewModel
{ {
public class FoodMenuViewModel: ObservableObject 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 RelayCommand<object> StartOrder { get; set; }


public FoodMenuViewModel() public FoodMenuViewModel()
{ {
Json<MaterialAndFryingTime>.Data.materials?.Keys?.ToList().ForEach(key => FoodMenus.Add(new FoodMenuModel { GoodName = key }));

StartOrder = new RelayCommand<object>((o) => StartOrder = new RelayCommand<object>((o) =>
{ {
ActionManage.GetInstance.Send("开始下单", o); ActionManage.GetInstance.Send("开始下单", o);
}); });
} }

} }
} }

+ 5
- 5
BPASmartClient/Control/FoodMenuView.xaml Näytä tiedosto

@@ -6,10 +6,8 @@
xmlns:local="clr-namespace:Control" xmlns:local="clr-namespace:Control"
xmlns:vm="clr-namespace:BPASmartClient.ViewModel;assembly=BPASmartClient.ViewModel" xmlns:vm="clr-namespace:BPASmartClient.ViewModel;assembly=BPASmartClient.ViewModel"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.DataContext>
<vm:FoodMenuViewModel/>
</UserControl.DataContext>
d:DesignHeight="850" d:DesignWidth="800">
<UserControl.Resources> <UserControl.Resources>
<ResourceDictionary> <ResourceDictionary>
<ResourceDictionary.MergedDictionaries> <ResourceDictionary.MergedDictionaries>
@@ -23,6 +21,7 @@
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="50"/> <RowDefinition Height="50"/>
<RowDefinition Height="*"/> <RowDefinition Height="*"/>
<RowDefinition Height="0.6*"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid HorizontalAlignment="Center"> <Grid HorizontalAlignment="Center">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
@@ -47,11 +46,12 @@
<TextBlock Grid.Column="1" FontSize="18" Text="{Binding GoodName}" VerticalAlignment="Center" HorizontalAlignment="Center"/> <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" <Button Grid.Column="2" Width="120" Content="下单" HorizontalAlignment="Center" VerticalAlignment="Center" Height="30"
Command="{Binding DataContext.StartOrder, RelativeSource={RelativeSource AncestorType=UserControl,Mode=FindAncestor}}" Command="{Binding DataContext.StartOrder, RelativeSource={RelativeSource AncestorType=UserControl,Mode=FindAncestor}}"
CommandParameter="{Binding GoodKey}"/>
CommandParameter="{Binding .}"/>
</Grid> </Grid>
</DataTemplate> </DataTemplate>
</ListBox.ItemTemplate> </ListBox.ItemTemplate>
</ListBox> </ListBox>
</Grid> </Grid>


+ 3
- 1
BPASmartClient/Control/FoodMenuView.xaml.cs Näytä tiedosto

@@ -1,4 +1,5 @@
using System;
using BPASmartClient.ViewModel;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using System.Windows; using System.Windows;
@@ -21,6 +22,7 @@ namespace BPASmartClient.Control
public FoodMenuView() public FoodMenuView()
{ {
InitializeComponent(); InitializeComponent();
this.DataContext = new FoodMenuViewModel();
} }
} }
} }

Ladataan…
Peruuta
Tallenna