Przeglądaj źródła

暂存

reconfiguration
lyw 2 miesięcy temu
rodzic
commit
27091e8c2d
21 zmienionych plików z 2543 dodań i 432 usunięć
  1. +68
    -0
      BPASmartClient.Academy/50L/DeviceStatus.cs
  2. +59
    -26
      BPASmartClient.Academy/50L/PlcControl.cs
  3. +50
    -21
      BPASmartClient.Academy/50L/SqliteOperate.cs
  4. +32
    -32
      BPASmartClient.Academy/App.xaml.cs
  5. +54
    -0
      BPASmartClient.Academy/Model/DataFeedback.cs
  6. +149
    -147
      BPASmartClient.Academy/Model/HistorySqlite.cs
  7. +4
    -1
      BPASmartClient.Academy/Model/SaveData.cs
  8. +1
    -1
      BPASmartClient.Academy/Model/SaveNameData.cs
  9. +26
    -4
      BPASmartClient.Academy/Model/Simens_PLC.cs
  10. +45
    -7
      BPASmartClient.Academy/Model/Sqlite.cs
  11. +1
    -1
      BPASmartClient.Academy/View/DeviceChart50LView.xaml
  12. +2
    -2
      BPASmartClient.Academy/View/DeviceChartView.xaml.cs
  13. +179
    -22
      BPASmartClient.Academy/View/DeviceMotionView.xaml
  14. +161
    -135
      BPASmartClient.Academy/View/DeviceMotionView.xaml.cs
  15. +5
    -5
      BPASmartClient.Academy/View/HistoryChartView.xaml
  16. +6
    -9
      BPASmartClient.Academy/View/HistoryChartView.xaml.cs
  17. +1679
    -6
      BPASmartClient.Academy/View/ReactionKettle50LView.xaml
  18. +6
    -5
      BPASmartClient.Academy/ViewModel/DeviceChart50LViewModel.cs
  19. +1
    -2
      BPASmartClient.Academy/ViewModel/DeviceMotionViewModel.cs
  20. +8
    -5
      BPASmartClient.Academy/ViewModel/HistoryChartViewModel.cs
  21. +7
    -1
      BPASmartClient.Academy/ViewModel/ReactionKettle50LViewModel.cs

+ 68
- 0
BPASmartClient.Academy/50L/DeviceStatus.cs Wyświetl plik

@@ -0,0 +1,68 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmartClient.Academy._50L
{
public class DeviceStatus:NotifyBase
{
/// <summary>
/// 旋转电机启停反馈
/// </summary>
public bool TurnMotor{get { return _turnMotor; }set { _turnMotor = value; OnPropertyChanged(); }}
private bool _turnMotor;
/// <summary>
/// 负压风机启动反馈
/// </summary>
public bool Fans { get { return _fans; } set { _fans = value; OnPropertyChanged(); } }
private bool _fans;
/// <summary>
/// 压缩空气进气阀反馈
/// </summary>
public bool InAir { get { return _inAir; } set { _inAir = value; OnPropertyChanged(); } }
private bool _inAir;
/// <summary>
/// 排热空气阀反馈
/// </summary>
public bool OutAir { get { return _outAir; } set { _outAir = value; OnPropertyChanged(); } }
private bool _outAir;
/// <summary>
/// 泄压阀反馈
/// </summary>
public bool RelivePre { get { return _relivePre; } set { _relivePre = value; OnPropertyChanged(); } }
private bool _relivePre;
/// <summary>
/// 进冷却水阀反馈
/// </summary>
public bool InCold { get { return _inCold; } set { _inCold = value; OnPropertyChanged(); } }
private bool _inCold;
/// <summary>
/// 出冷却水阀反馈
/// </summary>
public bool OutCold { get { return _outCold; } set { _outCold = value; OnPropertyChanged(); } }
private bool _outCold;
/// <summary>
/// 蒸汽梳水阀反馈
/// </summary>
public bool CardWater { get { return _cardWater; } set { _cardWater = value; OnPropertyChanged(); } }
private bool _cardWater;
/// <summary>
/// 冷凝水罐进水阀反馈
/// </summary>
public bool ColdPot { get { return _coldPot; } set { _coldPot = value; OnPropertyChanged(); } }
private bool _coldPot;
/// <summary>
/// 称重水罐负压阀反馈
/// </summary>
public bool WeightPot { get { return _weightPot; } set { _weightPot = value; OnPropertyChanged(); } }
private bool _weightPot;
/// <summary>
/// 反应釜原点位置反馈
/// </summary>
public bool OriginBit { get { return _originBit; } set { _originBit = value; OnPropertyChanged(); } }
private bool _originBit;

}
}

+ 59
- 26
BPASmartClient.Academy/50L/PlcControl.cs Wyświetl plik

@@ -15,16 +15,17 @@ namespace BPASmartClient.Academy._50L
private volatile static PlcControl _Instance;
public static PlcControl GetInstance => _Instance ?? (_Instance = new PlcControl());
private PlcControl() { }

public bool? IsConnect => comm.IsReconnect;
public DeviceStatus DeviceStatus { get; set; } = new DeviceStatus();
private ICommSiemens comm = CommHelper.Siemens;

public void Init()
{
//CommHelper.CreateSiemens(CpuType.S7200Smart, Json<DevicePar>.Data.IpAddress).OnSuccess(s =>
//{
// comm = s.Content;
// Read();
//});
CommHelper.CreateSiemens(CpuType.S7200Smart, Json<DevicePar>.Data.IpAddress).OnSuccess(s =>
{
comm = s.Content;
Read();
});
}


@@ -36,30 +37,55 @@ namespace BPASmartClient.Academy._50L
{
comm.Read<bool[]>("DB1.DBX2000.0", 11).OnSuccess(s =>
{
Data[FeedbackData.旋转电机启停反馈] = s.Content[0];
Data[FeedbackData.负压风机启动反馈] = s.Content[1];
Data[FeedbackData.压缩空气进气阀反馈] = s.Content[2];
Data[FeedbackData.排热空气阀反馈] = s.Content[3];
Data[FeedbackData.泄压阀反馈] = s.Content[4];
Data[FeedbackData.进冷却水阀反馈] = s.Content[5];
Data[FeedbackData.出冷却水阀反馈] = s.Content[6];
Data[FeedbackData.蒸汽梳水阀反馈] = s.Content[7];
Data[FeedbackData.冷凝水罐进水阀反馈] = s.Content[8];
Data[FeedbackData.称重水罐负压阀反馈] = s.Content[9];
Data[FeedbackData.反应釜原点位置反馈] = s.Content[10];
//Data[FeedbackData.旋转电机启停反馈] = s.Content[0];
//Data[FeedbackData.负压风机启动反馈] = s.Content[1];
//Data[FeedbackData.压缩空气进气阀反馈] = s.Content[2];
//Data[FeedbackData.排热空气阀反馈] = s.Content[3];
//Data[FeedbackData.泄压阀反馈] = s.Content[4];
//Data[FeedbackData.进冷却水阀反馈] = s.Content[5];
//Data[FeedbackData.出冷却水阀反馈] = s.Content[6];
//Data[FeedbackData.蒸汽梳水阀反馈] = s.Content[7];
//Data[FeedbackData.冷凝水罐进水阀反馈] = s.Content[8];
//Data[FeedbackData.称重水罐负压阀反馈] = s.Content[9];
//Data[FeedbackData.反应釜原点位置反馈] = s.Content[10];
DeviceStatus.TurnMotor = s.Content[0];
DeviceStatus.Fans = s.Content[1];
DeviceStatus.InAir = s.Content[2];
DeviceStatus.OutAir = s.Content[3];
DeviceStatus.RelivePre = s.Content[4];
DeviceStatus.InCold = s.Content[5];
DeviceStatus.OutCold = s.Content[6];
DeviceStatus.CardWater = s.Content[7];
DeviceStatus.ColdPot = s.Content[8];
DeviceStatus.WeightPot = s.Content[9];
DeviceStatus.OriginBit = s.Content[10];
});

comm.Read<float[]>("DB1.DBD2006", 9).OnSuccess(s =>
{
Data[FeedbackData.反应釜温度] = s.Content[0];
Data[FeedbackData.反应釜蒸汽压力] = s.Content[1];
Data[FeedbackData.反应釜蒸汽流量] = s.Content[2];
Data[FeedbackData.冷凝水罐温度] = s.Content[3];
Data[FeedbackData.冷凝水罐湿度] = s.Content[4];
Data[FeedbackData.负压流量] = s.Content[5];
Data[FeedbackData.称重水罐重量] = s.Content[6];
Data[FeedbackData.反应釜编码器值] = s.Content[7];
Data[FeedbackData.蒸汽比例阀实际开度] = s.Content[8];
//Data[FeedbackData.反应釜温度] = s.Content[0];
//Data[FeedbackData.反应釜蒸汽压力] = s.Content[1];
//Data[FeedbackData.反应釜蒸汽流量] = s.Content[2];
//Data[FeedbackData.冷凝水罐温度] = s.Content[3];
//Data[FeedbackData.冷凝水罐湿度] = s.Content[4];
//Data[FeedbackData.负压流量] = s.Content[5];
//Data[FeedbackData.称重水罐重量] = s.Content[6];
//Data[FeedbackData.反应釜编码器值] = s.Content[7];
//Data[FeedbackData.蒸汽比例阀实际开度] = s.Content[8];
SamplingData sampling = new SamplingData()
{
Temperature = s.Content[0],
SteamPressure = s.Content[1],
SteamFlowRate = s.Content[2],
CondensateWaterTemperature = s.Content[3],
CondensateWaterHumidity = s.Content[4],
NegativePressureFlowRate = s.Content[5],
WeighingWaterTankWeight = s.Content[6],
ProportionalValveOpening = s.Content[7],
};
SqliteOperate.GetInstance.Add(sampling);
SqliteOperate.GetInstance.RealtimeChart(sampling);

});

comm.Read<bool[]>("DB1.DBX1003.7", 1).OnSuccess(s => { Data[FeedbackData.心跳] = s.Content[0]; });
@@ -77,6 +103,13 @@ namespace BPASmartClient.Academy._50L
}
Thread.Sleep(10);
}, "数据获取", true);
ThreadManage.GetInstance.StartLong(() =>
{
if (true)//产品开始测试数据
{
}
}, "实时曲线数据");

}



