public int openTspDialog(Pu pu, int channelNo) { foreach (OneDialog dlg in m_tspDialogs) { if (dlg.pu.id.Equals(pu.id, StringComparison.CurrentCultureIgnoreCase) && dlg.channelNo == channelNo) { LogHelper.LogHelper.RecordLog(51, string.Format("已经发送打开[{0}, {1}]串口通道的命令", pu.puName, channelNo)); return(-1); } } IntPtr dialog = IntPtr.Zero; int ret = BVCU.ManagedLayer_CuOpenTspDialog(m_bvsdkHandle, ref dialog, m_session.Handle, Encoding.UTF8.GetBytes(pu.id), channelNo, m_bvsdkEventHandler.tspDialog_OnEvent, m_bvsdkEventHandler.tspDialog_OnData); if (BVCU.BVCU_RESULT_S_OK == ret) { OneDialog dlg = new OneDialog(); dlg.dialogHandle = dialog; dlg.channelNo = channelNo; dlg.pu = pu; m_tspDialogs.Add(dlg); LogHelper.LogHelper.RecordLog(0, string.Format("正在打开设备:{0}, 通道:{1}的串口", pu.puName, channelNo)); return(0); } else { string errorMsg = string.Format("打开{0}的{1}串口失败(错误码:{2})", pu.puName, channelNo, ret); MessageBox.Show(errorMsg); LogHelper.LogHelper.RecordLog(100, errorMsg); } return(-1); }
public void OnGetPu(string puName, string puId, int iOnlineStatus, Channel channel) { foreach (Pu pu in m_server.puList) { if (pu.id.Equals(puId)) { pu.id = puId; pu.puName = puName; pu.OnlineStatus = iOnlineStatus == BVCU.BVCU_ONLINE_STATUS_ONLINE; if (null == getChannel(puId, channel.channelNo)) { if (null != channel) { channel.Parent = pu; } pu.channelList.Add(channel); return; } return; } } Pu newPu = new Pu(this); newPu.id = puId; newPu.puName = puName; newPu.OnlineStatus = iOnlineStatus == BVCU.BVCU_ONLINE_STATUS_ONLINE; if (null != channel) { channel.Parent = newPu; } newPu.channelList.Add(channel); m_server.puList.Add(newPu); }
public void procShowAlarmEventMessage(BVCU_Event_Source source) { string strEvent = source.szID; string strEventType = BVCU.ConvertEventType2String(source.iEventType); if (strEvent.Length == 0) { strEvent = "null" + " " + strEventType + " " + source.szEventDesc; } else if (source.iEventType >= BVCU.BVCU_EVENT_TYPE.VIDEOLOST && source.iEventType <= BVCU.BVCU_EVENT_TYPE.OUTROUTE) { if (null != m_sdkOperator && null != m_sdkOperator.m_session) { string puName = ""; Pu pu = m_sdkOperator.m_session.getPu(source.szID); if (pu != null) { puName = pu.puName; } strEvent = puName + "(" + source.szID + ")" + " " + strEventType + " " + source.szEventDesc; if (source.iEventType != BVCU.BVCU_EVENT_TYPE.PUONLINE && source.iEventType != BVCU.BVCU_EVENT_TYPE.PUOFFLINE) { if (source.bEnd == 1) { strEvent += " " + "结束"; } } } } MessageBox.Show(strEvent, "WinformDemo"); }
public int openGpsDialog(Pu pu, int channelNo) { foreach (OneDialog dlg in m_gpsDialogs) { if (dlg.pu.id.Equals(pu.id, StringComparison.CurrentCultureIgnoreCase) && dlg.channelNo == channelNo) { LogHelper.LogHelper.RecordLog(51, string.Format("已经发送打开[{0}, {1}]Gps通道的命令", pu.puName, channelNo)); return(-1); } } IntPtr dialog = IntPtr.Zero; int ret = BVCU.ManagedLayer_CuOpenGpsDialog(m_bvsdkHandle, ref dialog, m_session.Handle, Encoding.UTF8.GetBytes(pu.id), channelNo, m_bvsdkEventHandler.gpsDialog_OnEvent, m_bvsdkEventHandler.gpsDialog_OnData); if (BVCU.BVCU_RESULT_S_OK == ret) { OneDialog dlg = new OneDialog(); dlg.dialogHandle = dialog; dlg.channelNo = channelNo; dlg.pu = pu; m_gpsDialogs.Add(dlg); LogHelper.LogHelper.RecordLog(3, string.Format("正在打开{0}, {1}的Gps通道...", pu.puName, channelNo)); return(0); } else { LogHelper.LogHelper.RecordLog(3, string.Format("打开{0}, {1}的Gps通道失败, 错误码:{2}", pu.puName, channelNo, ret)); } return(-1); }
private void treeViewResList_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) { if (null == e || null == e.Node) { return; } if (e.Button == System.Windows.Forms.MouseButtons.Right) { if (e.Node.Level == TREE_LEVEL_CHANNEL) { Pu pu = m_sdkOperator.Session.getPu(e.Node.Parent.Name); int ichannelNo = (int)e.Node.Tag; g_pu = pu; g_channelNo = ichannelNo; if (ichannelNo >= BVCU.BVCU_SUBDEV_INDEXMAJOR_MIN_CHANNEL && ichannelNo < BVCU.BVCU_SUBDEV_INDEXMAJOR_MAX_CHANNEL) { contextMenuStripTalkOnly.Show(Control.MousePosition.X, Control.MousePosition.Y); } } if (e.Node.Level == TREE_LEVEL_PU) { tabControl.SelectedTab = tabPageDocRetrieval; Pu pu = m_sdkOperator.Session.getPu(e.Node.Name); g_SearchPu = pu; contextMenuStripDocRetrieval.Show(Control.MousePosition.X, Control.MousePosition.Y); } } }
void OnGetPuPtzAttr(IntPtr session, IntPtr puIdPtr, int ptzIndex, IntPtr ptzAttrPtr) { string puId = Marshal.PtrToStringAnsi(puIdPtr); BVCU_PUCFG_PTZAttr ptzAttr = (BVCU_PUCFG_PTZAttr)Marshal.PtrToStructure(ptzAttrPtr, typeof(BVCU_PUCFG_PTZAttr)); Pu pu = m_session.getPu(puId); if (pu != null) { pu.puPtz.Add(ptzAttr); } }
/// <summary> /// 打开对话(Dialog) /// </summary> /// <param name="pu"></param> /// <param name="channelNo"></param> /// <param name="panel"></param> public void openBrowse(Pu pu, int channelNo, Panel panel) { try { BVCU_DialogControlParam_Network net = new BVCU_DialogControlParam_Network(0, 5, 1, 3); BVRect dispRect = new BVRect(0, 0, panel.ClientRectangle.Height, panel.ClientRectangle.Width); OneDialog dlg = new OneDialog(); foreach (Channel channel in pu.channelList) { int volume = -1; if (channel.channelNo == channelNo) { if (channel.audioPlayback) { volume = 0; } //打开视屏浏览, 主要参数:sdkHandle、sessionHandle、puID、channelNo、显示区域的大小 int ret = BVCU.ManagedLayer_CuBrowsePu(m_bvsdkHandle, //sdk handle ref dlg.dialogHandle, //dialog handle m_session.Handle, //session handle Encoding.UTF8.GetBytes(pu.id), //pu id channelNo, //channel no panel.Handle, //pannel handle ref dispRect, //上下左右,矩形 volume, //音量 0, //single Rec File Sec Encoding.UTF8.GetBytes(""), //rec File Dir true, //videoTrans ref net, //network 时延 m_bvsdkEventHandler.dialog_OnDialogEvent, m_bvsdkEventHandler.dialog_OnStorageEvent); BVCU.FAILED(ret); LogHelper.LogHelper.RecordLog(4, string.Format("打开[{0}, {1}]的视屏预览通道", pu.puName, channelNo)); break; } } dlg.panel = panel; dlg.pu = pu; dlg.channelNo = channelNo; m_dialogs.Add(dlg); } catch { panel.ContextMenuStrip = null; MessageBox.Show("打开预览失败"); } }
/// <summary> /// 获得设备列表,更新Form中设备TreeView的内容,被this.getPuList()调用 /// </summary> void procGetPuList() { treeViewResList.Nodes.Clear(); TreeNode session = new TreeNode(m_sdkOperator.Session.Name); treeViewResList.Nodes.Add(session); for (int i = 0; i < m_sdkOperator.Session.PuList.Count; i++) { Pu pu = (Pu)m_sdkOperator.Session.PuList[i]; TreeNode puNode = new TreeNode(); puNode.Name = pu.id; if (pu.puName.Length == 0) { puNode.Text = pu.id; } else { puNode.Text = pu.puName; } session.Nodes.Add(puNode); for (int chIndex = 0; chIndex < pu.channelList.Count; chIndex++) { Channel channl = (Channel)pu.channelList[chIndex]; TreeNode channelNode = new TreeNode(channl.channelName); if (channl.OnlineStatus) { channelNode.ForeColor = Color.Blue; } else { channelNode.ForeColor = Color.Gray; } channelNode.Tag = channl.channelNo; puNode.Nodes.Add(channelNode); } if (pu.OnlineStatus) { puNode.ForeColor = Color.Blue; } else { puNode.ForeColor = Color.Gray; } } }
public Channel getChannel(string puId, int channelNo) { Pu pu = getPu(puId); if (pu != null) { foreach (Channel channel in pu.channelList) { if (channel.channelNo == channelNo) { return(channel); } } } return(null); }
public void openTalkOnly(Pu pu, int channelNo, Panel panel) { try { BVCU_DialogControlParam_Network net = new BVCU_DialogControlParam_Network(0, 5, 1, 3); BVRect dispRect = new BVRect(0, 0, panel.ClientRectangle.Height, panel.ClientRectangle.Width); OneDialog dlg = new OneDialog(); foreach (Channel channel in pu.channelList) { int captureVolume = 50; int audioVolume = 50; if (channel.channelNo == channelNo) { int ret = BVCU.ManagedLayer_CuNewTalk(m_bvsdkHandle, ref dlg.dialogHandle, m_session.Handle, Encoding.UTF8.GetBytes(pu.id), channelNo, captureVolume, audioVolume, ref net, m_bvsdkEventHandler.dialog_OnDialogEvent, m_bvsdkEventHandler.dialog_OnStorageEvent); BVCU.FAILED(ret); LogHelper.LogHelper.RecordLog(4, string.Format("打开[{0}]对讲", pu.puName)); break; } } dlg.panel = panel; dlg.pu = pu; dlg.channelNo = channelNo; m_dialogs.Add(dlg); } catch { panel.ContextMenuStrip = null; MessageBox.Show("打开对讲失败"); } }
/// <summary> /// 视频预览 /// </summary> /// <example>adf</example> /// <param name="pu">要预览的设备</param> /// <param name="channelNo">通道号</param> /// <param name="control">在哪个控件上预览</param> public void PreviewVideo(Pu pu, int channelNo, Control control) { BVCU_DialogControlParam_Network net = new BVCU_DialogControlParam_Network(0, 5, 1, 3); OneDialog dlg = new OneDialog(); BVRect dispRect = new BVRect(0, 0, control.ClientRectangle.Height, control.ClientRectangle.Width); //打开视屏浏览 int ret = BVCU.ManagedLayer_CuBrowsePu(m_bvsdkHandle, //sdk handle ref dlg.dialogHandle, //dialog handle m_session.Handle, //session handle Encoding.UTF8.GetBytes(pu.id), //pu id channelNo, //channel no control.Handle, //pannel handle ref dispRect, //上下左右,矩形 0, //音量 0, //single Rec File Sec Encoding.UTF8.GetBytes(""), //rec File Dir true, //videoTrans ref net, //network 时延 m_bvsdkEventHandler.dialog_OnDialogEvent, m_bvsdkEventHandler.dialog_OnStorageEvent); }
public void OnGetPu(string puName, string puId, Channel channel) { foreach (Pu pu in m_server.puList) { if (pu.id.Equals(puId)) { foreach (Channel chnl in pu.channelList) { if (chnl.channelNo == channel.channelNo) { return; } } pu.channelList.Add(channel); return; } } Pu newPu = new Pu(); newPu.id = puId; newPu.puName = puName; newPu.channelList.Add(channel); m_server.puList.Add(newPu); }
/// <summary> /// 点击设备列表中的节点时发生 /// </summary> private void treeViewResList_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) { if (null == e || null == e.Node) { return; } //点击通道时发生,视频通道 if (e.Node.Level == TREE_LEVEL_CHANNEL) { Pu pu = m_sdkOperator.Session.getPu(e.Node.Parent.Name); int channelNo = (int)e.Node.Tag; if (channelNo >= BVCU.BVCU_SUBDEV_INDEXMAJOR_MIN_CHANNEL && channelNo < BVCU.BVCU_SUBDEV_INDEXMAJOR_MAX_CHANNEL) { if (m_sdkOperator.Dialog.Count == VIDEO_PANEL_COUNT) { MessageBox.Show("窗口已全部占用"); return; } foreach (Panel panel in m_videoPanels) { if (panel.ContextMenuStrip == null) { panel.ContextMenuStrip = contextMenuStripVideo; Console.WriteLine("Open dialog pu " + pu.id + " channel " + channelNo); //打开浏览******************************************************************* m_sdkOperator.Dialog.openBrowse(pu, channelNo, panel); /* * Player p = new Player(); * p.Show(); * * m_sdkOperator.Dialog.PreviewVideo(pu, channelNo, p.tbPlay); */ break; } } } else if (channelNo >= BVCU.BVCU_SUBDEV_INDEXMAJOR_MIN_GPS && channelNo < BVCU.BVCU_SUBDEV_INDEXMAJOR_MAX_GPS) { //打开Gps通道 if (m_sdkOperator.Dialog.openGpsDialog(pu, channelNo) == 0) { ListViewItem item = new ListViewItem(); item.Text = pu.id; item.Tag = channelNo; ListViewItem.ListViewSubItem latItem = new ListViewItem.ListViewSubItem(); ListViewItem.ListViewSubItem lngItem = new ListViewItem.ListViewSubItem(); item.SubItems.AddRange(new ListViewItem.ListViewSubItem[] { latItem, lngItem }); listViewGPSData.Items.Add(item); } } else { //打开Tsp通道 if (m_sdkOperator.Dialog.openTspDialog(pu, channelNo) == 0) { ListViewItem item = new ListViewItem(); item.Text = pu.id; item.Tag = channelNo; ListViewItem.ListViewSubItem TspData = new ListViewItem.ListViewSubItem(); ListViewItem.ListViewSubItem len = new ListViewItem.ListViewSubItem(); item.SubItems.AddRange(new ListViewItem.ListViewSubItem[] { TspData, len }); listViewGPSData.Items.Add(item); } } }//点击通道时发生 end }