Beispiel #1
0
        public bool Initialize()
        {
            if (m_bIsInitialized)
            {
                return(true);
            }

            if (m_intChannelIndex <= 0 || m_intChannelIndex > MAX_CHANNELINDEX)
            {
                for (uint i = 1; i <= MAX_CHANNELINDEX; i++)
                {
                    if (!GroupSDK.MAG_IsChannelAvailable(i))            //find an unused channel
                    {
                        GroupSDK.MAG_NewChannel(i);
                        m_intChannelIndex = i;

                        break;
                    }
                }
            }

            if (m_intChannelIndex > 0 && m_intChannelIndex <= MAX_CHANNELINDEX && GroupSDK.MAG_IsLanConnected())
            {
                m_bIsInitialized = GroupSDK.MAG_Initialize(m_intChannelIndex, m_hWndMsg);
            }

            return(m_bIsInitialized);
        }
Beispiel #2
0
        public void DeInitialize()
        {
            if (!m_bIsInitialized)
            {
                return;
            }

            if (GroupSDK.MAG_IsProcessingImage(m_intChannelIndex))
            {
                GroupSDK.MAG_StopProcessImage(m_intChannelIndex);
            }

            if (GroupSDK.MAG_IsListening(m_intChannelIndex))
            {
                GroupSDK.MAG_StopListen(m_intChannelIndex);
            }

            if (GroupSDK.MAG_IsLinked(m_intChannelIndex))
            {
                DisLinkCamera();//include stop sd storage
            }

            if (GroupSDK.MAG_IsInitialized(m_intChannelIndex))
            {
                GroupSDK.MAG_Free(m_intChannelIndex);
            }

            if (GroupSDK.MAG_IsChannelAvailable(m_intChannelIndex))
            {
                GroupSDK.MAG_DelChannel(m_intChannelIndex);
            }
        }
