1613 lines
85 KiB
C#
1613 lines
85 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Media;
|
|
using System.Windows;
|
|
using FujianEarthquake.Common;
|
|
using FujianEarthquake.DataAccess;
|
|
using FujianEarthquake.Models;
|
|
using MySql.Data.MySqlClient;
|
|
using LiveCharts.Defaults;
|
|
using LiveCharts.Wpf;
|
|
using LiveCharts;
|
|
using FujianEarthquake.Models.CommModels;
|
|
using FujianEarthquake.Views.UserControls;
|
|
using FujianEarthquake.Views;
|
|
|
|
namespace FujianEarthquake.ViewModels
|
|
{
|
|
public class MainViewModel : NotifyBase
|
|
{
|
|
|
|
#region ViewModel Define
|
|
public static RealTimeDataViewModel realTimeDataViewModel1 = new RealTimeDataViewModel(1);
|
|
public static RealTimeDataViewModel realTimeDataViewModel2 = new RealTimeDataViewModel(2);
|
|
public static RealTimeDataViewModel realTimeDataViewModel3 = new RealTimeDataViewModel(3);
|
|
public static AlarmRecordViewModel alarmRecordViewModel1 = new AlarmRecordViewModel(1);
|
|
public static AlarmRecordViewModel alarmRecordViewModel2 = new AlarmRecordViewModel(2);
|
|
public static AlarmRecordViewModel alarmRecordViewModel3 = new AlarmRecordViewModel(3);
|
|
public static LogRecordViewModel logRecordViewModel1 = new LogRecordViewModel(1);
|
|
public static LogRecordViewModel logRecordViewModel2 = new LogRecordViewModel(2);
|
|
public static LogRecordViewModel logRecordViewModel3 = new LogRecordViewModel(3);
|
|
public static JunctionBoxEnvironDataViewModel junctionBoxEnvironDataViewModel1 = new JunctionBoxEnvironDataViewModel(1);
|
|
public static JunctionBoxEnvironDataViewModel junctionBoxEnvironDataViewModel2 = new JunctionBoxEnvironDataViewModel(2);
|
|
public static JunctionBoxEnvironDataViewModel junctionBoxEnvironDataViewModel3 = new JunctionBoxEnvironDataViewModel(3);
|
|
public static JunctionBoxStatusDataViewModel junctionBoxStatusDataViewModel1 = new JunctionBoxStatusDataViewModel(1);
|
|
public static JunctionBoxStatusDataViewModel junctionBoxStatusDataViewModel2 = new JunctionBoxStatusDataViewModel(2);
|
|
public static JunctionBoxStatusDataViewModel junctionBoxStatusDataViewModel3 = new JunctionBoxStatusDataViewModel(3);
|
|
|
|
public static JunctionBoxStatusModel junctionBoxStatusModel1 = new JunctionBoxStatusModel();
|
|
public static JunctionBoxStatusModel junctionBoxStatusModel2 = new JunctionBoxStatusModel();
|
|
public static JunctionBoxStatusModel junctionBoxStatusModel3 = new JunctionBoxStatusModel();
|
|
|
|
private JunctionBoxStatusModel jbsm;
|
|
|
|
public JunctionBoxStatusModel JBSM
|
|
{
|
|
get { return jbsm; }
|
|
set { jbsm = value; this.DoNotify(); }
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
#region Something Define
|
|
public int station_id { get; set; } = 1;
|
|
|
|
//折线图展示的点位数
|
|
int ChartPointNum = 15;
|
|
|
|
string Title_Name = ""; //设置当前显示的标题
|
|
|
|
private FrameworkElement _pageContent;
|
|
|
|
public FrameworkElement PageContent
|
|
{
|
|
get { return _pageContent; }
|
|
set { _pageContent = value; this.DoNotify(); }
|
|
}
|
|
#endregion
|
|
|
|
|
|
#region CommandBase Define
|
|
public CommandBase NavChangedCommand { get; set; }
|
|
|
|
public CommandBase Switch { set; get; }
|
|
#endregion
|
|
|
|
|
|
#region Communication
|
|
//下位机
|
|
public CommandBase Socket1DoOpenCommand { get; set; }
|
|
|
|
public CommandBase Socket2DoOpenCommand { get; set; }
|
|
|
|
public CommandBase Socket3DoOpenCommand { get; set; }
|
|
|
|
public ServerModel serverModel1 { get; set; } = new ServerModel();
|
|
|
|
public ServerModel serverModel2 { get; set; } = new ServerModel();
|
|
|
|
public ServerModel serverModel3 { get; set; } = new ServerModel();
|
|
|
|
public static SocketInfo SocketServerInfo1 { get; set; } = new SocketInfo() //PLC1连接信息
|
|
{
|
|
IP = Tools.GetAppSetting("XWJ_Service_IP1"),
|
|
Port = Convert.ToInt32(Tools.GetAppSetting("XWJ_Service_Port1"))
|
|
};
|
|
|
|
public static SocketInfo SocketServerInfo2 { get; set; } = new SocketInfo() //PLC2连接信息
|
|
{
|
|
IP = Tools.GetAppSetting("XWJ_Service_IP2"),
|
|
Port = Convert.ToInt32(Tools.GetAppSetting("XWJ_Service_Port2"))
|
|
};
|
|
|
|
public static SocketInfo SocketServerInfo3 { get; set; } = new SocketInfo() //PLC3连接信息
|
|
{
|
|
IP = Tools.GetAppSetting("XWJ_Service_IP3"),
|
|
Port = Convert.ToInt32(Tools.GetAppSetting("XWJ_Service_Port3"))
|
|
};
|
|
|
|
|
|
//岸基站
|
|
public CommandBase Socket1DoConnectCommand { get; set; } //客户端连接/断开操作
|
|
|
|
public ClientModel clientModel1 { get; set; } = new ClientModel();
|
|
|
|
public static SocketInfo SocketInfo1 { get; set; } = new SocketInfo() //PLC1连接信息
|
|
{
|
|
IP = Tools.GetAppSetting("SYZ_Client_IP1"),
|
|
Port = Convert.ToInt32(Tools.GetAppSetting("SYZ_Client_Port1"))
|
|
};
|
|
#endregion
|
|
|
|
|
|
public static DialogViewModel vm;
|
|
|
|
public MainViewModel()
|
|
{
|
|
vm = new DialogViewModel
|
|
{
|
|
Content = ""
|
|
};
|
|
|
|
|
|
#region Command Define
|
|
this.NavChangedCommand = new CommandBase();
|
|
this.NavChangedCommand.DoExcute = new Action<object>(DoNavChanged);
|
|
this.NavChangedCommand.DoCanExcute = new Func<object, bool>((o) => true);
|
|
|
|
//this.Switch = new CommandBase();
|
|
//this.Switch.DoExcute = new Action<object>(Btn_Switch);
|
|
//this.Switch.DoCanExcute = new Func<object, bool>((o) => true);
|
|
#endregion
|
|
|
|
|
|
#region 日志页面初始化
|
|
string sql = String.Format("select * from underjuncbox_log_record where StationID = {0} ORDER by id desc limit 100", 1);
|
|
MySqlDataReader dataReader = DBHelper.ExecuteReader(sql, 1);
|
|
int index = 1;
|
|
while (dataReader.Read())
|
|
{
|
|
LogRecordModel logRecord = new LogRecordModel();
|
|
logRecord.Index = index++;
|
|
logRecord.RecordTime = Convert.ToDateTime(dataReader["RecordTime"]);
|
|
logRecord.Device_Name = dataReader["Device_Name"].ToString();
|
|
logRecord.Operation_Type = dataReader["Operation_Type"].ToString();
|
|
logRecord.Record = dataReader["Record"].ToString();
|
|
logRecordViewModel1.TotalLogRecordList.Add(logRecord);
|
|
}
|
|
dataReader.Dispose();
|
|
logRecordViewModel1.RecordCount = index - 1;
|
|
logRecordViewModel1.TotalPage = index <= 10 ? 1 : (int)Math.Ceiling((double)index / 10);
|
|
|
|
for (int i = 0; i < (logRecordViewModel1.RecordCount < 10 ? logRecordViewModel1.RecordCount : 10); i++)
|
|
{
|
|
logRecordViewModel1.LogRecordList.Add(logRecordViewModel1.TotalLogRecordList[i]);
|
|
}
|
|
logRecordViewModel1.LogMsg = string.Format("共计{0}页,当前第{1}页", logRecordViewModel1.TotalPage, 1);
|
|
|
|
sql = String.Format("select * from underjuncbox_log_record where StationID = {0} ORDER by id desc limit 100", 2);
|
|
dataReader = DBHelper.ExecuteReader(sql, 1);
|
|
index = 1;
|
|
while (dataReader.Read())
|
|
{
|
|
LogRecordModel logRecord = new LogRecordModel();
|
|
logRecord.Index = index++;
|
|
logRecord.RecordTime = Convert.ToDateTime(dataReader["RecordTime"]);
|
|
logRecord.Device_Name = dataReader["Device_Name"].ToString();
|
|
logRecord.Operation_Type = dataReader["Operation_Type"].ToString();
|
|
logRecord.Record = dataReader["Record"].ToString();
|
|
logRecordViewModel2.TotalLogRecordList.Add(logRecord);
|
|
}
|
|
dataReader.Dispose();
|
|
logRecordViewModel2.RecordCount = index - 1;
|
|
logRecordViewModel2.TotalPage = index <= 10 ? 1 : (int)Math.Ceiling((double)index / 10);
|
|
for (int i = 0; i < (logRecordViewModel2.RecordCount < 10 ? logRecordViewModel2.RecordCount : 10); i++)
|
|
{
|
|
logRecordViewModel2.LogRecordList.Add(logRecordViewModel2.TotalLogRecordList[i]);
|
|
}
|
|
logRecordViewModel2.LogMsg = string.Format("共计{0}页,当前第{1}页", logRecordViewModel2.TotalPage, 1);
|
|
|
|
sql = String.Format("select * from underjuncbox_log_record where StationID = {0} ORDER by id desc limit 100", 3);
|
|
dataReader = DBHelper.ExecuteReader(sql, 1);
|
|
index = 1;
|
|
while (dataReader.Read())
|
|
{
|
|
LogRecordModel logRecord = new LogRecordModel();
|
|
logRecord.Index = index++;
|
|
logRecord.RecordTime = Convert.ToDateTime(dataReader["RecordTime"]);
|
|
logRecord.Device_Name = dataReader["Device_Name"].ToString();
|
|
logRecord.Operation_Type = dataReader["Operation_Type"].ToString();
|
|
logRecord.Record = dataReader["Record"].ToString();
|
|
logRecordViewModel3.TotalLogRecordList.Add(logRecord);
|
|
}
|
|
dataReader.Dispose();
|
|
logRecordViewModel3.RecordCount = index - 1;
|
|
logRecordViewModel3.TotalPage = index <= 10 ? 1 : (int)Math.Ceiling((double)index / 10);
|
|
for (int i = 0; i < (logRecordViewModel3.RecordCount < 10 ? logRecordViewModel3.RecordCount : 10); i++)
|
|
{
|
|
logRecordViewModel3.LogRecordList.Add(logRecordViewModel3.TotalLogRecordList[i]);
|
|
}
|
|
logRecordViewModel3.LogMsg = string.Format("共计{0}页,当前第{1}页", logRecordViewModel3.TotalPage, 1);
|
|
#endregion
|
|
|
|
|
|
#region 告警页面初始化
|
|
sql = String.Format("select * from underjuncbox_alarm_info where StationID = {0} ORDER by id desc limit 100", 1);
|
|
dataReader = DBHelper.ExecuteReader(sql, 1);
|
|
index = 1;
|
|
while (dataReader.Read())
|
|
{
|
|
AlarmRecordModel alarmRecordModel = new AlarmRecordModel();
|
|
alarmRecordModel.Index = index++;
|
|
alarmRecordModel.RecordTime = Convert.ToDateTime(dataReader["RecordTime"]);
|
|
alarmRecordModel.ParaName = dataReader["ParaName"].ToString();
|
|
alarmRecordModel.ParaNum = Convert.ToInt32(string.IsNullOrEmpty(dataReader["ParaNum"].ToString()) ? 0 : dataReader["ParaNum"]);
|
|
alarmRecordModel.ParaContent = dataReader["ParaContent"].ToString();
|
|
alarmRecordModel.ProcessingMethod = dataReader["ProcessingMethod"].ToString();
|
|
if (dataReader["UrgencyLevel"].ToString() == "1")
|
|
{
|
|
alarmRecordModel.UrgencyLevel = (ImageSource)Application.Current.FindResource("CycleRed");
|
|
}
|
|
else if (dataReader["UrgencyLevel"].ToString() == "2")
|
|
{
|
|
alarmRecordModel.UrgencyLevel = (ImageSource)Application.Current.FindResource("CycleOrange");
|
|
}
|
|
else
|
|
{
|
|
alarmRecordModel.UrgencyLevel = (ImageSource)Application.Current.FindResource("CycleYellow");
|
|
}
|
|
if (dataReader["IsHandled"].ToString() == "0")
|
|
{
|
|
alarmRecordModel.IsHandled = "未处理";
|
|
}
|
|
else if (dataReader["IsHandled"].ToString() == "1")
|
|
{
|
|
alarmRecordModel.IsHandled = "已处理";
|
|
}
|
|
else
|
|
{
|
|
alarmRecordModel.IsHandled = "处理中";
|
|
}
|
|
alarmRecordViewModel1.TotalAlarmRecordList.Add(alarmRecordModel);
|
|
}
|
|
dataReader.Dispose();
|
|
alarmRecordViewModel1.RecordCount = index - 1;
|
|
alarmRecordViewModel1.TotalPage = (index - 1) <= 10 ? 1 : (int)Math.Ceiling((double)(index - 1) / 10);
|
|
for (int i = 0; i < (alarmRecordViewModel1.RecordCount < 10 ? alarmRecordViewModel1.RecordCount : 10); i++)
|
|
{
|
|
alarmRecordViewModel1.AlarmRecordList.Add(alarmRecordViewModel1.TotalAlarmRecordList[i]);
|
|
}
|
|
alarmRecordViewModel1.AlarmMsg = string.Format("共计{0}页,当前第{1}页", alarmRecordViewModel1.TotalPage, 1);
|
|
|
|
sql = String.Format("select * from underjuncbox_alarm_info where StationID = {0} ORDER by id desc limit 100", 2);
|
|
dataReader = DBHelper.ExecuteReader(sql, 1);
|
|
index = 1;
|
|
while (dataReader.Read())
|
|
{
|
|
AlarmRecordModel alarmRecordModel = new AlarmRecordModel();
|
|
alarmRecordModel.Index = index++;
|
|
alarmRecordModel.RecordTime = Convert.ToDateTime(dataReader["RecordTime"]);
|
|
alarmRecordModel.ParaName = dataReader["ParaName"].ToString();
|
|
alarmRecordModel.ParaNum = Convert.ToInt32(string.IsNullOrEmpty(dataReader["ParaNum"].ToString()) ? 0 : dataReader["ParaNum"]);
|
|
alarmRecordModel.ParaContent = dataReader["ParaContent"].ToString();
|
|
alarmRecordModel.ProcessingMethod = dataReader["ProcessingMethod"].ToString();
|
|
if (dataReader["UrgencyLevel"].ToString() == "1")
|
|
{
|
|
alarmRecordModel.UrgencyLevel = (ImageSource)Application.Current.FindResource("CycleRed");
|
|
}
|
|
else if (dataReader["UrgencyLevel"].ToString() == "2")
|
|
{
|
|
alarmRecordModel.UrgencyLevel = (ImageSource)Application.Current.FindResource("CycleOrange");
|
|
}
|
|
else
|
|
{
|
|
alarmRecordModel.UrgencyLevel = (ImageSource)Application.Current.FindResource("CycleYellow");
|
|
}
|
|
if (dataReader["IsHandled"].ToString() == "0")
|
|
{
|
|
alarmRecordModel.IsHandled = "未处理";
|
|
}
|
|
else if (dataReader["IsHandled"].ToString() == "1")
|
|
{
|
|
alarmRecordModel.IsHandled = "已处理";
|
|
}
|
|
else
|
|
{
|
|
alarmRecordModel.IsHandled = "处理中";
|
|
}
|
|
alarmRecordViewModel2.TotalAlarmRecordList.Add(alarmRecordModel);
|
|
}
|
|
dataReader.Dispose();
|
|
alarmRecordViewModel2.RecordCount = index - 1;
|
|
alarmRecordViewModel2.TotalPage = (index - 1) <= 10 ? 1 : (int)Math.Ceiling((double)(index - 1) / 10);
|
|
for (int i = 0; i < (alarmRecordViewModel2.RecordCount < 10 ? alarmRecordViewModel2.RecordCount : 10); i++)
|
|
{
|
|
alarmRecordViewModel2.AlarmRecordList.Add(alarmRecordViewModel2.TotalAlarmRecordList[i]);
|
|
}
|
|
alarmRecordViewModel2.AlarmMsg = string.Format("共计{0}页,当前第{1}页", alarmRecordViewModel2.TotalPage, 1);
|
|
|
|
sql = String.Format("select * from underjuncbox_alarm_info where StationID = {0} ORDER by id desc limit 100", 3);
|
|
dataReader = DBHelper.ExecuteReader(sql, 1);
|
|
index = 1;
|
|
while (dataReader.Read())
|
|
{
|
|
AlarmRecordModel alarmRecordModel = new AlarmRecordModel();
|
|
alarmRecordModel.Index = index++;
|
|
alarmRecordModel.RecordTime = Convert.ToDateTime(dataReader["RecordTime"]);
|
|
alarmRecordModel.ParaName = dataReader["ParaName"].ToString();
|
|
alarmRecordModel.ParaNum = Convert.ToInt32(string.IsNullOrEmpty(dataReader["ParaNum"].ToString()) ? 0 : dataReader["ParaNum"]);
|
|
alarmRecordModel.ParaContent = dataReader["ParaContent"].ToString();
|
|
alarmRecordModel.ProcessingMethod = dataReader["ProcessingMethod"].ToString();
|
|
if (dataReader["UrgencyLevel"].ToString() == "1")
|
|
{
|
|
alarmRecordModel.UrgencyLevel = (ImageSource)Application.Current.FindResource("CycleRed");
|
|
}
|
|
else if (dataReader["UrgencyLevel"].ToString() == "2")
|
|
{
|
|
alarmRecordModel.UrgencyLevel = (ImageSource)Application.Current.FindResource("CycleOrange");
|
|
}
|
|
else
|
|
{
|
|
alarmRecordModel.UrgencyLevel = (ImageSource)Application.Current.FindResource("CycleYellow");
|
|
}
|
|
if (dataReader["IsHandled"].ToString() == "0")
|
|
{
|
|
alarmRecordModel.IsHandled = "未处理";
|
|
}
|
|
else if (dataReader["IsHandled"].ToString() == "1")
|
|
{
|
|
alarmRecordModel.IsHandled = "已处理";
|
|
}
|
|
else
|
|
{
|
|
alarmRecordModel.IsHandled = "处理中";
|
|
}
|
|
alarmRecordViewModel3.TotalAlarmRecordList.Add(alarmRecordModel);
|
|
}
|
|
dataReader.Dispose();
|
|
alarmRecordViewModel3.RecordCount = index - 1;
|
|
alarmRecordViewModel3.TotalPage = (index - 1) <= 10 ? 1 : (int)Math.Ceiling((double)(index - 1) / 10);
|
|
for (int i = 0; i < (alarmRecordViewModel3.RecordCount < 10 ? alarmRecordViewModel3.RecordCount : 10); i++)
|
|
{
|
|
alarmRecordViewModel3.AlarmRecordList.Add(alarmRecordViewModel3.TotalAlarmRecordList[i]);
|
|
}
|
|
alarmRecordViewModel3.AlarmMsg = string.Format("共计{0}页,当前第{1}页", alarmRecordViewModel3.TotalPage, 1);
|
|
#endregion
|
|
|
|
|
|
#region 实时数据显示页面折线图初始化
|
|
var chartValuesJuncboxTem = new ChartValues<DateTimePoint>();
|
|
var chartValuesJuncboxHum = new ChartValues<DateTimePoint>();
|
|
sql = String.Format("select * from underunderjuncbox_env where StationID = {0} ORDER by id desc limit {1}", 1, ChartPointNum);
|
|
dataReader = DBHelper.ExecuteReader(sql, 1);
|
|
while (dataReader.Read())
|
|
{
|
|
if (!Convert.IsDBNull(dataReader["Temperature"]) && !Convert.IsDBNull(dataReader["Humidity"]))
|
|
{
|
|
chartValuesJuncboxTem.Add(new DateTimePoint
|
|
{
|
|
Value = Convert.ToSingle(dataReader["Temperature"]),
|
|
DateTime = Convert.ToDateTime(dataReader["DataTime"]),
|
|
});
|
|
chartValuesJuncboxHum.Add(new DateTimePoint
|
|
{
|
|
Value = Convert.ToSingle(dataReader["Humidity"]),
|
|
DateTime = Convert.ToDateTime(dataReader["DataTime"]),
|
|
});
|
|
}
|
|
}
|
|
dataReader.Dispose();
|
|
realTimeDataViewModel1.SeriesCollectionJuncboxTem = new SeriesCollection
|
|
{
|
|
new LineSeries
|
|
{
|
|
Title = "温度",
|
|
Values = chartValuesJuncboxTem,
|
|
LineSmoothness = 0,
|
|
ScalesYAt = 0,
|
|
Stroke = new SolidColorBrush(Color.FromArgb(255, 43, 237, 241)),
|
|
Fill = new SolidColorBrush(Colors.Transparent)
|
|
},
|
|
};
|
|
realTimeDataViewModel1.SeriesCollectionJuncboxHum = new SeriesCollection
|
|
{
|
|
new LineSeries
|
|
{
|
|
Title = "湿度",
|
|
Values = chartValuesJuncboxHum,
|
|
LineSmoothness = 0,
|
|
ScalesYAt = 0,
|
|
Stroke = new SolidColorBrush(Color.FromArgb(255, 43, 237, 241)),
|
|
Fill = new SolidColorBrush(Colors.Transparent)
|
|
},
|
|
};
|
|
|
|
var chartValuesMainSeisVol = new ChartValues<DateTimePoint>();
|
|
var chartValuesMainSeisCur = new ChartValues<DateTimePoint>();
|
|
sql = String.Format("select RecordTime,Seis1_Voltage,Seis1_Current from underunderjuncbox_monitor where StationID = {0} ORDER by id desc limit {1}", 1, ChartPointNum);
|
|
dataReader = DBHelper.ExecuteReader(sql, 1);
|
|
while (dataReader.Read())
|
|
{
|
|
if (!Convert.IsDBNull(dataReader["Seis1_Voltage"]) && !Convert.IsDBNull(dataReader["Seis1_Current"]))
|
|
{
|
|
chartValuesMainSeisVol.Add(new DateTimePoint
|
|
{
|
|
Value = Convert.ToSingle(dataReader["Seis1_Voltage"]),
|
|
DateTime = Convert.ToDateTime(dataReader["RecordTime"]),
|
|
});
|
|
chartValuesMainSeisCur.Add(new DateTimePoint
|
|
{
|
|
Value = Convert.ToSingle(dataReader["Seis1_Current"]),
|
|
DateTime = Convert.ToDateTime(dataReader["RecordTime"]),
|
|
});
|
|
}
|
|
}
|
|
dataReader.Dispose();
|
|
realTimeDataViewModel1.SeriesCollectionMainSeis = new SeriesCollection
|
|
{
|
|
new LineSeries
|
|
{
|
|
Title = "电压",
|
|
Values = chartValuesMainSeisVol,
|
|
LineSmoothness = 0,
|
|
ScalesYAt = 0,
|
|
Stroke = new SolidColorBrush(Color.FromArgb(255, 43, 237, 241)),
|
|
Fill = new SolidColorBrush(Colors.Transparent)
|
|
},
|
|
new LineSeries
|
|
{
|
|
Title = "电流",
|
|
Values = chartValuesMainSeisCur,
|
|
LineSmoothness = 0,
|
|
ScalesYAt = 1,
|
|
Stroke = new SolidColorBrush(Color.FromArgb(255, 255, 165, 0)),
|
|
Fill = new SolidColorBrush(Colors.Transparent)
|
|
},
|
|
};
|
|
|
|
var chartValuesBackupSeisVol = new ChartValues<DateTimePoint>();
|
|
var chartValuesBackupSeisCur = new ChartValues<DateTimePoint>();
|
|
sql = String.Format("select RecordTime,Seis2_Voltage,Seis2_Current from underunderjuncbox_monitor where StationID = {0} ORDER by id desc limit {1}", 1, ChartPointNum);
|
|
dataReader = DBHelper.ExecuteReader(sql, 1);
|
|
while (dataReader.Read())
|
|
{
|
|
if (!Convert.IsDBNull(dataReader["Seis2_Voltage"]) && !Convert.IsDBNull(dataReader["Seis2_Current"]))
|
|
{
|
|
chartValuesBackupSeisVol.Add(new DateTimePoint
|
|
{
|
|
Value = Convert.ToSingle(dataReader["Seis2_Voltage"]),
|
|
DateTime = Convert.ToDateTime(dataReader["RecordTime"]),
|
|
});
|
|
chartValuesBackupSeisCur.Add(new DateTimePoint
|
|
{
|
|
Value = Convert.ToSingle(dataReader["Seis2_Current"]),
|
|
DateTime = Convert.ToDateTime(dataReader["RecordTime"]),
|
|
});
|
|
}
|
|
}
|
|
dataReader.Dispose();
|
|
realTimeDataViewModel1.SeriesCollectionBackupSeis = new SeriesCollection
|
|
{
|
|
new LineSeries
|
|
{
|
|
Title = "电压",
|
|
Values = chartValuesBackupSeisVol,
|
|
LineSmoothness = 0,
|
|
ScalesYAt = 0,
|
|
Stroke = new SolidColorBrush(Color.FromArgb(255, 43, 237, 241)),
|
|
Fill = new SolidColorBrush(Colors.Transparent)
|
|
},
|
|
new LineSeries
|
|
{
|
|
Title = "电流",
|
|
Values = chartValuesBackupSeisCur,
|
|
LineSmoothness = 0,
|
|
ScalesYAt = 1,
|
|
Stroke = new SolidColorBrush(Color.FromArgb(255, 255, 165, 0)),
|
|
Fill = new SolidColorBrush(Colors.Transparent)
|
|
},
|
|
};
|
|
|
|
var chartValuesBoosterStationVol = new ChartValues<DateTimePoint>();
|
|
var chartValuesBoosterStationCur = new ChartValues<DateTimePoint>();
|
|
sql = String.Format("select * from shorebasestation_output_state ORDER by id desc limit {0}", ChartPointNum);
|
|
dataReader = DBHelper.ExecuteReader(sql, 1);
|
|
while (dataReader.Read())
|
|
{
|
|
if (!Convert.IsDBNull(dataReader["Out_Vol"]) && !Convert.IsDBNull(dataReader["Out_Cur"]))
|
|
{
|
|
chartValuesBoosterStationVol.Add(new DateTimePoint
|
|
{
|
|
Value = Convert.ToSingle(dataReader["Out_Vol"]),
|
|
DateTime = Convert.ToDateTime(dataReader["RecordTime"]),
|
|
});
|
|
chartValuesBoosterStationCur.Add(new DateTimePoint
|
|
{
|
|
Value = Convert.ToSingle(dataReader["Out_Cur"]),
|
|
DateTime = Convert.ToDateTime(dataReader["RecordTime"]),
|
|
});
|
|
}
|
|
}
|
|
dataReader.Dispose();
|
|
realTimeDataViewModel1.SeriesCollectionShoreBaseStationVol = new SeriesCollection
|
|
{
|
|
new LineSeries
|
|
{
|
|
Title = "输出电压",
|
|
Values = chartValuesBoosterStationVol,
|
|
LineSmoothness = 0,
|
|
ScalesYAt = 0,
|
|
Stroke = new SolidColorBrush(Color.FromArgb(255, 43, 237, 241)),
|
|
Fill = new SolidColorBrush(Colors.Transparent)
|
|
},
|
|
};
|
|
realTimeDataViewModel1.SeriesCollectionShoreBaseStationCur = new SeriesCollection
|
|
{
|
|
new LineSeries
|
|
{
|
|
Title = "输出电流",
|
|
Values = chartValuesBoosterStationCur,
|
|
LineSmoothness = 0,
|
|
ScalesYAt = 0,
|
|
Stroke = new SolidColorBrush(Color.FromArgb(255, 43, 237, 241)),
|
|
Fill = new SolidColorBrush(Colors.Transparent)
|
|
},
|
|
};
|
|
|
|
realTimeDataViewModel1.XFormatter = val => new DateTime((long)val).ToString("MM/dd HH:mm:ss");
|
|
realTimeDataViewModel1.YFormatterVol = val => val.ToString("F2") + " V";
|
|
realTimeDataViewModel1.YFormatterCur = val => val.ToString("F2") + " A";
|
|
realTimeDataViewModel1.YFormatterTem = val => val.ToString("F2") + " ℃";
|
|
realTimeDataViewModel1.YFormatterHum = val => val.ToString("F2") + " %";
|
|
|
|
chartValuesJuncboxTem = new ChartValues<DateTimePoint>();
|
|
chartValuesJuncboxHum = new ChartValues<DateTimePoint>();
|
|
sql = String.Format("select * from underunderjuncbox_env where StationID = {0} ORDER by id desc limit {1}", 2, ChartPointNum);
|
|
dataReader = DBHelper.ExecuteReader(sql, 1);
|
|
while (dataReader.Read())
|
|
{
|
|
if (!Convert.IsDBNull(dataReader["Temperature"]) && !Convert.IsDBNull(dataReader["Humidity"]))
|
|
{
|
|
chartValuesJuncboxTem.Add(new DateTimePoint
|
|
{
|
|
Value = Convert.ToSingle(dataReader["Temperature"]),
|
|
DateTime = Convert.ToDateTime(dataReader["DataTime"]),
|
|
});
|
|
chartValuesJuncboxHum.Add(new DateTimePoint
|
|
{
|
|
Value = Convert.ToSingle(dataReader["Humidity"]),
|
|
DateTime = Convert.ToDateTime(dataReader["DataTime"]),
|
|
});
|
|
}
|
|
}
|
|
dataReader.Dispose();
|
|
realTimeDataViewModel2.SeriesCollectionJuncboxTem = new SeriesCollection
|
|
{
|
|
new LineSeries
|
|
{
|
|
Title = "温度",
|
|
Values = chartValuesJuncboxTem,
|
|
LineSmoothness = 0,
|
|
ScalesYAt = 0,
|
|
Stroke = new SolidColorBrush(Color.FromArgb(255, 43, 237, 241)),
|
|
Fill = new SolidColorBrush(Colors.Transparent)
|
|
},
|
|
};
|
|
realTimeDataViewModel2.SeriesCollectionJuncboxHum = new SeriesCollection
|
|
{
|
|
new LineSeries
|
|
{
|
|
Title = "湿度",
|
|
Values = chartValuesJuncboxHum,
|
|
LineSmoothness = 0,
|
|
ScalesYAt = 0,
|
|
Stroke = new SolidColorBrush(Color.FromArgb(255, 43, 237, 241)),
|
|
Fill = new SolidColorBrush(Colors.Transparent)
|
|
},
|
|
};
|
|
|
|
chartValuesMainSeisVol = new ChartValues<DateTimePoint>();
|
|
chartValuesMainSeisCur = new ChartValues<DateTimePoint>();
|
|
sql = String.Format("select RecordTime,Seis1_Voltage,Seis1_Current from underunderjuncbox_monitor where StationID = {0} ORDER by id desc limit {1}", 2, ChartPointNum);
|
|
dataReader = DBHelper.ExecuteReader(sql, 1);
|
|
while (dataReader.Read())
|
|
{
|
|
if (!Convert.IsDBNull(dataReader["Seis1_Voltage"]) && !Convert.IsDBNull(dataReader["Seis1_Current"]))
|
|
{
|
|
chartValuesMainSeisVol.Add(new DateTimePoint
|
|
{
|
|
Value = Convert.ToSingle(dataReader["Seis1_Voltage"]),
|
|
DateTime = Convert.ToDateTime(dataReader["RecordTime"]),
|
|
});
|
|
chartValuesMainSeisCur.Add(new DateTimePoint
|
|
{
|
|
Value = Convert.ToSingle(dataReader["Seis1_Current"]),
|
|
DateTime = Convert.ToDateTime(dataReader["RecordTime"]),
|
|
});
|
|
}
|
|
}
|
|
dataReader.Dispose();
|
|
realTimeDataViewModel2.SeriesCollectionMainSeis = new SeriesCollection
|
|
{
|
|
new LineSeries
|
|
{
|
|
Title = "电压",
|
|
Values = chartValuesMainSeisVol,
|
|
LineSmoothness = 0,
|
|
ScalesYAt = 0,
|
|
Stroke = new SolidColorBrush(Color.FromArgb(255, 43, 237, 241)),
|
|
Fill = new SolidColorBrush(Colors.Transparent)
|
|
},
|
|
new LineSeries
|
|
{
|
|
Title = "电流",
|
|
Values = chartValuesMainSeisCur,
|
|
LineSmoothness = 0,
|
|
ScalesYAt = 1,
|
|
Stroke = new SolidColorBrush(Color.FromArgb(255, 255, 165, 0)),
|
|
Fill = new SolidColorBrush(Colors.Transparent)
|
|
},
|
|
};
|
|
|
|
chartValuesBackupSeisVol = new ChartValues<DateTimePoint>();
|
|
chartValuesBackupSeisCur = new ChartValues<DateTimePoint>();
|
|
sql = String.Format("select RecordTime,Seis2_Voltage,Seis2_Current from underunderjuncbox_monitor where StationID = {0} ORDER by id desc limit {1}", 2, ChartPointNum);
|
|
dataReader = DBHelper.ExecuteReader(sql, 1);
|
|
while (dataReader.Read())
|
|
{
|
|
if (!Convert.IsDBNull(dataReader["Seis2_Voltage"]) && !Convert.IsDBNull(dataReader["Seis2_Current"]))
|
|
{
|
|
chartValuesBackupSeisVol.Add(new DateTimePoint
|
|
{
|
|
Value = Convert.ToSingle(dataReader["Seis2_Voltage"]),
|
|
DateTime = Convert.ToDateTime(dataReader["RecordTime"]),
|
|
});
|
|
chartValuesBackupSeisCur.Add(new DateTimePoint
|
|
{
|
|
Value = Convert.ToSingle(dataReader["Seis2_Current"]),
|
|
DateTime = Convert.ToDateTime(dataReader["RecordTime"]),
|
|
});
|
|
}
|
|
}
|
|
dataReader.Dispose();
|
|
realTimeDataViewModel2.SeriesCollectionBackupSeis = new SeriesCollection
|
|
{
|
|
new LineSeries
|
|
{
|
|
Title = "电压",
|
|
Values = chartValuesBackupSeisVol,
|
|
LineSmoothness = 0,
|
|
ScalesYAt = 0,
|
|
Stroke = new SolidColorBrush(Color.FromArgb(255, 43, 237, 241)),
|
|
Fill = new SolidColorBrush(Colors.Transparent)
|
|
},
|
|
new LineSeries
|
|
{
|
|
Title = "电流",
|
|
Values = chartValuesBackupSeisCur,
|
|
LineSmoothness = 0,
|
|
ScalesYAt = 1,
|
|
Stroke = new SolidColorBrush(Color.FromArgb(255, 255, 165, 0)),
|
|
Fill = new SolidColorBrush(Colors.Transparent)
|
|
},
|
|
};
|
|
|
|
chartValuesBoosterStationVol = new ChartValues<DateTimePoint>();
|
|
chartValuesBoosterStationCur = new ChartValues<DateTimePoint>();
|
|
sql = String.Format("select * from shorebasestation_output_state ORDER by id desc limit {0}", ChartPointNum);
|
|
dataReader = DBHelper.ExecuteReader(sql, 1);
|
|
while (dataReader.Read())
|
|
{
|
|
if (!Convert.IsDBNull(dataReader["Out_Vol"]) && !Convert.IsDBNull(dataReader["Out_Cur"]))
|
|
{
|
|
chartValuesBoosterStationVol.Add(new DateTimePoint
|
|
{
|
|
Value = Convert.ToSingle(dataReader["Out_Vol"]),
|
|
DateTime = Convert.ToDateTime(dataReader["RecordTime"]),
|
|
});
|
|
chartValuesBoosterStationCur.Add(new DateTimePoint
|
|
{
|
|
Value = Convert.ToSingle(dataReader["Out_Cur"]),
|
|
DateTime = Convert.ToDateTime(dataReader["RecordTime"]),
|
|
});
|
|
}
|
|
}
|
|
dataReader.Dispose();
|
|
realTimeDataViewModel2.SeriesCollectionShoreBaseStationVol = new SeriesCollection
|
|
{
|
|
new LineSeries
|
|
{
|
|
Title = "输出电压",
|
|
Values = chartValuesBoosterStationVol,
|
|
LineSmoothness = 0,
|
|
ScalesYAt = 0,
|
|
Stroke = new SolidColorBrush(Color.FromArgb(255, 43, 237, 241)),
|
|
Fill = new SolidColorBrush(Colors.Transparent)
|
|
},
|
|
};
|
|
realTimeDataViewModel2.SeriesCollectionShoreBaseStationCur = new SeriesCollection
|
|
{
|
|
new LineSeries
|
|
{
|
|
Title = "输出电流",
|
|
Values = chartValuesBoosterStationCur,
|
|
LineSmoothness = 0,
|
|
ScalesYAt = 0,
|
|
Stroke = new SolidColorBrush(Color.FromArgb(255, 43, 237, 241)),
|
|
Fill = new SolidColorBrush(Colors.Transparent)
|
|
},
|
|
};
|
|
|
|
realTimeDataViewModel2.XFormatter = val => new DateTime((long)val).ToString("MM/dd HH:mm:ss");
|
|
realTimeDataViewModel2.YFormatterVol = val => val.ToString("F2") + " V";
|
|
realTimeDataViewModel2.YFormatterCur = val => val.ToString("F2") + " A";
|
|
realTimeDataViewModel2.YFormatterTem = val => val.ToString("F2") + " ℃";
|
|
realTimeDataViewModel2.YFormatterHum = val => val.ToString("F2") + " %";
|
|
|
|
chartValuesJuncboxTem = new ChartValues<DateTimePoint>();
|
|
chartValuesJuncboxHum = new ChartValues<DateTimePoint>();
|
|
sql = String.Format("select * from underunderjuncbox_env where StationID = {0} ORDER by id desc limit {1}", 3, ChartPointNum);
|
|
dataReader = DBHelper.ExecuteReader(sql, 1);
|
|
while (dataReader.Read())
|
|
{
|
|
if (!Convert.IsDBNull(dataReader["Temperature"]) && !Convert.IsDBNull(dataReader["Humidity"]))
|
|
{
|
|
chartValuesJuncboxTem.Add(new DateTimePoint
|
|
{
|
|
Value = Convert.ToSingle(dataReader["Temperature"]),
|
|
DateTime = Convert.ToDateTime(dataReader["DataTime"]),
|
|
});
|
|
chartValuesJuncboxHum.Add(new DateTimePoint
|
|
{
|
|
Value = Convert.ToSingle(dataReader["Humidity"]),
|
|
DateTime = Convert.ToDateTime(dataReader["DataTime"]),
|
|
});
|
|
}
|
|
}
|
|
dataReader.Dispose();
|
|
realTimeDataViewModel3.SeriesCollectionJuncboxTem = new SeriesCollection
|
|
{
|
|
new LineSeries
|
|
{
|
|
Title = "温度",
|
|
Values = chartValuesJuncboxTem,
|
|
LineSmoothness = 0,
|
|
ScalesYAt = 0,
|
|
Stroke = new SolidColorBrush(Color.FromArgb(255, 43, 237, 241)),
|
|
Fill = new SolidColorBrush(Colors.Transparent)
|
|
},
|
|
};
|
|
realTimeDataViewModel3.SeriesCollectionJuncboxHum = new SeriesCollection
|
|
{
|
|
new LineSeries
|
|
{
|
|
Title = "湿度",
|
|
Values = chartValuesJuncboxHum,
|
|
LineSmoothness = 0,
|
|
ScalesYAt = 0,
|
|
Stroke = new SolidColorBrush(Color.FromArgb(255, 43, 237, 241)),
|
|
Fill = new SolidColorBrush(Colors.Transparent)
|
|
},
|
|
};
|
|
|
|
chartValuesMainSeisVol = new ChartValues<DateTimePoint>();
|
|
chartValuesMainSeisCur = new ChartValues<DateTimePoint>();
|
|
sql = String.Format("select RecordTime,Seis1_Voltage,Seis1_Current from underunderjuncbox_monitor where StationID = {0} ORDER by id desc limit {1}", 3, ChartPointNum);
|
|
dataReader = DBHelper.ExecuteReader(sql, 1);
|
|
while (dataReader.Read())
|
|
{
|
|
if (!Convert.IsDBNull(dataReader["Seis1_Voltage"]) && !Convert.IsDBNull(dataReader["Seis1_Current"]))
|
|
{
|
|
chartValuesMainSeisVol.Add(new DateTimePoint
|
|
{
|
|
Value = Convert.ToSingle(dataReader["Seis1_Voltage"]),
|
|
DateTime = Convert.ToDateTime(dataReader["RecordTime"]),
|
|
});
|
|
chartValuesMainSeisCur.Add(new DateTimePoint
|
|
{
|
|
Value = Convert.ToSingle(dataReader["Seis1_Current"]),
|
|
DateTime = Convert.ToDateTime(dataReader["RecordTime"]),
|
|
});
|
|
}
|
|
}
|
|
dataReader.Dispose();
|
|
realTimeDataViewModel3.SeriesCollectionMainSeis = new SeriesCollection
|
|
{
|
|
new LineSeries
|
|
{
|
|
Title = "电压",
|
|
Values = chartValuesMainSeisVol,
|
|
LineSmoothness = 0,
|
|
ScalesYAt = 0,
|
|
Stroke = new SolidColorBrush(Color.FromArgb(255, 43, 237, 241)),
|
|
Fill = new SolidColorBrush(Colors.Transparent)
|
|
},
|
|
new LineSeries
|
|
{
|
|
Title = "电流",
|
|
Values = chartValuesMainSeisCur,
|
|
LineSmoothness = 0,
|
|
ScalesYAt = 1,
|
|
Stroke = new SolidColorBrush(Color.FromArgb(255, 255, 165, 0)),
|
|
Fill = new SolidColorBrush(Colors.Transparent)
|
|
},
|
|
};
|
|
|
|
chartValuesBackupSeisVol = new ChartValues<DateTimePoint>();
|
|
chartValuesBackupSeisCur = new ChartValues<DateTimePoint>();
|
|
sql = String.Format("select RecordTime,Seis2_Voltage,Seis2_Current from underunderjuncbox_monitor where StationID = {0} ORDER by id desc limit {1}", 3, ChartPointNum);
|
|
dataReader = DBHelper.ExecuteReader(sql, 1);
|
|
while (dataReader.Read())
|
|
{
|
|
if (!Convert.IsDBNull(dataReader["Seis2_Voltage"]) && !Convert.IsDBNull(dataReader["Seis2_Current"]))
|
|
{
|
|
chartValuesBackupSeisVol.Add(new DateTimePoint
|
|
{
|
|
Value = Convert.ToSingle(dataReader["Seis2_Voltage"]),
|
|
DateTime = Convert.ToDateTime(dataReader["RecordTime"]),
|
|
});
|
|
chartValuesBackupSeisCur.Add(new DateTimePoint
|
|
{
|
|
Value = Convert.ToSingle(dataReader["Seis2_Current"]),
|
|
DateTime = Convert.ToDateTime(dataReader["RecordTime"]),
|
|
});
|
|
}
|
|
}
|
|
dataReader.Dispose();
|
|
realTimeDataViewModel3.SeriesCollectionBackupSeis = new SeriesCollection
|
|
{
|
|
new LineSeries
|
|
{
|
|
Title = "电压",
|
|
Values = chartValuesBackupSeisVol,
|
|
LineSmoothness = 0,
|
|
ScalesYAt = 0,
|
|
Stroke = new SolidColorBrush(Color.FromArgb(255, 43, 237, 241)),
|
|
Fill = new SolidColorBrush(Colors.Transparent)
|
|
},
|
|
new LineSeries
|
|
{
|
|
Title = "电流",
|
|
Values = chartValuesBackupSeisCur,
|
|
LineSmoothness = 0,
|
|
ScalesYAt = 1,
|
|
Stroke = new SolidColorBrush(Color.FromArgb(255, 255, 165, 0)),
|
|
Fill = new SolidColorBrush(Colors.Transparent)
|
|
},
|
|
};
|
|
|
|
chartValuesBoosterStationVol = new ChartValues<DateTimePoint>();
|
|
chartValuesBoosterStationCur = new ChartValues<DateTimePoint>();
|
|
sql = String.Format("select * from shorebasestation_output_state ORDER by id desc limit {0}", ChartPointNum);
|
|
dataReader = DBHelper.ExecuteReader(sql, 1);
|
|
while (dataReader.Read())
|
|
{
|
|
if (!Convert.IsDBNull(dataReader["Out_Vol"]) && !Convert.IsDBNull(dataReader["Out_Cur"]))
|
|
{
|
|
chartValuesBoosterStationVol.Add(new DateTimePoint
|
|
{
|
|
Value = Convert.ToSingle(dataReader["Out_Vol"]),
|
|
DateTime = Convert.ToDateTime(dataReader["RecordTime"]),
|
|
});
|
|
chartValuesBoosterStationCur.Add(new DateTimePoint
|
|
{
|
|
Value = Convert.ToSingle(dataReader["Out_Cur"]),
|
|
DateTime = Convert.ToDateTime(dataReader["RecordTime"]),
|
|
});
|
|
}
|
|
}
|
|
dataReader.Dispose();
|
|
realTimeDataViewModel3.SeriesCollectionShoreBaseStationVol = new SeriesCollection
|
|
{
|
|
new LineSeries
|
|
{
|
|
Title = "输出电压",
|
|
Values = chartValuesBoosterStationVol,
|
|
LineSmoothness = 0,
|
|
ScalesYAt = 0,
|
|
Stroke = new SolidColorBrush(Color.FromArgb(255, 43, 237, 241)),
|
|
Fill = new SolidColorBrush(Colors.Transparent)
|
|
},
|
|
};
|
|
realTimeDataViewModel3.SeriesCollectionShoreBaseStationCur = new SeriesCollection
|
|
{
|
|
new LineSeries
|
|
{
|
|
Title = "输出电流",
|
|
Values = chartValuesBoosterStationCur,
|
|
LineSmoothness = 0,
|
|
ScalesYAt = 0,
|
|
Stroke = new SolidColorBrush(Color.FromArgb(255, 43, 237, 241)),
|
|
Fill = new SolidColorBrush(Colors.Transparent)
|
|
},
|
|
};
|
|
|
|
realTimeDataViewModel3.XFormatter = val => new DateTime((long)val).ToString("MM/dd HH:mm:ss");
|
|
realTimeDataViewModel3.YFormatterVol = val => val.ToString("F2") + " V";
|
|
realTimeDataViewModel3.YFormatterCur = val => val.ToString("F2") + " A";
|
|
realTimeDataViewModel3.YFormatterTem = val => val.ToString("F2") + " ℃";
|
|
realTimeDataViewModel3.YFormatterHum = val => val.ToString("F2") + " %";
|
|
#endregion
|
|
|
|
|
|
#region 实时数据显示页面数据初始化
|
|
sql = String.Format("select * from underjuncbox_env where StationID = {0} ORDER by id desc limit 1", 1);
|
|
dataReader = DBHelper.ExecuteReader(sql, 1);
|
|
string sqlSub = String.Format("select * from underjuncbox_cavity_state where StationID = {0} ORDER by id desc limit 1", 1);
|
|
MySqlDataReader dataReaderSub = DBHelper.ExecuteReader(sqlSub, 1);
|
|
string sqlMon = String.Format("select * from underjuncbox_monitor where StationID = {0} ORDER by id desc limit 1", 1);
|
|
MySqlDataReader dataReaderMon = DBHelper.ExecuteReader(sqlMon, 1);
|
|
if (dataReaderMon.Read())
|
|
{
|
|
string voltage = string.IsNullOrEmpty(dataReaderMon["Seis1_Voltage"].ToString()) ? "0.00" : dataReaderMon["Seis1_Voltage"].ToString();
|
|
string current = string.IsNullOrEmpty(dataReaderMon["Seis1_Current"].ToString()) ? "0.00" : dataReaderMon["Seis1_Current"].ToString();
|
|
realTimeDataViewModel1.JunctionBoxStatus[0].Value = voltage + " / " + current;
|
|
|
|
voltage = string.IsNullOrEmpty(dataReaderMon["Seis2_Voltage"].ToString()) ? "0.00" : dataReaderMon["Seis2_Voltage"].ToString();
|
|
current = string.IsNullOrEmpty(dataReaderMon["Seis2_Current"].ToString()) ? "0.00" : dataReaderMon["Seis2_Current"].ToString();
|
|
realTimeDataViewModel1.JunctionBoxStatus[3].Value = voltage + " / " + current;
|
|
|
|
realTimeDataViewModel1.DataTimeMainSeis = Convert.ToDateTime(dataReaderMon["RecordTime"]);
|
|
realTimeDataViewModel1.DataTimeBackupSeis = Convert.ToDateTime(dataReaderMon["RecordTime"]);
|
|
}
|
|
else
|
|
{
|
|
realTimeDataViewModel1.JunctionBoxStatus[0].Value = "0.00 / 0.00";
|
|
realTimeDataViewModel1.JunctionBoxStatus[3].Value = "0.00 / 0.00";
|
|
|
|
realTimeDataViewModel1.DataTimeMainSeis = DateTime.Now;
|
|
realTimeDataViewModel1.DataTimeBackupSeis = DateTime.Now;
|
|
}
|
|
|
|
if (dataReader.Read())
|
|
{
|
|
realTimeDataViewModel1.JunctionBoxStatus[1].Value = string.IsNullOrEmpty(dataReader["Temperature"].ToString()) ? "0.00" : dataReader["Temperature"].ToString();
|
|
realTimeDataViewModel1.JunctionBoxStatus[4].Value = string.IsNullOrEmpty(dataReader["Humidity"].ToString()) ? "0.00" : dataReader["Humidity"].ToString();
|
|
|
|
realTimeDataViewModel1.DataTimeJuncboxTem = Convert.ToDateTime(dataReader["DataTime"]);
|
|
realTimeDataViewModel1.DataTimeJuncboxHum = Convert.ToDateTime(dataReader["DataTime"]);
|
|
}
|
|
else
|
|
{
|
|
realTimeDataViewModel1.JunctionBoxStatus[1].Value = "0.00";
|
|
realTimeDataViewModel1.JunctionBoxStatus[4].Value = "0.00";
|
|
|
|
realTimeDataViewModel1.DataTimeJuncboxTem = DateTime.Now;
|
|
realTimeDataViewModel1.DataTimeJuncboxHum = DateTime.Now;
|
|
}
|
|
|
|
if (dataReaderSub.Read())
|
|
{
|
|
int leakState = Convert.ToInt32(string.IsNullOrEmpty(dataReaderSub["Leakage"].ToString()) ? "2" : dataReaderSub["Leakage"]);
|
|
if (leakState == 1)
|
|
{
|
|
realTimeDataViewModel1.LeakageImage = (ImageSource)Application.Current.FindResource("CycleRed");
|
|
}
|
|
else if (leakState == 0)
|
|
{
|
|
realTimeDataViewModel1.LeakageImage = (ImageSource)Application.Current.FindResource("CycleGreen");
|
|
}
|
|
else
|
|
{
|
|
realTimeDataViewModel1.LeakageImage = (ImageSource)Application.Current.FindResource("CycleGray");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
realTimeDataViewModel1.LeakageImage = (ImageSource)Application.Current.FindResource("CycleGray");
|
|
}
|
|
dataReader.Dispose();
|
|
dataReaderSub.Dispose();
|
|
dataReaderMon.Dispose();
|
|
|
|
sql = String.Format("select * from shorebasestation_output_state ORDER by id desc limit 1");
|
|
dataReader = DBHelper.ExecuteReader(sql, 1);
|
|
if (dataReader.Read())
|
|
{
|
|
realTimeDataViewModel1.JunctionBoxStatus[2].Value = string.IsNullOrEmpty(dataReader["Out_Vol"].ToString()) ? "0.00" : dataReader["Out_Vol"].ToString();
|
|
realTimeDataViewModel1.JunctionBoxStatus[5].Value = string.IsNullOrEmpty(dataReader["Out_Cur"].ToString()) ? "0.00" : dataReader["Out_Cur"].ToString();
|
|
realTimeDataViewModel1.DataTimeShoreBaseStationVol = Convert.ToDateTime(dataReader["RecordTime"]);
|
|
realTimeDataViewModel1.DataTimeShoreBaseStationCur = Convert.ToDateTime(dataReader["RecordTime"]);
|
|
}
|
|
dataReader.Dispose();
|
|
|
|
sql = String.Format("select * from underjuncbox_env where StationID = {0} ORDER by id desc limit 1", 2);
|
|
dataReader = DBHelper.ExecuteReader(sql, 1);
|
|
sqlSub = String.Format("select * from underjuncbox_cavity_state where StationID = {0} ORDER by id desc limit 1", 2);
|
|
dataReaderSub = DBHelper.ExecuteReader(sqlSub, 1);
|
|
sqlMon = String.Format("select * from underjuncbox_monitor where StationID = {0} ORDER by id desc limit 1", 2);
|
|
dataReaderMon = DBHelper.ExecuteReader(sqlMon, 1);
|
|
if (dataReaderMon.Read())
|
|
{
|
|
string voltage = string.IsNullOrEmpty(dataReaderMon["Seis1_Voltage"].ToString()) ? "0.00" : dataReaderMon["Seis1_Voltage"].ToString();
|
|
string current = string.IsNullOrEmpty(dataReaderMon["Seis1_Current"].ToString()) ? "0.00" : dataReaderMon["Seis1_Current"].ToString();
|
|
realTimeDataViewModel2.JunctionBoxStatus[0].Value = voltage + " / " + current;
|
|
|
|
voltage = string.IsNullOrEmpty(dataReaderMon["Seis2_Voltage"].ToString()) ? "0.00" : dataReaderMon["Seis2_Voltage"].ToString();
|
|
current = string.IsNullOrEmpty(dataReaderMon["Seis2_Current"].ToString()) ? "0.00" : dataReaderMon["Seis2_Current"].ToString();
|
|
realTimeDataViewModel2.JunctionBoxStatus[3].Value = voltage + " / " + current;
|
|
|
|
realTimeDataViewModel2.DataTimeMainSeis = Convert.ToDateTime(dataReaderMon["RecordTime"]);
|
|
realTimeDataViewModel2.DataTimeBackupSeis = Convert.ToDateTime(dataReaderMon["RecordTime"]);
|
|
}
|
|
else
|
|
{
|
|
realTimeDataViewModel2.JunctionBoxStatus[0].Value = "0.00 / 0.00";
|
|
realTimeDataViewModel2.JunctionBoxStatus[3].Value = "0.00 / 0.00";
|
|
|
|
realTimeDataViewModel2.DataTimeMainSeis = DateTime.Now;
|
|
realTimeDataViewModel2.DataTimeBackupSeis = DateTime.Now;
|
|
}
|
|
|
|
if (dataReader.Read())
|
|
{
|
|
realTimeDataViewModel2.JunctionBoxStatus[1].Value = string.IsNullOrEmpty(dataReader["Temperature"].ToString()) ? "0.00" : dataReader["Temperature"].ToString();
|
|
realTimeDataViewModel2.JunctionBoxStatus[4].Value = string.IsNullOrEmpty(dataReader["Humidity"].ToString()) ? "0.00" : dataReader["Humidity"].ToString();
|
|
|
|
realTimeDataViewModel2.DataTimeJuncboxTem = Convert.ToDateTime(dataReader["DataTime"]);
|
|
realTimeDataViewModel2.DataTimeJuncboxHum = Convert.ToDateTime(dataReader["DataTime"]);
|
|
}
|
|
else
|
|
{
|
|
realTimeDataViewModel2.JunctionBoxStatus[1].Value = "0.00";
|
|
realTimeDataViewModel2.JunctionBoxStatus[4].Value = "0.00";
|
|
|
|
realTimeDataViewModel2.DataTimeJuncboxTem = DateTime.Now;
|
|
realTimeDataViewModel2.DataTimeJuncboxHum = DateTime.Now;
|
|
}
|
|
|
|
if (dataReaderSub.Read())
|
|
{
|
|
int leakState = Convert.ToInt32(string.IsNullOrEmpty(dataReaderSub["Leakage"].ToString()) ? "2" : dataReaderSub["Leakage"]);
|
|
if (leakState == 1)
|
|
{
|
|
realTimeDataViewModel2.LeakageImage = (ImageSource)Application.Current.FindResource("CycleRed");
|
|
}
|
|
else if (leakState == 0)
|
|
{
|
|
realTimeDataViewModel2.LeakageImage = (ImageSource)Application.Current.FindResource("CycleGreen");
|
|
}
|
|
else
|
|
{
|
|
realTimeDataViewModel2.LeakageImage = (ImageSource)Application.Current.FindResource("CycleGray");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
realTimeDataViewModel2.LeakageImage = (ImageSource)Application.Current.FindResource("CycleGray");
|
|
}
|
|
dataReader.Dispose();
|
|
dataReaderSub.Dispose();
|
|
dataReaderMon.Dispose();
|
|
|
|
sql = String.Format("select * from shorebasestation_output_state ORDER by id desc limit 1");
|
|
dataReader = DBHelper.ExecuteReader(sql, 1);
|
|
while (dataReader.Read())
|
|
{
|
|
realTimeDataViewModel2.JunctionBoxStatus[2].Value = string.IsNullOrEmpty(dataReader["Out_Vol"].ToString()) ? "0.00" : dataReader["Out_Vol"].ToString();
|
|
realTimeDataViewModel2.JunctionBoxStatus[5].Value = string.IsNullOrEmpty(dataReader["Out_Cur"].ToString()) ? "0.00" : dataReader["Out_Cur"].ToString();
|
|
realTimeDataViewModel2.DataTimeShoreBaseStationVol = Convert.ToDateTime(dataReader["RecordTime"]);
|
|
realTimeDataViewModel2.DataTimeShoreBaseStationCur = Convert.ToDateTime(dataReader["RecordTime"]);
|
|
}
|
|
dataReader.Dispose();
|
|
|
|
sql = String.Format("select * from underjuncbox_env where StationID = {0} ORDER by id desc limit 1", 3);
|
|
dataReader = DBHelper.ExecuteReader(sql, 1);
|
|
sqlSub = String.Format("select * from underjuncbox_cavity_state where StationID = {0} ORDER by id desc limit 1", 3);
|
|
dataReaderSub = DBHelper.ExecuteReader(sqlSub, 1);
|
|
sqlMon = String.Format("select * from underjuncbox_monitor where StationID = {0} ORDER by id desc limit 1", 3);
|
|
dataReaderMon = DBHelper.ExecuteReader(sqlMon, 1);
|
|
if (dataReaderMon.Read())
|
|
{
|
|
string voltage = string.IsNullOrEmpty(dataReaderMon["Seis1_Voltage"].ToString()) ? "0.00" : dataReaderMon["Seis1_Voltage"].ToString();
|
|
string current = string.IsNullOrEmpty(dataReaderMon["Seis1_Current"].ToString()) ? "0.00" : dataReaderMon["Seis1_Current"].ToString();
|
|
realTimeDataViewModel3.JunctionBoxStatus[0].Value = voltage + " / " + current;
|
|
|
|
voltage = string.IsNullOrEmpty(dataReaderMon["Seis2_Voltage"].ToString()) ? "0.00" : dataReaderMon["Seis2_Voltage"].ToString();
|
|
current = string.IsNullOrEmpty(dataReaderMon["Seis2_Current"].ToString()) ? "0.00" : dataReaderMon["Seis2_Current"].ToString();
|
|
realTimeDataViewModel3.JunctionBoxStatus[3].Value = voltage + " / " + current;
|
|
|
|
realTimeDataViewModel3.DataTimeMainSeis = Convert.ToDateTime(dataReaderMon["RecordTime"]);
|
|
realTimeDataViewModel3.DataTimeBackupSeis = Convert.ToDateTime(dataReaderMon["RecordTime"]);
|
|
}
|
|
else
|
|
{
|
|
realTimeDataViewModel3.JunctionBoxStatus[0].Value = "0.00 / 0.00";
|
|
realTimeDataViewModel3.JunctionBoxStatus[3].Value = "0.00 / 0.00";
|
|
|
|
realTimeDataViewModel3.DataTimeMainSeis = DateTime.Now;
|
|
realTimeDataViewModel3.DataTimeBackupSeis = DateTime.Now;
|
|
}
|
|
|
|
if (dataReader.Read())
|
|
{
|
|
realTimeDataViewModel3.JunctionBoxStatus[1].Value = string.IsNullOrEmpty(dataReader["Temperature"].ToString()) ? "0.00" : dataReader["Temperature"].ToString();
|
|
realTimeDataViewModel3.JunctionBoxStatus[4].Value = string.IsNullOrEmpty(dataReader["Humidity"].ToString()) ? "0.00" : dataReader["Humidity"].ToString();
|
|
|
|
realTimeDataViewModel3.DataTimeJuncboxTem = Convert.ToDateTime(dataReader["DataTime"]);
|
|
realTimeDataViewModel3.DataTimeJuncboxHum = Convert.ToDateTime(dataReader["DataTime"]);
|
|
}
|
|
else
|
|
{
|
|
realTimeDataViewModel3.JunctionBoxStatus[1].Value = "0.00";
|
|
realTimeDataViewModel3.JunctionBoxStatus[4].Value = "0.00";
|
|
|
|
realTimeDataViewModel3.DataTimeJuncboxTem = DateTime.Now;
|
|
realTimeDataViewModel3.DataTimeJuncboxHum = DateTime.Now;
|
|
}
|
|
|
|
if (dataReaderSub.Read())
|
|
{
|
|
int leakState = Convert.ToInt32(string.IsNullOrEmpty(dataReaderSub["Leakage"].ToString()) ? "2" : dataReaderSub["Leakage"]);
|
|
if (leakState == 1)
|
|
{
|
|
realTimeDataViewModel3.LeakageImage = (ImageSource)Application.Current.FindResource("CycleRed");
|
|
}
|
|
else if (leakState == 0)
|
|
{
|
|
realTimeDataViewModel3.LeakageImage = (ImageSource)Application.Current.FindResource("CycleGreen");
|
|
}
|
|
else
|
|
{
|
|
realTimeDataViewModel3.LeakageImage = (ImageSource)Application.Current.FindResource("CycleGray");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
realTimeDataViewModel3.LeakageImage = (ImageSource)Application.Current.FindResource("CycleGray");
|
|
}
|
|
dataReader.Dispose();
|
|
dataReaderSub.Dispose();
|
|
dataReaderMon.Dispose();
|
|
|
|
sql = String.Format("select * from shorebasestation_output_state ORDER by id desc limit 1");
|
|
dataReader = DBHelper.ExecuteReader(sql, 1);
|
|
while (dataReader.Read())
|
|
{
|
|
realTimeDataViewModel3.JunctionBoxStatus[2].Value = string.IsNullOrEmpty(dataReader["Out_Vol"].ToString()) ? "0.00" : dataReader["Out_Vol"].ToString();
|
|
realTimeDataViewModel3.JunctionBoxStatus[5].Value = string.IsNullOrEmpty(dataReader["Out_Cur"].ToString()) ? "0.00" : dataReader["Out_Cur"].ToString();
|
|
realTimeDataViewModel3.DataTimeShoreBaseStationVol = Convert.ToDateTime(dataReader["RecordTime"]);
|
|
realTimeDataViewModel3.DataTimeShoreBaseStationCur = Convert.ToDateTime(dataReader["RecordTime"]);
|
|
}
|
|
dataReader.Dispose();
|
|
#endregion
|
|
|
|
|
|
#region 实时数据显示页面告警数据初始化
|
|
sql = String.Format("select * from underjuncbox_alarm_info where StationID = {0} ORDER by id desc limit 7", 1);
|
|
dataReader = DBHelper.ExecuteReader(sql, 1);
|
|
index = 1;
|
|
while (dataReader.Read())
|
|
{
|
|
AlarmRecordModel alarmRecordModel = new AlarmRecordModel();
|
|
alarmRecordModel.Index = index++;
|
|
alarmRecordModel.RecordTime = Convert.ToDateTime(dataReader["RecordTime"]);
|
|
alarmRecordModel.ParaName = dataReader["ParaName"].ToString();
|
|
alarmRecordModel.ParaContent = dataReader["ParaContent"].ToString();
|
|
alarmRecordModel.ProcessingMethod = dataReader["ProcessingMethod"].ToString();
|
|
if (dataReader["UrgencyLevel"].ToString() == "1")
|
|
{
|
|
alarmRecordModel.UrgencyLevel = (ImageSource)Application.Current.FindResource("CycleYellow");
|
|
}
|
|
else if (dataReader["UrgencyLevel"].ToString() == "2")
|
|
{
|
|
alarmRecordModel.UrgencyLevel = (ImageSource)Application.Current.FindResource("CycleOrange");
|
|
}
|
|
else
|
|
{
|
|
alarmRecordModel.UrgencyLevel = (ImageSource)Application.Current.FindResource("CycleRed");
|
|
}
|
|
realTimeDataViewModel1.AlarmList.Add(alarmRecordModel);
|
|
}
|
|
dataReader.Dispose();
|
|
|
|
sql = String.Format("select * from underjuncbox_alarm_info where StationID = {0} ORDER by id desc limit 7", 2);
|
|
dataReader = DBHelper.ExecuteReader(sql, 1);
|
|
index = 1;
|
|
while (dataReader.Read())
|
|
{
|
|
AlarmRecordModel alarmRecordModel = new AlarmRecordModel();
|
|
alarmRecordModel.Index = index++;
|
|
alarmRecordModel.RecordTime = Convert.ToDateTime(dataReader["RecordTime"]);
|
|
alarmRecordModel.ParaName = dataReader["ParaName"].ToString();
|
|
alarmRecordModel.ParaContent = dataReader["ParaContent"].ToString();
|
|
alarmRecordModel.ProcessingMethod = dataReader["ProcessingMethod"].ToString();
|
|
if (dataReader["UrgencyLevel"].ToString() == "1")
|
|
{
|
|
alarmRecordModel.UrgencyLevel = (ImageSource)Application.Current.FindResource("CycleYellow");
|
|
}
|
|
else if (dataReader["UrgencyLevel"].ToString() == "2")
|
|
{
|
|
alarmRecordModel.UrgencyLevel = (ImageSource)Application.Current.FindResource("CycleOrange");
|
|
}
|
|
else
|
|
{
|
|
alarmRecordModel.UrgencyLevel = (ImageSource)Application.Current.FindResource("CycleRed");
|
|
}
|
|
realTimeDataViewModel2.AlarmList.Add(alarmRecordModel);
|
|
}
|
|
dataReader.Dispose();
|
|
|
|
sql = String.Format("select * from underjuncbox_alarm_info where StationID = {0} ORDER by id desc limit 7", 3);
|
|
dataReader = DBHelper.ExecuteReader(sql, 1);
|
|
index = 1;
|
|
while (dataReader.Read())
|
|
{
|
|
AlarmRecordModel alarmRecordModel = new AlarmRecordModel();
|
|
alarmRecordModel.Index = index++;
|
|
alarmRecordModel.RecordTime = Convert.ToDateTime(dataReader["RecordTime"]);
|
|
alarmRecordModel.ParaName = dataReader["ParaName"].ToString();
|
|
alarmRecordModel.ParaContent = dataReader["ParaContent"].ToString();
|
|
alarmRecordModel.ProcessingMethod = dataReader["ProcessingMethod"].ToString();
|
|
if (dataReader["UrgencyLevel"].ToString() == "1")
|
|
{
|
|
alarmRecordModel.UrgencyLevel = (ImageSource)Application.Current.FindResource("CycleYellow");
|
|
}
|
|
else if (dataReader["UrgencyLevel"].ToString() == "2")
|
|
{
|
|
alarmRecordModel.UrgencyLevel = (ImageSource)Application.Current.FindResource("CycleOrange");
|
|
}
|
|
else
|
|
{
|
|
alarmRecordModel.UrgencyLevel = (ImageSource)Application.Current.FindResource("CycleRed");
|
|
}
|
|
realTimeDataViewModel3.AlarmList.Add(alarmRecordModel);
|
|
}
|
|
dataReader.Dispose();
|
|
#endregion
|
|
|
|
|
|
#region 接驳盒环境数据页面初始化
|
|
sql = String.Format("select * from underjuncbox_env where StationID = {0} ORDER by id desc limit 100", 1);
|
|
dataReader = DBHelper.ExecuteReader(sql, 1);
|
|
sqlSub = String.Format("select * from underjuncbox_cavity_state where StationID = {0} ORDER by id desc limit 100", 1);
|
|
dataReaderSub = DBHelper.ExecuteReader(sqlSub, 1);
|
|
index = 1;
|
|
while (dataReader.Read())
|
|
{
|
|
JunctionBoxEnvironModel junctionBoxEnvironModel = new JunctionBoxEnvironModel();
|
|
junctionBoxEnvironModel.Index = index++;
|
|
junctionBoxEnvironModel.DataTime = Convert.ToDateTime(dataReader["DataTime"]);
|
|
junctionBoxEnvironModel.RecordTime = Convert.ToDateTime(dataReader["RecordTime"]);
|
|
junctionBoxEnvironModel.Temperature = Convert.ToSingle(string.IsNullOrEmpty(dataReader["Temperature"].ToString()) ? "0" : dataReader["Temperature"]);
|
|
junctionBoxEnvironModel.Humidity = Convert.ToSingle(string.IsNullOrEmpty(dataReader["Humidity"].ToString()) ? "0" : dataReader["Humidity"]);
|
|
junctionBoxEnvironModel.AttitudeX = Convert.ToSingle(string.IsNullOrEmpty(dataReader["AttitudeX"].ToString()) ? "0" : dataReader["AttitudeX"]);
|
|
junctionBoxEnvironModel.AttitudeY = Convert.ToSingle(string.IsNullOrEmpty(dataReader["AttitudeY"].ToString()) ? "0" : dataReader["AttitudeY"]);
|
|
junctionBoxEnvironModel.AttitudeZ = Convert.ToSingle(string.IsNullOrEmpty(dataReader["AttitudeZ"].ToString()) ? "0" : dataReader["AttitudeZ"]);
|
|
|
|
if (dataReaderSub.Read())
|
|
{
|
|
int leakState = Convert.ToInt32(string.IsNullOrEmpty(dataReaderSub["Leakage"].ToString()) ? "2" : dataReaderSub["Leakage"]);
|
|
if (leakState == 1)
|
|
{
|
|
junctionBoxEnvironModel.Leakage = (ImageSource)Application.Current.FindResource("CycleRed");
|
|
}
|
|
else if (leakState == 0)
|
|
{
|
|
junctionBoxEnvironModel.Leakage = (ImageSource)Application.Current.FindResource("CycleGreen");
|
|
}
|
|
else
|
|
{
|
|
junctionBoxEnvironModel.Leakage = (ImageSource)Application.Current.FindResource("CycleGray");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
junctionBoxEnvironModel.Leakage = (ImageSource)Application.Current.FindResource("CycleGray");
|
|
}
|
|
|
|
junctionBoxEnvironDataViewModel1.TotalJunctionBoxEnvironDataList.Add(junctionBoxEnvironModel);
|
|
}
|
|
dataReader.Dispose();
|
|
dataReaderSub.Dispose();
|
|
|
|
junctionBoxEnvironDataViewModel1.RecordCount = index - 1;
|
|
junctionBoxEnvironDataViewModel1.TotalPage = (index - 1) <= 10 ? 1 : (int)Math.Ceiling((double)(index - 1) / 10);
|
|
for (int i = 0; i < (junctionBoxEnvironDataViewModel1.RecordCount < 10 ? junctionBoxEnvironDataViewModel1.RecordCount : 10); i++)
|
|
{
|
|
junctionBoxEnvironDataViewModel1.JunctionBoxEnvironDataList.Add(junctionBoxEnvironDataViewModel1.TotalJunctionBoxEnvironDataList[i]);
|
|
}
|
|
junctionBoxEnvironDataViewModel1.JunctionBoxEnvironMsg = string.Format("共计{0}页,当前第{1}页", junctionBoxEnvironDataViewModel1.TotalPage, 1);
|
|
|
|
sql = String.Format("select * from underjuncbox_env where StationID = {0} ORDER by id desc limit 100", 2);
|
|
dataReader = DBHelper.ExecuteReader(sql, 1);
|
|
sqlSub = String.Format("select * from underjuncbox_cavity_state where StationID = {0} ORDER by id desc limit 100", 2);
|
|
dataReaderSub = DBHelper.ExecuteReader(sqlSub, 1);
|
|
index = 1;
|
|
while (dataReader.Read())
|
|
{
|
|
JunctionBoxEnvironModel junctionBoxEnvironModel = new JunctionBoxEnvironModel();
|
|
junctionBoxEnvironModel.Index = index++;
|
|
junctionBoxEnvironModel.DataTime = Convert.ToDateTime(dataReader["DataTime"]);
|
|
junctionBoxEnvironModel.RecordTime = Convert.ToDateTime(dataReader["RecordTime"]);
|
|
junctionBoxEnvironModel.Temperature = Convert.ToSingle(string.IsNullOrEmpty(dataReader["Temperature"].ToString()) ? "0" : dataReader["Temperature"]);
|
|
junctionBoxEnvironModel.Humidity = Convert.ToSingle(string.IsNullOrEmpty(dataReader["Humidity"].ToString()) ? "0" : dataReader["Humidity"]);
|
|
junctionBoxEnvironModel.AttitudeX = Convert.ToSingle(string.IsNullOrEmpty(dataReader["AttitudeX"].ToString()) ? "0" : dataReader["AttitudeX"]);
|
|
junctionBoxEnvironModel.AttitudeY = Convert.ToSingle(string.IsNullOrEmpty(dataReader["AttitudeY"].ToString()) ? "0" : dataReader["AttitudeY"]);
|
|
junctionBoxEnvironModel.AttitudeZ = Convert.ToSingle(string.IsNullOrEmpty(dataReader["AttitudeZ"].ToString()) ? "0" : dataReader["AttitudeZ"]);
|
|
|
|
if (dataReaderSub.Read())
|
|
{
|
|
int leakState = Convert.ToInt32(string.IsNullOrEmpty(dataReaderSub["Leakage"].ToString()) ? "2" : dataReaderSub["Leakage"]);
|
|
if (leakState == 1)
|
|
{
|
|
junctionBoxEnvironModel.Leakage = (ImageSource)Application.Current.FindResource("CycleRed");
|
|
}
|
|
else if (leakState == 0)
|
|
{
|
|
junctionBoxEnvironModel.Leakage = (ImageSource)Application.Current.FindResource("CycleGreen");
|
|
}
|
|
else
|
|
{
|
|
junctionBoxEnvironModel.Leakage = (ImageSource)Application.Current.FindResource("CycleGray");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
junctionBoxEnvironModel.Leakage = (ImageSource)Application.Current.FindResource("CycleGray");
|
|
}
|
|
|
|
junctionBoxEnvironDataViewModel2.TotalJunctionBoxEnvironDataList.Add(junctionBoxEnvironModel);
|
|
}
|
|
dataReader.Dispose();
|
|
dataReaderSub.Dispose();
|
|
|
|
junctionBoxEnvironDataViewModel2.RecordCount = index - 1;
|
|
junctionBoxEnvironDataViewModel2.TotalPage = (index - 1) <= 10 ? 1 : (int)Math.Ceiling((double)(index - 1) / 10);
|
|
for (int i = 0; i < (junctionBoxEnvironDataViewModel2.RecordCount < 10 ? junctionBoxEnvironDataViewModel2.RecordCount : 10); i++)
|
|
{
|
|
junctionBoxEnvironDataViewModel2.JunctionBoxEnvironDataList.Add(junctionBoxEnvironDataViewModel2.TotalJunctionBoxEnvironDataList[i]);
|
|
}
|
|
junctionBoxEnvironDataViewModel2.JunctionBoxEnvironMsg = string.Format("共计{0}页,当前第{1}页", junctionBoxEnvironDataViewModel2.TotalPage, 1);
|
|
|
|
sql = String.Format("select * from underjuncbox_env where StationID = {0} ORDER by id desc limit 100", 3);
|
|
dataReader = DBHelper.ExecuteReader(sql, 1);
|
|
sqlSub = String.Format("select * from underjuncbox_cavity_state where StationID = {0} ORDER by id desc limit 100", 3);
|
|
dataReaderSub = DBHelper.ExecuteReader(sqlSub, 1);
|
|
index = 1;
|
|
while (dataReader.Read())
|
|
{
|
|
JunctionBoxEnvironModel junctionBoxEnvironModel = new JunctionBoxEnvironModel();
|
|
junctionBoxEnvironModel.Index = index++;
|
|
junctionBoxEnvironModel.DataTime = Convert.ToDateTime(dataReader["DataTime"]);
|
|
junctionBoxEnvironModel.RecordTime = Convert.ToDateTime(dataReader["RecordTime"]);
|
|
junctionBoxEnvironModel.Temperature = Convert.ToSingle(string.IsNullOrEmpty(dataReader["Temperature"].ToString()) ? "0" : dataReader["Temperature"]);
|
|
junctionBoxEnvironModel.Humidity = Convert.ToSingle(string.IsNullOrEmpty(dataReader["Humidity"].ToString()) ? "0" : dataReader["Humidity"]);
|
|
junctionBoxEnvironModel.AttitudeX = Convert.ToSingle(string.IsNullOrEmpty(dataReader["AttitudeX"].ToString()) ? "0" : dataReader["AttitudeX"]);
|
|
junctionBoxEnvironModel.AttitudeY = Convert.ToSingle(string.IsNullOrEmpty(dataReader["AttitudeY"].ToString()) ? "0" : dataReader["AttitudeY"]);
|
|
junctionBoxEnvironModel.AttitudeZ = Convert.ToSingle(string.IsNullOrEmpty(dataReader["AttitudeZ"].ToString()) ? "0" : dataReader["AttitudeZ"]);
|
|
|
|
if (dataReaderSub.Read())
|
|
{
|
|
int leakState = Convert.ToInt32(string.IsNullOrEmpty(dataReaderSub["Leakage"].ToString()) ? "2" : dataReaderSub["Leakage"]);
|
|
if (leakState == 1)
|
|
{
|
|
junctionBoxEnvironModel.Leakage = (ImageSource)Application.Current.FindResource("CycleRed");
|
|
}
|
|
else if (leakState == 0)
|
|
{
|
|
junctionBoxEnvironModel.Leakage = (ImageSource)Application.Current.FindResource("CycleGreen");
|
|
}
|
|
else
|
|
{
|
|
junctionBoxEnvironModel.Leakage = (ImageSource)Application.Current.FindResource("CycleGray");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
junctionBoxEnvironModel.Leakage = (ImageSource)Application.Current.FindResource("CycleGray");
|
|
}
|
|
|
|
junctionBoxEnvironDataViewModel3.TotalJunctionBoxEnvironDataList.Add(junctionBoxEnvironModel);
|
|
}
|
|
dataReader.Dispose();
|
|
dataReaderSub.Dispose();
|
|
|
|
junctionBoxEnvironDataViewModel3.RecordCount = index - 1;
|
|
junctionBoxEnvironDataViewModel3.TotalPage = (index - 1) <= 10 ? 1 : (int)Math.Ceiling((double)(index - 1) / 10);
|
|
for (int i = 0; i < (junctionBoxEnvironDataViewModel3.RecordCount < 10 ? junctionBoxEnvironDataViewModel3.RecordCount : 10); i++)
|
|
{
|
|
junctionBoxEnvironDataViewModel3.JunctionBoxEnvironDataList.Add(junctionBoxEnvironDataViewModel3.TotalJunctionBoxEnvironDataList[i]);
|
|
}
|
|
junctionBoxEnvironDataViewModel3.JunctionBoxEnvironMsg = string.Format("共计{0}页,当前第{1}页", junctionBoxEnvironDataViewModel3.TotalPage, 1);
|
|
#endregion
|
|
|
|
|
|
#region 接驳盒状态数据页面初始化
|
|
sql = String.Format("select * from underjuncbox_monitor where StationID = {0} ORDER by id desc limit 100", 1);
|
|
dataReader = DBHelper.ExecuteReader(sql, 1);
|
|
index = 1;
|
|
while (dataReader.Read())
|
|
{
|
|
JunctionBoxMonitorModel junctionBoxMonitorModel = new JunctionBoxMonitorModel();
|
|
junctionBoxMonitorModel.Index = index++;
|
|
junctionBoxMonitorModel.RecordTime = Convert.ToDateTime(dataReader["RecordTime"]);
|
|
junctionBoxMonitorModel.Seis1_Voltage = Convert.ToSingle(string.IsNullOrEmpty(dataReader["Seis1_Voltage"].ToString()) ? "0" : dataReader["Seis1_Voltage"]);
|
|
junctionBoxMonitorModel.Seis1_Current = Convert.ToSingle(string.IsNullOrEmpty(dataReader["Seis1_Current"].ToString()) ? "0" : dataReader["Seis1_Current"]);
|
|
junctionBoxMonitorModel.Seis2_Voltage = Convert.ToSingle(string.IsNullOrEmpty(dataReader["Seis2_Voltage"].ToString()) ? "0" : dataReader["Seis2_Voltage"]);
|
|
junctionBoxMonitorModel.Seis2_Current = Convert.ToSingle(string.IsNullOrEmpty(dataReader["Seis2_Current"].ToString()) ? "0" : dataReader["Seis2_Current"]);
|
|
junctionBoxMonitorModel.Video_Current = Convert.ToSingle(string.IsNullOrEmpty(dataReader["Video_Current"].ToString()) ? "0" : dataReader["Video_Current"]);
|
|
junctionBoxMonitorModel.Video_Voltage = Convert.ToSingle(string.IsNullOrEmpty(dataReader["Video_Voltage"].ToString()) ? "0" : dataReader["Video_Voltage"]);
|
|
junctionBoxMonitorModel.Out_Voltage12_Reserved2 = Convert.ToSingle(string.IsNullOrEmpty(dataReader["Out_Voltage12_Reserved2"].ToString()) ? "0" : dataReader["Out_Voltage12_Reserved2"]);
|
|
junctionBoxStatusDataViewModel1.TotalJunctionBoxStatusDataList.Add(junctionBoxMonitorModel);
|
|
}
|
|
dataReader.Dispose();
|
|
|
|
junctionBoxStatusDataViewModel1.RecordCount = index - 1;
|
|
junctionBoxStatusDataViewModel1.TotalPage = (index - 1) <= 10 ? 1 : (int)Math.Ceiling((double)(index - 1) / 10);
|
|
for (int i = 0; i < (junctionBoxStatusDataViewModel1.RecordCount < 10 ? junctionBoxStatusDataViewModel1.RecordCount : 10); i++)
|
|
{
|
|
junctionBoxStatusDataViewModel1.JunctionBoxStatusDataList.Add(junctionBoxStatusDataViewModel1.TotalJunctionBoxStatusDataList[i]);
|
|
}
|
|
junctionBoxStatusDataViewModel1.JunctionBoxStatusDataMsg = string.Format("共计{0}页,当前第{1}页", junctionBoxStatusDataViewModel1.TotalPage, 1);
|
|
|
|
sql = String.Format("select * from underjuncbox_monitor where StationID = {0} ORDER by id desc limit 100", 2);
|
|
dataReader = DBHelper.ExecuteReader(sql, 1);
|
|
index = 1;
|
|
while (dataReader.Read())
|
|
{
|
|
JunctionBoxMonitorModel junctionBoxMonitorModel = new JunctionBoxMonitorModel();
|
|
junctionBoxMonitorModel.Index = index++;
|
|
junctionBoxMonitorModel.RecordTime = Convert.ToDateTime(dataReader["RecordTime"]);
|
|
junctionBoxMonitorModel.Seis1_Voltage = Convert.ToSingle(string.IsNullOrEmpty(dataReader["Seis1_Voltage"].ToString()) ? "0" : dataReader["Seis1_Voltage"]);
|
|
junctionBoxMonitorModel.Seis1_Current = Convert.ToSingle(string.IsNullOrEmpty(dataReader["Seis1_Current"].ToString()) ? "0" : dataReader["Seis1_Current"]);
|
|
junctionBoxMonitorModel.Seis2_Voltage = Convert.ToSingle(string.IsNullOrEmpty(dataReader["Seis2_Voltage"].ToString()) ? "0" : dataReader["Seis2_Voltage"]);
|
|
junctionBoxMonitorModel.Seis2_Current = Convert.ToSingle(string.IsNullOrEmpty(dataReader["Seis2_Current"].ToString()) ? "0" : dataReader["Seis2_Current"]);
|
|
junctionBoxMonitorModel.Video_Current = Convert.ToSingle(string.IsNullOrEmpty(dataReader["Video_Current"].ToString()) ? "0" : dataReader["Video_Current"]);
|
|
junctionBoxMonitorModel.Video_Voltage = Convert.ToSingle(string.IsNullOrEmpty(dataReader["Video_Voltage"].ToString()) ? "0" : dataReader["Video_Voltage"]);
|
|
junctionBoxMonitorModel.Out_Voltage12_Reserved2 = Convert.ToSingle(string.IsNullOrEmpty(dataReader["Out_Voltage12_Reserved2"].ToString()) ? "0" : dataReader["Out_Voltage12_Reserved2"]);
|
|
junctionBoxStatusDataViewModel2.TotalJunctionBoxStatusDataList.Add(junctionBoxMonitorModel);
|
|
}
|
|
dataReader.Dispose();
|
|
|
|
junctionBoxStatusDataViewModel2.RecordCount = index - 1;
|
|
junctionBoxStatusDataViewModel2.TotalPage = (index - 1) <= 10 ? 1 : (int)Math.Ceiling((double)(index - 1) / 10);
|
|
for (int i = 0; i < (junctionBoxStatusDataViewModel2.RecordCount < 10 ? junctionBoxStatusDataViewModel2.RecordCount : 10); i++)
|
|
{
|
|
junctionBoxStatusDataViewModel2.JunctionBoxStatusDataList.Add(junctionBoxStatusDataViewModel2.TotalJunctionBoxStatusDataList[i]);
|
|
}
|
|
junctionBoxStatusDataViewModel2.JunctionBoxStatusDataMsg = string.Format("共计{0}页,当前第{1}页", junctionBoxStatusDataViewModel2.TotalPage, 1);
|
|
|
|
sql = String.Format("select * from underjuncbox_monitor where StationID = {0} ORDER by id desc limit 100", 3);
|
|
dataReader = DBHelper.ExecuteReader(sql, 1);
|
|
index = 1;
|
|
while (dataReader.Read())
|
|
{
|
|
JunctionBoxMonitorModel junctionBoxMonitorModel = new JunctionBoxMonitorModel();
|
|
junctionBoxMonitorModel.Index = index++;
|
|
junctionBoxMonitorModel.RecordTime = Convert.ToDateTime(dataReader["RecordTime"]);
|
|
junctionBoxMonitorModel.Seis1_Voltage = Convert.ToSingle(string.IsNullOrEmpty(dataReader["Seis1_Voltage"].ToString()) ? "0" : dataReader["Seis1_Voltage"]);
|
|
junctionBoxMonitorModel.Seis1_Current = Convert.ToSingle(string.IsNullOrEmpty(dataReader["Seis1_Current"].ToString()) ? "0" : dataReader["Seis1_Current"]);
|
|
junctionBoxMonitorModel.Seis2_Voltage = Convert.ToSingle(string.IsNullOrEmpty(dataReader["Seis2_Voltage"].ToString()) ? "0" : dataReader["Seis2_Voltage"]);
|
|
junctionBoxMonitorModel.Seis2_Current = Convert.ToSingle(string.IsNullOrEmpty(dataReader["Seis2_Current"].ToString()) ? "0" : dataReader["Seis2_Current"]);
|
|
junctionBoxMonitorModel.Video_Current = Convert.ToSingle(string.IsNullOrEmpty(dataReader["Video_Current"].ToString()) ? "0" : dataReader["Video_Current"]);
|
|
junctionBoxMonitorModel.Video_Voltage = Convert.ToSingle(string.IsNullOrEmpty(dataReader["Video_Voltage"].ToString()) ? "0" : dataReader["Video_Voltage"]);
|
|
junctionBoxMonitorModel.Out_Voltage12_Reserved2 = Convert.ToSingle(string.IsNullOrEmpty(dataReader["Out_Voltage12_Reserved2"].ToString()) ? "0" : dataReader["Out_Voltage12_Reserved2"]);
|
|
junctionBoxStatusDataViewModel3.TotalJunctionBoxStatusDataList.Add(junctionBoxMonitorModel);
|
|
}
|
|
dataReader.Dispose();
|
|
|
|
junctionBoxStatusDataViewModel3.RecordCount = index - 1;
|
|
junctionBoxStatusDataViewModel3.TotalPage = (index - 1) <= 10 ? 1 : (int)Math.Ceiling((double)(index - 1) / 10);
|
|
for (int i = 0; i < (junctionBoxStatusDataViewModel3.RecordCount < 10 ? junctionBoxStatusDataViewModel3.RecordCount : 10); i++)
|
|
{
|
|
junctionBoxStatusDataViewModel3.JunctionBoxStatusDataList.Add(junctionBoxStatusDataViewModel3.TotalJunctionBoxStatusDataList[i]);
|
|
}
|
|
junctionBoxStatusDataViewModel3.JunctionBoxStatusDataMsg = string.Format("共计{0}页,当前第{1}页", junctionBoxStatusDataViewModel3.TotalPage, 1);
|
|
#endregion
|
|
|
|
|
|
//默认打开第一个界面
|
|
DoNavChanged("RealTimeDataView");
|
|
}
|
|
|
|
|
|
|
|
#region Page Switching
|
|
public void DoNavChanged(object obj)
|
|
{
|
|
if (obj.ToString() == "1" || obj.ToString() == "2" || obj.ToString() == "3" || obj.ToString() == "4" || obj.ToString() == "5") //说明是站点切换按钮
|
|
{
|
|
if (station_id == Convert.ToInt32(obj)) //如果切换的界面和之前一样 那就不切换
|
|
return;
|
|
station_id = Convert.ToInt32(obj);
|
|
}
|
|
else if (obj.ToString() == "")
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
if (Title_Name == obj.ToString())
|
|
return;
|
|
Title_Name = obj.ToString();
|
|
}
|
|
|
|
//切换页面之前清理一下内存
|
|
Tools.ClearMemory(this);
|
|
|
|
Type type = Type.GetType("FujianEarthquake.Views." + Title_Name);
|
|
ConstructorInfo cti = type.GetConstructor(System.Type.EmptyTypes);
|
|
FrameworkElement page = (FrameworkElement)cti.Invoke(null);
|
|
if (station_id == 1)
|
|
{
|
|
switch (Title_Name)
|
|
{
|
|
case "RealTimeDataView":
|
|
page.DataContext = realTimeDataViewModel1;
|
|
break;
|
|
case "JunctionBoxEnvironDataView":
|
|
junctionBoxEnvironDataViewModel1.RefreshFile(obj);
|
|
page.DataContext = junctionBoxEnvironDataViewModel1;
|
|
break;
|
|
case "JunctionBoxStatusDataView":
|
|
page.DataContext = junctionBoxStatusDataViewModel1;
|
|
break;
|
|
//case "ShoreBaseStationStatusDataView":
|
|
// page.DataContext = shoreBaseStationStatusDataViewModel1;
|
|
// break;
|
|
case "SystemControlView":
|
|
|
|
break;
|
|
case "LogRecordView":
|
|
page.DataContext = logRecordViewModel1;
|
|
break;
|
|
case "AlarmRecordView":
|
|
page.DataContext = alarmRecordViewModel1;
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
else if (station_id == 2)
|
|
{
|
|
switch (Title_Name)
|
|
{
|
|
case "RealTimeDataView":
|
|
page.DataContext = realTimeDataViewModel2;
|
|
break;
|
|
case "JunctionBoxEnvironDataView":
|
|
junctionBoxEnvironDataViewModel2.RefreshFile(obj);
|
|
page.DataContext = junctionBoxEnvironDataViewModel2;
|
|
break;
|
|
case "JunctionBoxStatusDataView":
|
|
page.DataContext = junctionBoxStatusDataViewModel2;
|
|
break;
|
|
//case "ShoreBaseStationStatusDataView":
|
|
// page.DataContext = shoreBaseStationStatusDataViewModel2;
|
|
// break;
|
|
case "SystemControlView":
|
|
|
|
break;
|
|
case "LogRecordView":
|
|
page.DataContext = logRecordViewModel2;
|
|
break;
|
|
case "AlarmRecordView":
|
|
page.DataContext = alarmRecordViewModel2;
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
else if (station_id == 3)
|
|
{
|
|
switch (Title_Name)
|
|
{
|
|
case "RealTimeDataView":
|
|
page.DataContext = realTimeDataViewModel3;
|
|
break;
|
|
case "JunctionBoxEnvironDataView":
|
|
junctionBoxEnvironDataViewModel3.RefreshFile(obj);
|
|
page.DataContext = junctionBoxEnvironDataViewModel3;
|
|
break;
|
|
case "JunctionBoxStatusDataView":
|
|
page.DataContext = junctionBoxStatusDataViewModel3;
|
|
break;
|
|
//case "ShoreBaseStationStatusDataView":
|
|
// page.DataContext = shoreBaseStationStatusDataViewModel3;
|
|
// break;
|
|
case "SystemControlView":
|
|
|
|
break;
|
|
case "LogRecordView":
|
|
page.DataContext = logRecordViewModel3;
|
|
break;
|
|
case "AlarmRecordView":
|
|
page.DataContext = alarmRecordViewModel3;
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
this.PageContent = page;
|
|
}
|
|
#endregion
|
|
|
|
}
|
|
}
|