@@ -27,10 +27,10 @@ namespace BPASmartClient.CustomResource.Pages.ViewModel | |||
}), "PermissionChange"); | |||
//测试用 | |||
Global.DeviceRawMaterials.Add(new RawMaterialModel { RawMaterialName = "营养强化剂", DeviceIp = "192.168.1.111", RawMaterialSource = 1 }); | |||
/* Global.DeviceRawMaterials.Add(new RawMaterialModel { RawMaterialName = "营养强化剂", DeviceIp = "192.168.1.111", RawMaterialSource = 1 }); | |||
Global.DeviceRawMaterials.Add(new RawMaterialModel { RawMaterialName = "甜味剂", DeviceIp = "192.168.1.112", RawMaterialSource = 1 }); | |||
Global.DeviceRawMaterials.Add(new RawMaterialModel { RawMaterialName = "抗氧化剂", DeviceIp = "192.168.1.113", RawMaterialSource = 1 }); | |||
Global.DeviceRawMaterials.Add(new RawMaterialModel { RawMaterialName = "食用香料", DeviceIp = "192.168.1.114", RawMaterialSource = 1 }); | |||
Global.DeviceRawMaterials.Add(new RawMaterialModel { RawMaterialName = "食用香料", DeviceIp = "192.168.1.114", RawMaterialSource = 1 });*/ | |||
} | |||
@@ -54,6 +54,11 @@ namespace BPASmartClient.DosingSystem.Model | |||
/// </summary> | |||
public static string RunStatus { get; set; } = "LW60"; | |||
/// <summary> | |||
/// 出料完成,置位该信号,plc复位运行状态 | |||
/// </summary> | |||
public static string FinfishStatus { get; set; } = "LW40"; | |||
/// <summary> | |||
/// 慢加重量 | |||
/// </summary> | |||
@@ -1,19 +1,16 @@ | |||
using BPASmartClient.Helper; | |||
using BPASmartClient.Modbus; | |||
using BPASmartClient.CustomResource.Pages.Model; | |||
using BPASmartClient.DosingSystem.ViewModel; | |||
using BPASmartClient.Helper; | |||
using BPASmartClient.Modbus; | |||
using BPASmartClient.Model; | |||
using System; | |||
using System.Collections.Concurrent; | |||
using System.Collections.Generic; | |||
using System.Diagnostics; | |||
using System.Collections.ObjectModel; | |||
using System.Linq; | |||
using System.Net.NetworkInformation; | |||
using System.Text; | |||
using System.Threading; | |||
using System.Threading.Tasks; | |||
using BPASmartClient.CustomResource.UserControls.MessageShow; | |||
using BPASmartClient.CustomResource.Pages.Model; | |||
using BPASmartClient.Model; | |||
using System.Collections.ObjectModel; | |||
namespace BPASmartClient.DosingSystem.Model | |||
{ | |||
@@ -149,7 +146,7 @@ namespace BPASmartClient.DosingSystem.Model | |||
devices.Add(new Devices() { DeviceName = DeviceName, IpAddress = ip }); | |||
if (TopDeviceCurrentStatuses.Count <= 8) | |||
if (TopDeviceCurrentStatuses.Count <= 7) | |||
TopDeviceCurrentStatuses.Add(new DeviceCurrentStatus() { DeviceName = DeviceName }); | |||
else | |||
BottomDeviceCurrentStatuses.Add(new DeviceCurrentStatus() { DeviceName = DeviceName }); | |||
@@ -251,6 +248,7 @@ namespace BPASmartClient.DosingSystem.Model | |||
{ | |||
this.DeviceName = DeviceName; | |||
AlarmHelper<AlarmInfo>.Init(); | |||
//AlarmHelper<AlarmInfo>.Alarm.EStop1 = true; | |||
if (modbusTcp.Connected) | |||
{ | |||
ThreadManage.GetInstance().StartLong(new Action(() => | |||
@@ -275,7 +273,7 @@ namespace BPASmartClient.DosingSystem.Model | |||
AlarmHelper<AlarmInfo>.Alarm.EStop2 = deviceStatus.DeviceAlarmCode.Get16bitValue(7); | |||
AlarmHelper<AlarmInfo>.Alarm.SiloUpperLimit = deviceStatus.DeviceAlarmCode.Get16bitValue(8); | |||
AlarmHelper<AlarmInfo>.Alarm.SiloLowerLimit = deviceStatus.DeviceAlarmCode.Get16bitValue(9); | |||
Thread.Sleep(100); | |||
}), $"{DeviceName} 开始监听", true); | |||
} | |||
@@ -289,7 +287,8 @@ namespace BPASmartClient.DosingSystem.Model | |||
public void StatusReset() | |||
{ | |||
this.modbusTcp.Write(DeviceAddress.RunStatus, (ushort)0); | |||
this.modbusTcp.Write(DeviceAddress.FinfishStatus, (ushort)1); | |||
//var res = modbusTcp.Read(DeviceAddress.RunStatus); | |||
} | |||
public void Dispose() | |||
@@ -314,7 +313,7 @@ namespace BPASmartClient.DosingSystem.Model | |||
modbusTcp.SetUint(DeviceAddress.ServoManualSpeed, (uint)res.ServoManualSpeed); | |||
modbusTcp.SetUint(DeviceAddress.SiloUpperLimitWeight, (uint)res.SiloUpperLimitWeight); | |||
modbusTcp.SetUint(DeviceAddress.LowerLimitWeightOfSilo, (uint)res.LowerLimitWeightOfSilo); | |||
modbusTcp.SetUint(DeviceAddress.StirringSpeed, (uint)res.StirringSpeed); | |||
modbusTcp.SetUint(DeviceAddress.StirringSpeed, (uint)res.StirringSpeed * 100); | |||
} | |||
} | |||
} | |||
@@ -780,15 +780,18 @@ | |||
</TreeView>--> | |||
<!-- 等待和已完成 --> | |||
<TreeView | |||
<TreeView | |||
x:Name="repiceList" | |||
HorizontalAlignment="Stretch" | |||
Background="Transparent" | |||
BorderThickness="0" | |||
ItemContainerStyle="{StaticResource recipeTreeItem}" | |||
ItemsSource="{Binding UserTreeWait}" | |||
ScrollViewer.VerticalScrollBarVisibility="Disabled" /> | |||
ScrollViewer.VerticalScrollBarVisibility="Visible" /> | |||
</Grid> | |||
</Border> | |||
@@ -78,13 +78,18 @@ namespace BPASmartClient.DosingSystem.ViewModel | |||
RawMaterialId = item.RawMaterialId, | |||
}); | |||
})); | |||
} | |||
Recipes.ElementAt(index).Are.WaitOne();//阻塞,直到当前配方完成 | |||
devices.TryDequeue(out string deviceName); | |||
UserTreeCompelete.Add(Recipes.ElementAt(index));//当前配方完成后添加到已完成的配方列表 | |||
App.Current.Dispatcher.Invoke(new Action(() => { recipeProcesses.Clear(); }));//完成后清空当前配方 | |||
devices.TryDequeue(out string deviceName); | |||
App.Current.Dispatcher.Invoke(new Action(() => | |||
{ | |||
UserTreeCompelete.Add(Recipes.ElementAt(index));//当前配方完成后添加到已完成的配方列表 | |||
})); | |||
App.Current.Dispatcher.Invoke(new Action(() => { | |||
recipeProcesses.Clear(); | |||
CurrentRecipeName = string.Empty; | |||
}));//完成后清空当前配方 | |||
} | |||
} | |||
@@ -112,30 +117,52 @@ namespace BPASmartClient.DosingSystem.ViewModel | |||
} | |||
} | |||
Recipes.ElementAt(i).RawMaterials.ElementAt(m).RecipeStatus = RunStatus; | |||
var res = Recipes.ElementAt(i).RawMaterials.Where(p => p.RecipeStatus == 3).ToList(); | |||
if (res != null && res.Count == Recipes.ElementAt(i).RawMaterials.Count)//配方所有配料完成下料 | |||
var proc = recipeProcesses.Where(p=>p.RecipeStatus==3).ToList(); | |||
if (proc != null && proc.Count > 0 && proc.Count== recipeProcesses.Count) | |||
{ | |||
for (int r = 0; r < Recipes.ElementAt(i).RawMaterials.Count; r++) | |||
int recipIndex = Array.FindIndex(Recipes.ToArray(), p => p.RecipeName == CurrentRecipeName); | |||
if (recipIndex >= 0 && recipIndex < Recipes.Count) | |||
{ | |||
DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(r).DeviceIp).StatusReset();//完成配料的设备运行状态地址写0 | |||
App.Current.Dispatcher.Invoke(new Action(() => { recipeProcesses.Clear(); })); | |||
for (int n = 0; n < recipeProcesses.Count; n++) | |||
{ | |||
DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(recipIndex).RawMaterials.ElementAt(n).DeviceIp).StatusReset();//完成配料的设备运行状态地址写0 | |||
MessageLog.GetInstance.ShowRunLog(Recipes.ElementAt(recipIndex).RawMaterials.ElementAt(n).DeviceIp); | |||
} | |||
App.Current.Dispatcher.Invoke(new Action(() => { recipeProcesses.Clear(); })); | |||
Recipes.ElementAt(recipIndex).IsEnable = true; | |||
Recipes.ElementAt(recipIndex).Are.Set(); | |||
} | |||
Recipes.ElementAt(i).IsEnable = true; | |||
Recipes.ElementAt(i).Are.Set(); | |||
} | |||
} | |||
//Recipes.ElementAt(i).RawMaterials.ElementAt(m).RecipeStatus = RunStatus; | |||
//var res = Recipes.ElementAt(i).RawMaterials.Where(p => p.RecipeStatus == 3).ToList(); | |||
//if (res != null && res.Count == Recipes.ElementAt(i).RawMaterials.Count)//配方所有配料完成下料 | |||
//{ | |||
// for (int r = 0; r < Recipes.ElementAt(i).RawMaterials.Count; r++) | |||
// { | |||
// DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(r).DeviceIp).StatusReset();//完成配料的设备运行状态地址写0 | |||
// App.Current.Dispatcher.Invoke(new Action(() => { recipeProcesses.Clear(); })); | |||
// } | |||
// Recipes.ElementAt(i).IsEnable = true; | |||
// Recipes.ElementAt(i).Are.Set(); | |||
//} | |||
} | |||
} | |||
Thread.Sleep(100); | |||
}), "RecipeControlViewModelStatusInquire"); | |||
//测试数据 | |||
RawMaterialModel rawMaterial_1 = new RawMaterialModel { RawMaterialName = "香料_1" }; | |||
/* RawMaterialModel rawMaterial_1 = new RawMaterialModel { RawMaterialName = "香料_1" }; | |||
RawMaterialModel rawMaterial_2 = new RawMaterialModel { RawMaterialName = "香料_2" }; | |||
RawMaterialModel rawMaterial_3 = new RawMaterialModel { RawMaterialName = "香料_3" }; | |||
RawMaterialModel rawMaterial_4 = new RawMaterialModel { RawMaterialName = "香料_4" }; | |||
ObservableCollection<RawMaterialModel> rawMaterials = new ObservableCollection<RawMaterialModel> { rawMaterial_1, rawMaterial_2, rawMaterial_3, rawMaterial_4 }; | |||
UserTreeCompelete.Add(new RecipeModel { RecipeName = "完成的香料1", RawMaterials = rawMaterials }); | |||
UserTreeCompelete.Add(new RecipeModel { RecipeName = "完成的香料2", RawMaterials = rawMaterials }); | |||
UserTreeCompelete.Add(new RecipeModel { RecipeName = "完成的香料2", RawMaterials = rawMaterials });*/ | |||
} | |||