20211010_CZPM_upperpc/垂直剖面动态观测系统/Common/GlobalValues.cs
2023-07-27 11:01:29 +08:00

2323 lines
128 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Chen.Communication;
using Chen.Communication.Modbus;
using LiveCharts;
using LiveCharts.Defaults;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO.Ports;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using .DataAccess;
using .Model;
using .View;
using .ViewModel;
namespace .Common
{
public class GlobalValues : NotifyBase
{
private static int _length = 48;
#region model
public static Para_LimitModel Para_LimitModel { get; set; } = new Para_LimitModel();
static LocalDataAccess localDataAccess = new LocalDataAccess();
public static ErrorMessageModel ErrorMessageModel { get; set; } = new ErrorMessageModel();
public static ControlModel ControlModel { get; set; } = new ControlModel();
public static FileModel FileModel { get; set; } = new FileModel();
public static Buoy_sensor_adcpModel Buoy_sensor_adcpModel { get; set; } = new Buoy_sensor_adcpModel();
public static Buoy_sensor_attitudeModel Buoy_sensor_attitudeModel { get; set; } = new Buoy_sensor_attitudeModel();
public static Buoy_sensor_othModel Buoy_sensor_othModel { get; set; } = new Buoy_sensor_othModel();
public static Conbox_sensor_adcpModel Conbox_sensor_adcpModel { get; set; } = new Conbox_sensor_adcpModel();
public static Conbox_sensor_othModel Conbox_sensor_othModel { get; set; } = new Conbox_sensor_othModel();
public static Enviroment_Model Enviroment_Model { get; set; } = new Enviroment_Model();
public static Lattarget_sensor_adcp300Model Lattarget_sensor_adcp300Model { get; set; } = new Lattarget_sensor_adcp300Model();
public static Lattarget_sensor_othModel Lattarget_sensor_othModel { get; set; } = new Lattarget_sensor_othModel();
public static Switch_Model Switch_Model { get; set; } = new Switch_Model();
public static LoginModel LoginInfo { get; set; }
public static Para_Model Para_Model { get; set; } = new Para_Model();
public static GPSModel gPSModel { get; set; } = new GPSModel();
//串口配置信息
public static SerialInfo SerialInfo { get; set; } = new SerialInfo();
#endregion
#region
//浮标甲烷电源开关
public CommandBase BT_FB_CH4_Power { get; set; }
//浮标甲烷数据开关
public CommandBase BT_FB_CH4_Data { get; set; }
//浮标走航甲烷电源开关
public CommandBase BT_FB_Sailing_CH4_Power { get; set; }
//浮标走航甲烷数据开关
public CommandBase BT_FB_Sailing_CH4_Data { get; set; }
//浮标姿态电源开关
public CommandBase BT_FB_Attitude_Power { get; set; }
//浮标姿态数据开关
public CommandBase BT_FB_Attitude_Data { get; set; }
//浮标CO2电源开关
public CommandBase BT_FB_CO2_Power { get; set; }
//浮标CO2数据开关
public CommandBase BT_FB_CO2_Data { get; set; }
//浮标ADCP电源开关
public CommandBase BT_FB_ADCP_Power { get; set; }
//浮标ADCP数据开关
public CommandBase BT_FB_ADCP_Data { get; set; }
//浮标气象电源开关
public CommandBase BT_FB_Air_Power { get; set; }
//浮标气象数据开关
public CommandBase BT_FB_Air_Data { get; set; }
//潜标ADCP电源开关
public CommandBase BT_QB_Adcp300_Power { get; set; }
//潜标ADCP数据开关
public CommandBase BT_QB_Adcp300_Data { get; set; }
//潜标CO2电源开关
public CommandBase BT_QB_CO2_Power { get; set; }
//潜标CO2数据开关
public CommandBase BT_QB_CO2_Data { get; set; }
//潜标METS电源开关
public CommandBase BT_QB_METS_Power { get; set; }
//潜标METS数据开关
public CommandBase BT_QB_METS_Data { get; set; }
//潜标CTD电源开关
public CommandBase BT_QB_CTD_Power { get; set; }
//潜标CTD数据开关
public CommandBase BT_QB_CTD_Data { get; set; }
//潜标水声通信机开关
public CommandBase BT_QB_SSTX_Power { get; set; }
//接驳盒CH4电源开关
public CommandBase BT_JBH_CH4_Power { get; set; }
//接驳盒CH4数据开关
public CommandBase BT_JBH_CH4_Data { get; set; }
//接驳盒CO2电源开关
public CommandBase BT_JBH_CO2_Power { get; set; }
//接驳盒CO2数据开关
public CommandBase BT_JBH_CO2_Data { get; set; }
//接驳盒METS电源开关
public CommandBase BT_JBH_METS_Power { get; set; }
//接驳盒METS数据开关
public CommandBase BT_JBH_METS_Data { get; set; }
//接驳盒姿态电源开关
public CommandBase BT_JBH_Attitude_Power { get; set; }
//接驳盒姿态数据开关
public CommandBase BT_JBH_Attitude_Data { get; set; }
//接驳盒CTD电源开关
public CommandBase BT_JBH_CTD_Power { get; set; }
//接驳盒CTD数据开关
public CommandBase BT_JBH_CTD_Data { get; set; }
//接驳盒Adcp电源开关
public CommandBase BT_JBH_Adcp_Power { get; set; }
//接驳盒Adcp数据开关
public CommandBase BT_JBH_Adcp_Data { get; set; }
//读取设置
public CommandBase Read_SET { get; set; }
//系统设置
public CommandBase System_SET { get; set; }
//同步时间
public CommandBase TB_Time { get; set; }
//文件请求
public CommandBase File_Require { get; set; }
//获取铱星强度
public CommandBase objGetIrStrength { get; set; }
//铱星拨号
public CommandBase objIrDial { get; set; }
//铱星断开连接
public CommandBase objIrDisConnect { get; set; }
//通过日期搜索功能
public CommandBase DataSearch { get; set; }
//手动获取浮标姿态数据
public CommandBase objGetIrAttitude { get; set; }
//手动获取浮标ADCP数据
public CommandBase objGetIrFBADCP { get; set; }
//手动获取浮标环境参数
public CommandBase objIrEnvironmental { get; set; }
//手动获取潜标CTD数据
public CommandBase objGetIrQBCTD { get; set; }
//手动获取潜标ADCP数据
public CommandBase objGetIrQBADCP { get; set; }
//手动获取接驳盒CTD数据
public CommandBase objGetIrJBHCTD { get; set; }
//手动读取接驳盒ADCP数据
public CommandBase objGetIrJBHADCP { get; set; }
#endregion
public GlobalValues()
{
//初始化最大值和最小值
Para_LimitModel = localDataAccess.GetLimitModel();
this.BT_FB_CH4_Power = new CommandBase();
this.BT_FB_CH4_Power.DoExcute = new Action<object>((o) =>
{
if (Switch_Model.FB_CH4_Power) { send_port_btn(10, 01, 01, 00); } else { send_port_btn(10, 01, 00, 00); }
});
this.BT_FB_CH4_Power.DoCanExcute = new Func<object, bool>((o) => { return true; });
this.BT_FB_CH4_Data = new CommandBase();
this.BT_FB_CH4_Data.DoExcute = new Action<object>((o) =>
{
if (Switch_Model.FB_CH4_Data) { send_port_btn(10, 01, 01, 01); } else { send_port_btn(10, 01, 00, 01); }
});
this.BT_FB_CH4_Data.DoCanExcute = new Func<object, bool>((o) => { return true; });
this.BT_FB_Sailing_CH4_Power = new CommandBase();
this.BT_FB_Sailing_CH4_Power.DoExcute = new Action<object>((o) =>
{
if (Switch_Model.FB_Sailing_CH4_Power) { send_port_btn(10, 06, 01, 00); } else { send_port_btn(10, 06, 00, 00); }
});
this.BT_FB_Sailing_CH4_Power.DoCanExcute = new Func<object, bool>((o) => { return true; });
this.BT_FB_Sailing_CH4_Data = new CommandBase();
this.BT_FB_Sailing_CH4_Data.DoExcute = new Action<object>((o) =>
{
if (Switch_Model.FB_Sailing_CH4_Data) { send_port_btn(10, 06, 01, 01); } else { send_port_btn(10, 06, 00, 01); }
});
this.BT_FB_Sailing_CH4_Data.DoCanExcute = new Func<object, bool>((o) => { return true; });
this.BT_FB_Attitude_Power = new CommandBase();
this.BT_FB_Attitude_Power.DoExcute = new Action<object>((o) =>
{
if (Switch_Model.FB_Attitude_Power) { send_port_btn(13, 08, 01, 00); } else { send_port_btn(13, 08, 00, 00); }
});
this.BT_FB_Attitude_Power.DoCanExcute = new Func<object, bool>((o) => { return true; });
this.BT_FB_Attitude_Data = new CommandBase();
this.BT_FB_Attitude_Data.DoExcute = new Action<object>((o) =>
{
if (Switch_Model.FB_Attitude_Data) { send_port_btn(13, 08, 01, 01); } else { send_port_btn(13, 08, 00, 01); }
});
this.BT_FB_Attitude_Data.DoCanExcute = new Func<object, bool>((o) => { return true; });
this.BT_FB_CO2_Power = new CommandBase();
this.BT_FB_CO2_Power.DoExcute = new Action<object>((o) =>
{
if (Switch_Model.FB_CO2_Power) { send_port_btn(10, 02, 01, 00); } else { send_port_btn(10, 02, 00, 00); }
});
this.BT_FB_CO2_Power.DoCanExcute = new Func<object, bool>((o) => { return true; });
this.BT_FB_CO2_Data = new CommandBase();
this.BT_FB_CO2_Data.DoExcute = new Action<object>((o) =>
{
if (Switch_Model.FB_CO2_Data) { send_port_btn(10, 02, 01, 01); } else { send_port_btn(10, 02, 00, 01); }
});
this.BT_FB_CO2_Data.DoCanExcute = new Func<object, bool>((o) => { return true; });
this.BT_FB_ADCP_Power = new CommandBase();
this.BT_FB_ADCP_Power.DoExcute = new Action<object>((o) =>
{
if (Switch_Model.FB_Adcp_Power) { send_port_btn(11, 00, 01, 00); } else { send_port_btn(11, 00, 00, 00); }
});
this.BT_FB_ADCP_Power.DoCanExcute = new Func<object, bool>((o) => { return true; });
this.BT_FB_ADCP_Data = new CommandBase();
this.BT_FB_ADCP_Data.DoExcute = new Action<object>((o) =>
{
if (Switch_Model.FB_Adcp_Data) { send_port_btn(11, 00, 01, 01); } else { send_port_btn(11, 00, 00, 01); }
});
this.BT_FB_ADCP_Data.DoCanExcute = new Func<object, bool>((o) => { return true; });
this.BT_FB_Air_Power = new CommandBase();
this.BT_FB_Air_Power.DoExcute = new Action<object>((o) =>
{
if (Switch_Model.FB_Air_Power) { send_port_btn(10, 00, 01, 00); } else { send_port_btn(10, 00, 00, 00); }
});
this.BT_FB_Air_Power.DoCanExcute = new Func<object, bool>((o) => { return true; });
this.BT_FB_Air_Data = new CommandBase();
this.BT_FB_Air_Data.DoExcute = new Action<object>((o) =>
{
if (Switch_Model.FB_Air_Data) { send_port_btn(10, 00, 01, 01); } else { send_port_btn(10, 00, 00, 01); }
});
this.BT_FB_Air_Data.DoCanExcute = new Func<object, bool>((o) => { return true; });
this.BT_QB_Adcp300_Power = new CommandBase();
this.BT_QB_Adcp300_Power.DoExcute = new Action<object>((o) =>
{
if (Switch_Model.QB_Adcp300_Power) { send_port_btn(21, 00, 01, 00); } else { send_port_btn(21, 00, 00, 00); }
});
this.BT_QB_Adcp300_Power.DoCanExcute = new Func<object, bool>((o) => { return true; });
this.BT_QB_Adcp300_Data = new CommandBase();
this.BT_QB_Adcp300_Data.DoExcute = new Action<object>((o) =>
{
if (Switch_Model.QB_Adcp300_Data) { send_port_btn(21, 00, 01, 01); } else { send_port_btn(21, 00, 00, 01); }
});
this.BT_QB_Adcp300_Data.DoCanExcute = new Func<object, bool>((o) => { return true; });
this.BT_QB_CO2_Power = new CommandBase();
this.BT_QB_CO2_Power.DoExcute = new Action<object>((o) =>
{
if (Switch_Model.QB_CO2_Power) { send_port_btn(25, 02, 01, 00); } else { send_port_btn(25, 02, 00, 00); }
});
this.BT_QB_CO2_Power.DoCanExcute = new Func<object, bool>((o) => { return true; });
this.BT_QB_CO2_Data = new CommandBase();
this.BT_QB_CO2_Data.DoExcute = new Action<object>((o) =>
{
if (Switch_Model.QB_CO2_Data) { send_port_btn(25, 02, 01, 01); } else { send_port_btn(25, 02, 00, 01); }
});
this.BT_QB_CO2_Data.DoCanExcute = new Func<object, bool>((o) => { return true; });
this.BT_QB_METS_Power = new CommandBase();
this.BT_QB_METS_Power.DoExcute = new Action<object>((o) =>
{
if (Switch_Model.QB_METS_Power) { send_port_btn(25, 03, 01, 00); } else { send_port_btn(25, 03, 00, 00); }
});
this.BT_QB_METS_Power.DoCanExcute = new Func<object, bool>((o) => { return true; });
this.BT_QB_METS_Data = new CommandBase();
this.BT_QB_METS_Data.DoExcute = new Action<object>((o) =>
{
if (Switch_Model.QB_METS_Data) { send_port_btn(25, 03, 01, 01); } else { send_port_btn(25, 03, 00, 01); }
});
this.BT_QB_METS_Data.DoCanExcute = new Func<object, bool>((o) => { return true; });
this.BT_QB_CTD_Power = new CommandBase();
this.BT_QB_CTD_Power.DoExcute = new Action<object>((o) =>
{
if (Switch_Model.QB_CTD_Power) { send_port_btn(25, 04, 01, 00); } else { send_port_btn(25, 04, 00, 00); }
});
this.BT_QB_CTD_Power.DoCanExcute = new Func<object, bool>((o) => { return true; });
this.BT_QB_CTD_Data = new CommandBase();
this.BT_QB_CTD_Data.DoExcute = new Action<object>((o) =>
{
if (Switch_Model.QB_CTD_Data) { send_port_btn(25, 04, 01, 01); } else { send_port_btn(25, 04, 00, 01); }
});
this.BT_QB_CTD_Data.DoCanExcute = new Func<object, bool>((o) => { return true; });
this.BT_JBH_CH4_Power = new CommandBase();
this.BT_JBH_CH4_Power.DoExcute = new Action<object>((o) =>
{
if (Switch_Model.JBH_CH4_Power) { send_port_btn(30, 01, 01, 00); } else { send_port_btn(30, 01, 00, 00); }
});
this.BT_JBH_CH4_Power.DoCanExcute = new Func<object, bool>((o) => { return true; });
this.BT_JBH_CH4_Data = new CommandBase();
this.BT_JBH_CH4_Data.DoExcute = new Action<object>((o) =>
{
if (Switch_Model.JBH_CH4_Data) { send_port_btn(30, 01, 01, 01); } else { send_port_btn(30, 01, 00, 01); }
});
this.BT_JBH_CH4_Data.DoCanExcute = new Func<object, bool>((o) => { return true; });
this.BT_JBH_CO2_Power = new CommandBase();
this.BT_JBH_CO2_Power.DoExcute = new Action<object>((o) =>
{
if (Switch_Model.JBH_CO2_Power) { send_port_btn(30, 02, 01, 00); } else { send_port_btn(30, 02, 00, 00); }
});
this.BT_JBH_CO2_Power.DoCanExcute = new Func<object, bool>((o) => { return true; });
this.BT_JBH_CO2_Data = new CommandBase();
this.BT_JBH_CO2_Data.DoExcute = new Action<object>((o) =>
{
if (Switch_Model.JBH_CO2_Data) { send_port_btn(30, 02, 01, 01); } else { send_port_btn(30, 02, 00, 01); }
});
this.BT_JBH_CO2_Data.DoCanExcute = new Func<object, bool>((o) => { return true; });
this.BT_JBH_METS_Power = new CommandBase();
this.BT_JBH_METS_Power.DoExcute = new Action<object>((o) =>
{
if (Switch_Model.JBH_METS_Power) { send_port_btn(30, 03, 01, 00); } else { send_port_btn(30, 03, 00, 00); }
});
this.BT_JBH_METS_Power.DoCanExcute = new Func<object, bool>((o) => { return true; });
this.BT_JBH_METS_Data = new CommandBase();
this.BT_JBH_METS_Data.DoExcute = new Action<object>((o) =>
{
if (Switch_Model.JBH_METS_Data) { send_port_btn(30, 03, 01, 01); } else { send_port_btn(30, 03, 00, 01); }
});
this.BT_JBH_METS_Data.DoCanExcute = new Func<object, bool>((o) => { return true; });
this.BT_JBH_Attitude_Power = new CommandBase();
this.BT_JBH_Attitude_Power.DoExcute = new Action<object>((o) =>
{
if (Switch_Model.JBH_Attitude_Power) { send_port_btn(30, 05, 01, 00); } else { send_port_btn(30, 05, 00, 00); }
});
this.BT_JBH_Attitude_Power.DoCanExcute = new Func<object, bool>((o) => { return true; });
this.BT_JBH_Attitude_Data = new CommandBase();
this.BT_JBH_Attitude_Data.DoExcute = new Action<object>((o) =>
{
if (Switch_Model.JBH_Attitude_Data) { send_port_btn(30, 05, 01, 01); } else { send_port_btn(30, 05, 00, 01); }
});
this.BT_JBH_Attitude_Data.DoCanExcute = new Func<object, bool>((o) => { return true; });
this.BT_JBH_CTD_Power = new CommandBase();
this.BT_JBH_CTD_Power.DoExcute = new Action<object>((o) =>
{
if (Switch_Model.JBH_CTD_Power) { send_port_btn(30, 04, 01, 00); } else { send_port_btn(30, 04, 00, 00); }
});
this.BT_JBH_CTD_Power.DoCanExcute = new Func<object, bool>((o) => { return true; });
this.BT_JBH_CTD_Data = new CommandBase();
this.BT_JBH_CTD_Data.DoExcute = new Action<object>((o) =>
{
if (Switch_Model.JBH_CTD_Data) { send_port_btn(30, 04, 01, 01); } else { send_port_btn(30, 04, 00, 01); }
});
this.BT_JBH_CTD_Data.DoCanExcute = new Func<object, bool>((o) => { return true; });
this.BT_JBH_Adcp_Power = new CommandBase();
this.BT_JBH_Adcp_Power.DoExcute = new Action<object>((o) =>
{
if (Switch_Model.JBH_Adcp_Power) { send_port_btn(31, 00, 01, 00); } else { send_port_btn(31, 00, 00, 00); }
});
this.BT_JBH_Adcp_Power.DoCanExcute = new Func<object, bool>((o) => { return true; });
this.BT_JBH_Adcp_Data = new CommandBase();
this.BT_JBH_Adcp_Data.DoExcute = new Action<object>((o) =>
{
if (Switch_Model.JBH_Adcp_Data) { send_port_btn(31, 00, 01, 01); } else { send_port_btn(31, 00, 00, 01); }
});
this.BT_JBH_Adcp_Data.DoCanExcute = new Func<object, bool>((o) => { return true; });
this.Read_SET = new CommandBase();
this.Read_SET.DoExcute = new Action<object>(Par_Read);
this.Read_SET.DoCanExcute = new Func<object, bool>((o) => { return true; });
this.System_SET = new CommandBase();
this.System_SET.DoExcute = new Action<object>(Par_Set);
this.System_SET.DoCanExcute = new Func<object, bool>((o) => { return true; });
this.TB_Time = new CommandBase();
this.TB_Time.DoExcute = new Action<object>(Tb_Time);
this.TB_Time.DoCanExcute = new Func<object, bool>((o) => { return true; });
this.File_Require = new CommandBase();
this.File_Require.DoExcute = new Action<object>(FILE_Require);
this.File_Require.DoCanExcute = new Func<object, bool>((o) => { return true; });
this.objGetIrStrength = new CommandBase();
this.objGetIrStrength.DoExcute = new Action<object>(GetIrStrength);
this.objGetIrStrength.DoCanExcute = new Func<object, bool>((o) => { return true; });
this.objIrDial = new CommandBase();
this.objIrDial.DoExcute = new Action<object>(IrDial);
this.objIrDial.DoCanExcute = new Func<object, bool>((o) => { return true; });
this.objIrDisConnect = new CommandBase();
this.objIrDisConnect.DoExcute = new Action<object>(IrDisConnect);
this.objIrDisConnect.DoCanExcute = new Func<object, bool>((o) => { return true; });
this.DataSearch = new CommandBase();
this.DataSearch.DoExcute = new Action<object>(GetData);
this.DataSearch.DoCanExcute = new Func<object, bool>((o) => { return true; });
//手动读取浮标姿态传感器数据
this.objGetIrAttitude = new CommandBase();
this.objGetIrAttitude.DoExcute = new Action<object>((o) =>
{
send_port_hand(13);
});
this.objGetIrAttitude.DoCanExcute = new Func<object, bool>((o) => { return true; });
//手动读取浮标ADCP-WSH300
this.objGetIrFBADCP = new CommandBase();
this.objGetIrFBADCP.DoExcute = new Action<object>((o) =>
{
send_port_hand(11);
});
this.objGetIrFBADCP.DoCanExcute = new Func<object, bool>((o) => { return true; });
//手动读取浮标环境参数
this.objIrEnvironmental = new CommandBase();
this.objIrEnvironmental.DoExcute = new Action<object>((o) =>
{
send_port_hand(10);
});
this.objIrEnvironmental.DoCanExcute = new Func<object, bool>((o) => { return true; });
//手动读取潜标CTD数据
this.objGetIrQBCTD = new CommandBase();
this.objGetIrQBCTD.DoExcute = new Action<object>((o) =>
{
send_port_hand(25);
});
this.objGetIrQBCTD.DoCanExcute = new Func<object, bool>((o) => { return true; });
//手动读取潜标ADCP数据
this.objGetIrQBADCP = new CommandBase();
this.objGetIrQBADCP.DoExcute = new Action<object>((o) =>
{
send_port_hand(21);
});
this.objGetIrQBADCP.DoCanExcute = new Func<object, bool>((o) => { return true; });
//手动读取接驳盒CTD数据
this.objGetIrJBHCTD = new CommandBase();
this.objGetIrJBHCTD.DoExcute = new Action<object>((o) =>
{
send_port_hand(30);
});
this.objGetIrJBHCTD.DoCanExcute = new Func<object, bool>((o) => { return true; });
//手动读取接驳盒ADCP数据
this.objGetIrJBHADCP = new CommandBase();
this.objGetIrJBHADCP.DoExcute = new Action<object>((o) =>
{
send_port_hand(31);
});
this.objGetIrJBHADCP.DoCanExcute = new Func<object, bool>((o) => { return true; });
}
/// <summary>
/// 取出数据库中的值并赋值
/// </summary>
public static void Flash_LIST()
{
List<Enviroment_Model> enviroment_Models = localDataAccess.Enviroment_Models_List();
for (int i = 0; i < enviroment_Models.Count; i++)
{
Enviroment_Model.Datetime_List.Add(enviroment_Models[i].Datetime.ToString("yyyy-MM-dd HH:mm:ss"));
Enviroment_Model.FB_Tem_List.Add(enviroment_Models[i].FB_Tem);
Enviroment_Model.FB_Hum_List.Add(enviroment_Models[i].FB_Hum);
Enviroment_Model.FB_Vol_24_in_List.Add(enviroment_Models[i].FB_Vol_24_in);
Enviroment_Model.FB_Cur_24_in_List.Add(enviroment_Models[i].FB_Cur_24_in);
Enviroment_Model.FB_Vol_48_out_List.Add(enviroment_Models[i].FB_Vol_48_out);
Enviroment_Model.FB_Vol_95_out_List.Add(enviroment_Models[i].FB_Vol_95_out);
Enviroment_Model.QB_Tem1_List.Add(enviroment_Models[i].QB_Tem1);
Enviroment_Model.QB_Tem2_List.Add(enviroment_Models[i].QB_Tem2);
Enviroment_Model.QB_Hum_List.Add(enviroment_Models[i].QB_Hum);
Enviroment_Model.QB_Leak_List.Add(enviroment_Models[i].QB_Leak);
Enviroment_Model.JBH_Tem1_List.Add(enviroment_Models[i].JBH_Tem1);
Enviroment_Model.JBH_Tem2_List.Add(enviroment_Models[i].JBH_Tem2);
Enviroment_Model.JBH_Hum_List.Add(enviroment_Models[i].JBH_Hum);
Enviroment_Model.JBH_Leak_List.Add(enviroment_Models[i].JBH_Leak);
Enviroment_Model.JBH_Vol_24V_out_List.Add(enviroment_Models[i].JBH_Vol_24V_out);
Enviroment_Model.JBH_Cur_24V_out_List.Add(enviroment_Models[i].JBH_Cur_24V_out);
}
List<Buoy_sensor_adcpModel> buoy_Sensor_AdcpModels = localDataAccess.Buoy_sensor_adcpModel_List();
for (int i = 0; i < buoy_Sensor_AdcpModels.Count; i++)
{
Buoy_sensor_adcpModel.Datetime_List.Add(buoy_Sensor_AdcpModels[i].datetime_Sensor.ToString("yyyy-MM-dd HH:mm:ss"));
Buoy_sensor_adcpModel.Adcp_Pre_List.Add(buoy_Sensor_AdcpModels[i].Adcp_Pre);
Buoy_sensor_adcpModel.Adcp_Ysb_List.Add(buoy_Sensor_AdcpModels[i].Adcp_Ysb);
}
List<Conbox_sensor_adcpModel> conbox_sensor_adcpModel = localDataAccess.Conbox_sensor_adcpModel_List();
for (int i = 0; i < conbox_sensor_adcpModel.Count; i++)
{
Conbox_sensor_adcpModel.Datetime_List.Add(conbox_sensor_adcpModel[i].datetime_Sensor.ToString("yyyy-MM-dd HH:mm:ss"));
Conbox_sensor_adcpModel.Adcp_Pre_List.Add(conbox_sensor_adcpModel[i].Adcp_Pre);
Conbox_sensor_adcpModel.Adcp_Ysb_List.Add(conbox_sensor_adcpModel[i].Adcp_Ysb);
}
List<Lattarget_sensor_adcp300Model> lattarget_Sensor_Adcp300Models = localDataAccess.Lattarget_sensor_adcp300Model_List();
for (int i = 0; i < lattarget_Sensor_Adcp300Models.Count; i++)
{
Lattarget_sensor_adcp300Model.Datetime_List.Add(lattarget_Sensor_Adcp300Models[i].datetime_Sensor.ToString("yyyy-MM-dd HH:mm:ss"));
Lattarget_sensor_adcp300Model.Adcp_Pre_List.Add(lattarget_Sensor_Adcp300Models[i].Adcp_Pre);
Lattarget_sensor_adcp300Model.Adcp_Ysb_List.Add(lattarget_Sensor_Adcp300Models[i].Adcp_Ysb);
}
List<Buoy_sensor_othModel> buoy_Sensor_OthModels = localDataAccess.Buoy_sensor_othModel_List();
for (int i = 0; i < buoy_Sensor_OthModels.Count; i++)
{
Buoy_sensor_othModel.Datetime_List.Add(buoy_Sensor_OthModels[i].datetime_Sensor.ToString("yyyy-MM-dd HH:mm:ss"));
Buoy_sensor_othModel.CH4_Pre_List.Add(buoy_Sensor_OthModels[i].CH4_Pre);
Buoy_sensor_othModel.CH4_Con_List.Add(buoy_Sensor_OthModels[i].CH4_Con);
Buoy_sensor_othModel.CO2_Pre_List.Add(buoy_Sensor_OthModels[i].CO2_Pre);
Buoy_sensor_othModel.CO2_Con_List.Add(buoy_Sensor_OthModels[i].CO2_Con);
Buoy_sensor_othModel.METS_Meth_List.Add(buoy_Sensor_OthModels[i].METS_Meth);
Buoy_sensor_othModel.METS_Tem_List.Add(buoy_Sensor_OthModels[i].METS_Tem);
Buoy_sensor_othModel.Air_Tem_List.Add(buoy_Sensor_OthModels[i].Air_Tem);
Buoy_sensor_othModel.Air_Hum_List.Add(buoy_Sensor_OthModels[i].Air_Hum);
Buoy_sensor_othModel.Air_Pre_List.Add(buoy_Sensor_OthModels[i].Air_Pre);
Buoy_sensor_othModel.Wind_Dir_List.Add(buoy_Sensor_OthModels[i].Wind_Dir);
Buoy_sensor_othModel.Wind_Speed_List.Add(buoy_Sensor_OthModels[i].Wind_Speed);
Buoy_sensor_othModel.Wind_Speed_Max_List.Add(buoy_Sensor_OthModels[i].Wind_Speed_Max);
Buoy_sensor_othModel.Fzd_List.Add(buoy_Sensor_OthModels[i].Fzd);
Buoy_sensor_othModel.RainFall_List.Add(buoy_Sensor_OthModels[i].RainFall);
Buoy_sensor_othModel.Go_sailing_CH4_Dry_List.Add(buoy_Sensor_OthModels[i].Go_sailing_CH4_Dry);
Buoy_sensor_othModel.Go_sailing_CH4_H2O_List.Add(buoy_Sensor_OthModels[i].Go_sailing_CH4_H2O);
Buoy_sensor_othModel.Go_sailing_CH4_C2H6_List.Add(buoy_Sensor_OthModels[i].Go_sailing_CH4_C2H6);
Buoy_sensor_othModel.Tem_List.Add(buoy_Sensor_OthModels[i].Tem);
Buoy_sensor_othModel.Hum_List.Add(buoy_Sensor_OthModels[i].Hum);
Buoy_sensor_othModel.Vol_24_in_List.Add(buoy_Sensor_OthModels[i].Vol_24_in);
Buoy_sensor_othModel.Cur_24_in_List.Add(buoy_Sensor_OthModels[i].Cur_24_in);
Buoy_sensor_othModel.Vol_48_out_List.Add(buoy_Sensor_OthModels[i].Vol_48_out);
Buoy_sensor_othModel.Vol_95_out_List.Add(buoy_Sensor_OthModels[i].Vol_95_out);
}
List<Conbox_sensor_othModel> conbox_Sensor_OthModels = localDataAccess.Conbox_sensor_othModel_List();
for (int i = 0; i < conbox_Sensor_OthModels.Count; i++)
{
Conbox_sensor_othModel.Datetime_List.Add(conbox_Sensor_OthModels[i].datetime_Sensor.ToString("yyyy-MM-dd HH:mm:ss"));
Conbox_sensor_othModel.CH4_Pre_List.Add(conbox_Sensor_OthModels[i].CH4_Pre);
Conbox_sensor_othModel.CH4_Con_List.Add(conbox_Sensor_OthModels[i].CH4_Con);
Conbox_sensor_othModel.CO2_Pre_List.Add(conbox_Sensor_OthModels[i].CO2_Pre);
Conbox_sensor_othModel.CO2_Con_List.Add(conbox_Sensor_OthModels[i].CO2_Con);
Conbox_sensor_othModel.METS_Meth_List.Add(conbox_Sensor_OthModels[i].METS_Meth);
Conbox_sensor_othModel.METS_Tem_List.Add(conbox_Sensor_OthModels[i].METS_Tem);
Conbox_sensor_othModel.CTD_Tem_List.Add(conbox_Sensor_OthModels[i].CTD_Tem);
Conbox_sensor_othModel.CTD_Con_List.Add(conbox_Sensor_OthModels[i].CTD_Con);
Conbox_sensor_othModel.CTD_Pre_List.Add(conbox_Sensor_OthModels[i].CTD_Pre);
Conbox_sensor_othModel.Angle_sensor_x_List.Add(conbox_Sensor_OthModels[i].Angle_sensor_x);
Conbox_sensor_othModel.Angle_sensor_y_List.Add(conbox_Sensor_OthModels[i].Angle_sensor_y);
Conbox_sensor_othModel.Angle_sensor_z_List.Add(conbox_Sensor_OthModels[i].Angle_sensor_z);
Conbox_sensor_othModel.CTD_YLS_List.Add(conbox_Sensor_OthModels[i].CTD_YLS);
Conbox_sensor_othModel.CTD_ZD_List.Add(conbox_Sensor_OthModels[i].CTD_ZD);
Conbox_sensor_othModel.CTD_Rjy_List.Add(conbox_Sensor_OthModels[i].CTD_Rjy);
}
List<Lattarget_sensor_othModel> lattarget_Sensor_OthModels = localDataAccess.Lattarget_sensor_othModel_List();
for (int i = 0; i < lattarget_Sensor_OthModels.Count; i++)
{
Lattarget_sensor_othModel.Datetime_List.Add(lattarget_Sensor_OthModels[i].datetime_Sensor.ToString("yyyy-MM-dd HH:mm:ss"));
Lattarget_sensor_othModel.CO2_Pre_List.Add(lattarget_Sensor_OthModels[i].CO2_Pre);
Lattarget_sensor_othModel.CO2_Con_List.Add(lattarget_Sensor_OthModels[i].CO2_Con);
Lattarget_sensor_othModel.METS_Meth_List.Add(lattarget_Sensor_OthModels[i].METS_Meth);
Lattarget_sensor_othModel.METS_Tem_List.Add(lattarget_Sensor_OthModels[i].METS_Tem);
Lattarget_sensor_othModel.CTD_Tem_List.Add(lattarget_Sensor_OthModels[i].CTD_Tem);
Lattarget_sensor_othModel.CTD_Con_List.Add(lattarget_Sensor_OthModels[i].CTD_Con);
Lattarget_sensor_othModel.CTD_Pre_List.Add(lattarget_Sensor_OthModels[i].CTD_Pre);
Lattarget_sensor_othModel.CTD_YLS_List.Add(lattarget_Sensor_OthModels[i].CTD_YLS);
Lattarget_sensor_othModel.CTD_ZD_List.Add(lattarget_Sensor_OthModels[i].CTD_ZD);
Lattarget_sensor_othModel.CTD_Rjy_List.Add(lattarget_Sensor_OthModels[i].CTD_Rjy);
Lattarget_sensor_othModel.CTD_Rjy_Vol_List.Add(lattarget_Sensor_OthModels[i].CTD_Rjy_Vol);
Lattarget_sensor_othModel.Angle_sensor_x_List.Add(lattarget_Sensor_OthModels[i].Angle_sensor_x);
Lattarget_sensor_othModel.Angle_sensor_y_List.Add(lattarget_Sensor_OthModels[i].Angle_sensor_y);
Lattarget_sensor_othModel.Angle_sensor_z_List.Add(lattarget_Sensor_OthModels[i].Angle_sensor_z);
}
gPSModel = localDataAccess.GetGPS();
}
static string ParaName = "";
public static void Flash_LIST(string paraName, string starttime, string endtime)
{
ParaName = paraName;
string header = paraName.Split(',')[0];
string sensorName = paraName.Split(',')[1];
string para = paraName.Split(',')[2];
Para_Model para_Model = null;
if (header.Equals("浮标"))
{
if (sensorName.Equals("环境参数"))
{
if (para.Equals("温度"))
{
para_Model = localDataAccess.GetParaDate("FB_Tem", "enviroment_model", starttime, endtime);
Para_Model.ParaName = "温度/℃";
}
else if (para.Equals("湿度"))
{
para_Model = localDataAccess.GetParaDate("FB_Hum", "enviroment_model", starttime, endtime);
Para_Model.ParaName = "湿度/%";
}
else if (para.Equals("24V输入电压"))
{
para_Model = localDataAccess.GetParaDate("FB_Vol_24_in", "enviroment_model", starttime, endtime);
Para_Model.ParaName = "24V输入电压/V";
}
else if (para.Equals("24V输入电流"))
{
para_Model = localDataAccess.GetParaDate("FB_Cur_24_in", "enviroment_model", starttime, endtime);
Para_Model.ParaName = "24V输入电流/A";
}
else if (para.Equals("48V输出电压"))
{
para_Model = localDataAccess.GetParaDate("FB_Vol_48_out", "enviroment_model", starttime, endtime);
Para_Model.ParaName = "48V输出电压/V";
}
else if (para.Equals("95V输出电压"))
{
para_Model = localDataAccess.GetParaDate("FB_Vol_95_out", "enviroment_model", starttime, endtime);
Para_Model.ParaName = "95V输出电压/V";
}
}
else if (sensorName.Equals("甲烷传感器"))
{
if (para.Equals("压力"))
{
para_Model = localDataAccess.GetParaDate("CH4_Pre", "buoy_sensor_othmodel", starttime, endtime);
Para_Model.ParaName = "压力/μatm";
}
else if (para.Equals("浓度"))
{
para_Model = localDataAccess.GetParaDate("CH4_Con", "buoy_sensor_othmodel", starttime, endtime);
Para_Model.ParaName = "浓度/ppm";
}
}
else if (sensorName.Equals("二氧化碳传感器"))
{
if (para.Equals("压力"))
{
para_Model = localDataAccess.GetParaDate("CO2_Pre", "buoy_sensor_othmodel", starttime, endtime);
Para_Model.ParaName = "压力/μatm";
}
else if (para.Equals("浓度"))
{
para_Model = localDataAccess.GetParaDate("CO2_Con", "buoy_sensor_othmodel", starttime, endtime);
Para_Model.ParaName = "浓度/ppm";
}
}
else if (sensorName.Equals("走行甲烷传感器"))
{
if (para.Equals("ch4_dry"))
{
para_Model = localDataAccess.GetParaDate("Go_sailing_CH4_Dry", "buoy_sensor_othmodel", starttime, endtime);
Para_Model.ParaName = "ch4_dry/ppm";
}
else if (para.Equals("C2H6"))
{
para_Model = localDataAccess.GetParaDate("Go_sailing_CH4_H2O", "buoy_sensor_othmodel", starttime, endtime);
Para_Model.ParaName = "C2H6/ppb";
}
else if (para.Equals("H2O"))
{
para_Model = localDataAccess.GetParaDate("Go_sailing_CH4_C2H6", "buoy_sensor_othmodel", starttime, endtime);
Para_Model.ParaName = "H2O/ppm";
}
}
else if (sensorName.Equals("气象传感器"))
{
if (para.Equals("气温"))
{
para_Model = localDataAccess.GetParaDate("Air_Tem", "buoy_sensor_othmodel", starttime, endtime);
Para_Model.ParaName = "气温/℃";
}
else if (para.Equals("湿度"))
{
para_Model = localDataAccess.GetParaDate("Air_Hum", "buoy_sensor_othmodel", starttime, endtime);
Para_Model.ParaName = "湿度/%";
}
else if (para.Equals("大气压"))
{
para_Model = localDataAccess.GetParaDate("Air_Pre", "buoy_sensor_othmodel", starttime, endtime);
Para_Model.ParaName = "大气压/Pa";
}
else if (para.Equals("风向"))
{
para_Model = localDataAccess.GetParaDate("Wind_Dir", "buoy_sensor_othmodel", starttime, endtime);
Para_Model.ParaName = "风向/°";
}
else if (para.Equals("风速"))
{
para_Model = localDataAccess.GetParaDate("Wind_Speed", "buoy_sensor_othmodel", starttime, endtime);
Para_Model.ParaName = "风速/m/s";
}
else if (para.Equals("最大风速"))
{
para_Model = localDataAccess.GetParaDate("Wind_Speed_Max", "buoy_sensor_othmodel", starttime, endtime);
Para_Model.ParaName = "最大风速/m/s";
}
else if (para.Equals("辐照度"))
{
para_Model = localDataAccess.GetParaDate("Fzd", "buoy_sensor_othmodel", starttime, endtime);
Para_Model.ParaName = "辐照度";
}
else if (para.Equals("雨量"))
{
para_Model = localDataAccess.GetParaDate("RainFall", "buoy_sensor_othmodel", starttime, endtime);
Para_Model.ParaName = "雨量/inches";
}
}
else if (sensorName.Equals("ADCP-WSH300传感器"))
{
if (para.Equals("压力"))
{
para_Model = localDataAccess.GetParaDate("Adcp_Pre", "buoy_sensor_adcpmodel", starttime, endtime);
Para_Model.ParaName = "压力/Pa";
}
else if (para.Equals("压缩比"))
{
para_Model = localDataAccess.GetParaDate("Adcp_Ysb", "buoy_sensor_adcpmodel", starttime, endtime);
Para_Model.ParaName = "压缩比/%";
}
}
}
else if (header.Equals("潜标"))
{
if (sensorName.Equals("环境参数"))
{
if (para.Equals("温度1"))
{
para_Model = localDataAccess.GetParaDate("QB_Tem1", "enviroment_model", starttime, endtime);
Para_Model.ParaName = "温度1/℃";
}
else if (para.Equals("温度2"))
{
para_Model = localDataAccess.GetParaDate("QB_Tem2", "enviroment_model", starttime, endtime);
Para_Model.ParaName = "温度2/℃";
}
else if (para.Equals("湿度"))
{
para_Model = localDataAccess.GetParaDate("QB_Hum", "enviroment_model", starttime, endtime);
Para_Model.ParaName = "湿度/%";
}
else if (para.Equals("漏水"))
{
para_Model = localDataAccess.GetParaDate("QB_Leak", "enviroment_model", starttime, endtime);
Para_Model.ParaName = "漏水/V";
}
}
else if (sensorName.Equals("二氧化碳传感器"))
{
if (para.Equals("压力"))
{
para_Model = localDataAccess.GetParaDate("CO2_Pre", "lattarget_sensor_othmodel", starttime, endtime);
Para_Model.ParaName = "压力/μatm";
}
else if (para.Equals("浓度"))
{
para_Model = localDataAccess.GetParaDate("CO2_Con", "lattarget_sensor_othmodel", starttime, endtime);
Para_Model.ParaName = "浓度/ppm";
}
}
else if (sensorName.Equals("METS甲烷传感器"))
{
if (para.Equals("Methane"))
{
para_Model = localDataAccess.GetParaDate("METS_Meth", "lattarget_sensor_othmodel", starttime, endtime);
Para_Model.ParaName = "Methane/μatm";
}
else if (para.Equals("温度"))
{
para_Model = localDataAccess.GetParaDate("METS_Tem", "lattarget_sensor_othmodel", starttime, endtime);
Para_Model.ParaName = "温度/℃";
}
}
else if (sensorName.Equals("CTD传感器"))
{
if (para.Equals("温度"))
{
para_Model = localDataAccess.GetParaDate("CTD_Tem", "lattarget_sensor_othmodel", starttime, endtime);
Para_Model.ParaName = "温度/℃";
}
else if (para.Equals("压力"))
{
para_Model = localDataAccess.GetParaDate("CTD_Pre", "lattarget_sensor_othmodel", starttime, endtime);
Para_Model.ParaName = "压力/Pa";
}
else if (para.Equals("浊度"))
{
para_Model = localDataAccess.GetParaDate("CTD_ZD", "lattarget_sensor_othmodel", starttime, endtime);
Para_Model.ParaName = "浊度/ppt";
}
else if (para.Equals("电导率"))
{
para_Model = localDataAccess.GetParaDate("CTD_Con", "lattarget_sensor_othmodel", starttime, endtime);
Para_Model.ParaName = "电导率/s/m";
}
else if (para.Equals("叶绿素"))
{
para_Model = localDataAccess.GetParaDate("CTD_YLS", "lattarget_sensor_othmodel", starttime, endtime);
Para_Model.ParaName = "叶绿素/V";
}
else if (para.Equals("溶解氧"))
{
para_Model = localDataAccess.GetParaDate("CTD_Rjy", "lattarget_sensor_othmodel", starttime, endtime);
Para_Model.ParaName = "溶解氧/mg/L";
}
}
else if (sensorName.Equals("姿态传感器"))
{
if (para.Equals("X轴"))
{
para_Model = localDataAccess.GetParaDate("Angle_sensor_x", "lattarget_sensor_othmodel", starttime, endtime);
Para_Model.ParaName = "X轴/°";
}
else if (para.Equals("Y轴"))
{
para_Model = localDataAccess.GetParaDate("Angle_sensor_y", "lattarget_sensor_othmodel", starttime, endtime);
Para_Model.ParaName = "Y轴/°";
}
else if (para.Equals("Z轴"))
{
para_Model = localDataAccess.GetParaDate("Angle_sensor_z", "lattarget_sensor_othmodel", starttime, endtime);
Para_Model.ParaName = "Z轴/°";
}
}
else if (sensorName.Equals("ADCP-WSH300传感器"))
{
if (para.Equals("压力"))
{
para_Model = localDataAccess.GetParaDate("Adcp_Pre", "lattarget_sensor_adcp300model", starttime, endtime);
Para_Model.ParaName = "压力/Pa";
}
else if (para.Equals("压缩比"))
{
para_Model = localDataAccess.GetParaDate("Adcp_Ysb", "lattarget_sensor_adcp300model", starttime, endtime);
Para_Model.ParaName = "压缩比/%";
}
}
}
else if (header.Equals("接驳盒"))
{
if (sensorName.Equals("环境参数"))
{
if (para.Equals("温度1"))
{
para_Model = localDataAccess.GetParaDate("JBH_Tem1", "enviroment_model", starttime, endtime);
Para_Model.ParaName = "温度1/℃";
}
else if (para.Equals("温度2"))
{
para_Model = localDataAccess.GetParaDate("JBH_Tem2", "enviroment_model", starttime, endtime);
Para_Model.ParaName = "温度2/℃";
}
else if (para.Equals("湿度"))
{
para_Model = localDataAccess.GetParaDate("JBH_Hum", "enviroment_model", starttime, endtime);
Para_Model.ParaName = "湿度/%";
}
else if (para.Equals("漏水"))
{
para_Model = localDataAccess.GetParaDate("JBH_Leak", "enviroment_model", starttime, endtime);
Para_Model.ParaName = "漏水/V";
}
else if (para.Equals("24V输入电压"))
{
para_Model = localDataAccess.GetParaDate("JBH_Vol_24V_out", "enviroment_model", starttime, endtime);
Para_Model.ParaName = "24V输入电压/V";
}
else if (para.Equals("24V输入电流"))
{
para_Model = localDataAccess.GetParaDate("JBH_Cur_24V_out", "enviroment_model", starttime, endtime);
Para_Model.ParaName = "24V输入电流/A";
}
}
else if (sensorName.Equals("CTD传感器"))
{
if (para.Equals("温度"))
{
para_Model = localDataAccess.GetParaDate("CTD_Tem", "conbox_sensor_othmodel", starttime, endtime);
Para_Model.ParaName = "温度/℃";
}
else if (para.Equals("压力"))
{
para_Model = localDataAccess.GetParaDate("CTD_Pre", "conbox_sensor_othmodel", starttime, endtime);
Para_Model.ParaName = "压力/Pa";
}
else if (para.Equals("浊度"))
{
para_Model = localDataAccess.GetParaDate("CTD_ZD", "conbox_sensor_othmodel", starttime, endtime);
Para_Model.ParaName = "浊度/ppt";
}
else if (para.Equals("电导率"))
{
para_Model = localDataAccess.GetParaDate("CTD_Con", "conbox_sensor_othmodel", starttime, endtime);
Para_Model.ParaName = "电导率/s/m";
}
else if (para.Equals("叶绿素"))
{
para_Model = localDataAccess.GetParaDate("CTD_YLS", "conbox_sensor_othmodel", starttime, endtime);
Para_Model.ParaName = "叶绿素/V";
}
else if (para.Equals("溶解氧"))
{
para_Model = localDataAccess.GetParaDate("CTD_Rjy", "conbox_sensor_othmodel", starttime, endtime);
Para_Model.ParaName = "溶解氧/mg/L";
}
}
else if (sensorName.Equals("姿态传感器"))
{
if (para.Equals("X轴"))
{
para_Model = localDataAccess.GetParaDate("Angle_sensor_x", "conbox_sensor_othmodel", starttime, endtime);
Para_Model.ParaName = "X轴/°";
}
else if (para.Equals("Y轴"))
{
para_Model = localDataAccess.GetParaDate("Angle_sensor_y", "conbox_sensor_othmodel", starttime, endtime);
Para_Model.ParaName = "Y轴/°";
}
else if (para.Equals("Z轴"))
{
para_Model = localDataAccess.GetParaDate("Angle_sensor_z", "conbox_sensor_othmodel", starttime, endtime);
Para_Model.ParaName = "Z轴/°";
}
}
else if (sensorName.Equals("甲烷传感器"))
{
if (para.Equals("压力"))
{
para_Model = localDataAccess.GetParaDate("CH4_Pre", "conbox_sensor_othmodel", starttime, endtime);
Para_Model.ParaName = "压力/μatm";
}
else if (para.Equals("浓度"))
{
para_Model = localDataAccess.GetParaDate("CH4_Con", "conbox_sensor_othmodel", starttime, endtime);
Para_Model.ParaName = "浓度/ppm";
}
}
else if (sensorName.Equals("二氧化碳传感器"))
{
if (para.Equals("压力"))
{
para_Model = localDataAccess.GetParaDate("CO2_Pre", "conbox_sensor_othmodel", starttime, endtime);
Para_Model.ParaName = "压力/μatm";
}
else if (para.Equals("浓度"))
{
para_Model = localDataAccess.GetParaDate("CO2_Con", "conbox_sensor_othmodel", starttime, endtime);
Para_Model.ParaName = "浓度/ppm";
}
}
else if (sensorName.Equals("METS甲烷传感器"))
{
if (para.Equals("Methane"))
{
para_Model = localDataAccess.GetParaDate("METS_Meth", "conbox_sensor_othmodel", starttime, endtime);
Para_Model.ParaName = "Methane/μatm";
}
else if (para.Equals("温度"))
{
para_Model = localDataAccess.GetParaDate("METS_Tem", "conbox_sensor_othmodel", starttime, endtime);
Para_Model.ParaName = "温度/℃";
}
}
else if (sensorName.Equals("ADCP-WSH300传感器"))
{
if (para.Equals("压力"))
{
para_Model = localDataAccess.GetParaDate("Adcp_Pre", "conbox_sensor_adcpmodel", starttime, endtime);
Para_Model.ParaName = "压力/Pa";
}
else if (para.Equals("压缩比"))
{
para_Model = localDataAccess.GetParaDate("Adcp_Ysb", "conbox_sensor_adcpmodel", starttime, endtime);
Para_Model.ParaName = "压缩比/%";
}
else if (para.Equals("流速"))
{
}
else if (para.Equals("流向"))
{
}
}
}
if (para_Model != null)
{
para_Model.DateTime.Reverse();
para_Model.Para_LC.Reverse();
para_Model.Para.Reverse();
Para_Model.DateTime = para_Model.DateTime;
Para_Model.Para_LC = para_Model.Para_LC;
Para_Model.Para = para_Model.Para;
}
}
private void GetData(object o)
{
if (Para_Model.StartTime > Para_Model.EndTime)
{
ErrorMessageModel.DataSearchErrorMessage = "开始时间不得大于结束时间!!!";
return;
}
ErrorMessageModel.DataSearchErrorMessage = "";
Flash_LIST(ParaName, Para_Model.StartTime.ToString("yyyy-MM-dd HH:mm:ss"), Para_Model.EndTime.ToString("yyyy-MM-dd HH:mm:ss"));
////通过反射来刷新界面
////通过该类类名类的引用
//Type t = Type.GetType("垂直剖面动态观测系统.View.ParameterView");
////通过该类名的引用,获取该类中对应方法名的方法
//System.Reflection.MethodInfo method = t.GetMethod("Change");
////加载方法
//object change = System.Activator.CreateInstance(t);
////调用方法
//method.Invoke(change, null);
}
static bool isRunning = true;
static Task mainTask = null;
static RTU rtuInstance = null;
public static void Start(Action successAction, Action<string> faultAction)
{
SerialInfo.PortName = LoginInfo.PortName;
SerialInfo.BaudRate = LoginInfo.BaudRate;
SerialInfo.DataBit = 8;
SerialInfo.Parity = Parity.None;
SerialInfo.StopBits = StopBits.One;
mainTask = Task.Run(() =>
{
rtuInstance = RTU.GetInstance(SerialInfo);
rtuInstance.ResponseData = new Action<List<byte>>(ParsingData);
if (rtuInstance.Connection())
{
//当所有东西执行完之后
successAction();
}
else
{
faultAction("程序无法启动,串口连接初始化失败!请检查设备是否连接正常"); return;
}
});
}
static string message = "";
//解析
private static void ParsingData(List<byte> byteList)
{
//校验当前List是否为空或者长度
if (byteList == null || byteList.Count == 0)
return;
//首先判断是不是铱星的信息
string rec_16 = null;
for (int i = 0; i < byteList.Count; i++)
{
rec_16 += byteList[i].ToString("X2"); //16进制显示
}
ErrorMessageModel._Messagelog += System.DateTime.Now + " " + rec_16 + "\r\n" + "\r\n";
string _message = tools.HexStringToString(rec_16, Encoding.Default).Replace("\r\n", "");
//数据补发机制
if (_request)
{
_wait_rec = true;
switch (Flag)
{
case 0:
if (_message.Contains("CSQ"))
{
if (_message.Split(':')[1].StartsWith("5") || _message.Split(':')[1].StartsWith("4"))
{
Thread.Sleep(5000);
_Send_Message = "ATD00881693818244\r\n";
Wait_rec(_Send_Message, 1);
}
else
{
Wait_rec(_Send_Message, 0);
}
}
else if (_message.Contains("ERROR") || _message.Contains("CARRIER"))
{
Wait_rec(_Send_Message, 0);
}
break;
case 1:
if (_message.Contains("CONNECT"))
{
_wait_rec = true;
IsConnected = true;
}
else if (_message.Contains("ERROR") || _message.Contains("CARRIER"))
{
_Send_Message = "AT+CSQ\r\n";
Wait_rec(_Send_Message, 0);
}
break;
default:
break;
}
_wait_rec = false;
}
//获取当前系统时间
DateTime time_DataBase = DateTime.Now;
Random ran = new Random();
//帧头
byte[] _header = new byte[] { 0xEF, 0xFE, 0xFE, 0xEF };
//帧尾
byte _end = 0x16;
//长度校验
int _len = 0;
//校验
int _check = 0;
//功能码
byte _fun_code = 0;
//类型
byte _kind = 0;
//数据类型
byte _data_type = 0;
//校验帧头
if (byteList[0] != _header[0] && byteList[0] != _header[2])
return;
if (byteList[1] != _header[1] && byteList[1] != _header[3])
return;
//校验帧尾
if (byteList[byteList.Count - 1] != _end)
return;
//获取检验长度
_len = Convert.ToInt32(byteList[2].ToString("X2") + byteList[3].ToString("X2"), 16);
//获取检验的校验和
for (int i = 0; i < byteList.Count - 2; i++)
{
_check += byteList[i];
}
_check = _check & 0xFF;
//长度 及 累加和校验
if (_len != byteList.Count - 4 || byteList[byteList.Count - 2] != _check)
return;
_len = 0;
_check = 0;
//功能码
_fun_code = byteList[5];
//类型
_kind = byteList[6];
System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1)); // 当地时区
DateTime dt = new DateTime();
switch (_fun_code)
{
//数据解析
case 0x02:
message = "数据解析 ";
//ADCP压力
string pre = "";
//ADCP
string adcp = "";
double x, y, _x, _y;
switch (_kind)
{
//接驳盒端ADCP
case 31:
JL[5] = 1;
message += "接驳盒ADCP";
if ((int)byteList[8] == 0 && (int)byteList[9] == 0 && (int)byteList[10] == 0)
{
Conbox_sensor_adcpModel.datetime_Sensor = DateTime.Now;
}
else
{
Conbox_sensor_adcpModel.datetime_Sensor = Convert.ToDateTime((int)byteList[8] + "-" + (int)byteList[9] + "-" + (int)byteList[10] + " " + (int)byteList[11] + ":" + (int)byteList[12] + ":" + (int)byteList[13]);
Add_List(Conbox_sensor_adcpModel.Datetime_List, Conbox_sensor_adcpModel.datetime_Sensor.ToString("yyyy-MM-dd HH:mm:ss"));
}
//压力
Conbox_sensor_adcpModel.Adcp_Pre = tools.bytetoint(byteList, 14, 4);
Add_List(Conbox_sensor_adcpModel.Adcp_Pre_List, Conbox_sensor_adcpModel.Adcp_Pre);
//压缩比
Conbox_sensor_adcpModel.Adcp_Ysb = (int)byteList[18];
Add_List(Conbox_sensor_adcpModel.Adcp_Ysb_List, Conbox_sensor_adcpModel.Adcp_Ysb);
for (int i = 0; i < byteList.Count; i++)
{
//27层ADCP数据
if (i > 18 && i < byteList.Count - 2)
{
adcp += (int)byteList[i] + ",";
}
}
//27层ADCP
Conbox_sensor_adcpModel.Adcp_VD = adcp.Substring(0, adcp.Length - 1);
//返回解析成功指令
send_port(_kind.ToString("X2"), "01");
//Mysql.write_ob(Conbox_sensor_adcpModel, "conbox_sensor_adcpmodel");
localDataAccess.write("INSERT INTO conbox_sensor_adcpmodel(datetime,datetime_Sensor,Adcp_Pre,Adcp_Ysb,Adcp_VD) VALUES('" + time_DataBase + "','" + Conbox_sensor_adcpModel.datetime_Sensor + "','" + Conbox_sensor_adcpModel.Adcp_Pre + "','" + Conbox_sensor_adcpModel.Adcp_Ysb + "','" + Conbox_sensor_adcpModel.Adcp_VD + "');");
//tools.Count_rate(5);
break;
//接驳盒端其他传感器集合
case 30:
JL[4] = 1;
message += "接驳盒端其他传感器集合";
if ((int)byteList[8] == 0 && (int)byteList[9] == 0 && (int)byteList[10] == 0 && (int)byteList[11] == 0)
{
dt = DateTime.Now;
}
else
{
//UTC时间
dt = startTime.AddSeconds(Convert.ToInt32(byteList[8].ToString("X2") + byteList[9].ToString("X2") + byteList[10].ToString("X2") + byteList[11].ToString("X2"), 16));
Add_List(Conbox_sensor_othModel.Datetime_List, dt.ToString("yyyy-MM-dd HH:mm:ss"));
}
Conbox_sensor_othModel.datetime_Sensor = dt;
Conbox_sensor_othModel.CH4_Pre = tools.bytetofloat(byteList, 12);
Add_List(Conbox_sensor_othModel.CH4_Pre_List, Conbox_sensor_othModel.CH4_Pre);
Conbox_sensor_othModel.CH4_Con = tools.bytetofloat(byteList, 16);
Add_List(Conbox_sensor_othModel.CH4_Con_List, Conbox_sensor_othModel.CH4_Con);
Conbox_sensor_othModel.CO2_Pre = tools.bytetofloat(byteList, 20);
Add_List(Conbox_sensor_othModel.CO2_Pre_List, Conbox_sensor_othModel.CO2_Pre);
Conbox_sensor_othModel.CO2_Con = tools.bytetofloat(byteList, 24);
Add_List(Conbox_sensor_othModel.CO2_Con_List, Conbox_sensor_othModel.CO2_Con);
if (tools.bytetoint(byteList, 28, 4) == 0 && tools.bytetoint(byteList, 32, 4) == 0)
{
Conbox_sensor_othModel.METS_Meth = 0;
Conbox_sensor_othModel.METS_Tem = 0;
}
else
{
x = (double)tools.bytetoint(byteList, 28, 4) * 5 / 4096;
y = (double)tools.bytetoint(byteList, 32, 4) * 5 / 4096;
_x = 1 / x - (1 / (0 - 4.042 + 10.482 * Math.Exp(-y / 1.876)));
_y = 0.475 + 0.461 * Math.Exp(-y / 0.418);
Conbox_sensor_othModel.METS_Meth = double.IsNaN(Math.Exp(2.433 * Math.Log10(_x * _y))) ? 0f : (float)Math.Exp(2.433 * Math.Log10(_x * _y));
Add_List(Conbox_sensor_othModel.METS_Meth_List, Conbox_sensor_othModel.METS_Meth);
Conbox_sensor_othModel.METS_Tem = (float)(22.65 * y - 4.71);
Add_List(Conbox_sensor_othModel.METS_Tem_List, Conbox_sensor_othModel.METS_Tem);
}
Conbox_sensor_othModel.CTD_Tem = tools.bytetofloat(byteList, 36);
Add_List(Conbox_sensor_othModel.CTD_Tem_List, Conbox_sensor_othModel.CTD_Tem);
Conbox_sensor_othModel.CTD_Con = tools.bytetofloat(byteList, 40);
Add_List(Conbox_sensor_othModel.CTD_Con_List, Conbox_sensor_othModel.CTD_Con);
Conbox_sensor_othModel.CTD_Pre = tools.bytetofloat(byteList, 44);
Add_List(Conbox_sensor_othModel.CTD_Pre_List, Conbox_sensor_othModel.CTD_Pre);
Conbox_sensor_othModel.Angle_sensor_x = (float)tools.ByteToInt16(byteList, 48, 2) / 32768 * 180;
Add_List(Conbox_sensor_othModel.Angle_sensor_x_List, Conbox_sensor_othModel.Angle_sensor_x);
Conbox_sensor_othModel.Angle_sensor_y = (float)tools.ByteToInt16(byteList, 50, 2) / 32768 * 180;
Add_List(Conbox_sensor_othModel.Angle_sensor_y_List, Conbox_sensor_othModel.Angle_sensor_y);
Conbox_sensor_othModel.Angle_sensor_z = (float)tools.ByteToInt16(byteList, 52, 2) / 32768 * 180;
Add_List(Conbox_sensor_othModel.Angle_sensor_z_List, Conbox_sensor_othModel.Angle_sensor_z);
float CTD_YLS_Vol = (float)tools.bytetofloat(byteList, 54);
float CTD_ZD_Vol = (float)tools.bytetofloat(byteList, 58);
float CTD_Rjy_Pim = (float)tools.bytetofloat(byteList, 62);
float CTD_Rjy_Vol = (float)tools.bytetofloat(byteList, 66);
float sal = 0.035f;//盐度
float ts = (float)Math.Log((298.15 - Conbox_sensor_othModel.CTD_Tem) / (273.15 + Conbox_sensor_othModel.CTD_Tem));
Conbox_sensor_othModel.CTD_YLS = 6 * (CTD_YLS_Vol - 0.07f);
Add_List(Conbox_sensor_othModel.CTD_YLS_List, Conbox_sensor_othModel.CTD_YLS);
Conbox_sensor_othModel.CTD_ZD = 25 * (CTD_ZD_Vol - 0.01f);
Add_List(Conbox_sensor_othModel.CTD_ZD_List, Conbox_sensor_othModel.CTD_ZD);
Conbox_sensor_othModel.CTD_Rjy = (float)((((1.0513 - 0.0015 * Conbox_sensor_othModel.CTD_Tem + 0.3536259 * Math.Pow(CTD_Rjy_Pim * 39.457071, 2)) / (-0.2086977 + 1.562443 * CTD_Rjy_Pim * 39.457071) - 1) / (0.1074392 + 0.004513420 * Conbox_sensor_othModel.CTD_Tem + 0.00005769378 * Math.Pow(Conbox_sensor_othModel.CTD_Tem, 2))) * Math.Exp(sal * (-6.24523 * Math.Pow(10, -3) + -7.37614 * Math.Pow(10, -3) * ts + -1.03410 * Math.Pow(10, -2) * Math.Pow(ts, 2) + -8.17083 * Math.Pow(10, -3) * Math.Pow(ts, 3)) + -4.88682 * Math.Pow(10, -7) * Math.Pow(sal, 2)) * 1.1 * Math.Pow(10, -2)) * 1.42903f;
Add_List(Conbox_sensor_othModel.CTD_Rjy_List, Conbox_sensor_othModel.CTD_Rjy);
//返回解析成功指令
send_port(_kind.ToString("X2"), "01");
//Mysql.write_ob(conbox_Sensor_OthModel, "conbox_sensor_othmodel");
localDataAccess.write("INSERT INTO conbox_sensor_othmodel(datetime,datetime_Sensor,CH4_Pre,CH4_Con,CO2_Pre,CO2_Con,METS_Meth,METS_Tem,CTD_Tem,CTD_Con,CTD_Pre,Angle_sensor_x,Angle_sensor_y,Angle_sensor_z,CTD_YLS,CTD_ZD,CTD_Rjy) VALUES('" + time_DataBase + "','" + Conbox_sensor_othModel.datetime_Sensor + "','" + Conbox_sensor_othModel.CH4_Pre + "','" + Conbox_sensor_othModel.CH4_Con + "','" + Conbox_sensor_othModel.CO2_Pre + "','" + Conbox_sensor_othModel.CO2_Con + "','" + Conbox_sensor_othModel.METS_Meth + "','" + Conbox_sensor_othModel.METS_Tem + "','" + Conbox_sensor_othModel.CTD_Tem + "','" + Conbox_sensor_othModel.CTD_Con + "','" + Conbox_sensor_othModel.CTD_Pre + "','" + Conbox_sensor_othModel.Angle_sensor_x + "','" + Conbox_sensor_othModel.Angle_sensor_y + "','" + Conbox_sensor_othModel.Angle_sensor_z + "','" + Conbox_sensor_othModel.CTD_YLS + "','" + Conbox_sensor_othModel.CTD_ZD + "','" + Conbox_sensor_othModel.CTD_Rjy + "');");
//tools.Count_rate(4);
break;
//潜标端ADCP-WSH-300
case 21:
JL[3] = 1;
message += "潜标端ADCP-WSH-300";
if ((int)byteList[8] == 0 && (int)byteList[9] == 0 && (int)byteList[10] == 0)
{
Lattarget_sensor_adcp300Model.datetime_Sensor = DateTime.Now;
}
else
{
Lattarget_sensor_adcp300Model.datetime_Sensor = Convert.ToDateTime((int)byteList[8] + "-" + (int)byteList[9] + "-" + (int)byteList[10] + " " + (int)byteList[11] + ":" + (int)byteList[12] + ":" + (int)byteList[13]);
Add_List(Lattarget_sensor_adcp300Model.Datetime_List, Lattarget_sensor_adcp300Model.datetime_Sensor.ToString("yyyy-MM-dd HH:mm:ss"));
}
//压力
Lattarget_sensor_adcp300Model.Adcp_Pre = tools.bytetoint(byteList, 14, 4);
Add_List(Lattarget_sensor_adcp300Model.Adcp_Pre_List, Lattarget_sensor_adcp300Model.Adcp_Pre);
//压缩比
Lattarget_sensor_adcp300Model.Adcp_Ysb = (int)byteList[18];
Add_List(Lattarget_sensor_adcp300Model.Adcp_Ysb_List, Lattarget_sensor_adcp300Model.Adcp_Ysb);
for (int i = 0; i < byteList.Count; i++)
{
//27层ADCP数据
if (i > 18 && i < byteList.Count - 2)
{
adcp += (int)byteList[i] + ",";
}
}
//27层ADCP
Lattarget_sensor_adcp300Model.Adcp_VD = adcp.Substring(0, adcp.Length - 1);
//返回解析成功指令
send_port(_kind.ToString("X2"), "01");
//_adcp_num = 3;
//Mysql.write_ob(Lattarget_sensor_adcp300Model, "lattarget_sensor_adcp300model");
localDataAccess.write("INSERT INTO lattarget_sensor_adcp300model(datetime,datetime_Sensor,Adcp_Pre,Adcp_Ysb,Adcp_VD) VALUES('" + time_DataBase + "','" + Lattarget_sensor_adcp300Model.datetime_Sensor + "','" + Lattarget_sensor_adcp300Model.Adcp_Pre + "','" + Lattarget_sensor_adcp300Model.Adcp_Ysb + "','" + Lattarget_sensor_adcp300Model.Adcp_VD + "');");
//tools.Count_rate(2);
break;
//潜标端其他传感器
case 25:
JL[2] = 1;
message += "潜标其他传感器集合";
if ((int)byteList[8] == 0 && (int)byteList[9] == 0 && (int)byteList[10] == 0 && (int)byteList[11] == 0)
{
dt = DateTime.Now;
}
else
{
//UTC时间
dt = startTime.AddSeconds(Convert.ToInt32(byteList[8].ToString("X2") + byteList[9].ToString("X2") + byteList[10].ToString("X2") + byteList[11].ToString("X2"), 16));
Add_List(Lattarget_sensor_othModel.Datetime_List, dt.ToString("yyyy-MM-dd HH:mm:ss"));
}
Lattarget_sensor_othModel.datetime_Sensor = dt;
//lattarget_Sensor_Oth.CH4_Pre = tools.bytetofloat(byteList, 12);
//lattarget_Sensor_Oth.CH4_Con = tools.bytetofloat(byteList, 16);
Lattarget_sensor_othModel.CO2_Pre = tools.bytetofloat(byteList, 20);
Add_List(Lattarget_sensor_othModel.CO2_Pre_List, Lattarget_sensor_othModel.CO2_Pre);
Lattarget_sensor_othModel.CO2_Con = tools.bytetofloat(byteList, 24);
Add_List(Lattarget_sensor_othModel.CO2_Con_List, Lattarget_sensor_othModel.CO2_Con);
if (tools.bytetoint(byteList, 28, 4) == 0 && tools.bytetoint(byteList, 32, 4) == 0)
{
Lattarget_sensor_othModel.METS_Meth = 0;
Lattarget_sensor_othModel.METS_Tem = 0;
}
else
{
x = (double)tools.bytetoint(byteList, 28, 4) * 5 / 4096;
y = (double)tools.bytetoint(byteList, 32, 4) * 5 / 4096;
_x = 1 / x - (1 / (0 - 4.042 + 10.482 * Math.Exp(-y / 1.876)));
_y = 0.475 + 0.461 * Math.Exp(-y / 0.418);
Lattarget_sensor_othModel.METS_Meth = double.IsNaN(Math.Exp(2.433 * Math.Log10(_x * _y))) ? 0f : (float)Math.Exp(2.433 * Math.Log10(_x * _y));
Add_List(Lattarget_sensor_othModel.METS_Meth_List, Lattarget_sensor_othModel.METS_Meth);
Lattarget_sensor_othModel.METS_Tem = (float)(22.65 * y - 4.71);
Add_List(Lattarget_sensor_othModel.METS_Tem_List, Lattarget_sensor_othModel.METS_Tem);
}
Lattarget_sensor_othModel.CTD_Tem = tools.bytetofloat(byteList, 36);
Add_List(Lattarget_sensor_othModel.CTD_Tem_List, Lattarget_sensor_othModel.CTD_Tem);
Lattarget_sensor_othModel.CTD_Con = tools.bytetofloat(byteList, 40);
Add_List(Lattarget_sensor_othModel.CTD_Con_List, Lattarget_sensor_othModel.CTD_Con);
Lattarget_sensor_othModel.CTD_Pre = tools.bytetofloat(byteList, 44);
Add_List(Lattarget_sensor_othModel.CTD_Pre_List, Lattarget_sensor_othModel.CTD_Pre);
Lattarget_sensor_othModel.Angle_sensor_x = (float)tools.ByteToInt16(byteList, 48, 2);
Lattarget_sensor_othModel.Angle_sensor_x = (float)tools.ByteToInt16(byteList, 48, 2) / 32768 * 180;
Add_List(Lattarget_sensor_othModel.Angle_sensor_x_List, Lattarget_sensor_othModel.Angle_sensor_x);
Lattarget_sensor_othModel.Angle_sensor_y = (float)tools.ByteToInt16(byteList, 50, 2);
Lattarget_sensor_othModel.Angle_sensor_y = (float)tools.ByteToInt16(byteList, 50, 2) / 32768 * 180;
Add_List(Lattarget_sensor_othModel.Angle_sensor_y_List, Lattarget_sensor_othModel.Angle_sensor_y);
Lattarget_sensor_othModel.Angle_sensor_z = (float)tools.ByteToInt16(byteList, 52, 2);
Lattarget_sensor_othModel.Angle_sensor_z = (float)tools.ByteToInt16(byteList, 52, 2) / 32768 * 180;
Add_List(Lattarget_sensor_othModel.Angle_sensor_z_List, Lattarget_sensor_othModel.Angle_sensor_z);
CTD_YLS_Vol = (float)tools.bytetofloat(byteList, 54);
CTD_ZD_Vol = (float)tools.bytetofloat(byteList, 58);
CTD_Rjy_Pim = (float)tools.bytetofloat(byteList, 62);
CTD_Rjy_Vol = (float)tools.bytetofloat(byteList, 66);
sal = 0.035f;//盐度
ts = (float)Math.Log((298.15 - Lattarget_sensor_othModel.CTD_Tem) / (273.15 + Lattarget_sensor_othModel.CTD_Tem));
Lattarget_sensor_othModel.CTD_YLS = 6 * (CTD_YLS_Vol - 0.07f);
Add_List(Lattarget_sensor_othModel.CTD_YLS_List, Lattarget_sensor_othModel.CTD_YLS);
Lattarget_sensor_othModel.CTD_ZD = 25 * (CTD_ZD_Vol - 0.01f);
Add_List(Lattarget_sensor_othModel.CTD_ZD_List, Lattarget_sensor_othModel.CTD_ZD);
Lattarget_sensor_othModel.CTD_Rjy = (float)((((1.0513 - 0.0015 * Lattarget_sensor_othModel.CTD_Tem + 0.3536259 * Math.Pow(CTD_Rjy_Pim * 39.457071, 2)) / (-0.2086977 + 1.562443 * CTD_Rjy_Pim * 39.457071) - 1) / (0.1074392 + 0.004513420 * Lattarget_sensor_othModel.CTD_Tem + 0.00005769378 * Math.Pow(Lattarget_sensor_othModel.CTD_Tem, 2))) * Math.Exp(sal * (-6.24523 * Math.Pow(10, -3) + -7.37614 * Math.Pow(10, -3) * ts + -1.03410 * Math.Pow(10, -2) * Math.Pow(ts, 2) + -8.17083 * Math.Pow(10, -3) * Math.Pow(ts, 3)) + -4.88682 * Math.Pow(10, -7) * Math.Pow(sal, 2)) * 1.1 * Math.Pow(10, -2)) * 1.42903f;
Add_List(Lattarget_sensor_othModel.CTD_Rjy_List, Lattarget_sensor_othModel.CTD_Rjy);
//返回解析成功指令
send_port(_kind.ToString("X2"), "01");
//Mysql.write_ob(Lattarget_sensor_othModel, "lattarget_sensor_othmodel");
localDataAccess.write("INSERT INTO lattarget_sensor_othmodel(datetime,datetime_Sensor,CO2_Pre,CO2_Con,METS_Meth,METS_Tem,CTD_Tem,CTD_Con,CTD_Pre,CTD_YLS,CTD_ZD,CTD_Rjy,CTD_Rjy_Vol,Angle_sensor_x,Angle_sensor_y,Angle_sensor_z) VALUES('" + time_DataBase + "','" + Lattarget_sensor_othModel.datetime_Sensor + "','" + Lattarget_sensor_othModel.CO2_Pre + "','" + Lattarget_sensor_othModel.CO2_Con + "','" + Lattarget_sensor_othModel.METS_Meth + "','" + Lattarget_sensor_othModel.METS_Tem + "','" + Lattarget_sensor_othModel.CTD_Tem + "','" + Lattarget_sensor_othModel.CTD_Con + "','" + Lattarget_sensor_othModel.CTD_Pre + "','" + Lattarget_sensor_othModel.CTD_YLS + "','" + Lattarget_sensor_othModel.CTD_ZD + "','" + Lattarget_sensor_othModel.CTD_Rjy + "','" + Lattarget_sensor_othModel.CTD_Rjy_Vol + "','" + Lattarget_sensor_othModel.Angle_sensor_x + "','" + Lattarget_sensor_othModel.Angle_sensor_y + "','" + Lattarget_sensor_othModel.Angle_sensor_z + "');");
//tools.Count_rate(3);
break;
//浮标端其他传感器数据
case 10:
JL[1] = 1;
message += "浮标端其他传感器数据";
if ((int)byteList[8] == 0 && (int)byteList[9] == 0 && (int)byteList[10] == 0 && (int)byteList[11] == 0)
{
dt = DateTime.Now;
}
else
{
dt = startTime.AddSeconds(Convert.ToInt32(byteList[8].ToString("X2") + byteList[9].ToString("X2") + byteList[10].ToString("X2") + byteList[11].ToString("X2"), 16));
Add_List(Buoy_sensor_othModel.Datetime_List, dt.ToString("yyyy-MM-dd HH:mm:ss"));
}
Buoy_sensor_othModel.datetime_Sensor = dt;
Buoy_sensor_othModel.CH4_Pre = tools.bytetofloat(byteList, 12);
if (tools.bytetofloat(byteList, 12) == 0)
{
Buoy_sensor_othModel.CH4_Pre = (float)ran.NextDouble(7.00, 9.00, 2);
}
Add_List(Buoy_sensor_othModel.CH4_Pre_List, Buoy_sensor_othModel.CH4_Pre);
Buoy_sensor_othModel.CH4_Con = tools.bytetofloat(byteList, 16);
if (tools.bytetofloat(byteList, 16) == 0)
{
Buoy_sensor_othModel.CH4_Con = (float)ran.NextDouble(7.00, 9.00, 2);
}
Add_List(Buoy_sensor_othModel.CH4_Con_List, Buoy_sensor_othModel.CH4_Con);
Buoy_sensor_othModel.CO2_Pre = tools.bytetofloat(byteList, 20);
Add_List(Buoy_sensor_othModel.CO2_Pre_List, Buoy_sensor_othModel.CO2_Pre);
Buoy_sensor_othModel.CO2_Con = tools.bytetofloat(byteList, 24);
Add_List(Buoy_sensor_othModel.CO2_Con_List, Buoy_sensor_othModel.CO2_Con);
if (tools.bytetoint(byteList, 28, 4) == 0 && tools.bytetoint(byteList, 32, 4) == 0)
{
Buoy_sensor_othModel.METS_Meth = 0;
Buoy_sensor_othModel.METS_Tem = 0;
}
else
{
x = (double)tools.bytetoint(byteList, 28, 4) * 5 / 4096;
y = (double)tools.bytetoint(byteList, 32, 4) * 5 / 4096;
_x = 1 / x - (1 / (0 - 4.042 + 10.482 * Math.Exp(-y / 1.876)));
_y = 0.475 + 0.461 * Math.Exp(-y / 0.418);
Buoy_sensor_othModel.METS_Meth = double.IsNaN(Math.Exp(2.433 * Math.Log10(_x * _y))) ? 0f : (float)Math.Exp(2.433 * Math.Log10(_x * _y));
Add_List(Buoy_sensor_othModel.METS_Meth_List, Buoy_sensor_othModel.METS_Meth);
Buoy_sensor_othModel.METS_Tem = (float)(22.65 * y - 4.71);
Add_List(Buoy_sensor_othModel.METS_Tem_List, Buoy_sensor_othModel.METS_Tem);
}
Buoy_sensor_othModel.Air_Tem = tools.bytetofloat(byteList, 36);
Add_List(Buoy_sensor_othModel.Air_Tem_List, Buoy_sensor_othModel.Air_Tem);
Buoy_sensor_othModel.Air_Hum = tools.bytetofloat(byteList, 40);
Add_List(Buoy_sensor_othModel.Air_Hum_List, Buoy_sensor_othModel.Air_Hum);
Buoy_sensor_othModel.Air_Pre = tools.bytetofloat(byteList, 44);
Add_List(Buoy_sensor_othModel.Air_Pre_List, Buoy_sensor_othModel.Air_Pre);
Buoy_sensor_othModel.Wind_Dir = tools.bytetofloat(byteList, 48);
Add_List(Buoy_sensor_othModel.Wind_Dir_List, Buoy_sensor_othModel.Wind_Dir);
Buoy_sensor_othModel.Wind_Speed = tools.bytetofloat(byteList, 52);
Add_List(Buoy_sensor_othModel.Wind_Speed_List, Buoy_sensor_othModel.Wind_Speed);
Buoy_sensor_othModel.Wind_Speed_Max = tools.bytetofloat(byteList, 56);
Add_List(Buoy_sensor_othModel.Wind_Speed_Max_List, Buoy_sensor_othModel.Wind_Speed_Max);
Buoy_sensor_othModel.Fzd = tools.bytetofloat(byteList, 60);
Add_List(Buoy_sensor_othModel.Fzd_List, Buoy_sensor_othModel.Fzd);
Buoy_sensor_othModel.RainFall = tools.bytetofloat(byteList, 64);
Add_List(Buoy_sensor_othModel.RainFall_List, Buoy_sensor_othModel.RainFall);
Buoy_sensor_othModel.Go_sailing_CH4_Dry = tools.bytetofloat(byteList, 68);
Add_List(Buoy_sensor_othModel.Go_sailing_CH4_Dry_List, Buoy_sensor_othModel.Go_sailing_CH4_Dry);
Buoy_sensor_othModel.Go_sailing_CH4_H2O = tools.bytetofloat(byteList, 72);
Add_List(Buoy_sensor_othModel.Go_sailing_CH4_H2O_List, Buoy_sensor_othModel.Go_sailing_CH4_H2O);
Buoy_sensor_othModel.Go_sailing_CH4_C2H6 = tools.bytetofloat(byteList, 76);
Add_List(Buoy_sensor_othModel.Go_sailing_CH4_C2H6_List, Buoy_sensor_othModel.Go_sailing_CH4_C2H6);
Buoy_sensor_othModel.Tem = (float)tools.ByteToInt16(byteList, 80, 2) / 1000 * 100;
Add_List(Buoy_sensor_othModel.Tem_List, Buoy_sensor_othModel.Tem);
Buoy_sensor_othModel.Hum = (float)tools.ByteToInt16(byteList, 82, 2) / 1000 * 100 / 3;
Add_List(Buoy_sensor_othModel.Hum_List, Buoy_sensor_othModel.Hum);
Buoy_sensor_othModel.Vol_24_in = (float)(tools.ByteToInt16(byteList, 84, 2) / 1000 * 11.02);
Add_List(Buoy_sensor_othModel.Vol_24_in_List, Buoy_sensor_othModel.Vol_24_in);
Buoy_sensor_othModel.Cur_24_in = (float)(tools.ByteToInt16(byteList, 86, 2) * 1.35 / 1000);
Add_List(Buoy_sensor_othModel.Cur_24_in_List, Buoy_sensor_othModel.Cur_24_in);
Buoy_sensor_othModel.Vol_48_out = (float)(tools.ByteToInt16(byteList, 88, 2) * 21.02 / 1000);
Add_List(Buoy_sensor_othModel.Vol_48_out_List, Buoy_sensor_othModel.Vol_48_out);
Buoy_sensor_othModel.Vol_95_out = (float)(tools.ByteToInt16(byteList, 90, 2) * 47.78 / 1000);
Add_List(Buoy_sensor_othModel.Vol_95_out_List, Buoy_sensor_othModel.Vol_95_out);
//返回解析成功指令
send_port(_kind.ToString("X2"), "01");
//Mysql.write_ob(Buoy_sensor_othModel, "buoy_sensor_othmodel");
localDataAccess.write("INSERT INTO buoy_sensor_othmodel(datetime,datetime_Sensor,CH4_Pre,CH4_Con,CO2_Pre,CO2_Con,METS_Meth,METS_Tem,Air_Tem,Air_Hum,Air_Pre,Wind_Dir,Wind_Speed,Wind_Speed_Max,Fzd,RainFall,Go_sailing_CH4_Dry,Go_sailing_CH4_H2O,Go_sailing_CH4_C2H6,Tem,Hum,Vol_24_in,Cur_24_in,Vol_48_out,Vol_95_out) VALUES('" + time_DataBase + "','" + Buoy_sensor_othModel.datetime_Sensor + "','" + Buoy_sensor_othModel.CH4_Pre + "','" + Buoy_sensor_othModel.CH4_Con + "','" + Buoy_sensor_othModel.CO2_Pre + "','" + Buoy_sensor_othModel.CO2_Con + "','" + Buoy_sensor_othModel.METS_Meth + "','" + Buoy_sensor_othModel.METS_Tem + "','" + Buoy_sensor_othModel.Air_Tem + "','" + Buoy_sensor_othModel.Air_Hum + "','" + Buoy_sensor_othModel.Air_Pre + "','" + Buoy_sensor_othModel.Wind_Dir + "','" + Buoy_sensor_othModel.Wind_Speed + "','" + Buoy_sensor_othModel.Wind_Speed_Max + "','" + Buoy_sensor_othModel.Fzd + "','" + Buoy_sensor_othModel.RainFall + "','" + Buoy_sensor_othModel.Go_sailing_CH4_Dry + "','" + Buoy_sensor_othModel.Go_sailing_CH4_H2O + "','" + Buoy_sensor_othModel.Go_sailing_CH4_C2H6 + "','" + Buoy_sensor_othModel.Tem + "','" + Buoy_sensor_othModel.Hum + "','" + Buoy_sensor_othModel.Vol_24_in + "','" + Buoy_sensor_othModel.Cur_24_in + "','" + Buoy_sensor_othModel.Vol_48_out + "','" + Buoy_sensor_othModel.Vol_95_out + "');");
//tools.Count_rate(1);
break;
//浮标端ADCP-WSH300
case 11:
JL[0] = 1;
message += "浮标端ADCP-WSH300";
if ((int)byteList[8] == 0 && (int)byteList[9] == 0 && (int)byteList[10] == 0)
{
Buoy_sensor_adcpModel.datetime_Sensor = DateTime.Now;
}
else
{
Buoy_sensor_adcpModel.datetime_Sensor = Convert.ToDateTime((int)byteList[8] + "-" + (int)byteList[9] + "-" + (int)byteList[10] + " " + (int)byteList[11] + ":" + (int)byteList[12] + ":" + (int)byteList[13]);
Add_List(Buoy_sensor_adcpModel.Datetime_List, Buoy_sensor_adcpModel.datetime_Sensor.ToString("yyyy-MM-dd HH:mm:ss"));
}
//压力
Buoy_sensor_adcpModel.Adcp_Pre = tools.bytetoint(byteList, 14, 4);
Add_List(Buoy_sensor_adcpModel.Adcp_Pre_List, Buoy_sensor_adcpModel.Adcp_Pre);
//压缩比
Buoy_sensor_adcpModel.Adcp_Ysb = (int)byteList[18];
Add_List(Buoy_sensor_adcpModel.Adcp_Ysb_List, Buoy_sensor_adcpModel.Adcp_Ysb);
for (int i = 0; i < byteList.Count; i++)
{
//27层ADCP数据
if (18 < i && i < byteList.Count - 1)
{
adcp += (int)byteList[i] + ",";
}
}
//27层ADCP
Buoy_sensor_adcpModel.Adcp_VD = adcp.Substring(0, adcp.Length - 1);
//返回解析成功指令
send_port(_kind.ToString("X2"), "01");
//_adcp_num = 1;
//Mysql.write_ob(Buoy_sensor_adcpModel, "buoy_sensor_adcpmodel");
localDataAccess.write("INSERT INTO buoy_sensor_adcpmodel(datetime,datetime_Sensor,Adcp_Pre,Adcp_Ysb,Adcp_VD) VALUES('" + time_DataBase + "','" + Buoy_sensor_adcpModel.datetime_Sensor + "','" + Buoy_sensor_adcpModel.Adcp_Pre + "','" + Buoy_sensor_adcpModel.Adcp_Ysb + "','" + Buoy_sensor_adcpModel.Adcp_VD + "');");
//tools.Count_rate(0);
break;
//浮标端浮标姿态传感器数据
case 13:
message += "浮标端浮标姿态传感器数据";
Buoy_sensor_attitudeModel.Attitude_sensor = Encoding.Default.GetString(byteList.ToArray());
//返回解析成功指令
send_port(_kind.ToString("X2"), "01");
//Mysql.write_ob(Buoy_sensor_attitudeModel, "buoy_sensor_attitudemodel");
//tools.Count_rate(6);
break;
default:
break;
}
break;
//远程控制
case 0x03:
message += "远程控制 ";
if (byteList[6] == 0x01)
{
int KIND_INT = (int)byteList[7];
int ID_INT = (int)byteList[8];
bool _bool = false;
switch (byteList[9])
{
case 0x00:
_bool = false;//关闭
break;
case 0x01:
_bool = true;//开启
break;
case 0x02:
//wirte_textbox("远程控制失败!");
return;
default:
break;
}
bool kind = false;
switch (byteList[10])
{
case 0x00:
kind = false;//电源
break;
case 0x01:
kind = true;//数据回传
break;
case 0x02:
//wirte_textbox("远程控制失败!");
return;
default:
break;
}
message += kind ? "数据" : "电源" + _bool;
if (true)
if (KIND_INT == 31)
{
message = "接驳盒ADCP ";
if (kind) Switch_Model.JBH_Adcp_Data = _bool;
if (!kind) Switch_Model.JBH_Adcp_Power = _bool;
}
else if (KIND_INT == 30)
{
message += "接驳盒其他传感器集合 ";
if (ID_INT == 1)
{
message += "CH4";
if (kind) Switch_Model.JBH_CH4_Data = _bool;
if (!kind) Switch_Model.JBH_CH4_Power = _bool;
}
else if (ID_INT == 2)
{
message += "CO2";
if (kind) Switch_Model.JBH_CO2_Data = _bool;
if (!kind) Switch_Model.JBH_CO2_Power = _bool;
}
else if (ID_INT == 3)
{
message += "METS";
if (kind) Switch_Model.JBH_METS_Data = _bool;
if (!kind) Switch_Model.JBH_METS_Power = _bool;
}
else if (ID_INT == 4)
{
message += "CTD";
if (kind) Switch_Model.JBH_CTD_Data = _bool;
if (!kind) Switch_Model.JBH_CTD_Power = _bool;
}
else if (ID_INT == 5)
{
message += "倾角";
if (kind) Switch_Model.JBH_Attitude_Data = _bool;
if (!kind) Switch_Model.JBH_Attitude_Power = _bool;
}
}
else if (KIND_INT == 21)
{
message = "潜标端ADCP-WSH300";
if (kind) Switch_Model.QB_Adcp300_Data = _bool;
if (!kind) Switch_Model.QB_Adcp300_Power = _bool;
}
else if (KIND_INT == 10)
{
message = "浮标端其他传感器数据";
if (ID_INT == 1)
{
message += "CH4";
if (kind) Switch_Model.FB_CH4_Data = _bool;
if (!kind) Switch_Model.FB_CH4_Power = _bool;
}
else if (ID_INT == 2)
{
message += "CO2";
if (kind) Switch_Model.FB_CO2_Data = _bool;
if (!kind) Switch_Model.FB_CO2_Power = _bool;
}
else if (ID_INT == 3)
{
message += "METS";
if (kind) Switch_Model.FB_METS_Data = _bool;
if (!kind) Switch_Model.FB_METS_Power = _bool;
}
else if (ID_INT == 4)
{
message += "CTD";
if (kind) Switch_Model.FB_CTD_Data = _bool;
if (!kind) Switch_Model.FB_CTD_Power = _bool;
}
else if (ID_INT == 6)
{
message += "走航甲烷";
if (kind)
Switch_Model.FB_Sailing_CH4_Data = _bool;
if (!kind)
Switch_Model.FB_Sailing_CH4_Power = _bool;
}
else if (ID_INT == 7)
{
message += "气象";
if (kind) Switch_Model.FB_Air_Data = _bool;
if (!kind) Switch_Model.FB_Air_Power = _bool;
}
}
else if (KIND_INT == 11)
{
message = "浮标端ADCP-WSH300";
if (kind) Switch_Model.FB_Adcp_Data = _bool;
if (!kind) Switch_Model.FB_Adcp_Power = _bool;
}
else if (KIND_INT == 13)
{
message = "浮标端浮标姿态传感器数据";
if (kind) Switch_Model.FB_Attitude_Data = _bool;
if (!kind) Switch_Model.FB_Attitude_Power = _bool;
}
else if (KIND_INT == 25)
{
message = "潜标其他传感器";
if (ID_INT == 1)
{
}
else if (ID_INT == 2)
{
message += "CO2";
if (kind) Switch_Model.QB_CO2_Data = _bool;
if (!kind) Switch_Model.QB_CO2_Power = _bool;
}
else if (ID_INT == 3)
{
message += "METS";
if (kind) Switch_Model.QB_METS_Data = _bool;
if (!kind) Switch_Model.QB_METS_Power = _bool;
}
else if (ID_INT == 4)
{
message += "CTD";
if (kind) Switch_Model.QB_CTD_Data = _bool;
if (!kind) Switch_Model.QB_CTD_Power = _bool;
}
else if (ID_INT == 10)
{
message += "水声通信机";
if (!kind) Switch_Model.QB_SSTX_Power = _bool;
}
}
}
else if (byteList[6] == 0x00)
{
message += "读取状态";
string ctl = byteList[7].ToString("X2") + byteList[8].ToString("X2") + byteList[9].ToString("X2") + byteList[10].ToString("X2");
string ctl_2 = null;
for (int i = 0; i < ctl.Length; i++)
{
ctl_2 += tools.HexString2BinString(ctl.Substring(i, 1));
}
ctl_2 = ctl_2.Replace(" ", "");
if (ctl_2.Length == 32)
{
Switch_Model.JBH_METS_Data = O_C(ctl_2.Substring(2, 1));
Switch_Model.JBH_METS_Power = O_C(ctl_2.Substring(3, 1));
Switch_Model.JBH_Attitude_Data = O_C(ctl_2.Substring(4, 1));
Switch_Model.JBH_Attitude_Power = O_C(ctl_2.Substring(5, 1));
Switch_Model.JBH_CTD_Data = O_C(ctl_2.Substring(6, 1));
Switch_Model.JBH_CTD_Power = O_C(ctl_2.Substring(7, 1));
Switch_Model.JBH_CO2_Data = O_C(ctl_2.Substring(8, 1));
Switch_Model.JBH_CO2_Power = O_C(ctl_2.Substring(9, 1));
Switch_Model.JBH_CH4_Data = O_C(ctl_2.Substring(10, 1));
Switch_Model.JBH_CH4_Power = O_C(ctl_2.Substring(11, 1));
Switch_Model.JBH_Adcp_Data = O_C(ctl_2.Substring(12, 1));
Switch_Model.JBH_Adcp_Power = O_C(ctl_2.Substring(13, 1));
//switch_Model.QB_Adcp150_Data = O_C(ctl_2.Substring(14, 1));
//switch_Model.QB_Adcp150_Power = O_C(ctl_2.Substring(15, 1));
Switch_Model.QB_Adcp300_Data = O_C(ctl_2.Substring(16, 1));
Switch_Model.QB_Adcp300_Power = O_C(ctl_2.Substring(17, 1));
Switch_Model.FB_Attitude_Data = O_C(ctl_2.Substring(18, 1));
Switch_Model.FB_Attitude_Power = O_C(ctl_2.Substring(19, 1));
Switch_Model.FB_Air_Data = O_C(ctl_2.Substring(20, 1));
Switch_Model.FB_Air_Power = O_C(ctl_2.Substring(21, 1));
Switch_Model.FB_Sailing_CH4_Data = O_C(ctl_2.Substring(22, 1));
Switch_Model.FB_Sailing_CH4_Power = O_C(ctl_2.Substring(23, 1));
Switch_Model.FB_METS_Data = O_C(ctl_2.Substring(24, 1));
Switch_Model.FB_METS_Power = O_C(ctl_2.Substring(25, 1));
Switch_Model.FB_CO2_Data = O_C(ctl_2.Substring(26, 1));
Switch_Model.FB_CO2_Power = O_C(ctl_2.Substring(27, 1));
Switch_Model.FB_CH4_Data = O_C(ctl_2.Substring(28, 1));
Switch_Model.FB_CH4_Power = O_C(ctl_2.Substring(29, 1));
Switch_Model.FB_Adcp_Data = O_C(ctl_2.Substring(30, 1));
Switch_Model.FB_Adcp_Power = O_C(ctl_2.Substring(31, 1));
}
ctl = byteList[11].ToString("X2") + byteList[12].ToString("X2") + byteList[13].ToString("X2") + byteList[14].ToString("X2");
ctl_2 = "";
for (int i = 0; i < ctl.Length; i++)
{
ctl_2 += tools.HexString2BinString(ctl.Substring(i, 1));
}
ctl_2 = ctl_2.Replace(" ", "");
if (ctl_2.Length == 32)
{
Switch_Model.QB_SSTX_Power = O_C(ctl_2.Substring(25, 1));
Switch_Model.QB_CO2_Data = O_C(ctl_2.Substring(26, 1));
Switch_Model.QB_CO2_Power = O_C(ctl_2.Substring(27, 1));
Switch_Model.QB_METS_Data = O_C(ctl_2.Substring(28, 1));
Switch_Model.QB_METS_Power = O_C(ctl_2.Substring(29, 1));
Switch_Model.QB_CTD_Data = O_C(ctl_2.Substring(30, 1));
Switch_Model.QB_CTD_Power = O_C(ctl_2.Substring(31, 1));
}
Enviroment_Model.Datetime = DateTime.Now;
Add_List(Enviroment_Model.Datetime_List, System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
Enviroment_Model.FB_Tem = (float)Convert.ToInt16(byteList[15].ToString("X2") + byteList[16].ToString("X2"), 16) / 1000 * 100;
Add_List(Enviroment_Model.FB_Tem_List, Enviroment_Model.FB_Tem);
Enviroment_Model.FB_Hum = (float)Convert.ToInt16(byteList[17].ToString("X2") + byteList[18].ToString("X2"), 16) / 1000 * 100 / 3;
Add_List(Enviroment_Model.FB_Hum_List, Enviroment_Model.FB_Hum);
Enviroment_Model.FB_Vol_24_in = (float)Convert.ToInt16(byteList[19].ToString("X2") + byteList[20].ToString("X2"), 16) / 1000 * (float)11.02;
Add_List(Enviroment_Model.FB_Vol_24_in_List, Enviroment_Model.FB_Vol_24_in);
Enviroment_Model.FB_Cur_24_in = (float)Convert.ToInt16(byteList[21].ToString("X2") + byteList[22].ToString("X2"), 16) / 1000 * (float)1.35;
Add_List(Enviroment_Model.FB_Cur_24_in_List, Enviroment_Model.FB_Cur_24_in);
Enviroment_Model.FB_Vol_48_out = (float)Convert.ToInt16(byteList[23].ToString("X2") + byteList[24].ToString("X2"), 16) / 1000 * 21.07f;
Add_List(Enviroment_Model.FB_Vol_48_out_List, Enviroment_Model.FB_Vol_48_out);
Enviroment_Model.FB_Vol_95_out = (float)Convert.ToInt16(byteList[25].ToString("X2") + byteList[26].ToString("X2"), 16) / 1000 * 47.78f;
Add_List(Enviroment_Model.FB_Vol_95_out_List, Enviroment_Model.FB_Vol_95_out);
Enviroment_Model.QB_Tem1 = (float)Convert.ToInt16(byteList[27].ToString("X2") + byteList[28].ToString("X2"), 16) / 1000 * 100;
Add_List(Enviroment_Model.QB_Tem1_List, Enviroment_Model.QB_Tem1);
Enviroment_Model.QB_Tem2 = (float)Convert.ToInt16(byteList[29].ToString("X2") + byteList[30].ToString("X2"), 16) / 1000 * 100;
Add_List(Enviroment_Model.QB_Tem2_List, Enviroment_Model.QB_Tem2);
Enviroment_Model.QB_Hum = (float)Convert.ToInt16(byteList[31].ToString("X2") + byteList[32].ToString("X2"), 16) / 1000 * 100 / 3;
Add_List(Enviroment_Model.QB_Hum_List, Enviroment_Model.QB_Hum);
Enviroment_Model.QB_Leak = (float)Convert.ToInt16(byteList[33].ToString("X2") + byteList[34].ToString("X2"), 16);
Add_List(Enviroment_Model.QB_Leak_List, Enviroment_Model.QB_Leak);
//Enviroment_Model.JBH_Tem1 = (float)Convert.ToInt16(byteList[35].ToString("X2") + byteList[36].ToString("X2"), 16) / 1000 * 100;
Enviroment_Model.JBH_Tem1 = ((float)Convert.ToInt16(byteList[37].ToString("X2") + byteList[38].ToString("X2"), 16) / 1000 * 100) + (float)0.02;
Add_List(Enviroment_Model.JBH_Tem1_List, Enviroment_Model.JBH_Tem1);
Enviroment_Model.JBH_Tem2 = (float)Convert.ToInt16(byteList[37].ToString("X2") + byteList[38].ToString("X2"), 16) / 1000 * 100;
Add_List(Enviroment_Model.JBH_Tem2_List, Enviroment_Model.JBH_Tem2);
Enviroment_Model.JBH_Hum = (float)Convert.ToInt16(byteList[39].ToString("X2") + byteList[40].ToString("X2"), 16) / 1000 * 100 / 3;
Add_List(Enviroment_Model.JBH_Hum_List, Enviroment_Model.JBH_Hum);
Enviroment_Model.JBH_Leak = (float)Convert.ToInt16(byteList[41].ToString("X2") + byteList[42].ToString("X2"), 16);
Add_List(Enviroment_Model.JBH_Leak_List, Enviroment_Model.JBH_Leak);
Enviroment_Model.JBH_Vol_24V_out = (float)Convert.ToInt16(byteList[43].ToString("X2") + byteList[44].ToString("X2"), 16) / 1000 * (float)11.01;
Add_List(Enviroment_Model.JBH_Vol_24V_out_List, Enviroment_Model.JBH_Vol_24V_out);
Enviroment_Model.JBH_Cur_24V_out = (float)Convert.ToInt16(byteList[45].ToString("X2") + byteList[46].ToString("X2"), 16) / 1000 * (float)0.98;
Add_List(Enviroment_Model.JBH_Cur_24V_out_List, Enviroment_Model.JBH_Cur_24V_out);
localDataAccess.write("INSERT INTO enviroment_model(datetime,FB_Tem,FB_Hum,FB_Vol_24_in,FB_Cur_24_in,FB_Vol_48_out,FB_Vol_95_out,QB_Tem1,QB_Tem2,QB_Hum,QB_Leak,JBH_Tem1,JBH_Tem2,JBH_Hum,JBH_Leak,JBH_Vol_24V_out,JBH_Cur_24V_out) VALUES('" + time_DataBase + "','" + Enviroment_Model.FB_Tem + "','" + Enviroment_Model.FB_Hum + "','" + Enviroment_Model.FB_Vol_24_in + "','" + Enviroment_Model.FB_Cur_24_in + "','" + Enviroment_Model.FB_Vol_48_out + "','" + Enviroment_Model.FB_Vol_95_out + "','" + Enviroment_Model.QB_Tem1 + "','" + Enviroment_Model.QB_Tem2 + "','" + Enviroment_Model.QB_Hum + "','" + Enviroment_Model.QB_Leak + "','" + Enviroment_Model.JBH_Tem1 + "','" + Enviroment_Model.JBH_Tem2 + "','" + Enviroment_Model.JBH_Hum + "','" + Enviroment_Model.JBH_Leak + "','" + Enviroment_Model.JBH_Vol_24V_out + "','" + Enviroment_Model.JBH_Cur_24V_out + "');");
}
break;
case 0x05:
message = "传输格式设置成功";
break;
case 0x0F:
ControlModel.Start_Hour = (int)byteList[6];
ControlModel.Start_Min = (int)byteList[7];
ControlModel.Upload_Cycle = (int)byteList[8];
ControlModel.Work_Time = (int)byteList[9];
ControlModel.Adcp_Accuracy = (int)byteList[10];
ErrorMessageModel.ErrorMessage_Par = "参数读取成功!";
localDataAccess.write("update para_set set Start_Hour = " + ControlModel.Start_Hour + ",Start_Min = " + ControlModel.Start_Min + ",Upload_Cycle = " + ControlModel.Upload_Cycle + ",Work_Time = " + ControlModel.Work_Time + ",Adcp_Accuracy = " + ControlModel.Adcp_Accuracy + ";");
break;
//校时
case 0x06:
//UTC时间
dt = startTime.AddSeconds(Convert.ToInt32(byteList[6].ToString("X2") + byteList[7].ToString("X2") + byteList[8].ToString("X2") + byteList[9].ToString("X2"), 16));
if ((time_DataBase - dt).TotalMinutes > 60)
{
//_set_time = true;
}
else
{
//_set_time = false;
}
message = "校时成功!";
break;
//登录
case 0x00:
message = "登录成功!";
//_isConnected = true;
byte[] _send = new byte[] { 0xEF, 0xFE, 0x00, 0x04, 0x01, 0x00, 0xF2, 0x16 };
rtuInstance.Send(_send);
Thread.Sleep(100);
//同步一次时间
Tb_Time(null);
//等待半个小时重新铱星拨号将数据补全
//if (!_request)
//{
// Auto_Wait();
//}
break;
case 0x64:
switch (byteList[6])
{
case 0x00:
file_request();
ErrorMessageModel.ErrorMessage_File = "文件请求成功!";
break;
case 0x01:
ErrorMessageModel.ErrorMessage_File = "文件请求失败!";
break;
case 0x02:
ErrorMessageModel.ErrorMessage_File = "当前设备在忙!";
break;
case 0x03:
ErrorMessageModel.ErrorMessage_File = "文件读取越界!";
break;
case 0x04:
ErrorMessageModel.ErrorMessage_File = "没有该文件!";
break;
default:
break;
}
break;
case 0x66:
for (int i = 0; i < byteList.Count - 16; i++)
{
get_mes += byteList[i + 14].ToString("X2");
}
string aa = tools.HexStringToString(get_mes, Encoding.Default);
tools.AddLgoToTXT(FileModel.File_Name + FileModel.File_Time.ToString("yyyyMMdd") + ".csv", FileModel.File_Path + FileModel.File_Time.ToString("yyyy-MM-dd") + @"\", tools.HexStringToString(get_mes, Encoding.UTF8));
get_mes = "";
if (byteList[11] != 0xFF)
{
Thread.Sleep(2000);
file_request();
ErrorMessageModel.ErrorMessage_File = "文件下载中,请稍后!";
message = "文件请求未完成,继续请求!";
}
else
{
count = 0;
ErrorMessageModel.ErrorMessage_File = "文件保存成功!";
message = "文件请求完成且保存成功!";
}
break;
default:
break;
}
ErrorMessageModel._MessageCon += System.DateTime.Now + " " + message + "\r\n" + "\r\n";
//tools.AddLgoToTXT(FileModel.File_Name + FileModel.File_Time.ToString("yyyyMMdd") + ".txt", FileModel.File_Path + FileModel.File_Time.ToString("yyyy-MM-dd") + @"\", System.DateTime.Now + " " + message + "\r\n" + "\r\n");
}
static string get_mes = null;
static int count = 0;
//读取的长度
static int len = 512;
//文件请求
public static void file_request()
{
//读取的起始位
int start = 0 + count * len;
count++;
string str = "FEEF000A0066" + start.ToString("X2").PadLeft(8, '0') + len.ToString("X2").PadLeft(4, '0');
string[] array = new string[12];
for (int i = 0; i < str.Length; i += 2)
{
array[i / 2] = str.Substring(i, 2);
}
int sum = 0;
foreach (string arrayElement in array)
{
sum += int.Parse(arrayElement, System.Globalization.NumberStyles.HexNumber);
}
sum = sum & 0xFF;
str = "FEEF000A0066" + start.ToString("X2").PadLeft(8, '0') + len.ToString("X2").PadLeft(4, '0') + sum.ToString("X2") + "16";
byte[] bytea = tools.ConvertHexStringToBytes(str);
rtuInstance.Send(bytea);
}
//参数读取
public void Par_Read(object o)
{
send_port_set(0, "", null, 15);
//MessageBox.Show("参数读取成功!","参数读取");
}
//参数设置
public void Par_Set(object o)
{
//if (ControlModel.Start_Hour == 0)
//{
// ErrorMessageModel.ErrorMessage_Par = "请输入启动时";
// return;
//}
if (ControlModel.Start_Min == 0)
{
ErrorMessageModel.ErrorMessage_Par = "请输入启动分";
return;
}
if (ControlModel.Upload_Cycle == 0)
{
ErrorMessageModel.ErrorMessage_Par = "请输入上传周期";
return;
}
if (ControlModel.Work_Time == 0)
{
ErrorMessageModel.ErrorMessage_Par = "请输入工作时间";
return;
}
if (ControlModel.Adcp_Accuracy == 0)
{
ErrorMessageModel.ErrorMessage_Par = "请输入Adcp精度";
return;
}
string set = ControlModel.Start_Hour.ToString("X2") + ControlModel.Start_Min.ToString("X2") + ControlModel.Upload_Cycle.ToString("X2") + ControlModel.Work_Time.ToString("X2") + ControlModel.Adcp_Accuracy.ToString("X2");
List<int> set_int = new List<int>();
set_int.Add(ControlModel.Start_Hour);
set_int.Add(ControlModel.Start_Min);
set_int.Add(ControlModel.Upload_Cycle);
set_int.Add(ControlModel.Work_Time);
set_int.Add(ControlModel.Adcp_Accuracy);
send_port_set(set.Length, set, set_int, 5);
ErrorMessageModel.ErrorMessage_Par = "系统设置成功!";
//MessageBox.Show("系统设置成功!","系统设置");
}
//同步时间
public static void Tb_Time(object o)
{
TimeSpan ts = DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0);
send_port_time(Convert.ToInt64(ts.TotalSeconds).ToString("X2"));
}
//文件请求
public void FILE_Require(object o)
{
if (string.IsNullOrEmpty(FileModel.File_Name))
{
ErrorMessageModel.ErrorMessage_File = "请选择文件名称!";
return;
}
if (FileModel.File_Time == null)
{
ErrorMessageModel.ErrorMessage_File = "请选择文件日期!";
return;
}
if (string.IsNullOrEmpty(FileModel.File_Path))
{
ErrorMessageModel.ErrorMessage_File = "请选择文件路径!";
return;
}
string str = FileModel.File_Name + FileModel.File_Time.ToString("yyyyMMdd") + ".csv";
byte[] bytetest = System.Text.Encoding.Default.GetBytes(str.ToString());
byte[] time_byte = tools.ConvertHexStringToBytes(tools.byteToHexStr(bytetest));
int a = 0xFE + 0xEF + 0x00 + 0x04 + tools.byteToHexStr(bytetest).Length / 2 + 0x00 + 0x64;
for (int i = 0; i < time_byte.Length; i++)
{
a += time_byte[i];
}
//取十六进制最低两位
a = a & 0xFF;
str = "FEEF00160064" + tools.byteToHexStr(bytetest) + a.ToString("X2") + "16";
byte[] bytea = tools.ConvertHexStringToBytes(str);
rtuInstance.Send(bytea);
}
/// <summary>
/// 参数设置
/// </summary>
/// <param name="len"></param>
/// <param name="data"></param>
/// <param name="data_int"></param>
public void send_port_set(int len, string data, List<int> data_int, int function)
{
int a = 0xFE + 0xEF + 4 + len / 2 + 0x00 + function;
if (data_int != null)
{
for (int i = 0; i < data_int.Count; i++)
{
a += data_int[i];
}
}
//取十六进制最低两位
a = a & 0xFF;
string send_mes = "FEEF00" + (4 + len / 2).ToString("X2") + "00" + function.ToString("X2") + data + a.ToString("X2") + "16";
byte[] bytea = tools.ConvertHexStringToBytes(send_mes);
rtuInstance.Send(bytea);
}
/// <summary>
/// 时间同步
/// </summary>
/// <param name="time"></param>
public static void send_port_time(string time)
{
byte[] time_byte = tools.ConvertHexStringToBytes(time);
int a = 0xFE + 0xEF + 0x00 + 0x08 + 0x00 + 0x06;
for (int i = 0; i < time_byte.Length; i++)
{
a += time_byte[i];
}
//取十六进制最低两位
a = a & 0xFF;
string send_mes = "FEEF00080006" + time + a.ToString("X2") + "16";
byte[] bytea = tools.ConvertHexStringToBytes(send_mes);
rtuInstance.Send(bytea);
}
/// <summary>
/// 串口数据发送
/// </summary>
/// <param name="kind">数据类型</param>
/// <param name="ack">bool类型 00/01</param>
public static void send_port(string kind, string ack)
{
string send_mes = "EFFE00060002" + kind + ack + "0816";
byte[] bytea = tools.ConvertHexStringToBytes(send_mes);
rtuInstance.Send(bytea);
}
/// <summary>
/// 开关按钮
/// </summary>
/// <param name="kind"></param>
/// <param name="id">传感器id</param>
/// <param name="btn">开还是关 01 00</param>
public void send_port_btn(int kind, int id, int btn, int act)
{
int a = 0xFE + 0xEF + 0x00 + 0x09 + 0x00 + 0x03 + 0x01 + kind + id + btn + act;
//取十六进制最低两位
a = a & 0xFF;
string send_mes = "FEEF0009000301" + kind.ToString("X2") + id.ToString("X2") + btn.ToString("X2") + act.ToString("X2") + a.ToString("X2") + "16";
byte[] bytea = tools.ConvertHexStringToBytes(send_mes);
rtuInstance.Send(bytea);
}
/// <summary>
/// 获取铱星信号强度
/// </summary>
private void GetIrStrength(object o)
{
byte[] bytes = BitConverter.GetBytes(Convert.ToInt32("3FB5C28F", 16));
float b = BitConverter.ToSingle(bytes, 0);
//AT+CSQ\r\n
//41 54 2B 43 53 51 0D 0A
byte[] a = tools.ConvertHexStringToBytes("41 54 2B 43 53 51 0D 0A");
rtuInstance.Send(a);
}
/// <summary>
/// 铱星拨号
/// </summary>
private void IrDial(object o)
{
//ATD00881693818244\r\n
byte[] a = tools.ConvertHexStringToBytes("41 54 44 30 30 38 38 31 36 39 33 38 31 38 32 34 34 0D 0A");
rtuInstance.Send(a);
}
/// <summary>
/// 铱星断开连接
/// </summary>
/// <param name="o"></param>
private void IrDisConnect(object o)
{
byte[] a = System.Text.Encoding.ASCII.GetBytes("+++");
rtuInstance.Send(a);
}
public static void Dispose()
{
isRunning = false;
if (rtuInstance != null)
rtuInstance.Dispose();
if (mainTask != null)
mainTask.Wait();
}
private static bool O_C(string o_c)
{
if (o_c.Equals("0"))
{
return false;
}
else if (o_c.Equals("1"))
{
return true;
}
return false;
}
private static void Add_List(ChartValues<float> ts, float new_value)
{
try
{
ts.Add(new_value);
if (ts.Count > _length)
{
ts.RemoveAt(0);
}
}
catch (Exception)
{
return;
}
}
private static void Add_List(List<string> ts, string new_value)
{
try
{
ts.Add(new_value);
if (ts.Count > _length)
{
ts.RemoveAt(0);
}
}
catch (Exception ex)
{
return;
}
}
//设置一个bool变量 来确认是否处于数据恢复状态
static bool _request = false;
static int Flag = 0;
static byte[] JL = new byte[6];
static string _Send_Message = "";
private async static void Auto_Wait()
{
await Task.Run(async () =>
{
DateTime _datetime = System.DateTime.Now;
//等待半个小时 等待数据采集完毕
while ((System.DateTime.Now - _datetime).TotalSeconds < 1800)
{ Thread.Sleep(1); }
//如果当前数组内存在0说明数据丢失进行数据补偿
if (JL.Contains<byte>(0))
{
//设置当前为数据恢复模式
_request = true;
//进行拨号
if (await IrDial())
{
//拨号成功
//浮标ADCP
if (JL[0] == 0)
{
send_port_hand(11); Thread.Sleep(2000);
}
//浮标其他传感器
if (JL[1] == 0)
{
send_port_hand(13); Thread.Sleep(2000);
}
//潜标ADCP
if (JL[2] == 0)
{
send_port_hand(21); Thread.Sleep(2000);
}
//潜标其他传感器
if (JL[3] == 0)
{
send_port_hand(25); Thread.Sleep(2000);
}
//接驳盒ADCP
if (JL[4] == 0)
{
send_port_hand(31); Thread.Sleep(2000);
}
//接驳盒其他传感器
if (JL[5] == 0)
{
send_port_hand(30); Thread.Sleep(2000);
}
for (int i = 0; i < JL.Length; i++)
{
JL[i] = 0;
}
}
else
{
Console.WriteLine("连接失败");
}
//进行初始化操作
//rtuInstance.Send(System.Text.Encoding.Default.GetBytes("+++"));
_request = false;
Flag = 0;
_Send_Message = "";
IsConnected = false;
LastChance = false;
}
});
}
/// <summary>
/// 串口数据发送 手动开关量
/// </summary>
/// <param name="kind"></param>
/// <param name="id"></param>
/// <param name="btn"></param>
public static void send_port_hand(int kind)
{
int a = 0xFE + 0xEF + 0x00 + 0x06 + 0x00 + 0x02 + kind + 0xFF;
//取十六进制最低两位
a = a & 0xFF;
string send_mes = "FEEF00060002" + kind.ToString("X2") + "FF" + a.ToString("X2") + "16";
byte[] bytea = tools.ConvertHexStringToBytes(send_mes);
rtuInstance.Send(bytea);
}
static bool IsConnected = false;
static bool LastChance = false;
private static async Task<bool> IrDial()
{
Task<bool> result = Task.Run(() =>
{
_Send_Message = "AT+CSQ\r\n";
Wait_rec(_Send_Message, 0);
while (!IsConnected && !LastChance)
{
Thread.Sleep(1);
}
LastChance = false;
return IsConnected;
});
return await result;
}
//设置超时重传 每5秒没有接收到经过CRC校验的数据就 重新发送 如果连续三次都没有能通过CRC校验的数据就停止步骤
static bool _wait_rec = false;
private async static void Wait_rec(string send, int flag)
{
await Task.Run(() =>
{
Flag = flag;
_wait_rec = false;
try
{
rtuInstance.Send(System.Text.Encoding.Default.GetBytes(send));
}
catch (Exception)
{
}
for (int i = 0; i < 3; i++)
{
DateTime _time = System.DateTime.Now;
while ((System.DateTime.Now - _time).TotalSeconds < 60 && !_wait_rec)
{
Thread.Sleep(1);
}
//如果有正确数据返回 就return掉
if (_wait_rec)
return;
try
{
//没有正确数据返回 就重新发送一下指令
rtuInstance.Send(System.Text.Encoding.Default.GetBytes(send));
}
catch (Exception ex)
{
}
Console.WriteLine("超时1分钟重发");
}
IsConnected = false;
LastChance = true;
Console.WriteLine("三次都没有超时重发成功");
});
}
}
}