// Opens the camera by IP. static bool CameraOpen(ref tCamera Camera) { // Get the camera's IP configuration. if ((Camera.lErr = Pv.CameraIpSettingsGet(Camera.UID, ref Camera.Conf)) == tErr.eErrSuccess) { Camera.sAddr = Camera.Conf.CurrentIpAddress; } // Open the Camera by the address of camera. if ((Pv.CameraOpenByAddr(Camera.sAddr, tAccessFlags.eAccessMaster, out Camera.Handle) == tErr.eErrSuccess)) { return(true); } else { return(false); } }
static void ListingCameras(ref in_addr Camera) { UInt32 MaxCameraList = 20; tCameraInfo[] CameraList = new tCameraInfo[MaxCameraList]; UInt32 CameraNum = 0; UInt32 CameraRle; UInt32 Zero = 0; bool gstop = true; while (gstop) { Console.WriteLine("***********************************"); // Get list of reachable cameras. CameraNum = Pv.CameraList(CameraList, MaxCameraList, ref Zero); // Store how many cameras listed are reachable. CameraRle = CameraNum; // Append the list of unreachable cameras. if (CameraNum < MaxCameraList) { CameraNum += Pv.CameraListUnreachable(CameraList, (MaxCameraList - CameraNum), ref Zero); } if (CameraNum > 0) { // Go through the number of cameras detected. for (UInt32 i = 0; i < CameraNum; i++) { if (i < CameraRle) { // Get the camera's IP configuration. if ((Camera.lErr = Pv.CameraIpSettingsGet(CameraList[i].UniqueId, ref Camera.Conf)) == tErr.eErrSuccess) { Camera.S_addr = Camera.Conf.CurrentIpAddress; System.Net.IPAddress Address = new IPAddress(Camera.S_addr); // Display the camera info. Console.Write("{0}- {1} - Unique ID = {2} IP@ = {3}", CameraList[i].SerialString, CameraList[i].DisplayName, CameraList[i].UniqueId, Address); // Check to see if the camera is being used. if (CameraList[i].PermittedAccess == 6) { Console.WriteLine(" [Available]"); } else { Console.WriteLine(" [In use]"); } Console.WriteLine(); } else { Console.Write("{0}- {1} - Unique ID = {2} [Unavailable] ", CameraList[i].SerialString, CameraList[i].DisplayName, CameraList[i].UniqueId); } } else { Console.Write("{0}- {1} - Unique ID = {2}", CameraList[i].SerialString, CameraList[i].DisplayName, CameraList[i].UniqueId); } } if (CameraNum != CameraRle) { Console.WriteLine("Camera is unreachable."); } } else { Console.WriteLine("There is no camera detected."); } // Wait a certain amount of time before checking again. Thread.Sleep(1500); } }