@@ -3,7 +3,7 @@ | |||
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;assembly=BPASmartClient.CustomResource" | |||
xmlns:convert ="clr-namespace:BPASmartClient.Academy.Converter" | |||
xmlns:convert="clr-namespace:BPASmartClient.Academy.Converter" | |||
xmlns:local="clr-namespace:BPASmartClient.Academy"> | |||
<Application.Resources> | |||
<ResourceDictionary> | |||
@@ -38,7 +38,7 @@ | |||
<ImageBrush x:Key="dbxt" ImageSource="/BPASmartClient.CustomResource;component/Image/顶部线条.png" /> | |||
</ResourceDictionary> | |||
<ResourceDictionary> | |||
<convert:DeviceCtrlConvert x:Key="deviceConvert"/> | |||
<convert:DeviceCtrlConvert x:Key="deviceConvert" /> | |||
</ResourceDictionary> | |||
</ResourceDictionary.MergedDictionaries> | |||
@@ -36,7 +36,7 @@ namespace BPASmartClient.Academy | |||
Forground = System.Windows.Media.Brushes.Red | |||
}); | |||
}); | |||
AlarmViewModel.AlarmInfos = MessageNotify.GetInstance.alarmLogs; | |||
//AlarmViewModel.AlarmInfos = MessageNotify.GetInstance.alarmLogs; | |||
ProgramStarted = new EventWaitHandle(false, EventResetMode.AutoReset, "Academy", out createNew); | |||
if (!createNew) | |||
{ | |||
@@ -86,9 +86,9 @@ namespace BPASmartClient.Academy | |||
mv.Show(); | |||
#endif | |||
MainWindow = mv; | |||
} | |||
} | |||
protected override void OnExit(ExitEventArgs e) | |||
{ | |||
@@ -8,29 +8,30 @@ using System.Threading.Tasks; | |||
namespace BPASmartClient.Academy.Model | |||
{ | |||
public class DataFeedback:NotifyBase | |||
public class DataFeedback : NotifyBase | |||
{ | |||
private string _id = Guid.NewGuid().ToString(); | |||
public string Id | |||
{ | |||
get { return _id; } | |||
set { _id = value;OnPropertyChanged(); } | |||
set { _id = value; OnPropertyChanged(); } | |||
} | |||
private string _name=""; | |||
private string _name = ""; | |||
public string Name | |||
{ | |||
get { return _name; } | |||
set { _name = value;OnPropertyChanged(); } | |||
set { _name = value; OnPropertyChanged(); } | |||
} | |||
public string ProductNumberId { get; set; } | |||
/// <summary> | |||
/// M101 速度曲线 | |||
/// </summary> | |||
public ChartValues<DataValue> M101_Speed { get; set; }= new ChartValues<DataValue>(); | |||
public ChartValues<DataValue> M101_Speed { get; set; } = new ChartValues<DataValue>(); | |||
/// <summary> | |||
/// M102 速度曲线 | |||
/// </summary> | |||
@@ -16,14 +16,14 @@ namespace BPASmartClient.Academy.Model | |||
public class HistorySqlite | |||
{ | |||
private static HistorySqlite _instance; | |||
public static HistorySqlite GetInstance { get; set; } = _instance??=new HistorySqlite(); | |||
public string DateString { get; set; }= DateTime.Now.ToString("yyyy-MM-dd"); | |||
public static HistorySqlite GetInstance { get; set; } = _instance ??= new HistorySqlite(); | |||
public string DateString { get; set; } = DateTime.Now.ToString("yyyy-MM-dd"); | |||
public HistorySqlite() { } | |||
public SqlSugarScope Db { get; set; } | |||
public SqlSugarScope Db { get; set; } | |||
public ObservableCollection<RecipeChart> recipeCharts { get; set; } = new ObservableCollection<RecipeChart>(); | |||
public void FindAllList() | |||
public void FindAllList() | |||
{ | |||
string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "AccessFile\\DB"); | |||
string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "AccessFile\\DB\\Data"); | |||
try | |||
{ | |||
DirectoryInfo directoryInfo = new DirectoryInfo(path); | |||
@@ -41,36 +41,36 @@ namespace BPASmartClient.Academy.Model | |||
}); | |||
Db.Queryable<SaveData>().Select(x => x.Name).Distinct().ToList().ForEach(t => | |||
{ | |||
recipeCharts.Add(new RecipeChart() | |||
recipeCharts.Add(new RecipeChart() | |||
{ | |||
Num = i++, | |||
Name = t, | |||
CreateTime = DateTime.Parse(e.Name.Replace("data","").Replace(".db","")) | |||
CreateTime = DateTime.Parse(e.Name.Replace("data", "").Replace(".db", "")) | |||
}); | |||
}); | |||
}); | |||
} | |||
catch (UnauthorizedAccessException ex) | |||
{ | |||
throw; | |||
} | |||
catch(DirectoryNotFoundException ex) | |||
catch (DirectoryNotFoundException ex) | |||
{ | |||
throw; | |||
} | |||
catch(Exception ex) | |||
catch (Exception ex) | |||
{ | |||
throw; | |||
} | |||
} | |||
public void FindDateList() | |||
public void FindDateList() | |||
{ | |||
string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"AccessFile\\DB\\data{DateString}.db"); | |||
string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"AccessFile\\DB\\Data\\data{DateString}.db"); | |||
if (File.Exists(path)) | |||
{ | |||
recipeCharts.Clear(); | |||
@@ -99,11 +99,45 @@ namespace BPASmartClient.Academy.Model | |||
}); | |||
} | |||
} | |||
public void FindProduct(string num) | |||
{ | |||
string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"AccessFile\\DB\\Data\\data{DateString}.db"); | |||
if (File.Exists(path)) | |||
{ | |||
recipeCharts.Clear(); | |||
Db = new SqlSugarScope(new ConnectionConfig() | |||
{ | |||
ConnectionString = $"Data Source = {path}", | |||
DbType = DbType.Sqlite, | |||
IsAutoCloseConnection = true, | |||
}); | |||
int i = 1; | |||
Db.Queryable<SaveData>().Select(x => x.Name).Distinct().ToList().ForEach(t => | |||
{ | |||
if (t == num) | |||
{ | |||
recipeCharts.Add(new RecipeChart() | |||
{ | |||
Num = i++, | |||
Name = t, | |||
CreateTime = DateTime.Parse(DateString) | |||
}); | |||
} | |||
}); | |||
} | |||
else | |||
{ | |||
MessageNotify.GetInstance.OpenMsg(EnumPromptType.Warn, "提示", "未找到对应的产品"); | |||
} | |||
} | |||
public List<SaveData> SelectName(string Name) | |||
{ | |||
try | |||
{ | |||
string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"AccessFile\\DB\\data{DateString}.db"); | |||
string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"AccessFile\\DB\\Data\\data{DateString}.db"); | |||
if (File.Exists(path)) | |||
{ | |||
Db = new SqlSugarScope(new ConnectionConfig() | |||
@@ -118,7 +152,7 @@ namespace BPASmartClient.Academy.Model | |||
{ | |||
return null; | |||
} | |||
} | |||
catch (Exception) | |||
{ | |||
@@ -1,4 +1,5 @@ | |||
using LiveCharts; | |||
using SqlSugar; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
@@ -7,11 +8,20 @@ using System.Threading.Tasks; | |||
namespace BPASmartClient.Academy.Model | |||
{ | |||
public class SaveData:NotifyBase | |||
public class SaveData : NotifyBase | |||
{ | |||
public string Id { get; set; } = ""; | |||
public string Name { get; set; } | |||
public DateTime Date { get; set; } | |||
//[SugarColumn(IsPrimaryKey = true)] | |||
public string Id { get; set; } | |||
///// <summary> | |||
///// 产品编号ID | |||
///// </summary> | |||
//public string ProductNumberId { get; set; } | |||
/// <summary> | |||
/// M101 速度曲线 | |||
/// </summary> | |||
@@ -32,11 +42,11 @@ namespace BPASmartClient.Academy.Model | |||
/// <summary> | |||
/// 反应釜温度 | |||
/// </summary> | |||
public int TempWok { get; set; } | |||
public int TempWok { get; set; } | |||
/// <summary> | |||
/// 配料罐温度 | |||
/// </summary> | |||
public int TempMaterial { get; set; } | |||
public int TempMaterial { get; set; } | |||
/// <summary> | |||
/// 反应釜排气温度 | |||
/// </summary> | |||
@@ -0,0 +1,29 @@ | |||
using SqlSugar; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.Academy.Model | |||
{ | |||
public class SaveNameData : SqliteBase | |||
{ | |||
/// <summary> | |||
/// 产品编号 | |||
/// </summary> | |||
public string ProductNumber { get; set; } | |||
public SaveNameData(string productNumber) | |||
{ | |||
ProductNumber = productNumber; | |||
Date = DateTime.Now; | |||
Id = Guid.NewGuid().ToString(); | |||
} | |||
public SaveNameData() | |||
{ | |||
Date = DateTime.Now; | |||
Id = Guid.NewGuid().ToString(); | |||
} | |||
} | |||
} |
@@ -324,6 +324,7 @@ namespace BPASmartClient.Academy.Model | |||
{ | |||
Id = Simens_PLC.GetInstance.id, | |||
Name = dataFeedback.Name, | |||
//ProductNumberId = dataFeedback.ProductNumberId, | |||
Date = DateTime.Now, | |||
M101_Speed = siemens.Read<int>("DB1.DBD2006").Content, | |||
M102_Speed = siemens.Read<int>("DB1.DBD2010").Content, | |||
@@ -19,7 +19,7 @@ namespace BPASmartClient.Academy.Model | |||
get | |||
{ | |||
Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory); | |||
return Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"AccessFile\\DB\\data{DateTime.Now.ToString("yyyy-MM-dd")}.db"); | |||
return Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"AccessFile\\DB\\Data\\data{DateTime.Now.ToString("yyyy-MM-dd")}.db"); | |||
} | |||
} | |||
public SqlSugarScope Db = new SqlSugarScope(new ConnectionConfig() | |||
@@ -38,16 +38,16 @@ namespace BPASmartClient.Academy.Model | |||
{ | |||
Db.DbMaintenance.CreateDatabase(); | |||
Db.CodeFirst.SetStringDefaultLength(100).InitTables<SaveData>(); | |||
Db.CodeFirst.SetStringDefaultLength(100).InitTables<SaveNameData>(); | |||
} | |||
else | |||
{ | |||
MessageNotify.GetInstance.ShowRunLog("创建失败"); | |||
} | |||
} | |||
catch (Exception) | |||
catch (Exception ex) | |||
{ | |||
throw; | |||
MessageNotify.GetInstance.ShowRunLog(ex.Message); | |||
} | |||
} | |||
public bool AddData(SaveData dfb) | |||
@@ -61,7 +61,20 @@ namespace BPASmartClient.Academy.Model | |||
return false; | |||
} | |||
} | |||
public List<SaveData> SelectId(string id) | |||
public bool AddData(SaveNameData snd) | |||
{ | |||
try | |||
{ | |||
return Db.Insertable(snd).ExecuteCommand() > 0; | |||
} | |||
catch (Exception) | |||
{ | |||
return false; | |||
} | |||
} | |||
public List<SaveData> SelectId(string id) | |||
{ | |||
try | |||
{ | |||
@@ -72,12 +85,12 @@ namespace BPASmartClient.Academy.Model | |||
return null; | |||
} | |||
} | |||
public List<String> SelectAllName() | |||
public List<String> SelectAllName() | |||
{ | |||
return Db.Queryable<SaveData>() | |||
.Select(x => x.Name) | |||
.Distinct() | |||
.ToList(); | |||
return Db.Queryable<SaveData>() | |||
.Select(x => x.Name) | |||
.Distinct() | |||
.ToList(); | |||
} | |||
} | |||
@@ -0,0 +1,19 @@ | |||
using SqlSugar; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.Academy.Model | |||
{ | |||
public class SqliteBase : NotifyBase | |||
{ | |||
public DateTime Date { get; set; } | |||
[SugarColumn(IsPrimaryKey = true)] | |||
public string Id { get; set; } | |||
} | |||
} |
@@ -54,11 +54,45 @@ | |||
HorizontalAlignment="Right" | |||
VerticalAlignment="Center" | |||
Orientation="Horizontal"> | |||
<TextBox Text="111" Width="120" Margin="0 0 60 0"/> | |||
<TextBlock | |||
VerticalAlignment="Center" | |||
FontSize="16" | |||
Foreground="DeepSkyBlue" | |||
Text="产品编号:" /> | |||
<TextBox | |||
Width="200" | |||
Height="30" | |||
Margin="0,0,10,0" | |||
VerticalContentAlignment="Center" | |||
Background="Transparent" | |||
BorderBrush="DeepSkyBlue" | |||
CaretBrush="DeepSkyBlue" | |||
FontSize="16" | |||
Foreground="DeepSkyBlue" | |||
Style="{x:Null}" | |||
Text="{Binding ProductNum}" /> | |||
<Button | |||
Width="120" | |||
Height="30" | |||
Command="{Binding FindProductCommand}" | |||
Content="查询编号" | |||
Style="{StaticResource ButtonStyle}" /> | |||
<TextBlock | |||
Margin="30,0,0,0" | |||
VerticalAlignment="Center" | |||
FontSize="16" | |||
Foreground="DeepSkyBlue" | |||
Text="查询时间:" /> | |||
<DatePicker | |||
Margin="0,0,60,0" | |||
Width="150" | |||
Margin="0,0,10,0" | |||
BorderBrush="DeepSkyBlue" | |||
FontSize="16" | |||
SelectedDate="{Binding SelectTime}" | |||
Style="{DynamicResource PickerStyle}" /> | |||
<Button | |||
Width="120" | |||
Height="30" | |||
@@ -28,10 +28,14 @@ namespace BPASmartClient.Academy.ViewModel | |||
IsChecked = true; | |||
DataFeedback dataFeedback = new DataFeedback(); | |||
dataFeedback.Name = Name; | |||
var snd = new SaveNameData(Name); | |||
dataFeedback.ProductNumberId = snd.Id; | |||
Sqlite.GetInstance.AddData(snd); | |||
Simens_PLC.GetInstance.id = Guid.NewGuid().ToString(); | |||
Simens_PLC.GetInstance.dataFeedback = dataFeedback; | |||
Simens_PLC.GetInstance.siemens.Write<bool>("DB1.DBX1002.0", true); | |||
Simens_PLC.GetInstance.siemens.Write<bool>("DB1.DBX1002.1", true); | |||
Content = "系统停止"; | |||
break; | |||
case "系统停止": | |||
@@ -6,20 +6,25 @@ using System.Threading.Tasks; | |||
namespace BPASmartClient.Academy.ViewModel | |||
{ | |||
internal class HistoryChartViewModel:NotifyBase | |||
internal class HistoryChartViewModel : NotifyBase | |||
{ | |||
public HistoryChartViewModel() | |||
public HistoryChartViewModel() | |||
{ | |||
HistorySqlite.GetInstance.FindAllList(); | |||
Select = new BPARelayCommand(() => | |||
Select = new BPARelayCommand(() => | |||
{ | |||
HistorySqlite.GetInstance.DateString = SelectTime.ToString("yyyy-MM-dd"); | |||
HistorySqlite.GetInstance.FindDateList(); | |||
}); | |||
FindProductCommand = new BPARelayCommand(() => | |||
{ | |||
HistorySqlite.GetInstance.FindProduct(ProductNum); | |||
}); | |||
} | |||
public ObservableCollection<RecipeChart> RecipeCharts { get; set; }=HistorySqlite.GetInstance.recipeCharts; | |||
public ObservableCollection<RecipeChart> RecipeCharts { get; set; } = HistorySqlite.GetInstance.recipeCharts; | |||
private DateTime _selectTime = DateTime.Now; | |||
@@ -29,7 +34,14 @@ namespace BPASmartClient.Academy.ViewModel | |||
set { _selectTime = value; OnPropertyChanged(); } | |||
} | |||
public string ProductNum { get { return _mProductNum; } set { _mProductNum = value; OnPropertyChanged(); } } | |||
private string _mProductNum; | |||
public BPARelayCommand Select { get; set; } | |||
public BPARelayCommand FindProductCommand { get; set; } | |||
} | |||
public class RecipeChart : NotifyBase | |||
{ | |||
@@ -55,7 +67,7 @@ namespace BPASmartClient.Academy.ViewModel | |||
public DateTime CreateTime | |||
{ | |||
get { return _createTime; } | |||
set { _createTime = value;OnPropertyChanged(); } | |||
set { _createTime = value; OnPropertyChanged(); } | |||
} | |||
} | |||
@@ -46,7 +46,7 @@ namespace BPASmartClient.CustomResource.Pages.Model | |||
{ | |||
Sqlite<UserLog>.GetInstance.Save(); | |||
Sqlite<RunLog>.GetInstance.Save(); | |||
Sqlite<BPASmartClient.Model.Alarm>.GetInstance.Save(); | |||
//Sqlite<BPASmartClient.Model.Alarm>.GetInstance.Save(); | |||
Sqlite<RecipeCompleteLog>.GetInstance.Save(); | |||
} | |||
catch (Exception) | |||
@@ -130,19 +130,22 @@ namespace BPASmartClient.CustomResource.Pages.Model | |||
{ | |||
lock (alarmlock) | |||
{ | |||
AlarmID++; | |||
BPASmartClient.Model.Alarm alarmLog = new BPASmartClient.Model.Alarm() | |||
{ | |||
NumId = AlarmID, | |||
Date = DateTime.Now.ToString("yyyy-MM-dd"), | |||
Time = DateTime.Now.ToString("HH:mm:ss"), | |||
Info = info, | |||
Value = AlarmNumber, | |||
Grade = (level) + "" | |||
}; | |||
Sqlite<BPASmartClient.Model.Alarm>.GetInstance.Base.Add(alarmLog); | |||
Application.Current.Dispatcher.Invoke(new Action(() => { alarmLogs.Insert(0, alarmLog); })); | |||
AlarmLog?.Invoke(info); | |||
LogHelper.GetInstance.AddAlarm(info, AlarmNumber); | |||
//AlarmID++; | |||
// BPASmartClient.Model.Alarm alarmLog = new BPASmartClient.Model.Alarm() | |||
// { | |||
// NumId = AlarmID, | |||
// Date = DateTime.Now.ToString("yyyy-MM-dd"), | |||
// Time = DateTime.Now.ToString("HH:mm:ss"), | |||
// Info = info, | |||
// Value = AlarmNumber, | |||
// Grade = (level) + "" | |||
// }; | |||
// Sqlite<BPASmartClient.Model.Alarm>.GetInstance.Base.Add(alarmLog); | |||
// Application.Current.Dispatcher.Invoke(new Action(() => { alarmLogs.Insert(0, alarmLog); })); | |||
// AlarmLog?.Invoke(info); | |||
} | |||
} | |||
@@ -11,6 +11,7 @@ using System.Windows; | |||
using BPASmartClient.CustomResource.Pages.Model; | |||
using BPASmartClient.Model; | |||
using System.Threading; | |||
using Microsoft.EntityFrameworkCore.Migrations; | |||
namespace BPASmartClient.CustomResource.Pages.ViewModel | |||
{ | |||
@@ -18,24 +19,41 @@ namespace BPASmartClient.CustomResource.Pages.ViewModel | |||
{ | |||
public AlarmViewModel() | |||
{ | |||
ControlCommand = new BPARelayCommand(() => | |||
ControlCommand = new BPARelayCommand(async () => | |||
{ | |||
if (ControlButText == "报警复位") | |||
{ | |||
return; | |||
} | |||
if (ControlButText == "报警复位") return; | |||
if (ControlButText == "开始查询") | |||
{ | |||
var lists = Sqlite<BPASmartClient.Model.Alarm>.GetInstance.GetData(); | |||
var res = lists.Where(p => Convert.ToDateTime(p.Date) >= StartDateTime && Convert.ToDateTime(p.Date) <= EndDateTime).ToList(); | |||
if (res != null) | |||
var startTime = Convert.ToDateTime($"{DateTime.Now.Year}-{DateTime.Now.Month}-{DateTime.Now.Day} {StartTS.Hours}:{StartTS.Minutes}:{StartTS.Seconds}"); | |||
var endTime = Convert.ToDateTime($"{DateTime.Now.Year}-{DateTime.Now.Month}-{DateTime.Now.Day} {EndTS.Hours}:{EndTS.Minutes}:{EndTS.Seconds}"); | |||
var res = await LogHelper.GetInstance.QueryableAsync<BPA.Helper.Log.DB.Alarm>(startTime, endTime); | |||
if (res != null) HistoryAlarm.Clear(); | |||
int count = 0; | |||
res?.ForEach(item => | |||
{ | |||
HistoryAlarm.Clear(); | |||
foreach (var item in res) | |||
count++; | |||
HistoryAlarm.Add(new Alarm() | |||
{ | |||
HistoryAlarm.Add(item); | |||
} | |||
} | |||
Date = item.Date, | |||
Grade = item.Grade, | |||
NumId = count, | |||
Info = item.MsgInfo, | |||
Time = item.Time, | |||
Value = item.Value | |||
}); | |||
}); | |||
//var lists = Sqlite<BPASmartClient.Model.Alarm>.GetInstance.GetData(); | |||
//var res = lists.Where(p => Convert.ToDateTime(p.Date) >= StartDateTime && Convert.ToDateTime(p.Date) <= EndDateTime).ToList(); | |||
//if (res != null) | |||
//{ | |||
// HistoryAlarm.Clear(); | |||
// foreach (var item in res) | |||
// { | |||
// HistoryAlarm.Add(item); | |||
// } | |||
//} | |||
} | |||
}); | |||
@@ -68,21 +86,43 @@ namespace BPASmartClient.CustomResource.Pages.ViewModel | |||
} | |||
private void GetHistoryAlarm() | |||
private async void GetHistoryAlarm() | |||
{ | |||
var data = Sqlite<BPASmartClient.Model.Alarm>.GetInstance.GetData(); | |||
if (data != null) | |||
var startTime = Convert.ToDateTime($"{DateTime.Now.Year}-{DateTime.Now.Month}-{DateTime.Now.Day} 00:00:00"); | |||
var endTime = Convert.ToDateTime($"{DateTime.Now.Year}-{DateTime.Now.Month}-{DateTime.Now.Day} 23:59:59"); | |||
var res = await LogHelper.GetInstance.QueryableAsync<BPA.Helper.Log.DB.Alarm>(startTime, endTime); | |||
if (res != null) HistoryAlarm.Clear(); | |||
int count = 0; | |||
res?.ForEach(item => | |||
{ | |||
HistoryAlarm.Clear(); | |||
foreach (var item in data) | |||
count++; | |||
HistoryAlarm.Add(new Alarm() | |||
{ | |||
int day = DateTime.Now.Subtract(Convert.ToDateTime(item.Date)).Days; | |||
if (day == 0) | |||
{ | |||
HistoryAlarm.Add(item); | |||
} | |||
} | |||
} | |||
Date = item.Date, | |||
Grade = item.Grade, | |||
NumId = count, | |||
Info = item.MsgInfo, | |||
Time = item.Time, | |||
Value = item.Value | |||
}); | |||
}); | |||
//var data = Sqlite<BPASmartClient.Model.Alarm>.GetInstance.GetData(); | |||
//if (data != null) | |||
//{ | |||
// HistoryAlarm.Clear(); | |||
// foreach (var item in data) | |||
// { | |||
// int day = DateTime.Now.Subtract(Convert.ToDateTime(item.Date)).Days; | |||
// if (day == 0) | |||
// { | |||
// HistoryAlarm.Add(item); | |||
// } | |||
// } | |||
//} | |||
} | |||
public BPARelayCommand SwitchCommand { get; set; } | |||
@@ -129,8 +169,21 @@ namespace BPASmartClient.CustomResource.Pages.ViewModel | |||
public DateTime EndDateTime { get { return _mEndDateTime; } set { _mEndDateTime = value; OnPropertyChanged(); } } | |||
private DateTime _mEndDateTime = DateTime.Now; | |||
/// <summary> | |||
/// 开始时间 | |||
/// </summary> | |||
public TimeSpan StartTS { get { return _mStartTS; } set { _mStartTS = value; OnPropertyChanged(); } } | |||
private TimeSpan _mStartTS = new TimeSpan(0, 0, 0); | |||
/// <summary> | |||
/// 结束时间 | |||
/// </summary> | |||
public TimeSpan EndTS { get { return _mEndTS; } set { _mEndTS = value; OnPropertyChanged(); } } | |||
private TimeSpan _mEndTS = new TimeSpan(23, 59, 59); | |||
public static ObservableCollection<BPASmartClient.Model.Alarm> AlarmInfos { get; set; } | |||
public static ObservableCollection<BPASmartClient.Model.Alarm> AlarmInfos { get; set; } = new(); | |||
public ObservableCollection<BPASmartClient.Model.Alarm> HistoryAlarm { get; set; } = new(); | |||
} | |||
@@ -109,6 +109,7 @@ namespace BPASmartClient.CustomResource.Pages.ViewModel | |||
if (c != null) | |||
IsAlarm = Convert.ToBoolean(c); | |||
}), "HeartBeatCheck"); | |||
LogInit(); | |||
} | |||
private void PermissionChange() | |||
@@ -119,12 +120,40 @@ namespace BPASmartClient.CustomResource.Pages.ViewModel | |||
int SubIndex; SubIndex = Array.FindIndex(menuModels.ElementAt(MainIndex).subMenumodels.ToArray(), p => p.SubMenuVisibility == Visibility.Visible); | |||
if (SubIndex >= 0 && SubIndex < menuModels.ElementAt(MainIndex).subMenumodels.Count) | |||
{ | |||
//DoNavChanged(menuModels.ElementAt(MainIndex).subMenumodels.ElementAt(SubIndex).ToggleWindowPath); | |||
DoNavChanged(menuModels.ElementAt(MainIndex).subMenumodels.ElementAt(SubIndex)); | |||
} | |||
} | |||
} | |||
private void LogInit() | |||
{ | |||
LogHelper.GetInstance.Init(); | |||
LogHelper.GetInstance.ShowAlarmLog = s => | |||
{ | |||
//if (AlarmViewModel.AlarmInfos == null) AlarmViewModel.AlarmInfos = new ObservableCollection<Alarm>(); | |||
Alarm alarm = new Alarm() | |||
{ | |||
Date = s.Date, | |||
Grade = s.Grade, | |||
NumId = AlarmViewModel.AlarmInfos.Count, | |||
Info = s.MsgInfo, | |||
Time = s.Time, | |||
Value = s.Value | |||
}; | |||
Application.Current?.Dispatcher.Invoke(() => | |||
{ | |||
if (AlarmViewModel.AlarmInfos.Count <= 0) AlarmViewModel.AlarmInfos.Add(alarm); | |||
else if (AlarmViewModel.AlarmInfos.Count > 0) AlarmViewModel.AlarmInfos.Insert(0, alarm); | |||
}); | |||
for (int i = 0; i < AlarmViewModel.AlarmInfos.Count; i++) | |||
{ | |||
AlarmViewModel.AlarmInfos[i].NumId = i + 1; | |||
} | |||
}; | |||
} | |||
public ObservableCollection<MenuModel> menuModels { get; set; } | |||
private void DoNavChanged(object obj) | |||
@@ -59,10 +59,10 @@ | |||
<Grid x:Name="gr" SnapsToDevicePixels="True"> | |||
<pry:BeveledButton | |||
x:Name="bb" | |||
FillColor="#F14129" | |||
IsParallelogram="False" | |||
StrokeThickness="1" /> | |||
x:Name="bb" | |||
FillColor="#F14129" | |||
IsParallelogram="False" | |||
StrokeThickness="1" /> | |||
<ContentPresenter | |||
x:Name="contentPresenter" | |||
@@ -156,7 +156,7 @@ | |||
Content="{TemplateBinding Content}" | |||
ContentStringFormat="{TemplateBinding ContentStringFormat}" | |||
ContentTemplate="{TemplateBinding ContentTemplate}" | |||
Foreground="{TemplateBinding Foreground}"/> | |||
Foreground="{TemplateBinding Foreground}" /> | |||
</Grid> | |||
<ControlTemplate.Triggers> | |||
<Trigger Property="IsChecked" Value="True"> | |||