@@ -6,6 +6,7 @@ using System.Collections.ObjectModel; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using System.Windows; | |||
using BPASmartClient.Model; | |||
namespace BPASmartClient.CustomResource.Pages.Model | |||
{ | |||
@@ -16,22 +17,26 @@ namespace BPASmartClient.CustomResource.Pages.Model | |||
public static readonly object runLock = new object(); | |||
public static readonly object userlock = new object(); | |||
public static readonly object alarmlock = new object(); | |||
private MessageLog() { } | |||
public Action<string> UserLog { get; set; } | |||
public Action<string> RunLog { get; set; } | |||
public Action<string> AlarmLog { get; set; } | |||
public ObservableCollection<RunLog> runLogs { get; set; } = new ObservableCollection<RunLog>(); | |||
public ObservableCollection<UserLog> userLogs { get; set; } = new ObservableCollection<UserLog>(); | |||
public ObservableCollection<Alarm> alarmLogs { get; set; } = new ObservableCollection<Alarm>(); | |||
public void LogSave() | |||
{ | |||
Sqlite<UserLog>.GetInstance.Save(); | |||
Sqlite<RunLog>.GetInstance.Save(); | |||
Sqlite<Alarm>.GetInstance.Save(); | |||
} | |||
public void ShowUserLog(string info) | |||
@@ -67,9 +72,25 @@ namespace BPASmartClient.CustomResource.Pages.Model | |||
RunLog?.Invoke(info); | |||
} | |||
} | |||
int AlarmID; | |||
public void ShowAlarmLog(string info, string AlarmNumber="_", AlarmLevel level= AlarmLevel.一般报警) | |||
{ | |||
lock (alarmlock) | |||
{ | |||
AlarmID++; | |||
Alarm alarmLog = new Alarm() | |||
{ | |||
NumId = AlarmID, | |||
Date = DateTime.Now.ToString("yyyy-MM-dd"), | |||
Time = DateTime.Now.ToString("HH:mm:ss"), | |||
Info = info, | |||
Value = AlarmNumber, | |||
Grade = (level)+"" | |||
}; | |||
Sqlite<Alarm>.GetInstance.Base.Add(alarmLog); | |||
Application.Current.Dispatcher.Invoke(new Action(() => { alarmLogs.Insert(0, alarmLog); })); | |||
AlarmLog?.Invoke(info); | |||
} | |||
} | |||
} | |||
} |
@@ -64,13 +64,13 @@ namespace BPASmartClient.CustomResource.Pages.ViewModel | |||
} | |||
}); | |||
AlarmInfos = AlarmHelper<AlarmInfo>.Alarms; | |||
AlarmInfos = MessageLog.GetInstance.alarmLogs; | |||
} | |||
private void GetHistoryAlarm() | |||
{ | |||
var data = Sqlite<BPASmartClient.Model.Alarm>.GetInstance.GetData(); | |||
var data = Sqlite<Alarm>.GetInstance.GetData(); | |||
if (data != null) | |||
{ | |||
HistoryAlarm.Clear(); | |||
@@ -133,9 +133,5 @@ namespace BPASmartClient.CustomResource.Pages.ViewModel | |||
public ObservableCollection<Alarm> AlarmInfos { get; set; } | |||
public ObservableCollection<Alarm> HistoryAlarm { get; set; } = new ObservableCollection<Alarm>(); | |||
} | |||
} |
@@ -106,7 +106,7 @@ namespace BPASmartClient.CustomResource.Pages.ViewModel | |||
/// </summary> | |||
public string ControlButText { get { return _mControlButText; } set { _mControlButText = value; OnPropertyChanged(); } } | |||
private string _mControlButText = "报警复位"; | |||
/// <summary> | |||
/// 开始时间 | |||
/// </summary> | |||
@@ -35,8 +35,12 @@ namespace BPASmartClient.DosingSystem | |||
//mv.Show(); | |||
LoginView lv = new LoginView(); | |||
var res = lv.ShowDialog(); | |||
if (res != null && res == true) | |||
if (res != null && res == true) | |||
{ | |||
MessageLog.GetInstance.ShowUserLog("用户登录"); | |||
mv.Show(); | |||
DeviceInquire.GetInstance.Init(); | |||
} | |||
else | |||
mv.Close(); | |||
MainWindow = mv; | |||
@@ -16,27 +16,27 @@ namespace BPASmartClient.DosingSystem.Model | |||
/// <summary> | |||
/// 料仓重量反馈起始地址 | |||
/// </summary> | |||
public static string WeightFeedback { get; set; } = "LW204"; | |||
public static string WeightFeedback { get; set; } = "LW52";//LW204 | |||
/// <summary> | |||
/// 重量设置地址 | |||
/// </summary> | |||
public static string WeightSet { get; set; } = "LW200"; | |||
public static string WeightSet { get; set; } = "LW21";//LW200 | |||
/// <summary> | |||
/// 启动信号地址 | |||
/// </summary> | |||
public static string Start { get; set; } = "LW210"; | |||
public static string Start { get; set; } = "LW20";//LW210 | |||
/// <summary> | |||
/// 下料重量反馈地址 | |||
/// </summary> | |||
public static string CutWeightFeedback { get; set; } = "LW202"; | |||
public static string CutWeightFeedback { get; set; } = "LW54";//LW202 | |||
/// <summary> | |||
/// 设备运行状态地址 | |||
/// </summary> | |||
public static string RunStatus { get; set; } = "LW206"; | |||
public static string RunStatus { get; set; } = "LW51";//LW206 | |||
} | |||
@@ -1,5 +1,4 @@ | |||
using BPASmartClient.Helper; | |||
using BPASmartClient.Message; | |||
using BPASmartClient.Modbus; | |||
using BPASmartClient.DosingSystem.ViewModel; | |||
using System; | |||
@@ -11,6 +10,8 @@ using System.Net.NetworkInformation; | |||
using System.Text; | |||
using System.Threading; | |||
using System.Threading.Tasks; | |||
using BPASmartClient.CustomResource.UserControls.MessageShow; | |||
using BPASmartClient.CustomResource.Pages.Model; | |||
namespace BPASmartClient.DosingSystem.Model | |||
{ | |||
@@ -124,7 +125,7 @@ namespace BPASmartClient.DosingSystem.Model | |||
DS.modbusTcp.ConnectFail = new Action(() => | |||
{ | |||
if (!InvalidIP.Contains(ip)) InvalidIP.Add(ip); | |||
MessageLog.GetInstance.Show($"{ip}连接失败"); | |||
//MessageLog.GetInstance.ShowAlarmLog($"设备{ip}连接失败"); | |||
}); | |||
DS.modbusTcp.Disconnect = new Action(() => | |||
@@ -135,7 +136,7 @@ namespace BPASmartClient.DosingSystem.Model | |||
App.Current.Dispatcher.Invoke(new Action(() => | |||
{ | |||
DeviceListViewModel.devices.Remove(res); | |||
if (NewRecipeViewModel.RawMaterialNames.Contains(res.DeviceName))///???????? | |||
if (NewRecipeViewModel.RawMaterialNames.Contains(res.DeviceName)) | |||
NewRecipeViewModel.RawMaterialNames.Remove(res.DeviceName); | |||
})); | |||
if (DeviceLists.ContainsKey(ip)) DeviceLists[ip].Dispose(); | |||
@@ -188,9 +189,7 @@ namespace BPASmartClient.DosingSystem.Model | |||
//获取设备料仓剩余重量 | |||
deviceStatus.WeightFeedback = this.modbusTcp.GetUint(DeviceAddress.WeightFeedback) * 10; | |||
//获取料仓下限反馈 | |||
//获取料仓上限反馈 | |||
//获取下料重量(称) | |||
deviceStatus.CutWeightFeedback = this.modbusTcp.GetUint(DeviceAddress.CutWeightFeedback) * 10; | |||
Thread.Sleep(100); | |||
}), $"{DeviceName} 开始监听", true); | |||
} | |||
@@ -51,7 +51,7 @@ | |||
Height="500" | |||
CurrentValue="50" />--> | |||
<pry:MotorBottle CurrentValue="100" IsRun="True" /> | |||
<!--<pry:MotorBottle IsRun="True" CurrentValue="100"/>--> | |||
<Grid> | |||
@@ -8,6 +8,7 @@ using System.Collections.ObjectModel; | |||
using Microsoft.Toolkit.Mvvm.Input; | |||
using BPASmartClient.Helper; | |||
using BPASmartClient.DosingSystem.Model; | |||
using BPASmartClient.CustomResource.Pages.Model; | |||
namespace BPASmartClient.DosingSystem.ViewModel | |||
{ | |||
@@ -26,15 +26,15 @@ namespace BPASmartClient.DosingSystem.ViewModel | |||
Recipes = Json<LocaPar>.Data.Recipes; | |||
StartCommand = new RelayCommand<object>((o) => | |||
{ | |||
if (o != null && o is string recipeName) | |||
if (o != null && o is string deviceName) | |||
{ | |||
//int index = Array.FindIndex(Recipes.ToArray(), p => p.RecipeName == deviceName); | |||
//if (index >= 0 && index < Recipes.Count) | |||
//{ | |||
// Recipes.ElementAt(index).IsEnable = false; | |||
//} | |||
//MessageLog.GetInstance.ShowUserLog($"下发工单 {Recipes.ElementAt(index).RecipeName}"); | |||
devices.Enqueue(recipeName); | |||
int index = Array.FindIndex(Recipes.ToArray(), p => p.RecipeName == deviceName); | |||
if (index >= 0 && index < Recipes.Count) | |||
{ | |||
Recipes.ElementAt(index).IsEnable = false; | |||
} | |||
MessageLog.GetInstance.ShowUserLog($"下发工单 { Recipes.ElementAt(index).RecipeName}"); | |||
devices.Enqueue(deviceName); | |||
} | |||
NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"配方下发成功!"); | |||
MessageLog.GetInstance.ShowUserLog($"下发工单 {Guid.NewGuid().ToString()}"); | |||
@@ -16,6 +16,7 @@ using BPASmartClient.CustomResource.UserControls.Model; | |||
using BPASmartClient.CustomResource.UserControls.Enum; | |||
using System.Windows.Media; | |||
using BPASmartClient.CustomResource.UserControls.MessageShow; | |||
using BPASmartClient.CustomResource.Pages.Model; | |||
namespace BPASmartClient.DosingSystem.ViewModel | |||
{ | |||
@@ -29,10 +30,12 @@ namespace BPASmartClient.DosingSystem.ViewModel | |||
{ | |||
NewRecipeView nrv = new NewRecipeView(); | |||
nrv.ShowDialog(); | |||
MessageLog.GetInstance.ShowUserLog("新建配方"); | |||
}); | |||
SaveRecipe = new RelayCommand(() => | |||
{ | |||
Json<LocaPar>.Save(); | |||
MessageLog.GetInstance.ShowUserLog("保存配方"); | |||
NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"配方保存成功!"); | |||
}); | |||
RemoveCommand = new RelayCommand<object>((o) => | |||
@@ -41,6 +44,7 @@ namespace BPASmartClient.DosingSystem.ViewModel | |||
{ | |||
var res = Json<LocaPar>.Data.Recipes.FirstOrDefault(p => p.RecipCode == str); | |||
if (res != null) Json<LocaPar>.Data.Recipes.Remove(res); | |||
MessageLog.GetInstance.ShowUserLog($"删除名称——{res.RecipeName}"); | |||
} | |||
}); | |||
@@ -50,9 +54,10 @@ namespace BPASmartClient.DosingSystem.ViewModel | |||
{ | |||
ActionManage.GetInstance.CancelRegister("Details"); | |||
NewRecipeView nrv = new NewRecipeView(); | |||
ActionManage.GetInstance.Send("Details", Json<LocaPar>.Data.Recipes.FirstOrDefault(p => p.RecipCode == str)); | |||
var res = Json<LocaPar>.Data.Recipes.FirstOrDefault(p => p.RecipCode == str); | |||
ActionManage.GetInstance.Send("Details",res); | |||
nrv.ShowDialog(); | |||
MessageLog.GetInstance.ShowUserLog($"编辑配方名称——{res.RecipeName}"); | |||
} | |||
}); | |||
} | |||