Browse Source

冲突解决

样式分支
taoye 2 years ago
parent
commit
f115eea043
10 changed files with 61 additions and 35 deletions
  1. +26
    -5
      BPASmartClient.CustomResource/Pages/Model/MessageLog.cs
  2. +2
    -6
      BPASmartClient.CustomResource/Pages/ViewModel/AlarmViewModel.cs
  3. +1
    -1
      BPASmartClient.CustomResource/Pages/ViewModel/RunLogViewModel.cs
  4. +5
    -1
      DosingSystem/App.xaml.cs
  5. +5
    -5
      DosingSystem/Model/DeviceAddress.cs
  6. +5
    -6
      DosingSystem/Model/DeviceInquire.cs
  7. +1
    -1
      DosingSystem/View/DeviceListView.xaml
  8. +1
    -0
      DosingSystem/ViewModel/NewRecipeViewModel.cs
  9. +8
    -8
      DosingSystem/ViewModel/RecipeControlViewModel.cs
  10. +7
    -2
      DosingSystem/ViewModel/RecipeSettingsViewModel.cs

+ 26
- 5
BPASmartClient.CustomResource/Pages/Model/MessageLog.cs View File

@@ -6,6 +6,7 @@ using System.Collections.ObjectModel;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows; using System.Windows;
using BPASmartClient.Model;


namespace BPASmartClient.CustomResource.Pages.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 runLock = new object();
public static readonly object userlock = new object(); public static readonly object userlock = new object();
public static readonly object alarmlock = new object();
private MessageLog() { } private MessageLog() { }


public Action<string> UserLog { get; set; } public Action<string> UserLog { get; set; }


public Action<string> RunLog { 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<RunLog> runLogs { get; set; } = new ObservableCollection<RunLog>();


public ObservableCollection<UserLog> userLogs { get; set; } = new ObservableCollection<UserLog>(); public ObservableCollection<UserLog> userLogs { get; set; } = new ObservableCollection<UserLog>();


public ObservableCollection<Alarm> alarmLogs { get; set; } = new ObservableCollection<Alarm>();

public void LogSave() public void LogSave()
{ {
Sqlite<UserLog>.GetInstance.Save(); Sqlite<UserLog>.GetInstance.Save();
Sqlite<RunLog>.GetInstance.Save(); Sqlite<RunLog>.GetInstance.Save();
Sqlite<Alarm>.GetInstance.Save();
} }


public void ShowUserLog(string info) public void ShowUserLog(string info)
@@ -67,9 +72,25 @@ namespace BPASmartClient.CustomResource.Pages.Model
RunLog?.Invoke(info); 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);
}
}
} }
} }

+ 2
- 6
BPASmartClient.CustomResource/Pages/ViewModel/AlarmViewModel.cs View File

@@ -64,13 +64,13 @@ namespace BPASmartClient.CustomResource.Pages.ViewModel
} }
}); });


AlarmInfos = AlarmHelper<AlarmInfo>.Alarms;
AlarmInfos = MessageLog.GetInstance.alarmLogs;
} }


private void GetHistoryAlarm() private void GetHistoryAlarm()
{ {
var data = Sqlite<BPASmartClient.Model.Alarm>.GetInstance.GetData();
var data = Sqlite<Alarm>.GetInstance.GetData();
if (data != null) if (data != null)
{ {
HistoryAlarm.Clear(); HistoryAlarm.Clear();
@@ -133,9 +133,5 @@ namespace BPASmartClient.CustomResource.Pages.ViewModel
public ObservableCollection<Alarm> AlarmInfos { get; set; } public ObservableCollection<Alarm> AlarmInfos { get; set; }
public ObservableCollection<Alarm> HistoryAlarm { get; set; } = new ObservableCollection<Alarm>(); public ObservableCollection<Alarm> HistoryAlarm { get; set; } = new ObservableCollection<Alarm>();



} }



} }

+ 1
- 1
BPASmartClient.CustomResource/Pages/ViewModel/RunLogViewModel.cs View File

@@ -106,7 +106,7 @@ namespace BPASmartClient.CustomResource.Pages.ViewModel
/// </summary> /// </summary>
public string ControlButText { get { return _mControlButText; } set { _mControlButText = value; OnPropertyChanged(); } } public string ControlButText { get { return _mControlButText; } set { _mControlButText = value; OnPropertyChanged(); } }
private string _mControlButText = "报警复位"; private string _mControlButText = "报警复位";
/// <summary> /// <summary>
/// 开始时间 /// 开始时间
/// </summary> /// </summary>


