506 lines
19 KiB
C#
506 lines
19 KiB
C#
using AxPPVSGUARDLib;
|
|
using DevExpress.XtraEditors;
|
|
using HL_FristAidPlatform_Public;
|
|
using HLJW.PC.MyGPSMap;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Windows.Forms;
|
|
|
|
namespace HL_FristAidPlatform_RealTimeVideo
|
|
{
|
|
public partial class Form_FirstAidTrack : XtraForm
|
|
{
|
|
#region 变量
|
|
private WebMap wm = null;
|
|
|
|
AxPpvsguard axPpvsguard1;
|
|
|
|
private int lpGPS;
|
|
|
|
private string _longitude;
|
|
|
|
private string _latitude;
|
|
|
|
private string _speed;
|
|
|
|
private string _time;
|
|
|
|
private int subscribeAllGPSNum;
|
|
|
|
private string ServerIP = "";
|
|
|
|
/// <summary>
|
|
/// 设备ID
|
|
/// </summary>
|
|
private string deviceId = "";
|
|
|
|
private string plateNumber = "";
|
|
|
|
/// <summary>
|
|
/// 当前患者编号(GUID)
|
|
/// </summary>
|
|
private string Cur_PatientGuid = "";
|
|
|
|
/// <summary>
|
|
/// 当前患者所属院区编号(GUID)
|
|
/// </summary>
|
|
private string Cur_HospitalGuid = "";
|
|
|
|
/// <summary>
|
|
/// 绘制控件
|
|
/// </summary>
|
|
private MyWebMapControl webMapCotrol2 = new MyWebMapControl();
|
|
|
|
/// <summary>
|
|
/// 速度
|
|
/// </summary>
|
|
public string Speed
|
|
{
|
|
get
|
|
{
|
|
return _speed;
|
|
}
|
|
set
|
|
{
|
|
_speed = value;
|
|
label_Speed.Text = "速度:" + _speed;
|
|
//lbl_Speed.Invalidate();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 经度
|
|
/// </summary>
|
|
public string Longitude
|
|
{
|
|
get
|
|
{
|
|
return _longitude;
|
|
}
|
|
set
|
|
{
|
|
_longitude = value;
|
|
label_Longitude.Text = "经度:" + _longitude;
|
|
label_Longitude.Invalidate();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 纬度
|
|
/// </summary>
|
|
public string Latitude
|
|
{
|
|
get
|
|
{
|
|
return _latitude;
|
|
}
|
|
set
|
|
{
|
|
_latitude = value;
|
|
label_Latitude.Text = "纬度:" + _latitude;
|
|
label_Latitude.Invalidate();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 时间
|
|
/// </summary>
|
|
public string Time
|
|
{
|
|
get
|
|
{
|
|
return _time;
|
|
}
|
|
set
|
|
{
|
|
_time = value;
|
|
label_Time.Text = "时间:" + _time;
|
|
//lbl_Time.Invalidate();
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// 急救轨迹
|
|
/// </summary>
|
|
/// <param name="_hospitalGuid">患者所属院区编号(GUID)</param>
|
|
/// <param name="_patientID">患者编号(GUID)</param>
|
|
public Form_FirstAidTrack(string _hospitalGuid, string _patientID)
|
|
{
|
|
Cur_HospitalGuid = _hospitalGuid;
|
|
Cur_PatientGuid = _patientID;
|
|
InitializeComponent();
|
|
wm = WebMap.Instance;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 窗体加载
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void Form_FirstAidTrack_Load(object sender, EventArgs e)
|
|
{
|
|
dateEdit_Start.TimeValue = DateTime.Now.AddDays(-7).ToShortDateString() + " 00:00:00";
|
|
dateEdit_End.TimeValue = DateTime.Now.ToShortDateString() + " 23:59:59";
|
|
Create();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 绘制
|
|
/// </summary>
|
|
public void Create()
|
|
{
|
|
try
|
|
{
|
|
wm.WebBrowser1 = webBrowser;
|
|
M_CarGPS m_CarGPS = new M_CarGPS();
|
|
|
|
#region 赋予默认值信息
|
|
//根据医院ID获取到经纬度
|
|
string Url = string.Format("api/base/T_Base_Hospital/GetByGuid?guid={0}", Cur_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
|
|
|
|
wm.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);
|
|
//Name = "MyIVMS";
|
|
//Text = "MyIVMS";
|
|
axPpvsguard1.EndInit();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
PublicClass.WriteErrorLog(Text, "绘制:\r\n" + ex);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 实时播放
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void Button_RTLS_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
#region 实时播放
|
|
string Url = string.Format("api/service/T_Service_Patient/{0}", Cur_PatientGuid);
|
|
DataTable PatientDT = DBHelpClass.GetDataRow(Url);
|
|
string name = "";
|
|
string passWord = "";
|
|
int serverPortNumber = 0;
|
|
int streamPortNumber = 0;
|
|
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)
|
|
{
|
|
ServerIP = ServerDT.Rows[0]["ServerIP"].ToString();
|
|
name = ServerDT.Rows[0]["UserName"].ToString();
|
|
passWord = ServerDT.Rows[0]["Password"].ToString();
|
|
deviceId = ServerDT.Rows[0]["EquipmentCode"].ToString();
|
|
serverPortNumber = int.Parse(ServerDT.Rows[0]["CommunicationPort"].ToString());
|
|
streamPortNumber = int.Parse(ServerDT.Rows[1]["CommunicationPort"].ToString());
|
|
plateNumber = ServerDT.Rows[0]["PlateNumber"].ToString();
|
|
}
|
|
else
|
|
{
|
|
XtraMessageBox.Show("当前病人没有绑定急救车!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
}
|
|
axPpvsguard1.ConnectDeviceByACS(deviceId, ServerIP, serverPortNumber, name, passWord);
|
|
//axPpvsguard1.SetDeviceNetLine(1);
|
|
//axPpvsguard1.StreamPlayStartByTCP(ServerIP, 0x1d82, deviceId, 1, 1, 1);
|
|
subscribeAllGPSNum = axPpvsguard1.SubscribeAllGPS(ServerIP, streamPortNumber, name, passWord, 0);
|
|
DictionaryXY.subScribeAllGPS = subscribeAllGPSNum;
|
|
//if (!DictionaryXY.arrXY.Keys.Contains<string>(plateNumber))
|
|
//{
|
|
// XtraMessageBox.Show("设备[" + plateNumber + "]不在线,无法进行实时播放!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
//}
|
|
//else
|
|
//{
|
|
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 btn_Playback_Click(object sender, EventArgs e)
|
|
{
|
|
//MyLngLatPoint startPoint = new MyLngLatPoint(116.380967, 39.913285);
|
|
//MyLngLatPoint endPoint = new MyLngLatPoint(116.424374, 39.914668);
|
|
//wm.BD_ShowCarRun(startPoint, endPoint);
|
|
//Thread th_carPlay;
|
|
//List<CarEntity> carHistoryTrailList = new List<CarEntity>();
|
|
//EventHandler method = null;
|
|
//if (btn_Playback.Text.Trim() == "开始回放")
|
|
//{
|
|
// if (string.IsNullOrEmpty(dateEdit_Start.TimeValue))
|
|
// {
|
|
// MessageBox.Show("请选择开始时间");
|
|
// }
|
|
// else if (string.IsNullOrEmpty(dateEdit_End.TimeValue))
|
|
// {
|
|
// MessageBox.Show("请选择结束时间");
|
|
// }
|
|
// else
|
|
// {
|
|
// DateTime time = Convert.ToDateTime(dateEdit_Start.TimeValue);
|
|
// DateTime time2 = Convert.ToDateTime(dateEdit_Start.TimeValue);
|
|
// if (time2 <= time)
|
|
// {
|
|
// MessageBox.Show("结束时间请大于开始时间");
|
|
// }
|
|
// else
|
|
// {
|
|
// TimeSpan span = (TimeSpan)(time2 - time);
|
|
// if (span.TotalMinutes > 120.0)
|
|
// {
|
|
// MessageBox.Show("时间范围请在2小时内");
|
|
// }
|
|
// else
|
|
// {
|
|
// if (method == null)
|
|
// {
|
|
// method = (param0, param1) => UnSubScribeGPS(DictionaryXY.subScribeAllGPS);
|
|
// }
|
|
// Invoke(method);
|
|
// //bool GpsFlag = false;
|
|
// Button_RTLS.Text = "实时播放";
|
|
// timer_drawLine.Stop();
|
|
// webMapCotrol2.BD_ClearOverlys();
|
|
// carHistoryTrailList.Clear();
|
|
// timer_drawLine.Start();
|
|
// DataTable dtCarPlay = null;
|
|
// int iBeginIndex = 0;
|
|
// try
|
|
// {
|
|
// bool threadRun = false;
|
|
// Thread th_carLoad.Abort();
|
|
// }
|
|
// catch
|
|
// {
|
|
// }
|
|
// webMapCotrol2.BD_ClearOverlys();
|
|
// try
|
|
// {
|
|
// if (th_carPlay != null)
|
|
// {
|
|
// th_carPlay.Abort();
|
|
// }
|
|
// th_carPlay = new Thread(new ThreadStart(CarPlay));
|
|
// th_carPlay.IsBackground = true;
|
|
// th_carPlay.Start();
|
|
// SelectCar();
|
|
// }
|
|
// catch
|
|
// {
|
|
// }
|
|
// this.timer_drawLine.Enabled = true;
|
|
// if (this.dtCarPlay == null)
|
|
// {
|
|
// this.simpleButton1.Text = "开始回放";
|
|
// }
|
|
// else
|
|
// {
|
|
// this.simpleButton1.Text = "停止回放";
|
|
// }
|
|
// this.firstPanTo = 0;
|
|
// }
|
|
// }
|
|
// }
|
|
//}
|
|
//else
|
|
//{
|
|
// this.timer_drawLine.Stop();
|
|
// this.webMapCotrol2.BD_ClearOverlys();
|
|
// this.carHistoryTrailList.Clear();
|
|
// this.timer_drawLine.Enabled = false;
|
|
// btn_Playback.Text = "开始回放";
|
|
//}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 实时定位
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void axPpvsguard_GPSComeEx(object sender, _DPpvsguardEvents_GPSComeExEvent e)
|
|
{
|
|
//SmartPpvsguard smartPpvsguard = new SmartPpvsguard();
|
|
//string str = (((Convert.ToDouble(Longitude)) / 3600.0) / 100.0).ToString("f6");
|
|
//string str2 = (((Convert.ToDouble(Latitude)) / 3600.0) / 100.0).ToString("f6");
|
|
|
|
if (e.lpDeviceID == deviceId)
|
|
{
|
|
Longitude = e.lpX;//经度
|
|
Latitude = e.lpY;//纬度
|
|
Speed = e.lpSpeed;
|
|
Time = e.lpSampleTime;
|
|
wm.BD_MapDirectionShow(plateNumber, e.lpDirection, Convert.ToDouble(Longitude), Convert.ToDouble(Latitude));
|
|
}
|
|
else
|
|
{
|
|
//SmartPpvsguard_GPSComeEx?.Invoke(sender, e);
|
|
}
|
|
}
|
|
|
|
public bool UnSubScribeGPS(int lAlarmUsrID)
|
|
{
|
|
bool flag2;
|
|
try
|
|
{
|
|
bool flag = false;
|
|
axPpvsguard1.UnSubscribeGPS(lAlarmUsrID);
|
|
axPpvsguard1.GPSComeEx -= new _DPpvsguardEvents_GPSComeExEventHandler(axPpvsguard_GPSComeEx);
|
|
flag2 = flag;
|
|
}
|
|
catch
|
|
{
|
|
throw;
|
|
}
|
|
return flag2;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 定时器绘制
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void timer_drawLine_Tick(object sender, EventArgs e)
|
|
{
|
|
//string str = _MSF.c_AVDeviceNumber;
|
|
//if (carHistoryTrailList.Count > 0)
|
|
//{
|
|
// string[] arr;
|
|
// string item = webMapCotrol2.CorrectPointFromGps(carHistoryTrailList[this.pushTrialPointsCount].LpX, this.carHistoryTrailList[this.pushTrialPointsCount].LpY);
|
|
// if (item.Length == 0)
|
|
// {
|
|
// MessageBox.Show("纠偏函数返回的数据有误!");
|
|
// }
|
|
// else
|
|
// {
|
|
// this.drawTrialLinePoints.Add(item);
|
|
// arr = item.Split(new char[] { ',' });
|
|
// if ((this.pushTrialPointsCount == 0) && (item != ""))
|
|
// {
|
|
// MyLngLatPoint p = new MyLngLatPoint
|
|
// {
|
|
// Lng = this.carHistoryTrailList[this.pushTrialPointsCount].LpX,
|
|
// Lat = this.carHistoryTrailList[this.pushTrialPointsCount].LpY
|
|
// };
|
|
// webMapCotrol2.BD_MapDirectionShow(p);
|
|
// webMapCotrol2.BD_PanTo(this.carHistoryTrailList[this.pushTrialPointsCount].LpX, this.carHistoryTrailList[this.pushTrialPointsCount].LpY);
|
|
// }
|
|
// MethodInvoker method = () => this.webMapCotrol2.BD_ShowCurve(string.Join(";", this.drawTrialLinePoints), arr[0], arr[1]);
|
|
// base.Invoke(method);
|
|
// this.pushTrialPointsCount++;
|
|
// if (this.pushTrialPointsCount == this.carHistoryTrailList.Count)
|
|
// {
|
|
// this.pushTrialPointsCount = 0;
|
|
// this.timer_drawLine.Stop();
|
|
// this.drawTrialLinePoints.Clear();
|
|
// MessageBox.Show("轨迹回放结束!");
|
|
// this.simpleButton1.Text = "开始回放";
|
|
// }
|
|
// Thread.Sleep(this.trackBarControl1.get_Value());
|
|
// }
|
|
//}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 关闭窗体
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void Form_FirstAidTrack_FormClosed(object sender, FormClosedEventArgs e)
|
|
{
|
|
axPpvsguard1.UnSubscribeGPS(subscribeAllGPSNum);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 坐标信息
|
|
/// </summary>
|
|
public static class DictionaryXY
|
|
{
|
|
// Fields
|
|
public static Dictionary<string, M_CarGPS> arrXY = new Dictionary<string, M_CarGPS>();
|
|
public static int notifySubscribe = 0;
|
|
public static int subScribeAllGPS = 0;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 车辆GPS信息
|
|
/// </summary>
|
|
public class M_CarGPS
|
|
{
|
|
/// <summary>
|
|
/// 急救车牌号
|
|
/// </summary>
|
|
public string ambulanceNumber = "湘A 120120";
|
|
|
|
/// <summary>
|
|
/// 设备ID
|
|
/// </summary>
|
|
public string deviceId = "657764018";
|
|
|
|
/// <summary>
|
|
/// 经度
|
|
/// </summary>
|
|
public string lpX = "112.988416";
|
|
|
|
/// <summary>
|
|
/// 纬度
|
|
/// </summary>
|
|
public string lpY = "28.196157";
|
|
}
|
|
}
|