+ 50
- 21
BPASmartClient.Academy/50L/SqliteOperate.cs Wyświetl plik

@@ -1,4 +1,5 @@
using SqlSugar;
using LiveCharts;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.IO;
@@ -13,6 +14,7 @@ namespace BPASmartClient.Academy._50L
{
private volatile static SqliteOperate _Instance;
public static SqliteOperate GetInstance => _Instance ?? (_Instance = new SqliteOperate());
public DataFeedBack_50 DataFeedBacks { get; set; } = new DataFeedBack_50();
private SqliteOperate() { }

static string directoryPath = $"AccessFile\\DB\\{Json<DevicePar>.Data.ProjectTypeName.ToString()}";
@@ -46,30 +48,57 @@ namespace BPASmartClient.Academy._50L
catch (Exception ex)
{ }
}

/// <summary>
/// 生成测试数据
/// </summary>
private void CreateTestData()
public void RealtimeChart(SamplingData sampling)
{
for (int i = 0; i < 5; i++)
DateTime time = DateTime.Now;
DataView(DataFeedBacks.Temperature, new DataValue() { DateTime = time, Value = sampling.Temperature });
DataView(DataFeedBacks.SteamPressure, new DataValue() { DateTime = time, Value = sampling.SteamPressure });
DataView(DataFeedBacks.SteamFlowRate, new DataValue() { DateTime = time, Value = sampling.SteamFlowRate });
DataView(DataFeedBacks.CondensateWaterTemperature, new DataValue() { DateTime = time, Value = sampling.CondensateWaterTemperature });
DataView(DataFeedBacks.CondensateWaterHumidity, new DataValue() { DateTime = time, Value = sampling.CondensateWaterHumidity });
DataView(DataFeedBacks.NegativePressureFlowRate, new DataValue() { DateTime = time, Value = sampling.NegativePressureFlowRate });
DataView(DataFeedBacks.WeighingWaterTankWeight, new DataValue() { DateTime = time, Value = sampling.WeighingWaterTankWeight });
DataView(DataFeedBacks.ProportionalValveOpening, new DataValue() { DateTime = time, Value = sampling.ProportionalValveOpening });
}
private void DataView<T>(ChartValues<T> values, T value)
{
if (values.Count >= 20)
{
var d1 = new SaveNameData($"test{DateTime.Now.Ticks}");
Add(d1);
Random rd = new Random();
List<SamplingData> sd = new List<SamplingData>();
for (int m = 0; m < 10000; m++)
{
sd.Add(new SamplingData(d1.Id));
}
for (int x = 0; x < 10; x++)
{
Db.Insertable<SamplingData>(sd.GetRange(0 * 1000, 1000)).SplitTable().ExecuteCommand();
}
values.RemoveAt(0);
values.Add(value);
}
else
{
values.Add(value);
}
MessageNotify.GetInstance.OpenMsg("测试数据生成成功");
}

///// <summary>
///// 生成测试数据
///// </summary>
//private void CreateTestData()
//{
// for (int i = 0; i < 5; i++)
// {
// var d1 = new SaveNameData($"test{DateTime.Now.Ticks}");
// Add(d1);
// Random rd = new Random();
// List<SamplingData> sd = new List<SamplingData>();
// for (int m = 0; m < 10000; m++)
// {
// sd.Add(new SamplingData(d1.Id));
// }
// for (int x = 0; x < 10; x++)
// {
// Db.Insertable<SamplingData>(sd.GetRange(0 * 1000, 1000)).SplitTable().ExecuteCommand();
// }
// }
// MessageNotify.GetInstance.OpenMsg("测试数据生成成功");
//}
/// <summary>
/// 数据库存储曲线数据
/// </summary>
/// <param name="sd">曲线数据/组</param>
public void Add(SamplingData sd)
{
try


+ 32
- 32
BPASmartClient.Academy/App.xaml.cs Wyświetl plik

@@ -53,40 +53,40 @@ namespace BPASmartClient.Academy
MainView mv = new MainView();
string typeName = Json<DevicePar>.Data.ProjectTypeName == ProjectType.HKYF20240714.ToString() ? "10L" : "50L";
mv.TitleName = $"{typeName} 反应釜焖制系统 V1.0.1";
#if !DEBUG
LoginView lv = new LoginView();
var res = lv.ShowDialog();
if (res != null && res == true)
{
#region 更新测试
//string directory = $"{AppDomain.CurrentDomain.BaseDirectory}AccessFile\\JSON\\UpdateModel.json";
//if (File.Exists(directory))
// mv.TitleName = $"味魔方管理系统软件[简称:味魔方] {Json<UpdateModel>.Data.UpgradeVersion}";
//else
//{
// mv.TitleName = $"味魔方管理系统软件[简称:味魔方] V1.0.1";
// Task.Run(() =>
// {
// Thread.Sleep(3000);
// var tt = MessageNotify.GetInstance.ShowDialog("检测到新版本,请问是否现在更新?", DialogType.Information);
// if (tt)
// {
// string directory = AppDomain.CurrentDomain.BaseDirectory;
// Process.Start($"{directory}BPASmartClient.Update.exe");
// App.Current.Dispatcher.Invoke(() => { mv.Close(); });
// }
// });
//}
#endregion
//#if !DEBUG
// LoginView lv = new LoginView();
// var res = lv.ShowDialog();
// if (res != null && res == true)
// {
// #region 更新测试
// //string directory = $"{AppDomain.CurrentDomain.BaseDirectory}AccessFile\\JSON\\UpdateModel.json";
// //if (File.Exists(directory))
// // mv.TitleName = $"味魔方管理系统软件[简称:味魔方] {Json<UpdateModel>.Data.UpgradeVersion}";
// //else
// //{
// // mv.TitleName = $"味魔方管理系统软件[简称:味魔方] V1.0.1";
// // Task.Run(() =>
// // {
// // Thread.Sleep(3000);
// // var tt = MessageNotify.GetInstance.ShowDialog("检测到新版本,请问是否现在更新?", DialogType.Information);
// // if (tt)
// // {
// // string directory = AppDomain.CurrentDomain.BaseDirectory;
// // Process.Start($"{directory}BPASmartClient.Update.exe");
// // App.Current.Dispatcher.Invoke(() => { mv.Close(); });
// // }
// // });
// //}
// #endregion

BPASmartClient.CustomResource.Pages.Model.MessageNotify.GetInstance.ShowUserLog("用户登录");
mv.Show();
}
else
mv.Close();
#else
// BPASmartClient.CustomResource.Pages.Model.MessageNotify.GetInstance.ShowUserLog("用户登录");
// mv.Show();
// }
// else
// mv.Close();
//#else
mv.Show();
#endif
//#endif
MainWindow = mv;
}



