From d54eb8816ecb8e6ed46ede1c81f455bc3eaa8e9a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=A6=82=E6=84=8F=20=E5=BD=AD?= <2417589739@qq.com>
Date: Mon, 16 May 2022 09:47:49 +0800
Subject: [PATCH 01/13] =?UTF-8?q?=E5=8F=82=E6=95=B0=E9=85=8D=E7=BD=AE?=
=?UTF-8?q?=E4=BF=AE=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../RecDictionarys/GlobalStyle.xaml | 12 +-
BPASmartClient/App.config | 14 +-
BPASmartClient/App.xaml | 2 +
.../Control/ShopDeviceConfigView.xaml | 1399 ++++++++---------
BPASmartClient/DeviceInfo.xml | 2 +-
BPASmartClient/MainWindow.xaml | 2 +-
6 files changed, 686 insertions(+), 745 deletions(-)
diff --git a/BPASmartClient.CustomResource/RecDictionarys/GlobalStyle.xaml b/BPASmartClient.CustomResource/RecDictionarys/GlobalStyle.xaml
index 2426ffba..8b6a4b0d 100644
--- a/BPASmartClient.CustomResource/RecDictionarys/GlobalStyle.xaml
+++ b/BPASmartClient.CustomResource/RecDictionarys/GlobalStyle.xaml
@@ -4,5 +4,15 @@
xmlns:con="clr-namespace:BPASmartClient.CustomResource.Converters">
-
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/BPASmartClient/App.config b/BPASmartClient/App.config
index 2fb2713f..1caea14f 100644
--- a/BPASmartClient/App.config
+++ b/BPASmartClient/App.config
@@ -3,7 +3,7 @@
-
+
@@ -16,8 +16,10 @@
-
- -->
+ -->
+
+
+
@@ -37,10 +39,10 @@
-
-
+
+
-
+
diff --git a/BPASmartClient/App.xaml b/BPASmartClient/App.xaml
index 29cb2e65..a85b3559 100644
--- a/BPASmartClient/App.xaml
+++ b/BPASmartClient/App.xaml
@@ -13,6 +13,8 @@
+
+
diff --git a/BPASmartClient/Control/ShopDeviceConfigView.xaml b/BPASmartClient/Control/ShopDeviceConfigView.xaml
index 358590c6..a242d89d 100644
--- a/BPASmartClient/Control/ShopDeviceConfigView.xaml
+++ b/BPASmartClient/Control/ShopDeviceConfigView.xaml
@@ -7,8 +7,8 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:pry="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource"
xmlns:vm="clr-namespace:BPASmartClient.ViewModel;assembly=BPASmartClient.ViewModel"
- d:DesignHeight="450"
- d:DesignWidth="800"
+ d:DesignHeight="900"
+ d:DesignWidth="1200"
mc:Ignorable="d">
@@ -19,6 +19,7 @@
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -72,193 +323,204 @@
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+ FontSize="20"
+ Foreground="#ff23caca"
+ IsEditable="False"
+ ItemsSource="{Binding ClientDevices}"
+ SelectedIndex="0"
+ Style="{StaticResource ComboBoxStyle}"
+ Text="{Binding ClientDeviceType}" />
-
+
-
-
+
-
-
-
-
-
+
-
-
-
-
+
-
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+ Grid.Column="5"
+ Width="170"
+ HorizontalAlignment="Left"
+ Style="{StaticResource TextBoxStyle}"
+ Text="" />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Text="请选择设备模块:" />
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
+
-
+ Text="IP地址:" />
+ Width="170"
+ HorizontalAlignment="Left"
+ Style="{StaticResource TextBoxStyle}"
+ Text="{Binding Path=Device.IP}" />
-
+ Text="端口号:" />
+ Width="170"
+ HorizontalAlignment="Left"
+ Style="{StaticResource TextBoxStyle}"
+ Text="{Binding Path=Device.PortNum}" />
-
-
-
-
-
+ HorizontalAlignment="Right"
+ Style="{StaticResource TextBlockStyle}"
+ Text="站号:" />
+
+
-
+
- -->
-
-
+
-
-
-
-
+
+
+
+
- -->
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
- -->
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
- -->
-
-
+
+
+
+
+
+
+
-
diff --git a/BPASmartClient/DeviceInfo.xml b/BPASmartClient/DeviceInfo.xml
index 89e636c8..48d28f7c 100644
--- a/BPASmartClient/DeviceInfo.xml
+++ b/BPASmartClient/DeviceInfo.xml
@@ -38,7 +38,7 @@
-->
-
+
diff --git a/BPASmartClient/MainWindow.xaml b/BPASmartClient/MainWindow.xaml
index dc110869..f68747fa 100644
--- a/BPASmartClient/MainWindow.xaml
+++ b/BPASmartClient/MainWindow.xaml
@@ -13,7 +13,7 @@
Height="800"
AllowsTransparency="True"
Background="{x:Null}"
- Topmost="True"
+ Topmost="False"
WindowStartupLocation="CenterScreen"
WindowStyle="None"
mc:Ignorable="d">
From 73de27797a749ba5b3389a063368978a0b04fa23 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=A6=82=E6=84=8F=20=E5=BD=AD?= <2417589739@qq.com>
Date: Mon, 16 May 2022 13:50:34 +0800
Subject: [PATCH 02/13] =?UTF-8?q?=E5=8F=82=E6=95=B0=E9=85=8D=E7=BD=AE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Model/DeviceConfigModel.cs | 4 +
.../NewShopWindowModel.cs | 26 +-
.../ShopDeviceConfigViewModel.cs | 47 ++-
.../Control/ShopDeviceConfigView.xaml | 82 +++--
.../DialogWindow/NewShopWindow.xaml | 312 ++++++------------
.../DialogWindow/NewShopWindow.xaml.cs | 18 +-
BPASmartClient/MainWindow.xaml.cs | 2 +-
7 files changed, 238 insertions(+), 253 deletions(-)
diff --git a/BPASmartClient.ViewModel/Model/DeviceConfigModel.cs b/BPASmartClient.ViewModel/Model/DeviceConfigModel.cs
index 8301b3ca..49e9d013 100644
--- a/BPASmartClient.ViewModel/Model/DeviceConfigModel.cs
+++ b/BPASmartClient.ViewModel/Model/DeviceConfigModel.cs
@@ -73,6 +73,10 @@ namespace BPASmartClient.ViewModel.Model
private string _mCommunicationModule = string.Empty;
+ public string CommunicationName { get { return _mCommunicationName; } set { _mCommunicationName = value; OnPropertyChanged(); } }
+ private string _mCommunicationName = string.Empty;
+
+
}
diff --git a/BPASmartClient.ViewModel/NewShopWindowModel.cs b/BPASmartClient.ViewModel/NewShopWindowModel.cs
index 7c2e1cc7..cef93844 100644
--- a/BPASmartClient.ViewModel/NewShopWindowModel.cs
+++ b/BPASmartClient.ViewModel/NewShopWindowModel.cs
@@ -3,7 +3,10 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using BPASmartClient.Helper;
using Microsoft.Toolkit.Mvvm.ComponentModel;
+using Microsoft.Toolkit.Mvvm.Input;
+using Microsoft.Toolkit.Mvvm.Messaging;
namespace BPASmartClient.ViewModel
{
@@ -11,7 +14,28 @@ namespace BPASmartClient.ViewModel
{
public NewShopWindowModel()
{
-
+ CloseWindowCommand = new RelayCommand(() => { WeakReferenceMessenger.Default.Send("", "CloseWindow"); });
+ CancelCommand = new RelayCommand(() => { WeakReferenceMessenger.Default.Send("", "CloseWindow"); });
+ DefineCommand = new RelayCommand(() =>
+ {
+ ActionManage.GetInstance.Send("ShopPar", new string[] { ShopName, ShopId });
+ WeakReferenceMessenger.Default.Send("", "CloseWindow");
+ });
}
+
+ public RelayCommand CloseWindowCommand { get; set; }
+
+ public RelayCommand CancelCommand { get; set; }
+
+ public RelayCommand DefineCommand { get; set; }
+
+ public string ShopName { get { return _mShopName; } set { _mShopName = value; OnPropertyChanged(); } }
+ private string _mShopName;
+
+ public string ShopId { get { return _mShopId; } set { _mShopId = value; OnPropertyChanged(); } }
+ private string _mShopId;
+
+
+
}
}
diff --git a/BPASmartClient.ViewModel/ShopDeviceConfigViewModel.cs b/BPASmartClient.ViewModel/ShopDeviceConfigViewModel.cs
index 51572f95..e7e0de7c 100644
--- a/BPASmartClient.ViewModel/ShopDeviceConfigViewModel.cs
+++ b/BPASmartClient.ViewModel/ShopDeviceConfigViewModel.cs
@@ -3,7 +3,11 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using BPASmartClient.Helper;
using Microsoft.Toolkit.Mvvm.ComponentModel;
+using Microsoft.Toolkit.Mvvm.Input;
+using BPASmartClient.ViewModel.Model;
+using System.Collections.ObjectModel;
namespace BPASmartClient.ViewModel
{
@@ -11,9 +15,50 @@ namespace BPASmartClient.ViewModel
{
public ShopDeviceConfigViewModel()
{
- //NewCommand = new Action(() => {ActionManager });
+ ActionManage.GetInstance.Register(new Action
-->
-
+
diff --git a/HBLConsole.MORKIC/BPASmartClient.MORKIC.csproj b/HBLConsole.MORKIC/BPASmartClient.MORKIC.csproj
index e444219e..0dcf2236 100644
--- a/HBLConsole.MORKIC/BPASmartClient.MORKIC.csproj
+++ b/HBLConsole.MORKIC/BPASmartClient.MORKIC.csproj
@@ -5,7 +5,7 @@
-
+
From 338de893cdcd5f8a590f0803cd11ecc9cdaac598 Mon Sep 17 00:00:00 2001
From: fyf
Date: Wed, 18 May 2022 13:48:32 +0800
Subject: [PATCH 08/13] 6
---
BPASmartClient/Control/DataVView.xaml.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/BPASmartClient/Control/DataVView.xaml.cs b/BPASmartClient/Control/DataVView.xaml.cs
index 3ffd3018..d0067c42 100644
--- a/BPASmartClient/Control/DataVView.xaml.cs
+++ b/BPASmartClient/Control/DataVView.xaml.cs
@@ -44,7 +44,7 @@ namespace BPASmartClient.Control
dispatcherTimer.Stop();
}));
};
- dispatcherTimer.Interval = TimeSpan.FromSeconds(20);
+ dispatcherTimer.Interval = TimeSpan.FromSeconds(120);
}
From b27c0a2b45049024016bcafa5d3fc1a46dd2baf0 Mon Sep 17 00:00:00 2001
From: fyf
Date: Wed, 18 May 2022 16:07:19 +0800
Subject: [PATCH 09/13] 3232
---
.../Themes/MyStyle.xaml | 64 ++++++++++++++++++-
BPASmartClient/Control/DataVView.xaml | 12 ++--
BPASmartClient/MainWindow.xaml | 16 ++---
3 files changed, 74 insertions(+), 18 deletions(-)
diff --git a/BPASmartClient.CustomResource/Themes/MyStyle.xaml b/BPASmartClient.CustomResource/Themes/MyStyle.xaml
index 5a02829c..eee7a413 100644
--- a/BPASmartClient.CustomResource/Themes/MyStyle.xaml
+++ b/BPASmartClient.CustomResource/Themes/MyStyle.xaml
@@ -957,7 +957,67 @@
-
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/BPASmartClient.CustomResource/UserControls/UserKeyBoard.xaml.cs b/BPASmartClient.CustomResource/UserControls/UserKeyBoard.xaml.cs
new file mode 100644
index 00000000..7ad1d728
--- /dev/null
+++ b/BPASmartClient.CustomResource/UserControls/UserKeyBoard.xaml.cs
@@ -0,0 +1,74 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace BPASmartClient.CustomResource.UserControls
+{
+ ///
+ /// UserKeyBoard.xaml 的交互逻辑
+ ///
+ public partial class UserKeyBoard : UserControl
+ {
+ public Action MyKeyDown;
+
+ public UserKeyBoard()
+ {
+ InitializeComponent();
+ }
+
+ //通过判断按钮的content属性来做对应处理
+ private void ButtonGrid_Click(object sender, RoutedEventArgs e)
+ {
+ Button clickedButton = (Button)e.OriginalSource; //获取click事件触发源,即按了的按钮
+ switch((String)clickedButton.Content)
+ {
+ case "DEL":
+ MyKeyDown(EKeyitem.DEL);
+ break;
+ case "AC":
+ MyKeyDown(EKeyitem.AC);
+ break;
+ case "确认":
+ MyKeyDown(EKeyitem.OK);
+ break;
+ case "A/a":
+ UIElementCollection grd = ButtonGrid.Children;
+ int count = grd.Count;
+ for (int i = 0; i < count; i++)
+ {
+ Button buttonTemp = grd[i] as Button;
+ String contentTemp = buttonTemp.Content as String;
+ if (contentTemp == "AC" || contentTemp == "A/a" || contentTemp == "确认" || contentTemp == "DEL")
+ continue;
+ buttonTemp.Content = contentTemp[0] > 90 ? contentTemp.ToUpper() : contentTemp.ToLower();
+ }
+ break;
+ default:
+ MyKeyDown((String)clickedButton.Content);
+ break;
+ }
+ }
+
+
+ public enum EKeyitem
+ {
+ DEL,
+ AC,
+ Shift,
+ OK,
+ A
+
+ }
+ }
+}
diff --git a/BPASmartClient.Lebai/LebaiRobot.cs b/BPASmartClient.Lebai/LebaiRobot.cs
index 58953747..d65041b9 100644
--- a/BPASmartClient.Lebai/LebaiRobot.cs
+++ b/BPASmartClient.Lebai/LebaiRobot.cs
@@ -69,7 +69,7 @@ namespace BPASmartClient.Lebai
public const int SENCE_放冰淇淋位置 = 10043;
//add 新加场景
- public const int SENCE_接咖啡_新 = 10051;
+ public const int SENCE_接咖啡后回原点 = 10051;
public const int SENCE_咖啡杯回原点 = 10050;
public const int SENCE_冰淇淋杯回原点 = 10049;
public const int SENCE_取咖啡出餐 = 10052;
diff --git a/BPASmartClient.MorkT/BPASmartClient.MorkT.csproj b/BPASmartClient.MorkT/BPASmartClient.MorkT.csproj
index 288c5e34..2f9dc957 100644
--- a/BPASmartClient.MorkT/BPASmartClient.MorkT.csproj
+++ b/BPASmartClient.MorkT/BPASmartClient.MorkT.csproj
@@ -6,6 +6,7 @@
+
diff --git a/BPASmartClient.MorkT/Control_MorkT.cs b/BPASmartClient.MorkT/Control_MorkT.cs
index cfacd727..7118f214 100644
--- a/BPASmartClient.MorkT/Control_MorkT.cs
+++ b/BPASmartClient.MorkT/Control_MorkT.cs
@@ -1,13 +1,19 @@
-using BPASmartClient.Device;
+using BPA.Message.Enum;
+using BPASmartClient.Device;
using BPASmartClient.EventBus;
+using BPASmartClient.GSIceCream;
using BPASmartClient.Lebai;
using BPASmartClient.Message;
using BPASmartClient.Model;
+using BPASmartClient.Model.冰淇淋.Enum;
+using BPASmartClient.Model.单片机;
+using BPASmartClient.Model.单片机.Enum;
using BPASmartClient.Peripheral;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
+using System.Threading;
using System.Threading.Tasks;
using static BPASmartClient.EventBus.EventBus;
@@ -20,7 +26,6 @@ namespace BPASmartClient.MorkT
GLV_MorkT morkT = new GLV_MorkT();
-
public override void DoMain()
{
ServerInit();
@@ -30,7 +35,7 @@ namespace BPASmartClient.MorkT
if (morkT.MakeCoffeeOrder != null)
morkT.MakeCoffeeOrder.OrderStatus = 1;
});
- MessageLog.GetInstance.Show("MORKF 设备初始化完成");
+ MessageLog.GetInstance.Show("MORKT 设备初始化完成");
}
public override void ResetProgram()
@@ -41,6 +46,12 @@ namespace BPASmartClient.MorkT
public override void MainTask()
{
+ MakeCoffeeProcess();
+ if(!LebaiRobot.GetInstance.GetInput())//取餐口有空余位置
+ {
+ MakeIceCreamProcess();
+ MakeCoffeeComplete();
+ }
}
public override void ReadData()
@@ -121,8 +132,10 @@ namespace BPASmartClient.MorkT
{
SuborderId = order.MorkOrder.SuborderId,
BatchingId = res.BatchingId,
- Loc = loc_Goods
- });
+ Loc = loc_Goods,
+ GoodsName = order.MorkOrder.GoodsName,
+ SortNum = order.MorkOrder.SortNum
+ }) ;
}
break;
case GOODS_TYPE.ICECREAM:
@@ -132,7 +145,9 @@ namespace BPASmartClient.MorkT
{
SuborderId = order.MorkOrder.SuborderId,
BatchingId = res.BatchingId,
- Loc = loc_Goods
+ Loc = loc_Goods,
+ GoodsName = order.MorkOrder.GoodsName,
+ SortNum = order.MorkOrder.SortNum
});
}
break;
@@ -157,8 +172,307 @@ namespace BPASmartClient.MorkT
return morkT.batchings[batchingLoc].GoodsType;
return GOODS_TYPE.NEITHER;
}
-
+ private void OrderChange(string subid, ORDER_STATUS oRDER_STATUS)
+ {
+ EventBus.EventBus.GetInstance().Publish(new OrderStatusChangedEvent() { Status = oRDER_STATUS, SubOrderId = subid, deviceClientType = DeviceType });
+ }
+
+ private void Wait(int value = 101)
+ {
+ while (!(morkT.lebai.Ok && morkT.lebai.Value == value))
+ {
+ Thread.Sleep(5);
+ }
+ }
+
+ ///
+ /// 是否可以开始制作咖啡
+ ///
+ ///
+ private bool CoffeeCanMake()
+ {
+ bool canMake = (IsHealth && morkT.morkOrderPushesCoffee.Count > 0 && !morkT.IsCoffeeMake) ? true : false;
+ return canMake;
+
+ }
+
+ ///
+ /// 制作咖啡流程
+ ///
+ private void MakeCoffeeProcess()
+ {
+ if(CoffeeCanMake())
+ {
+ if(morkT.morkOrderPushesCoffee.TryDequeue(out OrderLocInfo orderLoc))
+ {
+ DeviceProcessLogShow($"开始制作 [咖啡] 订单[{orderLoc.SortNum}]");
+ GetAndCheeckCoffe(orderLoc);
+ LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_接咖啡后回原点);//把咖啡杯放到咖啡机机的位置后回原点
+ Wait();
+ LebaiRobot.GetInstance.SetValue(1);
+ new DRCoffee_MakeCoffeeEvent() { DrinkCode = (Model.咖啡机.Enum.DrCoffeeDrinksCode)int.Parse(orderLoc.Loc) }.Publish(); //接咖啡控制
+ DeviceProcessLogShow($"发送咖啡机制作{orderLoc.Loc}!");
+ morkT.IsCoffeeMake = true; morkT.MakeCoffeeOrder = orderLoc;
+ }
+
+ }
+
+
+ }
+ ///
+ /// 咖啡机制作完咖啡,取走并放到取餐口,最后回原点
+ ///
+ private void MakeCoffeeComplete()
+ {
+ if (morkT.IsCoffeeMake&&IsHealth)
+ {
+ if (morkT.MakeCoffeeOrder != null && morkT.MakeCoffeeOrder.OrderStatus == 1)
+ {
+ DeviceProcessLogShow($"将咖啡移动到取餐位 [咖啡] 订单[{morkT.MakeCoffeeOrder.SortNum}]");
+ DoCoffeeQC(morkT.MakeCoffeeOrder);
+ morkT.MakeCoffeeOrder = null;
+ morkT.IsCoffeeMake = false;
+ }
+ }
+ }
+
+
+ ///
+ /// 将咖啡杯从咖啡机 取走到 取餐口
+ ///
+ private void DoCoffeeQC(OrderLocInfo order)
+ {
+ LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_取咖啡出餐);
+ Wait();
+ LebaiRobot.GetInstance.SetValue(1);
+ //订单状态改变:完成
+ OrderChange(order.SuborderId, ORDER_STATUS.COMPLETED_COOK);
+ DeviceProcessLogShow($"{order.GoodsName}等待取餐");
+ //WaitTakeMealOrder.Enqueue(order);
+
+ }
+
+ ///
+ /// 取咖啡杯&&咖啡杯检测 若检测失败机器人回原点
+ ///
+ ///
+ private void GetAndCheeckCoffe(OrderLocInfo order)
+ {
+ LebaiRobot.GetInstance.SetValue(0);
+ OrderChange(order.SuborderId, ORDER_STATUS.COOKING);
+ LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_取咖啡杯);
+ Wait();
+ new SCChip_TakeCupEvent() { Cup = IC_CUP.CUP_COFFEE }.Publish();//落碗控制
+ Thread.Sleep(500);
+ DeviceProcessLogShow("尝试取咖啡杯!");
+ LebaiRobot.GetInstance.SetValue(1);
+ int count = 2;
+ p:
+ LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_咖啡杯检测);
+ Wait();
+ LebaiRobot.GetInstance.SetValue(1);
+
+ if (!LebaiRobot.GetInstance.GetInput())
+ {
+ if (count >= 3)
+ {
+ //退出循环回到初始位置
+ DeviceProcessLogShow($"执行{count}次取咖啡杯,仍为成功,订单默认废弃,机器人回到初始位置!");
+ LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_咖啡杯回原点);
+ Wait();
+ LebaiRobot.GetInstance.SetValue(1);
+ return;
+ }
+ DeviceProcessLogShow("执行二次取咖啡杯");
+ LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_二次取咖啡杯);
+ Wait();
+ new SCChip_TakeCupEvent() { Cup = IC_CUP.CUP_COFFEE }.Publish();//落碗控制
+ LebaiRobot.GetInstance.SetValue(1);
+ count++;
+ goto p;
+ }
+ DeviceProcessLogShow("取咖啡杯完成");
+ }
+
+ ///
+ /// 冰淇淋是否可以开始制作
+ ///
+ ///
+ private bool IceCreamCanMake()
+ {
+ bool canMake = (IsHealth && morkT.morkOrderPushesIceCream.Count > 0) ? true : false;
+ return canMake;
+ }
+ ///
+ /// 制作冰淇淋流程
+ ///
+ private void MakeIceCreamProcess()
+ {
+ if(IceCreamCanMake())
+ {
+ if (MorkIStatus.GetInstance().CurrentMode != MORKI_MODE.制冷模式) new GSIceCream_ModeSetEvent() { Mode = MORKI_MODE.制冷模式 }.Publish();
+ if (MorkIStatus.GetInstance().CXB >= 86 && morkT.morkOrderPushesIceCream.Count > 0)//成型比大于86才可以制作
+ {
+ if (LebaiRobot.GetInstance.GetInput(3))
+ {
+ if (morkT.IceIsOK) DeviceProcessLogShow("请检查冰淇淋出料口有无遮挡");
+ morkT.IceIsOK = false;
+
+ }
+ else if (morkT.morkOrderPushesIceCream.TryDequeue(out OrderLocInfo order))
+ {
+ morkT.IceIsOK = true;
+ DeviceProcessLogShow($"开始制作 [冰淇淋] 订单[{order.SortNum}]");
+ DoIceCream(order);
+ }
+ }
+ }
+ }
+
+
+ ///
+ /// 做冰淇淋
+ ///
+ private void DoIceCream(OrderLocInfo order)
+ {
+ GetIceCreamCup();
+ CheckICeCreaCup();
+ GetIceCream(order);
+ PutIceCream(order);
+ }
+
+ ///
+ /// 取冰淇淋杯
+ ///
+ private void GetIceCreamCup()
+ {
+ LebaiRobot.GetInstance.SetValue(0);
+ LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_取冰淇淋杯);
+ Wait();
+ new SCChip_TakeCupEvent() { Cup = IC_CUP.CUP_ICECREAM }.Publish();//落碗控制
+ Thread.Sleep(500);
+ DeviceProcessLogShow("尝试取冰淇淋杯!");
+
+ }
+
+ ///
+ /// 冰淇淋杯检测,失败后机器人回到原点
+ ///
+ private void CheckICeCreaCup()
+ {
+ int count = 2;
+ LebaiRobot.GetInstance.SetValue(1);
+ p:
+ LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_冰淇淋杯检测);
+ Wait();
+ LebaiRobot.GetInstance.SetValue(1);
+ if (!LebaiRobot.GetInstance.GetInput())
+ {
+ if (count >= 3)
+ {
+ //退出循环回到初始位置
+ DeviceProcessLogShow($"执行{count}次取冰淇淋杯,仍未成功,订单默认废弃,机器人回到初始位置!");
+ LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_冰淇淋杯回原点);
+ Wait();
+ LebaiRobot.GetInstance.SetValue(1);
+ return;
+ }
+ DeviceProcessLogShow($"执行{count}次取冰淇淋杯!");
+ LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_二次取冰淇淋杯);
+ new SCChip_TakeCupEvent() { Cup = IC_CUP.CUP_ICECREAM }.Publish();//落碗控制
+ Wait();
+ LebaiRobot.GetInstance.SetValue(1);
+ count++;
+ goto p;
+ }
+ DeviceProcessLogShow("冰淇淋杯检测完成");
+ }
+
+ ///
+ /// 机器人取接冰淇淋
+ ///
+ ///
+ private void GetIceCream(OrderLocInfo order)
+ {
+ //制冷模式
+ new GSIceCream_ModeSetEvent() { Mode = MORKI_MODE.制冷模式 }.Publish();
+ LebaiRobot.GetInstance.SetValue(0);
+ OrderChange(order.SuborderId, ORDER_STATUS.COOKING);
+ LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_接1号冰淇淋);
+ Wait();
+ bool doItResult = true;
+ //出料
+ new GSIceCream_DischargeEvent().Publish(delegate (object[] args)
+ {
+ doItResult = (bool)args[0];
+ });
+ if (doItResult)
+ {
+ IceCreamCookCheck();
+ }
+ else
+ {
+ int count_1 = 0;
+ while (MorkIStatus.GetInstance().CXB <= 86)
+ {
+ Thread.Sleep(5);
+ count_1++;
+ if (count_1 >= 2000)
+ break;
+ }
+ IceCreamCookCheck();
+ }
+ LebaiRobot.GetInstance.SetValue(1);
+ }
+
+ ///
+ /// 把冰淇淋放到取餐位后回原点
+ ///
+ ///
+ private void PutIceCream(OrderLocInfo order)
+ {
+ while (LebaiRobot.GetInstance.GetInput())
+ {
+ Thread.Sleep(500);
+ }
+ LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_放冰淇淋位置);
+ Wait();
+ LebaiRobot.GetInstance.SetValue(1);
+ //订单状态改变:完成
+ OrderChange(order.SuborderId, ORDER_STATUS.COMPLETED_COOK);
+ DeviceProcessLogShow($"{order.GoodsName}等待取餐");
+ //WaitTakeMealOrder.Enqueue(order);
+
+ }
+
+ ///
+ /// 冰淇淋机器制作冰淇淋
+ ///
+ public void IceCreamCookCheck()
+ {
+ int retry = 3;
+ DateTime beginTime = DateTime.Now;
+ while (!LebaiRobot.GetInstance.GetInput(3))
+ {
+ if (retry <= 0 && DateTime.Now.Subtract(beginTime).TotalSeconds >= 10)
+ {
+ DeviceProcessLogShow("超时未出料,重试次数用尽");
+ break;
+ }
+ if (DateTime.Now.Subtract(beginTime).TotalSeconds > 5)
+ {
+ DeviceProcessLogShow("超时未出料,重新发送打料指令");
+ new GSIceCream_ModeSetEvent() { Mode = MORKI_MODE.打料 }.Publish();
+ beginTime = DateTime.Now;
+ retry--;
+ }
+ Thread.Sleep(10);
+ }
+ DeviceProcessLogShow("开始等待6s");
+ Thread.Sleep(5000);
+
+ }
}
}
diff --git a/BPASmartClient.MorkT/GLV_MorkT.cs b/BPASmartClient.MorkT/GLV_MorkT.cs
index 8a09f07a..a87dd384 100644
--- a/BPASmartClient.MorkT/GLV_MorkT.cs
+++ b/BPASmartClient.MorkT/GLV_MorkT.cs
@@ -33,5 +33,14 @@ namespace BPASmartClient.MorkT
/// 获取乐百机器人的数据
///
public SignalResult lebai = new SignalResult();
+
+ ///
+ /// 咖啡机位置是否有咖啡在制作中
+ ///
+ public bool IsCoffeeMake = false;
+ ///
+ /// 冰淇淋机器出料口传感器检测
+ ///
+ public bool IceIsOK = true;
}
}
diff --git a/BPASmartClient.MorkT/OrderLocInfo.cs b/BPASmartClient.MorkT/OrderLocInfo.cs
index 6199c5b3..adcbcf98 100644
--- a/BPASmartClient.MorkT/OrderLocInfo.cs
+++ b/BPASmartClient.MorkT/OrderLocInfo.cs
@@ -9,11 +9,14 @@ namespace BPASmartClient.MorkT
public class OrderLocInfo
{
public string SuborderId { get; set; }
+ public string GoodsName { get; set; }
public string Loc { get; set; }
- public ushort RecipeNumber { get; set; }
+ public int SortNum { get; set; }
public int BatchingId { get; set; }
public int OrderStatus { get; set; }
+
+
public OrderLocInfo()
{
OrderStatus = 0;
diff --git a/BPASmartClient.ViewModel/AdminstratorsViewModel.cs b/BPASmartClient.ViewModel/AdminstratorsViewModel.cs
new file mode 100644
index 00000000..5f974b7e
--- /dev/null
+++ b/BPASmartClient.ViewModel/AdminstratorsViewModel.cs
@@ -0,0 +1,35 @@
+using BPASmartClient.Helper;
+using Microsoft.Toolkit.Mvvm.ComponentModel;
+using Microsoft.Toolkit.Mvvm.Input;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BPASmartClient.ViewModel
+{
+ public class AdminstratorsViewModel:ObservableObject
+ {
+ public string Admin { get { return _admin; } set { _admin = value; OnPropertyChanged(); } }
+ private string _admin;
+
+ public string Password { get { return _password; } set { _password = value; OnPropertyChanged(); } }
+ private string _password;
+
+ public string ErrorMessage { get { return _errorMessage; } set { _errorMessage = value; OnPropertyChanged(); } }
+ private string _errorMessage;
+
+ public RelayCommand AdminLoginCommand { get; set; }
+
+ public AdminstratorsViewModel()
+ {
+ AdminLoginCommand = new RelayCommand(() =>
+ {
+
+ ActionManage.GetInstance.Send("Lonin");
+ });
+ }
+
+ }
+}
diff --git a/BPASmartClient.ViewModel/MainViewModel.cs b/BPASmartClient.ViewModel/MainViewModel.cs
index 60990cc7..a22a6a19 100644
--- a/BPASmartClient.ViewModel/MainViewModel.cs
+++ b/BPASmartClient.ViewModel/MainViewModel.cs
@@ -38,6 +38,12 @@ namespace BPASmartClient.ViewModel
OnPropertyChanged("NetworkConnectState");
}
}
+ //状态隐藏
+ public Visibility VsMenuItem { get { return _vsMenuItem; } set { _vsMenuItem = value; OnPropertyChanged(); } }
+ private Visibility _vsMenuItem;
+
+ public RelayCommand LogoutCommand { get; set; }
+
///
/// 是否告警
///
@@ -74,6 +80,16 @@ namespace BPASmartClient.ViewModel
};
dispatcherTimer.Interval = TimeSpan.FromSeconds(1);
dispatcherTimer.Start();
+ ActionManage.GetInstance.Register(new Action(() =>
+ {
+ VsMenuItem = Visibility.Hidden;
+ }),"Lonin");
+ LogoutCommand = new RelayCommand(() =>
+ {
+ VsMenuItem = Visibility.Visible;
+ });
+
+
}
}
diff --git a/BPASmartClient/App.config b/BPASmartClient/App.config
index 2fb2713f..d891b170 100644
--- a/BPASmartClient/App.config
+++ b/BPASmartClient/App.config
@@ -3,7 +3,7 @@
-
+
diff --git a/BPASmartClient/Control/AdminstratorsView.xaml b/BPASmartClient/Control/AdminstratorsView.xaml
new file mode 100644
index 00000000..81251a0d
--- /dev/null
+++ b/BPASmartClient/Control/AdminstratorsView.xaml
@@ -0,0 +1,84 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/BPASmartClient/Control/AdminstratorsView.xaml.cs b/BPASmartClient/Control/AdminstratorsView.xaml.cs
new file mode 100644
index 00000000..1d562284
--- /dev/null
+++ b/BPASmartClient/Control/AdminstratorsView.xaml.cs
@@ -0,0 +1,91 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+using static BPASmartClient.CustomResource.UserControls.UserKeyBoard;
+
+namespace BPASmartClient.Control
+{
+ ///
+ /// AdministratorsView.xaml 的交互逻辑
+ ///
+ public partial class AdminstratorsView : UserControl
+ {
+ public AdminstratorsView()
+ {
+ InitializeComponent();
+
+ }
+ private void UserControl_Loaded(object sender, RoutedEventArgs e)
+ {
+ this.tbx_admin.Focus();
+ }
+ private void MyKeyDown_Admin(object _key)
+ {
+ EKeyitem key = EKeyitem.A;
+ if (_key.GetType() == typeof(EKeyitem)) key = (EKeyitem)_key;
+ switch(key)
+ {
+ case EKeyitem.DEL:
+ if (tbx_admin.Text.Length > 0)
+ {
+ tbx_admin.Text = tbx_admin.Text.Substring(0, tbx_admin.Text.Length - 1);
+ }
+ break;
+ case EKeyitem.AC:
+ tbx_admin.Text = string.Empty;
+ break;
+ case EKeyitem.OK:
+ break;
+ default:
+ tbx_admin.Text += _key.ToString();
+ break;
+ }
+ this.tbx_admin.Focus();
+ }
+
+ private void MyKeyDown_Password(object _key)
+ {
+ EKeyitem key = EKeyitem.A;
+ if (_key.GetType() == typeof(EKeyitem)) key = (EKeyitem)_key;
+ switch (key)
+ {
+ case EKeyitem.DEL:
+ if (password.Password.Length > 0)
+ {
+ password.Password = password.Password.Substring(0, password.Password.Length - 1);
+ }
+ break;
+ case EKeyitem.AC:
+ password.Password = string.Empty;
+ break;
+ case EKeyitem.OK:
+ break;
+ default:
+ password.Password += _key.ToString();
+ break;
+ }
+
+ }
+
+ private void TextBox_GotFocus(object sender, RoutedEventArgs e)
+ {
+ myKeyboard.MyKeyDown = MyKeyDown_Admin;
+ }
+
+ private void Password_GotFocus(object sender, RoutedEventArgs e)
+ {
+ myKeyboard.MyKeyDown = MyKeyDown_Password;
+ }
+ }
+}
diff --git a/BPASmartClient/Control/Helper/PasswordBoxHelper.cs b/BPASmartClient/Control/Helper/PasswordBoxHelper.cs
new file mode 100644
index 00000000..a31b1e99
--- /dev/null
+++ b/BPASmartClient/Control/Helper/PasswordBoxHelper.cs
@@ -0,0 +1,40 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+
+namespace BPASmartClient.Control.Helper
+{
+ ///
+ /// 为PasswordBox控件的Password增加绑定功能
+ ///
+ public static class PasswordBoxHelper
+ {
+ public static string GetPasswordContent(DependencyObject obj) => (string)obj.GetValue(PasswordContentProperty);
+
+ public static void SetPasswordContent(DependencyObject obj, string value) => obj.SetValue(PasswordContentProperty, value);
+
+ public static readonly DependencyProperty PasswordContentProperty =
+ DependencyProperty.RegisterAttached("PasswordContent", typeof(string), typeof(PasswordBoxHelper),
+ new PropertyMetadata(string.Empty, OnPasswordContentPropertyChanged));
+
+ private static void OnPasswordContentPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ var box = d as PasswordBox;
+ box.PasswordChanged -= OnPasswordChanged;
+ var password = (string)e.NewValue;
+ if (box != null && box.Password != password)
+ box.Password = password;
+ box.PasswordChanged += OnPasswordChanged;
+ }
+
+ private static void OnPasswordChanged(object sender, RoutedEventArgs e)
+ {
+ var box = sender as PasswordBox;
+ SetPasswordContent(box, box.Password);
+ }
+ }
+}
diff --git a/BPASmartClient/MainWindow.xaml b/BPASmartClient/MainWindow.xaml
index 79af5cea..6b2fab87 100644
--- a/BPASmartClient/MainWindow.xaml
+++ b/BPASmartClient/MainWindow.xaml
@@ -50,7 +50,7 @@
Margin="20,0,0,0"
VerticalAlignment="Center"
Style="{DynamicResource imagetop_Title}" />
-
+
diff --git a/BPASmartClient/MainWindow.xaml.cs b/BPASmartClient/MainWindow.xaml.cs
index ac58be4b..ec7db6ad 100644
--- a/BPASmartClient/MainWindow.xaml.cs
+++ b/BPASmartClient/MainWindow.xaml.cs
@@ -1,5 +1,6 @@
using BPA.Message;
using BPASmartClient.Business;
+using BPASmartClient.Control;
using BPASmartClient.CustomResource.UserControls;
using BPASmartClient.CustomResource.UserControls.MessageShow;
using BPASmartClient.Device;
@@ -196,5 +197,28 @@ namespace BPASmartClient
{
ActionManage.GetInstance.Send("InitDevice");
}
+
+ private void Button_Login(object sender, RoutedEventArgs e)
+ {
+ try
+ {
+ Type type = Type.GetType($"BPASmartClient.Control.AdminstratorsView");
+ if (type == null) { MenuClick((sender as MenuItem).Tag?.ToString()); return; }
+ ConstructorInfo cti = type.GetConstructor(System.Type.EmptyTypes);
+ contentRegion.Content = (FrameworkElement)cti.Invoke(null);
+ Title.Text = "管理员登录界面";
+ }
+ catch (Exception ex)
+ {
+
+ MessageLog.GetInstance.ShowEx($"BPASmartClient 中引发错误,MainWindow.xaml.cs 类MenuItem_Click(),描述:[{ex.Message}]");
+ }
+
+ }
+
+ private void Button_LogOut(object sender, RoutedEventArgs e)
+ {
+
+ }
}
}
diff --git a/HBLConsole.MORKIC/Control_MORKIC.cs b/HBLConsole.MORKIC/Control_MORKIC.cs
index 090b8a61..99ebf33b 100644
--- a/HBLConsole.MORKIC/Control_MORKIC.cs
+++ b/HBLConsole.MORKIC/Control_MORKIC.cs
@@ -1,28 +1,25 @@
-using System;
-using System.Collections.Generic;
-using System.Configuration;
-using System.Linq;
-using System.Threading;
-using BPA.Message;
-using Robotc;
-using System.Collections.Concurrent;
-using System.Diagnostics;
+using BPA.Message;
+using BPA.Message.Enum;
using BPA.Message.IOT;
-using System.Threading.Tasks;
using BPASmartClient.Device;
-using BPA.Message.Enum;
using BPASmartClient.DRCoffee;
+using BPASmartClient.EventBus;
using BPASmartClient.GSIceCream;
using BPASmartClient.Helper;
using BPASmartClient.Lebai;
-using BPASmartClient.EventBus;
-using BPASmartClient.Model.咖啡机.Enum;
using BPASmartClient.Message;
+using BPASmartClient.Model;
using BPASmartClient.Model.冰淇淋.Enum;
+using BPASmartClient.Model.单片机;
using BPASmartClient.Model.单片机.Enum;
+using BPASmartClient.Model.咖啡机.Enum;
using BPASmartClient.SCChip;
-using BPASmartClient.Model;
-using BPASmartClient.Model.单片机;
+using Robotc;
+using System;
+using System.Collections.Concurrent;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading;
using static BPASmartClient.EventBus.EventBus;
namespace BPASmartClient.MORKIC
@@ -53,7 +50,7 @@ namespace BPASmartClient.MORKIC
///
/// 咖啡位置是否有东西
///
- private bool IsCoffeeMake=false;
+ private bool IsCoffeeMake = false;
private bool enableFunny = false;
private DateTime lastRecvdOrder = DateTime.Now;
@@ -79,41 +76,41 @@ namespace BPASmartClient.MORKIC
///
/// 等待取餐的订单,只有一个
///
- ConcurrentQueue WaitTakeMealOrder= new ConcurrentQueue();
+ ConcurrentQueue WaitTakeMealOrder = new ConcurrentQueue();
public void Init()
{
- ActionManage.GetInstance.Register(new Action((s) =>
- {
- if (s is DrCoffeeDrinksCode cf)
- {
- DoCoffee(new SimOrderData { Loc = ((int)cf).ToString() });
- }
- else if (s is Dictionary ms)
- {
- if (ms.ContainsKey("Button"))
- {
- switch (ms["Button"])
- {
- case "启动示教":
- LebaiRobot.GetInstance.StartTeachMode();
- break;
- case "停止示教":
- LebaiRobot.GetInstance.EndtTeachMode();
- break;
- case "启动机器人":
- LebaiRobot.GetInstance.StartRobot();
- break;
- case "急停":
- LebaiRobot.GetInstance.EStopRobot();
- break;
- default:
- break;
- }
- }
- }
- }),"SimCoffee");
+ ActionManage.GetInstance.Register(new Action((s) =>
+ {
+ if (s is DrCoffeeDrinksCode cf)
+ {
+ DoCoffee(new SimOrderData { Loc = ((int)cf).ToString() });
+ }
+ else if (s is Dictionary ms)
+ {
+ if (ms.ContainsKey("Button"))
+ {
+ switch (ms["Button"])
+ {
+ case "启动示教":
+ LebaiRobot.GetInstance.StartTeachMode();
+ break;
+ case "停止示教":
+ LebaiRobot.GetInstance.EndtTeachMode();
+ break;
+ case "启动机器人":
+ LebaiRobot.GetInstance.StartRobot();
+ break;
+ case "急停":
+ LebaiRobot.GetInstance.EStopRobot();
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ }), "SimCoffee");
//构建所有商品物料信息
batchings = PolymerBatching.BuildAll();
@@ -162,13 +159,13 @@ namespace BPASmartClient.MORKIC
{
ThreadManage.GetInstance().StartLong(new Action(() =>
{
- while (IsHealth &&(morkOrderPushesCoffee.Count > 0 || morkOrderPushesIceCream.Count>0 || IsCoffeeMake))
+ while (IsHealth && (morkOrderPushesCoffee.Count > 0 || morkOrderPushesIceCream.Count > 0 || IsCoffeeMake))
{
working = true; NoOrderTime = 0;
//1.有咖啡订单 取杯去制作
if (!IsCoffeeMake)//位置无杯子
{
- if (morkOrderPushesCoffee.Count>0 && morkOrderPushesCoffee.TryDequeue(out SimOrderData simOrder))
+ if (morkOrderPushesCoffee.Count > 0 && morkOrderPushesCoffee.TryDequeue(out SimOrderData simOrder))
{
IsCoffeeMake = true; MakeCoffeeOrder = simOrder;
MessageLog.GetInstance.Show($"开始制作 [咖啡] 订单[{simOrder.morkOrder.SortNum}]");
@@ -180,20 +177,20 @@ namespace BPASmartClient.MORKIC
{
//取餐位的订单完成
if (WaitTakeMealOrder.TryDequeue(out SimOrderData waitOrder)) OrderChange(waitOrder.morkOrder.SuborderId, BPA.Message.Enum.ORDER_STATUS.COMPLETED_TAKE);
-
+
//1.制作冰淇淋
- if (morkOrderPushesIceCream.Count>0 && MorkIStatus.GetInstance().CurrentMode!= MORKI_MODE.制冷模式) new GSIceCream_ModeSetEvent() { Mode = MORKI_MODE.制冷模式 }.Publish();
+ if (morkOrderPushesIceCream.Count > 0 && MorkIStatus.GetInstance().CurrentMode != MORKI_MODE.制冷模式) new GSIceCream_ModeSetEvent() { Mode = MORKI_MODE.制冷模式 }.Publish();
if (MorkIStatus.GetInstance().CXB >= 86 && morkOrderPushesIceCream.Count > 0)//成型比大于80 我才会制作
{
if (LebaiRobot.GetInstance.GetInput(3))
{
- if(IceIsOK) MessageLog.GetInstance.Show("请擦拭冰淇淋机出口");
+ if (IceIsOK) MessageLog.GetInstance.Show("请擦拭冰淇淋机出口");
IceIsOK = false;
}
- else if(morkOrderPushesIceCream.TryDequeue(out SimOrderData order))
+ else if (morkOrderPushesIceCream.TryDequeue(out SimOrderData order))
{
IceIsOK = true;
MessageLog.GetInstance.Show($"开始制作 [冰淇淋] 订单[{order.morkOrder.SortNum}]");
@@ -216,7 +213,7 @@ namespace BPASmartClient.MORKIC
working = false;
lastRecvdOrder = DateTime.Now;
}
-
+
if (IsHealth == false && (morkOrderPushesCoffee.Count > 0 || morkOrderPushesIceCream.Count > 0 || IsCoffeeMake))
{
MessageLog.GetInstance.Show($"机器连接问题 订单,不允许制作,请检查设备连接后尝试," +
@@ -237,8 +234,8 @@ namespace BPASmartClient.MORKIC
}
- Thread.Sleep(1000);
- }),"订单制作");
+ Thread.Sleep(1000);
+ }), "订单制作");
}
private void OrderChange(string subid, ORDER_STATUS oRDER_STATUS)
@@ -273,7 +270,7 @@ namespace BPASmartClient.MORKIC
}
//LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_欢迎);
}), "MORK-IC欢迎");
-
+
}
public void DataParse(T order)
@@ -313,10 +310,10 @@ namespace BPASmartClient.MORKIC
switch (currentGoodsType)
{
case GOODS_TYPE.COFFEE:
- morkOrderPushesCoffee.Enqueue(new SimOrderData { Loc = loc_coffe,morkOrder = morkOrderPush });
+ morkOrderPushesCoffee.Enqueue(new SimOrderData { Loc = loc_coffe, morkOrder = morkOrderPush });
break;
case GOODS_TYPE.ICECREAM:
- morkOrderPushesIceCream.Enqueue(new SimOrderData { Loc = loc_coffe,morkOrder = morkOrderPush });
+ morkOrderPushesIceCream.Enqueue(new SimOrderData { Loc = loc_coffe, morkOrder = morkOrderPush });
break;
case GOODS_TYPE.NEITHER:
MessageLog.GetInstance.Show("未知的商品类型");
@@ -356,7 +353,7 @@ namespace BPASmartClient.MORKIC
int checkeNum = 0;
// are.Reset();
LebaiRobot.GetInstance.SetValue(0);
- OrderChange(order.morkOrder.SuborderId, BPA.Message.Enum.ORDER_STATUS.COOKING);
+ OrderChange(order.morkOrder.SuborderId, ORDER_STATUS.COOKING);
//SimpleFactory.GetInstance.OrderChanged(order.morkOrder.SuborderId, BPA.Message.Enum.ORDER_STATUS.COOKING);
LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_取咖啡杯);
Wait();
@@ -370,19 +367,19 @@ namespace BPASmartClient.MORKIC
LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_咖啡杯检测);
Wait();
LebaiRobot.GetInstance.SetValue(1);
-
+
if (!LebaiRobot.GetInstance.GetInput())
{
if (count >= 3)
{
//退出循环回到初始位置
- MessageLog.GetInstance.Show($"执行{count}次取咖啡杯,仍为成功,订单默认废弃,机器人回到初始位置!");
+ DeviceProcessLogShow($"执行{count}次取咖啡杯,仍为成功,订单默认废弃,机器人回到初始位置!");
LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_咖啡杯回原点);
Wait();
LebaiRobot.GetInstance.SetValue(1);
return;
}
- MessageLog.GetInstance.Show("执行二次取咖啡杯");
+ DeviceProcessLogShow("执行二次取咖啡杯");
LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_二次取咖啡杯);
Wait();
new SCChip_TakeCupEvent() { Cup = IC_CUP.CUP_COFFEE }.Publish();//落碗控制
@@ -391,13 +388,13 @@ namespace BPASmartClient.MORKIC
goto p;
}
- MessageLog.GetInstance.Show("咖啡杯取杯完成");
- LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_接咖啡_新);
+ DeviceProcessLogShow("咖啡杯取杯完成");
+ LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_接咖啡后回原点);
Wait();
LebaiRobot.GetInstance.SetValue(1);
//加场景 回初始位置
new DRCoffee_MakeCoffeeEvent() { DrinkCode = (Model.咖啡机.Enum.DrCoffeeDrinksCode)int.Parse(order.Loc) }.Publish(); //接咖啡控制
- MessageLog.GetInstance.Show($"发送咖啡机制作{order.Loc}!");
+ DeviceProcessLogShow($"发送咖啡机制作{order.Loc}!");
#endregion
}
@@ -413,7 +410,7 @@ namespace BPASmartClient.MORKIC
//订单状态改变:完成
OrderChange(order.morkOrder.SuborderId, BPA.Message.Enum.ORDER_STATUS.COMPLETED_COOK);
//SimpleFactory.GetInstance.OrderChanged(order.morkOrder.SuborderId,BPA.Message.Enum.ORDER_STATUS.COMPLETED_COOK);
- MessageLog.GetInstance.Show($"{order.morkOrder.GoodsName}等待取餐");
+ DeviceProcessLogShow($"{order.morkOrder.GoodsName}等待取餐");
WaitTakeMealOrder.Enqueue(order);
}
@@ -427,7 +424,7 @@ namespace BPASmartClient.MORKIC
// MessageLog.GetInstance.Show("请擦拭冰淇淋机出口");
// return;
//}
-
+
#region 且时且多入场设备程序
int checkeNum = 0;
//are.Reset();
@@ -443,7 +440,7 @@ namespace BPASmartClient.MORKIC
p:
LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_冰淇淋杯检测);
Wait();
-
+
LebaiRobot.GetInstance.SetValue(1);
if (!LebaiRobot.GetInstance.GetInput())
{
@@ -499,13 +496,13 @@ namespace BPASmartClient.MORKIC
}
LebaiRobot.GetInstance.SetValue(1);
#endregion
-
+
while (LebaiRobot.GetInstance.GetInput())
{
Thread.Sleep(500);
}
LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_放冰淇淋位置);
-
+
Wait();
LebaiRobot.GetInstance.SetValue(1);
//订单状态改变:完成
@@ -514,7 +511,7 @@ namespace BPASmartClient.MORKIC
MessageLog.GetInstance.Show($"{order.morkOrder.GoodsName}等待取餐");
WaitTakeMealOrder.Enqueue(order);
#endregion
-
+
}
///
@@ -568,7 +565,7 @@ namespace BPASmartClient.MORKIC
public void SimOrder(T simOrder)
{
-
+
}
///
@@ -603,7 +600,7 @@ namespace BPASmartClient.MORKIC
public override void DoMain()
{
-
+
}
public override void Stop()
@@ -641,7 +638,7 @@ namespace BPASmartClient.MORKIC
public SimOrderData()
{
id = Guid.NewGuid().ToString();
- OrderStatus=0;
+ OrderStatus = 0;
}
}
}
From b6f9d66b5bc54bc29f07b6984dd0e9884aab93ca Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=A6=82=E6=84=8F=20=E5=BD=AD?= <2417589739@qq.com>
Date: Thu, 19 May 2022 11:07:53 +0800
Subject: [PATCH 12/13] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E4=BF=AE=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
BPASmartClient.Business/Plugin/OrderProxy.cs | 7 +-
.../Themes/GenricStyle.xaml | 54 +++--
.../BPASmartClient.Device.csproj | 2 +
BPASmartClient.Helper/ActionManage.cs | 8 +-
BPASmartClient.Helper/ExpandMethod.cs | 36 +--
BPASmartClient.Helper/LocaPath.cs | 13 +-
.../BPASmartClient.MQTT.csproj | 2 +-
.../BPASmartClient.MorkD.csproj | 2 +
.../BPASmartClient.MorkF.csproj | 2 +
.../BPASmartClient.MorkS.csproj | 2 +
.../{Control.cs => Control_Morks.cs} | 53 ++++-
.../BPASmartClient.MorkT.csproj | 1 +
.../BPASmartClient.ViewModel.csproj | 2 +
BPASmartClient.ViewModel/MainViewModel.cs | 10 +-
.../Model/DeviceConfigModel.cs | 75 +++---
.../NewShopWindowModel.cs | 21 +-
.../ShopDeviceConfigViewModel.cs | 183 +++++++--------
BPASmartClient/App.config | 24 +-
.../Control/ShopDeviceConfigView.xaml | 217 ++++++++++++------
.../Control/ShopDeviceConfigView.xaml.cs | 133 ++++++++---
BPASmartClient/DeviceInfo.xml | 2 +-
.../DialogWindow/NewShopWindow.xaml | 4 +-
.../DialogWindow/NewShopWindow.xaml.cs | 22 +-
BPASmartClient/MainWindow.xaml | 11 +-
BPASmartClient/MainWindow.xaml.cs | 6 +-
.../BPASmartClient.MORKIC.csproj | 2 +
26 files changed, 582 insertions(+), 312 deletions(-)
rename BPASmartClient.MorkS/{Control.cs => Control_Morks.cs} (92%)
diff --git a/BPASmartClient.Business/Plugin/OrderProxy.cs b/BPASmartClient.Business/Plugin/OrderProxy.cs
index 5f8969ef..720a2698 100644
--- a/BPASmartClient.Business/Plugin/OrderProxy.cs
+++ b/BPASmartClient.Business/Plugin/OrderProxy.cs
@@ -122,7 +122,12 @@ namespace BPASmartClient.Business
{
OrderStatusChangedEvent orderStatusChangedEvent = @event as OrderStatusChangedEvent;
string result = string.Empty;
- OrderStatusChange orderStatusChange = new OrderStatusChange() { CookingStatus = orderStatusChangedEvent.Status, SuborderId = orderStatusChangedEvent.SubOrderId };
+ OrderStatusChange orderStatusChange = new OrderStatusChange()
+ {
+ CookingStatus = orderStatusChangedEvent.Status,
+ SuborderId = orderStatusChangedEvent.SubOrderId,
+ GoodName = orderStatusChangedEvent.GoodName
+ };
#region API 订单状态修改
try
diff --git a/BPASmartClient.CustomResource/Themes/GenricStyle.xaml b/BPASmartClient.CustomResource/Themes/GenricStyle.xaml
index f82209c3..e15e3c81 100644
--- a/BPASmartClient.CustomResource/Themes/GenricStyle.xaml
+++ b/BPASmartClient.CustomResource/Themes/GenricStyle.xaml
@@ -123,37 +123,45 @@
-
-
-
+
+
+
@@ -584,7 +592,7 @@
-
+
diff --git a/BPASmartClient.Device/BPASmartClient.Device.csproj b/BPASmartClient.Device/BPASmartClient.Device.csproj
index 3164a1d8..3f4f0b9f 100644
--- a/BPASmartClient.Device/BPASmartClient.Device.csproj
+++ b/BPASmartClient.Device/BPASmartClient.Device.csproj
@@ -2,6 +2,8 @@
net6.0
+ bin\
+ portable
diff --git a/BPASmartClient.Helper/ActionManage.cs b/BPASmartClient.Helper/ActionManage.cs
index ba2f19c6..e9a8a7dd 100644
--- a/BPASmartClient.Helper/ActionManage.cs
+++ b/BPASmartClient.Helper/ActionManage.cs
@@ -72,13 +72,13 @@ namespace BPASmartClient.Helper
if (actions.ContainsKey(key))
if (par == null)
{
- if (actions[key].FuncObj != null)
- return actions[key].FuncObj;
+ //if (actions[key].FuncObj != null)
+ return actions[key].FuncObj?.Invoke();
}
else
{
- if (actions[key].FuncPar != null)
- return actions[key].FuncPar(par);
+ //if (actions[key].FuncPar != null)
+ return actions[key].FuncPar?.Invoke(par);
}
return default;
}
diff --git a/BPASmartClient.Helper/ExpandMethod.cs b/BPASmartClient.Helper/ExpandMethod.cs
index f0d1ccac..97336f6e 100644
--- a/BPASmartClient.Helper/ExpandMethod.cs
+++ b/BPASmartClient.Helper/ExpandMethod.cs
@@ -41,11 +41,13 @@ namespace BPASmartClient.Helper
/// 委托回调
public static void Invoke(this Action action, Action callback)
{
- if (action != null)
- {
- action();
- if (callback != null) callback();
- }
+ action?.Invoke();
+ callback?.Invoke();
+ //if (action != null)
+ //{
+ // action();
+ // if (callback != null) callback();
+ //}
}
///
@@ -56,20 +58,24 @@ namespace BPASmartClient.Helper
/// 委托回调
public static void Invoke(this Action action, object par, Action callback)
{
- if (action != null)
- {
- action(par);
- if (callback != null) callback();
- }
+ action?.Invoke(par);
+ callback?.Invoke();
+ //if (action != null)
+ //{
+ // action(par);
+ // if (callback != null) callback();
+ //}
}
public static void Invokes(this Action action, object[] par, Action callback)
{
- if (action != null)
- {
- action(par);
- if (callback != null) callback();
- }
+ action?.Invoke(par);
+ callback?.Invoke();
+ //if (action != null)
+ //{
+ // action(par);
+ // if (callback != null) callback();
+ //}
}
diff --git a/BPASmartClient.Helper/LocaPath.cs b/BPASmartClient.Helper/LocaPath.cs
index afc71e39..ccd14562 100644
--- a/BPASmartClient.Helper/LocaPath.cs
+++ b/BPASmartClient.Helper/LocaPath.cs
@@ -7,10 +7,8 @@ using System.Threading.Tasks;
namespace BPASmartClient.Helper
{
- public class LocaPath:Singleton
+ public class LocaPath : Singleton
{
-
-
public string FilePath { get; set; } = string.Empty;
public string Getpath(string name)
@@ -19,5 +17,14 @@ namespace BPASmartClient.Helper
return $"{AppDomain.CurrentDomain.BaseDirectory}{FilePath}JSON\\{name}.json";
}
+ public string GetDeviceConfigPath
+ {
+ get
+ {
+ Directory.CreateDirectory(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"AccessFile\\DeviceConfig"));
+ return $"{AppDomain.CurrentDomain.BaseDirectory}AccessFile\\DeviceConfig\\";
+ }
+ }
+
}
}
diff --git a/BPASmartClient.MQTT/BPASmartClient.MQTT.csproj b/BPASmartClient.MQTT/BPASmartClient.MQTT.csproj
index 69f50a3d..04bceac9 100644
--- a/BPASmartClient.MQTT/BPASmartClient.MQTT.csproj
+++ b/BPASmartClient.MQTT/BPASmartClient.MQTT.csproj
@@ -5,7 +5,7 @@
-
+
diff --git a/BPASmartClient.MorkD/BPASmartClient.MorkD.csproj b/BPASmartClient.MorkD/BPASmartClient.MorkD.csproj
index dbc15171..b4b46ffa 100644
--- a/BPASmartClient.MorkD/BPASmartClient.MorkD.csproj
+++ b/BPASmartClient.MorkD/BPASmartClient.MorkD.csproj
@@ -2,6 +2,8 @@
net6.0
+ bin\
+ portable
diff --git a/BPASmartClient.MorkF/BPASmartClient.MorkF.csproj b/BPASmartClient.MorkF/BPASmartClient.MorkF.csproj
index e39ff09d..09946d55 100644
--- a/BPASmartClient.MorkF/BPASmartClient.MorkF.csproj
+++ b/BPASmartClient.MorkF/BPASmartClient.MorkF.csproj
@@ -4,6 +4,8 @@
net6.0
enable
enable
+ bin\
+ portable
diff --git a/BPASmartClient.MorkS/BPASmartClient.MorkS.csproj b/BPASmartClient.MorkS/BPASmartClient.MorkS.csproj
index ce6a7f77..11f083b1 100644
--- a/BPASmartClient.MorkS/BPASmartClient.MorkS.csproj
+++ b/BPASmartClient.MorkS/BPASmartClient.MorkS.csproj
@@ -2,6 +2,8 @@
net6.0
+ bin\
+ portable
diff --git a/BPASmartClient.MorkS/Control.cs b/BPASmartClient.MorkS/Control_Morks.cs
similarity index 92%
rename from BPASmartClient.MorkS/Control.cs
rename to BPASmartClient.MorkS/Control_Morks.cs
index b788434d..ae2ac5b7 100644
--- a/BPASmartClient.MorkS/Control.cs
+++ b/BPASmartClient.MorkS/Control_Morks.cs
@@ -17,7 +17,7 @@ using System.Reflection;
namespace BPASmartClient.MorkS
{
- public class Control : BaseDevice
+ public class Control_Morks : BaseDevice
{
public override DeviceClientType DeviceType => DeviceClientType.MORKS;
GVL_MORKS mORKS = new GVL_MORKS();
@@ -223,16 +223,19 @@ namespace BPASmartClient.MorkS
mORKS.AllowRun = mORKS.InitComplete;
//IsHealth = mORKS.Error && mORKS.InitComplete;
IsHealth = true;
- TakeBowlTask();
- TakeNoodleTask();
+ if (mORKS.AllowRun)
+ {
+ TakeBowlTask();
- OutNoodleTask();
+ TakeNoodleTask();
- SingleDetect();
+ OutNoodleTask();
- TurntableControl();
+ SingleDetect();
+ TurntableControl();
+ }
}
@@ -245,11 +248,39 @@ namespace BPASmartClient.MorkS
{
if (mORKS.TakeBowlTask.TryDequeue(out OrderLocInfo orderLocInfo))
{
- mORKS.TakeBowlId = orderLocInfo.SuborderId;
- TakeBowlControl(orderLocInfo.Loc);
- SetRecipeNumber(orderLocInfo.RecipeNumber);
- OrderChange(mORKS.TakeBowlId, ORDER_STATUS.COOKING);
- DeviceProcessLogShow($"订单【{ mORKS.TakeBowlId}】执行取碗控制,位置:[{orderLocInfo.Loc}]");
+ ushort BowLoc = 0;
+ var res = orderMaterialDelivery?.BatchingInfo?.Where(p => p.BatchingId == orderLocInfo.BatchingId).ToList();
+ if (res != null)
+ {
+ foreach (var item in res)
+ {
+ if (ushort.TryParse(item.BatchingLoc, out ushort loc))
+ {
+ if (loc == 10 && alarm.Supply1_LossBowl)
+ {
+ BowLoc = loc;
+ break;
+ }
+ else if (loc == 11 && alarm.Supply2_LossBowl)
+ {
+ BowLoc = loc;
+ break;
+ }
+ }
+
+ }
+ }
+
+ if (BowLoc >= 10 && BowLoc <= 11)
+ {
+ mORKS.TakeBowlId = orderLocInfo.SuborderId;
+ //TakeBowlControl(orderLocInfo.Loc);
+ TakeBowlControl(BowLoc);
+ SetRecipeNumber(orderLocInfo.RecipeNumber);
+ OrderChange(mORKS.TakeBowlId, ORDER_STATUS.COOKING);
+ DeviceProcessLogShow($"订单【{ mORKS.TakeBowlId}】执行取碗控制,位置:[{orderLocInfo.Loc}]");
+ }
+
}
mORKS.TakeBowlInterlock = true;
}
diff --git a/BPASmartClient.MorkT/BPASmartClient.MorkT.csproj b/BPASmartClient.MorkT/BPASmartClient.MorkT.csproj
index 288c5e34..efbf696e 100644
--- a/BPASmartClient.MorkT/BPASmartClient.MorkT.csproj
+++ b/BPASmartClient.MorkT/BPASmartClient.MorkT.csproj
@@ -2,6 +2,7 @@
net6.0
+ D:\HBL\Porgram\BPASmartClient\BPASmartClient\bin\Debug\net6.0-windows\Devices
diff --git a/BPASmartClient.ViewModel/BPASmartClient.ViewModel.csproj b/BPASmartClient.ViewModel/BPASmartClient.ViewModel.csproj
index b99aa4f8..69df2f85 100644
--- a/BPASmartClient.ViewModel/BPASmartClient.ViewModel.csproj
+++ b/BPASmartClient.ViewModel/BPASmartClient.ViewModel.csproj
@@ -8,6 +8,8 @@
+
+
diff --git a/BPASmartClient.ViewModel/MainViewModel.cs b/BPASmartClient.ViewModel/MainViewModel.cs
index 60990cc7..bef488e8 100644
--- a/BPASmartClient.ViewModel/MainViewModel.cs
+++ b/BPASmartClient.ViewModel/MainViewModel.cs
@@ -52,7 +52,7 @@ namespace BPASmartClient.ViewModel
public MainViewModel()
{
- IsAlarm =new AlarmModel();
+ IsAlarm = new AlarmModel();
OrderStatusViewModel.Init();
//设备告警日志
MessageLog.GetInstance.AlarmLogNotify = new Action(() =>
@@ -75,6 +75,12 @@ namespace BPASmartClient.ViewModel
dispatcherTimer.Interval = TimeSpan.FromSeconds(1);
dispatcherTimer.Start();
}
+
+
+ public bool AutoStart { get { return SystemHelper.GetInstance.IsAutoStart(); } set { SystemHelper.GetInstance.AutoStart(value); OnPropertyChanged(); } }
+
+
+
}
public class AlarmModel : ObservableObject
@@ -118,7 +124,7 @@ namespace BPASmartClient.ViewModel
public AlarmModel()
{
-
+
}
}
}
diff --git a/BPASmartClient.ViewModel/Model/DeviceConfigModel.cs b/BPASmartClient.ViewModel/Model/DeviceConfigModel.cs
index f6f699f3..cf5977b8 100644
--- a/BPASmartClient.ViewModel/Model/DeviceConfigModel.cs
+++ b/BPASmartClient.ViewModel/Model/DeviceConfigModel.cs
@@ -6,6 +6,7 @@ using System.Threading.Tasks;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using System.Collections.ObjectModel;
using Microsoft.Toolkit.Mvvm.Input;
+using System.Windows;
namespace BPASmartClient.ViewModel.Model
{
@@ -96,12 +97,29 @@ namespace BPASmartClient.ViewModel.Model
///
public class CommunicationPar : ObservableObject
{
+ /////
+ ///// 通讯类型,false:串口,true:网口
+ /////
+ //public bool CommunicationType { get { return _mCommunicationType; } set { _mCommunicationType = value; OnPropertyChanged(); } }
+ //private bool _mCommunicationType;
+
+ ///
+ /// 选择网口通讯
+ ///
+ public bool IsNetworkPort { get { return _mIsNetworkPort; } set { _mIsNetworkPort = value; OnPropertyChanged(); } }
+ private bool _mIsNetworkPort = false;
+
///
- /// 通讯类型,false:串口,true:网口
+ /// 选择串口通讯
///
- public bool CommunicationType { get { return _mCommunicationType; } set { _mCommunicationType = value; OnPropertyChanged(); } }
- private bool _mCommunicationType;
+ public bool IsSerialPort { get { return _mIsSerialPort; } set { _mIsSerialPort = value; OnPropertyChanged(); } }
+ private bool _mIsSerialPort = true;
+ //public Visibility NetworkVisibility { get { return _mNetworkVisibility; } set { _mNetworkVisibility = value; OnPropertyChanged(); } }
+ //private Visibility _mNetworkVisibility = Visibility.Collapsed;
+
+ //public Visibility SerialVisibility { get { return _mSerialVisibility; } set { _mSerialVisibility = value; OnPropertyChanged(); } }
+ //private Visibility _mSerialVisibility = Visibility.Visible;
///
/// IP地址
@@ -138,13 +156,13 @@ namespace BPASmartClient.ViewModel.Model
/// 数据位
///
public int DataBits { get { return _mDataBits; } set { _mDataBits = value; OnPropertyChanged(); } }
- private int _mDataBits;
+ private int _mDataBits = 8;
///
/// 停止位
///
public string StopBits { get { return _mStopBits; } set { _mStopBits = value; OnPropertyChanged(); } }
- private string _mStopBits;
+ private string _mStopBits = "1";
///
/// 校验位
@@ -152,37 +170,22 @@ namespace BPASmartClient.ViewModel.Model
public string Parity { get { return _mParity; } set { _mParity = value; OnPropertyChanged(); } }
private string _mParity;
+ public ObservableCollection variables { get; set; } = new ObservableCollection();
}
- //public enum CommunicationParType
- //{
- // ///
- // /// IP地址
- // ///
- // IPAddress,
- // ///
- // /// 端口号
- // ///
- // Port,
- // ///
- // /// 串口端口号
- // ///
- // SerialPort,
- // ///
- // /// 波特率
- // ///
- // BaudRate,
- // ///
- // /// 数据位
- // ///
- // DataBits,
- // ///
- // /// 停止位
- // ///
- // StopBits,
- // ///
- // /// 校验位
- // ///
- // Parity,
- //}
+ public class Variable : ObservableObject
+ {
+ public int Id { get { return _mId; } set { _mId = value; OnPropertyChanged(); } }
+ private int _mId;
+
+
+ public string Address { get { return _mAddress; } set { _mAddress = value; OnPropertyChanged(); } }
+ private string _mAddress;
+
+
+ public int ReadLeng { get { return _mReadLeng; } set { _mReadLeng = value; OnPropertyChanged(); } }
+ private int _mReadLeng;
+
+
+ }
}
diff --git a/BPASmartClient.ViewModel/NewShopWindowModel.cs b/BPASmartClient.ViewModel/NewShopWindowModel.cs
index cef93844..49787d3b 100644
--- a/BPASmartClient.ViewModel/NewShopWindowModel.cs
+++ b/BPASmartClient.ViewModel/NewShopWindowModel.cs
@@ -7,23 +7,32 @@ using BPASmartClient.Helper;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using Microsoft.Toolkit.Mvvm.Input;
using Microsoft.Toolkit.Mvvm.Messaging;
+using System.Windows;
+using System.IO;
namespace BPASmartClient.ViewModel
{
public class NewShopWindowModel : ObservableObject
{
+
public NewShopWindowModel()
{
- CloseWindowCommand = new RelayCommand(() => { WeakReferenceMessenger.Default.Send("", "CloseWindow"); });
- CancelCommand = new RelayCommand(() => { WeakReferenceMessenger.Default.Send("", "CloseWindow"); });
+ CancelCommand = new RelayCommand(() => { ActionManage.GetInstance.Send("CloseWindow"); });
DefineCommand = new RelayCommand(() =>
{
+ DirectoryInfo directoryInfo = new DirectoryInfo(LocaPath.GetInstance().GetDeviceConfigPath);
+ var files = directoryInfo.GetFiles();
+ if (files != null && files.FirstOrDefault(p => p.FullName.Contains(ShopName)) != null)
+ {
+ ErrorInfo = "已存在该店铺,请重新输入!";
+ return;
+ }
ActionManage.GetInstance.Send("ShopPar", new string[] { ShopName, ShopId });
- WeakReferenceMessenger.Default.Send("", "CloseWindow");
+ ActionManage.GetInstance.Send("OkCloseWindow");
});
}
- public RelayCommand CloseWindowCommand { get; set; }
+ //public RelayCommand CloseWindowCommand { get; set; }
public RelayCommand CancelCommand { get; set; }
@@ -35,6 +44,10 @@ namespace BPASmartClient.ViewModel
public string ShopId { get { return _mShopId; } set { _mShopId = value; OnPropertyChanged(); } }
private string _mShopId;
+ public string ErrorInfo { get { return _mErrorInfo; } set { _mErrorInfo = value; OnPropertyChanged(); } }
+ private string _mErrorInfo;
+
+
}
diff --git a/BPASmartClient.ViewModel/ShopDeviceConfigViewModel.cs b/BPASmartClient.ViewModel/ShopDeviceConfigViewModel.cs
index a919b862..b5041e8b 100644
--- a/BPASmartClient.ViewModel/ShopDeviceConfigViewModel.cs
+++ b/BPASmartClient.ViewModel/ShopDeviceConfigViewModel.cs
@@ -11,12 +11,16 @@ using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Windows;
+using System.IO.Ports;
+using System.IO;
+using Newtonsoft.Json;
namespace BPASmartClient.ViewModel
{
public class ShopDeviceConfigViewModel : ObservableObject
{
private DeviceConfigModel configModel = new DeviceConfigModel();
+ string FileName => deviceConfig.Count > 0 ? deviceConfig[0].ShopName : string.Empty;
public ShopDeviceConfigViewModel()
{
@@ -28,6 +32,7 @@ namespace BPASmartClient.ViewModel
{
configModel.ShopName = par[0];
configModel.ShopId = par[1];
+ deviceConfig.Clear();
deviceConfig.Add(configModel);
}
}
@@ -37,8 +42,19 @@ namespace BPASmartClient.ViewModel
RemoveDeviceCommand = new RelayCommand(RemoveDevice);
NewCommunicationCommand = new RelayCommand(NewCommunication);
RemoveCommunicationCommand = new RelayCommand(RemoveCommunication);
+
+ DataListInit();
+
+ SaveData = new Action(() =>
+ {
+ if (deviceConfig.Count > 0)
+ {
+ File.WriteAllText($"{LocaPath.GetInstance().GetDeviceConfigPath}{FileName}.json", JsonConvert.SerializeObject(deviceConfig));
+ }
+ });
}
+ #region 右键菜单按钮操作
private void RemoveCommunication(object? obj)
{
if (obj != null && obj is CommunicationModel com)
@@ -78,7 +94,7 @@ namespace BPASmartClient.ViewModel
{
CommunicationName = $"Communication_{num}",
DeviceModelId = deviceConfig.ElementAt(0).deviceModels.FirstOrDefault(p => p.DeviceName == dm.DeviceName)?.Id,
- communicationPar = new CommunicationPar() { CommunicationType = false }
+ communicationPar = new CommunicationPar() { IsNetworkPort = false }
});
break;
@@ -120,97 +136,9 @@ namespace BPASmartClient.ViewModel
}
}
}
+ #endregion
-
- public static event EventHandler StaticPropertyChanged;
- private static void OnStaticPropertyChanged([CallerMemberName] string PropName = "")
- {
- StaticPropertyChanged?.Invoke(null, new PropertyChangedEventArgs(PropName));
- }
-
-
- //public static string DeviceNamePar
- //{
- // get { return _mDeviceNamePar; }
- // set
- // {
- // _mDeviceNamePar = value;
- // if (deviceConfig.Count == 1)
- // {
- // int index = Array.FindIndex(deviceConfig.ElementAt(0).deviceModels.ToArray(), p => p.DeviceName == DeviceName);
- // if (index >= 0 && index < deviceConfig.ElementAt(0).deviceModels.Count)
- // {
- // deviceConfig.ElementAt(0).deviceModels.ElementAt(index).DeviceName = value;
- // }
- // }
- // OnStaticPropertyChanged();
- // }
- //}
- //private static string _mDeviceNamePar;
-
- //public static string DeviceIdPar
- //{
- // get { return _mDeviceIdPar; }
- // set
- // {
- // _mDeviceIdPar = value;
- // if (deviceConfig.Count == 1)
- // {
- // int index = Array.FindIndex(deviceConfig.ElementAt(0).deviceModels.ToArray(), p => p.DeviceName == DeviceName);
- // if (index >= 0 && index < deviceConfig.ElementAt(0).deviceModels.Count)
- // {
- // deviceConfig.ElementAt(0).deviceModels.ElementAt(index).DeviceId = value;
- // }
- // }
- // OnStaticPropertyChanged();
- // }
- //}
- //private static string _mDeviceIdPar;
-
- public static Visibility DeviceParVisibility { get { return _mDeviceParVisibility; } set { _mDeviceParVisibility = value; OnStaticPropertyChanged(); } }
- private static Visibility _mDeviceParVisibility = Visibility.Hidden;
- public static Visibility CommunicationVisibility { get { return _mCommunicationVisibility; } set { _mCommunicationVisibility = value; OnStaticPropertyChanged(); } }
- private static Visibility _mCommunicationVisibility = Visibility.Hidden;
-
-
-
-
- //public static string DeviceModelId
- //{
- // get { return _mDeviceModelId; }
- // set
- // {
- // _mDeviceModelId = value;
-
- // }
- //}
- //private static string _mDeviceModelId;
-
-
- //public static string DeviceName
- //{
- // get { return _mDeviceName; }
- // set
- // {
- // _mDeviceName = value;
- // if (deviceConfig.Count == 1)
- // {
- // var res = deviceConfig.ElementAt(0).deviceModels.FirstOrDefault(p => p.DeviceName == value);
- // if (res != null)
- // {
- // DeviceIdPar = res.DeviceId;
- // DeviceNamePar = res.DeviceName;
- // }
- // }
- // }
- //}
- //private static string _mDeviceName;
-
-
- //public static string CommunicationName { get; set; }
-
-
-
+ #region Command
///
/// 新建设备
///
@@ -231,8 +159,81 @@ namespace BPASmartClient.ViewModel
///
public RelayCommand RemoveCommunicationCommand { get; set; }
+ public Action SaveData { get; set; }
+ #endregion
+
+ #region 列表集合
+ ///
+ /// 设备信息列表
+ ///
public static ObservableCollection deviceConfig { get; set; } = new ObservableCollection();
+ ///
+ /// 端口号列表
+ ///
+ public static ObservableCollection Ports { get; set; } = new ObservableCollection();
+
+ ///
+ /// 波特率列表
+ ///
+ public static ObservableCollection BaudRates { get; set; } = new ObservableCollection();
+
+ ///
+ /// 奇偶校验列表
+ ///
+ public static ObservableCollection Paritys { get; set; } = new ObservableCollection();
+
+ ///
+ /// 设备模块
+ ///
+ public static ObservableCollection DeviceModels { get; set; } = new ObservableCollection();
+
+ ///
+ /// 通讯模块
+ ///
+ public static ObservableCollection CommunicationModel { get; set; } = new ObservableCollection();
+
+ ///
+ /// 店铺集合
+ ///
+ public static ObservableCollection Shops { get; set; } = new ObservableCollection();
+
+ private void DataListInit()
+ {
+ Ports.Clear();
+ SerialPort.GetPortNames().ToList().ForEach((item) => { Ports.Add(item); });
+
+ BaudRates.Clear();
+ int[] rb = new int[] { 110, 300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 38400, 43000, 57600, 76800, 115200 };
+ rb.ToList().ForEach((item) => { BaudRates.Add(item); });
+
+ Paritys.Clear();
+ Enum.GetNames(typeof(Parity)).ToList().ForEach((item) => { Paritys.Add(item); });
+
+ DeviceModels.Clear();
+ DeviceModels.Add("Morks");
+ DeviceModels.Add("Morkt");
+ DeviceModels.Add("Morkic");
+ DeviceModels.Add("Morkjc");
+
+ CommunicationModel.Clear();
+ CommunicationModel.Add("乐百");
+ CommunicationModel.Add("节卡");
+ CommunicationModel.Add("单片机");
+ CommunicationModel.Add("咖啡机");
+ CommunicationModel.Add("冰淇淋机");
+
+ Shops.Clear();
+ DirectoryInfo directoryInfo = new DirectoryInfo(LocaPath.GetInstance().GetDeviceConfigPath);
+ var files = directoryInfo.GetFiles();
+ foreach (var item in files)
+ {
+ var res = Path.GetFileNameWithoutExtension(item.FullName);
+ if (res != null && res.Length > 0 && item.FullName.Contains("json")) Shops.Add(res);
+ }
+ }
+ #endregion
+
}
diff --git a/BPASmartClient/App.config b/BPASmartClient/App.config
index fd222222..0b7359ac 100644
--- a/BPASmartClient/App.config
+++ b/BPASmartClient/App.config
@@ -3,7 +3,7 @@
-
+
@@ -12,16 +12,19 @@
-
+
+
+
+
-
-
-
-
+
+
+
+
@@ -48,10 +54,10 @@
-
+
-
+
diff --git a/BPASmartClient/Control/ShopDeviceConfigView.xaml b/BPASmartClient/Control/ShopDeviceConfigView.xaml
index 11d18b8a..b114f896 100644
--- a/BPASmartClient/Control/ShopDeviceConfigView.xaml
+++ b/BPASmartClient/Control/ShopDeviceConfigView.xaml
@@ -27,6 +27,16 @@
+
+
- -->
-
@@ -473,36 +472,25 @@
Header="删除通讯" />
-
-
-
+
-
-
-
-
+
+
+
+
-
+
@@ -514,17 +502,26 @@
+ Columns="2"
+ Visibility="Collapsed">
+ Foreground="{StaticResource TextBlockForeground}"
+ IsChecked="{Binding SelectedValue.communicationPar.IsNetworkPort, ElementName=tv, Mode=TwoWay}" />
+
+ Foreground="{StaticResource TextBlockForeground}"
+ IsChecked="{Binding SelectedValue.communicationPar.IsSerialPort, ElementName=tv, Mode=TwoWay}" />
+
-
-
-
+
+
@@ -584,9 +584,9 @@
FontSize="20"
Foreground="#ff23caca"
IsEditable="False"
- ItemsSource="{Binding Path=Device.PlcTypes}"
+ ItemsSource="{Binding DeviceModels}"
Style="{StaticResource ComboBoxStyle}"
- Text="{Binding Path=Device.PlcType}" />
+ Text="{Binding SelectedValue.DeviceModule, ElementName=tv, Mode=TwoWay}" />
+
-
+
@@ -671,9 +675,10 @@
+ Visibility="Collapsed">
@@ -707,7 +712,7 @@
FontSize="20"
Foreground="#ff23caca"
IsEditable="False"
- ItemsSource="{Binding Path=Device.Ports}"
+ ItemsSource="{Binding Ports}"
SelectedIndex="0"
Style="{StaticResource ComboBoxStyle}"
Text="{Binding SelectedValue.communicationPar.SerialPort, ElementName=tv, Mode=TwoWay}" />
@@ -730,7 +735,7 @@
FontSize="20"
Foreground="#ff23caca"
IsEditable="False"
- ItemsSource="{Binding Path=Device.BaudRates}"
+ ItemsSource="{Binding BaudRates}"
SelectedIndex="0"
Style="{StaticResource ComboBoxStyle}"
Text="{Binding SelectedValue.communicationPar.BaudRate, ElementName=tv, Mode=TwoWay}" />
@@ -753,7 +758,7 @@
FontSize="20"
Foreground="#ff23caca"
IsEditable="False"
- ItemsSource="{Binding Path=Device.Paritys}"
+ ItemsSource="{Binding Paritys}"
SelectedIndex="0"
Style="{StaticResource ComboBoxStyle}"
Text="{Binding SelectedValue.communicationPar.Parity, ElementName=tv, Mode=TwoWay}" />
@@ -802,8 +807,77 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
@@ -850,7 +924,7 @@
Grid.Row="1"
HorizontalScrollBarVisibility="Hidden"
VerticalScrollBarVisibility="Hidden">
-
+
@@ -860,28 +934,35 @@
+
-
-
-
-
-
+ HorizontalAlignment="Center"
+ VerticalAlignment="Center"
+ Background="Transparent"
+ FontSize="14"
+ Foreground="{StaticResource TitleBorderColor}"
+ Text="{Binding Id}" />
+
+
+
-
+ Width="400"
+ HorizontalAlignment="Left"
+ Style="{StaticResource InputTextboxStyle}"
+ Text="{Binding ReadLeng}" />
e)
@@ -40,60 +49,120 @@ namespace BPASmartClient.Control
Refresh();
}
- private void tv_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
- {
- //if (e.ButtonState == MouseButtonState.Pressed)
- //{
- // Refresh();
- //}
- }
-
private void Refresh()
{
if (this.tv.SelectedValue is DeviceConfigModel deviceConfigModel)
{
- //ShopDeviceConfigViewModel.ShopName = deviceConfigModel.ShopName;
}
else if (this.tv.SelectedValue is DeviceModel deviceModel)
{
- ShopDeviceConfigViewModel.DeviceParVisibility = Visibility.Visible;
- ShopDeviceConfigViewModel.CommunicationVisibility = Visibility.Hidden;
- //ShopDeviceConfigViewModel.DeviceName = deviceModel.DeviceName;
+ this.Device.Visibility = Visibility.Visible;
+ this.CommType.Visibility = Visibility.Collapsed;
+ this.VarTab.Visibility = Visibility.Collapsed;
+ this.Serial.Visibility = Visibility.Collapsed;
+ this.Network.Visibility = Visibility.Collapsed;
+ this.GridCommunication.Visibility = Visibility.Collapsed;
}
else if (this.tv.SelectedValue is CommunicationModel communicationModel)
{
- ShopDeviceConfigViewModel.CommunicationVisibility = Visibility.Visible;
- ShopDeviceConfigViewModel.DeviceParVisibility = Visibility.Hidden;
- //ShopDeviceConfigViewModel.CommunicationName = communicationModel.CommunicationName;
- //ShopDeviceConfigViewModel.DeviceModelId = communicationModel.DeviceModelId;
+ this.Device.Visibility = Visibility.Collapsed;
+ this.CommType.Visibility = Visibility.Visible;
+ this.VarTab.Visibility = Visibility.Visible;
+ this.GridCommunication.Visibility = Visibility.Visible;
+ this.Serial.Visibility = (bool)this.rbSerial.IsChecked ? Visibility.Visible : Visibility.Collapsed;
+ this.Network.Visibility = (bool)this.rbNetwork.IsChecked ? Visibility.Visible : Visibility.Collapsed;
+
+
+ if (ShopDeviceConfigViewModel.deviceConfig.Count > 0)
+ {
+ int index = Array.FindIndex(ShopDeviceConfigViewModel.deviceConfig.ElementAt(0).deviceModels.ToArray(), p => p.Id == communicationModel.DeviceModelId);
+ if (index >= 0 && index < ShopDeviceConfigViewModel.deviceConfig.ElementAt(0).deviceModels.Count)
+ {
+ int commIndex = Array.FindIndex(ShopDeviceConfigViewModel.deviceConfig.ElementAt(0).deviceModels.ElementAt(index).communicationDevcies.ToArray(), p => p.DeviceModelId == communicationModel.DeviceModelId);
+ if (commIndex >= 0 && commIndex < ShopDeviceConfigViewModel.deviceConfig.ElementAt(0).deviceModels.ElementAt(index).communicationDevcies.Count)
+ {
+ if (ShopDeviceConfigViewModel.deviceConfig.ElementAt(0).deviceModels.ElementAt(index).communicationDevcies.ElementAt(commIndex).communicationPar.variables.Count <= 0)
+ {
+ for (int i = 0; i < 20; i++)
+ {
+ ShopDeviceConfigViewModel.deviceConfig.ElementAt(0).deviceModels.ElementAt(index).communicationDevcies.ElementAt(commIndex).communicationPar.variables.Add(new Variable()
+ {
+ Id = ShopDeviceConfigViewModel.deviceConfig.ElementAt(0).deviceModels.ElementAt(index).communicationDevcies.ElementAt(commIndex).communicationPar.variables.Count,
+ Address = string.Empty,
+ ReadLeng = 0
+ });
+ }
+ }
+ }
+ }
+ }
+
}
}
- private void tv_PreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e)
+ private void rbNetwork_Checked(object sender, RoutedEventArgs e)
{
+ rbVisibility();
+ }
+ private void rbSerial_Checked(object sender, RoutedEventArgs e)
+ {
+ rbVisibility();
}
- private void DeviceInfo(object sender, MouseButtonEventArgs e)
+ private void rbVisibility()
{
- var tb = sender as TextBlock;
- if (tb != null)
+ this.Network.Visibility = (bool)this.rbNetwork.IsChecked ? Visibility.Visible : Visibility.Collapsed;
+ this.Serial.Visibility = (bool)this.rbSerial.IsChecked ? Visibility.Visible : Visibility.Collapsed;
+ }
+
+ private void ComboBox_DropDownOpened(object sender, EventArgs e)
+ {
+ ShopDeviceConfigViewModel.Shops.Clear();
+ DirectoryInfo directoryInfo = new DirectoryInfo(LocaPath.GetInstance().GetDeviceConfigPath);
+ var files = directoryInfo.GetFiles();
+ foreach (var item in files)
{
- //ShopDeviceConfigViewModel.DeviceName = tb.Text.Trim();
- //tb.Background = Brushes.Blue;
+ var res = System.IO.Path.GetFileNameWithoutExtension(item.FullName);
+ if (res != null && res.Length > 0 && item.FullName.Contains("json")) ShopDeviceConfigViewModel.Shops.Add(res);
}
}
- private void CommunicationInfo(object sender, MouseButtonEventArgs e)
+
+ private void shop_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
- //var tb = sender as TextBlock;
- //if (tb != null)
- //{
- // ShopDeviceConfigViewModel.CommunicationName = tb.Text.Trim();
- // ShopDeviceConfigViewModel.DeviceModelId = tb.Tag.ToString();
- // tb.Focus();
- // //tb.Background = Brushes.Blue;
+ var text = TextHelper.GetInstance.ReadTextInfo("StartShop", "DeviceConfig");
+ if (this.shop.Items.Contains(text)) this.shop.SelectedValue = text;
+ DirectoryInfo directoryInfo = new DirectoryInfo(LocaPath.GetInstance().GetDeviceConfigPath);
+ var files = directoryInfo.GetFiles();
+ if (files != null && this.shop.SelectedValue != null && this.shop.SelectedValue.ToString().Length > 0)
+ {
+ var file = files.FirstOrDefault(p => p.FullName.Contains(this.shop.SelectedValue.ToString()));
+ if (file != null && File.Exists(file.FullName))
+ {
+ string JsonString = File.ReadAllText(file.FullName);
+ var result = JsonConvert.DeserializeObject>(JsonString);
+ if (result != null)
+ {
+ ShopDeviceConfigViewModel.deviceConfig.Clear();
+ foreach (var item in result)
+ {
+ ShopDeviceConfigViewModel.deviceConfig.Add(item);
+ }
+ VisibilityControl();
+ }
+ }
+ }
+ TextHelper.GetInstance.WriteTextInfo(this.shop.SelectedValue?.ToString(), "StartShop", "DeviceConfig");
+ }
- //}
+ private void VisibilityControl()
+ {
+ if (this.Device != null) this.Device.Visibility = Visibility.Collapsed;
+ if (this.CommType != null) this.CommType.Visibility = Visibility.Collapsed;
+ if (this.VarTab != null) this.VarTab.Visibility = Visibility.Collapsed;
+ if (this.Serial != null) this.Serial.Visibility = Visibility.Collapsed;
+ if (this.Network != null) this.Network.Visibility = Visibility.Collapsed;
+ if (this.GridCommunication != null) this.GridCommunication.Visibility = Visibility.Collapsed;
}
}
}
diff --git a/BPASmartClient/DeviceInfo.xml b/BPASmartClient/DeviceInfo.xml
index 89e636c8..95e5a89b 100644
--- a/BPASmartClient/DeviceInfo.xml
+++ b/BPASmartClient/DeviceInfo.xml
@@ -38,7 +38,7 @@
-->
-
+
diff --git a/BPASmartClient/DialogWindow/NewShopWindow.xaml b/BPASmartClient/DialogWindow/NewShopWindow.xaml
index 838849c1..e2cdd252 100644
--- a/BPASmartClient/DialogWindow/NewShopWindow.xaml
+++ b/BPASmartClient/DialogWindow/NewShopWindow.xaml
@@ -125,7 +125,7 @@
Visibility="Hidden" />
@@ -200,7 +200,7 @@
FontFamily="楷体"
FontSize="20"
Foreground="Red"
- Text="错误提示" />
+ Text="{Binding ErrorInfo}" />
diff --git a/BPASmartClient/DialogWindow/NewShopWindow.xaml.cs b/BPASmartClient/DialogWindow/NewShopWindow.xaml.cs
index 1176065d..b58e0f44 100644
--- a/BPASmartClient/DialogWindow/NewShopWindow.xaml.cs
+++ b/BPASmartClient/DialogWindow/NewShopWindow.xaml.cs
@@ -1,4 +1,5 @@
-using Microsoft.Toolkit.Mvvm.Messaging;
+using BPASmartClient.Helper;
+using Microsoft.Toolkit.Mvvm.Messaging;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -28,13 +29,28 @@ namespace BPASmartClient.DialogWindow
this.DragMove();
};
- WeakReferenceMessenger.Default.Register(this, "CloseWindow", (o, e) =>
+ ActionManage.GetInstance.CancelRegister("CloseWindow");
+ ActionManage.GetInstance.CancelRegister("OkCloseWindow");
+
+ ActionManage.GetInstance.Register(new Action(() =>
{
App.Current.Dispatcher.Invoke(new Action(() =>
{
+ this.DialogResult = false;
this.Close();
}));
- });
+ }), "CloseWindow");
+
+ ActionManage.GetInstance.Register(new Action(() =>
+ {
+ App.Current.Dispatcher.Invoke(new Action(() =>
+ {
+ this.DialogResult = true;
+ this.Close();
+ }));
+ }), "OkCloseWindow");
+
+
}
diff --git a/BPASmartClient/MainWindow.xaml b/BPASmartClient/MainWindow.xaml
index cbc6beea..b9f83f0e 100644
--- a/BPASmartClient/MainWindow.xaml
+++ b/BPASmartClient/MainWindow.xaml
@@ -241,7 +241,7 @@
Cursor="Hand"
Style="{DynamicResource CommonBtn_返回}" />
-
+ Style="{DynamicResource CommonBtn_返回}" />-->
+
+
{
var res = Json.Data.orderLists.FirstOrDefault(p => p.DeviceId == "2")?.morkOrderPushes;
@@ -186,7 +186,7 @@ namespace BPASmartClient
count = 0;
}
}
- App.Current.Dispatcher.Invoke(new Action(() => { this.save.IsEnabled = true; }));
+ //App.Current.Dispatcher.Invoke(new Action(() => { this.save.IsEnabled = true; }));
}));
diff --git a/HBLConsole.MORKIC/BPASmartClient.MORKIC.csproj b/HBLConsole.MORKIC/BPASmartClient.MORKIC.csproj
index 0dcf2236..a6768c85 100644
--- a/HBLConsole.MORKIC/BPASmartClient.MORKIC.csproj
+++ b/HBLConsole.MORKIC/BPASmartClient.MORKIC.csproj
@@ -2,6 +2,8 @@
net6.0
+ bin\
+ portable
From 464d0614a814dc2dfc8f7d9906c9681573ac78b3 Mon Sep 17 00:00:00 2001
From: NXX <447201003@qq>
Date: Thu, 19 May 2022 13:11:42 +0800
Subject: [PATCH 13/13] =?UTF-8?q?MORKT=20=E4=BF=AE=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
BPASmartClient.MorkT/Control_MorkT.cs | 276 ++++++++++++++++++++++++++
BPASmartClient/App.config | 8 +-
2 files changed, 280 insertions(+), 4 deletions(-)
diff --git a/BPASmartClient.MorkT/Control_MorkT.cs b/BPASmartClient.MorkT/Control_MorkT.cs
index 7e60ce0d..09a87c9a 100644
--- a/BPASmartClient.MorkT/Control_MorkT.cs
+++ b/BPASmartClient.MorkT/Control_MorkT.cs
@@ -174,6 +174,282 @@ namespace BPASmartClient.MorkT
}
+
+
+ private void OrderChange(string subid, ORDER_STATUS oRDER_STATUS)
+ {
+ EventBus.EventBus.GetInstance().Publish(new OrderStatusChangedEvent() { Status = oRDER_STATUS, SubOrderId = subid, deviceClientType = DeviceType });
+ }
+
+ private void Wait(int value = 101)
+ {
+ while (!(morkT.lebai.Ok && morkT.lebai.Value == value))
+ {
+ Thread.Sleep(5);
+ }
+ }
+
+ ///
+ /// 是否可以开始制作咖啡
+ ///
+ ///
+ private bool CoffeeCanMake()
+ {
+ bool canMake = (IsHealth && morkT.morkOrderPushesCoffee.Count > 0 && !morkT.IsCoffeeMake) ? true : false;
+ return canMake;
+
+ }
+
+ ///
+ /// 制作咖啡流程
+ ///
+ private void MakeCoffeeProcess()
+ {
+ if (CoffeeCanMake())
+ {
+ if (morkT.morkOrderPushesCoffee.TryDequeue(out OrderLocInfo orderLoc))
+ {
+ DeviceProcessLogShow($"开始制作 [咖啡] 订单[{orderLoc.SortNum}]");
+ GetAndCheeckCoffe(orderLoc);
+ LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_接咖啡后回原点);//把咖啡杯放到咖啡机机的位置后回原点
+ Wait();
+ LebaiRobot.GetInstance.SetValue(1);
+ new DRCoffee_MakeCoffeeEvent() { DrinkCode = (Model.咖啡机.Enum.DrCoffeeDrinksCode)int.Parse(orderLoc.Loc) }.Publish(); //接咖啡控制
+ DeviceProcessLogShow($"发送咖啡机制作{orderLoc.Loc}!");
+ morkT.IsCoffeeMake = true; morkT.MakeCoffeeOrder = orderLoc;
+ }
+
+ }
+
+
+ }
+ ///
+ /// 咖啡机制作完咖啡,取走并放到取餐口,最后回原点
+ ///
+ private void MakeCoffeeComplete()
+ {
+ if (morkT.IsCoffeeMake && IsHealth)
+ {
+ if (morkT.MakeCoffeeOrder != null && morkT.MakeCoffeeOrder.OrderStatus == 1)
+ {
+ DeviceProcessLogShow($"将咖啡移动到取餐位 [咖啡] 订单[{morkT.MakeCoffeeOrder.SortNum}]");
+ DoCoffeeQC(morkT.MakeCoffeeOrder);
+ morkT.MakeCoffeeOrder = null;
+ morkT.IsCoffeeMake = false;
+ }
+ }
+ }
+
+
+ ///
+ /// 将咖啡杯从咖啡机 取走到 取餐口
+ ///
+ private void DoCoffeeQC(OrderLocInfo order)
+ {
+ LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_取咖啡出餐);
+ Wait();
+ LebaiRobot.GetInstance.SetValue(1);
+ //订单状态改变:完成
+ OrderChange(order.SuborderId, ORDER_STATUS.COMPLETED_COOK);
+ DeviceProcessLogShow($"{order.GoodsName}等待取餐");
+ //WaitTakeMealOrder.Enqueue(order);
+
+ }
+
+ ///
+ /// 取咖啡杯&&咖啡杯检测 若检测失败机器人回原点
+ ///
+ ///
+ private void GetAndCheeckCoffe(OrderLocInfo order)
+ {
+ LebaiRobot.GetInstance.SetValue(0);
+ OrderChange(order.SuborderId, ORDER_STATUS.COOKING);
+ LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_取咖啡杯);
+ Wait();
+ new SCChip_TakeCupEvent() { Cup = IC_CUP.CUP_COFFEE }.Publish();//落碗控制
+ Thread.Sleep(500);
+ DeviceProcessLogShow("尝试取咖啡杯!");
+ LebaiRobot.GetInstance.SetValue(1);
+ int count = 2;
+ p:
+ LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_咖啡杯检测);
+ Wait();
+ LebaiRobot.GetInstance.SetValue(1);
+
+ if (!LebaiRobot.GetInstance.GetInput())
+ {
+ if (count >= 3)
+ {
+ //退出循环回到初始位置
+ DeviceProcessLogShow($"执行{count}次取咖啡杯,仍为成功,订单默认废弃,机器人回到初始位置!");
+ LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_咖啡杯回原点);
+ Wait();
+ LebaiRobot.GetInstance.SetValue(1);
+ return;
+ }
+ DeviceProcessLogShow("执行二次取咖啡杯");
+ LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_二次取咖啡杯);
+ Wait();
+ new SCChip_TakeCupEvent() { Cup = IC_CUP.CUP_COFFEE }.Publish();//落碗控制
+ LebaiRobot.GetInstance.SetValue(1);
+ count++;
+ goto p;
+ }
+ DeviceProcessLogShow("取咖啡杯完成");
+ }
+
+ ///
+ /// 冰淇淋是否可以开始制作
+ ///
+ ///
+ private bool IceCreamCanMake()
+ {
+ bool canMake = (IsHealth && morkT.morkOrderPushesIceCream.Count > 0) ? true : false;
+ return canMake;
+ }
+
+ ///
+ /// 制作冰淇淋流程
+ ///
+ private void MakeIceCreamProcess()
+ {
+ if (IceCreamCanMake())
+ {
+ if (MorkIStatus.GetInstance().CurrentMode != MORKI_MODE.制冷模式) new GSIceCream_ModeSetEvent() { Mode = MORKI_MODE.制冷模式 }.Publish();
+ if (MorkIStatus.GetInstance().CXB >= 86 && morkT.morkOrderPushesIceCream.Count > 0)//成型比大于86才可以制作
+ {
+ if (LebaiRobot.GetInstance.GetInput(3))
+ {
+ if (morkT.IceIsOK) DeviceProcessLogShow("请检查冰淇淋出料口有无遮挡");
+ morkT.IceIsOK = false;
+
+ }
+ else if (morkT.morkOrderPushesIceCream.TryDequeue(out OrderLocInfo order))
+ {
+ morkT.IceIsOK = true;
+ DeviceProcessLogShow($"开始制作 [冰淇淋] 订单[{order.SortNum}]");
+ DoIceCream(order);
+ }
+ }
+ }
+ }
+
+
+ ///
+ /// 做冰淇淋
+ ///
+ private void DoIceCream(OrderLocInfo order)
+ {
+ GetIceCreamCup();
+ CheckICeCreaCup();
+ GetIceCream(order);
+ PutIceCream(order);
+ }
+
+ ///
+ /// 取冰淇淋杯
+ ///
+ private void GetIceCreamCup()
+ {
+ LebaiRobot.GetInstance.SetValue(0);
+ LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_取冰淇淋杯);
+ Wait();
+ new SCChip_TakeCupEvent() { Cup = IC_CUP.CUP_ICECREAM }.Publish();//落碗控制
+ Thread.Sleep(500);
+ DeviceProcessLogShow("尝试取冰淇淋杯!");
+
+ }
+
+ ///
+ /// 冰淇淋杯检测,失败后机器人回到原点
+ ///
+ private void CheckICeCreaCup()
+ {
+ int count = 2;
+ LebaiRobot.GetInstance.SetValue(1);
+ p:
+ LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_冰淇淋杯检测);
+ Wait();
+ LebaiRobot.GetInstance.SetValue(1);
+ if (!LebaiRobot.GetInstance.GetInput())
+ {
+ if (count >= 3)
+ {
+ //退出循环回到初始位置
+ DeviceProcessLogShow($"执行{count}次取冰淇淋杯,仍未成功,订单默认废弃,机器人回到初始位置!");
+ LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_冰淇淋杯回原点);
+ Wait();
+ LebaiRobot.GetInstance.SetValue(1);
+ return;
+ }
+ DeviceProcessLogShow($"执行{count}次取冰淇淋杯!");
+ LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_二次取冰淇淋杯);
+ new SCChip_TakeCupEvent() { Cup = IC_CUP.CUP_ICECREAM }.Publish();//落碗控制
+ Wait();
+ LebaiRobot.GetInstance.SetValue(1);
+ count++;
+ goto p;
+ }
+ DeviceProcessLogShow("冰淇淋杯检测完成");
+ }
+
+ ///
+ /// 机器人取接冰淇淋
+ ///
+ ///
+ private void GetIceCream(OrderLocInfo order)
+ {
+ //制冷模式
+ new GSIceCream_ModeSetEvent() { Mode = MORKI_MODE.制冷模式 }.Publish();
+ LebaiRobot.GetInstance.SetValue(0);
+ OrderChange(order.SuborderId, ORDER_STATUS.COOKING);
+ LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_接1号冰淇淋);
+ Wait();
+ bool doItResult = true;
+ //出料
+ new GSIceCream_DischargeEvent().Publish(delegate (object[] args)
+ {
+ doItResult = (bool)args[0];
+ });
+ if (doItResult)
+ {
+ IceCreamCookCheck();
+ }
+ else
+ {
+ int count_1 = 0;
+ while (MorkIStatus.GetInstance().CXB <= 86)
+ {
+ Thread.Sleep(5);
+ count_1++;
+ if (count_1 >= 2000)
+ break;
+ }
+ IceCreamCookCheck();
+ }
+ LebaiRobot.GetInstance.SetValue(1);
+ }
+
+ ///
+ /// 把冰淇淋放到取餐位后回原点
+ ///
+ ///
+ private void PutIceCream(OrderLocInfo order)
+ {
+ while (LebaiRobot.GetInstance.GetInput())
+ {
+ Thread.Sleep(500);
+ }
+ LebaiRobot.GetInstance.Scene(LebaiRobot.SENCE_放冰淇淋位置);
+ Wait();
+ LebaiRobot.GetInstance.SetValue(1);
+ //订单状态改变:完成
+ OrderChange(order.SuborderId, ORDER_STATUS.COMPLETED_COOK);
+ DeviceProcessLogShow($"{order.GoodsName}等待取餐");
+ //WaitTakeMealOrder.Enqueue(order);
+
+ }
+
///
/// 冰淇淋机器制作冰淇淋
///
diff --git a/BPASmartClient/App.config b/BPASmartClient/App.config
index e789e97e..08824b61 100644
--- a/BPASmartClient/App.config
+++ b/BPASmartClient/App.config
@@ -12,7 +12,7 @@
-
+
@@ -36,7 +36,7 @@
-->
-
+