diff --git a/InSituLaboratory.Entities/Sensor/CH4IsotopeModel.cs b/InSituLaboratory.Entities/Sensor/CH4IsotopeModel.cs
new file mode 100644
index 0000000..78f2bfa
--- /dev/null
+++ b/InSituLaboratory.Entities/Sensor/CH4IsotopeModel.cs
@@ -0,0 +1,105 @@
+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;
+
+namespace InSituLaboratory.Entities.Sensor
+{
+ ///
+ /// 甲烷同位素分析仪
+ ///
+ public class CH4IsotopeModel
+ {
+ ///
+ /// 主键
+ ///
+ [Key]
+ 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; }
+
+ ///
+ /// C1浓度
+ ///
+ public float C1 { get; set; }
+
+ ///
+ /// C2浓度
+ ///
+ public float C2 { get; set; }
+
+ ///
+ /// 丰度
+ ///
+ public float Abundance { get; set; }
+
+
+ [NotMapped]
+ public int DataIdNum { get; set; }
+
+
+ public ChartsModel CH4IsotopeChartsC1 { get; set; } = new ChartsModel()
+ {
+ Values = new ChartValues(),
+ Value_Name = "C1浓度",
+ X_Time = new List(),
+ Y_MinValue = Convert.ToInt32(tools.GetAppSetting("甲烷同位素分析仪C1浓度Min")),
+ Y_MaxValue = Convert.ToInt32(tools.GetAppSetting("甲烷同位素分析仪C1浓度Max"))
+
+ };
+
+ public ChartsModel CH4IsotopeChartsC2 { get; set; } = new ChartsModel()
+ {
+ Values = new ChartValues(),
+ Value_Name = "C2浓度",
+ X_Time = new List(),
+ Y_MinValue = Convert.ToInt32(tools.GetAppSetting("甲烷同位素分析仪C2浓度Min")),
+ Y_MaxValue = Convert.ToInt32(tools.GetAppSetting("甲烷同位素分析仪C2浓度Max"))
+
+ };
+
+ public ChartsModel CH4IsotopeChartsAbundance { 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 86f3fe2..6880555 100644
--- a/InSituLaboratory.IService/Sensor/ISensorService.cs
+++ b/InSituLaboratory.IService/Sensor/ISensorService.cs
@@ -101,6 +101,34 @@ namespace InSituLaboratory.IService.Sensor
#endregion
+ #region 甲烷同位素分析仪
+
+ ///
+ /// 获取甲烷同位素分析仪数据
+ ///
+ ///
+ IEnumerable GetCh4Isotope();
+
+ ///
+ /// 获取甲烷同位素分析仪数据--图表
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ IEnumerable GetCh4ISotopeData();
+
+ ///
+ /// 获取甲烷同位素分析仪数据--分页 按时间倒序排序
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ IEnumerable GetCh4ISotopeData(string key, int pageSize, int pageIndex, out int totalCount);
+ #endregion
}
}
diff --git a/InSituLaboratory.Models/Sendsor/CH4IsotopeModels.cs b/InSituLaboratory.Models/Sendsor/CH4IsotopeModels.cs
new file mode 100644
index 0000000..d51d50f
--- /dev/null
+++ b/InSituLaboratory.Models/Sendsor/CH4IsotopeModels.cs
@@ -0,0 +1,70 @@
+using InSituLaboratory.Entities;
+using LiveCharts;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace InSituLaboratory.Models.Sendsor
+{
+ ///
+ /// 甲烷同位素分析仪
+ ///
+ public class CH4IsotopeModels
+ {
+ ///
+ /// 主键
+ ///
+ 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; }
+
+ ///
+ /// C1浓度
+ ///
+ public float C1 { get; set; }
+
+ ///
+ /// C2浓度
+ ///
+ public float C2 { get; set; }
+
+ ///
+ /// 丰度
+ ///
+ public float Abundance { get; set; }
+
+ }
+}
diff --git a/InSituLaboratory.ORM/NoimptyDbContext.cs b/InSituLaboratory.ORM/NoimptyDbContext.cs
index 9894716..ca01787 100644
--- a/InSituLaboratory.ORM/NoimptyDbContext.cs
+++ b/InSituLaboratory.ORM/NoimptyDbContext.cs
@@ -78,5 +78,6 @@ namespace InSituLaboratory.ORM
public virtual DbSet MEMSSpModel { get; set; }
public virtual DbSet MEMSZpModel { get; set; }
public virtual DbSet ColorMSModel { get; set; }
+ public virtual DbSet CH4IsotopeModel { get; set; }
}
}
diff --git a/InSituLaboratory.Service/Sensor/SensorService.cs b/InSituLaboratory.Service/Sensor/SensorService.cs
index 8119b75..5b0cb37 100644
--- a/InSituLaboratory.Service/Sensor/SensorService.cs
+++ b/InSituLaboratory.Service/Sensor/SensorService.cs
@@ -147,5 +147,48 @@ namespace InSituLaboratory.Service.Sensor
#endregion
+
+ #region 甲烷同位素分析仪
+
+ ///
+ /// 获取甲烷同位素分析仪数据
+ ///
+ ///
+ public IEnumerable GetCh4Isotope()
+ {
+ return this.Query(m => true).OrderByDescending(n => n.CreateTime).AsNoTracking();
+ }
+
+ ///
+ /// 获取甲烷同位素分析仪数据---图表
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public IEnumerable GetCh4ISotopeData()
+ {
+ return this.Query(m => true).OrderBy(m => m.CreateTime).AsNoTracking().ToList();
+ }
+
+ ///
+ /// 获取甲烷同位素分析仪数据--分页 按时间倒序排序
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public IEnumerable GetCh4ISotopeData(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
+
}
}
diff --git a/InSituLaboratory/App.config b/InSituLaboratory/App.config
index 6799887..94f36f7 100644
--- a/InSituLaboratory/App.config
+++ b/InSituLaboratory/App.config
@@ -53,6 +53,13 @@
+
+
+
+
+
+
+
diff --git a/InSituLaboratory/Base/CSVDownload.cs b/InSituLaboratory/Base/CSVDownload.cs
index d15c404..a0b240b 100644
--- a/InSituLaboratory/Base/CSVDownload.cs
+++ b/InSituLaboratory/Base/CSVDownload.cs
@@ -234,6 +234,7 @@ namespace InSituLaboratory.Base
}
#endregion
+
#region ColorMSModel
///
/// 获取类的属性集合(以便生成CSV文件的所有Column标题)
@@ -331,5 +332,95 @@ namespace InSituLaboratory.Base
return successFlag;
}
#endregion
+
+
+ #region CH4IsotopeModel
+ ///
+ /// 获取类的属性集合(以便生成CSV文件的所有Column标题)
+ ///
+ ///
+ public static PropertyInfo[] GetCH4IsotopeInfoArray()
+ {
+ PropertyInfo[] props = null;
+ try
+ {
+ Type type = typeof(CH4IsotopeModels);
+ 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 SaveCh4IsotopeDataToCSVFile(ObservableCollection BaseStationList, string filePath)
+ {
+ bool successFlag = true;
+
+ StringBuilder strColumn = new StringBuilder();
+ StringBuilder strValue = new StringBuilder();
+ StreamWriter sw = null;
+ PropertyInfo[] props = GetCH4IsotopeInfoArray();
+
+ 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].C1);
+ strValue.Append(",");
+ strValue.Append(BaseStationList[i].C2);
+ strValue.Append(",");
+ strValue.Append(BaseStationList[i].Abundance);
+
+
+ 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/CH4IsotopeViewModel.cs b/InSituLaboratory/ViewModels/Pages/Sensor/CH4IsotopeViewModel.cs
index fb78d75..ae4fcc5 100644
--- a/InSituLaboratory/ViewModels/Pages/Sensor/CH4IsotopeViewModel.cs
+++ b/InSituLaboratory/ViewModels/Pages/Sensor/CH4IsotopeViewModel.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,178 @@ namespace InSituLaboratory.ViewModels.Pages.Sensor
///
public class CH4IsotopeViewModel : ViewModelBase
{
- public CH4IsotopeViewModel(IRegionManager regionManager) : base(regionManager)
+
+ #region 实体类
+ public CH4IsotopeModel cH4IsotopeModel { get; set; } = new CH4IsotopeModel();
+ public PaginationModel PaginationModel { get; set; } = new PaginationModel();
+
+ public ObservableCollection cH4IsotopeModellist { get; set; } = new ObservableCollection();
+ public ObservableCollection cH4IsotopeModelslist { get; set; } = new ObservableCollection();
+
+ public DispatcherTimer timerDownloadDataMsgHidden = new DispatcherTimer();
+ #endregion
+
+ ISensorService _iSensorService;
+ public CH4IsotopeViewModel(IRegionManager regionManager, ISensorService iSensorService) : base(regionManager)
{
PageTitle = "甲烷同位素分析仪";
+ _iSensorService = iSensorService;
+
+ PaginationModel.NavCommand = new DelegateCommand