颗粒物分析仪页面开发完成
This commit is contained in:
parent
065fe14766
commit
499d0b5730
@ -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
|
||||
/// </summary>
|
||||
public string? Insulation { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 颗粒物序号
|
||||
/// </summary>
|
||||
public float? ParticleNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 坐标X
|
||||
/// </summary>
|
||||
public float? CoordinateX { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 坐标Y
|
||||
/// </summary>
|
||||
public float? CoordinateY { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 类型
|
||||
/// </summary>
|
||||
public float? Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 面积
|
||||
/// </summary>
|
||||
public float? Area { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 长
|
||||
/// </summary>
|
||||
public float? Long { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 宽
|
||||
/// </summary>
|
||||
public float? Wide { get; set; }
|
||||
|
||||
|
||||
[NotMapped]
|
||||
public int DataIdNum { get; set; }
|
||||
|
||||
|
||||
public ChartsModel AreaCharts { get; set; } = new ChartsModel()
|
||||
{
|
||||
Values = new ChartValues<float>(),
|
||||
Value_Name = "面积",
|
||||
X_Time = new List<string>(),
|
||||
Y_MinValue = Convert.ToInt32(tools.GetAppSetting("颗粒物分析仪面积Min")),
|
||||
Y_MaxValue = Convert.ToInt32(tools.GetAppSetting("颗粒物分析仪面积Max"))
|
||||
|
||||
};
|
||||
|
||||
public ChartsModel LongCharts { get; set; } = new ChartsModel()
|
||||
{
|
||||
Values = new ChartValues<float>(),
|
||||
Value_Name = "长",
|
||||
X_Time = new List<string>(),
|
||||
Y_MinValue = Convert.ToInt32(tools.GetAppSetting("颗粒物分析仪长Min")),
|
||||
Y_MaxValue = Convert.ToInt32(tools.GetAppSetting("颗粒物分析仪长Max"))
|
||||
|
||||
};
|
||||
|
||||
public ChartsModel WideCharts { get; set; } = new ChartsModel()
|
||||
{
|
||||
Values = new ChartValues<float>(),
|
||||
Value_Name = "宽",
|
||||
X_Time = new List<string>(),
|
||||
Y_MinValue = Convert.ToInt32(tools.GetAppSetting("颗粒物分析仪宽Min")),
|
||||
Y_MaxValue = Convert.ToInt32(tools.GetAppSetting("颗粒物分析仪宽Max"))
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@ -191,6 +191,35 @@ namespace InSituLaboratory.IService.Sensor
|
||||
#endregion
|
||||
|
||||
|
||||
#region 颗粒物分析仪
|
||||
/// <summary>
|
||||
/// 获取颗粒物分析仪数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
IEnumerable<ParticleAnalyzerModel> GetParticleAnalyzer();
|
||||
|
||||
/// <summary>
|
||||
/// 获取颗粒物分析仪数据--图表
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="pageSize"></param>
|
||||
/// <param name="pageIndex"></param>
|
||||
/// <param name="totalCount"></param>
|
||||
/// <returns></returns>
|
||||
IEnumerable<ParticleAnalyzerModel> GetParticleAnalyzerData();
|
||||
|
||||
/// <summary>
|
||||
/// 获取颗粒物分析仪数据--分页 按时间倒序排序
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="pageSize"></param>
|
||||
/// <param name="pageIndex"></param>
|
||||
/// <param name="totalCount"></param>
|
||||
/// <returns></returns>
|
||||
IEnumerable<ParticleAnalyzerModel> GetParticleAnalyzerData(string key, int pageSize, int pageIndex, out int totalCount);
|
||||
#endregion
|
||||
|
||||
|
||||
#region 与下位机通信电源开关类 --- 传感器
|
||||
/// <summary>
|
||||
/// 获取传感器电源开关数据
|
||||
|
||||
85
InSituLaboratory.Models/Sendsor/ParticleAnalyzerModels.cs
Normal file
85
InSituLaboratory.Models/Sendsor/ParticleAnalyzerModels.cs
Normal file
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// 颗粒物分析仪
|
||||
/// </summary>
|
||||
public class ParticleAnalyzerModels
|
||||
{
|
||||
/// <summary>
|
||||
/// 主键
|
||||
/// </summary>
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 采样时间
|
||||
/// </summary>
|
||||
public DateTime SamplingTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 记录时间
|
||||
/// </summary>
|
||||
public DateTime CreateTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 故障代码--设备温度 (未开启/未监控 正常 警报 故障)
|
||||
/// </summary>
|
||||
public string? Tem { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 故障代码--设备湿度 (未开启/未监控 正常 警报 故障)
|
||||
/// </summary>
|
||||
public string? Hum { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 故障代码--压力 (未开启/未监控 正常 警报 故障)
|
||||
/// </summary>
|
||||
public string? Pressure { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 故障代码--绝缘 (未开启/未监控 正常 警报 故障)
|
||||
/// </summary>
|
||||
public string? Insulation { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 颗粒物序号
|
||||
/// </summary>
|
||||
public float? ParticleNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 坐标X
|
||||
/// </summary>
|
||||
public float? CoordinateX { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 坐标Y
|
||||
/// </summary>
|
||||
public float? CoordinateY { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 类型
|
||||
/// </summary>
|
||||
public float? Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 面积
|
||||
/// </summary>
|
||||
public float? Area { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 长
|
||||
/// </summary>
|
||||
public float? Long { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 宽
|
||||
/// </summary>
|
||||
public float? Wide { get; set; }
|
||||
}
|
||||
}
|
||||
@ -278,6 +278,50 @@ namespace InSituLaboratory.Service.Sensor
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region 颗粒物分析仪
|
||||
|
||||
/// <summary>
|
||||
/// 获取颗粒物分析仪数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public IEnumerable<ParticleAnalyzerModel> GetParticleAnalyzer()
|
||||
{
|
||||
return this.Query<ParticleAnalyzerModel>(m => true).OrderByDescending(n => n.CreateTime).AsNoTracking();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取颗粒物分析仪数据---图表
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="pageSize"></param>
|
||||
/// <param name="pageIndex"></param>
|
||||
/// <param name="totalCount"></param>
|
||||
/// <returns></returns>
|
||||
public IEnumerable<ParticleAnalyzerModel> GetParticleAnalyzerData()
|
||||
{
|
||||
return this.Query<ParticleAnalyzerModel>(m => true).OrderBy(m => m.CreateTime).AsNoTracking().ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取颗粒物分析仪数据--分页 按时间倒序排序
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="pageSize"></param>
|
||||
/// <param name="pageIndex"></param>
|
||||
/// <param name="totalCount"></param>
|
||||
/// <returns></returns>
|
||||
public IEnumerable<ParticleAnalyzerModel> GetParticleAnalyzerData(string key, int pageSize, int pageIndex, out int totalCount)
|
||||
{
|
||||
var pResult = this.QueryPage<ParticleAnalyzerModel, string>(m => string.IsNullOrEmpty(key) || m.SamplingTime.ToString().Contains(key), pageSize, pageIndex, order => order.SamplingTime.ToString(), false);
|
||||
|
||||
totalCount = pResult.TotalCount;
|
||||
|
||||
return pResult.DataList;
|
||||
}
|
||||
|
||||
#endregion
|
||||
#region
|
||||
/// <summary>
|
||||
/// 获取传感器电源开关数据
|
||||
|
||||
@ -77,6 +77,14 @@
|
||||
<add key="测序仪试剂温度Min" value="0"/>
|
||||
<add key="测序仪样本浓度Max" value="10"/>
|
||||
<add key="测序仪样本浓度Min" value="0"/>
|
||||
|
||||
<add key="颗粒物分析仪面积Max" value="50"/>
|
||||
<add key="颗粒物分析仪面积Min" value="0"/>
|
||||
<add key="颗粒物分析仪长Max" value="100"/>
|
||||
<add key="颗粒物分析仪长Min" value="0"/>
|
||||
<add key="颗粒物分析仪宽Max" value="100"/>
|
||||
<add key="颗粒物分析仪宽Min" value="0"/>
|
||||
|
||||
<!--文件下载-->
|
||||
<add key="MEMSSPFolder" value="D:\\Download\\"/>
|
||||
</appSettings>
|
||||
|
||||
@ -516,7 +516,7 @@ namespace InSituLaboratory.Base
|
||||
#endregion
|
||||
|
||||
|
||||
#region 二氧化碳同位素分析仪
|
||||
#region 测序仪
|
||||
/// <summary>
|
||||
/// 获取类的属性集合(以便生成CSV文件的所有Column标题)
|
||||
/// </summary>
|
||||
@ -603,5 +603,101 @@ namespace InSituLaboratory.Base
|
||||
return successFlag;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 颗粒物分析仪
|
||||
/// <summary>
|
||||
/// 获取类的属性集合(以便生成CSV文件的所有Column标题)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Save the List data to CSV file
|
||||
/// </summary>
|
||||
/// <param name="BaseStationList">data source</param>
|
||||
/// <param name="filePath">file path</param>
|
||||
/// <returns>success flag</returns>
|
||||
public static bool SaveParticleDataToCSVFile(ObservableCollection<ParticleAnalyzerModels> 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
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
/// </summary>
|
||||
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<ParticleAnalyzerModel> ParticleModellist { get; set; } = new ObservableCollection<ParticleAnalyzerModel>();
|
||||
public ObservableCollection<ParticleAnalyzerModels> ParticleModelslist { get; set; } = new ObservableCollection<ParticleAnalyzerModels>();
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
ISensorService _iSensorService;
|
||||
public ParticleAnalyzerViewModel(IRegionManager regionManager, ISensorService iSensorService) : base(regionManager)
|
||||
{
|
||||
PageTitle = "颗粒物分析仪";
|
||||
_iSensorService = iSensorService;
|
||||
|
||||
PaginationModel.NavCommand = new DelegateCommand<object>(index =>
|
||||
{
|
||||
PaginationModel.PageIndex = int.Parse(index.ToString());
|
||||
this.Refresh();
|
||||
});
|
||||
|
||||
this.Refresh();
|
||||
|
||||
timerDownloadDataMsgHidden.Interval = TimeSpan.FromSeconds(2);
|
||||
timerDownloadDataMsgHidden.Tick += TimerDownloadDataMsgHidden_Tick;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 数据刷新
|
||||
/// </summary>
|
||||
public override void Refresh()
|
||||
{
|
||||
ParticleModellist.Clear();
|
||||
ParticleModelslist.Clear();
|
||||
ParticleModel.AreaCharts.Values.Clear();
|
||||
ParticleModel.AreaCharts.X_Time.Clear();
|
||||
ParticleModel.LongCharts.Values.Clear();
|
||||
ParticleModel.LongCharts.X_Time.Clear();
|
||||
ParticleModel.WideCharts.Values.Clear();
|
||||
ParticleModel.WideCharts.X_Time.Clear();
|
||||
|
||||
var particaleforChart = _iSensorService.GetParticleAnalyzerData();
|
||||
var particalelist = _iSensorService.GetParticleAnalyzerData(SearchKey, PaginationModel.PageSize, PaginationModel.PageIndex, out int totalCount);
|
||||
|
||||
///状态监控
|
||||
if (particalelist.Count() != 0)
|
||||
{
|
||||
var data = _iSensorService.GetParticleAnalyzer().FirstOrDefault();
|
||||
ParticleModel.Tem = data.Tem;
|
||||
ParticleModel.Hum = data.Hum;
|
||||
ParticleModel.Pressure = data.Pressure;
|
||||
ParticleModel.Insulation = data.Insulation;
|
||||
ParticleModel.SamplingTime = data.SamplingTime;
|
||||
}
|
||||
|
||||
///列表清单数据
|
||||
int index = 0;
|
||||
foreach (var item in particalelist)
|
||||
{
|
||||
index++;
|
||||
ParticleModellist.Add(new ParticleAnalyzerModel
|
||||
{
|
||||
DataIdNum = index + (PaginationModel.PageIndex - 1) * PaginationModel.PageSize,
|
||||
SamplingTime = item.SamplingTime,
|
||||
CreateTime = item.CreateTime,
|
||||
Tem = item.Tem,
|
||||
Hum = item.Hum,
|
||||
Pressure = item.Pressure,
|
||||
Insulation = item.Insulation,
|
||||
ParticleNumber = item.ParticleNumber,
|
||||
CoordinateX = item.CoordinateX,
|
||||
CoordinateY = item.CoordinateY,
|
||||
Type = item.Type,
|
||||
Area = item.Area,
|
||||
Long = item.Long,
|
||||
Wide = item.Wide
|
||||
});
|
||||
}
|
||||
|
||||
///图表数据及下载
|
||||
int indexm = 0;
|
||||
foreach (var item in particaleforChart)
|
||||
{
|
||||
indexm++;
|
||||
ParticleModelslist.Add(new ParticleAnalyzerModels
|
||||
{
|
||||
Id = indexm,
|
||||
SamplingTime = item.SamplingTime,
|
||||
CreateTime = item.CreateTime,
|
||||
Tem = item.Tem,
|
||||
Hum = item.Hum,
|
||||
Pressure = item.Pressure,
|
||||
Insulation = item.Insulation,
|
||||
ParticleNumber = item.ParticleNumber,
|
||||
CoordinateX = item.CoordinateX,
|
||||
CoordinateY = item.CoordinateY,
|
||||
Type = item.Type,
|
||||
Area = item.Area,
|
||||
Long = item.Long,
|
||||
Wide = item.Wide
|
||||
});
|
||||
if (ParticleModel.AreaCharts.Values.Count >= Convert.ToInt32(tools.GetAppSetting("Chart_Limit")))
|
||||
{
|
||||
ParticleModel.AreaCharts.Values.RemoveAt(0);
|
||||
ParticleModel.AreaCharts.X_Time.RemoveAt(0);
|
||||
}
|
||||
|
||||
if (ParticleModel.LongCharts.Values.Count >= Convert.ToInt32(tools.GetAppSetting("Chart_Limit")))
|
||||
{
|
||||
ParticleModel.LongCharts.Values.RemoveAt(0);
|
||||
ParticleModel.LongCharts.X_Time.RemoveAt(0);
|
||||
}
|
||||
|
||||
if (ParticleModel.WideCharts.Values.Count >= Convert.ToInt32(tools.GetAppSetting("Chart_Limit")))
|
||||
{
|
||||
ParticleModel.WideCharts.Values.RemoveAt(0);
|
||||
ParticleModel.WideCharts.X_Time.RemoveAt(0);
|
||||
}
|
||||
|
||||
|
||||
ParticleModel.AreaCharts.Values.Add(Convert.ToSingle(item.Area));
|
||||
ParticleModel.AreaCharts.X_Time.Add(item.SamplingTime.ToShortTimeString());
|
||||
ParticleModel.LongCharts.Values.Add(Convert.ToSingle(item.Long));
|
||||
ParticleModel.LongCharts.X_Time.Add(item.SamplingTime.ToShortTimeString());
|
||||
ParticleModel.WideCharts.Values.Add(Convert.ToSingle(item.Wide));
|
||||
ParticleModel.WideCharts.X_Time.Add(item.SamplingTime.ToShortTimeString());
|
||||
}
|
||||
|
||||
// 刷新分页组件的页码
|
||||
PaginationModel.FillPageNumbers(totalCount);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 数据下载
|
||||
/// </summary>
|
||||
public override void DoDownload()
|
||||
{
|
||||
DownloadDataBtnIsEnabled = false;
|
||||
DownloadDataMsgVisibility = Visibility.Visible;
|
||||
string baseStationFolder = "";
|
||||
System.Windows.Forms.FolderBrowserDialog FolderBrowserDialog = new System.Windows.Forms.FolderBrowserDialog(); //选择文件夹
|
||||
//注意,此处一定要手动引入System.Window.Forms空间,否则你如果使用默认的DialogResult会发现没有OK属性
|
||||
if (FolderBrowserDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
||||
{
|
||||
baseStationFolder = FolderBrowserDialog.SelectedPath + "\\";
|
||||
}
|
||||
|
||||
//string baseStationFolder = tools.GetAppSetting("MEMSSPFolder");
|
||||
string savePath = CSVDownload.CreateFile(baseStationFolder, "颗粒物分析仪_Data_" + DateTime.Now.ToString("yyyyMMddHHmmss"), "csv");
|
||||
|
||||
bool result = CSVDownload.SaveParticleDataToCSVFile(ParticleModelslist, savePath);
|
||||
if (result)
|
||||
{
|
||||
DownloadDataMsg = "下载数据成功!";
|
||||
DownloadDataMsgForeground = new SolidColorBrush(Colors.Green);
|
||||
}
|
||||
else
|
||||
{
|
||||
DownloadDataMsg = "下载数据失败!";
|
||||
DownloadDataMsgForeground = new SolidColorBrush(Colors.Red);
|
||||
}
|
||||
|
||||
timerDownloadDataMsgHidden.Start();
|
||||
DownloadDataBtnIsEnabled = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 定时器停止
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void TimerDownloadDataMsgHidden_Tick(object sender, EventArgs e)
|
||||
{
|
||||
DownloadDataMsgVisibility = Visibility.Hidden;
|
||||
|
||||
// 停止定时器
|
||||
(sender as DispatcherTimer).Stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -49,7 +49,7 @@
|
||||
</Setter>
|
||||
</Style>
|
||||
</UserControl.Resources>
|
||||
<Grid Background="#14273a" Margin="10,5,10,10">
|
||||
<Grid Background="#14273a" Margin="10,5,10,10">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="100"/>
|
||||
<RowDefinition/>
|
||||
|
||||
@ -9,7 +9,287 @@
|
||||
xmlns:local="clr-namespace:InSituLaboratory.Views.Pages.Sensor"
|
||||
mc:Ignorable="d" Template="{StaticResource PageSearchAndDownloadTempalte}"
|
||||
FontFamily="{StaticResource DigitalDisplay}">
|
||||
|
||||
<UserControl.Resources>
|
||||
<converters:SensorStateConvert x:Key="SensorStateConvert" />
|
||||
<Style TargetType="GroupBox">
|
||||
<Setter Property="Margin" Value="10,5" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="GroupBox">
|
||||
<Grid>
|
||||
<!-- 左上角 -->
|
||||
<Polyline HorizontalAlignment="Left" VerticalAlignment="Top" Points="0 30, 0 10, 10 0, 30 0" Stroke="#9918AABD" StrokeThickness="1" />
|
||||
<!-- 左上角点 -->
|
||||
<Ellipse Width="4" Height="4" Margin="24,-2,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Fill="#9918AABD" />
|
||||
<Ellipse Width="4" Height="4" Margin="-2,24,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Fill="#9918AABD" />
|
||||
<!-- 右上角 -->
|
||||
<Path HorizontalAlignment="Right" VerticalAlignment="Top" Data="M0 0, 3 3, 30 3, 33 0, 68 0, 73 7,78 7, 78 10M8 0, 25 0" Stroke="#5518AABD" />
|
||||
<!-- 左下角 -->
|
||||
<Polyline HorizontalAlignment="Left" VerticalAlignment="Bottom" Points="0,0 0,15 10,15" Stroke="#5518AABD" />
|
||||
<!-- 右下角 -->
|
||||
<Polyline HorizontalAlignment="Right" VerticalAlignment="Bottom" Points="10,0 0,10" Stroke="#5518AABD" />
|
||||
<!-- 右下角图标 -->
|
||||
<Polygon HorizontalAlignment="Right" VerticalAlignment="Bottom" Fill="#9918AABD" Points="0,7 7 7 7 0" />
|
||||
|
||||
<Border Margin="30,-0.5,78,0" VerticalAlignment="Top" BorderBrush="#5518AABD" BorderThickness="0,1,0,0" />
|
||||
<Border Margin="0,10" HorizontalAlignment="Right" BorderBrush="#5518AABD" BorderThickness="0,0,1,0" />
|
||||
<Border Margin="10,0" VerticalAlignment="Bottom" BorderBrush="#5518AABD" BorderThickness="0,1,0,0" />
|
||||
<Border Margin="-0.5,15" HorizontalAlignment="Left" BorderBrush="#5518AABD" BorderThickness="0,0,1,0" />
|
||||
|
||||
<!-- 箭头 -->
|
||||
<Path Margin="10,13" HorizontalAlignment="Left" VerticalAlignment="Top" Data="M0 0,3 0,5 4,3 8,0 8,3 4" Fill="#9918AABD" />
|
||||
<Path Margin="16,13" HorizontalAlignment="Left" VerticalAlignment="Top" Data="M0 0,3 0,5 4,3 8,0 8,3 4" Fill="#5518AABD" />
|
||||
<!-- 字体 -->
|
||||
<TextBlock Margin="25,8" HorizontalAlignment="Left" VerticalAlignment="Top" Foreground="#18AABD" Text="{TemplateBinding Header}" FontSize="18"/>
|
||||
<!-- 占位对象 -->
|
||||
<ContentPresenter />
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</UserControl.Resources>
|
||||
<Grid Background="#14273a" Margin="10,5,10,10">
|
||||
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="100"/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid >
|
||||
<!--状态监控-->
|
||||
<GroupBox Header="状态监控" Margin="12,12,12,5">
|
||||
<Grid >
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid >
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="30"/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid Grid.Row="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="2*" />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Column="0" Text="设备温度" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="16" Foreground="White"/>
|
||||
<Border Grid.Column="1" Width="20" Height="20" Background="{Binding ParticleModel.Tem, Converter={StaticResource ResourceKey=SensorStateConvert}}" CornerRadius="10" HorizontalAlignment="Center" VerticalAlignment="Center" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
<Grid Grid.Column="1">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="30"/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid Grid.Row="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="2*" />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Column="0" Text="设备湿度" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="16" Foreground="White"/>
|
||||
<Border Grid.Column="1" Width="20" Height="20" Background="{Binding ParticleModel.Hum, Converter={StaticResource ResourceKey=SensorStateConvert}}" CornerRadius="10" HorizontalAlignment="Center" VerticalAlignment="Center" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
<Grid Grid.Column="2">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="30"/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid Grid.Row="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="2*" />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Column="0" Text="设备压力" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="16" Foreground="White"/>
|
||||
<Border Grid.Column="1" Width="20" Height="20" Background="{Binding ParticleModel.Pressure, Converter={StaticResource ResourceKey=SensorStateConvert}}" CornerRadius="10" HorizontalAlignment="Center" VerticalAlignment="Center" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
<Grid Grid.Column="3">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="30"/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid Grid.Row="0">
|
||||
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Orientation="Horizontal">
|
||||
<Border Width="10" Height="10" Background="Gray" CornerRadius="10" />
|
||||
<TextBlock Text="未开启/未监控" Margin="10,5" Foreground="White"/>
|
||||
<Border Width="10" Height="10" Background="Green" CornerRadius="10" />
|
||||
<TextBlock Text="正常" Margin="10,5" Foreground="White"/>
|
||||
<Border Width="10" Height="10" Background="Yellow" CornerRadius="10" />
|
||||
<TextBlock Text="警报" Margin="10,5" Foreground="White"/>
|
||||
<Border Width="10" Height="10" Background="red" CornerRadius="10" />
|
||||
<TextBlock Text="故障" Margin="10,5" Foreground="White"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
<Grid Grid.Row="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="2*" />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Column="0" Text="设备绝缘" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="16" Foreground="White"/>
|
||||
<Border Grid.Column="1" Width="20" Height="20" Background="{Binding ParticleModel.Insulation, Converter={StaticResource ResourceKey=SensorStateConvert}}" CornerRadius="10" HorizontalAlignment="Center" VerticalAlignment="Center" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</GroupBox>
|
||||
</Grid>
|
||||
<Grid Grid.Row="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<!--状态数据展示-->
|
||||
<Grid Grid.Column="0">
|
||||
<GroupBox Header="状态数据展示" Margin="12,3,12,18">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="35"/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid Grid.IsSharedSizeScope="True" Margin="5,5,5,2" Grid.Row="1">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition/>
|
||||
<RowDefinition Height="50"/>
|
||||
</Grid.RowDefinitions>
|
||||
<ScrollViewer ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Hidden" x:Name="sv" CanContentScroll="False" PreviewMouseWheel="ScrollViewer_PreviewMouseWheel">
|
||||
<DataGrid ItemsSource="{Binding ParticleModellist }" FontSize="15" FontWeight="Bold" IsReadOnly="True" >
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Header="序号" Width="60" Binding="{Binding DataIdNum}" Foreground="White"/>
|
||||
<DataGridTextColumn Header="采样时间" Width="170" Binding="{Binding SamplingTime,StringFormat=yyyy-MM-dd HH:mm:ss}" Foreground="White"/>
|
||||
<DataGridTextColumn Header="颗粒物序号" Width="80" Binding="{Binding ParticleNumber}" Foreground="White"/>
|
||||
<DataGridTextColumn Header="坐标X" Width="120" Binding="{Binding CoordinateX}" Foreground="White"/>
|
||||
<DataGridTextColumn Header="坐标Y" Width="120" Binding="{Binding CoordinateY}" Foreground="White"/>
|
||||
<DataGridTextColumn Header="类型" Width="150" Binding="{Binding Type}" Foreground="White"/>
|
||||
<DataGridTextColumn Header="面积" Width="105" Binding="{Binding Area}" Foreground="White"/>
|
||||
<DataGridTextColumn Header="长" Width="105" Binding="{Binding Long}" Foreground="White"/>
|
||||
<DataGridTextColumn Header="宽" Width="105" Binding="{Binding Wide}" Foreground="White"/>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
</ScrollViewer>
|
||||
|
||||
<zxc:Pagination DataContext="{Binding PaginationModel}" Grid.Row="2" HorizontalAlignment="Center"/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</GroupBox>
|
||||
</Grid>
|
||||
<!--状态数据折线图-->
|
||||
<Grid Grid.Column="1">
|
||||
<GroupBox Header="实时数据跟踪 -面积/长/宽 " Margin="12,3,12,18">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!--面积-->
|
||||
<Grid >
|
||||
<lvc:CartesianChart Margin="20,35,20,5" DataContext="{Binding ParticleModel.AreaCharts}" DisableAnimations="True">
|
||||
<lvc:CartesianChart.Series>
|
||||
<lvc:LineSeries Values="{Binding Values }" Title="{Binding Value_Name}" PointGeometrySize="0" Stroke="#FF2BEDF1" StrokeThickness="1">
|
||||
<lvc:LineSeries.Fill>
|
||||
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
|
||||
<GradientStop Color="#552BEDF1" Offset="0"/>
|
||||
<GradientStop Color="Transparent" Offset="1"/>
|
||||
</LinearGradientBrush>
|
||||
</lvc:LineSeries.Fill>
|
||||
</lvc:LineSeries>
|
||||
</lvc:CartesianChart.Series>
|
||||
<!--X轴-->
|
||||
<lvc:CartesianChart.AxisX>
|
||||
<lvc:Axis Labels="{Binding X_Time}">
|
||||
<lvc:Axis.Separator>
|
||||
<lvc:Separator Step="1" StrokeThickness="0"/>
|
||||
</lvc:Axis.Separator>
|
||||
</lvc:Axis>
|
||||
</lvc:CartesianChart.AxisX>
|
||||
<!--Y轴-->
|
||||
<lvc:CartesianChart.AxisY>
|
||||
<lvc:Axis MinValue="{Binding Y_MinValue}" MaxValue="{Binding Y_MaxValue}">
|
||||
<lvc:Axis.Separator>
|
||||
<lvc:Separator Step="{Binding Step}" Stroke="#11FFFFFF"/>
|
||||
</lvc:Axis.Separator>
|
||||
</lvc:Axis>
|
||||
</lvc:CartesianChart.AxisY>
|
||||
</lvc:CartesianChart>
|
||||
|
||||
<!--右上角图例 采集时间-->
|
||||
<StackPanel Orientation="Horizontal" VerticalAlignment="Top" HorizontalAlignment="Right" Margin="10">
|
||||
<Border Width="6" Height="6" Background="#552BEDF1" Margin="5,0"/>
|
||||
<TextBlock Text="{Binding ParticleModel.SamplingTime,StringFormat=yyyy/MM/dd HH:mm:ss}" FontSize="11" Foreground="White"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
<!--长-->
|
||||
<Grid Grid.Row="1">
|
||||
<lvc:CartesianChart Margin="20,35,20,5" DataContext="{Binding ParticleModel.LongCharts}" DisableAnimations="True">
|
||||
<lvc:CartesianChart.Series>
|
||||
<lvc:LineSeries Values="{Binding Values }" Title="{Binding Value_Name}" PointGeometrySize="0" Stroke="#FF2BEDF1" StrokeThickness="1">
|
||||
<lvc:LineSeries.Fill>
|
||||
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
|
||||
<GradientStop Color="#552BEDF1" Offset="0"/>
|
||||
<GradientStop Color="Transparent" Offset="1"/>
|
||||
</LinearGradientBrush>
|
||||
</lvc:LineSeries.Fill>
|
||||
</lvc:LineSeries>
|
||||
</lvc:CartesianChart.Series>
|
||||
<!--X轴-->
|
||||
<lvc:CartesianChart.AxisX>
|
||||
<lvc:Axis Labels="{Binding X_Time}">
|
||||
<lvc:Axis.Separator>
|
||||
<lvc:Separator Step="1" StrokeThickness="0"/>
|
||||
</lvc:Axis.Separator>
|
||||
</lvc:Axis>
|
||||
</lvc:CartesianChart.AxisX>
|
||||
<!--Y轴-->
|
||||
<lvc:CartesianChart.AxisY>
|
||||
<lvc:Axis MinValue="{Binding Y_MinValue}" MaxValue="{Binding Y_MaxValue}">
|
||||
<lvc:Axis.Separator>
|
||||
<lvc:Separator Step="{Binding Step}" Stroke="#11FFFFFF"/>
|
||||
</lvc:Axis.Separator>
|
||||
</lvc:Axis>
|
||||
</lvc:CartesianChart.AxisY>
|
||||
</lvc:CartesianChart>
|
||||
</Grid>
|
||||
|
||||
<!--宽-->
|
||||
<Grid Grid.Row="2">
|
||||
<lvc:CartesianChart Margin="20,35,20,5" DataContext="{Binding ParticleModel.WideCharts}" DisableAnimations="True">
|
||||
<lvc:CartesianChart.Series>
|
||||
<lvc:LineSeries Values="{Binding Values }" Title="{Binding Value_Name}" PointGeometrySize="0" Stroke="#FF2BEDF1" StrokeThickness="1">
|
||||
<lvc:LineSeries.Fill>
|
||||
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
|
||||
<GradientStop Color="#552BEDF1" Offset="0"/>
|
||||
<GradientStop Color="Transparent" Offset="1"/>
|
||||
</LinearGradientBrush>
|
||||
</lvc:LineSeries.Fill>
|
||||
</lvc:LineSeries>
|
||||
</lvc:CartesianChart.Series>
|
||||
<!--X轴-->
|
||||
<lvc:CartesianChart.AxisX>
|
||||
<lvc:Axis Labels="{Binding X_Time}">
|
||||
<lvc:Axis.Separator>
|
||||
<lvc:Separator Step="1" StrokeThickness="0"/>
|
||||
</lvc:Axis.Separator>
|
||||
</lvc:Axis>
|
||||
</lvc:CartesianChart.AxisX>
|
||||
<!--Y轴-->
|
||||
<lvc:CartesianChart.AxisY>
|
||||
<lvc:Axis MinValue="{Binding Y_MinValue}" MaxValue="{Binding Y_MaxValue}">
|
||||
<lvc:Axis.Separator>
|
||||
<lvc:Separator Step="{Binding Step}" Stroke="#11FFFFFF"/>
|
||||
</lvc:Axis.Separator>
|
||||
</lvc:Axis>
|
||||
</lvc:CartesianChart.AxisY>
|
||||
</lvc:CartesianChart>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</GroupBox>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
||||
@ -24,5 +24,31 @@ namespace InSituLaboratory.Views.Pages.Sensor
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 支持鼠标滚轮上下滚动
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ScrollViewer_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
|
||||
{
|
||||
ScrollViewer viewer = sv; //sv 为Scrollview的名字,在Xaml文件中定义。
|
||||
if (viewer == null) return;
|
||||
double num = Math.Abs((int)(e.Delta / 2));
|
||||
double offset = 0.0;
|
||||
if (e.Delta > 0)
|
||||
{
|
||||
offset = Math.Max((double)0.0, (double)(viewer.VerticalOffset - num));//viewer.VerticalOffset获取包含滚动内容的垂直偏移量的值。
|
||||
}
|
||||
else
|
||||
{
|
||||
offset = Math.Min(viewer.ScrollableHeight, viewer.VerticalOffset + num);
|
||||
}
|
||||
if (offset != viewer.VerticalOffset)
|
||||
{
|
||||
viewer.ScrollToVerticalOffset(offset);//将 ScrollViewer 内的内容滚动到指定的垂直偏移量位置。
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user