#ifndef _CAMERAINTERFACE_H
#define _CAMERAINTERFACE_H

#include "CameraInterfaceDm.h"

/*
CLASS 
CameraInterface

DESCRIPTION
Interface to control zoom, focus and iris

AUTHOR
Tom O'Reilly
*/
class CameraInterface {

public:

  ///////////////////////////////////////////////////////////////////
  // Constructor. 
  // [input] zoomMode: CameraZoomMode (ZoomRate or ZoomPosition)
  // [input] dmCameraPrefix: DataManager prefix for camera system
  //         (e.g., "VENTANA.HDTV.")
  CameraInterface(CameraZoomMode zoomMode, const char *dmCameraPrefix);

  ~CameraInterface();

  ///////////////////////////////////////////////////////////////////
  // Try to become exclusive provider of setpoint items.
  // Returns 0 on success, -1 on error.
  virtual int grab();

  ///////////////////////////////////////////////////////////////////
  // Release setpoint items.
  // Returns 0 on success, -1 on error.
  virtual int release();
    
  ///////////////////////////////////////////////////////////////////
  // Has object been grabbed by another user?
  MBool inUse();

  ///////////////////////////////////////////////////////////////////
  // Get zoom mode
  // Returns 0 on success, -1 on error.
  virtual int zoomMode(CameraZoomMode *mode);

  ///////////////////////////////////////////////////////////////////
  // Set zoom
  // Returns 0 on success, -1 on error.
  virtual int setZoom(Int16 value);

  ///////////////////////////////////////////////////////////////////
  // Get zoom setpoint
  // Returns 0 on success, -1 on error.
  virtual int zoomSetpoint(Int16 *value);

  ///////////////////////////////////////////////////////////////////
  // Get zoom 
  // Returns 0 on success, -1 on error.
  virtual int zoom(Int16 *value);

  ///////////////////////////////////////////////////////////////////
  // Set focus
  // Returns 0 on success, -1 on error.
  virtual int setFocus(Int16 value);

  ///////////////////////////////////////////////////////////////////
  // Get focus setpoint
  // Returns 0 on success, -1 on error.
  virtual focusSetpoint(Int16 *value);

  ///////////////////////////////////////////////////////////////////
  // Get focus
  // Returns 0 on success, -1 on error.
  virtual int focus(Int16 *value);

  ///////////////////////////////////////////////////////////////////
  // Set iris
  // Returns 0 on success, -1 on error.
  virtual int setIris(Int16 value);

  ///////////////////////////////////////////////////////////////////
  // Get iris setpoint
  // Returns 0 on success, -1 on error.
  virtual int irisSetpoint(Int16 *value);

  ///////////////////////////////////////////////////////////////////
  // Get iris
  // Returns 0 on success, -1 on error.
  virtual int iris(Int16 *value);

  ///////////////////////////////////////////////////////////////////
  // Get field-of-view width
  // Returns 0 on success, -1 on error.
  virtual int fieldWidth(Flt64 *value);

  ///////////////////////////////////////////////////////////////////
  // Get focal distance
  // Returns 0 on success, -1 on error.
  virtual int focalDistance(Flt64 *value);


  ///////////////////////////////////////////////////////////////////
  // Get zoom angle
  // Returns 0 on success, -1 on error.
  virtual int zoomAngle(Flt64 *value);

  ///////////////////////////////////////////////////////////////////
  // Pointer to data manager items
  CameraInterfaceDm *dmItems();
    

protected:

  CameraZoomMode _zoomMode;
  CameraInterfaceDm *_dmItems;
  Period _providePeriod;
  Period _consumePeriod;

  // True if object has successfully grabbed control
  MBool _iHaveIt;
};

#endif