+ 5
- 1
DosingSystem/App.xaml.cs View File

@@ -35,8 +35,12 @@ namespace BPASmartClient.DosingSystem
//mv.Show(); //mv.Show();
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)
{
MessageLog.GetInstance.ShowUserLog("用户登录");
mv.Show(); mv.Show();
DeviceInquire.GetInstance.Init();
}
else else
mv.Close(); mv.Close();
MainWindow = mv; MainWindow = mv;


+ 5
- 5
DosingSystem/Model/DeviceAddress.cs View File

@@ -16,27 +16,27 @@ namespace BPASmartClient.DosingSystem.Model
/// <summary> /// <summary>
/// 料仓重量反馈起始地址 /// 料仓重量反馈起始地址
/// </summary> /// </summary>
public static string WeightFeedback { get; set; } = "LW204";
public static string WeightFeedback { get; set; } = "LW52";//LW204


/// <summary> /// <summary>
/// 重量设置地址 /// 重量设置地址
/// </summary> /// </summary>
public static string WeightSet { get; set; } = "LW200";
public static string WeightSet { get; set; } = "LW21";//LW200


/// <summary> /// <summary>
/// 启动信号地址 /// 启动信号地址
/// </summary> /// </summary>
public static string Start { get; set; } = "LW210";
public static string Start { get; set; } = "LW20";//LW210


/// <summary> /// <summary>
/// 下料重量反馈地址 /// 下料重量反馈地址
/// </summary> /// </summary>
public static string CutWeightFeedback { get; set; } = "LW202";
public static string CutWeightFeedback { get; set; } = "LW54";//LW202


/// <summary> /// <summary>
/// 设备运行状态地址 /// 设备运行状态地址
/// </summary> /// </summary>
public static string RunStatus { get; set; } = "LW206";
public static string RunStatus { get; set; } = "LW51";//LW206
} }






+ 5
- 6
DosingSystem/Model/DeviceInquire.cs View File

@@ -1,5 +1,4 @@
using BPASmartClient.Helper; using BPASmartClient.Helper;
using BPASmartClient.Message;
using BPASmartClient.Modbus; using BPASmartClient.Modbus;
using BPASmartClient.DosingSystem.ViewModel; using BPASmartClient.DosingSystem.ViewModel;
using System; using System;
@@ -11,6 +10,8 @@ using System.Net.NetworkInformation;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using BPASmartClient.CustomResource.UserControls.MessageShow;
using BPASmartClient.CustomResource.Pages.Model;


namespace BPASmartClient.DosingSystem.Model namespace BPASmartClient.DosingSystem.Model
{ {
@@ -124,7 +125,7 @@ namespace BPASmartClient.DosingSystem.Model
DS.modbusTcp.ConnectFail = new Action(() => DS.modbusTcp.ConnectFail = new Action(() =>
{ {
if (!InvalidIP.Contains(ip)) InvalidIP.Add(ip); if (!InvalidIP.Contains(ip)) InvalidIP.Add(ip);
MessageLog.GetInstance.Show($"{ip}连接失败");
//MessageLog.GetInstance.ShowAlarmLog($"设备{ip}连接失败");
}); });


DS.modbusTcp.Disconnect = new Action(() => DS.modbusTcp.Disconnect = new Action(() =>
@@ -135,7 +136,7 @@ namespace BPASmartClient.DosingSystem.Model
App.Current.Dispatcher.Invoke(new Action(() => App.Current.Dispatcher.Invoke(new Action(() =>
{ {
DeviceListViewModel.devices.Remove(res); DeviceListViewModel.devices.Remove(res);
if (NewRecipeViewModel.RawMaterialNames.Contains(res.DeviceName))///????????
if (NewRecipeViewModel.RawMaterialNames.Contains(res.DeviceName))
NewRecipeViewModel.RawMaterialNames.Remove(res.DeviceName); NewRecipeViewModel.RawMaterialNames.Remove(res.DeviceName);
})); }));
if (DeviceLists.ContainsKey(ip)) DeviceLists[ip].Dispose(); if (DeviceLists.ContainsKey(ip)) DeviceLists[ip].Dispose();
@@ -188,9 +189,7 @@ namespace BPASmartClient.DosingSystem.Model


//获取设备料仓剩余重量 //获取设备料仓剩余重量
deviceStatus.WeightFeedback = this.modbusTcp.GetUint(DeviceAddress.WeightFeedback) * 10; deviceStatus.WeightFeedback = this.modbusTcp.GetUint(DeviceAddress.WeightFeedback) * 10;
//获取料仓下限反馈
//获取料仓上限反馈
//获取下料重量(称)
deviceStatus.CutWeightFeedback = this.modbusTcp.GetUint(DeviceAddress.CutWeightFeedback) * 10;
Thread.Sleep(100); Thread.Sleep(100);
}), $"{DeviceName} 开始监听", true); }), $"{DeviceName} 开始监听", true);
} }