+ 54
- 0
BPASmartClient.Academy/Model/DataFeedback.cs Wyświetl plik

@@ -67,4 +67,58 @@ namespace BPASmartClient.Academy.Model
public ChartValues<DataValue> WeightWok { get; set; } = new ChartValues<DataValue>();

}

public class DataFeedBack_50 : NotifyBase
{
private string _id = Guid.NewGuid().ToString();

public string Id
{
get { return _id; }
set { _id = value; OnPropertyChanged(); }
}

private string _name = "";

public string Name
{
get { return _name; }
set { _name = value; OnPropertyChanged(); }
}

public string ProductNumberId { get; set; }

/// <summary>
/// 反应釜温度
/// </summary>
public ChartValues<DataValue> Temperature { get; set; } = new ChartValues<DataValue>();
/// <summary>
/// 反应釜蒸汽压力
/// </summary>
public ChartValues<DataValue> SteamPressure { get; set; } = new ChartValues<DataValue>();
/// <summary>
/// 反应釜蒸汽流量
/// </summary>
public ChartValues<DataValue> SteamFlowRate { get; set; } = new ChartValues<DataValue>();
/// <summary>
/// 冷凝水罐温度
/// </summary>
public ChartValues<DataValue> CondensateWaterTemperature { get; set; } = new ChartValues<DataValue>();
/// <summary>
/// 冷凝水罐湿度
/// </summary>
public ChartValues<DataValue> CondensateWaterHumidity { get; set; } = new ChartValues<DataValue>();
/// <summary>
/// 负压流量
/// </summary>
public ChartValues<DataValue> NegativePressureFlowRate { get; set; } = new ChartValues<DataValue>();
/// <summary>
/// 称重水罐重量
/// </summary>
public ChartValues<DataValue> WeighingWaterTankWeight { get; set; } = new ChartValues<DataValue>();
/// <summary>
/// 蒸汽比例阀实际开度
/// </summary>
public ChartValues<DataValue> ProportionalValveOpening { get; set; } = new ChartValues<DataValue>();
}
}

+ 149
- 147
BPASmartClient.Academy/Model/HistorySqlite.cs Wyświetl plik

@@ -13,160 +13,162 @@ using System.Threading.Tasks;

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 HistorySqlite() { }
public SqlSugarScope Db { get; set; }
public ObservableCollection<RecipeChart> recipeCharts { get; set; } = new ObservableCollection<RecipeChart>();
private string directoryPath = $"AccessFile\\DB\\{Json<DevicePar>.Data.ProjectTypeName}";
public void FindAllList()
{
string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, directoryPath);
try
{
DirectoryInfo directoryInfo = new DirectoryInfo(path);
FileInfo[] files = directoryInfo.GetFiles();
string[] filePath = Directory.GetFiles(path);
recipeCharts.Clear();
int i = 1;
files.ToList().ForEach(e =>
{
Db = new SqlSugarScope(new ConnectionConfig()
{
ConnectionString = $"Data Source = {e.FullName}",
DbType = DbType.Sqlite,
IsAutoCloseConnection = true,
});
Db.Queryable<SaveData>().Select(x => x.Name).Distinct().ToList().ForEach(t =>
{
recipeCharts.Add(new RecipeChart()
{
Num = i++,
Name = t,
CreateTime = DateTime.Parse(e.Name.Replace("data", "").Replace(".db", ""))
});
});
});
//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 HistorySqlite() { }
//public SqlSugarScope Db { get; set; }
//public ObservableCollection<RecipeChart> recipeCharts { get; set; } = new ObservableCollection<RecipeChart>();
//private string directoryPath = $"AccessFile\\DB\\{Json<DevicePar>.Data.ProjectTypeName}";

}
catch (UnauthorizedAccessException ex)
{
throw;
}
catch (DirectoryNotFoundException ex)
{
throw;
}
catch (Exception ex)
{
throw;
}
}
//public void FindAllList()
//{
// string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, directoryPath);
// try
// {
// DirectoryInfo directoryInfo = new DirectoryInfo(path);
// FileInfo[] files = directoryInfo.GetFiles();
// string[] filePath = Directory.GetFiles(path);
// recipeCharts.Clear();
// int i = 1;
// files.ToList().ForEach(e =>
// {
// Db = new SqlSugarScope(new ConnectionConfig()
// {
// ConnectionString = $"Data Source = {e.FullName}",
// DbType = DbType.Sqlite,
// IsAutoCloseConnection = true,
// });
// Db.Queryable<SaveData>().Select(x => x.Name).Distinct().ToList().ForEach(t =>
// {
// recipeCharts.Add(new RecipeChart()
// {
// Num = i++,
// Name = t,
// CreateTime = DateTime.Parse(e.Name.Replace("data", "").Replace(".db", ""))
// });
// });
// });

public void FindDateList()
{
string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"{directoryPath}\\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 =>
{
recipeCharts.Add(new RecipeChart()
{
Num = i++,
Name = t,
CreateTime = DateTime.Parse(DateString)
});
});
}
else
{
App.Current.Dispatcher.Invoke(() =>
{
NoticeDemoViewModel.OpenMsg(EnumPromptType.Info, App.MainWindow, "提示", "未找到相关测试记录!", 1, 1);
});
}
}
// }
// catch (UnauthorizedAccessException ex)
// {
// throw;
// }
// catch (DirectoryNotFoundException ex)
// {
// throw;
// }
// catch (Exception ex)
// {
// throw;
// }
//}

public void FindProduct(string num)
{
string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"{directoryPath}\\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 void FindDateList()
//{
// string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"{directoryPath}\\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 =>
// {
// recipeCharts.Add(new RecipeChart()
// {
// Num = i++,
// Name = t,
// CreateTime = DateTime.Parse(DateString)
// });
// });
// }
// else
// {
// App.Current.Dispatcher.Invoke(() =>
// {
// NoticeDemoViewModel.OpenMsg(EnumPromptType.Info, App.MainWindow, "提示", "未找到相关测试记录!", 1, 1);
// });
// }
//}

//public void FindProduct(string num)
//{
// string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"{directoryPath}\\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, $"{directoryPath}\\data{DateString}.db");
if (File.Exists(path))
{
Db = new SqlSugarScope(new ConnectionConfig()
{
ConnectionString = $"Data Source = {path}",
DbType = DbType.Sqlite,
IsAutoCloseConnection = true,
});
return Db.Queryable<SaveData>().Where(o => o.Name == Name).ToList();
}
else
{
return null;
}

}
catch (Exception)
{
return null;
}
}
public List<SaveData> SelectId(string id)
{
try
{
return Db.Queryable<SaveData>().Where(o => o.Id == id).ToList();
}
catch (Exception)
{
return null;
}
}
//public List<SaveData> SelectName(string Name)
//{
// try
// {
// string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"{directoryPath}\\data{DateString}.db");
// if (File.Exists(path))
// {
// Db = new SqlSugarScope(new ConnectionConfig()
// {
// ConnectionString = $"Data Source = {path}",
// DbType = DbType.Sqlite,
// IsAutoCloseConnection = true,
// });
// return Db.Queryable<SaveData>().Where(o => o.Name == Name).ToList();
// }
// else
// {
// return null;
// }

