1224 lines
69 KiB
C#
1224 lines
69 KiB
C#
using AutomaticApp.Base;
|
||
using AutomaticApp.Common;
|
||
using AutomaticApp.Controls;
|
||
using AutomaticApp.DataAccess;
|
||
using AutomaticApp.Model;
|
||
using AutomaticApp.Models;
|
||
using AutomaticApp.TestModels;
|
||
using AutomaticApp.Views;
|
||
using Communication;
|
||
using MySql.Data.MySqlClient;
|
||
using Org.BouncyCastle.Asn1.Mozilla;
|
||
using Org.BouncyCastle.Bcpg.OpenPgp;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Collections.ObjectModel;
|
||
using System.IO.Ports;
|
||
using System.Linq;
|
||
using System.Reflection;
|
||
using System.Text;
|
||
using System.Threading.Tasks;
|
||
using System.Windows;
|
||
using Ubiety.Dns.Core.Common;
|
||
using NotifyBase = AutomaticApp.Common.NotifyBase;
|
||
|
||
namespace AutomaticApp.ViewModels
|
||
{
|
||
/// <summary>
|
||
/// 主页面数据
|
||
/// </summary>
|
||
public class MainViewModel : NotifyBase
|
||
{
|
||
string sql = "";
|
||
|
||
#region 初始化DataContext
|
||
public static BuoystationModel buoystation1Model = new BuoystationModel();
|
||
public static BuoystationModel buoystation2Model = new BuoystationModel();
|
||
public static ConboxStationModel conboxStation1Model = new ConboxStationModel();
|
||
public static ConboxStationModel conboxStation2Model = new ConboxStationModel();
|
||
public static ControlPageViewModel CPV1 = new ControlPageViewModel();
|
||
public static ControlPageViewModel CPV2 = new ControlPageViewModel();
|
||
static public Switch_State SS1 = new Switch_State();
|
||
static public Switch_State SS2 = new Switch_State();
|
||
static public State_FeedBack SFB1 = new State_FeedBack();
|
||
static public State_FeedBack SFB2 = new State_FeedBack();
|
||
static public ParaSet PS1 = new ParaSet();
|
||
static public ParaSet PS2 = new ParaSet();
|
||
static public EarthQuakeParaSet EQPS1 = new EarthQuakeParaSet();
|
||
static public EarthQuakeParaSet EQPS2 = new EarthQuakeParaSet();
|
||
static public EarthquakeSensorModel EQSM1 = new EarthquakeSensorModel();
|
||
static public EarthquakeSensorModel EQSM2 = new EarthquakeSensorModel();
|
||
static public FTPModel ftp1 { get; set; } = new FTPModel() { IP = tools.GetAppSetting("PLC_IP1"), Port = Convert.ToInt32(tools.GetAppSetting("PLC_FTP_Port1")) };
|
||
static public FTPModel ftp2 { get; set; } = new FTPModel() { IP = tools.GetAppSetting("PLC_IP2"), Port = Convert.ToInt32(tools.GetAppSetting("PLC_FTP_Port2")) };
|
||
#endregion
|
||
private Switch_State ss;
|
||
|
||
public Switch_State SS
|
||
{
|
||
get { return ss; }
|
||
set { ss = value; this.DoNotify(); }
|
||
}
|
||
|
||
private ParaSet ps;
|
||
|
||
public ParaSet PS
|
||
{
|
||
get { return ps; }
|
||
set { ps = value; this.DoNotify(); }
|
||
}
|
||
|
||
private EarthQuakeParaSet eqps;
|
||
|
||
public EarthQuakeParaSet EQPS
|
||
{
|
||
get { return eqps; }
|
||
set { eqps = value; }
|
||
}
|
||
|
||
private EarthquakeSensorModel eqsm;
|
||
|
||
public EarthquakeSensorModel EQSM
|
||
{
|
||
get { return eqsm; }
|
||
set { eqsm = value; }
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 刷新下控制域的DataContext
|
||
/// </summary>
|
||
public void FlashControlPageDataContext()
|
||
{
|
||
if (station_id == 1)
|
||
{
|
||
SS = SS1;
|
||
PS = PS1;
|
||
EQPS = EQPS1;
|
||
EQSM = EQSM1;
|
||
}
|
||
else if (station_id == 2)
|
||
{
|
||
SS = SS2;
|
||
PS = PS2;
|
||
EQPS = EQPS2;
|
||
EQSM = EQSM2;
|
||
}
|
||
}
|
||
|
||
private FrameworkElement _pageContent;
|
||
|
||
public FrameworkElement PageContent
|
||
{
|
||
get { return _pageContent; }
|
||
set { _pageContent = value; this.DoNotify(); }
|
||
}
|
||
public int station_id { get; set; } = 1;
|
||
//int station_id = 1; //设置当前显示的站点号 1为1号站点 2为2号站点
|
||
public CommandBase NavChangedCommand { get; set; }
|
||
string Title_Name = ""; //设置当前显示的标题 1 浮标 2 接驳盒 3 系统控制 4 日志记录
|
||
public CommandBase ComDoConnectCommand { get; set; } //串口连接/断开操作
|
||
|
||
public CommandBase Socket1DoConnectCommand { get; set; } //客户端连接/断开操作
|
||
public CommandBase Socket2DoConnectCommand { get; set; } //客户端连接/断开操作
|
||
|
||
public CommandBase CommunicationChangedCommand { get; set; }//切换控制器的通信路径
|
||
|
||
#region 开关
|
||
public CommandBase Switch { set; get; }
|
||
public CommandBase ParaSetSwitch { set; get; } //系统参数设置按钮
|
||
#endregion
|
||
|
||
public ComModel comModel { get; set; } = new ComModel();
|
||
public ClientModel clientModel1 { get; set; } = new ClientModel();
|
||
public ClientModel clientModel2 { get; set; } = new ClientModel();
|
||
|
||
private NR_MsgModel nR_Msg = new NR_MsgModel();
|
||
private BD_MsgModel BD_Msg = new BD_MsgModel();
|
||
|
||
private string bDCountDown = "";
|
||
|
||
public string BDCountDown
|
||
{
|
||
get { return bDCountDown; }
|
||
set { bDCountDown = value; this.DoNotify(); }
|
||
}
|
||
|
||
private bool gridIsEnabled = true;
|
||
|
||
public bool GridIsEnabled
|
||
{
|
||
get { return gridIsEnabled; }
|
||
set { gridIsEnabled = value; this.DoNotify(); }
|
||
}
|
||
/// <summary>
|
||
/// 是否处于发送状态
|
||
/// </summary>
|
||
static bool isSending = false;
|
||
|
||
private Visibility vis = Visibility.Hidden;
|
||
/// <summary>
|
||
/// 按钮是否可见
|
||
/// </summary>
|
||
public Visibility visibility
|
||
{
|
||
get { return vis; }
|
||
set { vis = value; this.DoNotify(); }
|
||
}
|
||
|
||
/// <summary>
|
||
/// 待发送的数据队列
|
||
/// </summary>
|
||
public List<SendMessageList> sendMessageLists { get; set; } = new List<SendMessageList>();
|
||
|
||
|
||
|
||
public void AddsendMessageLists(string MessageContent, byte[] Message, int CommunicateChoose)
|
||
{
|
||
if (CommunicateChoose == 1)
|
||
{
|
||
if (sendMessageLists.Count < 5)
|
||
{
|
||
sendMessageLists.Add(new SendMessageList()
|
||
{
|
||
ID = sendMessageLists.Count + 1,
|
||
StationID = station_id,
|
||
MessageContent = MessageContent,
|
||
Message = Message,
|
||
SendState = "未发送"
|
||
});
|
||
}
|
||
else
|
||
{
|
||
EM.ControlMessage = "当前北斗发送数据队列已满,请稍后再试!!!";
|
||
return;
|
||
}
|
||
}
|
||
else if (CommunicateChoose == 2)
|
||
{
|
||
if (station_id == 1)
|
||
{
|
||
clientModel1.SendData(Message);
|
||
}
|
||
else if (station_id == 2)
|
||
{
|
||
clientModel2.SendData(Message);
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
|
||
public async Task<bool> BDCountDownCommand()
|
||
{
|
||
isSending = true;
|
||
bool isSend = true;
|
||
GridIsEnabled = false;
|
||
visibility = Visibility.Visible;//显示详情按钮
|
||
while (sendMessageLists.Count != 0)
|
||
{
|
||
isSend = comModel.SendMessage(sendMessageLists[0].Message);
|
||
sendMessageLists[0].SendState = "已发送";
|
||
int CountDown = 0;
|
||
if (isSend)
|
||
{
|
||
while (CountDown < 65)
|
||
{
|
||
for (int i = 0; i < sendMessageLists.Count; i++)
|
||
{
|
||
sendMessageLists[i].RemindTime = ((65 * i - CountDown) < 0) ? 0 : (65 * i - CountDown);
|
||
}
|
||
this.BDCountDown = string.Format("北斗短报文倒计时{0}秒,剩余{1}条数据未发送", (65 * sendMessageLists.Count - CountDown).ToString(), (sendMessageLists.Count - 1).ToString());
|
||
await Task.Delay(1000);
|
||
CountDown++;
|
||
}
|
||
}
|
||
//移除报文中的第一条
|
||
sendMessageLists.RemoveAt(0);
|
||
CountDown = 0;
|
||
}
|
||
//for (int i = 0; i < sendMessageLists.Count; i++)
|
||
//{
|
||
// isSend = comModel.SendMessage(sendMessageLists[0].Message);
|
||
// int CountDown = 0;
|
||
// if (isSend)
|
||
// {
|
||
// while (CountDown < 65)
|
||
// {
|
||
// this.BDCountDown = string.Format("北斗短报文倒计时{0}秒,剩余{1}条数据未发送", (65 * (sendMessageLists.Count - i) - CountDown).ToString(), (sendMessageLists.Count - i - 1).ToString());
|
||
// await Task.Delay(1000);
|
||
// CountDown++;
|
||
// }
|
||
// }
|
||
// //移除报文中的第一条
|
||
// sendMessageLists.RemoveAt(0);
|
||
// CountDown = 0;
|
||
//}
|
||
visibility = Visibility.Hidden;//隐藏详情按钮
|
||
GridIsEnabled = true;
|
||
sendMessageLists.Clear();
|
||
this.BDCountDown = "";
|
||
isSending = false;
|
||
return isSend;
|
||
}
|
||
|
||
|
||
|
||
|
||
public static ErrorMessageModel EM { get; set; } = new ErrorMessageModel();
|
||
public static SerialInfo SerialInfo { get; set; } = new SerialInfo() //初始化串口连接信息
|
||
{
|
||
PortName = tools.GetAppSetting("PortName"),
|
||
BaudRate = Convert.ToInt32(tools.GetAppSetting("BaudRate")),
|
||
DataBit = 8,
|
||
Parity = Parity.None,
|
||
StopBits = StopBits.One
|
||
};
|
||
public static SocketInfo SocketInfo1 { get; set; } = new SocketInfo() //PLC1连接信息
|
||
{
|
||
IP = tools.GetAppSetting("PLC_IP1"),
|
||
Port = Convert.ToInt32(tools.GetAppSetting("PLC_Service_Port1"))
|
||
};
|
||
public static SocketInfo SocketInfo2 { get; set; } = new SocketInfo() //PLC2连接信息
|
||
{
|
||
IP = tools.GetAppSetting("PLC_IP2"),
|
||
Port = Convert.ToInt32(tools.GetAppSetting("PLC_Service_Port2"))
|
||
};
|
||
public MainViewModel()
|
||
{
|
||
|
||
|
||
this.NavChangedCommand = new CommandBase();
|
||
this.NavChangedCommand.DoExcute = new Action<object>(DoNavChanged);
|
||
this.NavChangedCommand.DoCanExcute = new Func<object, bool>((o) => true);
|
||
|
||
this.ComDoConnectCommand = new CommandBase();
|
||
this.ComDoConnectCommand.DoExcute = new Action<object>(DoComConnect);
|
||
this.ComDoConnectCommand.DoCanExcute = new Func<object, bool>((o) => { return true; });
|
||
|
||
this.Socket1DoConnectCommand = new CommandBase();
|
||
this.Socket1DoConnectCommand.DoExcute = new Action<object>(DoSocket1Connect);
|
||
this.Socket1DoConnectCommand.DoCanExcute = new Func<object, bool>((o) => true);
|
||
|
||
this.Socket2DoConnectCommand = new CommandBase();
|
||
this.Socket2DoConnectCommand.DoExcute = new Action<object>(DoSocket2Connect);
|
||
this.Socket2DoConnectCommand.DoCanExcute = new Func<object, bool>((o) => true);
|
||
|
||
this.CommunicationChangedCommand = new CommandBase();
|
||
this.CommunicationChangedCommand.DoExcute = new Action<object>(CommunicationChanged);
|
||
this.CommunicationChangedCommand.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);
|
||
|
||
this.ParaSetSwitch = new CommandBase();
|
||
this.ParaSetSwitch.DoExcute = new Action<object>(Btn_ParaSet);
|
||
this.ParaSetSwitch.DoCanExcute = new Func<object, bool>((o) => true);
|
||
|
||
#region 初始化系统控制界面
|
||
//初始化系统控制界面
|
||
sql = string.Format("select * from paraset where StationID = {0} ORDER by id desc limit 1", 1);
|
||
MySqlDataReader reader = DBHelper.ExecuteReader(sql, 1);
|
||
while (reader.Read())
|
||
{
|
||
PS1.RecordTime = Convert.ToDateTime(reader["RecordTime"]);
|
||
PS1.DataTime = Convert.ToDateTime(reader["DataTime"]);
|
||
PS1.BDCycle = Convert.ToInt32(reader["BDCycle"]);
|
||
PS1.AirSpeedSet = Convert.ToInt32(reader["AirSpeedSet"]);
|
||
PS1.Attitude_angle_x = Convert.ToInt32(reader["Attitude_angle_x"]);
|
||
PS1.Attitude_angle_y = Convert.ToInt32(reader["Attitude_angle_y"]);
|
||
PS1.Attitude_angle_z = Convert.ToInt32(reader["Attitude_angle_z"]);
|
||
PS1.Automatic_control = reader["Automatic_control"].ToString();
|
||
PS1.System_control_mode = reader["System_control_mode"].ToString();
|
||
PS1.System_Communication_mode = reader["System_Communication_mode"].ToString();
|
||
}
|
||
reader.Dispose();
|
||
sql = string.Format("select * from paraset where StationID = {0} ORDER by id desc limit 1", 2);
|
||
reader = DBHelper.ExecuteReader(sql, 1);
|
||
while (reader.Read())
|
||
{
|
||
PS2.RecordTime = Convert.ToDateTime(reader["RecordTime"]);
|
||
PS2.DataTime = Convert.ToDateTime(reader["DataTime"]);
|
||
PS2.BDCycle = Convert.ToInt32(reader["BDCycle"]);
|
||
PS2.AirSpeedSet = Convert.ToInt32(reader["AirSpeedSet"]);
|
||
PS2.Attitude_angle_x = Convert.ToInt32(reader["Attitude_angle_x"]);
|
||
PS2.Attitude_angle_y = Convert.ToInt32(reader["Attitude_angle_y"]);
|
||
PS2.Attitude_angle_z = Convert.ToInt32(reader["Attitude_angle_z"]);
|
||
PS2.Automatic_control = reader["Automatic_control"].ToString();
|
||
PS2.System_control_mode = reader["System_control_mode"].ToString();
|
||
PS2.System_Communication_mode = reader["System_Communication_mode"].ToString();
|
||
}
|
||
reader.Dispose();
|
||
sql = String.Format("select * from EarthQuakeParaSet where StationID = {0} ORDER by id desc limit 1", 1);
|
||
reader = DBHelper.ExecuteReader(sql, 1);
|
||
while (reader.Read())
|
||
{
|
||
EQPS1.RecordTime = Convert.ToDateTime(reader["RecordTime"]);
|
||
EQPS1.DataTime = Convert.ToDateTime(reader["DataTime"]);
|
||
EQPS1.StationNo = Convert.ToInt32(reader["StationNo"]);
|
||
EQPS1.StationName = reader["StationName"].ToString();
|
||
EQPS1.StationShortName = reader["StationShortName"].ToString();
|
||
EQPS1.EarthQuakeCount = Convert.ToInt16(reader["EarthQuakeCount"]);
|
||
EQPS1.ChannelsNo = Convert.ToInt16(reader["ChannelsNo"]);
|
||
EQPS1.WD = Convert.ToInt32(reader["WD"]);
|
||
EQPS1.JD = Convert.ToInt32(reader["JD"]);
|
||
EQPS1.GaoCheng = Convert.ToInt32(reader["GaoCheng"]);
|
||
EQPS1.StartTime = reader["StartTime"].ToString();
|
||
EQPS1.Station_Id = reader["Station_Id"].ToString();
|
||
EQPS1.Software_Version = reader["Software_Version"].ToString();
|
||
|
||
}
|
||
reader.Dispose();
|
||
sql = String.Format("select * from EarthQuakeParaSet where StationID = {0} ORDER by id desc limit 1", 2);
|
||
reader = DBHelper.ExecuteReader(sql, 1);
|
||
while (reader.Read())
|
||
{
|
||
EQPS2.RecordTime = Convert.ToDateTime(reader["RecordTime"]);
|
||
EQPS2.DataTime = Convert.ToDateTime(reader["DataTime"]);
|
||
EQPS2.StationNo = Convert.ToInt32(reader["StationNo"]);
|
||
EQPS2.StationName = reader["StationName"].ToString();
|
||
EQPS2.StationShortName = reader["StationShortName"].ToString();
|
||
EQPS2.EarthQuakeCount = Convert.ToInt16(reader["EarthQuakeCount"]);
|
||
EQPS2.ChannelsNo = Convert.ToInt16(reader["ChannelsNo"]);
|
||
EQPS2.WD = Convert.ToInt32(reader["WD"]);
|
||
EQPS2.JD = Convert.ToInt32(reader["JD"]);
|
||
EQPS2.GaoCheng = Convert.ToInt32(reader["GaoCheng"]);
|
||
EQPS2.StartTime = reader["StartTime"].ToString();
|
||
EQPS2.Station_Id = reader["Station_Id"].ToString();
|
||
EQPS2.Software_Version = reader["Software_Version"].ToString();
|
||
|
||
}
|
||
reader.Dispose();
|
||
sql = String.Format("select * from alarminfohis where StationID = {0} ORDER by id desc limit 7", 1);
|
||
reader = DBHelper.ExecuteReader(sql, 1);
|
||
while (reader.Read())
|
||
{
|
||
|
||
AlarmInfo alarmInfo = new AlarmInfo();
|
||
alarmInfo.StationID = Convert.ToInt32(reader["StationID"]);
|
||
alarmInfo.RecordTime = Convert.ToDateTime(reader["RecordTime"]);
|
||
alarmInfo.DataTime = Convert.ToDateTime(reader["DataTime"]);
|
||
alarmInfo.ParaName = reader["ParaName"].ToString();
|
||
alarmInfo.IsHandled = Convert.ToInt32(reader["IsHandled"]);
|
||
if (reader["ParaState"].ToString().Contains("电压欠压") || reader["ParaState"].ToString().Contains("电压过压"))
|
||
{
|
||
alarmInfo.ParaState = reader["ParaState"].ToString() + "V";
|
||
}
|
||
else if (reader["ParaState"].ToString().Contains("电流过流"))
|
||
{
|
||
alarmInfo.ParaState = reader["ParaState"].ToString() + "A";
|
||
}
|
||
else
|
||
{
|
||
string[] arr = reader["ParaState"].ToString().Split(',');
|
||
for (int i = 0; i < arr.Length; i++)
|
||
{
|
||
alarmInfo.ParaState = arr[0].ToString();
|
||
}
|
||
}
|
||
buoystation1Model.AlarmList.Add(alarmInfo);
|
||
}
|
||
reader.Dispose();
|
||
sql = String.Format("select * from alarminfohis where StationID = {0} ORDER by id desc limit 7", 2);
|
||
reader = DBHelper.ExecuteReader(sql, 1);
|
||
while (reader.Read())
|
||
{
|
||
AlarmInfo alarmInfo = new AlarmInfo();
|
||
alarmInfo.StationID = Convert.ToInt32(reader["StationID"]);
|
||
alarmInfo.RecordTime = Convert.ToDateTime(reader["RecordTime"]);
|
||
alarmInfo.DataTime = Convert.ToDateTime(reader["DataTime"]);
|
||
alarmInfo.ParaName = reader["ParaName"].ToString();
|
||
alarmInfo.IsHandled = Convert.ToInt32(reader["IsHandled"]);
|
||
if (reader["ParaState"].ToString().Contains("电压欠压") || reader["ParaState"].ToString().Contains("电压过压"))
|
||
{
|
||
alarmInfo.ParaState = reader["ParaState"].ToString() + "V";
|
||
}
|
||
else if (reader["ParaState"].ToString().Contains("电流过流"))
|
||
{
|
||
alarmInfo.ParaState = reader["ParaState"].ToString() + "A";
|
||
}
|
||
else
|
||
{
|
||
string[] arr = reader["ParaState"].ToString().Split(',');
|
||
for (int i = 0; i < arr.Length; i++)
|
||
{
|
||
alarmInfo.ParaState = arr[0].ToString();
|
||
}
|
||
}
|
||
buoystation2Model.AlarmList.Add(alarmInfo);
|
||
}
|
||
reader.Dispose();
|
||
sql = String.Format("select * from switch_state where StationID = {0} ORDER by id desc limit 1", 1);
|
||
reader = DBHelper.ExecuteReader(sql, 1);
|
||
while (reader.Read())
|
||
{
|
||
SS1.Conbox_ADCP = reader["Conbox_ADCP"].ToString() == "打开" ? true : false;
|
||
SS1.JBH_SEI2 = reader["JBH_SEI2"].ToString() == "打开" ? true : false;
|
||
SS1.JBH_SEI1 = reader["JBH_SEI1"].ToString() == "打开" ? true : false;
|
||
SS1.JBH_Switch = reader["JBH_Switch"].ToString() == "打开" ? true : false;
|
||
SS1.JBH_DSL = reader["JBH_DSL"].ToString() == "打开" ? true : false;
|
||
SS1.FB_Switch = reader["FB_Switch"].ToString() == "打开" ? true : false;
|
||
SS1.FB_DSL = reader["FB_DSL"].ToString() == "打开" ? true : false;
|
||
SS1.FB_Antenna = reader["FB_Antenna"].ToString() == "打开" ? true : false;
|
||
SS1.FB_BD = reader["FB_BD"].ToString() == "打开" ? true : false;
|
||
SS1.ConboxPower1 = reader["ConboxPower1"].ToString() == "打开" ? true : false;
|
||
SS1.ConboxPower2 = reader["ConboxPower2"].ToString() == "打开" ? true : false;
|
||
}
|
||
reader.Dispose();
|
||
sql = String.Format("select * from switch_state where StationID = {0} ORDER by id desc limit 1", 2);
|
||
reader = DBHelper.ExecuteReader(sql, 1);
|
||
while (reader.Read())
|
||
{
|
||
SS2.Conbox_ADCP = reader["Conbox_ADCP"].ToString() == "打开" ? true : false;
|
||
SS2.JBH_SEI2 = reader["JBH_SEI2"].ToString() == "打开" ? true : false;
|
||
SS2.JBH_SEI1 = reader["JBH_SEI1"].ToString() == "打开" ? true : false;
|
||
SS2.JBH_Switch = reader["JBH_Switch"].ToString() == "打开" ? true : false;
|
||
SS2.JBH_DSL = reader["JBH_DSL"].ToString() == "打开" ? true : false;
|
||
SS2.FB_Switch = reader["FB_Switch"].ToString() == "打开" ? true : false;
|
||
SS2.FB_DSL = reader["FB_DSL"].ToString() == "打开" ? true : false;
|
||
SS2.FB_Antenna = reader["FB_Antenna"].ToString() == "打开" ? true : false;
|
||
SS2.FB_BD = reader["FB_BD"].ToString() == "打开" ? true : false;
|
||
SS2.ConboxPower1 = reader["ConboxPower1"].ToString() == "打开" ? true : false;
|
||
SS2.ConboxPower2 = reader["ConboxPower2"].ToString() == "打开" ? true : false;
|
||
}
|
||
reader.Dispose();
|
||
sql = String.Format("select * from buoyenvpara where StationID = {0} ORDER by id desc limit 1", 1);
|
||
reader = DBHelper.ExecuteReader(sql, 1);
|
||
while (reader.Read())
|
||
{
|
||
buoystation1Model.buoyEnvironmentModel.RecordTime = Convert.ToDateTime(reader["RecordTime"]);
|
||
buoystation1Model.BuoyEvironment1[0].Value = Convert.IsDBNull(reader["FB_Tem"]) ? "0.00" : Convert.ToString(reader["FB_Tem"]);
|
||
buoystation1Model.BuoyEvironment1[1].Value = Convert.IsDBNull(reader["FB_Hum"]) ? "0.00" : Convert.ToString(reader["FB_Hum"]);
|
||
buoystation1Model.BuoyEvironment1[2].Value = Convert.IsDBNull(reader["FB_Smoke"]) ? "0.00" : Convert.ToString(reader["FB_Smoke"]);
|
||
//buoystation1Model.BuoyEvironment1[3].Value = Convert.IsDBNull(reader["FB_Attitude_x"]) ? 0 : Convert.ToSingle(reader["FB_Attitude_x"]);
|
||
//buoystation1Model.BuoyEvironment1[4].Value = Convert.IsDBNull(reader["FB_Attitude_y"]) ? 0 : Convert.ToSingle(reader["FB_Attitude_y"]);
|
||
//buoystation1Model.BuoyEvironment1[5].Value = Convert.IsDBNull(reader["FB_Attitude_z"]) ? 0 : Convert.ToSingle(reader["FB_Attitude_z"]);
|
||
buoystation1Model.BuoyEvironment1[6].Value = Convert.IsDBNull(reader["WD"]) ? "0.00" : Convert.ToString(reader["WD"]);
|
||
buoystation1Model.BuoyEvironment1[7].Value = Convert.IsDBNull(reader["JD"]) ? "0.00" : Convert.ToString(reader["JD"]);
|
||
buoystation1Model.BuoyEvironment1[8].Value = Convert.ToBoolean(reader["FB_Leak1"]) ? "否" : "是";
|
||
buoystation1Model.BuoyEvironment1[9].Value = Convert.ToBoolean(reader["Hatch_Status"]) ? "关闭" : "打开";
|
||
|
||
buoystation1Model.BuoyEvironment2[0].Value = Convert.IsDBNull(reader["Battery_Vol"]) ? "0.00" : Convert.ToString(reader["Battery_Vol"]);
|
||
buoystation1Model.BuoyEvironment2[1].Value = Convert.IsDBNull(reader["Charging_Cur"]) ? "0.00" : Convert.ToString(reader["Charging_Cur"]);
|
||
buoystation1Model.BuoyEvironment2[2].Value = Convert.IsDBNull(reader["Battery_Vol"]) ? "0.00" : Convert.ToString(reader["Battery_Vol"]);
|
||
buoystation1Model.BuoyEvironment2[3].Value = Convert.IsDBNull(reader["Remaining_Power"]) ? "0.00" : Convert.ToString(reader["Remaining_Power"]);
|
||
buoystation1Model.BuoyEvironment2[4].Value = Convert.IsDBNull(reader["Load_Vol"]) ? "0.00" : Convert.ToString(reader["Load_Vol"]);
|
||
buoystation1Model.BuoyEvironment2[5].Value = Convert.IsDBNull(reader["Load_Cur"]) ? "0.00" : Convert.ToString(reader["Load_Cur"]);
|
||
buoystation1Model.BuoyEvironment2[6].Value = Convert.IsDBNull(reader["Antenna_Vol"]) ? "0.00" : Convert.ToString(reader["Antenna_Vol"]);
|
||
buoystation1Model.BuoyEvironment2[7].Value = Convert.IsDBNull(reader["BD_Vol"]) ? "0.00" : Convert.ToString(reader["BD_Vol"]);
|
||
buoystation1Model.BuoyEvironment2[8].Value = Convert.IsDBNull(reader["AIS_Vol"]) ? "0.00" : Convert.ToString(reader["AIS_Vol"]);
|
||
|
||
}
|
||
reader.Dispose();
|
||
sql = String.Format("select * from buoyenvpara where StationID = {0} ORDER by id desc limit 1", 2);
|
||
reader = DBHelper.ExecuteReader(sql, 1);
|
||
while (reader.Read())
|
||
{
|
||
buoystation2Model.buoyEnvironmentModel.RecordTime = Convert.ToDateTime(reader["RecordTime"]);
|
||
buoystation2Model.BuoyEvironment1[0].Value = Convert.IsDBNull(reader["FB_Tem"]) ? "0.00" : Convert.ToString(reader["FB_Tem"]);
|
||
buoystation2Model.BuoyEvironment1[1].Value = Convert.IsDBNull(reader["FB_Hum"]) ? "0.00" : Convert.ToString(reader["FB_Hum"]);
|
||
buoystation2Model.BuoyEvironment1[2].Value = Convert.IsDBNull(reader["FB_Smoke"]) ? "0.00" : Convert.ToString(reader["FB_Smoke"]);
|
||
//buoystation2Model.BuoyEvironment1[3].Value = Convert.IsDBNull(reader["FB_Attitude_x"]) ? 0 : Convert.ToSingle(reader["FB_Attitude_x"]);
|
||
//buoystation2Model.BuoyEvironment1[4].Value = Convert.IsDBNull(reader["FB_Attitude_y"]) ? 0 : Convert.ToSingle(reader["FB_Attitude_y"]);
|
||
//buoystation2Model.BuoyEvironment1[5].Value = Convert.IsDBNull(reader["FB_Attitude_z"]) ? 0 : Convert.ToSingle(reader["FB_Attitude_z"]);
|
||
buoystation2Model.BuoyEvironment1[6].Value = Convert.IsDBNull(reader["WD"]) ? "0.00" : Convert.ToString(reader["WD"]);
|
||
buoystation2Model.BuoyEvironment1[7].Value = Convert.IsDBNull(reader["JD"]) ? "0.00" : Convert.ToString(reader["JD"]);
|
||
buoystation2Model.BuoyEvironment1[8].Value = Convert.ToBoolean(reader["FB_Leak1"]) ? "否" : "是";
|
||
buoystation2Model.BuoyEvironment1[9].Value = Convert.ToBoolean(reader["Hatch_Status"]) ? "关闭" : "打开";
|
||
|
||
buoystation2Model.BuoyEvironment2[0].Value = Convert.IsDBNull(reader["Battery_Vol"]) ? "0.00" : Convert.ToString(reader["Battery_Vol"]);
|
||
buoystation2Model.BuoyEvironment2[1].Value = Convert.IsDBNull(reader["Charging_Cur"]) ? "0.00" : Convert.ToString(reader["Charging_Cur"]);
|
||
buoystation2Model.BuoyEvironment2[2].Value = Convert.IsDBNull(reader["Battery_Vol"]) ? "0.00" : Convert.ToString(reader["Battery_Vol"]);
|
||
buoystation2Model.BuoyEvironment2[3].Value = Convert.IsDBNull(reader["Remaining_Power"]) ? "0.00" : Convert.ToString(reader["Remaining_Power"]);
|
||
buoystation2Model.BuoyEvironment2[4].Value = Convert.IsDBNull(reader["Load_Vol"]) ? "0.00" : Convert.ToString(reader["Load_Vol"]);
|
||
buoystation2Model.BuoyEvironment2[5].Value = Convert.IsDBNull(reader["Load_Cur"]) ? "0.00" : Convert.ToString(reader["Load_Cur"]);
|
||
buoystation2Model.BuoyEvironment2[6].Value = Convert.IsDBNull(reader["Antenna_Vol"]) ? "0.00" : Convert.ToString(reader["Antenna_Vol"]);
|
||
buoystation2Model.BuoyEvironment2[7].Value = Convert.IsDBNull(reader["BD_Vol"]) ? "0.00" : Convert.ToString(reader["BD_Vol"]);
|
||
buoystation2Model.BuoyEvironment2[8].Value = Convert.IsDBNull(reader["AIS_Vol"]) ? "0.00" : Convert.ToString(reader["AIS_Vol"]);
|
||
}
|
||
reader.Dispose();
|
||
|
||
|
||
sql = String.Format("select * from special_posture where StationID = {0} ORDER by id desc limit 1", 1);
|
||
reader = DBHelper.ExecuteReader(sql, 1);
|
||
while (reader.Read())
|
||
{
|
||
buoystation1Model.buoyEnvironmentModel.FB_Attitude_x = Convert.IsDBNull(reader["X"]) ? 0 : Convert.ToSingle(reader["X"]);
|
||
buoystation1Model.buoyEnvironmentModel.FB_Attitude_y = Convert.IsDBNull(reader["Y"]) ? 0 : Convert.ToSingle(reader["Y"]);
|
||
buoystation1Model.buoyEnvironmentModel.FB_Attitude_z = Convert.IsDBNull(reader["Z"]) ? 0 : Convert.ToSingle(reader["Z"]);
|
||
buoystation1Model.BuoyEvironment1[3].Value = Convert.IsDBNull(reader["X"]) ? "0.00" : Convert.ToString(reader["X"]);
|
||
buoystation1Model.BuoyEvironment1[4].Value = Convert.IsDBNull(reader["Y"]) ? "0.00" : Convert.ToString(reader["Y"]);
|
||
buoystation1Model.BuoyEvironment1[5].Value = Convert.IsDBNull(reader["Z"]) ? "0.00" : Convert.ToString(reader["Z"]);
|
||
|
||
}
|
||
reader.Dispose();
|
||
|
||
sql = String.Format("select * from special_posture where StationID = {0} ORDER by id desc limit 1", 1);
|
||
reader = DBHelper.ExecuteReader(sql, 1);
|
||
while (reader.Read())
|
||
{
|
||
buoystation2Model.buoyEnvironmentModel.FB_Attitude_x = Convert.IsDBNull(reader["X"]) ? 0 : Convert.ToSingle(reader["X"]);
|
||
buoystation2Model.buoyEnvironmentModel.FB_Attitude_y = Convert.IsDBNull(reader["Y"]) ? 0 : Convert.ToSingle(reader["Y"]);
|
||
buoystation2Model.buoyEnvironmentModel.FB_Attitude_z = Convert.IsDBNull(reader["Z"]) ? 0 : Convert.ToSingle(reader["Z"]);
|
||
buoystation2Model.BuoyEvironment1[3].Value = Convert.IsDBNull(reader["X"]) ? "0.00" : Convert.ToString(reader["X"]);
|
||
buoystation2Model.BuoyEvironment1[4].Value = Convert.IsDBNull(reader["Y"]) ? "0.00" : Convert.ToString(reader["Y"]);
|
||
buoystation2Model.BuoyEvironment1[5].Value = Convert.IsDBNull(reader["Z"]) ? "0.00" : Convert.ToString(reader["Z"]);
|
||
}
|
||
reader.Dispose();
|
||
|
||
|
||
sql = String.Format("select RecordTime,Air_Speed,Air_Wind_Dir,Air_Speed_Max,Air_Wind_Dir_Max from buoyweatherpara where StationID = {0} ORDER by id desc limit 1", 1);
|
||
reader = DBHelper.ExecuteReader(sql, 1);
|
||
while (reader.Read())
|
||
{
|
||
buoystation1Model.weatherSensorModel.RecordTime = Convert.ToDateTime(reader["RecordTime"]);
|
||
buoystation1Model.BuoyEvironment1[10].Value = Convert.IsDBNull(reader["Air_Speed"]) ? "0.00" : Convert.ToString(reader["Air_Speed"]);
|
||
buoystation1Model.BuoyEvironment1[11].Value = Convert.IsDBNull(reader["Air_Wind_Dir"]) ? "0.00" : Convert.ToString(reader["Air_Wind_Dir"]);
|
||
|
||
buoystation1Model.BuoyEvironment2[9].Value = Convert.IsDBNull(reader["Air_Speed_Max"]) ? "0.00" : Convert.ToString(reader["Air_Speed_Max"]);
|
||
buoystation1Model.BuoyEvironment2[10].Value = Convert.IsDBNull(reader["Air_Wind_Dir_Max"]) ? "0.00" : Convert.ToString(reader["Air_Wind_Dir_Max"]);
|
||
}
|
||
reader.Dispose();
|
||
|
||
sql = String.Format("select RecordTime,Air_Speed,Air_Wind_Dir,Air_Speed_Max,Air_Wind_Dir_Max from buoyweatherpara where StationID = {0} ORDER by id desc limit 1", 2);
|
||
reader = DBHelper.ExecuteReader(sql, 1);
|
||
while (reader.Read())
|
||
{
|
||
buoystation2Model.weatherSensorModel.RecordTime = Convert.ToDateTime(reader["RecordTime"]);
|
||
buoystation2Model.BuoyEvironment1[10].Value = Convert.IsDBNull(reader["Air_Speed"]) ? "0.00" : Convert.ToString(reader["Air_Speed"]);
|
||
buoystation2Model.BuoyEvironment1[11].Value = Convert.IsDBNull(reader["Air_Wind_Dir"]) ? "0.00" : Convert.ToString(reader["Air_Wind_Dir"]);
|
||
|
||
buoystation2Model.BuoyEvironment2[9].Value = Convert.IsDBNull(reader["Air_Speed_Max"]) ? "0.00" : Convert.ToString(reader["Air_Speed_Max"]);
|
||
buoystation2Model.BuoyEvironment2[10].Value = Convert.IsDBNull(reader["Air_Wind_Dir_Max"]) ? "0.00" : Convert.ToString(reader["Air_Wind_Dir_Max"]);
|
||
}
|
||
reader.Dispose();
|
||
|
||
sql = String.Format("select RecordTime,Air_Temperture,Air_Hum,Air_Rainfall,Air_Pressure from buoyweatherpara where StationID = {0} ORDER by id desc limit {1}", 1, Convert.ToInt32(tools.GetAppSetting("Chart_Limit")));
|
||
reader = DBHelper.ExecuteReader(sql, 1);
|
||
while (reader.Read())
|
||
{
|
||
if (!Convert.IsDBNull(reader["Air_Temperture"]))
|
||
{
|
||
buoystation1Model.weatherSensorModel.Siancharts.Values.Add(Convert.ToSingle(reader["Air_Temperture"]));
|
||
buoystation1Model.weatherSensorModel.Siancharts.X_Time.Add(Convert.ToDateTime(reader["RecordTime"]).ToShortTimeString());
|
||
}
|
||
if (!Convert.IsDBNull(reader["Air_Hum"]))
|
||
{
|
||
buoystation1Model.weatherSensorModel.Humcharts.Values.Add(Convert.ToSingle(reader["Air_Hum"]));
|
||
buoystation1Model.weatherSensorModel.Humcharts.X_Time.Add(Convert.ToDateTime(reader["RecordTime"]).ToShortTimeString());
|
||
}
|
||
if (!Convert.IsDBNull(reader["Air_Rainfall"]))
|
||
{
|
||
buoystation1Model.weatherSensorModel.AirRainfall.Values.Add(Convert.ToSingle(reader["Air_Rainfall"]));
|
||
buoystation1Model.weatherSensorModel.AirRainfall.X_Time.Add(Convert.ToDateTime(reader["RecordTime"]).ToShortTimeString());
|
||
}
|
||
if (!Convert.IsDBNull(reader["Air_Pressure"]))
|
||
{
|
||
buoystation1Model.weatherSensorModel.AirPressure.Values.Add(Convert.ToSingle(reader["Air_Pressure"]));
|
||
buoystation1Model.weatherSensorModel.AirPressure.X_Time.Add(Convert.ToDateTime(reader["RecordTime"]).ToShortTimeString());
|
||
}
|
||
}
|
||
reader.Dispose();
|
||
|
||
sql = String.Format("select RecordTime,Air_Temperture,Air_Hum,Air_Rainfall,Air_Pressure from buoyweatherpara where StationID = {0} ORDER by id desc limit {1}", 2, Convert.ToInt32(tools.GetAppSetting("Chart_Limit")));
|
||
reader = DBHelper.ExecuteReader(sql, 1);
|
||
while (reader.Read())
|
||
{
|
||
if (!Convert.IsDBNull(reader["Air_Temperture"]))
|
||
{
|
||
buoystation2Model.weatherSensorModel.Siancharts.Values.Add(Convert.ToSingle(reader["Air_Temperture"]));
|
||
buoystation2Model.weatherSensorModel.Siancharts.X_Time.Add(Convert.ToDateTime(reader["RecordTime"]).ToShortTimeString());
|
||
}
|
||
if (!Convert.IsDBNull(reader["Air_Hum"]))
|
||
{
|
||
buoystation2Model.weatherSensorModel.Humcharts.Values.Add(Convert.ToSingle(reader["Air_Hum"]));
|
||
buoystation2Model.weatherSensorModel.Humcharts.X_Time.Add(Convert.ToDateTime(reader["RecordTime"]).ToShortTimeString());
|
||
}
|
||
if (!Convert.IsDBNull(reader["Air_Rainfall"]))
|
||
{
|
||
buoystation2Model.weatherSensorModel.AirRainfall.Values.Add(Convert.ToSingle(reader["Air_Rainfall"]));
|
||
buoystation2Model.weatherSensorModel.AirRainfall.X_Time.Add(Convert.ToDateTime(reader["RecordTime"]).ToShortTimeString());
|
||
}
|
||
if (!Convert.IsDBNull(reader["Air_Pressure"]))
|
||
{
|
||
buoystation2Model.weatherSensorModel.AirPressure.Values.Add(Convert.ToSingle(reader["Air_Pressure"]));
|
||
buoystation2Model.weatherSensorModel.AirPressure.X_Time.Add(Convert.ToDateTime(reader["RecordTime"]).ToShortTimeString());
|
||
}
|
||
}
|
||
reader.Dispose();
|
||
|
||
sql = String.Format("select * from conboxenvpara where StationID = {0} ORDER by id desc limit 1", 1);
|
||
reader = DBHelper.ExecuteReader(sql, 1);
|
||
while (reader.Read())
|
||
{
|
||
conboxStation1Model.conboxEnvironmentModel.RecordTime = Convert.ToDateTime(reader["RecordTime"]);
|
||
conboxStation1Model.ConboxEvironment1[0].Value = Convert.IsDBNull(reader["In_Vol"]) ? "0.00" : Convert.ToString(reader["In_Vol"]);
|
||
conboxStation1Model.ConboxEvironment1[1].Value = Convert.IsDBNull(reader["In_Cur"]) ? "0.00" : Convert.ToString(reader["In_Cur"]);
|
||
conboxStation1Model.conboxEnvironmentModel.JBH_Attitude_x = Convert.IsDBNull(reader["JBH_Attitude_x"]) ? 0 : Convert.ToSingle(reader["JBH_Attitude_x"]);
|
||
conboxStation1Model.conboxEnvironmentModel.JBH_Attitude_y = Convert.IsDBNull(reader["JBH_Attitude_y"]) ? 0 : Convert.ToSingle(reader["JBH_Attitude_y"]);
|
||
conboxStation1Model.conboxEnvironmentModel.JBH_Attitude_z = Convert.IsDBNull(reader["JBH_Attitude_z"]) ? 0 : Convert.ToSingle(reader["JBH_Attitude_z"]);
|
||
|
||
conboxStation1Model.ConboxEvironment1[2].Value = Convert.IsDBNull(reader["JBH_Attitude_x"]) ? "0.00" : Convert.ToString(reader["JBH_Attitude_x"]);
|
||
conboxStation1Model.ConboxEvironment1[3].Value = Convert.IsDBNull(reader["JBH_Attitude_y"]) ? "0.00" : Convert.ToString(reader["JBH_Attitude_y"]);
|
||
conboxStation1Model.ConboxEvironment1[4].Value = Convert.IsDBNull(reader["JBH_Attitude_z"]) ? "0.00" : Convert.ToString(reader["JBH_Attitude_z"]);
|
||
|
||
conboxStation1Model.ConboxEvironment2[0].Value = Convert.IsDBNull(reader["JBH_PowerCarrier_Cur"]) ? "0.00" : Convert.ToString(reader["JBH_PowerCarrier_Cur"]);
|
||
conboxStation1Model.ConboxEvironment2[1].Value = Convert.ToBoolean(reader["JBH_Leak"]) ? "是" : "否";
|
||
conboxStation1Model.ConboxEvironment2[2].Value = Convert.ToBoolean(reader["Hatch_Status"]) ? "打开" : "关闭";
|
||
conboxStation1Model.ConboxEvironment2[3].Value = Convert.IsDBNull(reader["JBH_Reserve1"]) ? "0.00" : Convert.ToString(reader["JBH_Reserve1"]);
|
||
conboxStation1Model.ConboxEvironment2[4].Value = Convert.IsDBNull(reader["JBH_Reserve2"]) ? "0.00" : Convert.ToString(reader["JBH_Reserve2"]);
|
||
}
|
||
reader.Dispose();
|
||
|
||
sql = String.Format("select * from conboxenvpara where StationID = {0} ORDER by id desc limit 1", 2);
|
||
reader = DBHelper.ExecuteReader(sql, 1);
|
||
while (reader.Read())
|
||
{
|
||
conboxStation2Model.conboxEnvironmentModel.RecordTime = Convert.ToDateTime(reader["RecordTime"]);
|
||
conboxStation2Model.ConboxEvironment1[0].Value = Convert.IsDBNull(reader["In_Vol"]) ? "0.00" : Convert.ToString(reader["In_Vol"]);
|
||
conboxStation2Model.ConboxEvironment1[1].Value = Convert.IsDBNull(reader["In_Cur"]) ? "0.00" : Convert.ToString(reader["In_Cur"]);
|
||
conboxStation2Model.conboxEnvironmentModel.JBH_Attitude_x = Convert.IsDBNull(reader["JBH_Attitude_x"]) ? 0 : Convert.ToSingle(reader["JBH_Attitude_x"]);
|
||
conboxStation2Model.conboxEnvironmentModel.JBH_Attitude_y = Convert.IsDBNull(reader["JBH_Attitude_y"]) ? 0 : Convert.ToSingle(reader["JBH_Attitude_y"]);
|
||
conboxStation2Model.conboxEnvironmentModel.JBH_Attitude_z = Convert.IsDBNull(reader["JBH_Attitude_z"]) ? 0 : Convert.ToSingle(reader["JBH_Attitude_z"]);
|
||
|
||
conboxStation2Model.ConboxEvironment1[2].Value = Convert.IsDBNull(reader["JBH_Attitude_x"]) ? "0.00" : Convert.ToString(reader["JBH_Attitude_x"]);
|
||
conboxStation2Model.ConboxEvironment1[3].Value = Convert.IsDBNull(reader["JBH_Attitude_y"]) ? "0.00" : Convert.ToString(reader["JBH_Attitude_y"]);
|
||
conboxStation2Model.ConboxEvironment1[4].Value = Convert.IsDBNull(reader["JBH_Attitude_z"]) ? "0.00" : Convert.ToString(reader["JBH_Attitude_z"]);
|
||
|
||
conboxStation2Model.ConboxEvironment2[0].Value = Convert.IsDBNull(reader["JBH_PowerCarrier_Cur"]) ? "0.00" : Convert.ToString(reader["JBH_PowerCarrier_Cur"]);
|
||
conboxStation2Model.ConboxEvironment2[1].Value = Convert.ToBoolean(reader["JBH_Leak"]) ? "是" : "否";
|
||
conboxStation2Model.ConboxEvironment2[2].Value = Convert.ToBoolean(reader["Hatch_Status"]) ? "打开" : "关闭";
|
||
conboxStation2Model.ConboxEvironment2[3].Value = Convert.IsDBNull(reader["JBH_Reserve1"]) ? "0.00" : Convert.ToString(reader["JBH_Reserve1"]);
|
||
conboxStation2Model.ConboxEvironment2[4].Value = Convert.IsDBNull(reader["JBH_Reserve2"]) ? "0.00" : Convert.ToString(reader["JBH_Reserve2"]);
|
||
|
||
|
||
//conboxStation2Model.conboxEnvironmentModel.In_Vol = Convert.IsDBNull(reader["In_Vol"]) ? 0 : Convert.ToSingle(reader["In_Vol"]);
|
||
//conboxStation2Model.conboxEnvironmentModel.In_Cur = Convert.IsDBNull(reader["In_Cur"]) ? 0 : Convert.ToSingle(reader["In_Cur"]);
|
||
//conboxStation2Model.conboxEnvironmentModel.JBH_Attitude_x = Convert.IsDBNull(reader["JBH_Attitude_x"]) ? 0 : Convert.ToSingle(reader["JBH_Attitude_x"]);
|
||
//conboxStation2Model.conboxEnvironmentModel.JBH_Attitude_y = Convert.IsDBNull(reader["JBH_Attitude_y"]) ? 0 : Convert.ToSingle(reader["JBH_Attitude_y"]);
|
||
//conboxStation2Model.conboxEnvironmentModel.JBH_Attitude_z = Convert.IsDBNull(reader["JBH_Attitude_z"]) ? 0 : Convert.ToSingle(reader["JBH_Attitude_z"]);
|
||
|
||
//conboxStation2Model.conboxEnvironmentModel.JBH_PowerCarrier_Cur = Convert.IsDBNull(reader["JBH_PowerCarrier_Cur"]) ? 0 : Convert.ToSingle(reader["JBH_PowerCarrier_Cur"]);
|
||
//conboxStation2Model.conboxEnvironmentModel.JBH_Leak = Convert.IsDBNull(reader["JBH_Leak"]) ? 0 : Convert.ToSingle(reader["JBH_Leak"]);
|
||
//conboxStation2Model.conboxEnvironmentModel.Hatch_Status = Convert.IsDBNull(reader["Hatch_Status"]) ? 0 : Convert.ToSingle(reader["Hatch_Status"]);
|
||
//conboxStation2Model.conboxEnvironmentModel.JBH_Reserve1 = Convert.IsDBNull(reader["JBH_Reserve1"]) ? 0 : Convert.ToSingle(reader["JBH_Reserve1"]);
|
||
//conboxStation2Model.conboxEnvironmentModel.JBH_Reserve2 = Convert.IsDBNull(reader["JBH_Reserve2"]) ? 0 : Convert.ToSingle(reader["JBH_Reserve2"]);
|
||
}
|
||
reader.Dispose();
|
||
|
||
//柱状图
|
||
sql = String.Format("select RecordTime,Remaining_Power from buoyenvpara where StationID = {0} ORDER by id desc limit {1}", 1, Convert.ToInt32(tools.GetAppSetting("Chart_Limit")));
|
||
reader = DBHelper.ExecuteReader(sql, 1);
|
||
while (reader.Read())
|
||
{
|
||
if (!Convert.IsDBNull(reader["Remaining_Power"]))
|
||
{
|
||
buoystation1Model.buoyEnvironmentModel.RemainingBatteryPower.Values.Add(Convert.ToSingle(reader["Remaining_Power"]));
|
||
buoystation1Model.buoyEnvironmentModel.RemainingBatteryPower.X_Time.Add(Convert.ToDateTime(reader["RecordTime"]).ToShortTimeString());
|
||
}
|
||
}
|
||
reader.Dispose();
|
||
|
||
sql = String.Format("select RecordTime,Remaining_Power from buoyenvpara where StationID = {0} ORDER by id desc limit {1}", 2, Convert.ToInt32(tools.GetAppSetting("Chart_Limit")));
|
||
reader = DBHelper.ExecuteReader(sql, 1);
|
||
while (reader.Read())
|
||
{
|
||
if (!Convert.IsDBNull(reader["Remaining_Power"]))
|
||
{
|
||
buoystation2Model.buoyEnvironmentModel.RemainingBatteryPower.Values.Add(Convert.ToSingle(reader["Remaining_Power"]));
|
||
buoystation2Model.buoyEnvironmentModel.RemainingBatteryPower.X_Time.Add(Convert.ToDateTime(reader["RecordTime"]).ToShortTimeString());
|
||
}
|
||
}
|
||
|
||
sql = String.Format("select RecordTime,JBH_DL_Vol,JBH_SEI_Cur1,JBH_SEI_Cur2,JBH_ADCP_Cur,JBH_Tem,JBH_Hum from conboxenvpara where StationID = {0} ORDER by id desc limit {1}", 1, Convert.ToInt32(tools.GetAppSetting("Chart_Limit")));
|
||
reader = DBHelper.ExecuteReader(sql, 1);
|
||
while (reader.Read())
|
||
{
|
||
if (!Convert.IsDBNull(reader["JBH_DL_Vol"]))
|
||
{
|
||
conboxStation1Model.conboxEnvironmentModel.BatteryVoltageCharts.Values.Add(Convert.ToSingle(reader["JBH_DL_Vol"]));
|
||
conboxStation1Model.conboxEnvironmentModel.BatteryVoltageCharts.X_Time.Add(Convert.ToDateTime(reader["RecordTime"]).ToShortTimeString());
|
||
}
|
||
if (!Convert.IsDBNull(reader["JBH_SEI_Cur1"]))
|
||
{
|
||
conboxStation1Model.conboxEnvironmentModel.Seismometer1CurrentCharts.Values.Add(Convert.ToSingle(reader["JBH_SEI_Cur1"]));
|
||
conboxStation1Model.conboxEnvironmentModel.Seismometer1CurrentCharts.X_Time.Add(Convert.ToDateTime(reader["RecordTime"]).ToShortTimeString());
|
||
}
|
||
if (!Convert.IsDBNull(reader["JBH_SEI_Cur2"]))
|
||
{
|
||
conboxStation1Model.conboxEnvironmentModel.Seismometer2CurrentCharts.Values.Add(Convert.ToSingle(reader["JBH_SEI_Cur2"]));
|
||
conboxStation1Model.conboxEnvironmentModel.Seismometer2CurrentCharts.X_Time.Add(Convert.ToDateTime(reader["RecordTime"]).ToShortTimeString());
|
||
}
|
||
if (!Convert.IsDBNull(reader["JBH_ADCP_Cur"]))
|
||
{
|
||
conboxStation1Model.conboxEnvironmentModel.CurrentMeterCurrentCharts.Values.Add(Convert.ToSingle(reader["JBH_ADCP_Cur"]));
|
||
conboxStation1Model.conboxEnvironmentModel.CurrentMeterCurrentCharts.X_Time.Add(Convert.ToDateTime(reader["RecordTime"]).ToShortTimeString());
|
||
}
|
||
if (!Convert.IsDBNull(reader["JBH_Tem"]))
|
||
{
|
||
conboxStation1Model.conboxEnvironmentModel.ConboxSiancharts.Values.Add(Convert.ToSingle(reader["JBH_Tem"]));
|
||
conboxStation1Model.conboxEnvironmentModel.ConboxSiancharts.X_Time.Add(Convert.ToDateTime(reader["RecordTime"]).ToShortTimeString());
|
||
}
|
||
if (!Convert.IsDBNull(reader["JBH_Hum"]))
|
||
{
|
||
conboxStation1Model.conboxEnvironmentModel.HumidityJunctionCharts.Values.Add(Convert.ToSingle(reader["JBH_Hum"]));
|
||
conboxStation1Model.conboxEnvironmentModel.HumidityJunctionCharts.X_Time.Add(Convert.ToDateTime(reader["RecordTime"]).ToShortTimeString());
|
||
}
|
||
}
|
||
reader.Dispose();
|
||
|
||
sql = String.Format("select RecordTime,JBH_DL_Vol,JBH_SEI_Cur1,JBH_SEI_Cur2,JBH_ADCP_Cur,JBH_Tem,JBH_Hum from conboxenvpara where StationID = {0} ORDER by id desc limit {1}", 2, Convert.ToInt32(tools.GetAppSetting("Chart_Limit")));
|
||
reader = DBHelper.ExecuteReader(sql, 1);
|
||
while (reader.Read())
|
||
{
|
||
if (!Convert.IsDBNull(reader["JBH_DL_Vol"]))
|
||
{
|
||
conboxStation2Model.conboxEnvironmentModel.BatteryVoltageCharts.Values.Add(Convert.ToSingle(reader["JBH_DL_Vol"]));
|
||
conboxStation2Model.conboxEnvironmentModel.BatteryVoltageCharts.X_Time.Add(Convert.ToDateTime(reader["RecordTime"]).ToShortTimeString());
|
||
}
|
||
if (!Convert.IsDBNull(reader["JBH_SEI_Cur1"]))
|
||
{
|
||
conboxStation2Model.conboxEnvironmentModel.Seismometer1CurrentCharts.Values.Add(Convert.ToSingle(reader["JBH_SEI_Cur1"]));
|
||
conboxStation2Model.conboxEnvironmentModel.Seismometer1CurrentCharts.X_Time.Add(Convert.ToDateTime(reader["RecordTime"]).ToShortTimeString());
|
||
}
|
||
if (!Convert.IsDBNull(reader["JBH_SEI_Cur2"]))
|
||
{
|
||
conboxStation2Model.conboxEnvironmentModel.Seismometer2CurrentCharts.Values.Add(Convert.ToSingle(reader["JBH_SEI_Cur2"]));
|
||
conboxStation2Model.conboxEnvironmentModel.Seismometer2CurrentCharts.X_Time.Add(Convert.ToDateTime(reader["RecordTime"]).ToShortTimeString());
|
||
}
|
||
if (!Convert.IsDBNull(reader["JBH_ADCP_Cur"]))
|
||
{
|
||
conboxStation2Model.conboxEnvironmentModel.CurrentMeterCurrentCharts.Values.Add(Convert.ToSingle(reader["JBH_ADCP_Cur"]));
|
||
conboxStation2Model.conboxEnvironmentModel.CurrentMeterCurrentCharts.X_Time.Add(Convert.ToDateTime(reader["RecordTime"]).ToShortTimeString());
|
||
}
|
||
if (!Convert.IsDBNull(reader["JBH_Tem"]))
|
||
{
|
||
conboxStation2Model.conboxEnvironmentModel.ConboxSiancharts.Values.Add(Convert.ToSingle(reader["JBH_Tem"]));
|
||
conboxStation2Model.conboxEnvironmentModel.ConboxSiancharts.X_Time.Add(Convert.ToDateTime(reader["RecordTime"]).ToShortTimeString());
|
||
}
|
||
if (!Convert.IsDBNull(reader["JBH_Hum"]))
|
||
{
|
||
conboxStation2Model.conboxEnvironmentModel.HumidityJunctionCharts.Values.Add(Convert.ToSingle(reader["JBH_Hum"]));
|
||
conboxStation2Model.conboxEnvironmentModel.HumidityJunctionCharts.X_Time.Add(Convert.ToDateTime(reader["RecordTime"]).ToShortTimeString());
|
||
}
|
||
}
|
||
|
||
reader.Dispose();
|
||
|
||
sql = String.Format("select * from earthquakestate where StationID = {0} ORDER by id desc limit 1", 1);
|
||
reader = DBHelper.ExecuteReader(sql, 1);
|
||
while (reader.Read())
|
||
{
|
||
EQSM1.RecordTime = Convert.ToDateTime(reader["RecordTime"]);
|
||
EQSM1.Out_Vol = Convert.IsDBNull(reader["Out_Vol"]) ? 0 : Convert.ToSingle(reader["Out_Vol"]);
|
||
EQSM1.Backup_Vol = Convert.IsDBNull(reader["Backup_Vol"]) ? 0 : Convert.ToSingle(reader["Backup_Vol"]);
|
||
EQSM1.Pre = Convert.IsDBNull(reader["Pre"]) ? 0 : Convert.ToSingle(reader["Pre"]);
|
||
EQSM1.Tem = Convert.IsDBNull(reader["Tem"]) ? 0 : Convert.ToSingle(reader["Tem"]);
|
||
EQSM1.Sei_Tilt_Angle = Convert.IsDBNull(reader["Sei_Tilt_Angle"]) ? 0 : Convert.ToSingle(reader["Sei_Tilt_Angle"]);
|
||
EQSM1.OBS_Tilt_Angle = Convert.IsDBNull(reader["OBS_Tilt_Angle"]) ? 0 : Convert.ToSingle(reader["OBS_Tilt_Angle"]);
|
||
EQSM1.Species_Dif = Convert.IsDBNull(reader["Species_Dif"]) ? 0 : Convert.ToSingle(reader["Species_Dif"]);
|
||
EQSM1.Frequency_Dif = Convert.IsDBNull(reader["Frequency_Dif"]) ? 0 : Convert.ToSingle(reader["Frequency_Dif"]);
|
||
EQSM1.CF_Total_Cap = Convert.IsDBNull(reader["CF_Total_Cap"]) ? 0 : Convert.ToSingle(reader["CF_Total_Cap"]);
|
||
EQSM1.CF_Usable_Cap = Convert.IsDBNull(reader["CF_Usable_Cap"]) ? 0 : Convert.ToSingle(reader["CF_Usable_Cap"]);
|
||
EQSM1.SD_Total_Cap1 = Convert.IsDBNull(reader["SD_Total_Cap1"]) ? 0 : Convert.ToSingle(reader["SD_Total_Cap1"]);
|
||
EQSM1.SD_Usable_Cap1 = Convert.IsDBNull(reader["SD_Usable_Cap1"]) ? 0 : Convert.ToSingle(reader["SD_Usable_Cap1"]);
|
||
EQSM1.SD_Total_Cap2 = Convert.IsDBNull(reader["SD_Total_Cap2"]) ? 0 : Convert.ToSingle(reader["SD_Total_Cap2"]);
|
||
EQSM1.SD_Usable_Cap2 = Convert.IsDBNull(reader["SD_Usable_Cap2"]) ? 0 : Convert.ToSingle(reader["SD_Usable_Cap2"]);
|
||
EQSM1.Sei_U_Point = Convert.IsDBNull(reader["Sei_U_Point"]) ? 0 : Convert.ToSingle(reader["Sei_U_Point"]);
|
||
EQSM1.Sei_V_Point = Convert.IsDBNull(reader["Sei_V_Point"]) ? 0 : Convert.ToSingle(reader["Sei_V_Point"]);
|
||
EQSM1.Sei_W_Point = Convert.IsDBNull(reader["Sei_W_Point"]) ? 0 : Convert.ToSingle(reader["Sei_W_Point"]);
|
||
EQSM1.North_Angle = Convert.IsDBNull(reader["North_Angle"]) ? 0 : Convert.ToSingle(reader["North_Angle"]);
|
||
}
|
||
reader.Dispose();
|
||
sql = String.Format("select * from earthquakestate where StationID = {0} ORDER by id desc limit 1", 2);
|
||
reader = DBHelper.ExecuteReader(sql, 1);
|
||
while (reader.Read())
|
||
{
|
||
EQSM2.RecordTime = Convert.ToDateTime(reader["RecordTime"]);
|
||
EQSM2.Out_Vol = Convert.IsDBNull(reader["Out_Vol"]) ? 0 : Convert.ToSingle(reader["Out_Vol"]);
|
||
EQSM2.Backup_Vol = Convert.IsDBNull(reader["Backup_Vol"]) ? 0 : Convert.ToSingle(reader["Backup_Vol"]);
|
||
EQSM2.Pre = Convert.IsDBNull(reader["Pre"]) ? 0 : Convert.ToSingle(reader["Pre"]);
|
||
EQSM2.Tem = Convert.IsDBNull(reader["Tem"]) ? 0 : Convert.ToSingle(reader["Tem"]);
|
||
EQSM2.Sei_Tilt_Angle = Convert.IsDBNull(reader["Sei_Tilt_Angle"]) ? 0 : Convert.ToSingle(reader["Sei_Tilt_Angle"]);
|
||
EQSM2.OBS_Tilt_Angle = Convert.IsDBNull(reader["OBS_Tilt_Angle"]) ? 0 : Convert.ToSingle(reader["OBS_Tilt_Angle"]);
|
||
EQSM2.Species_Dif = Convert.IsDBNull(reader["Species_Dif"]) ? 0 : Convert.ToSingle(reader["Species_Dif"]);
|
||
EQSM2.Frequency_Dif = Convert.IsDBNull(reader["Frequency_Dif"]) ? 0 : Convert.ToSingle(reader["Frequency_Dif"]);
|
||
EQSM2.CF_Total_Cap = Convert.IsDBNull(reader["CF_Total_Cap"]) ? 0 : Convert.ToSingle(reader["CF_Total_Cap"]);
|
||
EQSM2.CF_Usable_Cap = Convert.IsDBNull(reader["CF_Usable_Cap"]) ? 0 : Convert.ToSingle(reader["CF_Usable_Cap"]);
|
||
EQSM2.SD_Total_Cap1 = Convert.IsDBNull(reader["SD_Total_Cap1"]) ? 0 : Convert.ToSingle(reader["SD_Total_Cap1"]);
|
||
EQSM2.SD_Usable_Cap1 = Convert.IsDBNull(reader["SD_Usable_Cap1"]) ? 0 : Convert.ToSingle(reader["SD_Usable_Cap1"]);
|
||
EQSM2.SD_Total_Cap2 = Convert.IsDBNull(reader["SD_Total_Cap2"]) ? 0 : Convert.ToSingle(reader["SD_Total_Cap2"]);
|
||
EQSM2.SD_Usable_Cap2 = Convert.IsDBNull(reader["SD_Usable_Cap2"]) ? 0 : Convert.ToSingle(reader["SD_Usable_Cap2"]);
|
||
EQSM2.Sei_U_Point = Convert.IsDBNull(reader["Sei_U_Point"]) ? 0 : Convert.ToSingle(reader["Sei_U_Point"]);
|
||
EQSM2.Sei_V_Point = Convert.IsDBNull(reader["Sei_V_Point"]) ? 0 : Convert.ToSingle(reader["Sei_V_Point"]);
|
||
EQSM2.Sei_W_Point = Convert.IsDBNull(reader["Sei_W_Point"]) ? 0 : Convert.ToSingle(reader["Sei_W_Point"]);
|
||
EQSM2.North_Angle = Convert.IsDBNull(reader["North_Angle"]) ? 0 : Convert.ToSingle(reader["North_Angle"]);
|
||
}
|
||
reader.Dispose();
|
||
#endregion
|
||
//默认打开第一个界面
|
||
DoNavChanged("Buoystation");
|
||
EM.ComConMessage = string.Format("串口号:{0} \r\n波特率:{1}", SerialInfo.PortName, SerialInfo.BaudRate.ToString());
|
||
}
|
||
|
||
//各个开关
|
||
public async void Btn_Switch(object o)
|
||
{
|
||
string[] msg = o.ToString().Split(',');
|
||
int switchNum = msg[1].Equals("True") ? 1 : 0;
|
||
string MessageContent = "";
|
||
switch (msg[0])
|
||
{
|
||
case "SatcomPowerPicker":
|
||
MessageContent = "卫通电源" + (msg[1].Equals("True") ? "打开" : "关闭");
|
||
break;
|
||
case "JBHPowerPicker":
|
||
MessageContent = "接驳盒电源" + (msg[1].Equals("True") ? "打开" : "关闭");
|
||
break;
|
||
case "MainSeismograph":
|
||
MessageContent = "主地震仪电源" + (msg[1].Equals("True") ? "打开" : "关闭");
|
||
break;
|
||
case "StandbySeismograph":
|
||
MessageContent = "备用地震仪电源" + (msg[1].Equals("True") ? "打开" : "关闭");
|
||
break;
|
||
case "DZTL":
|
||
MessageContent = "地震计调零" + (msg[1].Equals("True") ? "打开" : "关闭");
|
||
break;
|
||
case "DZTZTL":
|
||
MessageContent = "地震计调零" + (msg[1].Equals("True") ? "打开" : "关闭");
|
||
break;
|
||
case "DZTP":
|
||
MessageContent = "地震计调平" + (msg[1].Equals("True") ? "打开" : "关闭");
|
||
break;
|
||
case "DZTZTP":
|
||
MessageContent = "地震计调平" + (msg[1].Equals("True") ? "打开" : "关闭");
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
|
||
AddsendMessageLists(MessageContent, Communicate == 1 ? BD_Msg.BD_Msg(station_id, 0x0F, 16, new string[] { msg[0] }, new object[] { switchNum }) :
|
||
nR_Msg.Nr_Msg(station_id, 0x0F, 16, new string[] { msg[0] }, new object[] { switchNum }), Communicate);
|
||
if (!isSending)
|
||
{
|
||
bool isSend = await BDCountDownCommand();
|
||
//if (isSend)
|
||
//{
|
||
// EM.ControlMessage = "成功!";
|
||
//}
|
||
//else
|
||
//{
|
||
// EM.ControlMessage = "失败!请检查串口配置及其状态";
|
||
//}
|
||
}
|
||
}
|
||
|
||
public async void Btn_ParaSet(object o)
|
||
{
|
||
string[] msg = o.ToString().Split(',');
|
||
for (int i = 0; i < msg.Length; i++)
|
||
{
|
||
if (string.IsNullOrEmpty(msg[i]))
|
||
{
|
||
EM.ControlMessage = "失败! 请输入完整信息!";
|
||
return;
|
||
}
|
||
}
|
||
switch (msg[0])
|
||
{
|
||
case "ParaSet":
|
||
AddsendMessageLists("参数设置", Communicate == 1 ? BD_Msg.BD_Msg(station_id, 0x13, 11, new string[] { "1", "2", "3", "4", "5", "6", "7", "8" }, new object[] { int.Parse(msg[1]), int.Parse(msg[2]), int.Parse(msg[3]), int.Parse(msg[4]), int.Parse(msg[5]), msg[6].ToString().Equals("自动") ? 0 : 1, msg[7].ToString().Equals("自动") ? 0 : 1, msg[8].ToString().Equals("自动") ? 0 : 1 }) :
|
||
nR_Msg.Nr_Msg(station_id, 0x13, 11, new string[] { "1", "2", "3", "4", "5", "6", "7", "8" }, new object[] { int.Parse(msg[1]), int.Parse(msg[2]), int.Parse(msg[3]), int.Parse(msg[4]), int.Parse(msg[5]), msg[6].ToString().Equals("自动") ? 0 : 1, msg[7].ToString().Equals("自动") ? 0 : 1, msg[8].ToString().Equals("自动") ? 0 : 1 }), Communicate);
|
||
break;
|
||
case "ReadParaSet":
|
||
AddsendMessageLists("读取参数设置", Communicate == 1 ? BD_Msg.BD_Msg(station_id, 0x14, 11, new string[] { "1" }, new object[] { 1 }) :
|
||
nR_Msg.Nr_Msg(station_id, 0x14, 11, new string[] { "1" }, new object[] { 1 }), Communicate);
|
||
break;
|
||
case "EarthQuakeBTN":
|
||
AddsendMessageLists("地震仪参数设置1", Communicate == 1 ? BD_Msg.BD_Msg(station_id, 0x11, 10, new string[] { "1", "2", "3", "4", "5", "6", "7", "8" }, new object[] { int.Parse(msg[1]), msg[2].ToString(), msg[3].ToString(), short.Parse(msg[4]), short.Parse(msg[5]), int.Parse(msg[6]), int.Parse(msg[7]), int.Parse(msg[8]) })
|
||
: nR_Msg.Nr_Msg(station_id, 0x11, 10, new string[] { "1", "2", "3", "4", "5", "6", "7", "8" }, new object[] { int.Parse(msg[1]), msg[2].ToString(), msg[3].ToString(), short.Parse(msg[4]), short.Parse(msg[5]), int.Parse(msg[6]), int.Parse(msg[7]), int.Parse(msg[8]) }), Communicate);
|
||
AddsendMessageLists("地震仪参数设置2", Communicate == 1 ? BD_Msg.BD_Msg(station_id, 0x11, 10, new string[] { "9", "10", "11" }, new object[] { msg[9].ToString(), msg[10].ToString(), msg[11].ToString() })
|
||
: nR_Msg.Nr_Msg(station_id, 0x11, 10, new string[] { "9", "10", "11" }, new object[] { msg[9].ToString(), msg[10].ToString(), msg[11].ToString() }), Communicate);
|
||
break;
|
||
case "EarthQuakeParaReadBtn":
|
||
AddsendMessageLists("地震仪参数设置读取", Communicate == 1 ? BD_Msg.BD_Msg(station_id, 0x12, 10, new string[] { "1" }, new object[] { 1 })
|
||
: nR_Msg.Nr_Msg(station_id, 0x12, 10, new string[] { "1" }, new object[] { 1 }), Communicate);
|
||
break;
|
||
default:
|
||
return;
|
||
break;
|
||
}
|
||
if (!isSending)
|
||
{
|
||
bool isSend = await BDCountDownCommand();
|
||
//if (isSend)
|
||
//{
|
||
// EM.ControlMessage = "成功!";
|
||
//}
|
||
//else
|
||
//{
|
||
// EM.ControlMessage = "失败!请检查串口配置及其状态";
|
||
//}
|
||
}
|
||
}
|
||
|
||
public void DoNavChanged(object obj)
|
||
{
|
||
if (obj.ToString() == "1" || obj.ToString() == "2") //说明是站点切换按钮
|
||
{
|
||
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("AutomaticApp.Views." + Title_Name);
|
||
ConstructorInfo cti = type.GetConstructor(System.Type.EmptyTypes);
|
||
FrameworkElement page = (FrameworkElement)cti.Invoke(null);
|
||
if (station_id == 1)
|
||
{
|
||
switch (Title_Name)
|
||
{
|
||
case "Buoystation":
|
||
page.DataContext = buoystation1Model;
|
||
break;
|
||
case "ConboxStation":
|
||
page.DataContext = conboxStation1Model;
|
||
break;
|
||
case "ControlPageView":
|
||
//page.DataContext = CPV1;
|
||
SS = SS1;
|
||
PS = PS1;
|
||
EQPS = EQPS1;
|
||
EQSM = EQSM1;
|
||
break;
|
||
case "LogView":
|
||
//page.DataContext = conboxStation1Model;
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
else if (station_id == 2)
|
||
{
|
||
switch (Title_Name)
|
||
{
|
||
case "Buoystation":
|
||
page.DataContext = buoystation2Model;
|
||
break;
|
||
case "ConboxStation":
|
||
page.DataContext = conboxStation2Model;
|
||
break;
|
||
case "ControlPageView":
|
||
//page.DataContext = CPV2;
|
||
SS = SS2;
|
||
PS = PS2;
|
||
EQPS = EQPS2;
|
||
EQSM = EQSM2;
|
||
break;
|
||
case "LogView":
|
||
//page.DataContext = conboxStation2Model;
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
this.PageContent = page;
|
||
}
|
||
/// <summary>
|
||
/// 串口连接
|
||
/// </summary>
|
||
/// <param name="o"></param>
|
||
public void DoComConnect(object o)
|
||
{
|
||
if (EM.ComConBtn == "断开")
|
||
{
|
||
Task.Run(new Action(async () =>
|
||
{
|
||
await Task.Delay(100);
|
||
|
||
if (comModel.DisConnect())
|
||
{
|
||
EM.ComStateMessage = "已连接";
|
||
EM.ComConBtn = "断开";
|
||
}
|
||
else
|
||
{
|
||
EM.ComStateMessage = "未连接";
|
||
EM.ComConBtn = "连接";
|
||
}
|
||
}));
|
||
|
||
}
|
||
else if (EM.ComConBtn == "连接")
|
||
{
|
||
Task.Run(new Action(async () =>
|
||
{
|
||
await Task.Delay(100);
|
||
|
||
if (comModel.DoConnect(SerialInfo))
|
||
{
|
||
EM.ComStateMessage = "已连接";
|
||
EM.ComConBtn = "断开";
|
||
EM.ComConMessage = string.Format("串口号:{0} \r\n波特率:{1}", SerialInfo.PortName, SerialInfo.BaudRate.ToString());
|
||
//更新下App.config中的配置信息
|
||
tools.UpdateAppSettings("PortName", SerialInfo.PortName);
|
||
tools.UpdateAppSettings("BaudRate", SerialInfo.BaudRate.ToString());
|
||
}
|
||
else
|
||
{
|
||
EM.ComStateMessage = "未连接";
|
||
EM.ComConBtn = "连接";
|
||
}
|
||
}));
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// Socket1连接
|
||
/// </summary>
|
||
/// <param name="o"></param>
|
||
public void DoSocket1Connect(object o)
|
||
{
|
||
if (EM.Socket1ConBtn == "断开")
|
||
{
|
||
Task.Run(new Action(async () =>
|
||
{
|
||
await Task.Delay(100);
|
||
|
||
if (clientModel1.DisConnect())
|
||
{
|
||
EM.Socket1StateMessage = "已连接";
|
||
EM.Socket1ConBtn = "断开";
|
||
}
|
||
else
|
||
{
|
||
EM.Socket1StateMessage = "未连接";
|
||
EM.Socket1ConBtn = "连接";
|
||
}
|
||
}));
|
||
}
|
||
else if (EM.Socket1ConBtn == "连接")
|
||
{
|
||
Task.Run(new Action(async () =>
|
||
{
|
||
await Task.Delay(150);
|
||
|
||
if (clientModel1.DoConnect(SocketInfo1))
|
||
{
|
||
EM.Socket1StateMessage = "已连接";
|
||
EM.Socket1ConBtn = "断开";
|
||
EM.Socket1ConMessage = string.Format("IP:{0} \r\n端口号:{1}", SocketInfo1.IP, SocketInfo1.Port.ToString());
|
||
//更新下App.config中的配置信息
|
||
tools.UpdateAppSettings("PLC_IP1", SocketInfo1.IP);
|
||
tools.UpdateAppSettings("PLC_Service_Port1", SocketInfo1.Port.ToString());
|
||
}
|
||
else
|
||
{
|
||
EM.Socket1StateMessage = "未连接";
|
||
EM.Socket1ConBtn = "连接";
|
||
}
|
||
}));
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// Socket2连接
|
||
/// </summary>
|
||
/// <param name="o"></param>
|
||
public void DoSocket2Connect(object o)
|
||
{
|
||
if (EM.Socket2ConBtn == "断开")
|
||
{
|
||
Task.Run(new Action(async () =>
|
||
{
|
||
await Task.Delay(100);
|
||
|
||
if (clientModel2.DisConnect())
|
||
{
|
||
EM.Socket2StateMessage = "已连接";
|
||
EM.Socket2ConBtn = "断开";
|
||
}
|
||
else
|
||
{
|
||
EM.Socket2StateMessage = "未连接";
|
||
EM.Socket2ConBtn = "连接";
|
||
}
|
||
}));
|
||
}
|
||
else if (EM.Socket2ConBtn == "连接")
|
||
{
|
||
Task.Run(new Action(async () =>
|
||
{
|
||
await Task.Delay(200);
|
||
|
||
if (clientModel2.DoConnect(SocketInfo2))
|
||
{
|
||
EM.Socket2ConBtn = "断开";
|
||
EM.Socket2StateMessage = "已连接";
|
||
EM.Socket2ConMessage = string.Format("IP:{0} \r\n端口号:{1}", SocketInfo2.IP, SocketInfo2.Port.ToString());
|
||
//更新下App.config中的配置信息
|
||
tools.UpdateAppSettings("PLC_IP2", SocketInfo2.IP);
|
||
tools.UpdateAppSettings("PLC_Service_Port2", SocketInfo2.Port.ToString());
|
||
}
|
||
else
|
||
{
|
||
EM.Socket2StateMessage = "未连接";
|
||
EM.Socket2ConBtn = "连接";
|
||
}
|
||
}));
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// 当前通讯路径
|
||
/// </summary>
|
||
private int Communicate = 1;
|
||
|
||
/// <summary>
|
||
/// 通讯路径切换 1 北斗 2卫通
|
||
/// </summary>
|
||
/// <param name="o"></param>
|
||
public void CommunicationChanged(object o)
|
||
{
|
||
|
||
Communicate = int.Parse(o.ToString());
|
||
|
||
//进行判断对应的通讯路径是否打开
|
||
if (o.Equals("1") && !comModel.IsConnected)
|
||
{
|
||
MessageBox.Show("当前北斗串口未打开,请打开串口以实现通信!");
|
||
return;
|
||
}
|
||
switch (station_id)
|
||
{
|
||
case 1:
|
||
if (o.Equals("2") && !clientModel1.IsConnected)
|
||
{
|
||
MessageBox.Show("当前站点1客户端未连接,请打开连接以实现通信!");
|
||
return;
|
||
}
|
||
break;
|
||
case 2:
|
||
if (o.Equals("2") && !clientModel2.IsConnected)
|
||
{
|
||
MessageBox.Show("当前站点2客户端未连接,请打开连接以实现通信!");
|
||
return;
|
||
}
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
}
|