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 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); }
public int openTspDialog(Session.Pu pu, int channelNo) { foreach (OneDialog dlg in m_tspDialogs) { if (dlg.pu.id.Equals(pu.id, StringComparison.CurrentCultureIgnoreCase) && dlg.channelNo == channelNo) { return(-1); } } IntPtr dialog = IntPtr.Zero; if (BVCU.ManagedLayer_CuOpenTspDialog(m_bvsdkHandle, ref dialog, m_session.Handle, Encoding.UTF8.GetBytes(pu.id), channelNo, m_bvsdkEventHandler.tspDialog_OnEvent, m_bvsdkEventHandler.tspDialog_OnData) == BVCU.BVCU_RESULT_S_OK) { OneDialog dlg = new OneDialog(); dlg.dialogHandle = dialog; dlg.channelNo = channelNo; dlg.pu = pu; m_tspDialogs.Add(dlg); return(0); } return(-1); }
void displayFont(IntPtr dialog, Int64 timeStamp) { OneDialog cuDlg = m_dialog.getDialog(dialog); if (null == cuDlg) { return; } if (cuDlg.panel != null) { AfterRenderIndex idx = getIdx(dialog); if (idx == null) { return; } cuDlg.panel.BeginInvoke(refreshAfterRenderIdx, new object[] { cuDlg, timeStamp }); BVCU.Color color = new BVCU.Color(0xFFFFFFFF); try { BVCU.BVDisplay_DisplayFont(idx.dispHandle, idx.index, ref idx.dispRect, ref color, cuDlg.timeStamp.ToString("yyyy'/'MM'/'dd HH:mm:ss")); } catch { } } }
public void ClearDialogs() { for (int i = 0; i < m_globalBVCUSdk.m_dialog.m_dialogs.Count; ++i) { OneDialog oneDialog = (OneDialog)m_globalBVCUSdk.m_dialog.m_dialogs[i]; if (oneDialog.dialogHandle != null) { m_globalBVCUSdk.m_dialog.closeDialog(oneDialog); } } for (int i = 0; i < m_globalBVCUSdk.m_dialog.m_gpsDialogs.Count; ++i) { OneDialog oneDialog = (OneDialog)m_globalBVCUSdk.m_dialog.m_gpsDialogs[i]; if (oneDialog.dialogHandle != null) { m_globalBVCUSdk.m_dialog.closeGpsDialog(oneDialog); } } for (int i = 0; i < m_globalBVCUSdk.m_dialog.m_tspDialogs.Count; ++i) { OneDialog oneDialog = (OneDialog)m_globalBVCUSdk.m_dialog.m_tspDialogs[i]; if (oneDialog.dialogHandle != null) { m_globalBVCUSdk.m_dialog.closeTspDialog(oneDialog); } } }
/// <summary> /// 创建用于叠加显示的字体 /// </summary> /// <param name="dialog"></param> public void createTimeStampFont(OneDialog dialog) { if (null == dialog) { return; } dialog.panel.BeginInvoke(createFontInDialog, new object[] { dialog }); }
private void buttonGetPtzAttr_Click(object sender, EventArgs e) { OneDialog dlg = m_sdkOperator.Dialog.getDialog(m_activePanel); if (dlg != null) { m_sdkOperator.getPtzAttr(dlg.pu.id, dlg.channelNo); } }
/// <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("打开预览失败"); } }
private void buttonGotoPresetPoint_Click(object sender, EventArgs e) { try { int index = int.Parse(comboBoxPresetPoint.Text.Substring(0, comboBoxPresetPoint.Text.IndexOf(" | "))); OneDialog dlg = m_sdkOperator.Dialog.getDialog(m_activePanel); if (dlg == null) { return; } m_sdkOperator.ptzControl(BVCU.BVCU_PTZ_COMMAND.PRESET_GO, dlg.pu.id, dlg.channelNo, BVCU_PTZ_MOVE.BEGIN, index); } catch { } }
private void comboBoxCruiseLine_DropDown(object sender, EventArgs e) { comboBoxCruiseLine.Items.Clear(); OneDialog dlg = m_sdkOperator.Dialog.getDialog(m_activePanel); if (dlg != null && dlg.pu.puPtz.Count > 0) { BVCU_PUCFG_PTZAttr ptzAttr = (BVCU_PUCFG_PTZAttr)dlg.pu.puPtz[0]; foreach (BVCU_PUCFG_Cruise cruise in ptzAttr.stCruise) { if (cruise.iIndex != -1) { comboBoxCruiseLine.Items.Add(cruise.iIndex + " | " + cruise.szName); } } } }
private void comboBoxPresetPoint_DropDown(object sender, EventArgs e) { comboBoxPresetPoint.Items.Clear(); OneDialog dlg = m_sdkOperator.Dialog.getDialog(m_activePanel); if (dlg != null && dlg.pu.puPtz.Count > 0) { BVCU_PUCFG_PTZAttr ptzAttr = (BVCU_PUCFG_PTZAttr)dlg.pu.puPtz[0]; foreach (BVCU_PUCFG_Preset preset in ptzAttr.stPreset) { if (preset.iIndex != -1) { comboBoxPresetPoint.Items.Add(preset.iIndex + " | " + preset.szPreset); } } } }
public void closeTspDialog(OneDialog tspDialog) { if (null == tspDialog) { return; } foreach (OneDialog dlg in m_tspDialogs) { if (dlg == tspDialog && dlg.dialogHandle != null) { BVCU.ManagedLayer_CuCloseDialog(m_bvsdkHandle, dlg.dialogHandle); m_tspDialogs.Remove(dlg); break; } } m_tspDialogs.Clear(); }
void procRefreshAfterRenderIdx(OneDialog dialog, Int64 timeStamp) { AfterRenderIndex idx = getIdx(dialog.dialogHandle); if (null == idx) { return; } idx.dispHandle = dialog.panel.Handle; idx.dispRect = new BVRect(dialog.panel.ClientRectangle.Top, dialog.panel.ClientRectangle.Left, dialog.panel.ClientRectangle.Bottom, dialog.panel.ClientRectangle.Right); double time = timeStamp / BVCU.SAV_TIME_BASE + 28800; DateTime dateTime = new DateTime(1970, 1, 1, 0, 0, 0).AddSeconds(time); dialog.timeStamp = dateTime; }
void procCreateFontInDialog(OneDialog dialog) { AfterRenderIndex idx = new AfterRenderIndex(); idx.type = INDEX_TYPE.FONT; idx.dispHandle = dialog.panel.Handle; idx.dialogHandle = dialog.dialogHandle; if (!BVCU.SUCCEEDED(BVCU.BVDisplay_CreateFont(idx.dispHandle, ref idx.index, 15, "Arial"))) { return; } BVCU.FontDisplayMode effect = new BVCU.FontDisplayMode(); effect.size = BVCU.FONT_DISPLAY_MODE_SIZE; effect.fontColor = new BVCU.Color(0xFFFFFFFF); effect.backColor = new BVCU.Color(0xFF000000); effect.effect = BVCU.BVDISPLAY_TEXT_EFFECT_OUTLINE; effect.effectSize = 1; BVCU.BVDisplay_SetFontDisplayMode(idx.dispHandle, idx.index, ref effect); m_afterRenderList.Add(idx); }
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 closeTspDialog(string puId, int channelNo) { //新增 foreach (OneDialog dlg in m_tspDialogs) { if (dlg.pu.id.Equals(puId, StringComparison.CurrentCultureIgnoreCase) && dlg.channelNo == channelNo) { BVCU.ManagedLayer_CuCloseDialog(m_bvsdkHandle, dlg.dialogHandle); for (int i = 0; i < this.m_tspDialogs.Count; i++) { OneDialog oneDialog = this.m_tspDialogs[i] as OneDialog; if (oneDialog.pu.id.Equals(puId) && oneDialog.channelNo.Equals(channelNo)) { this.m_tspDialogs.RemoveAt(i); this.TspStatusChange_OnEvent(); break; } } return; } } }
/// <summary> /// 巡游事件响应 /// </summary> private void buttonCruise_Click(object sender, EventArgs e) { try { int index = int.Parse(comboBoxCruiseLine.Text.Substring(0, comboBoxCruiseLine.Text.IndexOf(" | "))); m_cruiseBegin = !m_cruiseBegin; OneDialog dlg = m_sdkOperator.Dialog.getDialog(m_activePanel); if (dlg == null) { return; } if (m_cruiseBegin) { m_sdkOperator.ptzControl(BVCU.BVCU_PTZ_COMMAND.CRUISE_GO, dlg.pu.id, dlg.channelNo, BVCU_PTZ_MOVE.BEGIN, index); } else { m_sdkOperator.ptzControl(BVCU.BVCU_PTZ_COMMAND.CRUISE_STOP, dlg.pu.id, dlg.channelNo, BVCU_PTZ_MOVE.BEGIN, index); } } catch { } }
/* * 打开对话(Dialog) */ public void openBrowse(Session.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 (Session.Channel channel in pu.channelList) { int volume = -1; if (channel.channelNo == channelNo) { if (channel.audioPlayback) { volume = 0; } BVCU.FAILED( BVCU.ManagedLayer_CuBrowsePu(m_bvsdkHandle, ref dlg.dialogHandle, m_session.Handle, Encoding.UTF8.GetBytes(pu.id), channelNo, panel.Handle, ref dispRect, volume, 0, Encoding.UTF8.GetBytes(""), true, ref net, m_bvsdkEventHandler.dialog_OnDialogEvent, m_bvsdkEventHandler.dialog_OnStorageEvent)); break; } } dlg.panel = panel; dlg.pu = pu; dlg.channelNo = channelNo; m_dialogs.Add(dlg); } catch { panel.ContextMenuStrip = null; MessageBox.Show("打开预览失败"); } }
/// <summary> /// 云台控制响应 /// </summary> /// <param name="button"></param> /// <param name="move"></param> void buttonPtzControl(Button button, BVCU_PTZ_MOVE move) { int cmd = BVCU.BVCU_PTZ_COMMAND.UP; if (button.Name.Equals("buttonPTZLeftUp")) { cmd = BVCU.BVCU_PTZ_COMMAND.LEFTTOP; } else if (button.Name.Equals("buttonPTZUp")) { cmd = BVCU.BVCU_PTZ_COMMAND.UP; } else if (button.Name.Equals("buttonPTZRightUp")) { cmd = BVCU.BVCU_PTZ_COMMAND.RIGHTTOP; } else if (button.Name.Equals("buttonPTZRight")) { cmd = BVCU.BVCU_PTZ_COMMAND.RIGHT; } else if (button.Name.Equals("buttonPTZRightDown")) { cmd = BVCU.BVCU_PTZ_COMMAND.RIGHTDOWN; } else if (button.Name.Equals("buttonPTZDown")) { cmd = BVCU.BVCU_PTZ_COMMAND.DOWN; } else if (button.Name.Equals("buttonPTZLeftDown")) { cmd = BVCU.BVCU_PTZ_COMMAND.LEFTDOWN; } else if (button.Name.Equals("buttonPTZLeft")) { cmd = BVCU.BVCU_PTZ_COMMAND.LEFT; } else if (button.Name.Equals("buttonLensUp")) { cmd = BVCU.BVCU_PTZ_COMMAND.ZOOM_DEC; } else if (button.Name.Equals("buttonLensDown")) { cmd = BVCU.BVCU_PTZ_COMMAND.ZOOM_INC; } else if (button.Name.Equals("buttonFocusUp")) { cmd = BVCU.BVCU_PTZ_COMMAND.FOCUS_DEC; } else if (button.Name.Equals("buttonFocusDown")) { cmd = BVCU.BVCU_PTZ_COMMAND.FOCUS_INC; } else if (button.Name.Equals("buttonApertureUp")) { cmd = BVCU.BVCU_PTZ_COMMAND.APERTURE_DEC; } else if (button.Name.Equals("buttonApertureDown")) { cmd = BVCU.BVCU_PTZ_COMMAND.APERTURE_INC; } else { return; } OneDialog dlg = m_sdkOperator.Dialog.getDialog(m_activePanel); if (dlg != null) { m_sdkOperator.ptzControl(cmd, dlg.pu.id, dlg.channelNo, move); } }