//开始运行 private bool RunMap() { string key = string.Empty; CameraConf cameraConf = new CameraConf(); //地图 Image imgMap = null; int nLoadMap = BaseMethod.INIGetIntValue(BaseDefine.CONFIG_FILE_PATH_ENV, BaseDefine.CONFIG_SECTION_CONFIG, BaseDefine.CONFIG_KEY_LOADMAP, 0); if (1 == nLoadMap) { try { imgMap = Image.FromFile(BaseDefine.IMG_PATH_MAPN); } catch (Exception e) { Log.GetLogger().ErrorFormat("Image.FromFile catch an error : {0}", e.Message); } } foreach (int iKch in dicCars.Keys) { Thread.Sleep(10); CarManager carManager = dicCars[iKch]; //动态解码 key = string.Format("考车{0}_1", iKch); if (!dicCameras.ContainsKey(key)) { Log.GetLogger().ErrorFormat("{0} 摄像头未配置,请检查", key); } else { cameraConf = dicCameras[key]; carManager.StartDynamicDecode(cameraConf, 0); } key = string.Format("考车{0}_2", iKch); if (!dicCameras.ContainsKey(key)) { Log.GetLogger().ErrorFormat("{0} 摄像头未配置,请检查", key); } else { cameraConf = dicCameras[key]; carManager.StartDynamicDecode(cameraConf, 1); } try { //被动解码 int thirdPH = -1; int fourthPH = -1; if (carManager.StartPassiveDecode(2, ref thirdPH) && carManager.StartPassiveDecode(3, ref fourthPH)) { ExamProcedure examProcedure = new ExamProcedure(); if (examProcedure.Init(m_userId, iKch, thirdPH, fourthPH, imgMap)) { dicExamProcedures.Add(iKch, examProcedure); } } else { Log.GetLogger().ErrorFormat("被动解码失败,kch={0}", iKch); } } catch (Exception e) { Log.GetLogger().ErrorFormat("catch an error : {0}", e.Message); } } return(true); }
/// <summary> /// 合码器通道检测及初始化 /// </summary> /// <param name="kch">考车号</param> /// <param name="dvi">dvi 编号</param> /// <returns></returns> private bool CheckDVIChan(int kch, int dvi) { uint lpdwEnable = 0; uint dwDecChanNum = 0; byte[] byDecChan = new byte[4]; //解码通道检测 for (int i = 0; i < 4; i++) { byDecChan[i] = (byte)(m_struDecAbility.byStartChan + dvi * 4 + i); dwDecChanNum = byDecChan[i]; if (CHCNetSDK.NET_DVR_MatrixGetDecChanEnable(m_userId, dwDecChanNum, ref lpdwEnable)) { if (0 == lpdwEnable) //取出的值为 0 表示关闭。 { if (!CHCNetSDK.NET_DVR_MatrixSetDecChanEnable(m_userId, dwDecChanNum, 1)) //打开通道 { m_iErrorCode = CHCNetSDK.NET_DVR_GetLastError(); Log.GetLogger().ErrorFormat("NET_DVR_MatrixSetDecChanEnable failed, error code = {0},打开通道失败", m_iErrorCode); return(false); } } } } //显示通道检测 CHCNetSDK.NET_DVR_MATRIX_VOUTCFG m_DispChanCfg = new CHCNetSDK.NET_DVR_MATRIX_VOUTCFG(); uint dwDispChan = (uint)(m_struDecAbility.struDviInfo.byStartChan + dvi); if (!CHCNetSDK.NET_DVR_MatrixGetDisplayCfg_V41(m_userId, dwDispChan, ref m_DispChanCfg)) { m_iErrorCode = CHCNetSDK.NET_DVR_GetLastError(); Log.GetLogger().ErrorFormat("NET_DVR_MatrixGetDisplayCfg_V41 failed, error code = {0},获取显示通道配置失败", m_iErrorCode); return(false); } if (m_DispChanCfg.dwWindowMode != 4 || m_DispChanCfg.byJoinDecChan[0] != byDecChan[m_dispalyShow[0]] || m_DispChanCfg.byJoinDecChan[1] != byDecChan[m_dispalyShow[1]] || m_DispChanCfg.byJoinDecChan[2] != byDecChan[m_dispalyShow[2]] || m_DispChanCfg.byJoinDecChan[3] != byDecChan[m_dispalyShow[3]]) //显示通道不是四分割输出 { m_DispChanCfg.byJoinDecChan[0] = byDecChan[m_dispalyShow[0]]; m_DispChanCfg.byJoinDecChan[1] = byDecChan[m_dispalyShow[1]]; m_DispChanCfg.byJoinDecChan[2] = byDecChan[m_dispalyShow[2]]; m_DispChanCfg.byJoinDecChan[3] = byDecChan[m_dispalyShow[3]]; m_DispChanCfg.byAudio = 1; //开启音频 m_DispChanCfg.byAudioWindowIdx = (byte)m_dispalyShow[4]; //音频子窗口 1 m_DispChanCfg.byVedioFormat = 1; //视频制式,1-NTSC,2-PAL //该项配置与合码器不同 m_DispChanCfg.dwResolution = 67207228; //该项配置与合码器不同 m_DispChanCfg.dwWindowMode = 4; m_DispChanCfg.byScale = 0; //真实 //解码器设置显示通道配置 if (!CHCNetSDK.NET_DVR_MatrixSetDisplayCfg_V41(m_userId, dwDispChan, ref m_DispChanCfg)) { m_iErrorCode = CHCNetSDK.NET_DVR_GetLastError(); if (29 == m_iErrorCode) { Log.GetLogger().ErrorFormat("错误29:设备操作失败,请将合码器完全恢复下.设备管理=>恢复默认参数=>完成恢复"); } Log.GetLogger().ErrorFormat("NET_DVR_MatrixSetDisplayCfg_V41 failed, error code = {0},设置显示通道配置失败", m_iErrorCode); return(false); } } //考车初始化 CarManager car = new CarManager(); car.InitCar(kch, m_userId, byDecChan); if (!dicCars.ContainsKey(kch)) { dicCars.Add(kch, car); } return(true); }