387 lines
12 KiB
C#
387 lines
12 KiB
C#
|
|
using JiangsuEarthquake.Common;
|
|||
|
|
using JiangsuEarthquake.DataAccess;
|
|||
|
|
using JiangsuEarthquake.Models;
|
|||
|
|
using JiangsuEarthquake.Views;
|
|||
|
|
using JiangsuEarthquake.Views.UserControls;
|
|||
|
|
using LiveCharts;
|
|||
|
|
using MySql.Data.MySqlClient;
|
|||
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Linq;
|
|||
|
|
using System.Text;
|
|||
|
|
using System.Threading;
|
|||
|
|
using System.Threading.Tasks;
|
|||
|
|
using System.Windows.Media;
|
|||
|
|
using static Org.BouncyCastle.Crypto.Engines.SM2Engine;
|
|||
|
|
|
|||
|
|
namespace JiangsuEarthquake.ViewModels
|
|||
|
|
{
|
|||
|
|
public class RealTimeDataViewModel : NotifyBase
|
|||
|
|
{
|
|||
|
|
public BaseStationStatusModel baseStationStatusModel { get; set; } = new BaseStationStatusModel();
|
|||
|
|
|
|||
|
|
public BaseStationModel baseStationModel { get; set; } = new BaseStationModel();
|
|||
|
|
|
|||
|
|
public BoosterStationStateDataModel boosterStationStateModel { get; set; } = new BoosterStationStateDataModel();
|
|||
|
|
|
|||
|
|
private BaseStationGestureModel baseStationGesture = new BaseStationGestureModel();
|
|||
|
|
|
|||
|
|
public BaseStationGestureModel BaseStationGesture
|
|||
|
|
{
|
|||
|
|
get { return baseStationGesture; }
|
|||
|
|
set { baseStationGesture = value; this.DoNotify(); DoFresh(); }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#region SeriesCollection
|
|||
|
|
public SeriesCollection seriesCollectionConboxTem;
|
|||
|
|
|
|||
|
|
public SeriesCollection SeriesCollectionConboxTem
|
|||
|
|
{
|
|||
|
|
get { return seriesCollectionConboxTem; }
|
|||
|
|
set
|
|||
|
|
{
|
|||
|
|
seriesCollectionConboxTem = value;
|
|||
|
|
this.DoNotify();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public SeriesCollection seriesCollectionConboxHum;
|
|||
|
|
|
|||
|
|
public SeriesCollection SeriesCollectionConboxHum
|
|||
|
|
{
|
|||
|
|
get { return seriesCollectionConboxHum; }
|
|||
|
|
set
|
|||
|
|
{
|
|||
|
|
seriesCollectionConboxHum = value;
|
|||
|
|
this.DoNotify();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public SeriesCollection seriesCollectionConboxVol;
|
|||
|
|
|
|||
|
|
public SeriesCollection SeriesCollectionConboxVol
|
|||
|
|
{
|
|||
|
|
get { return seriesCollectionConboxVol; }
|
|||
|
|
set
|
|||
|
|
{
|
|||
|
|
seriesCollectionConboxVol = value;
|
|||
|
|
this.DoNotify();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public SeriesCollection seriesCollectionConboxCur;
|
|||
|
|
|
|||
|
|
public SeriesCollection SeriesCollectionConboxCur
|
|||
|
|
{
|
|||
|
|
get { return seriesCollectionConboxCur; }
|
|||
|
|
set
|
|||
|
|
{
|
|||
|
|
seriesCollectionConboxCur = value;
|
|||
|
|
this.DoNotify();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public SeriesCollection seriesCollectionBoosterStationVol;
|
|||
|
|
|
|||
|
|
public SeriesCollection SeriesCollectionBoosterStationVol
|
|||
|
|
{
|
|||
|
|
get { return seriesCollectionBoosterStationVol; }
|
|||
|
|
set
|
|||
|
|
{
|
|||
|
|
seriesCollectionBoosterStationVol = value;
|
|||
|
|
this.DoNotify();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public SeriesCollection seriesCollectionBoosterStationCur;
|
|||
|
|
|
|||
|
|
public SeriesCollection SeriesCollectionBoosterStationCur
|
|||
|
|
{
|
|||
|
|
get { return seriesCollectionBoosterStationCur; }
|
|||
|
|
set
|
|||
|
|
{
|
|||
|
|
seriesCollectionBoosterStationCur = value;
|
|||
|
|
this.DoNotify();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
|
|||
|
|
#region Formatter
|
|||
|
|
private Func<double, string> _xFormatter;
|
|||
|
|
|
|||
|
|
public Func<double, string> XFormatter
|
|||
|
|
{
|
|||
|
|
get { return _xFormatter; }
|
|||
|
|
set
|
|||
|
|
{
|
|||
|
|
_xFormatter = value;
|
|||
|
|
this.DoNotify();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private Func<double, string> _yFormatterVol;
|
|||
|
|
|
|||
|
|
public Func<double, string> YFormatterVol
|
|||
|
|
{
|
|||
|
|
get { return _yFormatterVol; }
|
|||
|
|
set
|
|||
|
|
{
|
|||
|
|
_yFormatterVol = value;
|
|||
|
|
this.DoNotify();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private Func<double, string> _yFormatterCur;
|
|||
|
|
|
|||
|
|
public Func<double, string> YFormatterCur
|
|||
|
|
{
|
|||
|
|
get { return _yFormatterCur; }
|
|||
|
|
set
|
|||
|
|
{
|
|||
|
|
_yFormatterCur = value;
|
|||
|
|
this.DoNotify();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private Func<double, string> _yFormatterTem;
|
|||
|
|
|
|||
|
|
public Func<double, string> YFormatterTem
|
|||
|
|
{
|
|||
|
|
get { return _yFormatterTem; }
|
|||
|
|
set
|
|||
|
|
{
|
|||
|
|
_yFormatterTem = value;
|
|||
|
|
this.DoNotify();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private Func<double, string> _yFormatterHum;
|
|||
|
|
|
|||
|
|
public Func<double, string> YFormatterHum
|
|||
|
|
{
|
|||
|
|
get { return _yFormatterHum; }
|
|||
|
|
set
|
|||
|
|
{
|
|||
|
|
_yFormatterHum = value;
|
|||
|
|
this.DoNotify();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
|
|||
|
|
#region RecordTime
|
|||
|
|
public DateTime dataTimeConboxTem;
|
|||
|
|
|
|||
|
|
public DateTime DataTimeConboxTem
|
|||
|
|
{
|
|||
|
|
get { return dataTimeConboxTem; }
|
|||
|
|
set
|
|||
|
|
{
|
|||
|
|
dataTimeConboxTem = value;
|
|||
|
|
this.DoNotify();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public DateTime dataTimeConboxHum;
|
|||
|
|
|
|||
|
|
public DateTime DataTimeConboxHum
|
|||
|
|
{
|
|||
|
|
get { return dataTimeConboxHum; }
|
|||
|
|
set
|
|||
|
|
{
|
|||
|
|
dataTimeConboxHum = value;
|
|||
|
|
this.DoNotify();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public DateTime dataTimeConboxVol;
|
|||
|
|
|
|||
|
|
public DateTime DataTimeConboxVol
|
|||
|
|
{
|
|||
|
|
get { return dataTimeConboxVol; }
|
|||
|
|
set
|
|||
|
|
{
|
|||
|
|
dataTimeConboxVol = value;
|
|||
|
|
this.DoNotify();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public DateTime dataTimeConboxCur;
|
|||
|
|
|
|||
|
|
public DateTime DataTimeConboxCur
|
|||
|
|
{
|
|||
|
|
get { return dataTimeConboxCur; }
|
|||
|
|
set
|
|||
|
|
{
|
|||
|
|
dataTimeConboxCur = value;
|
|||
|
|
this.DoNotify();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public DateTime dataTimeBoosterStationVol;
|
|||
|
|
|
|||
|
|
public DateTime DataTimeBoosterStationVol
|
|||
|
|
{
|
|||
|
|
get { return dataTimeBoosterStationVol; }
|
|||
|
|
set
|
|||
|
|
{
|
|||
|
|
dataTimeBoosterStationVol = value;
|
|||
|
|
this.DoNotify();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public DateTime dataTimeBoosterStationCur;
|
|||
|
|
|
|||
|
|
public DateTime DataTimeBoosterStationCur
|
|||
|
|
{
|
|||
|
|
get { return dataTimeBoosterStationCur; }
|
|||
|
|
set
|
|||
|
|
{
|
|||
|
|
dataTimeBoosterStationCur = value;
|
|||
|
|
this.DoNotify();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
|
|||
|
|
#region AngleBackground
|
|||
|
|
public Brush angleBackgroundX;
|
|||
|
|
|
|||
|
|
public Brush AngleBackgroundX
|
|||
|
|
{
|
|||
|
|
get { return angleBackgroundX; }
|
|||
|
|
set
|
|||
|
|
{
|
|||
|
|
angleBackgroundX = value;
|
|||
|
|
this.DoNotify();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public Brush angleBackgroundY;
|
|||
|
|
|
|||
|
|
public Brush AngleBackgroundY
|
|||
|
|
{
|
|||
|
|
get { return angleBackgroundY; }
|
|||
|
|
set
|
|||
|
|
{
|
|||
|
|
angleBackgroundY = value;
|
|||
|
|
this.DoNotify();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public Brush angleBackgroundZ;
|
|||
|
|
|
|||
|
|
public Brush AngleBackgroundZ
|
|||
|
|
{
|
|||
|
|
get { return angleBackgroundZ; }
|
|||
|
|
set
|
|||
|
|
{
|
|||
|
|
angleBackgroundZ = value;
|
|||
|
|
this.DoNotify();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
|
|||
|
|
private ImageSource leakageImage;
|
|||
|
|
|
|||
|
|
public ImageSource LeakageImage
|
|||
|
|
{
|
|||
|
|
get { return leakageImage; }
|
|||
|
|
set { leakageImage = value; }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 环境状态列表数据1
|
|||
|
|
/// </summary>
|
|||
|
|
private List<KeypaiValueModel> _baseStationStatus = new List<KeypaiValueModel>
|
|||
|
|
{
|
|||
|
|
new KeypaiValueModel { Header = "基站输入电压(V)" },
|
|||
|
|
new KeypaiValueModel { Header = "基站温度(℃)" },
|
|||
|
|
new KeypaiValueModel { Header = "升压站输入电压(V)" },
|
|||
|
|
new KeypaiValueModel { Header = "基站输入电流(A)" },
|
|||
|
|
new KeypaiValueModel { Header = "基站湿度(%)" },
|
|||
|
|
new KeypaiValueModel { Header = "升压站输入电流(A)" },
|
|||
|
|
//new KeypaiValueModel { Header = "基站姿态X轴(°)" },
|
|||
|
|
//new KeypaiValueModel { Header = "基站姿态Y轴(°)" },
|
|||
|
|
//new KeypaiValueModel { Header = "基站姿态Z轴(°)" },
|
|||
|
|
//new KeypaiValueModel { Header = "基站漏水状态" },
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
public List<KeypaiValueModel> BaseStationStatus
|
|||
|
|
{
|
|||
|
|
get { return _baseStationStatus; }
|
|||
|
|
set { _baseStationStatus = value; this.DoNotify(); }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 告警信息
|
|||
|
|
/// </summary>
|
|||
|
|
private List<AlarmRecordModel> alarmList = new List<AlarmRecordModel>();
|
|||
|
|
|
|||
|
|
public List<AlarmRecordModel> AlarmList
|
|||
|
|
{
|
|||
|
|
get { return alarmList; }
|
|||
|
|
set { alarmList = value; this.DoNotify(); }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public CommandBase ResetAngleCommand { get; set; }
|
|||
|
|
|
|||
|
|
int station_id = 1;
|
|||
|
|
|
|||
|
|
public RealTimeDataView realTimeDataView = new RealTimeDataView();
|
|||
|
|
|
|||
|
|
public BaseStationModelViewModel baseStationModelViewModel { get; set; } = new BaseStationModelViewModel();
|
|||
|
|
|
|||
|
|
public RealTimeDataViewModel(int id)
|
|||
|
|
{
|
|||
|
|
DoFresh();
|
|||
|
|
|
|||
|
|
station_id = id;
|
|||
|
|
|
|||
|
|
this.ResetAngleCommand = new CommandBase();
|
|||
|
|
this.ResetAngleCommand.DoExcute = new Action<object>(ResetAngle);
|
|||
|
|
this.ResetAngleCommand.DoCanExcute = new Func<object, bool>((o) => true);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void ResetAngle(object o)
|
|||
|
|
{
|
|||
|
|
string sql = String.Format("select * from conboxenvpara where StationID = {0} ORDER by id desc limit 1", station_id);
|
|||
|
|
MySqlDataReader dataReader = DBHelper.ExecuteReader(sql, 1);
|
|||
|
|
while (dataReader.Read())
|
|||
|
|
{
|
|||
|
|
BaseStationGesture.RollAngle = Convert.ToSingle(string.IsNullOrEmpty(dataReader["JBH_Attitude_x"].ToString()) ? "0.00" : dataReader["JBH_Attitude_x"].ToString());
|
|||
|
|
BaseStationGesture.PitchAngle = Convert.ToSingle(string.IsNullOrEmpty(dataReader["JBH_Attitude_y"].ToString()) ? "0.00" : dataReader["JBH_Attitude_y"].ToString());
|
|||
|
|
BaseStationGesture.HeadingAngle = Convert.ToSingle(string.IsNullOrEmpty(dataReader["JBH_Attitude_z"].ToString()) ? "0.00" : dataReader["JBH_Attitude_z"].ToString());
|
|||
|
|
}
|
|||
|
|
dataReader.Dispose();
|
|||
|
|
|
|||
|
|
baseStationModelViewModel.BaseStationGesture.RollAngle = BaseStationGesture.RollAngle;
|
|||
|
|
baseStationModelViewModel.BaseStationGesture.PitchAngle = BaseStationGesture.PitchAngle;
|
|||
|
|
baseStationModelViewModel.BaseStationGesture.HeadingAngle = BaseStationGesture.HeadingAngle;
|
|||
|
|
|
|||
|
|
baseStationModel.angleX.Content = BaseStationGesture.RollAngle;
|
|||
|
|
baseStationModel.angleY.Content = BaseStationGesture.PitchAngle;
|
|||
|
|
baseStationModel.angleZ.Content = BaseStationGesture.HeadingAngle;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
//数据刷新
|
|||
|
|
private void DoFresh()
|
|||
|
|
{
|
|||
|
|
BaseStationStatus[0].Value = baseStationStatusModel.In_Vol.ToString("0.00");
|
|||
|
|
BaseStationStatus[1].Value = baseStationStatusModel.JBH_Tem.ToString("0.00");
|
|||
|
|
BaseStationStatus[2].Value = boosterStationStateModel.In_Vol.ToString("0.00");
|
|||
|
|
BaseStationStatus[3].Value = baseStationStatusModel.In_Cur.ToString("0.00");
|
|||
|
|
BaseStationStatus[4].Value = baseStationStatusModel.JBH_Hum.ToString("0.00");
|
|||
|
|
BaseStationStatus[5].Value = boosterStationStateModel.In_Cur.ToString("0.00");
|
|||
|
|
//BaseStationStatus[4].Value = baseStationStatusModel.JBH_Attitude_x.ToString("0.00");
|
|||
|
|
//BaseStationStatus[5].Value = baseStationStatusModel.JBH_Attitude_y.ToString("0.00");
|
|||
|
|
//BaseStationStatus[6].Value = baseStationStatusModel.JBH_Attitude_z.ToString("0.00");
|
|||
|
|
//BaseStationStatus[4].Value = Convert.ToBoolean(baseStationStatusModel.JBH_Leak) ? "是" : "否";
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|