diff --git a/InSituLaboratory.Entities/Sensor/ParticleAnalyzerModel.cs b/InSituLaboratory.Entities/Sensor/ParticleAnalyzerModel.cs
index 3d6bb1d..ef8dc6a 100644
--- a/InSituLaboratory.Entities/Sensor/ParticleAnalyzerModel.cs
+++ b/InSituLaboratory.Entities/Sensor/ParticleAnalyzerModel.cs
@@ -1,6 +1,8 @@
-using System;
+using LiveCharts;
+using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -48,8 +50,74 @@ namespace InSituLaboratory.Entities.Sensor
///
public string? Insulation { get; set; }
+ ///
+ /// 颗粒物序号
+ ///
+ public float? ParticleNumber { get; set; }
+
+ ///
+ /// 坐标X
+ ///
+ public float? CoordinateX { get; set; }
+
+ ///
+ /// 坐标Y
+ ///
+ public float? CoordinateY { get; set; }
+
+ ///
+ /// 类型
+ ///
+ public float? Type { get; set; }
+
+ ///
+ /// 面积
+ ///
+ public float? Area { get; set; }
+
+ ///
+ /// 长
+ ///
+ public float? Long { get; set; }
+
+ ///
+ /// 宽
+ ///
+ public float? Wide { get; set; }
+ [NotMapped]
+ public int DataIdNum { get; set; }
+
+ public ChartsModel AreaCharts { get; set; } = new ChartsModel()
+ {
+ Values = new ChartValues(),
+ Value_Name = "面积",
+ X_Time = new List(),
+ Y_MinValue = Convert.ToInt32(tools.GetAppSetting("颗粒物分析仪面积Min")),
+ Y_MaxValue = Convert.ToInt32(tools.GetAppSetting("颗粒物分析仪面积Max"))
+
+ };
+
+ public ChartsModel LongCharts { get; set; } = new ChartsModel()
+ {
+ Values = new ChartValues(),
+ Value_Name = "长",
+ X_Time = new List(),
+ Y_MinValue = Convert.ToInt32(tools.GetAppSetting("颗粒物分析仪长Min")),
+ Y_MaxValue = Convert.ToInt32(tools.GetAppSetting("颗粒物分析仪长Max"))
+
+ };
+
+ public ChartsModel WideCharts { get; set; } = new ChartsModel()
+ {
+ Values = new ChartValues(),
+ Value_Name = "宽",
+ X_Time = new List(),
+ Y_MinValue = Convert.ToInt32(tools.GetAppSetting("颗粒物分析仪宽Min")),
+ Y_MaxValue = Convert.ToInt32(tools.GetAppSetting("颗粒物分析仪宽Max"))
+
+ };
}
}
diff --git a/InSituLaboratory.IService/Sensor/ISensorService.cs b/InSituLaboratory.IService/Sensor/ISensorService.cs
index 7b60e71..21a6583 100644
--- a/InSituLaboratory.IService/Sensor/ISensorService.cs
+++ b/InSituLaboratory.IService/Sensor/ISensorService.cs
@@ -191,6 +191,35 @@ namespace InSituLaboratory.IService.Sensor
#endregion
+ #region 颗粒物分析仪
+ ///
+ /// 获取颗粒物分析仪数据
+ ///
+ ///
+ IEnumerable GetParticleAnalyzer();
+
+ ///
+ /// 获取颗粒物分析仪数据--图表
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ IEnumerable GetParticleAnalyzerData();
+
+ ///
+ /// 获取颗粒物分析仪数据--分页 按时间倒序排序
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ IEnumerable GetParticleAnalyzerData(string key, int pageSize, int pageIndex, out int totalCount);
+ #endregion
+
+
#region 与下位机通信电源开关类 --- 传感器
///
/// 获取传感器电源开关数据
diff --git a/InSituLaboratory.Models/Sendsor/ParticleAnalyzerModels.cs b/InSituLaboratory.Models/Sendsor/ParticleAnalyzerModels.cs
new file mode 100644
index 0000000..6d5a34f
--- /dev/null
+++ b/InSituLaboratory.Models/Sendsor/ParticleAnalyzerModels.cs
@@ -0,0 +1,85 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace InSituLaboratory.Models.Sendsor
+{
+ ///
+ /// 颗粒物分析仪
+ ///
+ public class ParticleAnalyzerModels
+ {
+ ///
+ /// 主键
+ ///
+ public int Id { get; set; }
+
+ ///
+ /// 采样时间
+ ///
+ public DateTime SamplingTime { get; set; }
+
+ ///
+ /// 记录时间
+ ///
+ public DateTime CreateTime { get; set; }
+
+ ///
+ /// 故障代码--设备温度 (未开启/未监控 正常 警报 故障)
+ ///
+ public string? Tem { get; set; }
+
+ ///
+ /// 故障代码--设备湿度 (未开启/未监控 正常 警报 故障)
+ ///
+ public string? Hum { get; set; }
+
+ ///
+ /// 故障代码--压力 (未开启/未监控 正常 警报 故障)
+ ///
+ public string? Pressure { get; set; }
+
+ ///
+ /// 故障代码--绝缘 (未开启/未监控 正常 警报 故障)
+ ///
+ public string? Insulation { get; set; }
+
+ ///
+ /// 颗粒物序号
+ ///
+ public float? ParticleNumber { get; set; }
+
+ ///
+ /// 坐标X
+ ///
+ public float? CoordinateX { get; set; }
+
+ ///
+ /// 坐标Y
+ ///
+ public float? CoordinateY { get; set; }
+
+ ///
+ /// 类型
+ ///
+ public float? Type { get; set; }
+
+ ///
+ /// 面积
+ ///
+ public float? Area { get; set; }
+
+ ///
+ /// 长
+ ///
+ public float? Long { get; set; }
+
+ ///
+ /// 宽
+ ///
+ public float? Wide { get; set; }
+ }
+}
diff --git a/InSituLaboratory.Service/Sensor/SensorService.cs b/InSituLaboratory.Service/Sensor/SensorService.cs
index 4f65f16..8f5c06c 100644
--- a/InSituLaboratory.Service/Sensor/SensorService.cs
+++ b/InSituLaboratory.Service/Sensor/SensorService.cs
@@ -278,6 +278,50 @@ namespace InSituLaboratory.Service.Sensor
}
#endregion
+
+
+ #region 颗粒物分析仪
+
+ ///
+ /// 获取颗粒物分析仪数据
+ ///
+ ///
+ public IEnumerable GetParticleAnalyzer()
+ {
+ return this.Query(m => true).OrderByDescending(n => n.CreateTime).AsNoTracking();
+ }
+
+ ///
+ /// 获取颗粒物分析仪数据---图表
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public IEnumerable GetParticleAnalyzerData()
+ {
+ return this.Query(m => true).OrderBy(m => m.CreateTime).AsNoTracking().ToList();
+ }
+
+ ///
+ /// 获取颗粒物分析仪数据--分页 按时间倒序排序
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public IEnumerable GetParticleAnalyzerData(string key, int pageSize, int pageIndex, out int totalCount)
+ {
+ var pResult = this.QueryPage(m => string.IsNullOrEmpty(key) || m.SamplingTime.ToString().Contains(key), pageSize, pageIndex, order => order.SamplingTime.ToString(), false);
+
+ totalCount = pResult.TotalCount;
+
+ return pResult.DataList;
+ }
+
+ #endregion
#region
///
/// 获取传感器电源开关数据
diff --git a/InSituLaboratory/App.config b/InSituLaboratory/App.config
index 43ef31c..3f25117 100644
--- a/InSituLaboratory/App.config
+++ b/InSituLaboratory/App.config
@@ -77,6 +77,14 @@
+
+
+
+
+
+
+
+
diff --git a/InSituLaboratory/Base/CSVDownload.cs b/InSituLaboratory/Base/CSVDownload.cs
index 822a40b..c8a84a7 100644
--- a/InSituLaboratory/Base/CSVDownload.cs
+++ b/InSituLaboratory/Base/CSVDownload.cs
@@ -516,7 +516,7 @@ namespace InSituLaboratory.Base
#endregion
- #region 二氧化碳同位素分析仪
+ #region 测序仪
///
/// 获取类的属性集合(以便生成CSV文件的所有Column标题)
///
@@ -603,5 +603,101 @@ namespace InSituLaboratory.Base
return successFlag;
}
#endregion
+
+ #region 颗粒物分析仪
+ ///
+ /// 获取类的属性集合(以便生成CSV文件的所有Column标题)
+ ///
+ ///
+ public static PropertyInfo[] GetParticleInfoArray()
+ {
+ PropertyInfo[] props = null;
+ try
+ {
+ Type type = typeof(ParticleAnalyzerModels);
+ object obj = Activator.CreateInstance(type);
+ props = type.GetProperties(BindingFlags.Public | BindingFlags.Instance);
+ }
+ catch (Exception ex)
+ { }
+ return props;
+ }
+
+
+ ///
+ /// Save the List data to CSV file
+ ///
+ /// data source
+ /// file path
+ /// success flag
+ public static bool SaveParticleDataToCSVFile(ObservableCollection BaseStationList, string filePath)
+ {
+ bool successFlag = true;
+
+ StringBuilder strColumn = new StringBuilder();
+ StringBuilder strValue = new StringBuilder();
+ StreamWriter sw = null;
+ PropertyInfo[] props = GetParticleInfoArray();
+
+ try
+ {
+ sw = new StreamWriter(filePath);
+ for (int i = 0; i < props.Length; i++)
+ {
+ strColumn.Append(props[i].Name);
+ strColumn.Append(",");
+ }
+ strColumn.Remove(strColumn.Length - 1, 1);
+ sw.WriteLine(strColumn); //write the column name
+
+ for (int i = 0; i < BaseStationList.Count; i++)
+ {
+ strValue.Remove(0, strValue.Length); //clear the temp row value
+ strValue.Append(BaseStationList[i].Id);
+ strValue.Append(",");
+ strValue.Append(BaseStationList[i].CreateTime);
+ strValue.Append(",");
+ strValue.Append(BaseStationList[i].SamplingTime);
+ strValue.Append(",");
+ strValue.Append(BaseStationList[i].Tem);
+ strValue.Append(",");
+ strValue.Append(BaseStationList[i].Hum);
+ strValue.Append(",");
+ strValue.Append(BaseStationList[i].Pressure);
+ strValue.Append(",");
+ strValue.Append(BaseStationList[i].Insulation);
+ strValue.Append(",");
+ strValue.Append(BaseStationList[i].ParticleNumber);
+ strValue.Append(",");
+ strValue.Append(BaseStationList[i].CoordinateX);
+ strValue.Append(",");
+ strValue.Append(BaseStationList[i].CoordinateY);
+ strValue.Append(",");
+ strValue.Append(BaseStationList[i].Type);
+ strValue.Append(",");
+ strValue.Append(BaseStationList[i].Area);
+ strValue.Append(",");
+ strValue.Append(BaseStationList[i].Long);
+ strValue.Append(",");
+ strValue.Append(BaseStationList[i].Wide);
+
+ sw.WriteLine(strValue); //write the row value
+ }
+ }
+ catch (Exception ex)
+ {
+ successFlag = false;
+ }
+ finally
+ {
+ if (sw != null)
+ {
+ sw.Dispose();
+ }
+ }
+
+ return successFlag;
+ }
+ #endregion
}
}
diff --git a/InSituLaboratory/ViewModels/Pages/Sensor/ParticleAnalyzerViewModel.cs b/InSituLaboratory/ViewModels/Pages/Sensor/ParticleAnalyzerViewModel.cs
index 5b9052a..b3afe07 100644
--- a/InSituLaboratory/ViewModels/Pages/Sensor/ParticleAnalyzerViewModel.cs
+++ b/InSituLaboratory/ViewModels/Pages/Sensor/ParticleAnalyzerViewModel.cs
@@ -1,9 +1,20 @@
-using Prism.Regions;
+using InSituLaboratory.Base;
+using InSituLaboratory.Controls;
+using InSituLaboratory.Entities;
+using InSituLaboratory.Entities.Sensor;
+using InSituLaboratory.IService.Sensor;
+using InSituLaboratory.Models.Sendsor;
+using Prism.Commands;
+using Prism.Regions;
using System;
using System.Collections.Generic;
+using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Media;
+using System.Windows.Threading;
namespace InSituLaboratory.ViewModels.Pages.Sensor
{
@@ -12,9 +23,186 @@ namespace InSituLaboratory.ViewModels.Pages.Sensor
///
public class ParticleAnalyzerViewModel : ViewModelBase
{
- public ParticleAnalyzerViewModel(IRegionManager regionManager) : base(regionManager)
+ #region 实体类
+ public ParticleAnalyzerModel ParticleModel { get; set; } = new ParticleAnalyzerModel();
+ public PaginationModel PaginationModel { get; set; } = new PaginationModel();
+ public DispatcherTimer timerDownloadDataMsgHidden = new DispatcherTimer();
+ public ObservableCollection ParticleModellist { get; set; } = new ObservableCollection();
+ public ObservableCollection ParticleModelslist { get; set; } = new ObservableCollection();
+
+
+ #endregion
+
+ ISensorService _iSensorService;
+ public ParticleAnalyzerViewModel(IRegionManager regionManager, ISensorService iSensorService) : base(regionManager)
{
PageTitle = "颗粒物分析仪";
+ _iSensorService = iSensorService;
+
+ PaginationModel.NavCommand = new DelegateCommand