// }
// catch (Exception)
// {
// return null;
// }
//}
//public List<SaveData> SelectId(string id)
//{
// try
// {
// return Db.Queryable<SaveData>().Where(o => o.ProductNumberId == id).ToList();
// }
// catch (Exception)
// {
// return null;
// }
//}
}
}

+ 4
- 1
BPASmartClient.Academy/Model/SaveData.cs Wyświetl plik

@@ -1,4 +1,5 @@
using LiveCharts;
using Microsoft.Data.Sqlite;
using SqlSugar;
using System;
using System.Collections.Generic;
@@ -8,6 +9,8 @@ using System.Threading.Tasks;

namespace BPASmartClient.Academy.Model
{
[SplitTable(SplitType.Day)]
[SugarTable("SaveData_{year}{month}{day}")]
public class SaveData : NotifyBase
{
public string Name { get; set; }
@@ -16,7 +19,7 @@ namespace BPASmartClient.Academy.Model

//[SugarColumn(IsPrimaryKey = true)]

public string Id { get; set; }
public string ProductNumberId { get; set; }

///// <summary>
///// 产品编号ID


+ 1
- 1
BPASmartClient.Academy/Model/SaveNameData.cs Wyświetl plik

@@ -10,7 +10,7 @@ namespace BPASmartClient.Academy.Model
public class SaveNameData : SqliteBase
{
/// <summary>
/// 产品编号
/// 产品名称
/// </summary>
public string ProductNumber { get; set; }



+ 26
- 4
BPASmartClient.Academy/Model/Simens_PLC.cs Wyświetl plik

@@ -101,8 +101,9 @@ namespace BPASmartClient.Academy.Model
App.Current.Dispatcher.Invoke(() =>
{
NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", Simens_PLC.GetInstance.AlarmInfo[o], 2, 1);
MessageNotify.GetInstance.ShowAlarmLog(Simens_PLC.GetInstance.AlarmInfo[o]);
});
MessageNotify.GetInstance.ShowAlarmLog(Simens_PLC.GetInstance.AlarmInfo[o]);
}
});
});
@@ -118,6 +119,28 @@ namespace BPASmartClient.Academy.Model
{
heart = o.Content;
});
/* siemens.Read<bool[]>("DB1.DBX2000.0", 20).OnSuccess(o =>
{
deviceCtrl.M101 = o.Content[0];
deviceCtrl.M102 = o.Content[1];
deviceCtrl.M103 = o.Content[2];
deviceCtrl.VX100 = o.Content[3];
deviceCtrl.VX101 = o.Content[4];
deviceCtrl.VX102 = o.Content[5];
deviceCtrl.VX103 = o.Content[6];
deviceCtrl.VX104 = o.Content[7];
deviceCtrl.VX105 = o.Content[8];
deviceCtrl.VX106 = o.Content[9];
deviceCtrl.VX107 = o.Content[10];
deviceCtrl.VX108 = o.Content[11];
deviceCtrl.VX109 = o.Content[12];
deviceCtrl.VX110 = o.Content[13];
deviceCtrl.VX111 = o.Content[14];
deviceCtrl.VX112 = o.Content[15];
deviceCtrl.VX113 = o.Content[16];
deviceCtrl.VX114 = o.Content[17];
deviceCtrl.VX115 = o.Content[18];
});*/
siemens.Read<bool>("DB1.DBX2000.0").OnSuccess(o =>
{
deviceCtrl.M101 = o.Content;
@@ -279,7 +302,6 @@ namespace BPASmartClient.Academy.Model
}
}

public bool IsSave { get; set; } = false;


public void ChartDataRead()
@@ -313,10 +335,10 @@ namespace BPASmartClient.Academy.Model
//DataView(dataFeedback.WeightWok, new DataValue() { DateTime = date, Value = saveData.WeightWok });
if (siemens != null && id != "")
{
SaveData saveData = new SaveData()
{
Id = Simens_PLC.GetInstance.id,
ProductNumberId = Simens_PLC.GetInstance.id,
Name = dataFeedback.Name,
//ProductNumberId = dataFeedback.ProductNumberId,
Date = DateTime.Now,


+ 45
- 7
BPASmartClient.Academy/Model/Sqlite.cs Wyświetl plik

@@ -14,6 +14,7 @@ namespace BPASmartClient.Academy.Model
public static Sqlite GetInstance { get; set; } = instance ??= new Sqlite();
private Sqlite() { }
public List<SaveData> saveDatas { get; set; } = new List<SaveData>();
public ObservableCollection<RecipeChart> recipeCharts { get; set; } = new ObservableCollection<RecipeChart>();
static string directoryPath = $"AccessFile\\DB\\{Json<DevicePar>.Data.ProjectTypeName.ToString()}";
static string path
{
@@ -21,7 +22,7 @@ namespace BPASmartClient.Academy.Model
{
string tempPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"AccessFile\\DB\\{Json<DevicePar>.Data.ProjectTypeName.ToString()}");
Directory.CreateDirectory(tempPath);
return Path.Combine(tempPath, $"data{DateTime.Now.ToString("yyyy-MM-dd")}.db");
return Path.Combine(tempPath, $"data.db");
}
}
public SqlSugarScope Db = new SqlSugarScope(new ConnectionConfig()
@@ -31,7 +32,46 @@ namespace BPASmartClient.Academy.Model
IsAutoCloseConnection = true,

});
public void FindDateList(DateTime date)
{
int i = 1;
recipeCharts.Clear();
Db.Queryable<SaveNameData>().Where(o => o.Createtime.Date == date.Date).ToList().ForEach(t =>
{
recipeCharts.Add(new RecipeChart()
{
Num = i++,
CreateTime = t.Createtime,
Name = t.ProductNumber,
Id = t.Id
});
});
if (recipeCharts.Count<=0)
{
MessageNotify.GetInstance.OpenMsg("未查询到有效记录");
}
}

public void FindName(string Name)
{
int i = 1;
recipeCharts.Clear();
Db.Queryable<SaveNameData>().Where(o => o.ProductNumber.Contains(Name)).ToList().ForEach(t =>
{
recipeCharts.Add(new RecipeChart()
{
Num = i++,
CreateTime = t.Createtime,
Name = t.ProductNumber,
Id = t.Id
});
});
}