+ 1
- 1
DosingSystem/View/DeviceListView.xaml View File

@@ -51,7 +51,7 @@
Height="500" Height="500"
CurrentValue="50" />--> CurrentValue="50" />-->


<pry:MotorBottle CurrentValue="100" IsRun="True" />
<!--<pry:MotorBottle IsRun="True" CurrentValue="100"/>-->




<Grid> <Grid>


+ 1
- 0
DosingSystem/ViewModel/NewRecipeViewModel.cs View File

@@ -8,6 +8,7 @@ using System.Collections.ObjectModel;
using Microsoft.Toolkit.Mvvm.Input; using Microsoft.Toolkit.Mvvm.Input;
using BPASmartClient.Helper; using BPASmartClient.Helper;
using BPASmartClient.DosingSystem.Model; using BPASmartClient.DosingSystem.Model;
using BPASmartClient.CustomResource.Pages.Model;


namespace BPASmartClient.DosingSystem.ViewModel namespace BPASmartClient.DosingSystem.ViewModel
{ {


+ 8
- 8
DosingSystem/ViewModel/RecipeControlViewModel.cs View File

@@ -26,15 +26,15 @@ namespace BPASmartClient.DosingSystem.ViewModel
Recipes = Json<LocaPar>.Data.Recipes; Recipes = Json<LocaPar>.Data.Recipes;
StartCommand = new RelayCommand<object>((o) => 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, "提示", $"配方下发成功!"); NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"配方下发成功!");
MessageLog.GetInstance.ShowUserLog($"下发工单 {Guid.NewGuid().ToString()}"); MessageLog.GetInstance.ShowUserLog($"下发工单 {Guid.NewGuid().ToString()}");


+ 7
- 2
DosingSystem/ViewModel/RecipeSettingsViewModel.cs View File

@@ -16,6 +16,7 @@ using BPASmartClient.CustomResource.UserControls.Model;
using BPASmartClient.CustomResource.UserControls.Enum; using BPASmartClient.CustomResource.UserControls.Enum;
using System.Windows.Media; using System.Windows.Media;
using BPASmartClient.CustomResource.UserControls.MessageShow; using BPASmartClient.CustomResource.UserControls.MessageShow;
using BPASmartClient.CustomResource.Pages.Model;


namespace BPASmartClient.DosingSystem.ViewModel namespace BPASmartClient.DosingSystem.ViewModel
{ {
@@ -29,10 +30,12 @@ namespace BPASmartClient.DosingSystem.ViewModel
{ {
NewRecipeView nrv = new NewRecipeView(); NewRecipeView nrv = new NewRecipeView();
nrv.ShowDialog(); nrv.ShowDialog();
MessageLog.GetInstance.ShowUserLog("新建配方");
}); });
SaveRecipe = new RelayCommand(() => SaveRecipe = new RelayCommand(() =>
{ {
Json<LocaPar>.Save(); Json<LocaPar>.Save();
MessageLog.GetInstance.ShowUserLog("保存配方");
NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"配方保存成功!"); NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"配方保存成功!");
}); });
RemoveCommand = new RelayCommand<object>((o) => RemoveCommand = new RelayCommand<object>((o) =>
@@ -41,6 +44,7 @@ namespace BPASmartClient.DosingSystem.ViewModel
{ {
var res = Json<LocaPar>.Data.Recipes.FirstOrDefault(p => p.RecipCode == str); var res = Json<LocaPar>.Data.Recipes.FirstOrDefault(p => p.RecipCode == str);
if (res != null) Json<LocaPar>.Data.Recipes.Remove(res); 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"); ActionManage.GetInstance.CancelRegister("Details");
NewRecipeView nrv = new NewRecipeView(); 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(); nrv.ShowDialog();
MessageLog.GetInstance.ShowUserLog($"编辑配方名称——{res.RecipeName}");
} }
}); });
} }


Loading…
Cancel
Save