@@ -22,14 +22,14 @@ namespace BPASmartClient.Business | |||||
InternetInfo.InitConfig(); | InternetInfo.InitConfig(); | ||||
//业务插件初始化 | //业务插件初始化 | ||||
Plugin.GetInstance().Init(); | Plugin.GetInstance().Init(); | ||||
//设备开启 | //设备开启 | ||||
Plugin.GetInstance().GetPlugin<DeviceMgr>().StartService(); | Plugin.GetInstance().GetPlugin<DeviceMgr>().StartService(); | ||||
MessageLog.GetInstance.InfoNotify = new Action<string>((msg => | |||||
{ | |||||
Console.WriteLine(msg); | |||||
})); | |||||
//MessageLog.GetInstance.InfoNotify = new Action<string>((msg => | |||||
//{ | |||||
// Console.WriteLine(msg); | |||||
//})); | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -1,4 +1,5 @@ | |||||
using BPA.Message; | |||||
//#define test | |||||
using BPA.Message; | |||||
using BPA.Message.Enum; | using BPA.Message.Enum; | ||||
using BPASmartClient.EventBus; | using BPASmartClient.EventBus; | ||||
using BPASmartClient.Helper; | using BPASmartClient.Helper; | ||||
@@ -28,12 +29,32 @@ namespace BPASmartClient.Business | |||||
private bool running = false; | private bool running = false; | ||||
//设备管理 | //设备管理 | ||||
private DeviceMgr deviceMgr; | private DeviceMgr deviceMgr; | ||||
ConcurrentQueue<MorkOrderPush> morkOrderPushes = new ConcurrentQueue<MorkOrderPush>(); | |||||
/// <summary> | /// <summary> | ||||
/// 初始化 | /// 初始化 | ||||
/// </summary> | /// </summary> | ||||
public void Initialize() | public void Initialize() | ||||
{ | { | ||||
deviceMgr = Plugin.GetInstance().GetPlugin<DeviceMgr>(); | deviceMgr = Plugin.GetInstance().GetPlugin<DeviceMgr>(); | ||||
#if test | |||||
ThreadManage.GetInstance().StartLong(new Action(() => | |||||
{ | |||||
while (morkOrderPushes.Count > 0) | |||||
{ | |||||
if (morkOrderPushes.TryDequeue(out MorkOrderPush mork)) | |||||
{ | |||||
Thread.Sleep(3000); | |||||
new OrderStatusChangedEvent() { Status = ORDER_STATUS.COOKING, SubOrderId = mork.SuborderId }.Publish(); | |||||
Thread.Sleep(5000); | |||||
new OrderStatusChangedEvent() { Status = ORDER_STATUS.COMPLETED_COOK, SubOrderId = mork.SuborderId }.Publish(); | |||||
Thread.Sleep(5000); | |||||
new OrderStatusChangedEvent() { Status = ORDER_STATUS.COMPLETED_TAKE, SubOrderId = mork.SuborderId }.Publish(); | |||||
Thread.Sleep(2000); | |||||
} | |||||
} | |||||
Thread.Sleep(1000); | |||||
}), "sim order"); | |||||
#endif | |||||
} | } | ||||
public void Start() | public void Start() | ||||
@@ -84,48 +105,13 @@ namespace BPASmartClient.Business | |||||
{ | { | ||||
if (orders[deviceId].TryDequeue(out MorkOrderPush temp)) | if (orders[deviceId].TryDequeue(out MorkOrderPush temp)) | ||||
{ | { | ||||
#if test | |||||
morkOrderPushes.Enqueue(temp); | |||||
#endif | |||||
var orderEvent = DoOrderEvent.Make(temp); | var orderEvent = DoOrderEvent.Make(temp); | ||||
orderEvent.Id = device.DeviceId; | orderEvent.Id = device.DeviceId; | ||||
orderEvent.Publish(); | orderEvent.Publish(); | ||||
#region 添加订单 | |||||
ObservableCollection<MorkOrder> observableCollection = new ObservableCollection<MorkOrder>(); | |||||
observableCollection.Add(new MorkOrder() | |||||
{ | |||||
OrderStatus = ORDER_STATUS.WAIT | |||||
}); | |||||
var res = Json<KeepDataBase>.Data.orderLists.FirstOrDefault(p => p.DeviceId == deviceId.ToString()); | |||||
if (res == null) | |||||
{ | |||||
Json<KeepDataBase>.Data.orderLists.Add(new OrderData() | |||||
{ | |||||
DeviceId = device.ToString(), | |||||
IsAllSelect = true, | |||||
morkOrderPushes = observableCollection | |||||
}); | |||||
} | |||||
else | |||||
{ | |||||
res.morkOrderPushes.Add(new MorkOrder() { OrderPush = temp }); | |||||
} | |||||
#endregion | |||||
//Json<KeepDataBase>.Data.orderLists.Add(new OrderData() | |||||
//{ | |||||
// DeviceId = device.ToString(), | |||||
// IsAllSelect = true, | |||||
// morkOrderPushes = observableCollection | |||||
//}); | |||||
//Json<KeepDataBase>.Data.orderLists.Add(new OrderData() | |||||
//{ | |||||
// IsSelected = true, | |||||
// OrderPush = temp, | |||||
// OrderStatus = BPA.Message.Enum.ORDER_STATUS.WAIT | |||||
//}); | |||||
ActionManage.GetInstance.Send("AddOrder", new object[] { temp, device }); | |||||
} | } | ||||
} | } | ||||
Thread.Sleep(50); | Thread.Sleep(50); | ||||
@@ -149,7 +135,8 @@ namespace BPASmartClient.Business | |||||
MessageLog.GetInstance.ShowEx(ex.ToString()); | MessageLog.GetInstance.ShowEx(ex.ToString()); | ||||
} | } | ||||
var res = JsonConvert.DeserializeObject<OrderStatusRsp>(result); | var res = JsonConvert.DeserializeObject<OrderStatusRsp>(result); | ||||
MessageLog.GetInstance.ShowEx(string.Format("订单状态改变,调用API执行结果{0}", res == null ? false : res.isSuccess)); | |||||
ActionManage.GetInstance.Send("OrderStatusChange", orderStatusChangedEvent); | |||||
MessageLog.GetInstance.Show(string.Format("订单状态改变,调用API执行结果{0}", res == null ? false : res.isSuccess)); | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -57,6 +57,7 @@ namespace BPASmartClient.Business | |||||
{ | { | ||||
wholeDeviceStatus[device.DeviceId] = device.Status.GetStatus(); | wholeDeviceStatus[device.DeviceId] = device.Status.GetStatus(); | ||||
deviceStatus.Healthy = device.IsHealth ? BPA.Message.Enum.DeviceHealthy.Health : BPA.Message.Enum.DeviceHealthy.UnHealth; | deviceStatus.Healthy = device.IsHealth ? BPA.Message.Enum.DeviceHealthy.Health : BPA.Message.Enum.DeviceHealthy.UnHealth; | ||||
deviceStatus.DeviceType = device.DeviceType; | |||||
var msg = BPAPackage.Make(deviceStatus, device.DeviceId, device.DeviceType); | var msg = BPAPackage.Make(deviceStatus, device.DeviceId, device.DeviceType); | ||||
mqttMgr.Publish(TopicDefine.GetInstance().PushHeartbeatTopics[device.DeviceType], msg.Serialize()); | mqttMgr.Publish(TopicDefine.GetInstance().PushHeartbeatTopics[device.DeviceType], msg.Serialize()); | ||||
} | } | ||||
@@ -70,6 +71,6 @@ namespace BPASmartClient.Business | |||||
running = false; | running = false; | ||||
} | } | ||||
} | } | ||||
} | } |
@@ -0,0 +1,42 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
using System.Data; | |||||
using System.Windows.Data; | |||||
using System.Globalization; | |||||
using System.Text.RegularExpressions; | |||||
namespace BPASmartClient.CustomResource.Converters | |||||
{ | |||||
public class StringToIconConverter : IValueConverter | |||||
{ | |||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | |||||
{ | |||||
if (value != null) | |||||
{ | |||||
return Regex.Unescape(StringToUnicode(value.ToString())); | |||||
} | |||||
return value; | |||||
} | |||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | |||||
{ | |||||
throw new NotImplementedException(); | |||||
} | |||||
/// <summary> | |||||
/// 字符串转为UniCode码字符串 | |||||
/// </summary> | |||||
public static string StringToUnicode(string s) | |||||
{ | |||||
if (!string.IsNullOrEmpty(s)) | |||||
{ | |||||
//这里把格式 转为 \ue625 | |||||
return s.Replace(@"&#x", @"\u").Replace(";", ""); | |||||
} | |||||
return s; | |||||
} | |||||
} | |||||
} |
@@ -1,4 +1,8 @@ | |||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> | |||||
<ResourceDictionary | |||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||||
xmlns:con="clr-namespace:BPASmartClient.CustomResource.Converters"> | |||||
<!-- 文本框的字体颜色 --> | <!-- 文本框的字体颜色 --> | ||||
<SolidColorBrush x:Key="TextBlockForeground" Color="#9934F7F7" /> | <SolidColorBrush x:Key="TextBlockForeground" Color="#9934F7F7" /> | ||||
<!--<con:StringToIconConverter x:Key="StringToIconConverter"/>--> | |||||
</ResourceDictionary> | </ResourceDictionary> |
@@ -557,93 +557,6 @@ | |||||
<SolidColorBrush x:Key="DisabledBrush" Color="#A5FFFFFF" /> | <SolidColorBrush x:Key="DisabledBrush" Color="#A5FFFFFF" /> | ||||
<ControlTemplate x:Key="DropDownButtonTemplate" TargetType="{x:Type Button}"> | <ControlTemplate x:Key="DropDownButtonTemplate" TargetType="{x:Type Button}"> | ||||
<Grid> | <Grid> | ||||
<VisualStateManager.VisualStateGroups> | |||||
<VisualStateGroup x:Name="CommonStates"> | |||||
<VisualStateGroup.Transitions> | |||||
<VisualTransition GeneratedDuration="0" /> | |||||
<VisualTransition GeneratedDuration="0:0:0.1" To="MouseOver" /> | |||||
<VisualTransition GeneratedDuration="0:0:0.1" To="Pressed" /> | |||||
</VisualStateGroup.Transitions> | |||||
<VisualState x:Name="Normal" /> | |||||
<VisualState x:Name="MouseOver"> | |||||
<Storyboard> | |||||
<ColorAnimation | |||||
Storyboard.TargetName="Background" | |||||
Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)" | |||||
To="#FF448DCA" | |||||
Duration="0" /> | |||||
<ColorAnimationUsingKeyFrames | |||||
BeginTime="0" | |||||
Storyboard.TargetName="BackgroundGradient" | |||||
Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[3].(GradientStop.Color)" | |||||
Duration="00:00:00.001"> | |||||
<SplineColorKeyFrame KeyTime="0" Value="#7FFFFFFF" /> | |||||
</ColorAnimationUsingKeyFrames> | |||||
<ColorAnimationUsingKeyFrames | |||||
BeginTime="0" | |||||
Storyboard.TargetName="BackgroundGradient" | |||||
Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[2].(GradientStop.Color)" | |||||
Duration="00:00:00.001"> | |||||
<SplineColorKeyFrame KeyTime="0" Value="#CCFFFFFF" /> | |||||
</ColorAnimationUsingKeyFrames> | |||||
<ColorAnimationUsingKeyFrames | |||||
BeginTime="0" | |||||
Storyboard.TargetName="BackgroundGradient" | |||||
Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[1].(GradientStop.Color)" | |||||
Duration="00:00:00.001"> | |||||
<SplineColorKeyFrame KeyTime="0" Value="#F2FFFFFF" /> | |||||
</ColorAnimationUsingKeyFrames> | |||||
</Storyboard> | |||||
</VisualState> | |||||
<VisualState x:Name="Pressed"> | |||||
<Storyboard> | |||||
<ColorAnimationUsingKeyFrames | |||||
BeginTime="0" | |||||
Storyboard.TargetName="Background" | |||||
Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)" | |||||
Duration="00:00:00.001"> | |||||
<SplineColorKeyFrame KeyTime="0" Value="#FF448DCA" /> | |||||
</ColorAnimationUsingKeyFrames> | |||||
<DoubleAnimationUsingKeyFrames | |||||
BeginTime="0" | |||||
Storyboard.TargetName="Highlight" | |||||
Storyboard.TargetProperty="(UIElement.Opacity)" | |||||
Duration="00:00:00.001"> | |||||
<SplineDoubleKeyFrame KeyTime="0" Value="1" /> | |||||
</DoubleAnimationUsingKeyFrames> | |||||
<ColorAnimationUsingKeyFrames | |||||
BeginTime="0" | |||||
Storyboard.TargetName="BackgroundGradient" | |||||
Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[1].(GradientStop.Color)" | |||||
Duration="00:00:00.001"> | |||||
<SplineColorKeyFrame KeyTime="0" Value="#EAFFFFFF" /> | |||||
</ColorAnimationUsingKeyFrames> | |||||
<ColorAnimationUsingKeyFrames | |||||
BeginTime="0" | |||||
Storyboard.TargetName="BackgroundGradient" | |||||
Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[2].(GradientStop.Color)" | |||||
Duration="00:00:00.001"> | |||||
<SplineColorKeyFrame KeyTime="0" Value="#C6FFFFFF" /> | |||||
</ColorAnimationUsingKeyFrames> | |||||
<ColorAnimationUsingKeyFrames | |||||
BeginTime="0" | |||||
Storyboard.TargetName="BackgroundGradient" | |||||
Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[3].(GradientStop.Color)" | |||||
Duration="00:00:00.001"> | |||||
<SplineColorKeyFrame KeyTime="0" Value="#6BFFFFFF" /> | |||||
</ColorAnimationUsingKeyFrames> | |||||
<ColorAnimationUsingKeyFrames | |||||
BeginTime="0" | |||||
Storyboard.TargetName="BackgroundGradient" | |||||
Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[0].(GradientStop.Color)" | |||||
Duration="00:00:00.001"> | |||||
<SplineColorKeyFrame KeyTime="0" Value="#F4FFFFFF" /> | |||||
</ColorAnimationUsingKeyFrames> | |||||
</Storyboard> | |||||
</VisualState> | |||||
<VisualState x:Name="Disabled" /> | |||||
</VisualStateGroup> | |||||
</VisualStateManager.VisualStateGroups> | |||||
<Grid | <Grid | ||||
Width="19" | Width="19" | ||||
Height="18" | Height="18" | ||||
@@ -764,6 +677,93 @@ | |||||
Source="/BPASmartClient.CustomResource;component/Image/日历.png" /> | Source="/BPASmartClient.CustomResource;component/Image/日历.png" /> | ||||
</Grid> | </Grid> | ||||
<VisualStateManager.VisualStateGroups> | |||||
<VisualStateGroup x:Name="CommonStates"> | |||||
<VisualStateGroup.Transitions> | |||||
<VisualTransition GeneratedDuration="0" /> | |||||
<VisualTransition GeneratedDuration="0:0:0.1" To="MouseOver" /> | |||||
<VisualTransition GeneratedDuration="0:0:0.1" To="Pressed" /> | |||||
</VisualStateGroup.Transitions> | |||||
<VisualState x:Name="Normal" /> | |||||
<VisualState x:Name="MouseOver"> | |||||
<Storyboard> | |||||
<ColorAnimation | |||||
Storyboard.TargetName="Background" | |||||
Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)" | |||||
To="#FF448DCA" | |||||
Duration="0" /> | |||||
<ColorAnimationUsingKeyFrames | |||||
BeginTime="0" | |||||
Storyboard.TargetName="BackgroundGradient" | |||||
Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[3].(GradientStop.Color)" | |||||
Duration="00:00:00.001"> | |||||
<SplineColorKeyFrame KeyTime="0" Value="#7FFFFFFF" /> | |||||
</ColorAnimationUsingKeyFrames> | |||||
<ColorAnimationUsingKeyFrames | |||||
BeginTime="0" | |||||
Storyboard.TargetName="BackgroundGradient" | |||||
Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[2].(GradientStop.Color)" | |||||
Duration="00:00:00.001"> | |||||
<SplineColorKeyFrame KeyTime="0" Value="#CCFFFFFF" /> | |||||
</ColorAnimationUsingKeyFrames> | |||||
<ColorAnimationUsingKeyFrames | |||||
BeginTime="0" | |||||
Storyboard.TargetName="BackgroundGradient" | |||||
Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[1].(GradientStop.Color)" | |||||
Duration="00:00:00.001"> | |||||
<SplineColorKeyFrame KeyTime="0" Value="#F2FFFFFF" /> | |||||
</ColorAnimationUsingKeyFrames> | |||||
</Storyboard> | |||||
</VisualState> | |||||
<VisualState x:Name="Pressed"> | |||||
<Storyboard> | |||||
<ColorAnimationUsingKeyFrames | |||||
BeginTime="0" | |||||
Storyboard.TargetName="Background" | |||||
Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)" | |||||
Duration="00:00:00.001"> | |||||
<SplineColorKeyFrame KeyTime="0" Value="#FF448DCA" /> | |||||
</ColorAnimationUsingKeyFrames> | |||||
<DoubleAnimationUsingKeyFrames | |||||
BeginTime="0" | |||||
Storyboard.TargetName="Highlight" | |||||
Storyboard.TargetProperty="(UIElement.Opacity)" | |||||
Duration="00:00:00.001"> | |||||
<SplineDoubleKeyFrame KeyTime="0" Value="1" /> | |||||
</DoubleAnimationUsingKeyFrames> | |||||
<ColorAnimationUsingKeyFrames | |||||
BeginTime="0" | |||||
Storyboard.TargetName="BackgroundGradient" | |||||
Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[1].(GradientStop.Color)" | |||||
Duration="00:00:00.001"> | |||||
<SplineColorKeyFrame KeyTime="0" Value="#EAFFFFFF" /> | |||||
</ColorAnimationUsingKeyFrames> | |||||
<ColorAnimationUsingKeyFrames | |||||
BeginTime="0" | |||||
Storyboard.TargetName="BackgroundGradient" | |||||
Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[2].(GradientStop.Color)" | |||||
Duration="00:00:00.001"> | |||||
<SplineColorKeyFrame KeyTime="0" Value="#C6FFFFFF" /> | |||||
</ColorAnimationUsingKeyFrames> | |||||
<ColorAnimationUsingKeyFrames | |||||
BeginTime="0" | |||||
Storyboard.TargetName="BackgroundGradient" | |||||
Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[3].(GradientStop.Color)" | |||||
Duration="00:00:00.001"> | |||||
<SplineColorKeyFrame KeyTime="0" Value="#6BFFFFFF" /> | |||||
</ColorAnimationUsingKeyFrames> | |||||
<ColorAnimationUsingKeyFrames | |||||
BeginTime="0" | |||||
Storyboard.TargetName="BackgroundGradient" | |||||
Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[0].(GradientStop.Color)" | |||||
Duration="00:00:00.001"> | |||||
<SplineColorKeyFrame KeyTime="0" Value="#F4FFFFFF" /> | |||||
</ColorAnimationUsingKeyFrames> | |||||
</Storyboard> | |||||
</VisualState> | |||||
<VisualState x:Name="Disabled" /> | |||||
</VisualStateGroup> | |||||
</VisualStateManager.VisualStateGroups> | |||||
</Grid> | </Grid> | ||||
</ControlTemplate> | </ControlTemplate> | ||||
</Grid.Resources> | </Grid.Resources> | ||||
@@ -2,6 +2,7 @@ | |||||
x:Class="BPASmartClient.CustomResource.UserControls.IcoButton" | x:Class="BPASmartClient.CustomResource.UserControls.IcoButton" | ||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||||
xmlns:con="clr-namespace:BPASmartClient.CustomResource.Converters" | |||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||||
xmlns:local="clr-namespace:BPASmartClient.CustomResource.UserControls" | xmlns:local="clr-namespace:BPASmartClient.CustomResource.UserControls" | ||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||||
@@ -52,35 +53,47 @@ | |||||
</Setter> | </Setter> | ||||
</Style> | </Style> | ||||
</UserControl.Resources>--> | </UserControl.Resources>--> | ||||
<UserControl.Resources> | |||||
<con:StringToIconConverter x:Key="StringToIconConverter" /> | |||||
</UserControl.Resources> | |||||
<Grid> | <Grid> | ||||
<!--<Canvas Width="auto" Height="auto">--> | <!--<Canvas Width="auto" Height="auto">--> | ||||
<Button Name="a"> | |||||
<!--<TextBlock | |||||
x:Name="tbx" | |||||
FontFamily="../Fonts/#iconfont" | |||||
Text="{Binding Path=IcoText, Mode=TwoWay, Converter={StaticResource StringToIconConverter}}" />--> | |||||
<TextBlock | |||||
x:Name="tbx" | |||||
FontSize="14" | |||||
Foreground="Red" /> | |||||
<!--<Button Name="a"> | |||||
<Button.Style> | <Button.Style> | ||||
<Style TargetType="Button"> | <Style TargetType="Button"> | ||||
<Setter Property="FontFamily" Value="../Fonts/#iconfont" /> | |||||
--> | |||||
<!--<Setter Property="FontFamily" Value="../Fonts/#iconfont" />--> | |||||
<!-- | |||||
<Setter Property="Template"> | <Setter Property="Template"> | ||||
<Setter.Value> | <Setter.Value> | ||||
<ControlTemplate TargetType="Button"> | <ControlTemplate TargetType="Button"> | ||||
<Border | <Border | ||||
x:Name="br" | |||||
Background="Transparent" | |||||
BorderBrush="#FF19B7EC" | |||||
BorderThickness="2"> | |||||
x:Name="br" | |||||
Background="Transparent" | |||||
BorderBrush="#FF19B7EC" | |||||
BorderThickness="2"> | |||||
<StackPanel | <StackPanel | ||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
Orientation="Horizontal"> | |||||
<TextBlock | |||||
Margin="0,0,5,0" | |||||
FontFamily="../Fonts/#iconfont" | |||||
Text="我是图标" /> | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
Orientation="Horizontal"> | |||||
--> | |||||
<!--<TextBlock FontFamily="../Fonts/#iconfont" Text="{Binding Path=IcoText, Converter={StaticResource StringToIconConverter}}" />--> | |||||
<!-- | |||||
<ContentControl | <ContentControl | ||||
Margin="10,0,5,0" | |||||
VerticalAlignment="Center" | |||||
Content="{TemplateBinding Content}" | |||||
Foreground="{TemplateBinding Foreground}" /> | |||||
Margin="10,0,5,0" | |||||
VerticalAlignment="Center" | |||||
Content="{TemplateBinding Content}" | |||||
Foreground="{TemplateBinding Foreground}" /> | |||||
</StackPanel> | </StackPanel> | ||||
</Border> | </Border> | ||||
<ControlTemplate.Triggers> | <ControlTemplate.Triggers> | ||||
@@ -98,7 +111,7 @@ | |||||
</Setter> | </Setter> | ||||
</Style> | </Style> | ||||
</Button.Style> | </Button.Style> | ||||
</Button> | |||||
</Button>--> | |||||
<!--</Canvas>--> | <!--</Canvas>--> | ||||
</Grid> | </Grid> | ||||
</UserControl> | </UserControl> |
@@ -32,7 +32,7 @@ namespace BPASmartClient.CustomResource.UserControls | |||||
private void Refresh() | private void Refresh() | ||||
{ | { | ||||
tbx.Text = this.IcoText; | |||||
} | } | ||||
public int BorderThickness | public int BorderThickness | ||||
@@ -52,7 +52,7 @@ namespace BPASmartClient.CustomResource.UserControls | |||||
} | } | ||||
public static readonly DependencyProperty IcoTextProperty = | public static readonly DependencyProperty IcoTextProperty = | ||||
DependencyProperty.Register("IcoText", typeof(string), typeof(IcoButton), | DependencyProperty.Register("IcoText", typeof(string), typeof(IcoButton), | ||||
new PropertyMetadata("", new PropertyChangedCallback(OnPropertyChanged))); | |||||
new PropertyMetadata(string.Empty, new PropertyChangedCallback(OnPropertyChanged))); | |||||
} | } | ||||
} | } |
@@ -14,6 +14,7 @@ namespace BPASmartClient.Helper | |||||
public static ActionManage GetInstance => _Instance ?? (_Instance = new ActionManage()); | public static ActionManage GetInstance => _Instance ?? (_Instance = new ActionManage()); | ||||
private ActionManage() { } | private ActionManage() { } | ||||
//private static ConcurrentDictionary<string, delegate> actions = new ConcurrentDictionary<string, delegate>(); | |||||
private static ConcurrentDictionary<string, Delegation> actions = new ConcurrentDictionary<string, Delegation>(); | private static ConcurrentDictionary<string, Delegation> actions = new ConcurrentDictionary<string, Delegation>(); | ||||
static readonly object SendLock = new object(); | static readonly object SendLock = new object(); | ||||
@@ -40,11 +41,18 @@ namespace BPASmartClient.Helper | |||||
{ | { | ||||
lock (SendLock) | lock (SendLock) | ||||
if (actions.ContainsKey(key)) actions[key].ActionPar.Invoke(par, Callback); | if (actions.ContainsKey(key)) actions[key].ActionPar.Invoke(par, Callback); | ||||
//if (actions[key].ActionPar != null) | |||||
//{ | |||||
// actions[key].ActionPar(par); | |||||
// if (Callback != null) Callback(); | |||||
//} | |||||
} | |||||
/// <summary> | |||||
/// 执行注册过的委托 | |||||
/// </summary> | |||||
/// <param name="key">注册委托的key</param> | |||||
/// <param name="par">委托参数</param> | |||||
/// <param name="Callback">委托回调</param> | |||||
public void Send(string key, object[] par, Action Callback = null) | |||||
{ | |||||
lock (SendLock) | |||||
if (actions.ContainsKey(key)) actions[key].ActionPars.Invokes(par, Callback); | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -89,6 +97,9 @@ namespace BPASmartClient.Helper | |||||
if (action is Action<object> actionObj) | if (action is Action<object> actionObj) | ||||
actions.TryAdd(key, new Delegation() { ActionPar = actionObj }); | actions.TryAdd(key, new Delegation() { ActionPar = actionObj }); | ||||
if (action is Action<object[]> actionObjs) | |||||
actions.TryAdd(key, new Delegation() { ActionPars = actionObjs }); | |||||
if (action is Func<object> funcObj) | if (action is Func<object> funcObj) | ||||
actions.TryAdd(key, new Delegation() { FuncObj = funcObj }); | actions.TryAdd(key, new Delegation() { FuncObj = funcObj }); | ||||
@@ -110,10 +121,13 @@ namespace BPASmartClient.Helper | |||||
/// </summary> | /// </summary> | ||||
public Action<object> ActionPar { get; set; } | public Action<object> ActionPar { get; set; } | ||||
/// <summary> | /// <summary> | ||||
/// 带参数的委托 | |||||
/// </summary> | |||||
public Action<object[]> ActionPars { get; set; } | |||||
/// <summary> | |||||
/// 无参数的委托 | /// 无参数的委托 | ||||
/// </summary> | /// </summary> | ||||
public Action ActionBus { get; set; } | public Action ActionBus { get; set; } | ||||
public Action CallBack { get; set; } | |||||
/// <summary> | /// <summary> | ||||
/// 有返回值的委托 | /// 有返回值的委托 | ||||
/// </summary> | /// </summary> | ||||
@@ -63,6 +63,15 @@ namespace BPASmartClient.Helper | |||||
} | } | ||||
} | } | ||||
public static void Invokes(this Action<object[]> action, object[] par, Action callback) | |||||
{ | |||||
if (action != null) | |||||
{ | |||||
action(par); | |||||
if (callback != null) callback(); | |||||
} | |||||
} | |||||
///// <summary> | ///// <summary> | ||||
@@ -86,7 +86,6 @@ namespace BPASmartClient.Helper | |||||
/// <param name="key"></param> | /// <param name="key"></param> | ||||
public void Start(Action action, string key, bool isRestart = true) | public void Start(Action action, string key, bool isRestart = true) | ||||
{ | { | ||||
MessageLog.GetInstance.Show($"线程 【{key}】启动"); | |||||
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(() => | ||||
{ | { | ||||
@@ -96,7 +95,7 @@ namespace BPASmartClient.Helper | |||||
} | } | ||||
catch (Exception ex) | catch (Exception ex) | ||||
{ | { | ||||
MessageLog.GetInstance.Show($"线程 【{key}】运行发生异常"); | |||||
MessageLog.GetInstance.ShowEx(ex.ToString()); | |||||
if (isRestart) | if (isRestart) | ||||
{ | { | ||||
MessageLog.GetInstance.Show($"线程 【{key}】正在重启"); | MessageLog.GetInstance.Show($"线程 【{key}】正在重启"); | ||||
@@ -104,11 +103,16 @@ namespace BPASmartClient.Helper | |||||
Threads.TryRemove(guid + key, out Task item2); | Threads.TryRemove(guid + key, out Task item2); | ||||
Start(action, key, isRestart); | Start(action, key, isRestart); | ||||
} | } | ||||
else | |||||
{ | |||||
MessageLog.GetInstance.Show($"线程 【{key}】运行发生异常"); | |||||
} | |||||
} | } | ||||
}), CancellationTokenSources[guid + key].Token).ContinueWith(new Action<Task, object>((t, o) => | }), CancellationTokenSources[guid + key].Token).ContinueWith(new Action<Task, object>((t, o) => | ||||
{ | { | ||||
ThreadStatus(t, o.ToString()); | ThreadStatus(t, o.ToString()); | ||||
}), guid + key)); | }), guid + key)); | ||||
MessageLog.GetInstance.Show($"启动线程 【{key}】"); | |||||
if (!result) MessageLog.GetInstance.Show($"【{key}】任务已存在,请检查 TaskName"); | if (!result) MessageLog.GetInstance.Show($"【{key}】任务已存在,请检查 TaskName"); | ||||
} | } | ||||
@@ -22,7 +22,7 @@ namespace BPASmartClient.PLC | |||||
{ | { | ||||
plcReadParameters = PLCReadParameter.DeSerialize(PLCReadAddress); | plcReadParameters = PLCReadParameter.DeSerialize(PLCReadAddress); | ||||
modbusTcp.ModbusTcpConnect(IpAddress, Port);//PLC 设备连接 | |||||
Task.Run(new Action(() => { modbusTcp.ModbusTcpConnect(IpAddress, Port); })); //PLC 设备连接 | |||||
ThreadManage.GetInstance().StartLong(new Action(() => | ThreadManage.GetInstance().StartLong(new Action(() => | ||||
{ | { | ||||
@@ -5,7 +5,7 @@ using System.Collections.Generic; | |||||
using System.Linq; | using System.Linq; | ||||
using System.Net.Sockets; | using System.Net.Sockets; | ||||
using System.Threading; | using System.Threading; | ||||
using System.Threading.Tasks; | |||||
namespace BPASmartClient.Modbus | namespace BPASmartClient.Modbus | ||||
{ | { | ||||
@@ -44,8 +44,6 @@ namespace BPASmartClient.Modbus | |||||
master.Transport.ReadTimeout = 2000;//读取超时时间 | master.Transport.ReadTimeout = 2000;//读取超时时间 | ||||
master.Transport.WriteTimeout = 2000;//写入超时时间 | master.Transport.WriteTimeout = 2000;//写入超时时间 | ||||
master.Transport.Retries = 10;//重试次数 | master.Transport.Retries = 10;//重试次数 | ||||
//ActionManage.GetInstance.Send("ConnectOk"); | |||||
//ActionManage.GetInstance.Send($"{GVL.GeneralConfig.DeviceType.ToString()}/ConnectOk"); | |||||
MessageLog.GetInstance.Show($"设备【{ip}:{port}】连接成功"); | MessageLog.GetInstance.Show($"设备【{ip}:{port}】连接成功"); | ||||
} | } | ||||
@@ -97,7 +95,7 @@ namespace BPASmartClient.Modbus | |||||
} | } | ||||
} | } | ||||
} | } | ||||
else if (address.ToUpper().Contains("VW") && address.Length > 3) | |||||
else if (address.ToUpper().Contains("VW") && address.Length >= 3) | |||||
{ | { | ||||
var res = address.Substring(2); | var res = address.Substring(2); | ||||
if (res != null && int.TryParse(res, out int tempAddress)) | if (res != null && int.TryParse(res, out int tempAddress)) | ||||
@@ -154,6 +152,12 @@ namespace BPASmartClient.Modbus | |||||
action(bools); | action(bools); | ||||
} | } | ||||
} | } | ||||
else if (result is bool bl) | |||||
{ | |||||
List<bool> boolLists = new List<bool>(); | |||||
boolLists.Add(bl); | |||||
action(boolLists.ToArray()); | |||||
} | |||||
} | } | ||||
} | } | ||||
@@ -103,74 +103,27 @@ namespace BPASmartClient.MorkS | |||||
}); | }); | ||||
} | } | ||||
private void ReadPLCData() | |||||
private void GetStatus(string key, Action<bool[]> action) | |||||
{ | { | ||||
ThreadManage.GetInstance().StartLong(new Action(() => | |||||
if (peripheralStatus.ContainsKey(key)) | |||||
{ | { | ||||
var bools = (bool[])peripheralStatus["M0.3"]; | |||||
mORKS.RobotTakeNoodle = bools[0]; | |||||
mORKS.RobotOutMeal = bools[1]; | |||||
mORKS.MoveTurntable = bools[2]; | |||||
bools = (bool[])peripheralStatus["M100.0"]; | |||||
mORKS.InitComplete = bools[0]; | |||||
mORKS.TakeBowlIdle = bools[1]; | |||||
mORKS.TemperatureReached = bools[2]; | |||||
mORKS.AllowFallNoodle = bools[3]; | |||||
mORKS.RbTakeNoodleComplete = bools[4]; | |||||
mORKS.RbFallNoodleComplete = bools[5]; | |||||
mORKS.RbOutMealComplete = bools[6]; | |||||
mORKS.RobotIdle = bools[7]; | |||||
mORKS.TakeMealDetect = bools[8]; | |||||
mORKS.MissingBowl = bools[9]; | |||||
Initing = bools[10]; | |||||
mORKS.TurntableLowerLimit = bools[11]; | |||||
mORKS.MissingBowlSignal2 = bools[12]; | |||||
mORKS.TurntableUpLimit = bools[13]; | |||||
mORKS.FeedComplete = bools[14]; | |||||
mORKS.TurntableMoveInPlace = bools[15]; | |||||
bools = (bool[])peripheralStatus["M235.0"]; | |||||
mORKS.Error = bools[0]; | |||||
bools = (bool[])peripheralStatus["M102.0"]; | |||||
for (int i = 0; i < 6; i++) | |||||
{ | |||||
mORKS.NoodleCookerStatus[i] = bools[i]; | |||||
} | |||||
mORKS.Feeding = bools[6]; | |||||
bools = (bool[])peripheralStatus["M103.0"]; | |||||
for (int i = 0; i < 6; i++) | |||||
{ | |||||
mORKS.CookNoodlesComplete[i] = bools[i]; | |||||
} | |||||
EventBus.EventBus.GetInstance().Publish(new ReadModel() { Id = DeviceId, Address = "VW372", Length = 1 }, (o) => | |||||
{ | |||||
if (o != null && o.Length > 0 && o[0] is ushort value) | |||||
{ | |||||
mORKS.TurntableFeedbackloc = value; | |||||
} | |||||
}); | |||||
Thread.Sleep(500); | |||||
}), "ReadPLCData", true); | |||||
action((bool[])peripheralStatus[key]); | |||||
} | |||||
} | |||||
#region 替换为内部主动读取 | |||||
/* | |||||
private void ReadPLCData() | |||||
{ | |||||
ThreadManage.GetInstance().StartLong(new Action(() => | ThreadManage.GetInstance().StartLong(new Action(() => | ||||
{ | { | ||||
ReadData("M0.3", 3, new Action<bool[]>((bools) => | |||||
{ | |||||
mORKS.RobotTakeNoodle = bools[0]; | |||||
mORKS.RobotOutMeal = bools[1]; | |||||
mORKS.MoveTurntable = bools[2]; | |||||
})); | |||||
GetStatus("M0.3", new Action<bool[]>((bools) => | |||||
{ | |||||
mORKS.RobotTakeNoodle = bools[0]; | |||||
mORKS.RobotOutMeal = bools[1]; | |||||
mORKS.MoveTurntable = bools[2]; | |||||
})); | |||||
ReadData("M100.0", 16, new Action<bool[]>((bools) => | |||||
GetStatus("M100.0", new Action<bool[]>((bools) => | |||||
{ | { | ||||
mORKS.InitComplete = bools[0]; | mORKS.InitComplete = bools[0]; | ||||
mORKS.TakeBowlIdle = bools[1]; | mORKS.TakeBowlIdle = bools[1]; | ||||
@@ -190,9 +143,13 @@ namespace BPASmartClient.MorkS | |||||
mORKS.TurntableMoveInPlace = bools[15]; | mORKS.TurntableMoveInPlace = bools[15]; | ||||
})); | })); | ||||
ReadData("M235.0", 1, new Action<bool[]>((bools) => { mORKS.Error = bools[0]; })); | |||||
GetStatus("M235.0", new Action<bool[]>((bools) => | |||||
{ | |||||
mORKS.Error = bools[0]; | |||||
})); | |||||
ReadData("M102.0", 7, new Action<bool[]>((bools) => | |||||
GetStatus("M102.0", new Action<bool[]>((bools) => | |||||
{ | { | ||||
for (int i = 0; i < 6; i++) | for (int i = 0; i < 6; i++) | ||||
{ | { | ||||
@@ -201,7 +158,7 @@ namespace BPASmartClient.MorkS | |||||
mORKS.Feeding = bools[6]; | mORKS.Feeding = bools[6]; | ||||
})); | })); | ||||
ReadData("M103.0", 6, new Action<bool[]>((bools) => | |||||
GetStatus("M103.0", new Action<bool[]>((bools) => | |||||
{ | { | ||||
for (int i = 0; i < 6; i++) | for (int i = 0; i < 6; i++) | ||||
{ | { | ||||
@@ -209,25 +166,6 @@ namespace BPASmartClient.MorkS | |||||
} | } | ||||
})); | })); | ||||
//ReadData("M550.0", 20, new Action<bool[]>((bools) => | |||||
//{ | |||||
// //alarm.MachineLeftLowTemperature = bools[0]; | |||||
// //alarm.MachineRightLowTemperature = bools[1]; | |||||
// //alarm.Supply1_LossBowl = bools[2]; | |||||
// //alarm.Supply2_LossBowl = bools[3]; | |||||
// //alarm.Supply1_ErrorOutBowl = bools[4]; | |||||
// //alarm.Supply2_ErrorOutBowl = bools[5]; | |||||
// //alarm.PushBowlCylinderError = bools[6]; | |||||
// //alarm.NoodleMacCommunicateError = bools[7]; | |||||
// //alarm.DosingMacCommunicateError = bools[8]; | |||||
// //alarm.RobotMacCommunicateError = bools[9]; | |||||
// //alarm.RobotInitError = bools[11]; | |||||
// //alarm.RobotUrgentStop = bools[12]; | |||||
// //alarm.RobotNotInRemoteMode = bools[13]; | |||||
// //alarm.RobotNotInReady = bools[14]; | |||||
// //alarm.RobotSelfInException = bools[15]; | |||||
//})); | |||||
EventBus.EventBus.GetInstance().Publish(new ReadModel() { Id = DeviceId, Address = "VW372", Length = 1 }, (o) => | EventBus.EventBus.GetInstance().Publish(new ReadModel() { Id = DeviceId, Address = "VW372", Length = 1 }, (o) => | ||||
{ | { | ||||
if (o != null && o.Length > 0 && o[0] is ushort value) | if (o != null && o.Length > 0 && o[0] is ushort value) | ||||
@@ -238,8 +176,6 @@ namespace BPASmartClient.MorkS | |||||
Thread.Sleep(500); | Thread.Sleep(500); | ||||
}), "ReadPLCData", true); | }), "ReadPLCData", true); | ||||
*/ | |||||
#endregion | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -589,7 +525,7 @@ namespace BPASmartClient.MorkS | |||||
mORKS.CurrentLoc = loc; | mORKS.CurrentLoc = loc; | ||||
mORKS.TurntableInterlock = true; | mORKS.TurntableInterlock = true; | ||||
mORKS.TurntableLocLists.Add(loc); | mORKS.TurntableLocLists.Add(loc); | ||||
WriteData("VW0", loc); | |||||
WriteData("VW2", loc); | |||||
WriteData("M0.5", true); | WriteData("M0.5", true); | ||||
} | } | ||||
@@ -15,11 +15,11 @@ namespace BPASmartClient.ViewModel | |||||
/// <summary> | /// <summary> | ||||
/// 主界面 | /// 主界面 | ||||
/// </summary> | /// </summary> | ||||
public class MainViewModel :ObservableObject | |||||
public class MainViewModel : ObservableObject | |||||
{ | { | ||||
public MainViewModel() | public MainViewModel() | ||||
{ | { | ||||
OrderStatusViewModel.Init(); | |||||
} | } | ||||
} | } | ||||
} | } |
@@ -7,6 +7,8 @@ using System.Threading.Tasks; | |||||
using System.Windows; | using System.Windows; | ||||
using BPA.Message; | using BPA.Message; | ||||
using BPA.Message.Enum; | using BPA.Message.Enum; | ||||
using BPASmartClient.Device; | |||||
using BPASmartClient.EventBus; | |||||
using BPASmartClient.Helper; | using BPASmartClient.Helper; | ||||
using BPASmartClient.Model; | using BPASmartClient.Model; | ||||
using Microsoft.Toolkit.Mvvm.ComponentModel; | using Microsoft.Toolkit.Mvvm.ComponentModel; | ||||
@@ -23,104 +25,115 @@ namespace BPASmartClient.ViewModel | |||||
/// <summary> | /// <summary> | ||||
/// 订单状态列表 | /// 订单状态列表 | ||||
/// </summary> | /// </summary> | ||||
public static ObservableCollection<OrderData> orderStatusLists | |||||
{ | |||||
get { return Json<KeepDataBase>.Data.orderLists; } | |||||
set { Json<KeepDataBase>.Data.orderLists = value; } | |||||
} | |||||
public static ObservableCollection<MorkOrder> orderStatusLists { get; set; } = new ObservableCollection<MorkOrder>(); | |||||
/// <summary> | /// <summary> | ||||
/// 等待取餐列表 | /// 等待取餐列表 | ||||
/// </summary> | /// </summary> | ||||
public static ObservableCollection<OrderData> WaitTakeMeal { get; set; } = new ObservableCollection<OrderData>(); | |||||
public static ObservableCollection<MorkOrder> WaitTakeMeal { get; set; } = new ObservableCollection<MorkOrder>(); | |||||
/// <summary> | /// <summary> | ||||
/// MQTT 大屏取餐通知委托 | /// MQTT 大屏取餐通知委托 | ||||
/// </summary> | /// </summary> | ||||
public void MqttReceive() | |||||
public static void Init() | |||||
{ | { | ||||
//清除订单数据 | //清除订单数据 | ||||
ActionManage.GetInstance.Register(new Action(() => | |||||
{ | |||||
Application.Current.Dispatcher.Invoke(() => | |||||
{ | |||||
orderStatusLists.Clear(); | |||||
WaitTakeMeal.Clear(); | |||||
}); | |||||
}), "ClearOrders"); | |||||
//ActionManage.GetInstance.Register(new Action(() => | |||||
//{ | |||||
// Application.Current.Dispatcher.Invoke(() => | |||||
// { | |||||
// orderStatusLists.Clear(); | |||||
// WaitTakeMeal.Clear(); | |||||
// }); | |||||
//}), "ClearOrders"); | |||||
ActionManage.GetInstance.Register(new Action<object>((o) => | |||||
ActionManage.GetInstance.Register(new Action<object[]>((o) => | |||||
{ | { | ||||
if (o is MorkOrderPush morkOrderpush) | |||||
if (o is object[] obj) | |||||
{ | { | ||||
System.Windows.Application.Current?.Dispatcher.BeginInvoke((Action)delegate | |||||
if (o.Length == 2) | |||||
{ | { | ||||
//var result = orderStatusLists.FirstOrDefault(p => p.OrderPush.SuborderId == morkOrderpush.SuborderId); | |||||
//if (result == null) | |||||
//{ | |||||
// orderStatusLists.Add(new OrderData() | |||||
// { | |||||
// OrderPush = morkOrderpush, | |||||
// OrderStatus = ORDER_STATUS.WAIT, | |||||
// IsSelected = true, | |||||
// StartDate = DateTime.Now.ToString("HH:mm:ss") | |||||
// }); | |||||
//} | |||||
}); | |||||
if (o[0] is MorkOrderPush morkOrderpush && o[1] is IDevice device) | |||||
{ | |||||
ObservableCollection<MorkOrder> observableCollection = new ObservableCollection<MorkOrder>(); | |||||
observableCollection.Add(new MorkOrder() | |||||
{ | |||||
OrderPush = morkOrderpush, | |||||
OrderStatus = ORDER_STATUS.WAIT, | |||||
StartDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), | |||||
}); | |||||
//var res = Json<KeepDataBase>.Data.orderLists.FirstOrDefault(p => p.DeviceId == device.ToString()); | |||||
//if (res == null) | |||||
//{ | |||||
Application.Current?.Dispatcher.BeginInvoke((Action)delegate | |||||
{ | |||||
Json<KeepDataBase>.Data.orderLists.Add(new OrderData() | |||||
{ | |||||
DeviceId = device.ToString(), | |||||
IsAllSelect = true, | |||||
morkOrderPushes = observableCollection, | |||||
}); | |||||
orderStatusLists.Add(new MorkOrder() | |||||
{ | |||||
OrderPush = morkOrderpush, | |||||
OrderStatus = ORDER_STATUS.WAIT, | |||||
StartDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), | |||||
}); | |||||
}); | |||||
//} | |||||
//else | |||||
//{ | |||||
// res.morkOrderPushes.Add(new MorkOrder() { OrderPush = morkOrderpush }); | |||||
//} | |||||
} | |||||
} | |||||
} | } | ||||
}), "AddOrder"); | }), "AddOrder"); | ||||
ActionManage.GetInstance.Register(new Action<object>((o) => | ActionManage.GetInstance.Register(new Action<object>((o) => | ||||
{ | { | ||||
if (o is OrderStatusChange orderStatusChange) | |||||
if (o is OrderStatusChangedEvent orderStatusChange) | |||||
{ | { | ||||
Application.Current?.Dispatcher.BeginInvoke((Action)delegate | |||||
int index = Array.FindIndex(orderStatusLists.ToArray(), p => p.OrderPush.SuborderId == orderStatusChange.SubOrderId); | |||||
switch (orderStatusChange.Status) | |||||
{ | { | ||||
int index = Array.FindIndex(orderStatusLists.ToArray(), p => p.morkOrderPushes.FirstOrDefault(s => s.OrderPush.SuborderId == orderStatusChange.SuborderId) != null); | |||||
int index2 = -1; | |||||
if (index >= 0 && index < orderStatusLists.Count) | |||||
{ | |||||
index2 = Array.FindIndex(orderStatusLists.ElementAt(index).morkOrderPushes.ToArray(), p => p.OrderPush.SuborderId == orderStatusChange.SuborderId); | |||||
} | |||||
if (index2 < 0) return; | |||||
switch (orderStatusChange.CookingStatus) | |||||
{ | |||||
case ORDER_STATUS.COOKING: | |||||
if (index >= 0 && index < orderStatusLists.Count) | |||||
orderStatusLists.ElementAt(index).morkOrderPushes.ElementAt(index2).OrderStatus = orderStatusChange.CookingStatus; | |||||
break; | |||||
case ORDER_STATUS.COMPLETED_COOK: | |||||
if (index >= 0 && index < orderStatusLists.Count) | |||||
case ORDER_STATUS.COOKING: | |||||
if (index >= 0 && index < orderStatusLists.Count) | |||||
orderStatusLists.ElementAt(index).OrderStatus = orderStatusChange.Status; | |||||
break; | |||||
case ORDER_STATUS.COMPLETED_COOK: | |||||
if (index >= 0 && index < orderStatusLists.Count) | |||||
{ | |||||
Application.Current.Dispatcher.BeginInvoke((Action)delegate | |||||
{ | { | ||||
Application.Current.Dispatcher.BeginInvoke((Action)delegate | |||||
{ | |||||
orderStatusLists.ElementAt(index).morkOrderPushes.ElementAt(index2).OrderStatus = orderStatusChange.CookingStatus; | |||||
orderStatusLists.ElementAt(index).morkOrderPushes.ElementAt(index2).EndDate = DateTime.Now.ToString("HH:mm:ss"); | |||||
TimeSpan timeSpan = DateTime.Now.Subtract(Convert.ToDateTime(orderStatusLists.ElementAt(index).morkOrderPushes.ElementAt(index2).StartDate)); | |||||
orderStatusLists.ElementAt(index).morkOrderPushes.ElementAt(index2).CompleteDate = $"{timeSpan.TotalSeconds.ToString("0.00")} S"; | |||||
WaitTakeMeal.Insert(0, orderStatusLists.ElementAt(index)); | |||||
orderStatusLists.RemoveAt(index); | |||||
}); | |||||
} | |||||
orderStatusLists.ElementAt(index).OrderStatus = orderStatusChange.Status; | |||||
orderStatusLists.ElementAt(index).EndDate = DateTime.Now.ToString("HH:mm:ss"); | |||||
TimeSpan timeSpan = DateTime.Now.Subtract(Convert.ToDateTime(orderStatusLists.ElementAt(index).StartDate)); | |||||
orderStatusLists.ElementAt(index).CompleteDate = $"{timeSpan.TotalSeconds.ToString("0.00")} S"; | |||||
WaitTakeMeal.Insert(0, orderStatusLists.ElementAt(index)); | |||||
orderStatusLists.RemoveAt(index); | |||||
}); | |||||
} | |||||
break; | |||||
case ORDER_STATUS.COMPLETED_TAKE: | |||||
var re = WaitTakeMeal.FirstOrDefault(p => p.morkOrderPushes.FirstOrDefault(s => s.OrderPush.SuborderId == orderStatusChange.SuborderId) != null); | |||||
if (re != null) | |||||
break; | |||||
case ORDER_STATUS.COMPLETED_TAKE: | |||||
var re = WaitTakeMeal.FirstOrDefault(p => p.OrderPush.SuborderId == orderStatusChange.SubOrderId); | |||||
if (re != null) | |||||
{ | |||||
Application.Current.Dispatcher.BeginInvoke((Action)delegate | |||||
{ | { | ||||
Application.Current.Dispatcher.BeginInvoke((Action)delegate | |||||
{ | |||||
WaitTakeMeal.Remove(re); | |||||
Json<KeepDataBase>.Data.orderLists.Remove(re); | |||||
}); | |||||
} | |||||
break; | |||||
default: | |||||
break; | |||||
} | |||||
}); | |||||
WaitTakeMeal.Remove(re); | |||||
var removeObj = Json<KeepDataBase>.Data.orderLists.FirstOrDefault(p => p.morkOrderPushes.FirstOrDefault(s => s.OrderPush.SuborderId == re.OrderPush.SuborderId) != null); | |||||
if (removeObj != null) Json<KeepDataBase>.Data.orderLists.Remove(removeObj); | |||||
}); | |||||
} | |||||
break; | |||||
default: | |||||
break; | |||||
} | |||||
} | } | ||||
}), "OrderStatusChange"); | }), "OrderStatusChange"); | ||||
} | } | ||||
@@ -11,7 +11,7 @@ | |||||
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/RecDictionarys/RecCheckBox.xaml" /> | <ResourceDictionary Source="/BPASmartClient.CustomResource;component/RecDictionarys/RecCheckBox.xaml" /> | ||||
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/RecDictionarys/RecTitleBarButton.xaml" /> | <ResourceDictionary Source="/BPASmartClient.CustomResource;component/RecDictionarys/RecTitleBarButton.xaml" /> | ||||
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/RecDictionarys/GlobalStyle.xaml" /> | <ResourceDictionary Source="/BPASmartClient.CustomResource;component/RecDictionarys/GlobalStyle.xaml" /> | ||||
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/RecDictionarys/RecComboBox.xaml"/> | |||||
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/RecDictionarys/RecComboBox.xaml" /> | |||||
<!--<ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/GenricStyle.xaml"/> | <!--<ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/GenricStyle.xaml"/> | ||||
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/MyStyle.xaml"/>--> | <ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/MyStyle.xaml"/>--> | ||||
@@ -5,11 +5,16 @@ | |||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||||
xmlns:local="clr-namespace:BPASmartClient.Control" | xmlns:local="clr-namespace:BPASmartClient.Control" | ||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||||
xmlns:vm="clr-namespace:BPASmartClient.ViewModel;assembly=BPASmartClient.ViewModel" | |||||
d:DesignHeight="450" | d:DesignHeight="450" | ||||
d:DesignWidth="800" | d:DesignWidth="800" | ||||
Background="{x:Null}" | Background="{x:Null}" | ||||
mc:Ignorable="d"> | mc:Ignorable="d"> | ||||
<UserControl.DataContext> | |||||
<vm:OrderStatusViewModel/> | |||||
</UserControl.DataContext> | |||||
<UserControl.Resources> | <UserControl.Resources> | ||||
<SolidColorBrush x:Key="BorderSolid" Color="#5523CACA" /> | <SolidColorBrush x:Key="BorderSolid" Color="#5523CACA" /> | ||||
<SolidColorBrush x:Key="FontColor" Color="#FF2AB2E7" /> | <SolidColorBrush x:Key="FontColor" Color="#FF2AB2E7" /> | ||||
@@ -131,7 +136,7 @@ | |||||
<TextBlock | <TextBlock | ||||
Grid.Column="0" | Grid.Column="0" | ||||
Foreground="{Binding OrderStatus, Converter={StaticResource ColorConverter}}" | |||||
Foreground="{Binding OrderStatus, Converter={StaticResource ColorConverter}}" | |||||
Style="{StaticResource TextBlockStyle}" | Style="{StaticResource TextBlockStyle}" | ||||
Text="{Binding OrderPush.SortNum}" /> | Text="{Binding OrderPush.SortNum}" /> | ||||
@@ -102,7 +102,7 @@ | |||||
VerticalAlignment="Center" | VerticalAlignment="Center" | ||||
Content="新建" | Content="新建" | ||||
Foreground="{StaticResource TextBlockForeground}" | Foreground="{StaticResource TextBlockForeground}" | ||||
IcoText="" /> | |||||
IcoText="AA" /> | |||||
<!--<Button | <!--<Button | ||||
Width="140" | Width="140" | ||||
@@ -1,6 +1,6 @@ | |||||
<?xml version="1.0" encoding="utf-8" ?> | <?xml version="1.0" encoding="utf-8" ?> | ||||
<BPADevices> | <BPADevices> | ||||
<!--<Device Name="MorkT" Module="BPASmartClient.MorkT.Device_MorkT" DeviceId="1"> | |||||
<!--<Device Name="MorkT" Module="BPASmartClient.MorkT.Device_MorkT" DeviceId="1"> | |||||
<Peripherals> | <Peripherals> | ||||
<Peripheral Module="BPASmartClient.Lebai.LebaiRobot"> | <Peripheral Module="BPASmartClient.Lebai.LebaiRobot"> | ||||
<Parameters> | <Parameters> | ||||
@@ -19,36 +19,36 @@ | |||||
</Peripherals> | </Peripherals> | ||||
</Device>--> | </Device>--> | ||||
<Device Name="MorkS" Module="BPASmartClient.MorkS.Control" DeviceId="2"> | |||||
<!--<Parameters> | |||||
<Device Name="MorkS" Module="BPASmartClient.MorkS.Control" DeviceId="2"> | |||||
<!--<Parameters> | |||||
<IpAddress>127.0.10.1</IpAddress> | <IpAddress>127.0.10.1</IpAddress> | ||||
<Port>11</Port> | <Port>11</Port> | ||||
</Parameters>--> | </Parameters>--> | ||||
<Peripherals> | |||||
<Peripheral Module="BPASmartClient.PLC.MorksMachine"> | |||||
<Parameters> | |||||
<IpAddress>127.0.0.1</IpAddress> | |||||
<Port>502</Port> | |||||
<PLCReadAddress>M,M0.3,3;M,M100.0,16;M,M235.0,1;M,M102,7;M,M103,6;VW,VW372,1</PLCReadAddress> | |||||
</Parameters> | |||||
</Peripheral> | |||||
<Peripherals> | |||||
<Peripheral Module="BPASmartClient.PLC.MorksMachine"> | |||||
<Parameters> | |||||
<IpAddress>192.168.1.11</IpAddress> | |||||
<Port>508</Port> | |||||
<PLCReadAddress>M,M0.3,3;M,M100.0,16;M,M235.0,1;M,M102.0,7;M,M103.0,6;VW,VW372,1</PLCReadAddress> | |||||
</Parameters> | |||||
</Peripheral> | |||||
<!--<Peripheral Module="BPASmartClient.MORKSM.BK.PLC.MorksMachine"> | |||||
<!--<Peripheral Module="BPASmartClient.MORKSM.BK.PLC.MorksMachine"> | |||||
<Parameters> | <Parameters> | ||||
<IpAddress>127.0.10.1</IpAddress> | <IpAddress>127.0.10.1</IpAddress> | ||||
<Port>11</Port> | <Port>11</Port> | ||||
</Parameters> | </Parameters> | ||||
</Peripheral>--> | </Peripheral>--> | ||||
<!--<Peripheral Module="BPASmartClient.KLMCoffee.CoffeeMachine"> | |||||
<!--<Peripheral Module="BPASmartClient.KLMCoffee.CoffeeMachine"> | |||||
<Parameters> | <Parameters> | ||||
<PortName>COM8</PortName> | <PortName>COM8</PortName> | ||||
<BaudRate>38400</BaudRate> | <BaudRate>38400</BaudRate> | ||||
</Parameters> | </Parameters> | ||||
</Peripheral>--> | </Peripheral>--> | ||||
</Peripherals> | |||||
</Device> | |||||
</Peripherals> | |||||
</Device> | |||||