public List<SaveData> FindList(RecipeChart chart)
{
return Db.Queryable<SaveData>().SplitTable().Where(o => o.ProductNumberId == chart.Id).ToList();
}
public void Init()
{
try
@@ -40,15 +80,13 @@ namespace BPASmartClient.Academy.Model
{
Db.DbMaintenance.CreateDatabase();
Db.CodeFirst.SetStringDefaultLength(100).InitTables<SaveData>();
Db.CodeFirst.InitTables<SaveNameData>();
//Db.CodeFirst.SetStringDefaultLength(100).InitTables<SaveNameData>();
}
else
{
MessageNotify.GetInstance.ShowRunLog("创建失败");
}
}
catch (Exception ex)
{
MessageNotify.GetInstance.OpenMsg("创建数据库失败");
MessageNotify.GetInstance.ShowRunLog(ex.Message);
}
}
@@ -56,7 +94,7 @@ namespace BPASmartClient.Academy.Model
{
try
{
return Db.Insertable(dfb).ExecuteCommand() > 0;
return Db.Insertable(dfb).SplitTable().ExecuteCommand() > 0;
}
catch (Exception)
{
@@ -80,7 +118,7 @@ namespace BPASmartClient.Academy.Model
{
try
{
return Db.Queryable<SaveData>().Where(o => o.Id == id).ToList();
return Db.Queryable<SaveData>().SplitTable().Where(o => o.ProductNumberId == id).ToList();
}
catch (Exception)
{


+ 1
- 1
BPASmartClient.Academy/View/DeviceChart50LView.xaml Wyświetl plik

@@ -38,7 +38,7 @@
PointGeometry="{x:Null}"
Stroke="Red"
StrokeThickness="2"
Values="{Binding DataFeedback.TempWok}" />
Values="{Binding DataFeedback.CondensateWaterHumidity}" />
<lvc:LineSeries
Fill="Transparent"
LineSmoothness="1"


+ 2
- 2
BPASmartClient.Academy/View/DeviceChartView.xaml.cs Wyświetl plik

@@ -92,7 +92,7 @@ namespace BPASmartClient.Academy.View
if (!(plotModel.Axes.Count > 0))
{
plotModel.Axes.Add(new DateTimeAxis() { Position = OxyPlot.Axes.AxisPosition.Bottom, Title = "时间/s", StringFormat = "hh:mm:ss", Minimum = min, Maximum = max});
plotModel.Axes.Add(new LinearAxis() { Key = "y1", Title = "转速/rpm", Position = OxyPlot.Axes.AxisPosition.Left, LabelFormatter = value => value.ToString("f2") });
plotModel.Axes.Add(new LinearAxis() { Key = "y1", Title = "转速/", Position = OxyPlot.Axes.AxisPosition.Left, LabelFormatter = value => value.ToString("f2") });
}
plotModel.Series.Add(line_3);
plotModel.Series.Add(line_4);
@@ -154,7 +154,7 @@ namespace BPASmartClient.Academy.View
if (!(plotModel.Axes.Count > 0))
{
plotModel.Axes.Add(new DateTimeAxis() { Position = OxyPlot.Axes.AxisPosition.Bottom, Title = "时间/s", StringFormat = "hh:mm:ss", Minimum = min, Maximum = max });
plotModel.Axes.Add(new LinearAxis() { Key = "y1", Title = "冷却水罐重量/kg", Position = OxyPlot.Axes.AxisPosition.Left, LabelFormatter = value => value.ToString("f2")});
plotModel.Axes.Add(new LinearAxis() { Key = "y1", Title = "冷却水罐重量/g", Position = OxyPlot.Axes.AxisPosition.Left, LabelFormatter = value => value.ToString("f2")});
}
plotModel.Series.Add(line_5);
plotModel.InvalidatePlot(true);//重新加载曲线


+ 179
- 22
BPASmartClient.Academy/View/DeviceMotionView.xaml Wyświetl plik

@@ -8,8 +8,8 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="clr-namespace:BPASmartClient.Academy.ViewModel"
d:DataContext="{d:DesignInstance Type=vm:DeviceMotionViewModel}"
d:DesignHeight="450"
d:DesignWidth="800"
d:DesignHeight="900"
d:DesignWidth="1440"
mc:Ignorable="d">
<UserControl.Resources>
<Style x:Key="checkBox" TargetType="{x:Type CheckBox}">
@@ -96,14 +96,14 @@
x:Name="ooo"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
IsHitTestVisible="True"
Opacity="1">
IsHitTestVisible="False"
Opacity="0.5">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="0" />
</Grid.RowDefinitions>
<Grid>
<Grid Margin="20,100">
<Grid Margin="150,100">
<Viewbox Stretch="Uniform">
<Canvas Width="800" Height="450">

@@ -902,7 +902,7 @@
Canvas.Top="70"
Width="60"
Foreground="Red"
Text="{Binding DeviceStatus.TempWok, StringFormat='{}{0}℃'}"
Text="{Binding DeviceStatus.TempMaterial, StringFormat='{}{0}℃'}"
TextAlignment="Center" />
<TextBlock
Canvas.Left="214"
@@ -914,7 +914,7 @@
Canvas.Top="260"
Width="60"
Foreground="Red"
Text="{Binding DeviceStatus.TempMaterial, StringFormat='{}{0}℃'}"
Text="{Binding DeviceStatus.TempWok, StringFormat='{}{0}℃'}"
TextAlignment="Center" />
<TextBlock
Canvas.Left="569"
@@ -944,7 +944,7 @@
Width="60"
FontSize="9"
Foreground="Red"
Text="{Binding DeviceStatus.WeightWok, StringFormat='{}{0:f2}kg'}"
Text="{Binding DeviceStatus.WeightWok, StringFormat='{}{0:f2}g'}"
TextAlignment="Center" />
<TextBlock
Canvas.Left="780"
@@ -966,6 +966,7 @@
FontSize="10"
Style="{StaticResource ButtonStyle}" />
<!--#endregion-->

<!--#region 控制按钮-->
<StackPanel
Canvas.Left="-20"
@@ -1455,10 +1456,158 @@
Content="真空泵:关"
FontSize="10"
Foreground="White"
GroupName="2"
GroupName="20"
IsChecked="True"
Style="{StaticResource radiobutton}"
Tag="20" />
Tag="2" />
</StackPanel>
<!--#endregion-->

<!--#region 新增按钮-->
<StackPanel
Canvas.Left="705"
Canvas.Top="-30"
Orientation="Vertical">
<RadioButton
Width="70"
Height="20"
Margin="0,0,0,2"
BorderThickness="0"
Click="new_Click"
Content="闪蒸:开"
FontSize="8"
Foreground="White"
GroupName="t1"
Style="{StaticResource radiobutton}"
Tag="0" />
<RadioButton
Width="70"
Height="20"
BorderThickness="0"
Click="new_Click"
Content="闪蒸:关"
FontSize="8"
Foreground="White"
GroupName="t1"
IsChecked="True"
Style="{StaticResource radiobutton}"
Tag="0" />
</StackPanel>
<StackPanel
Canvas.Left="785"
Canvas.Top="-30"
Orientation="Vertical">
<RadioButton
Width="70"
Height="20"
Margin="0,0,0,2"
BorderThickness="0"
Click="new_Click"
Content="真空蒸馏:开"
FontSize="8"
Foreground="White"
GroupName="t2"
Style="{StaticResource radiobutton}"
Tag="1" />
<RadioButton
Width="70"
Height="20"
BorderThickness="0"
Click="new_Click"
Content="真空蒸馏:关"
FontSize="8"
Foreground="White"
GroupName="t2"
IsChecked="True"
Style="{StaticResource radiobutton}"
Tag="1" />
</StackPanel>
<StackPanel
Canvas.Left="705"
Canvas.Top="20"
Orientation="Vertical">
<RadioButton
Width="70"
Height="20"
Margin="0,0,0,2"
BorderThickness="0"
Click="new_Click"
Content="真空下料:开"
FontSize="8"
Foreground="White"
GroupName="t3"
Style="{StaticResource radiobutton}"
Tag="2" />
<RadioButton
Width="70"
Height="20"
BorderThickness="0"
Click="new_Click"
Content="真空下料:关"
FontSize="8"
Foreground="White"
GroupName="t3"
IsChecked="True"
Style="{StaticResource radiobutton}"
Tag="2" />
</StackPanel>
<StackPanel
Canvas.Left="785"
Canvas.Top="20"
Orientation="Vertical">
<RadioButton
Width="70"
Height="20"
Margin="0,0,0,2"
BorderThickness="0"
Click="new_Click"
Content="加压出料:开"
FontSize="8"
Foreground="White"
GroupName="t4"
Style="{StaticResource radiobutton}"
Tag="3" />
<RadioButton
Width="70"
Height="20"
BorderThickness="0"
Click="new_Click"
Content="加压出料:关"
FontSize="8"
Foreground="White"
GroupName="t4"
IsChecked="True"
Style="{StaticResource radiobutton}"
Tag="3" />
</StackPanel>
<StackPanel
Canvas.Left="745"
Canvas.Top="70"
Orientation="Vertical">
<RadioButton
Width="70"
Height="20"
Margin="0,0,0,2"
BorderThickness="0"
Click="new_Click"
Content="排空阀:开"
FontSize="8"
Foreground="White"
GroupName="t5"
Style="{StaticResource radiobutton}"
Tag="4" />
<RadioButton
Width="70"
Height="20"
BorderThickness="0"
Click="new_Click"
Content="排空阀:关"
FontSize="8"
Foreground="White"
GroupName="t5"
IsChecked="True"
Style="{StaticResource radiobutton}"
Tag="4" />
</StackPanel>
<!--#endregion-->
</Canvas>
@@ -1491,7 +1640,7 @@
<Button
Margin="10,0,10,0"
Command="{Binding DataRecordCommand}"
Content="开始记录"
Content="选择设备类型"
Style="{StaticResource ButtonStyle}" />
</StackPanel>
<CheckBox
@@ -1580,20 +1729,28 @@
FontSize="16"
Foreground="White"
Text="℃" />
<Button
Width="120"
<RadioButton
Width="100"
Height="30"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Click="TempSet_CLick"
Content="启动"
Style="{StaticResource ButtonStyle}" />
<Button
Width="120"
BorderThickness="0"
Foreground="White"
GroupName="tempctrl"
Style="{StaticResource radiobutton}" />
<RadioButton
Width="100"
Height="30"
Margin="40,0,0,0"
Click="TempCLose_CLick"
BorderThickness="0"
Content="停止"
Style="{StaticResource ButtonStyle}" />
Foreground="White"
GroupName="tempctrl"
IsChecked="True"
Style="{StaticResource radiobutton}" />
</StackPanel>
</WrapPanel>
<WrapPanel
@@ -1605,7 +1762,7 @@
Margin="40,0,20,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="16"
FontSize="14"
Foreground="White"
Text="反应釜排气温度校准:" />
<TextBox
@@ -1618,7 +1775,7 @@
Margin="20,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="16"
FontSize="14"
Foreground="White"
Text="℃" />
</StackPanel>
@@ -1640,7 +1797,7 @@
Margin="20,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="16"
FontSize="14"
Foreground="White"
Text="℃" />
</StackPanel>
@@ -1649,7 +1806,7 @@
Margin="40,0,20,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="16"
FontSize="14"
Foreground="White"
Text="反应釜温度校准:" />
<TextBox
@@ -1662,7 +1819,7 @@
Margin="20,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="16"
FontSize="14"
Foreground="White"
Text="℃" />
</StackPanel>


+ 161
- 135
BPASmartClient.Academy/View/DeviceMotionView.xaml.cs Wyświetl plik

@@ -23,6 +23,7 @@ using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using static System.Net.Mime.MediaTypeNames;
using SqlSugar;

namespace BPASmartClient.Academy.View
{
@@ -42,25 +43,25 @@ namespace BPASmartClient.Academy.View
{
Simens_PLC.GetInstance.connect = o =>
{
//App.Current.Dispatcher.Invoke(() =>
//{
// if (o)
// {
// ooo.Opacity = 1;
// ooo.IsHitTestVisible = true;
// state.Visibility = Visibility.Collapsed;
// }
// else
// {
App.Current.Dispatcher.Invoke(() =>
{
if (o)
{
ooo.Opacity = 1;
ooo.IsHitTestVisible = true;
state.Visibility = Visibility.Collapsed;
}
else
{

// ooo.Opacity = 0.5;
// ooo.IsHitTestVisible = false;
// state.Text = "设 备 未 连 接";
// //MessageNotify.GetInstance.ShowRunLog("设备未连接");
// state.Visibility = Visibility.Visible;
// state.Foreground = Brushes.Red;
// }
//});
ooo.Opacity = 0.5;
ooo.IsHitTestVisible = false;
state.Text = "设 备 未 连 接";
//MessageNotify.GetInstance.ShowRunLog("设备未连接");
state.Visibility = Visibility.Visible;
state.Foreground = Brushes.Red;
}
});

};
}
@@ -162,132 +163,136 @@ namespace BPASmartClient.Academy.View
private void TempSet_CLick(object sender, RoutedEventArgs e)
{
bool suc;
switch (tempName)
if (Simens_PLC.GetInstance.IsConnected)
{
case "反应釜升温":
int tempValue;
suc = int.TryParse(temp_1.Text.ToString(), out tempValue);
if (suc)
{
Simens_PLC.GetInstance.siemens.Write<bool>("DB1.DBX1001.7", true);
Simens_PLC.GetInstance.siemens.Write<int>("DB1.DBD1020", tempValue);
}
else
{
App.Current.Dispatcher.Invoke(() =>
switch (tempName)
{
case "反应釜升温":
int tempValue;
suc = int.TryParse(temp_1.Text.ToString(), out tempValue);
if (suc)
{
NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", "请检查温度输入是否正确", 1, 1);
});
}
break;
case "配料罐升温":
suc = int.TryParse(temp_1.Text.ToString(), out tempValue);
//int time;
//suc = int.TryParse(time_1.Text.ToString(), out time);
if (suc)
{
Simens_PLC.GetInstance.siemens.Write<bool>("DB1.DBX1001.6", true);
//Simens_PLC.GetInstance.siemens.Write<ushort>("DB1.DBD100", (ushort)(time*10));
Simens_PLC.GetInstance.siemens.Write<int>("DB1.DBD1016", tempValue);
}
else
{
App.Current.Dispatcher.Invoke(() =>
Simens_PLC.GetInstance.siemens.Write<bool>("DB1.DBX1001.7", true);
Simens_PLC.GetInstance.siemens.Write<int>("DB1.DBD1020", tempValue);
}
else
{
NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", "请检查温度输入是否正确", 1, 1);
});
}
break;
case "反应釜降温":
suc = int.TryParse(temp_1.Text.ToString(), out tempValue);
//int time;
//suc = int.TryParse(time_1.Text.ToString(), out time);
if (suc)
{
Simens_PLC.GetInstance.siemens.Write<bool>("DB1.DBX1003.0", true);
//Simens_PLC.GetInstance.siemens.Write<ushort>("DB1.DBD100", (ushort)(time*10));
Simens_PLC.GetInstance.siemens.Write<int>("DB1.DBD1020", tempValue);
}
else
{
App.Current.Dispatcher.Invoke(() =>
App.Current.Dispatcher.Invoke(() =>
{
NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", "请检查温度输入是否正确", 1, 1);
});
}

break;
case "配料罐升温":
suc = int.TryParse(temp_1.Text.ToString(), out tempValue);
//int time;
//suc = int.TryParse(time_1.Text.ToString(), out time);
if (suc)
{
NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", "请检查温度输入是否正确", 1, 1);
});
}
break;
case "温度校准":
bool val = true;
int value;
suc = int.TryParse(tempvent.Text.ToString(),out value);
if (suc)
{
Simens_PLC.GetInstance.siemens.Write<int>("DB1.DBD1024", value).OnFailure(o =>
Simens_PLC.GetInstance.siemens.Write<bool>("DB1.DBX1001.6", true);
//Simens_PLC.GetInstance.siemens.Write<ushort>("DB1.DBD100", (ushort)(time*10));
Simens_PLC.GetInstance.siemens.Write<int>("DB1.DBD1016", tempValue);
}
else
{
val = false;
App.Current.Dispatcher.Invoke(() =>
{
NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", "反应釜排气温度写入失败", 1, 1);
NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", "请检查温度输入是否正确", 1, 1);
});
});
}
else
{
App.Current.Dispatcher.Invoke(() =>
}
break;
case "反应釜降温":
suc = int.TryParse(temp_1.Text.ToString(), out tempValue);
//int time;
//suc = int.TryParse(time_1.Text.ToString(), out time);
if (suc)
{
NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", "请检查排气温度校准输入", 1, 1);
});
}
suc = int.TryParse(tempmaterial.Text.ToString(), out value);
if (suc)
{
Simens_PLC.GetInstance.siemens.Write<int>("DB1.DBD1028", value).OnFailure(o =>
Simens_PLC.GetInstance.siemens.Write<bool>("DB1.DBX1003.0", true);
//Simens_PLC.GetInstance.siemens.Write<ushort>("DB1.DBD100", (ushort)(time*10));
Simens_PLC.GetInstance.siemens.Write<int>("DB1.DBD1020", tempValue);
}
else
{
val = false;
App.Current.Dispatcher.Invoke(() =>
{
NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", "配料罐温度写入失败", 1, 1);
NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", "请检查温度输入是否正确", 1, 1);
});
});
}
else
{
App.Current.Dispatcher.Invoke(() =>
}
break;
case "温度校准":
bool val = true;
int value;
suc = int.TryParse(tempvent.Text.ToString(), out value);
if (suc)
{
NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", "请检查配料罐温度校准输入", 1, 1);
});
}
suc = int.TryParse(tempwok.Text.ToString(), out value);
if (suc)
{
Simens_PLC.GetInstance.siemens.Write<int>("DB1.DBD1032", value).OnFailure(o =>
Simens_PLC.GetInstance.siemens.Write<int>("DB1.DBD1024", value).OnFailure(o =>
{
val = false;
App.Current.Dispatcher.Invoke(() =>
{
NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", "反应釜排气温度写入失败", 1, 1);
});
});
}
else
{
val = false;
App.Current.Dispatcher.Invoke(() =>
{
NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", "反应釜温度写入失败", 1, 1);
NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", "请检查排气温度校准输入", 1, 1);
});
});
}
else
{
App.Current.Dispatcher.Invoke(() =>
}
suc = int.TryParse(tempmaterial.Text.ToString(), out value);
if (suc)
{
NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", "请检查反应釜温度校准输入", 1, 1);
});
}
if (val)
{
App.Current.Dispatcher.Invoke(() =>
Simens_PLC.GetInstance.siemens.Write<int>("DB1.DBD1028", value).OnFailure(o =>
{
val = false;
App.Current.Dispatcher.Invoke(() =>
{
NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", "配料罐温度写入失败", 1, 1);
});
});
}
else
{
NoticeDemoViewModel.OpenMsg(EnumPromptType.Info, App.MainWindow, "成功", "校准完成", 1, 1);
});
}
break;
default:
break;
App.Current.Dispatcher.Invoke(() =>
{
NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", "请检查配料罐温度校准输入", 1, 1);
});
}
suc = int.TryParse(tempwok.Text.ToString(), out value);
if (suc)
{
Simens_PLC.GetInstance.siemens.Write<int>("DB1.DBD1032", value).OnFailure(o =>
{
val = false;
App.Current.Dispatcher.Invoke(() =>
{
NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", "反应釜温度写入失败", 1, 1);
});
});
}
else
{
App.Current.Dispatcher.Invoke(() =>
{
NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", "请检查反应釜温度校准输入", 1, 1);
});
}
if (val)
{
App.Current.Dispatcher.Invoke(() =>
{
NoticeDemoViewModel.OpenMsg(EnumPromptType.Info, App.MainWindow, "成功", "校准完成", 1, 1);
});
}
break;
default:
break;
}
}
}

