Ejemplo n.º 1
0
 /// <summary>
 /// Creates a new Camera from a Device.
 /// </summary>
 /// <param name="device">The device </param>
 /// <returns>The newly created Camera</returns>
 /// <exception cref="ArgumentNullException">The Device supplied is null</exception>
 /// <exception cref="DeviceNotFound"></exception>
 public static Camera Create(this Device device)
 {
     if (null == device)
         throw new ArgumentNullException();
     if (!device.IsPoweredOn)
         throw new ArgumentException("The device is not powered on");
     lock (deviceLock)
     {
         // The SpotCam service only allows one camera at a time to be controlled.
         if (currentCamera != null)
             currentCamera.HandleDisconnection(DisconnectionReason.ForcedByService);
         currentCamera = null;
         currentCamera = new Camera(device);
         return currentCamera;
     }
 }
Ejemplo n.º 2
0
 public static void Reconnect(Camera camera)
 {
     if (null == camera)
         throw new ArgumentNullException();
     lock (deviceLock)
     {
         ulong devUid = camera.DeviceUid;
         unsafe
         {
             var serviceException = SpotCamService.MakeException(SpotCamService.SpotSetValue(CoreParameter.DeviceUid, new IntPtr(&devUid)));
             if (serviceException != null)
                 throw new InvalidOperationException("Unable to set the device identifier", serviceException);
         }
         SpotCamService.MakeException(SpotCamService.SpotInit()).ThrowIfNotNull();
         currentCamera = camera;                
     }
     camera.HandleConnection();
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Shuts down the factory. Initialize must be called again to restart the factory.
 /// </summary>
 public static void Shutdown()
 {
     System.Diagnostics.Debug.Assert(SpotCamReturnCode.Success == SpotCamService.SpotShutDown());
     currentCamera = null;
 }