Beispiel #3
0
        /// <summary>
        /// 重启热像仪
        /// </summary>
        /// <returns></returns>
        public bool ResetCamera()
        {
            //the user should stop image process before reset
            //if you forget, the sdk will call MAG_StopProcessImage()

            //remember to stop sd storage before reset
            if (m_bIsRecordingMGS)
            {
                SDStorageMGSStop();
            }

            if (m_bIsRecordingAVI)
            {
                SDStorageAviStop();
            }

            if (GroupSDK.MAG_ResetCamera(m_intChannelIndex))
            {
                //MAG_ResetCamera() will call MAG_Free() and MAG_DelChannel()
                //so the channel is invalid now
                m_bIsInitialized  = false;
                m_intChannelIndex = 0xffffffff;

                //this object is reusable after call Initialize()

                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #4
0
 public void StopProcessImage()
 {
     if (GroupSDK.MAG_IsProcessingImage(m_intChannelIndex))
     {
         GroupSDK.MAG_StopProcessImage(m_intChannelIndex);
     }
 }
Beispiel #5
0
        /// <summary>
        /// 枚举在线相机,异步更新相机列表,因此立即GetTerminalList可能拿不到最新的,推荐sleep(50)
        /// </summary>
        /// <returns></returns>
        public bool EnumCameras()
        {
            if (!m_bIsIntialized)
            {
                Initialize();
            }

            return(m_bIsIntialized ? GroupSDK.MAG_EnumCameras() : false);
        }
Beispiel #6
0
        /// <summary>
        /// 获取本机IP
        /// </summary>
        /// <returns></returns>
        public uint GetLocalIp()
        {
            if (!m_bIsIntialized)
            {
                Initialize();
            }

            return(m_bIsIntialized ? GroupSDK.MAG_GetLocalIp() : 0);
        }
Beispiel #7
0
        public bool GetMulticastState(uint intTargetIP, ref uint intMulticastIp, ref uint intMulticastPort, uint intTimeout)
        {
            if (!m_bIsIntialized)
            {
                Initialize();
            }

            return(m_bIsIntialized ? GroupSDK.MAG_GetMulticastState(0, ref intMulticastIp, ref intMulticastPort, intTimeout) : false);
        }
Beispiel #8
0
        public GroupSDK.TEMP_STATE GetFrameStatisticalData()
        {
            int size = (int)Marshal.SizeOf(typeof(GroupSDK.TEMP_STATE));

            IntPtr ptr = GroupSDK.MAG_GetFrameStatisticalData(m_intChannelIndex);

            GroupSDK.TEMP_STATE state = (GroupSDK.TEMP_STATE)Marshal.PtrToStructure(ptr, typeof(GroupSDK.TEMP_STATE));

            return(state);
        }
Beispiel #9
0
        public bool SDStorageAviStop()
        {
            bool bReturn = GroupSDK.MAG_SDStorageAviStop(m_intChannelIndex);

            if (bReturn)
            {
                m_bIsRecordingAVI = false;
            }

            return(bReturn);
        }
Beispiel #10
0
 public bool ListenTo(uint intIP)
 {
     if (GroupSDK.MAG_ListenTo(m_intChannelIndex, intIP))
     {
         GroupSDK.MAG_GetCamInfo(m_intChannelIndex, ref m_CamInfo, Marshal.SizeOf(typeof(GroupSDK.CAMERA_INFO)));
         return(true);
     }
     else
     {
         return(false);
     }
 }
Beispiel #11
0
 public bool SetCameraRegContent(GroupSDK.CAMERA_REGCONTENT RegContent)
 {
     if (GroupSDK.MAG_SetCameraRegContent(m_intChannelIndex, ref RegContent))
     {
         GroupSDK.MAG_ReadCameraRegContent(m_intChannelIndex, ref m_RegContent, 2 * MAG_DEFAULT_TIMEOUT, 0);
         return(true);
     }
     else
     {
         return(false);
     }
 }
Beispiel #12
0
        void threadfthod()
        {
            if (!GroupSDK.MAG_IsChannelAvailable(0))
            {
                if (GroupSDK.MAG_NewChannel(0))
                {
                    if (GroupSDK.MAG_Initialize(0, IntPtr.Zero))
                    {
                        updateListBox("初始化成功");
                        updateListBox("创建通道0成功");
                        if (GroupSDK.MAG_IsUsingStaticIp())
                        {
                            updateListBox("使用静态IP");
                            uint loaclIP = magService.GetLocalIp();
                            updateListBox("获取到本机IP" + loaclIP);
                            if (magService.StartDHCPServer())
                            {
                                updateListBox("开启静态连接");
                                uint dev_num = 0;

                                if (magService.EnumCameras())
                                {
                                    updateListBox("枚举摄像机");
                                    Thread.Sleep(500);
                                    dev_num = magService.GetTerminalList(_LstEnumInfo, MAX_ENUMDEVICE);

                                    updateListBox("一共有" + dev_num + "摄像机,集合长度" + _LstEnumInfo[0].sName);
                                    if (mag.LinkCamera(loaclIP, 50))
                                    {
                                        updateListBox("连接成功");
                                    }
                                    else
                                    {
                                        updateListBox("连接false");
                                    }
                                }
                            }
                        }
                    }

                    //if (mag.LinkCamera("192.168.1.33", 50000))
                    //{
                    //    updateListBox("连接成功");
                    //}
                    //else
                    //{
                    //    updateListBox("连接失败");
                    //}
                }
            }
        }
Beispiel #13
0
        public bool LoadDDT(GroupSDK.OUTPUT_PARAM param, [MarshalAs(UnmanagedType.LPWStr)] string sFileName, GroupSDK.DelegateNewFrame funcFrame, IntPtr pUserData)
        {
            if (!GroupSDK.MAG_IsProcessingImage(m_intChannelIndex))
            {
                if (!GroupSDK.MAG_LoadDDT(m_intChannelIndex, ref param, sFileName, funcFrame, pUserData))
                {
                    return(false);
                }

                GroupSDK.MAG_GetCamInfo(m_intChannelIndex, ref m_CamInfo, Marshal.SizeOf(typeof(GroupSDK.CAMERA_INFO)));
                return(true);
            }

            return(false);
        }
Beispiel #14
0
        public bool LoadBufferedDDT(GroupSDK.OUTPUT_PARAM param, IntPtr pBuffer, uint size, GroupSDK.DelegateNewFrame funcFrame, IntPtr pUserData)
        {
            if (!GroupSDK.MAG_IsProcessingImage(m_intChannelIndex))
            {
                if (!GroupSDK.MAG_LoadBufferedDDT(m_intChannelIndex, ref param, pBuffer, size, funcFrame, pUserData))
                {
                    return(false);
                }

                GroupSDK.MAG_GetCamInfo(m_intChannelIndex, ref m_CamInfo, Marshal.SizeOf(typeof(GroupSDK.CAMERA_INFO)));
                return(true);
            }

            return(true);
        }
Beispiel #15
0
        /// <summary>
        /// 连接相机
        /// </summary>
        /// <param name="intIP"></param>
        /// <param name="intTimeOut">ms</param>
        /// <returns></returns>
        public bool LinkCamera(uint intIP, uint intTimeOut)
        {
            if (GroupSDK.MAG_LinkCamera(m_intChannelIndex, intIP, intTimeOut))
            {
                m_intCameraIPAddr = intIP;
                GroupSDK.MAG_GetCamInfo(m_intChannelIndex, ref m_CamInfo, Marshal.SizeOf(typeof(GroupSDK.CAMERA_INFO)));
                GroupSDK.MAG_ReadCameraRegContent(m_intChannelIndex, ref m_RegContent, intTimeOut, 0);

                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #16
0
        public bool LinkCameraEx(uint intIP, ushort shortPort, string charCloudUser, string charCloudPwd,
                                 uint intCamSN, string charCamUser, string charCamPwd, uint intTimeOut)
        {
            if (GroupSDK.MAG_LinkCameraEx(m_intChannelIndex, intIP, shortPort, charCloudUser, charCloudPwd,
                                          intCamSN, charCamUser, charCamPwd, intTimeOut))
            {
                m_intCameraIPAddr = intIP;
                GroupSDK.MAG_GetCamInfo(m_intChannelIndex, ref m_CamInfo, Marshal.SizeOf(typeof(GroupSDK.CAMERA_INFO)));
                GroupSDK.MAG_ReadCameraRegContent(m_intChannelIndex, ref m_RegContent, intTimeOut, 0);

                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #17
0
        public void DisLinkCamera()
        {
            //remember to stop sd storage before dislink
            if (m_bIsRecordingMGS)
            {
                SDStorageMGSStop();
            }

            if (m_bIsRecordingAVI)
            {
                SDStorageAviStop();
            }

            m_intCameraIPAddr = 0;

            GroupSDK.MAG_DisLinkCamera(m_intChannelIndex);
        }
Beispiel #18
0
        /// <summary>
        /// 获取在线相机列表
        /// </summary>
        /// <param name="list"></param>
        /// <param name="size">list总的字节数</param>
        /// <returns></returns>
        public uint GetTerminalList(GroupSDK.ENUM_INFO[] list, uint unit_count)
        {
            if (!m_bIsIntialized)
            {
                return(0);
            }
            //创建新的实例
            GroupSDK.ENUM_INFO[] camers = new GroupSDK.ENUM_INFO[32];

            uint size = (uint)Marshal.SizeOf(typeof(GroupSDK.CAMERA_INFO)) * unit_count;

            IntPtr ptr       = Marshal.AllocHGlobal((int)size);
            IntPtr ptrBackup = ptr;

            uint dev_num = GroupSDK.MAG_GetTerminalList(ptr, size);

            for (int i = 0; i < dev_num; i++)
            {
                camers[i] = (GroupSDK.ENUM_INFO)Marshal.PtrToStructure(ptr, typeof(GroupSDK.ENUM_INFO));
                ptr       = (IntPtr)((int)ptr + Marshal.SizeOf(typeof(GroupSDK.ENUM_INFO)));
            }

            Marshal.FreeHGlobal(ptrBackup);
            int index = 0;

            for (int i = 0; i < dev_num; i++)
            {
                string nowip = IntToIP(camers[i].intCamIp);
                if (nowip == Globals.CameraIp1 || nowip == Globals.CameraIp2)//如果相机属于配置文件里面的IP
                {
                    list[index] = camers[i];
                    index++;
                    if (index == 2)
                    {
                        break;
                    }
                }
            }
            if (dev_num >= 2)
            {
                dev_num = 2;
            }

            return(dev_num);
        }
Beispiel #19
0
        public bool Initialize()
        {
            if (m_bIsIntialized)
            {
                return(true);
            }

            if (!GroupSDK.MAG_IsChannelAvailable(0))
            {
                GroupSDK.MAG_NewChannel(0);
            }

            if (GroupSDK.MAG_IsLanConnected())
            {
                m_bIsIntialized = GroupSDK.MAG_Initialize(0, m_hWndMsg);
            }

            return(m_bIsIntialized);
        }
Beispiel #20
0
        public void DeInitialize()
        {
            if (!m_bIsIntialized)
            {
                return;
            }

            if (GroupSDK.MAG_IsDHCPServerRunning())
            {
                GroupSDK.MAG_StopDHCPServer();
            }

            if (GroupSDK.MAG_IsInitialized(0))
            {
                GroupSDK.MAG_Free(0);
            }

            if (GroupSDK.MAG_IsChannelAvailable(0))
            {
                GroupSDK.MAG_DelChannel(0);
            }

            m_bIsIntialized = false;
        }
Beispiel #21
0
        /// <summary>
        /// 获取在线相机列表
        /// </summary>
        /// <param name="list"></param>
        /// <param name="size">list总的字节数</param>
        /// <returns></returns>
        public uint GetTerminalList(GroupSDK.ENUM_INFO[] list, uint unit_count)
        {
            if (!m_bIsIntialized)
            {
                return(0);
            }

            uint size = (uint)Marshal.SizeOf(typeof(GroupSDK.CAMERA_INFO)) * unit_count;

            IntPtr ptr       = Marshal.AllocHGlobal((int)size);
            IntPtr ptrBackup = ptr;

            uint dev_num = GroupSDK.MAG_GetTerminalList(ptr, size);

            for (int i = 0; i < dev_num; i++)
            {
                list[i] = (GroupSDK.ENUM_INFO)Marshal.PtrToStructure(ptr, typeof(GroupSDK.ENUM_INFO));
                ptr     = (IntPtr)((int)ptr + Marshal.SizeOf(typeof(GroupSDK.ENUM_INFO)));
            }

            Marshal.FreeHGlobal(ptrBackup);

            return(dev_num);
        }
Beispiel #22
0
 public void SetIsothermalPara(int intLowerLimit, int intUpperLimit)
 {
     GroupSDK.MAG_SetIsothermalPara(m_intChannelIndex, intLowerLimit, intUpperLimit);
 }
Beispiel #23
0
 public bool SetSerialCallBack(GroupSDK.DelegateSerial cb, IntPtr pUserData)
 {
     return(GroupSDK.MAG_SetSerialCallBack(m_intChannelIndex, cb, pUserData));
 }
Beispiel #24
0
 public bool GetCurrentOffset([MarshalAs(UnmanagedType.LPWStr)] string sReferenceDDT, ref int offsetx, ref int offsety)
 {
     return(GroupSDK.MAG_GetCurrentOffset(m_intChannelIndex, sReferenceDDT, ref offsetx, ref offsety));
 }
Beispiel #25
0
 public void Unlock()
 {
     GroupSDK.MAG_UnLockFrame(m_intChannelIndex);
 }
Beispiel #26
0
 public bool SaveDDT([MarshalAs(UnmanagedType.LPWStr)] string sFileName)
 {
     return(GroupSDK.MAG_SaveDDT(m_intChannelIndex, sFileName));
 }
Beispiel #27
0
 public bool SDStorageAviStart()
 {
     m_bIsRecordingAVI |= GroupSDK.MAG_SDStorageAviStart(m_intChannelIndex);
     return(m_bIsRecordingAVI);
 }
Beispiel #28
0
 public bool SDStorageMGSStart()
 {
     m_bIsRecordingMGS |= GroupSDK.MAG_SDStorageMGSStart(m_intChannelIndex);
     return(m_bIsRecordingMGS);
 }
Beispiel #29
0
 public bool SDStorageBMP()
 {
     return(GroupSDK.MAG_SDStorageBMP(m_intChannelIndex));
 }
Beispiel #30
0
 public int SaveDDT2Buffer(byte[] pBuffer, uint intBufferSize)
 {
     return(GroupSDK.MAG_SaveDDT2Buffer(m_intChannelIndex, pBuffer, intBufferSize));
 }