private void hzSet_Click(object sender, RoutedEventArgs e)
@@ -339,20 +344,24 @@ namespace BPASmartClient.Academy.View

private void TempCLose_CLick(object sender, RoutedEventArgs e)
{
switch (tempName)
if (Simens_PLC.GetInstance.IsConnected)
{
case "配料罐升温":
Simens_PLC.GetInstance.siemens.Write<bool>("DB1.DBX1001.6", false);
break;
case "反应釜升温":
Simens_PLC.GetInstance.siemens.Write<bool>("DB1.DBX1001.7", false);
break;
case "反应釜降温":
Simens_PLC.GetInstance.siemens.Write<bool>("DB1.DBX1003.0", false);
break;
default:
break;
switch (tempName)
{
case "配料罐升温":
Simens_PLC.GetInstance.siemens.Write<bool>("DB1.DBX1001.6", false);
break;
case "反应釜升温":
Simens_PLC.GetInstance.siemens.Write<bool>("DB1.DBX1001.7", false);
break;
case "反应釜降温":
Simens_PLC.GetInstance.siemens.Write<bool>("DB1.DBX1003.0", false);
break;
default:
break;
}
}
}

private void ClearBtn_CLick(object sender, RoutedEventArgs e)
@@ -363,6 +372,23 @@ namespace BPASmartClient.Academy.View
}
}

