@@ -0,0 +1,31 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Globalization; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
using System.Windows.Data; | |||||
using System.Windows.Media; | |||||
namespace BPASmartClient.CustomResource.Converters | |||||
{ | |||||
public class RecipeStatusConvert : IValueConverter | |||||
{ | |||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | |||||
{ | |||||
if (value != null) | |||||
{ | |||||
if (value.ToString() == "等待制作") | |||||
return Brushes.Yellow; | |||||
else if (value.ToString() == "制作完成") | |||||
return Brushes.Green; | |||||
} | |||||
return default; | |||||
} | |||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | |||||
{ | |||||
throw new NotImplementedException(); | |||||
} | |||||
} | |||||
} |
@@ -114,7 +114,7 @@ namespace BPASmartClient.Model | |||||
set | set | ||||
{ | { | ||||
_mRecipeStatus = value; | _mRecipeStatus = value; | ||||
if (value == 1) Status = Status.等待配料; | |||||
if (value == 1 && Status != Status.配料完成) Status = Status.等待配料; | |||||
else if (value == 2) Status = Status.正在配料; | else if (value == 2) Status = Status.正在配料; | ||||
else if (value == 3) Status = Status.配料完成; | else if (value == 3) Status = Status.配料完成; | ||||
OnPropertyChanged(); | OnPropertyChanged(); | ||||
@@ -9,6 +9,7 @@ | |||||
</PropertyGroup> | </PropertyGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
<PackageReference Include="BPA.Message" Version="1.0.72" /> | |||||
<PackageReference Include="BPA.Models" Version="1.0.34" /> | <PackageReference Include="BPA.Models" Version="1.0.34" /> | ||||
<PackageReference Include="Microsoft.Toolkit.Mvvm" Version="7.1.2" /> | <PackageReference Include="Microsoft.Toolkit.Mvvm" Version="7.1.2" /> | ||||
<PackageReference Include="System.Speech" Version="6.0.0" /> | <PackageReference Include="System.Speech" Version="6.0.0" /> | ||||
@@ -6,6 +6,7 @@ using System.Threading; | |||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
using BPA.Helper; | using BPA.Helper; | ||||
using BPASmartClient.MQTT; | using BPASmartClient.MQTT; | ||||
using BPA.Message; | |||||
namespace BPASmartClient.MorkS | namespace BPASmartClient.MorkS | ||||
{ | { | ||||
@@ -28,6 +28,7 @@ | |||||
<con:BoolToVisibilityConvert x:Key="BoolToVisibilityConvert" /> | <con:BoolToVisibilityConvert x:Key="BoolToVisibilityConvert" /> | ||||
<con:CountIsVisiableConvert x:Key="CountIsVisiableConvert" /> | <con:CountIsVisiableConvert x:Key="CountIsVisiableConvert" /> | ||||
<con:BoolToFillColorConverter x:Key="BoolToFillColorConverter" /> | <con:BoolToFillColorConverter x:Key="BoolToFillColorConverter" /> | ||||
<con:RecipeStatusConvert x:Key="RecipeStatusConvert" /> | |||||
</ResourceDictionary> | </ResourceDictionary> | ||||
<ResourceDictionary> | <ResourceDictionary> | ||||
@@ -28,8 +28,12 @@ namespace BPASmartClient.DosingSystem | |||||
BPASmartClient.Helper.SystemHelper.GetInstance.CreateDesktopShortcut(); | BPASmartClient.Helper.SystemHelper.GetInstance.CreateDesktopShortcut(); | ||||
MenuInit(); | MenuInit(); | ||||
DataInit(); | DataInit(); | ||||
DeviceInquire.GetInstance.Init();//配料机设备上线监听,设备列表初始化 | |||||
ThreadManage.GetInstance().Start(new Action(() => | |||||
{ | |||||
DeviceInquire.GetInstance.Init();//配料机设备上线监听,设备列表初始化 | |||||
}), "设备初始化"); | |||||
MainView mv = new MainView(); | MainView mv = new MainView(); | ||||
mv.TitleName = "味魔方管理系统软件[简称:味魔方] 1.0.1"; | |||||
LoginView lv = new LoginView(); | LoginView lv = new LoginView(); | ||||
var res = lv.ShowDialog(); | var res = lv.ShowDialog(); | ||||
if (res != null && res == true) | if (res != null && res == true) | ||||
@@ -307,7 +307,7 @@ namespace BPASmartClient.DosingSystem | |||||
modbusTcp.ShowEx = new Action<string>((s) => { MessageNotify.GetInstance.ShowRunLog(s); }); | modbusTcp.ShowEx = new Action<string>((s) => { MessageNotify.GetInstance.ShowRunLog(s); }); | ||||
this.DeviceName = DeviceName; | this.DeviceName = DeviceName; | ||||
AlarmHelper<AlarmInfo>.Init(); | AlarmHelper<AlarmInfo>.Init(); | ||||
if (modbusTcp.Connected) | if (modbusTcp.Connected) | ||||
{ | { | ||||
ThreadManage.GetInstance().StartLong(new Action(() => | ThreadManage.GetInstance().StartLong(new Action(() => | ||||
@@ -364,7 +364,7 @@ namespace BPASmartClient.DosingSystem | |||||
modbusTcp.SetUint(DeviceAddress.ServoManualSpeed, (uint)res.ServoManualSpeed); | modbusTcp.SetUint(DeviceAddress.ServoManualSpeed, (uint)res.ServoManualSpeed); | ||||
modbusTcp.SetUint(DeviceAddress.SiloUpperLimitWeight, (uint)res.SiloUpperLimitWeight); | modbusTcp.SetUint(DeviceAddress.SiloUpperLimitWeight, (uint)res.SiloUpperLimitWeight); | ||||
modbusTcp.SetUint(DeviceAddress.LowerLimitWeightOfSilo, (uint)res.LowerLimitWeightOfSilo); | modbusTcp.SetUint(DeviceAddress.LowerLimitWeightOfSilo, (uint)res.LowerLimitWeightOfSilo); | ||||
modbusTcp.SetUint(DeviceAddress.StirringSpeed, (uint)res.StirringSpeed * 100); | |||||
modbusTcp.SetUint(DeviceAddress.StirringSpeed, (uint)res.StirringSpeed); | |||||
MessageNotify.GetInstance.ShowRunLog($"{res.MaterialName},参数下发完成"); | MessageNotify.GetInstance.ShowRunLog($"{res.MaterialName},参数下发完成"); | ||||
} | } | ||||
} | } | ||||
@@ -40,6 +40,11 @@ namespace BPASmartClient.DosingSystem | |||||
[Newtonsoft.Json.JsonIgnore] | [Newtonsoft.Json.JsonIgnore] | ||||
public AutoResetEvent Are { get; set; } = new AutoResetEvent(false); | public AutoResetEvent Are { get; set; } = new AutoResetEvent(false); | ||||
[Newtonsoft.Json.JsonIgnore] | |||||
public string RecipStatus { get { return _mRecipStatus; } set { _mRecipStatus = value; OnPropertyChanged(); } } | |||||
private string _mRecipStatus; | |||||
/// <summary> | /// <summary> | ||||
/// 原料集合 | /// 原料集合 | ||||
/// </summary> | /// </summary> | ||||
@@ -1,5 +1,4 @@ | |||||
using BPASmartClient.Helper; | |||||
using System; | |||||
using System; | |||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Linq; | using System.Linq; | ||||
using System.Text; | using System.Text; | ||||
@@ -12,6 +11,7 @@ using System.Windows.Input; | |||||
using System.Windows.Media; | using System.Windows.Media; | ||||
using System.Windows.Media.Imaging; | using System.Windows.Media.Imaging; | ||||
using System.Windows.Shapes; | using System.Windows.Shapes; | ||||
using BPA.Helper; | |||||
namespace BPASmartClient.DosingSystem.View | namespace BPASmartClient.DosingSystem.View | ||||
{ | { | ||||
@@ -23,8 +23,8 @@ namespace BPASmartClient.DosingSystem.View | |||||
public ChangeDeviceNameView() | public ChangeDeviceNameView() | ||||
{ | { | ||||
InitializeComponent(); | InitializeComponent(); | ||||
ActionManage.GetInstance.CancelRegister("ChangeDeviceNameViewClose"); | |||||
ActionManage.GetInstance.Register(new Action(() => { this.Close(); }), "ChangeDeviceNameViewClose"); | |||||
//ActionManage.GetInstance.CancelRegister("ChangeDeviceNameViewClose"); | |||||
ActionManage.GetInstance.Register(new Action(() => { this.Close(); }), "ChangeDeviceNameViewClose", true); | |||||
this.br.MouseLeftButtonDown += (o, e) => { if (e.LeftButton == MouseButtonState.Pressed) this.DragMove(); }; | this.br.MouseLeftButtonDown += (o, e) => { if (e.LeftButton == MouseButtonState.Pressed) this.DragMove(); }; | ||||
} | } | ||||
} | } | ||||
@@ -880,8 +880,8 @@ | |||||
HorizontalAlignment="Center" | HorizontalAlignment="Center" | ||||
VerticalAlignment="Center" | VerticalAlignment="Center" | ||||
FontSize="16" | FontSize="16" | ||||
Foreground="Yellow" | |||||
Text="等待执行" /> | |||||
Foreground="{Binding RecipStatus,Converter={StaticResource RecipeStatusConvert}}" | |||||
Text="{Binding RecipStatus}" /> | |||||
<Border | <Border | ||||
Grid.ColumnSpan="10" | Grid.ColumnSpan="10" | ||||
BorderBrush="{StaticResource bordColor}" | BorderBrush="{StaticResource bordColor}" | ||||
@@ -54,15 +54,6 @@ namespace BPASmartClient.DosingSystem.ViewModel | |||||
private static string IpAddress = string.Empty; | private static string IpAddress = string.Empty; | ||||
//public BPARelayCommand ConfirmCommand { get; set; } | |||||
//public BPARelayCommand CancleCommand { get; set; } | |||||
//public string ErrorInfo { get { return _mErrorInfo; } set { _mErrorInfo = value; OnPropertyChanged(); } } | |||||
//private string _mErrorInfo; | |||||
public string DeviceName { get { return _mDeviceName; } set { _mDeviceName = value; OnPropertyChanged(); } } | public string DeviceName { get { return _mDeviceName; } set { _mDeviceName = value; OnPropertyChanged(); } } | ||||
private string _mDeviceName; | private string _mDeviceName; | ||||
@@ -59,7 +59,7 @@ namespace BPASmartClient.DosingSystem.ViewModel | |||||
RecipeNames.Enqueue(deviceName); | RecipeNames.Enqueue(deviceName); | ||||
var t = RecipeNames.GetHashCode(); | var t = RecipeNames.GetHashCode(); | ||||
var res = Recipes.FirstOrDefault(p => p.RecipeName == deviceName); | var res = Recipes.FirstOrDefault(p => p.RecipeName == deviceName); | ||||
UserTreeWait.Add(new RecipeModel { SerialNum = UserTreeWait.Count + 1, RecipeName = deviceName, RawMaterials = res.RawMaterials }); | |||||
UserTreeWait.Add(new RecipeModel { RecipStatus = "等待制作", SerialNum = UserTreeWait.Count + 1, RecipeName = deviceName, RawMaterials = res.RawMaterials }); | |||||
} | } | ||||
NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"配方下发成功!"); | NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"配方下发成功!"); | ||||
MessageNotify.GetInstance.ShowUserLog($"下发工单 {Guid.NewGuid().ToString()}"); | MessageNotify.GetInstance.ShowUserLog($"下发工单 {Guid.NewGuid().ToString()}"); | ||||
@@ -107,7 +107,7 @@ namespace BPASmartClient.DosingSystem.ViewModel | |||||
if (tempDevice != null) | if (tempDevice != null) | ||||
{ | { | ||||
/*data = data.SetBitValue((byte)tempDevice.DeviceNum, true);*/ | /*data = data.SetBitValue((byte)tempDevice.DeviceNum, true);*/ | ||||
if (tempDevice.DeviceNum > 0) | |||||
if (tempDevice.DeviceNum > 0) | |||||
{ | { | ||||
int a = data.SetBitValue((byte)tInfo.ElementAt(i).ElementAt(m).Loc, true); | int a = data.SetBitValue((byte)tInfo.ElementAt(i).ElementAt(m).Loc, true); | ||||
byte[] test1 = a.ToBytes(BPA.Helper.DataFormat.ABCD); | byte[] test1 = a.ToBytes(BPA.Helper.DataFormat.ABCD); | ||||
@@ -116,9 +116,9 @@ namespace BPASmartClient.DosingSystem.ViewModel | |||||
MessageNotify.GetInstance.ShowRunLog($"下发配方DB4.DBD{2 + (tempDevice.DeviceNum - 1) * 4} :{item.ToBinString()}"); | MessageNotify.GetInstance.ShowRunLog($"下发配方DB4.DBD{2 + (tempDevice.DeviceNum - 1) * 4} :{item.ToBinString()}"); | ||||
} | } | ||||
} | } | ||||
if (tInfo.ElementAt(i).ElementAt(m).Loc >0) | |||||
if (tInfo.ElementAt(i).ElementAt(m).Loc > 0) | |||||
{ | { | ||||
if (!BarrelNum.Contains(tInfo.ElementAt(i).ElementAt(m).Loc)) | |||||
if (!BarrelNum.Contains(tInfo.ElementAt(i).ElementAt(m).Loc)) | |||||
{ | { | ||||
BarrelNum.Add(tInfo.ElementAt(i).ElementAt(m).Loc); | BarrelNum.Add(tInfo.ElementAt(i).ElementAt(m).Loc); | ||||
} | } | ||||
@@ -232,6 +232,7 @@ namespace BPASmartClient.DosingSystem.ViewModel | |||||
RecipeName = recipeComple.RecipeName, | RecipeName = recipeComple.RecipeName, | ||||
SerialNum = UserTreeCompelete.Count + 1, | SerialNum = UserTreeCompelete.Count + 1, | ||||
RecipCode = recipeComple.RecipCode, | RecipCode = recipeComple.RecipCode, | ||||
RecipStatus = "制作完成" | |||||
}); | }); | ||||
}); | }); | ||||
App.Current.Dispatcher.Invoke(new Action(() => | App.Current.Dispatcher.Invoke(new Action(() => | ||||
@@ -283,14 +284,14 @@ namespace BPASmartClient.DosingSystem.ViewModel | |||||
MessageNotify.GetInstance.ShowRunLog("错误"); | MessageNotify.GetInstance.ShowRunLog("错误"); | ||||
return; | return; | ||||
} | } | ||||
else | |||||
else | |||||
{ | { | ||||
switch (cnt) | switch (cnt) | ||||
{ | { | ||||
case 1: | case 1: | ||||
int a1 = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceNum == 1); | int a1 = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceNum == 1); | ||||
int b1 = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceNum == 2); | int b1 = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceNum == 2); | ||||
if (a1 >= 0) | |||||
if (a1 >= 0) | |||||
{ | { | ||||
Location1 = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == DeviceInquire.GetInstance.devices.ElementAt(a1).DeviceName && p.Loc == barrel); | Location1 = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == DeviceInquire.GetInstance.devices.ElementAt(a1).DeviceName && p.Loc == barrel); | ||||
} | } | ||||
@@ -461,7 +462,7 @@ namespace BPASmartClient.DosingSystem.ViewModel | |||||
} | } | ||||
} | } | ||||
} | } | ||||
else | |||||
else | |||||
{ | { | ||||
if (Location2 >= 0) | if (Location2 >= 0) | ||||
{ | { | ||||