Пример #1
0
        public void InitCamearaList(int iPACK_SIZE)
        {
            CAMEAR_INF_LIST.Clear();
            CAMEAR_CODE_LIST.Clear();
            CameraNameList.Items.Clear();
            IVS_INDEX_RANGE pIndexRange = new IVS_INDEX_RANGE();

            pIndexRange.uiFromIndex = 1;
            pIndexRange.uiToIndex   = (uint)iPACK_SIZE;
            try
            {
                long   sizeList       = Marshal.SizeOf(typeof(IVS_CAMERA_BRIEF_INFO_LIST));                                               //992
                long   sizeInfo       = Marshal.SizeOf(typeof(IVS_CAMERA_BRIEF_INFO));                                                    //980
                long   deviceInfoLen  = (pIndexRange.uiToIndex - pIndexRange.uiFromIndex) * sizeInfo;                                     //2939020
                long   iBuffSize      = sizeList + deviceInfoLen;                                                                         //2940012
                IntPtr pDeviceListPtr = Marshal.AllocHGlobal((int)iBuffSize);                                                             //734789664
                IntPtr pDeviceINFO    = Marshal.AllocHGlobal((int)deviceInfoLen);                                                         //737738784

                int iRet = IVS_API.IVS_SDK_GetDeviceList(ApplicationEvent.iSession, 2, ref pIndexRange, pDeviceListPtr, (uint)iBuffSize); //0

                IVS_CAMERA_BRIEF_INFO_LIST list = new IVS_CAMERA_BRIEF_INFO_LIST();
                list.stCamerBriefInfo = new IVS_CAMERA_BRIEF_INFO[pIndexRange.uiToIndex - pIndexRange.uiFromIndex];
                list = (IVS_CAMERA_BRIEF_INFO_LIST)Marshal.PtrToStructure(pDeviceListPtr, typeof(IVS_CAMERA_BRIEF_INFO_LIST));
                int cCameraCount = StringEx.getInt(list.uiTotal);//得到数量
                if (list.uiTotal > 0)
                {
                    IntPtr tempInfoIntPtr = Marshal.AllocHGlobal((int)sizeInfo);//531396896
                    byte[] tempInfoByte   = new byte[sizeInfo];

                    for (int index = -1; index < pIndexRange.uiToIndex - pIndexRange.uiFromIndex && index < list.uiTotal - 1; index++)
                    {
                        Marshal.Copy((IntPtr)(pDeviceListPtr + (int)sizeList + (int)sizeInfo * index), tempInfoByte, 0, (int)sizeInfo);
                        Marshal.Copy(tempInfoByte, 0, tempInfoIntPtr, (int)sizeInfo);

                        IVS_CAMERA_BRIEF_INFO st = (IVS_CAMERA_BRIEF_INFO)Marshal.PtrToStructure(tempInfoIntPtr, typeof(IVS_CAMERA_BRIEF_INFO));//摄像机的内容
                        CAMEAR_INF_LIST.Add(st);
                        CAMEAR_CODE_LIST.Add(st.cCode);
                        CameraNameList.Items.Add(st.cName);
                    }
                    Marshal.FreeHGlobal(tempInfoIntPtr);
                }
                else
                {
                }
                Marshal.FreeHGlobal(pDeviceListPtr);
                Marshal.FreeHGlobal(pDeviceINFO);
            }
            catch (System.Exception ex)
            {
                System.Console.WriteLine(ex.ToString());
            }
        }
Пример #2
0
        private void timAfter_Tick(object sender, EventArgs e)
        {
            timAfter.Enabled = false;
            int iCode = 0;

            try
            {
                iCode = IVS_API.IVS_SDK_StopRealPlay(ApplicationEvent.iSession, (UInt32)ulRealPlayHandle);
            }
            catch (Exception ex)
            {
                log4net.WriteLogFile("IVS_SDK_StopRealPlay失败!");
            }

            try
            {
                String cORG_ID = INIConfig.ReadString("Config", AppConfig.ORG_ID);
                if (getTaskCameraCode(cORG_ID))
                {
                    log4net.WriteLogFile("剩余任务:" + ActiveLeftCount + ",当前任务:" + ActiveDevice_ID);
                    int idx = CAMEAR_CODE_LIST.IndexOf(ActiveDevice_ID);
                    if (idx == -1)
                    {
                        log4net.WriteLogFile("未找到匹配的摄像机!");
                    }
                    else
                    {
                        Object objInfo = CAMEAR_INF_LIST[idx];

                        IVS_CAMERA_BRIEF_INFO rowKey = (IVS_CAMERA_BRIEF_INFO)objInfo;

                        IVS_REALPLAY_PARAM para = new IVS_REALPLAY_PARAM();
                        para.bDirectFirst   = false;
                        para.bMultiCast     = false;
                        para.uiProtocolType = 2;
                        para.uiStreamType   = 1;
                        ActiveCameraCode    = rowKey.cCode;
                        ActiveCameraName    = rowKey.cName;

                        this.txtCameraName.Text = ActiveCameraName;
                        this.btnStartReal_Click(null, null);

                        ArrayList YWZList = Camera_YZW_List(ActiveCameraCode);
                        YWZ_TXT_LIST.Items.Clear();
                        YWZ_VAL_LIST.Clear();
                        //  for (int i = 0; (YWZList != null) && (i < YWZList.Count); i++)
                        if (YWZList.Count > 0)
                        {
                            for (int i = YWZList.Count - 1; i >= 0; i--)
                            {
                                IVS_PTZ_PRESET vPreset = (IVS_PTZ_PRESET)YWZList[i];
                                YWZ_TXT_LIST.Items.Add(vPreset.uiPresetIndex + ":" + vPreset.cPresetName);
                                YWZ_VAL_LIST.Add(vPreset);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                log4net.WriteLogFile(ActiveCameraName + "[" + ActiveCameraCode + "]" + ":" + ex.Message);
            }
            finally
            {
                timPreset.Enabled = true;
            }
        }