private void new_Click(object sender, RoutedEventArgs e)
{
if (Simens_PLC.GetInstance.IsConnected)
{
RadioButton radioButton = sender as RadioButton;
if (radioButton.Content.ToString().Contains("开"))
{
Simens_PLC.GetInstance.siemens.Write<bool>($"DB1.DBX3000.{radioButton.Tag}", true);
}
else
{
Simens_PLC.GetInstance.siemens.Write<bool>($"DB1.DBX3000.{radioButton.Tag}", false);
}
}
}

//private void xxx_MouseMove(object sender, MouseEventArgs e)
//{
// CartesianChart liveCharts = sender as CartesianChart;


+ 5
- 5
BPASmartClient.Academy/View/HistoryChartView.xaml Wyświetl plik

@@ -7,8 +7,8 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:oxy="http://oxyplot.org/wpf"
xmlns:vm="clr-namespace:BPASmartClient.Academy.ViewModel"
d:DesignHeight="450"
d:DesignWidth="800"
d:DesignHeight="900"
d:DesignWidth="1440"
mc:Ignorable="d">
<UserControl.DataContext>
<vm:HistoryChartViewModel />
@@ -104,7 +104,7 @@
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="2*" />
<ColumnDefinition Width="1.7*"/>
</Grid.ColumnDefinitions>
<!--#region 表格-->
<Grid
@@ -118,7 +118,7 @@
<!--#region 标题-->
<Grid Background="#ff0C255F">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100" />
<ColumnDefinition Width="50" />
<ColumnDefinition Width="180" />
<ColumnDefinition Width="120" />
<ColumnDefinition Width="1*" />
@@ -182,7 +182,7 @@
Margin="0,1"
Background="#163175">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100" />
<ColumnDefinition Width="50" />
<ColumnDefinition Width="180" />
<ColumnDefinition Width="120" />
<ColumnDefinition Width="1*" />


+ 6
- 9
BPASmartClient.Academy/View/HistoryChartView.xaml.cs Wyświetl plik

