@@ -74,12 +74,11 @@ namespace HBLConsole.Business.AbstractServer | |||||
{ | { | ||||
Json<BatchingInfoPar>.Data.recipeBoms = JsonConvert.DeserializeObject<RecipeBoms>(result); | Json<BatchingInfoPar>.Data.recipeBoms = JsonConvert.DeserializeObject<RecipeBoms>(result); | ||||
ActionManage.GetInstance.Send("recipeBom"); | ActionManage.GetInstance.Send("recipeBom"); | ||||
//WritePlcData(); | |||||
MessageLog.GetInstance.Show("接收到辅料信息"); | |||||
} | } | ||||
else if (PushType == 0) | else if (PushType == 0) | ||||
{ | { | ||||
Json<BatchingInfoPar>.Data.orderMaterialDelivery = JsonConvert.DeserializeObject<OrderMaterialDelivery>(result); | Json<BatchingInfoPar>.Data.orderMaterialDelivery = JsonConvert.DeserializeObject<OrderMaterialDelivery>(result); | ||||
} | } | ||||
} | } | ||||
catch (Exception ex) | catch (Exception ex) | ||||
@@ -68,7 +68,6 @@ namespace HBLConsole.Business | |||||
MqttM2.GetInstance.PublishInfo(PublishContent); | MqttM2.GetInstance.PublishInfo(PublishContent); | ||||
//mqttClient.Publish($"/sys/grgp0rFA2uu/{deviceName}/thing/event/property/post", Encoding.UTF8.GetBytes(PublishContent), 0, false); | //mqttClient.Publish($"/sys/grgp0rFA2uu/{deviceName}/thing/event/property/post", Encoding.UTF8.GetBytes(PublishContent), 0, false); | ||||
Thread.Sleep(1000); | |||||
}), "阿里云数据上报", new Action(() => { MqttM2.GetInstance.DisConnect(); })); | }), "阿里云数据上报", new Action(() => { MqttM2.GetInstance.DisConnect(); })); | ||||
} | } | ||||
@@ -27,16 +27,38 @@ namespace HBLConsole.MORKS | |||||
ActionManage.GetInstance.Register(new Action(() => { WriteRecipeBoms(); }), "recipeBom"); | ActionManage.GetInstance.Register(new Action(() => { WriteRecipeBoms(); }), "recipeBom"); | ||||
ActionManage.GetInstance.Register(new Action(() => { DeviceInit(); }), "InitCommand"); | ActionManage.GetInstance.Register(new Action(() => { DeviceInit(); }), "InitCommand"); | ||||
} | } | ||||
public void ConnectOk() | public void ConnectOk() | ||||
{ | { | ||||
mORKS.RBTakeNoodleTask.Enqueue(new OrderLocInfo()); | |||||
mORKS.RBTakeNoodleTask.Enqueue(new OrderLocInfo()); | |||||
mORKS.RBTakeNoodleTask.Enqueue(new OrderLocInfo()); | |||||
//WriteRecipeBoms(); | |||||
ReadData(); | ReadData(); | ||||
Main(); | Main(); | ||||
ResetProgram(); | ResetProgram(); | ||||
ActionManage.GetInstance.Register(new Action(() => | |||||
{ | |||||
Random rd = new Random(); | |||||
ThreadManage.GetInstance.StartLong(new Action(() => | |||||
{ | |||||
int NoodleLoc = rd.Next(1, 6); | |||||
int BowlLoc = rd.Next(10, 11); | |||||
string guid = new Guid().ToString(); | |||||
mORKS.RBTakeNoodleTask.Enqueue(new OrderLocInfo() { Loc = (ushort)NoodleLoc, SuborderId = guid }); | |||||
MessageLog.GetInstance.Show($"添加订单:面条位置【{NoodleLoc}】"); | |||||
mORKS.TakeBowlTask.Enqueue(new OrderLocInfo() { Loc = (ushort)BowlLoc, SuborderId = guid }); | |||||
MessageLog.GetInstance.Show($"添加订单:碗位置【{BowlLoc}】"); | |||||
Thread.Sleep(60000); | |||||
}), "ForOrder"); | |||||
}), "EnableForOrder"); | |||||
ActionManage.GetInstance.Register(new Action(() => | |||||
{ | |||||
ThreadManage.GetInstance.StopTask("ForOrder", new Action(() => | |||||
{ | |||||
mORKS.RBTakeNoodleTask.Clear(); | |||||
mORKS.TakeBowlTask.Clear(); | |||||
})); | |||||
}), "StopForOrder"); | |||||
MessageLog.GetInstance.Show("MORKS 设备初始化完成"); | MessageLog.GetInstance.Show("MORKS 设备初始化完成"); | ||||
} | } | ||||
@@ -113,14 +135,14 @@ namespace HBLConsole.MORKS | |||||
})); | })); | ||||
//var ResLoc = ModbusTcpHelper.GetInstance.Read(286, ReadType.HoldingRegisters); | |||||
//if (ResLoc != null) | |||||
//{ | |||||
// if (ResLoc is ushort loc) | |||||
// { | |||||
// mORKS.TurntableFeedbackloc = loc; | |||||
// } | |||||
//} | |||||
var ResLoc = ModbusTcpHelper.GetInstance.Read(286, ReadType.HoldingRegisters); | |||||
if (ResLoc != null) | |||||
{ | |||||
if (ResLoc is ushort loc) | |||||
{ | |||||
mORKS.TurntableFeedbackloc = loc; | |||||
} | |||||
} | |||||
Thread.Sleep(500); | Thread.Sleep(500); | ||||
}), "ReadPLCData"); | }), "ReadPLCData"); | ||||
@@ -221,9 +243,19 @@ namespace HBLConsole.MORKS | |||||
batching_W.BatchingLoc = "10"; | batching_W.BatchingLoc = "10"; | ||||
mORKS.RBTakeNoodleTask.Enqueue(new OrderLocInfo() { Loc = ushort.Parse(batching_M.BatchingLoc), SuborderId = morkOrderPush.SuborderId, BatchingId = batching_M.BatchingId }); | mORKS.RBTakeNoodleTask.Enqueue(new OrderLocInfo() { Loc = ushort.Parse(batching_M.BatchingLoc), SuborderId = morkOrderPush.SuborderId, BatchingId = batching_M.BatchingId }); | ||||
int index = Array.FindIndex(Json<BatchingInfoPar>.Data.recipeBoms.RecipeIds.ToArray(), p => p.RecipeId == morkOrderPush.RecipeId); | |||||
index++; | |||||
mORKS.TakeBowlTask.Enqueue(new OrderLocInfo() { Loc = ushort.Parse(batching_W.BatchingLoc), SuborderId = morkOrderPush.SuborderId, RecipeNumber = (index >= 1 && index <= 10) ? (ushort)index : (ushort)0 }); | |||||
int index = 0; | |||||
if (Json<BatchingInfoPar>.Data.recipeBoms != null) | |||||
{ | |||||
index = Array.FindIndex(Json<BatchingInfoPar>.Data.recipeBoms?.RecipeIds.ToArray(), p => p.RecipeId == morkOrderPush.RecipeId); | |||||
index++; | |||||
} | |||||
mORKS.TakeBowlTask.Enqueue(new OrderLocInfo() | |||||
{ | |||||
Loc = ushort.Parse(batching_W.BatchingLoc), | |||||
SuborderId = morkOrderPush.SuborderId, | |||||
RecipeNumber = (index >= 1 && index <= 10) ? (ushort)index : (ushort)0 | |||||
}); | |||||
} | } | ||||
} | } | ||||
@@ -235,8 +267,8 @@ namespace HBLConsole.MORKS | |||||
{ | { | ||||
mORKS.AllowRun = mORKS.InitComplete; | mORKS.AllowRun = mORKS.InitComplete; | ||||
//mORKS.AllowRun = mORKS.InitComplete && mORKS.TemperatureReached; | //mORKS.AllowRun = mORKS.InitComplete && mORKS.TemperatureReached; | ||||
//GeneralConfig.Healthy = true; | |||||
GeneralConfig.Healthy = mORKS.AllowRun; | |||||
GeneralConfig.Healthy = true; | |||||
//GeneralConfig.Healthy = mORKS.AllowRun; | |||||
TakeBowlTask(); | TakeBowlTask(); | ||||
@@ -305,6 +337,7 @@ namespace HBLConsole.MORKS | |||||
if (!mORKS.TurntableLocLists.Contains(loc)) | if (!mORKS.TurntableLocLists.Contains(loc)) | ||||
{ | { | ||||
TurntableStart(loc); | TurntableStart(loc); | ||||
MessageLog.GetInstance.Show("未检测到物料,启动转台查找"); | |||||
return; | return; | ||||
} | } | ||||
} | } | ||||
@@ -475,6 +508,7 @@ namespace HBLConsole.MORKS | |||||
{ | { | ||||
mORKS.TakeNoodleInterlock = false; | mORKS.TakeNoodleInterlock = false; | ||||
mORKS.AllowTakeNoodle = false; | mORKS.AllowTakeNoodle = false; | ||||
mORKS.TurntableInterlock = false; | |||||
MessageLog.GetInstance.Show("取面完成"); | MessageLog.GetInstance.Show("取面完成"); | ||||
TakeNoodleCompleteReset(); | TakeNoodleCompleteReset(); | ||||
} | } | ||||
@@ -513,6 +547,7 @@ namespace HBLConsole.MORKS | |||||
MessageLog.GetInstance.Show("成功写入配方数据"); | MessageLog.GetInstance.Show("成功写入配方数据"); | ||||
} | } | ||||
} | } | ||||
else { MessageLog.GetInstance.Show("配方数据为空"); } | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -591,11 +626,11 @@ namespace HBLConsole.MORKS | |||||
/// <param name="loc"></param> | /// <param name="loc"></param> | ||||
private void TakeBowlControl(ushort loc) | private void TakeBowlControl(ushort loc) | ||||
{ | { | ||||
if (loc == 10) | |||||
if (loc == 10)//小碗 | |||||
{ | { | ||||
ModbusTcpHelper.GetInstance.Write(321, WriteType.Coils, true); | ModbusTcpHelper.GetInstance.Write(321, WriteType.Coils, true); | ||||
} | } | ||||
else if (loc == 11) | |||||
else if (loc == 11)//大碗 | |||||
{ | { | ||||
ModbusTcpHelper.GetInstance.Write(322, WriteType.Coils, true); | ModbusTcpHelper.GetInstance.Write(322, WriteType.Coils, true); | ||||
} | } | ||||
@@ -53,23 +53,23 @@ namespace HBLConsole.MainConsole | |||||
{ | { | ||||
ThreadManage.GetInstance.Start(new Action(() => | ThreadManage.GetInstance.Start(new Action(() => | ||||
{ | { | ||||
SimpleFactory.GetInstance.DeviceInit();//设备初始化 | |||||
//SimpleFactory.GetInstance.DeviceInit();//设备初始化 | |||||
InternetInfo.ConfigInit();//从 consul 获取配置数据 | InternetInfo.ConfigInit();//从 consul 获取配置数据 | ||||
Topics.Clear(); | Topics.Clear(); | ||||
Topics.Add(TOPIC.GetInstance.GetOrderPushTopic(GeneralConfig.DeviceType, InternetInfo.ClientId)); | Topics.Add(TOPIC.GetInstance.GetOrderPushTopic(GeneralConfig.DeviceType, InternetInfo.ClientId)); | ||||
Topics.Add(TOPIC.GetInstance.GetBusinessTopic(GeneralConfig.DeviceType, InternetInfo.ClientId)); | Topics.Add(TOPIC.GetInstance.GetBusinessTopic(GeneralConfig.DeviceType, InternetInfo.ClientId)); | ||||
//MQTT 连接成功 | //MQTT 连接成功 | ||||
MqttHelper.GetInstance.ConnectOk = new Action(() => | MqttHelper.GetInstance.ConnectOk = new Action(() => | ||||
{ | { | ||||
//SimpleFactory.GetInstance.DeviceInit();//设备初始化 | |||||
SimpleFactory.GetInstance.DeviceInit();//设备初始化 | |||||
MqttHelper.GetInstance.MqttSubscriptionAsync(Topics.ToArray());//主题订阅 | MqttHelper.GetInstance.MqttSubscriptionAsync(Topics.ToArray());//主题订阅 | ||||
IotReport.GetInstance.Init();//IOT 上报 | |||||
//IotReport.GetInstance.Init();//IOT 上报 | |||||
HeartbeatReport.GetInstance.Init();//心跳上报 | HeartbeatReport.GetInstance.Init();//心跳上报 | ||||
@@ -110,7 +110,7 @@ namespace HBLConsole.MainConsole | |||||
{ | { | ||||
MqttHelper.GetInstance.MqttSubscriptionAsync(Topics.ToArray());//主题订阅 | MqttHelper.GetInstance.MqttSubscriptionAsync(Topics.ToArray());//主题订阅 | ||||
IotReport.GetInstance.Init();//IOT 上报 | |||||
//IotReport.GetInstance.Init();//IOT 上报 | |||||
HeartbeatReport.GetInstance.Init();//心跳上报 | HeartbeatReport.GetInstance.Init();//心跳上报 | ||||
@@ -0,0 +1,17 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||||
namespace HBLConsole.Model | |||||
{ | |||||
public class ParSet : ObservableObject | |||||
{ | |||||
public bool IsAutoStart { get { return _mIsAutoStart; } set { _mIsAutoStart = value; OnPropertyChanged(); } } | |||||
private bool _mIsAutoStart; | |||||
} | |||||
} |
@@ -95,9 +95,12 @@ namespace HBLConsole.Service | |||||
/// <returns></returns> | /// <returns></returns> | ||||
public bool IsAutoStart() | public bool IsAutoStart() | ||||
{ | { | ||||
//RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run\"); | |||||
RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run\"); | |||||
return registryKey.GetValueNames().Contains(GetApplicationName); | |||||
RegistryKey R_local = Registry.CurrentUser; | |||||
RegistryKey R_run = R_local.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run"); | |||||
bool res = R_run.GetValueNames().Contains(GetApplicationName); | |||||
R_run.Close(); | |||||
R_local.Close(); | |||||
return res; | |||||
} | } | ||||
@@ -36,24 +36,6 @@ namespace HBLConsole.Service | |||||
ActionManage.GetInstance.Register(ExitCallback, guid + key); | ActionManage.GetInstance.Register(ExitCallback, guid + key); | ||||
} | } | ||||
//public void StopTask(string[] keys, Action ExitCallback = null) | |||||
//{ | |||||
// lock (_lock) | |||||
// if (keys != null) | |||||
// { | |||||
// for (int i = 0; i < keys.Length; i++) | |||||
// { | |||||
// this.keys.Add(keys[i]); | |||||
// callbackKey.Append(keys[i]); | |||||
// if (CancellationTokenSources.ContainsKey(guid + keys[i])) | |||||
// CancellationTokenSources[guid + keys[i]]?.Cancel(); | |||||
// } | |||||
// callbackKey.Append(guid); | |||||
// ActionManage.GetInstance.Register(ExitCallback, callbackKey.ToString()); | |||||
// } | |||||
//} | |||||
/// <summary> | /// <summary> | ||||
/// 长任务,带 while true 的循环 | /// 长任务,带 while true 的循环 | ||||
/// </summary> | /// </summary> | ||||
@@ -62,17 +44,21 @@ namespace HBLConsole.Service | |||||
public void StartLong(Action action, string key, Action RunComplete = null) | public void StartLong(Action action, string key, Action RunComplete = null) | ||||
{ | { | ||||
CancellationTokenSources.TryAdd(guid + key, new CancellationTokenSource()); | CancellationTokenSources.TryAdd(guid + key, new CancellationTokenSource()); | ||||
bool result = Threads.TryAdd(guid + key, Task.Factory.StartNew(new Action(() => | |||||
bool result = Threads.TryAdd(guid + key, Task.Factory.StartNew(new Action(async () => | |||||
{ | { | ||||
try | try | ||||
{ | { | ||||
while (!CancellationTokenSources[guid + key].IsCancellationRequested) | while (!CancellationTokenSources[guid + key].IsCancellationRequested) | ||||
{ | { | ||||
if (action != null) action(); | |||||
if (action != null) | |||||
{ | |||||
action(); | |||||
} | |||||
} | } | ||||
} | } | ||||
catch (Exception ex) | catch (Exception ex) | ||||
{ | { | ||||
MessageLog.GetInstance.Show(ex.ToString()); | |||||
MessageLog.GetInstance.Show($"线程 【{key}】运行发生异常,已重启"); | MessageLog.GetInstance.Show($"线程 【{key}】运行发生异常,已重启"); | ||||
CancellationTokenSources.TryRemove(guid + key, out CancellationTokenSource temp); | CancellationTokenSources.TryRemove(guid + key, out CancellationTokenSource temp); | ||||
Threads.TryRemove(guid + key, out Task temp1); | Threads.TryRemove(guid + key, out Task temp1); | ||||
@@ -4,14 +4,15 @@ | |||||
<!--通用配置--> | <!--通用配置--> | ||||
<!--测试服务 Consul 地址--> | <!--测试服务 Consul 地址--> | ||||
<add key="ConsulAddress" value="http://1.14.74.54" /> | |||||
<add key="ConsulAddress" value="http://1.14.74.54:9005" /> | |||||
<!--正式服务 Consul 地址--> | <!--正式服务 Consul 地址--> | ||||
<!--<add key="ConsulAddress" value="http://162.14.105.138:9005" />--> | <!--<add key="ConsulAddress" value="http://162.14.105.138:9005" />--> | ||||
<!--客户端ID--> | <!--客户端ID--> | ||||
<!--MorkD = 2,MorkS 且时且多 = 8,MorkS 珠海 = 9,冰淇淋 = 4,咖啡机 = 13--> | <!--MorkD = 2,MorkS 且时且多 = 8,MorkS 珠海 = 9,冰淇淋 = 4,咖啡机 = 13--> | ||||
<add key="ClientId" value="5"/> | |||||
<!--达州展会 MORKS =9,10--> | |||||
<add key="ClientId" value="9"/> | |||||
<!--IOT大屏上报--> | <!--IOT大屏上报--> | ||||
<add key="ProductKey" value="grgpECHSL7q"/> | <add key="ProductKey" value="grgpECHSL7q"/> | ||||
<add key="DeviceName" value="test"/> | <add key="DeviceName" value="test"/> | ||||
@@ -24,8 +25,8 @@ | |||||
<add key="COM_IceCream" value="COM5"/> | <add key="COM_IceCream" value="COM5"/> | ||||
<add key="BAUD_IceCream" value="9600"/> | <add key="BAUD_IceCream" value="9600"/> | ||||
<add key="IceCream_CXB_Threshold" value="90"/> | <add key="IceCream_CXB_Threshold" value="90"/> | ||||
<add key="COM_ICChip" value="COM11"/> | |||||
<add key="BAUD_IChip" value="9600"/> | |||||
<add key="COM_ICChip" value="COM11"/> | |||||
<add key="BAUD_IChip" value="9600"/> | |||||
</appSettings> | </appSettings> | ||||
</configuration> | </configuration> |
@@ -35,7 +35,7 @@ namespace HBLConsole | |||||
protected override void OnStartup(StartupEventArgs e) | protected override void OnStartup(StartupEventArgs e) | ||||
{ | { | ||||
base.OnStartup(e); | base.OnStartup(e); | ||||
SystemHelper.GetInstance.AutoStart(false); | |||||
//SystemHelper.GetInstance.AutoStart(true); | |||||
SystemHelper.GetInstance.CreateDesktopShortcut(); | SystemHelper.GetInstance.CreateDesktopShortcut(); | ||||
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; | AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; | ||||
MainConsole.Main.GetInstance.DataInit(); | MainConsole.Main.GetInstance.DataInit(); | ||||
@@ -44,7 +44,7 @@ namespace HBLConsole | |||||
mainView.Show(); | mainView.Show(); | ||||
SplitScreenDisplay(); | SplitScreenDisplay(); | ||||
NoCompleteOrderInit(); | NoCompleteOrderInit(); | ||||
MainConsole.Main.GetInstance.BusinessSimTest(); | |||||
MainConsole.Main.GetInstance.BusinessInit(); | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -264,10 +264,8 @@ | |||||
<Button | <Button | ||||
x:Name="button_loop" | x:Name="button_loop" | ||||
Margin="0,0,10,0" | Margin="0,0,10,0" | ||||
Command="{Binding LoopSimOrderCommand}" | |||||
CommandParameter="{Binding ElementName=button_loop, Path=Content}" | |||||
Content="{Binding LoopButton, Mode=TwoWay, NotifyOnTargetUpdated=True}" | |||||
Foreground="{Binding LoopColor, Mode=TwoWay, NotifyOnTargetUpdated=True}" | |||||
Command="{Binding LoopSimOrderCommand}" | |||||
Content="{Binding LoopOrderButtonContent}" | |||||
Style="{StaticResource ButtonStyle}" /> | Style="{StaticResource ButtonStyle}" /> | ||||
<!--#endregion--> | <!--#endregion--> | ||||
@@ -266,6 +266,8 @@ | |||||
<RadioButton | <RadioButton | ||||
Margin="-10,0,0,0" | Margin="-10,0,0,0" | ||||
Command="{Binding NavChangedCommand}" | |||||
CommandParameter="ParSetView" | |||||
Content="参数设置" | Content="参数设置" | ||||
Style="{StaticResource ParallelogramRadioButtonStyle}" /> | Style="{StaticResource ParallelogramRadioButtonStyle}" /> | ||||
@@ -0,0 +1,39 @@ | |||||
<UserControl | |||||
x:Class="HBLConsole.View.ParSetView" | |||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||||
xmlns:local="clr-namespace:HBLConsole.View" | |||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||||
xmlns:vm="clr-namespace:HBLConsole.ViewModel" | |||||
d:DesignHeight="450" | |||||
d:DesignWidth="1000" | |||||
mc:Ignorable="d"> | |||||
<UserControl.DataContext> | |||||
<vm:ParSetViewModel /> | |||||
</UserControl.DataContext> | |||||
<UserControl.Resources> | |||||
<ResourceDictionary> | |||||
<ResourceDictionary.MergedDictionaries> | |||||
<ResourceDictionary Source="../Resources/ResourceDictionarys/BasicStyle.xaml" /> | |||||
</ResourceDictionary.MergedDictionaries> | |||||
</ResourceDictionary> | |||||
</UserControl.Resources> | |||||
<Grid> | |||||
<CheckBox | |||||
Grid.Column="2" | |||||
Height="20" | |||||
Margin="10" | |||||
VerticalAlignment="Top" | |||||
Background="#FF2AB2E7" | |||||
Content="开机启动" | |||||
FontSize="14" | |||||
Foreground="#00c2f4" | |||||
IsChecked="{Binding IsSelected}" | |||||
Template="{StaticResource CbTemplate}" /> | |||||
</Grid> | |||||
</UserControl> |
@@ -0,0 +1,28 @@ | |||||
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 HBLConsole.View | |||||
{ | |||||
/// <summary> | |||||
/// ParSetView.xaml 的交互逻辑 | |||||
/// </summary> | |||||
public partial class ParSetView : UserControl | |||||
{ | |||||
public ParSetView() | |||||
{ | |||||
InitializeComponent(); | |||||
} | |||||
} | |||||
} |
@@ -46,7 +46,6 @@ namespace HBLConsole.ViewModel | |||||
{ | { | ||||
locs.Add((ushort)(new Random().Next(1, 5))); | locs.Add((ushort)(new Random().Next(1, 5))); | ||||
locs.Add(10); | locs.Add(10); | ||||
} | } | ||||
ActionManage.GetInstance.Send("SimOrder", locs); | ActionManage.GetInstance.Send("SimOrder", locs); | ||||
@@ -63,46 +62,17 @@ namespace HBLConsole.ViewModel | |||||
LoopSimOrderCommand = new RelayCommand(() => | LoopSimOrderCommand = new RelayCommand(() => | ||||
{ | { | ||||
LoopButton = LoopButton == "循环跑单" ? "停止跑单" : "循环跑单"; | |||||
if (LoopOrderButtonContent == "循环跑单") ActionManage.GetInstance.Send("EnableForOrder"); | |||||
if (LoopOrderButtonContent == "停止跑单") ActionManage.GetInstance.Send("StopForOrder"); | |||||
LoopOrderButtonContent = LoopOrderButtonContent == "循环跑单" ? "停止跑单" : "循环跑单"; | |||||
}); | }); | ||||
//ThreadManage.GetInstance.StartLong(new Action(() => | |||||
//{ | |||||
// //try | |||||
// //{ | |||||
// // System.Windows.Application.Current.Dispatcher.BeginInvoke((Action)async delegate | |||||
// // { | |||||
// // if (IsLoop && !IsLoopzc) | |||||
// // { | |||||
// // IsLoopzc = true; | |||||
// // if (simOrderVisibleDatas.ElementAt(0).IsSelected) | |||||
// // simOrderVisibleDatas.ElementAt(0).Loc = (ushort)(new Random().Next(1,6)); | |||||
// // ActionManage.GetInstance.Send("SimOrder",new SimOrderData() | |||||
// // { | |||||
// // NoodleLoc = simOrderVisibleDatas.ElementAt(0).Loc, | |||||
// // SoupLoc = simOrderVisibleDatas.ElementAt(1).Loc, | |||||
// // BowlLoc = 10, | |||||
// // }); | |||||
// // await Task.Delay(50000); | |||||
// // IsLoopzc = false; | |||||
// // } | |||||
// // }); | |||||
// //} | |||||
// //catch (Exception ex) | |||||
// //{ | |||||
// //} | |||||
// Thread.Sleep(1000); | |||||
//}), "循环订单"); | |||||
EditCommand = new RelayCommand<object>((o) => | EditCommand = new RelayCommand<object>((o) => | ||||
{ | { | ||||
if (o != null) | if (o != null) | ||||
{ | { | ||||
//if (Json<KeepDataBase>.Data.simOrderConfig.ContainsKey(GVL.GeneralConfig.DeviceType.ToString())) | |||||
//{ | |||||
var res = Json<KeepDataBase>.Data.simOrderConfig.FirstOrDefault(p => p.Text == o.ToString()); | var res = Json<KeepDataBase>.Data.simOrderConfig.FirstOrDefault(p => p.Text == o.ToString()); | ||||
if (res != null) | if (res != null) | ||||
{ | { | ||||
@@ -110,7 +80,6 @@ namespace HBLConsole.ViewModel | |||||
simOrderConfitView.Show(); | simOrderConfitView.Show(); | ||||
ActionManage.GetInstance.Send("SendSimData", res); | ActionManage.GetInstance.Send("SendSimData", res); | ||||
} | } | ||||
//} | |||||
} | } | ||||
}); | }); | ||||
@@ -119,11 +88,8 @@ namespace HBLConsole.ViewModel | |||||
{ | { | ||||
if (o != null) | if (o != null) | ||||
{ | { | ||||
//if (Json<KeepDataBase>.Data.simOrderConfig.ContainsKey(GVL.GeneralConfig.DeviceType.ToString())) | |||||
//{ | |||||
var res = Json<KeepDataBase>.Data.simOrderConfig.FirstOrDefault(p => p.Text == o.ToString()); | var res = Json<KeepDataBase>.Data.simOrderConfig.FirstOrDefault(p => p.Text == o.ToString()); | ||||
if (res != null) Json<KeepDataBase>.Data.simOrderConfig.Remove(res); | if (res != null) Json<KeepDataBase>.Data.simOrderConfig.Remove(res); | ||||
//} | |||||
} | } | ||||
}); | }); | ||||
} | } | ||||
@@ -132,18 +98,10 @@ namespace HBLConsole.ViewModel | |||||
{ | { | ||||
get | get | ||||
{ | { | ||||
//if (!Json<KeepDataBase>.Data.simOrderConfig.ContainsKey(GVL.GeneralConfig.DeviceType.ToString())) | |||||
//{ | |||||
// Json<KeepDataBase>.Data.simOrderConfig.TryAdd(GVL.GeneralConfig.DeviceType.ToString(), new ObservableCollection<SimOrderVisibleData>()); | |||||
//} | |||||
return Json<KeepDataBase>.Data.simOrderConfig; | return Json<KeepDataBase>.Data.simOrderConfig; | ||||
} | } | ||||
set | set | ||||
{ | { | ||||
//if (!Json<KeepDataBase>.Data.simOrderConfig.ContainsKey(GVL.GeneralConfig.DeviceType.ToString())) | |||||
//{ | |||||
// Json<KeepDataBase>.Data.simOrderConfig.TryAdd(GVL.GeneralConfig.DeviceType.ToString(), new ObservableCollection<SimOrderVisibleData>()); | |||||
//} | |||||
Json<KeepDataBase>.Data.simOrderConfig = value; | Json<KeepDataBase>.Data.simOrderConfig = value; | ||||
} | } | ||||
} | } | ||||
@@ -160,23 +118,18 @@ namespace HBLConsole.ViewModel | |||||
public RelayCommand<object> RemoveCommand { get; set; } | public RelayCommand<object> RemoveCommand { get; set; } | ||||
public static bool IsLoop = false; | |||||
public static bool IsLoopzc = false; | |||||
public static string LoopButton | |||||
public static event EventHandler<PropertyChangedEventArgs> StaticPropertyChanged; | |||||
public static void OnStaticPropertyChanged([CallerMemberName] string PropName = "") | |||||
{ | { | ||||
get { return _LoopButton; } | |||||
set | |||||
{ | |||||
_LoopButton = value; | |||||
if (value != "循环跑单") { IsLoop = true; LoopColor = new SolidColorBrush((System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString("Red")); } | |||||
else { IsLoop = false; LoopColor = new SolidColorBrush((System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString("#00c2f4")); } | |||||
OnStaticPropertyChanged(); | |||||
} | |||||
StaticPropertyChanged?.Invoke(null, new PropertyChangedEventArgs(PropName)); | |||||
} | } | ||||
private static string _LoopButton = "循环跑单"; | |||||
public static Brush LoopColor { get { return _LoopColor; } set { _LoopColor = value; OnStaticPropertyChanged(); } } | |||||
private static Brush _LoopColor = new SolidColorBrush((System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString("#00c2f4")); | |||||
public static string LoopOrderButtonContent { get { return _mLoopOrderButtonContent; } set { _mLoopOrderButtonContent = value; OnStaticPropertyChanged(); } } | |||||
private static string _mLoopOrderButtonContent = "循环跑单"; | |||||
} | } | ||||
@@ -0,0 +1,26 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
using HBLConsole.Model; | |||||
using HBLConsole.Service; | |||||
namespace HBLConsole.ViewModel | |||||
{ | |||||
public class ParSetViewModel : ViewModelBase | |||||
{ | |||||
public ParSetViewModel() | |||||
{ | |||||
WindowName = "参数设置"; | |||||
} | |||||
public bool IsSelected | |||||
{ | |||||
get { return SystemHelper.GetInstance.IsAutoStart(); } | |||||
set { SystemHelper.GetInstance.AutoStart(value); OnPropertyChanged(); } | |||||
} | |||||
} | |||||
} |
@@ -107,7 +107,7 @@ namespace HBLConsole.ViewModel | |||||
private void Test() | private void Test() | ||||
{ | { | ||||
#if test | #if test | ||||
ThreadOperate.GetInstance.StartLong(new Action(() => | |||||
ThreadManage.GetInstance.StartLong(new Action(() => | |||||
{ | { | ||||
while (morkOrderPushes.Count > 0) | while (morkOrderPushes.Count > 0) | ||||
{ | { | ||||
@@ -188,7 +188,12 @@ namespace HBLConsole.ViewModel | |||||
break; | break; | ||||
case ORDER_STATUS.COMPLETED_TAKE: | case ORDER_STATUS.COMPLETED_TAKE: | ||||
var re = WaitTakeMeal.FirstOrDefault(p => p.OrderPush.SuborderId == orderStatusChange.SuborderId); | var re = WaitTakeMeal.FirstOrDefault(p => p.OrderPush.SuborderId == orderStatusChange.SuborderId); | ||||
if (re != null) WaitTakeMeal.Remove(re); | |||||
if (re != null) | |||||
{ | |||||
WaitTakeMeal.Remove(re); | |||||
Json<MorkOrderPushPar>.Data.morkOrderPushes.Remove(re); | |||||
} | |||||
break; | break; | ||||
default: | default: | ||||
break; | break; | ||||