20240815_FJEQ_upperpc_seabed/FujianEarthquake_seabed_UI/FujianEarthquake/ViewModels/RealTimeDataViewModel.cs
XuMin bcc3d4a66b 1 将岸基通信由网口改为串口;
2 初步完成与岸基电源的测试;
2024-11-01 16:05:11 +08:00

492 lines
14 KiB
C#

using FujianEarthquake.Common;
using FujianEarthquake.Models;
using FujianEarthquake.DataAccess;
using FujianEarthquake.Models.HelpModels;
using FujianEarthquake.Views;
using HandyControl.Tools;
using LiveCharts;
using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
using FujianEarthquake.Views.UserControls;
namespace FujianEarthquake.ViewModels
{
public class RealTimeDataViewModel : NotifyBase
{
#region State Define
private string mainSeisVol;
public string MainSeisVol
{
get { return mainSeisVol; }
set { mainSeisVol = value; this.DoNotify(); }
}
private string mainSeisCur;
public string MainSeisCur
{
get { return mainSeisCur; }
set { mainSeisCur = value; this.DoNotify(); }
}
private string backupSeisVol;
public string BackupSeisVol
{
get { return backupSeisVol; }
set { backupSeisVol = value; this.DoNotify(); }
}
private string backupSeisCur;
public string BackupSeisCur
{
get { return backupSeisCur; }
set { backupSeisCur = value; this.DoNotify(); }
}
private string backupSeisAttitudeX;
public string BackupSeisAttitudeX
{
get { return backupSeisAttitudeX; }
set { backupSeisAttitudeX = value; this.DoNotify(); }
}
private string backupSeisAttitudeY;
public string BackupSeisAttitudeY
{
get { return backupSeisAttitudeY; }
set { backupSeisAttitudeY = value; this.DoNotify(); }
}
private string backupSeisAttitudeZ;
public string BackupSeisAttitudeZ
{
get { return backupSeisAttitudeZ; }
set { backupSeisAttitudeZ = value; this.DoNotify(); }
}
private string shoreBaseStationVol;
public string ShoreBaseStationVol
{
get { return shoreBaseStationVol; }
set { shoreBaseStationVol = value; this.DoNotify(); }
}
private string shoreBaseStationCur;
public string ShoreBaseStationCur
{
get { return shoreBaseStationCur; }
set { shoreBaseStationCur = value; this.DoNotify(); }
}
private string juncBoxTem;
public string JuncBoxTem
{
get { return juncBoxTem; }
set { juncBoxTem = value; this.DoNotify(); }
}
private string juncBoxHum;
public string JuncBoxHum
{
get { return juncBoxHum; }
set { juncBoxHum = value; this.DoNotify(); }
}
private string juncBoxLeakage;
public string JuncBoxLeakage
{
get { return juncBoxLeakage; }
set { juncBoxLeakage = value; this.DoNotify(); }
}
private Brush juncBoxLeakageForeground;
public Brush JuncBoxLeakageForeground
{
get { return juncBoxLeakageForeground; }
set { juncBoxLeakageForeground = value; this.DoNotify(); }
}
private ImageSource juncBoxLeakageImage;
public ImageSource JuncBoxLeakageImage
{
get { return juncBoxLeakageImage; }
set { juncBoxLeakageImage = value; this.DoNotify(); }
}
#endregion
public JunctionBoxModelView junctionBoxModelView { get; set; } = new JunctionBoxModelView();
private JunctionBoxGestureModel junctionBoxGesture = new JunctionBoxGestureModel();
public JunctionBoxGestureModel JunctionBoxGesture
{
get { return junctionBoxGesture; }
set
{
junctionBoxGesture = value;
this.DoNotify();
//DoFresh();
}
}
#region SeriesCollection
public SeriesCollection seriesCollectionJuncboxTem;
public SeriesCollection SeriesCollectionJuncboxTem
{
get { return seriesCollectionJuncboxTem; }
set
{
seriesCollectionJuncboxTem = value;
this.DoNotify();
}
}
public SeriesCollection seriesCollectionJuncboxHum;
public SeriesCollection SeriesCollectionJuncboxHum
{
get { return seriesCollectionJuncboxHum; }
set
{
seriesCollectionJuncboxHum = value;
this.DoNotify();
}
}
public SeriesCollection seriesCollectionMainSeis;
public SeriesCollection SeriesCollectionMainSeis
{
get { return seriesCollectionMainSeis; }
set
{
seriesCollectionMainSeis = value;
this.DoNotify();
}
}
public SeriesCollection seriesCollectionBackupSeis;
public SeriesCollection SeriesCollectionBackupSeis
{
get { return seriesCollectionBackupSeis; }
set
{
seriesCollectionBackupSeis = value;
this.DoNotify();
}
}
public SeriesCollection seriesCollectionShoreBaseStationVol;
public SeriesCollection SeriesCollectionShoreBaseStationVol
{
get { return seriesCollectionShoreBaseStationVol; }
set
{
seriesCollectionShoreBaseStationVol = value;
this.DoNotify();
}
}
public SeriesCollection seriesCollectionShoreBaseStationCur;
public SeriesCollection SeriesCollectionShoreBaseStationCur
{
get { return seriesCollectionShoreBaseStationCur; }
set
{
seriesCollectionShoreBaseStationCur = 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 dataTimeJuncboxTem;
public DateTime DataTimeJuncboxTem
{
get { return dataTimeJuncboxTem; }
set
{
dataTimeJuncboxTem = value;
this.DoNotify();
}
}
public DateTime dataTimeJuncboxHum;
public DateTime DataTimeJuncboxHum
{
get { return dataTimeJuncboxHum; }
set
{
dataTimeJuncboxHum = value;
this.DoNotify();
}
}
public DateTime dataTimeMainSeis;
public DateTime DataTimeMainSeis
{
get { return dataTimeMainSeis; }
set
{
dataTimeMainSeis = value;
this.DoNotify();
}
}
public DateTime dataTimeBackupSeis;
public DateTime DataTimeBackupSeis
{
get { return dataTimeBackupSeis; }
set
{
dataTimeBackupSeis = value;
this.DoNotify();
}
}
public DateTime dataTimeShoreBaseStationVol;
public DateTime DataTimeShoreBaseStationVol
{
get { return dataTimeShoreBaseStationVol; }
set
{
dataTimeShoreBaseStationVol = value;
this.DoNotify();
}
}
public DateTime dataTimeShoreBaseStationCur;
public DateTime DataTimeShoreBaseStationCur
{
get { return dataTimeShoreBaseStationCur; }
set
{
dataTimeShoreBaseStationCur = 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>
///// 环境状态列表数据
///// </summary>
//private List<KeypaiValueModel> _junctionBoxStatus = new List<KeypaiValueModel>
//{
// new KeypaiValueModel { Header = "主地震仪电压(V) / 电流(A)" },
// new KeypaiValueModel { Header = "海底基站温度(℃)" },
// new KeypaiValueModel { Header = "岸基站输出电压(V)" },
// new KeypaiValueModel { Header = "备地震仪电压(V) / 电流(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> JunctionBoxStatus
//{
// get { return _junctionBoxStatus; }
// set { _junctionBoxStatus = 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 JunctionBoxModelViewModel junctionBoxModelViewModel { get; set; } = new JunctionBoxModelViewModel();
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 underjuncbox_env where StationID = {0} ORDER by id desc limit 1", station_id);
MySqlDataReader dataReader = DBHelper.ExecuteReader(sql, 1);
while (dataReader.Read())
{
JunctionBoxGesture.RollAngle = Convert.ToSingle(string.IsNullOrEmpty(dataReader["AttitudeX"].ToString()) ? "0.00" : dataReader["AttitudeX"].ToString());
JunctionBoxGesture.PitchAngle = Convert.ToSingle(string.IsNullOrEmpty(dataReader["AttitudeY"].ToString()) ? "0.00" : dataReader["AttitudeY"].ToString());
JunctionBoxGesture.HeadingAngle = Convert.ToSingle(string.IsNullOrEmpty(dataReader["AttitudeZ"].ToString()) ? "0.00" : dataReader["AttitudeZ"].ToString());
}
dataReader.Dispose();
junctionBoxModelViewModel.JunctionBoxGesture.RollAngle = JunctionBoxGesture.RollAngle;
junctionBoxModelViewModel.JunctionBoxGesture.PitchAngle = JunctionBoxGesture.PitchAngle;
junctionBoxModelViewModel.JunctionBoxGesture.HeadingAngle = JunctionBoxGesture.HeadingAngle;
junctionBoxModelView.angleX.Content = JunctionBoxGesture.RollAngle;
junctionBoxModelView.angleY.Content = JunctionBoxGesture.PitchAngle;
junctionBoxModelView.angleZ.Content = JunctionBoxGesture.HeadingAngle;
}
}
}