@@ -35,7 +35,7 @@ namespace BPASmartClient.Academy.View
Button button = sender as Button;
int num;
bool suc = int.TryParse(button.CommandParameter.ToString(), out num);
RecipeChart recipeChart = HistorySqlite.GetInstance.recipeCharts.FirstOrDefault(o => o.Num == num);
RecipeChart recipeChart = Sqlite.GetInstance.recipeCharts.FirstOrDefault(o => o.Num == num);
switch (button.Content.ToString())
{
case "温度曲线":
@@ -47,8 +47,7 @@ namespace BPASmartClient.Academy.View
List<DataPoint> twValues = new List<DataPoint>();
List<DataPoint> tvValues = new List<DataPoint>();
List<DataPoint> tmValues = new List<DataPoint>();
HistorySqlite.GetInstance.DateString = recipeChart.CreateTime.ToString("yyyy-MM-dd");
HistorySqlite.GetInstance.SelectName(recipeChart.Name).ForEach(t =>
Sqlite.GetInstance.FindList(recipeChart).ForEach(t =>
{
twValues.Add(new DataPoint(DateTimeAxis.ToDouble(t.Date), t.TempWok));
tvValues.Add(new DataPoint(DateTimeAxis.ToDouble(t.Date), t.TempVent));
@@ -76,8 +75,7 @@ namespace BPASmartClient.Academy.View
OxyPlot.Series.LineSeries line_4 = new OxyPlot.Series.LineSeries() { LineStyle = LineStyle.Solid, Title = "配料罐转速", MarkerFill = OxyColor.FromRgb(110, 79, 79), MarkerSize = 2, LineLegendPosition = OxyPlot.Series.LineLegendPosition.End };
List<DataPoint> m101 = new List<DataPoint>();
List<DataPoint> m102 = new List<DataPoint>();
HistorySqlite.GetInstance.DateString = recipeChart.CreateTime.ToString("yyyy-MM-dd");
HistorySqlite.GetInstance.SelectName(recipeChart.Name).ForEach(t =>
Sqlite.GetInstance.FindList(recipeChart).ForEach(t =>
{
m101.Add(new DataPoint(DateTimeAxis.ToDouble(t.Date), t.M101_Speed));
m102.Add(new DataPoint(DateTimeAxis.ToDouble(t.Date), t.M102_Speed));
@@ -88,7 +86,7 @@ namespace BPASmartClient.Academy.View
if (!(plotModel.Axes.Count > 0))
{
plotModel.Axes.Add(new DateTimeAxis() { Position = OxyPlot.Axes.AxisPosition.Bottom, Title = "时间/s", StringFormat = "hh:mm:ss" });
plotModel.Axes.Add(new LinearAxis() { Key = "y1", Title = "转速/rpm", Position = OxyPlot.Axes.AxisPosition.Left, LabelFormatter = value => value.ToString() });
plotModel.Axes.Add(new LinearAxis() { Key = "y1", Title = "转速/", Position = OxyPlot.Axes.AxisPosition.Left, LabelFormatter = value => value.ToString() });
}
plotModel.Series.Add(line_3);
plotModel.Series.Add(line_4);
@@ -100,8 +98,7 @@ namespace BPASmartClient.Academy.View
plotModel = new PlotModel() { Title = "冷却水罐重量曲线" };
List<DataPoint> ww = new List<DataPoint>();
OxyPlot.Series.LineSeries line_5 = new OxyPlot.Series.LineSeries() { Title = "冷却水罐重量", Color = OxyColor.FromRgb(0, 0, 0), LineStyle = LineStyle.Solid, LineLegendPosition = OxyPlot.Series.LineLegendPosition.End };
HistorySqlite.GetInstance.DateString = recipeChart.CreateTime.ToString("yyyy-MM-dd");
HistorySqlite.GetInstance.SelectName(recipeChart.Name).ForEach(t =>
Sqlite.GetInstance.FindList(recipeChart).ForEach(t =>
{
ww.Add(new DataPoint(DateTimeAxis.ToDouble(t.Date), t.WeightWok));

@@ -110,7 +107,7 @@ namespace BPASmartClient.Academy.View
if (!(plotModel.Axes.Count > 0))
{
plotModel.Axes.Add(new DateTimeAxis() { Position = OxyPlot.Axes.AxisPosition.Bottom, Title = "时间/s", StringFormat = "hh:mm:ss" });
plotModel.Axes.Add(new LinearAxis() { Key = "y1", Title = "冷却水罐重量/kg", Position = OxyPlot.Axes.AxisPosition.Left, LabelFormatter = value => value.ToString("f2") });
plotModel.Axes.Add(new LinearAxis() { Key = "y1", Title = "冷却水罐重量/g", Position = OxyPlot.Axes.AxisPosition.Left, LabelFormatter = value => value.ToString("f2") });
}
plotModel.Series.Add(line_5);
plotModel.InvalidatePlot(true);//重新加载曲线


+ 1679
- 6
BPASmartClient.Academy/View/ReactionKettle50LView.xaml
Plik diff jest za duży
Wyświetl plik


+ 6
- 5
BPASmartClient.Academy/ViewModel/DeviceChart50LViewModel.cs Wyświetl plik

@@ -1,4 +1,5 @@
using BPASmartClient.Academy.Model;
using BPASmartClient.Academy._50L;
using BPASmartClient.Academy.Model;
using LiveCharts;
using LiveCharts.Configurations;
using LiveCharts.Wpf;
@@ -15,17 +16,17 @@ namespace BPASmartClient.Academy.ViewModel
{
public DeviceChart50LViewModel()
{
DataFeedback = new DataFeedback();
DataFeedback = new DataFeedBack_50();
var mapper = Mappers.Xy<DataValue>()
.X(model => model.DateTime.Ticks)
.Y(model => model.Value);
Charting.For<DataValue>(mapper);
DataFeedback = Simens_PLC.GetInstance.dataFeedback;
DataFeedback = SqliteOperate.GetInstance.DataFeedBacks;
}


private DataFeedback dataFeedback;
public DataFeedback DataFeedback { get { return dataFeedback; } set { dataFeedback = value; OnPropertyChanged(); } }
private DataFeedBack_50 dataFeedback;
public DataFeedBack_50 DataFeedback { get { return dataFeedback; } set { dataFeedback = value; OnPropertyChanged(); } }
public Func<double, string> DateTimeFormatter { get; set; } = value => value > 0 ? new DateTime((long)value).ToString("HH:mm:ss") : new DateTime((long)DateTime.Now.Ticks).ToString("HH:mm:ss");

public Func<double, string> doubleFormatter { get; set; } = value => value.ToString("F2");


+ 1
- 2
BPASmartClient.Academy/ViewModel/DeviceMotionViewModel.cs Wyświetl plik

@@ -31,11 +31,10 @@ namespace BPASmartClient.Academy.ViewModel
var snd = new SaveNameData(Name);
dataFeedback.ProductNumberId = snd.Id;
Sqlite.GetInstance.AddData(snd);
Simens_PLC.GetInstance.id = Guid.NewGuid().ToString();
Simens_PLC.GetInstance.id = snd.Id;
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 "系统停止":


+ 8
- 5
BPASmartClient.Academy/ViewModel/HistoryChartViewModel.cs Wyświetl plik

@@ -11,20 +11,21 @@ namespace BPASmartClient.Academy.ViewModel
public HistoryChartViewModel()
{

HistorySqlite.GetInstance.FindAllList();
Sqlite.GetInstance.FindDateList(DateTime.Now);
Select = new BPARelayCommand(() =>
{
HistorySqlite.GetInstance.DateString = SelectTime.ToString("yyyy-MM-dd");
HistorySqlite.GetInstance.FindDateList();
Sqlite.GetInstance.FindDateList(SelectTime);
//HistorySqlite.GetInstance.DateString = SelectTime.ToString("yyyy-MM-dd");
//HistorySqlite.GetInstance.FindDateList();
});

FindProductCommand = new BPARelayCommand(() =>
{
HistorySqlite.GetInstance.FindProduct(ProductNum);
Sqlite.GetInstance.FindName(ProductNum);
});
}

public ObservableCollection<RecipeChart> RecipeCharts { get; set; } = HistorySqlite.GetInstance.recipeCharts;
public ObservableCollection<RecipeChart> RecipeCharts { get; set; } = Sqlite.GetInstance.recipeCharts;

private DateTime _selectTime = DateTime.Now;

@@ -54,5 +55,7 @@ namespace BPASmartClient.Academy.ViewModel
public DateTime CreateTime { get { return _mCreateTime; } set { _mCreateTime = value; OnPropertyChanged(); } }
private DateTime _mCreateTime;

public string Id { get { return _id; } set { _id = value; OnPropertyChanged(); } }
private string _id;
}
}

+ 7
- 1
BPASmartClient.Academy/ViewModel/ReactionKettle50LViewModel.cs Wyświetl plik

@@ -1,4 +1,5 @@
using System;
using BPASmartClient.Academy._50L;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -11,6 +12,11 @@ namespace BPASmartClient.Academy.ViewModel
private volatile static ReactionKettle50LViewModel _Instance;
public static ReactionKettle50LViewModel GetInstance => _Instance ?? (_Instance = new ReactionKettle50LViewModel());
private ReactionKettle50LViewModel() { }

public DeviceStatus DeviceStatus{get { return _mdeviceStatus; }set { _mdeviceStatus = value;OnPropertyChanged(); }}
private DeviceStatus _mdeviceStatus = PlcControl.GetInstance.DeviceStatus;


}
}

Ładowanie…
Anuluj
Zapisz