StableVersion4.3/HL_FristAidPlatform_RealTim.../Form_RealTimeVideo.cs

880 lines
34 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using AxPPVSGUARDLib;
using DevExpress.XtraEditors;
using HL_FristAidPlatform_DTO;
using HL_FristAidPlatform_Public;
using Newtonsoft.Json;
using System;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Net;
using System.Net.Sockets;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Windows.Forms;
namespace HL_FristAidPlatform_RealTimeVideo
{
public partial class Form_RealTimeVideo : XtraForm
{
#region 变量
/// <summary>
/// 当前患者编号(GUID)
/// </summary>
private string Cur_PatientGuid = string.Empty;
/// <summary>
/// 当前患者信息
/// </summary>
private DataTable Cur_PatientDT = null;
/// <summary>
/// 通道1
/// </summary>
private AxPpvsguard axPpvsguard1 = new AxPpvsguard();
/// <summary>
/// 通道2
/// </summary>
private AxPpvsguard axPpvsguard2 = new AxPpvsguard();
/// <summary>
/// 通道3
/// </summary>
private AxPpvsguard axPpvsguard3 = new AxPpvsguard();
/// <summary>
/// 通道4
/// </summary>
private AxPpvsguard axPpvsguard4 = new AxPpvsguard();
#region 急救地图需要
private WebMap webMap = WebMap.Instance;
private int LpGPS;
/// <summary>
/// 急救车牌号
/// </summary>
private string Cur_PlateNumber = "";
/// <summary>
/// 设备ID
/// </summary>
private string Cur_DeviceId = "";
/// <summary>
/// 速度
/// </summary>
private string _speed;
public string Speed
{
get
{
return _speed;
}
set
{
_speed = value;
}
}
/// <summary>
/// 经度
/// </summary>
private string _longitude;
public string Longitude
{
get
{
return _longitude;
}
set
{
_longitude = value;
}
}
/// <summary>
/// 纬度
/// </summary>
private string _latitude;
public string Latitude
{
get
{
return _latitude;
}
set
{
_latitude = value;
}
}
/// <summary>
/// 时间
/// </summary>
private string _time;
public string Time
{
get
{
return _time;
}
set
{
_time = value;
}
}
#endregion
#endregion
/// <summary>
/// 实时视频监控
/// </summary>
/// <param name="_patientGuid">GUID</param>
public Form_RealTimeVideo(string _patientGuid)
{
InitializeComponent();
Cur_PatientGuid = _patientGuid;
}
/// <summary>
/// 窗体加载
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Form_RealTimeVideo_Load(object sender, EventArgs e)
{
BindData();
}
/// <summary>
/// 绑定数据
/// </summary>
private void BindData()
{
try
{
#region 绑定数据
Cur_PatientDT = DBHelpClass.GetDataRow("api/service/T_Service_Patient/" + Cur_PatientGuid + "");
if (Cur_PatientDT != null && Cur_PatientDT.Rows.Count > 0)
{
string ambulanceGuid = Cur_PatientDT.Rows[0]["AmbulanceGuid"].ToString();
string url = string.Format("api/base/T_Base_Ambulance/GetServerInfoByGuid?guid={0}&serverType=1,2", ambulanceGuid);
DataTable ServerDT = DBHelpClass.GetJsonText(url);
if (ServerDT != null && ServerDT.Rows.Count > 0)
{
//车牌号
string PlateNumber = ServerDT.Rows[0]["PlateNumber"].ToString().Trim();
label_PlateNumber.Text = PlateNumber == "" ? "" : "当前车辆牌照:" + PlateNumber;
//云平台地址即IP地址
string ServerIP = ServerDT.Rows[0]["ServerIP"].ToString();
//监控平台用户名
string name = ServerDT.Rows[0]["UserName"].ToString();
//监控平台用户密码
string passWord = ServerDT.Rows[0]["Password"].ToString();
//设备ID
string deviceId = ServerDT.Rows[0]["EquipmentCode"].ToString();
//车载设备 通信端口
int serverPortNumber = int.Parse(ServerDT.Rows[0]["CommunicationPort"].ToString());
//单兵设备 通信端口
int streamPortNumber = int.Parse(ServerDT.Rows[1]["CommunicationPort"].ToString());
#region 通道1
int channel = 1;
axPpvsguard1.BeginInit();
ComponentResourceManager componentResourceManager = new ComponentResourceManager(typeof(Form_RealTimeVideo));
axPpvsguard1.Dock = DockStyle.Fill;
axPpvsguard1.Enabled = true;
axPpvsguard1.Location = new Point(0, 0);
axPpvsguard1.Name = "axPpvsguard1";
axPpvsguard1.OcxState = (AxHost.State)componentResourceManager.GetObject("axPpvsguard1.OcxState");
axPpvsguard1.Size = new Size(1046, 650);
axPpvsguard1.TabIndex = 1;
AutoScaleDimensions = new SizeF(6f, 12f);
AutoScaleMode = AutoScaleMode.Inherit;
ClientSize = new Size(1046, 650);
tableLayoutPanel_1.Controls.Add(axPpvsguard1);
//全屏
axPpvsguard1.MaxWindow += AxPpvsguard_MaxWindow;
//Name = "通道01";
//Text = "视频";
axPpvsguard1.EndInit();
axPpvsguard1.ConnectDeviceByACS(deviceId, ServerIP, serverPortNumber, name, passWord);
axPpvsguard1.SetActiveXShowMode(0, 1);
axPpvsguard1.SetDeviceNetLine(1);
axPpvsguard1.StreamPlayStartByTCP(ServerIP, streamPortNumber, deviceId, channel, 1, 1);
#endregion
#region 通道2
int channel2 = 2;
axPpvsguard2.BeginInit();
ComponentResourceManager componentResourceManager1 = new ComponentResourceManager(typeof(Form_RealTimeVideo));
axPpvsguard2.Dock = DockStyle.Fill;
axPpvsguard2.Enabled = true;
axPpvsguard2.Location = new Point(0, 0);
axPpvsguard2.Name = "axPpvsguard2";
axPpvsguard2.OcxState = (AxHost.State)componentResourceManager1.GetObject("axPpvsguard2.OcxState");
axPpvsguard2.Size = new Size(1046, 650);
axPpvsguard2.TabIndex = 2;
AutoScaleDimensions = new SizeF(6f, 12f);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1046, 650);
tableLayoutPanel_1.Controls.Add(axPpvsguard2);
//全屏
axPpvsguard2.MaxWindow += AxPpvsguard_MaxWindow;
//Name = "通道02";
//Text = "视频";
axPpvsguard2.EndInit();
axPpvsguard2.ConnectDeviceByACS(deviceId, ServerIP, serverPortNumber, name, passWord);
axPpvsguard2.SetActiveXShowMode(0, 1);
axPpvsguard2.SetDeviceNetLine(1);
axPpvsguard2.StreamPlayStartByTCP(ServerIP, streamPortNumber, deviceId, channel2, 1, 1);
#endregion
#region 通道3
Bind_RTLS();
//int channel3 = 3;
//axPpvsguard3.BeginInit();
//ComponentResourceManager componentResourceManager3 = new ComponentResourceManager(typeof(Form_RealTimeVideo));
//axPpvsguard3.Dock = DockStyle.Fill;
//axPpvsguard3.Enabled = true;
//axPpvsguard3.Location = new Point(0, 0);
//axPpvsguard3.Name = "axPpvsguard3";
//axPpvsguard3.OcxState = (AxHost.State)componentResourceManager3.GetObject("axPpvsguard3.OcxState");
//axPpvsguard3.Size = new Size(1046, 650);
//axPpvsguard3.TabIndex = 3;
//AutoScaleDimensions = new SizeF(6f, 12f);
//AutoScaleMode = AutoScaleMode.Font;
//ClientSize = new Size(1046, 650);
//tableLayoutPanel_1.Controls.Add(axPpvsguard3);
////全屏
//axPpvsguard3.MaxWindow += AxPpvsguard_MaxWindow;
////Name = "通道03";
////Text = "视频";
//axPpvsguard3.EndInit();
//axPpvsguard3.ConnectDeviceByACS(deviceId, ServerIP, serverPortNumber, name, passWord);
//axPpvsguard3.SetActiveXShowMode(0, 1);
//axPpvsguard3.SetDeviceNetLine(1);
//axPpvsguard3.StreamPlayStartByTCP(ServerIP, streamPortNumber, deviceId, channel3, 1, 1);
#endregion
#region 通道4
BindECG(axPpvsguard1.Width, axPpvsguard1.Height);
//int channel4 = 4;
//axPpvsguard4.BeginInit();
//ComponentResourceManager componentResourceManager4 = new ComponentResourceManager(typeof(Form_RealTimeVideo));
//axPpvsguard4.Dock = DockStyle.Fill;
//axPpvsguard4.Enabled = true;
//axPpvsguard4.Location = new Point(0, 0);
//axPpvsguard4.Name = "channel4";
//axPpvsguard4.OcxState = (AxHost.State)componentResourceManager4.GetObject("channel4.OcxState");
//axPpvsguard4.Size = new Size(1046, 650);
//axPpvsguard4.TabIndex = 4;
//AutoScaleDimensions = new SizeF(6f, 12f);
//AutoScaleMode = AutoScaleMode.Font;
//ClientSize = new Size(1046, 650);
//tableLayoutPanel_1.Controls.Add(axPpvsguard4);
////全屏
//axPpvsguard4.MaxWindow += AxPpvsguard_MaxWindow;
////Name = "MyIVMS";
////Text = "MyIVMS";
//axPpvsguard4.EndInit();
//axPpvsguard4.ConnectDeviceByACS(deviceId, ServerIP, serverPortNumber, name, passWord);
//axPpvsguard4.SetActiveXShowMode(0, 1);
//axPpvsguard4.SetDeviceNetLine(1);
//axPpvsguard4.StreamPlayStartByTCP(ServerIP, streamPortNumber, deviceId, channel4, 1, 1);
#endregion
}
else
{
XtraMessageBox.Show("当前病人没有绑定急救车!无法查看实时视频!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
this.Close();
}
}
#endregion
}
catch (Exception ex)
{
PublicClass.WriteErrorLog(this.Text, "绑定数据:\r\n" + ex);
}
}
/// <summary>
/// 全屏
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void AxPpvsguard_MaxWindow(object sender, EventArgs e)
{
try
{
//已经全屏
if (panelControl_Show.Visible)
{
//取消全屏
panelControl_Show.Visible = false;
panelControl_Show.Controls.Clear();
//加载四宫格
panel_Control.Controls.Add(tableLayoutPanel_1);
tableLayoutPanel_1.Visible = true;
tableLayoutPanel_1.Controls.Add(axPpvsguard1);
tableLayoutPanel_1.Controls.Add(axPpvsguard2);
//tableLayoutPanel_1.Controls.Add(axPpvsguard3);
//tableLayoutPanel_1.Controls.Add(axPpvsguard4);
Bind_RTLS();
BindECG(axPpvsguard1.Width, axPpvsguard1.Height);
}
else
{
tableLayoutPanel_1.Visible = false;
tableLayoutPanel_1.Controls.Clear();
//开启全屏
panel_Control.Controls.Add(panelControl_Show);
panelControl_Show.Visible = true;
AxPpvsguard axPpvsguard = (AxPpvsguard)sender;
panelControl_Show.Controls.Add(axPpvsguard);
}
}
catch (Exception ex)
{
PublicClass.WriteErrorLog(this.Text, "全屏:\r\n" + ex);
}
}
/// <summary>
/// 启用对讲
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btn_EnableIntercom_Click(object sender, EventArgs e)
{
try
{
if (axPpvsguard1.OpenSound())
{
axPpvsguard1.VoiceTalkStart(1, 0);//启用对讲
btn_EnableIntercom.Enabled = false;
btn_TurnOffIntercom.Enabled = true;
return;
}
else if (axPpvsguard2.OpenSound())
{
axPpvsguard2.VoiceTalkStart(1, 0);//启用对讲
btn_EnableIntercom.Enabled = false;
btn_TurnOffIntercom.Enabled = true;
return;
}
//else if (axPpvsguard3.OpenSound())
//{
// axPpvsguard3.VoiceTalkStart(1, 0);//启用对讲
// btn_EnableIntercom.Enabled = false;
// btn_TurnOffIntercom.Enabled = true;
// return;
//}
//else if (axPpvsguard4.OpenSound())
//{
// axPpvsguard4.VoiceTalkStart(1, 0);//启用对讲
// btn_EnableIntercom.Enabled = false;
// btn_TurnOffIntercom.Enabled = true;
// return;
//}
else
{
XtraMessageBox.Show("启用对讲失败!请确认设备是否正常开启!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
//axPpvsguard1.OpenSound();
//axPpvsguard1.VoiceTalkStart(1, 0);//启用对讲
//axPpvsguard2.OpenSound();
//axPpvsguard2.VoiceTalkStart(1, 0);//启用对讲
//axPpvsguard3.OpenSound();
//axPpvsguard3.VoiceTalkStart(1, 0);//启用对讲
//axPpvsguard4.OpenSound();
//axPpvsguard4.VoiceTalkStart(1, 0);//启用对讲
}
catch (Exception ex)
{
PublicClass.WriteErrorLog(this.Text, "启用对讲:\r\n" + ex);
}
}
/// <summary>
/// 关闭对讲
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btn_TurnOffIntercom_Click(object sender, EventArgs e)
{
try
{
if (axPpvsguard1.CloseSound())
{
axPpvsguard1.VoiceTalkStop();
btn_EnableIntercom.Enabled = true;
btn_TurnOffIntercom.Enabled = false;
return;
}
else if (axPpvsguard2.CloseSound())
{
axPpvsguard2.VoiceTalkStop();
btn_EnableIntercom.Enabled = true;
btn_TurnOffIntercom.Enabled = false;
return;
}
//else if (axPpvsguard3.CloseSound())
//{
// axPpvsguard3.VoiceTalkStop();
// btn_EnableIntercom.Enabled = true;
// btn_TurnOffIntercom.Enabled = false;
// return;
//}
//else if (axPpvsguard4.CloseSound())
//{
// axPpvsguard4.VoiceTalkStop();
// btn_EnableIntercom.Enabled = true;
// btn_TurnOffIntercom.Enabled = false;
// return;
//}
//axPpvsguard2.CloseSound();
//axPpvsguard2.VoiceTalkStop();
//axPpvsguard3.CloseSound();
//axPpvsguard3.VoiceTalkStop();
//axPpvsguard4.CloseSound();
//axPpvsguard4.VoiceTalkStop();
}
catch (Exception ex)
{
PublicClass.WriteErrorLog(this.Text, "关闭对讲:\r\n" + ex);
}
}
/// <summary>
/// 全屏
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btn_FullScreen_Click(object sender, EventArgs e)
{
try
{
Form_RealTimeVideo_FullScreen frm = new Form_RealTimeVideo_FullScreen(axPpvsguard1);
if (frm.ShowDialog() == DialogResult.OK)
{
//axPpvsguard1 = (AxPpvsguard)frm.Control;
////加载四宫格
//panel_Control.Controls.Add(tableLayoutPanel_1);
//tableLayoutPanel_1.Visible = true;
tableLayoutPanel_1.Controls.Add(axPpvsguard1);
tableLayoutPanel_1.Controls.Add(axPpvsguard2);
//tableLayoutPanel_1.Controls.Add(axPpvsguard3);
//tableLayoutPanel_1.Controls.Add(axPpvsguard4);
Bind_RTLS();
BindECG(axPpvsguard1.Width, axPpvsguard1.Height);
}
}
catch (Exception ex)
{
PublicClass.WriteErrorLog(this.Text, "全屏:\r\n" + ex);
}
}
/// <summary>
/// 开启监听
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btn_Voice_Click(object sender, EventArgs e)
{
try
{
if (axPpvsguard1.OpenSound())
{
btn_Voice.Visible = false;
btn_NoVoic.Visible = true;
return;
}
else if (axPpvsguard2.OpenSound())
{
btn_Voice.Visible = false;
btn_NoVoic.Visible = true;
return;
}
//else if (axPpvsguard3.OpenSound())
//{
// btn_Voice.Visible = false;
// btn_NoVoic.Visible = true;
// return;
//}
//else if (axPpvsguard4.OpenSound())
//{
// btn_Voice.Visible = false;
// btn_NoVoic.Visible = true;
// return;
//}
else
{
XtraMessageBox.Show("开启监听失败!请确认设备是否正常开启!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
catch (Exception ex)
{
PublicClass.WriteErrorLog(this.Text, "开启监听:\r\n" + ex);
}
}
/// <summary>
/// 关闭监听
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btn_NoVoic_Click(object sender, EventArgs e)
{
try
{
if (axPpvsguard1.CloseSound())
{
btn_Voice.Visible = true;
btn_NoVoic.Visible = false;
return;
}
else if (axPpvsguard2.CloseSound())
{
btn_Voice.Visible = true;
btn_NoVoic.Visible = false;
return;
}
//else if (axPpvsguard3.CloseSound())
//{
// btn_Voice.Visible = true;
// btn_NoVoic.Visible = false;
// return;
//}
//else if (axPpvsguard4.CloseSound())
//{
// btn_Voice.Visible = true;
// btn_NoVoic.Visible = false;
// return;
//}
}
catch (Exception ex)
{
PublicClass.WriteErrorLog(this.Text, "关闭监听:\r\n" + ex);
}
}
/// <summary>
/// 绑定生命体征
/// </summary>
/// <param name="width">宽</param>
/// <param name="height">高</param>
private void BindECG(int width, int height)
{
try
{
PatientInfo patientInfo = new PatientInfo();
patientInfo.patientName = Cur_PatientDT.Rows[0]["Name"].ToString();
patientInfo.patientAge = Cur_PatientDT.Rows[0]["Age"].ToString();
string Gender = PublicClass.ToString(Cur_PatientDT.Rows[0]["Gender"], "");
if (Gender == "1")
{
Gender = "男";
}
else if (Gender == "2")
{
Gender = "女";
}
else
{
Gender = "未知";
}
patientInfo.patientSex = Gender;
ECGShowParameter parameter = new ECGShowParameter();
parameter.width = width.ToString();
parameter.height = height.ToString();
parameter.patientFlag = "1";
parameter.patientInfo = patientInfo;
parameter.wardNo = Cur_PatientDT.Rows[0]["WardshipId"].ToString();
parameter.orgCode = Information.Hospital.Ecg_OrgCode;
string paras = JsonConvert.SerializeObject(parameter);
string dllPath = string.Format(Application.StartupPath + "\\ECG\\Hwyl.ECG_New.dll", System.Environment.CurrentDirectory);//dll组件路径
Assembly pAss = Assembly.LoadFrom(dllPath);//加载组件
Type pType = pAss.GetType("Hwyl.ECG_New.ECGViewControl");//获得类ECG_New命名空间ECGViewControl类名
MethodInfo pMtInfo = pType.GetMethod("ECGViewControl");//获得方法ECGViewControl方法名
Control ECG = (Control)Activator.CreateInstance(pType, paras);
ECG.Dock = DockStyle.Fill;
//创建类实例
this.Invoke(new ThreadStart(() => tableLayoutPanel_1.Controls.Add(ECG)));
}
catch (Exception ex)
{
PublicClass.WriteErrorLog(this.Text, "绑定生命体征:\r\n" + ex);
}
}
/// <summary>
/// 实时定位
/// </summary>
private void Bind_RTLS()
{
try
{
BindDefaultGPS();
#region 实时播放
string Url = string.Format("api/service/T_Service_Patient/{0}", Cur_PatientGuid);
DataTable PatientDT = DBHelpClass.GetDataRow(Url);
if (PatientDT != null && PatientDT.Rows.Count > 0)
{
string ambulanceGuid = "";
ambulanceGuid = PatientDT.Rows[0]["AmbulanceGuid"].ToString();
Url = string.Format("api/base/T_Base_Ambulance/GetServerInfoByGuid?guid={0}&serverType=1,3", ambulanceGuid);
DataTable ServerDT = DBHelpClass.GetJsonText(Url);
if (ServerDT != null && ServerDT.Rows.Count > 0)
{
Cur_DeviceId = ServerDT.Rows[0]["EquipmentCode"].ToString();
Cur_PlateNumber = ServerDT.Rows[0]["PlateNumber"].ToString();
string ServerIP = ServerDT.Rows[0]["ServerIP"].ToString();
string UserName = ServerDT.Rows[0]["UserName"].ToString();
string Password = ServerDT.Rows[0]["Password"].ToString();
int ServerPortNumber = int.Parse(ServerDT.Rows[0]["CommunicationPort"].ToString());
int StreamPortNumber = int.Parse(ServerDT.Rows[1]["CommunicationPort"].ToString());
axPpvsguard1.ConnectDeviceByACS(Cur_DeviceId, ServerIP, ServerPortNumber, UserName, Password);
int subscribeAllGPSNum = axPpvsguard1.SubscribeAllGPS(ServerIP, StreamPortNumber, UserName, Password, 0);
DictionaryXY.subScribeAllGPS = subscribeAllGPSNum;
if (subscribeAllGPSNum >= 0)
{
LpGPS = subscribeAllGPSNum;
axPpvsguard1.GPSComeEx += axPpvsguard_GPSComeEx;
}
}
}
#endregion
}
catch (Exception ex)
{
PublicClass.WriteErrorLog(Text, "绘制:\r\n" + ex);
}
}
/// <summary>
/// 实时定位
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void axPpvsguard_GPSComeEx(object sender, _DPpvsguardEvents_GPSComeExEvent e)
{
if (e.lpDeviceID == Cur_DeviceId)
{
Longitude = e.lpX;//经度
Latitude = e.lpY;//纬度
Speed = e.lpSpeed;
Time = e.lpSampleTime;
webMap.BD_MapDirectionShow(Cur_PlateNumber, e.lpDirection, Convert.ToDouble(Longitude), Convert.ToDouble(Latitude));
}
}
/// <summary>
/// 绑定默认的GPS位置
/// </summary>
private void BindDefaultGPS()
{
WebBrowser webBrowser = new WebBrowser();
webBrowser.Dock = DockStyle.Fill;
webMap.WebBrowser1 = webBrowser;
tableLayoutPanel_1.Controls.Add(webBrowser);
M_CarGPS m_CarGPS = new M_CarGPS();
#region 赋予默认值信息
string HospitalGUID = PublicClass.ToString(Cur_PatientDT.Rows[0]["HospitalGuid"], "");
//根据医院ID获取到经纬度
string Url = string.Format("api/base/T_Base_Hospital/GetByGuid?guid={0}", HospitalGUID);
DataTable HospitalDT = DBHelpClass.Get(Url);
if (HospitalDT != null && HospitalDT.Rows.Count > 0)
{
//根据默认急救车编号获取到急救车牌号和设备ID
string DefaultAmbulanceGuid = PublicClass.ToString(HospitalDT.Rows[0]["DefaultAmbulanceGuid"], "");
if (!string.IsNullOrEmpty(DefaultAmbulanceGuid))
{
DataTable AmbulanceDT = DBHelpClass.GetJsonText(string.Format("/api/base/T_Base_Ambulance/GetGPSInfoByGuid?guid={0}", DefaultAmbulanceGuid));
if (AmbulanceDT != null && AmbulanceDT.Rows.Count > 0)
{
m_CarGPS.ambulanceNumber = AmbulanceDT.Rows[0]["PlateNumber"].ToString();
m_CarGPS.deviceId = AmbulanceDT.Rows[0]["EquipmentCode"].ToString();
m_CarGPS.lpX = HospitalDT.Rows[0]["Longitude"].ToString();//经度
m_CarGPS.lpY = HospitalDT.Rows[0]["Latitude"].ToString();//纬度
}
}
}
#endregion
webMap.LoadDefaultUrl(m_CarGPS);
axPpvsguard1 = new AxPpvsguard();
axPpvsguard1.BeginInit();
ComponentResourceManager componentResourceManager = new ComponentResourceManager(typeof(Form_FirstAidTrack));
axPpvsguard1.Dock = DockStyle.Fill;
axPpvsguard1.Enabled = true;
axPpvsguard1.Location = new Point(0, 0);
axPpvsguard1.Name = "axPpvsguard1";
axPpvsguard1.OcxState = (AxHost.State)componentResourceManager.GetObject("axPpvsguard1.OcxState");
//axPpvsguard1.Size = new Size(1046, 650);
//axPpvsguard1.TabIndex = 0;
//AutoScaleDimensions = new SizeF(6f, 12f);
//AutoScaleMode = AutoScaleMode.Font;
//ClientSize = new Size(1046, 650);
Controls.Add(axPpvsguard1);
axPpvsguard1.EndInit();
}
#region 调用珠海德瑞斯车载视频代码
public void SendMeassage()
{
IPEndPoint point = new IPEndPoint(IPAddress.Parse("192.168.6.70"), 7880);
RemisCommonandMsg msg = new RemisCommonandMsg();
msg.CallTime = PublicClass.DateTimeNow();
msg.CommID = 1;
msg.CarNO = 30;
msg.userId = 61;
msg.Title = "视频";
byte[] data = StructToBytes(msg);
UdpClient udpClient = new UdpClient();
Byte[] sendBytes = Encoding.ASCII.GetBytes(msg.ToString());
try
{
udpClient.Send(sendBytes, sendBytes.Length, point);
}
catch (SocketException ex)
{
MessageBox.Show(ex.ErrorCode.ToString());
}
}
/// <summary>
/// 将struct类型转换为byte[]
/// </summary>
public static byte[] StructToBytes(object structObj)
{
int size = Marshal.SizeOf(structObj);
IntPtr buffer = Marshal.AllocHGlobal(size);
try
{
Marshal.StructureToPtr(structObj, buffer, false);
byte[] bytes = new byte[size];
Marshal.Copy(buffer, bytes, 0, size);
return bytes;
}
finally
{
Marshal.FreeHGlobal(buffer);
}
}
[StructLayoutAttribute(LayoutKind.Sequential)]
public struct RemisCommonandMsg
{
/// <summary>
/// 调用时间
/// </summary>
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 20)]
public string CallTime;//调用时间
/// <summary>
/// 通讯指令号
/// </summary>
public int CommID;//指令号 *
/// <summary>
/// 车辆编号 *
/// </summary>
public int CarNO;
/// <summary>
/// 医院编号
/// </summary>
public int HospitalID;
/// <summary>
/// 医院值班室监控设备ID号
/// </summary>
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 30)]
public string HospitalZBS;
/// <summary>
/// 医院停车位监控设备ID号
/// </summary>
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 30)]
public string HospitalTCW;
/// <summary>
/// 视频监控窗口标题
/// </summary>
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 20)]
public string Title;
/// <summary>
/// 视频视频回放开始时间
/// </summary>
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 20)]
public string StartTime;
/// <summary>
/// 视频视频回放结束时间
/// </summary>
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 20)]
public string EndTime;
/// <summary>
/// 备用
/// </summary>
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 50)]
public string Memo;
/// <summary>
/// 发送方的handle
/// </summary>
public int WindowHandle;
/// <summary>
/// 调用标识
/// </summary>
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 50)]
public string CommandID;
/// <summary>
/// 发送指令用户Id号 *
/// </summary>
public int userId;
}
/// <summary>
/// 指令编号
/// </summary>
public enum CommonType : int
{
/// <summary>
/// 打开救护车视频
/// </summary>
openCarVideo = 1
}
#endregion
}
}