/*******************************************************************************
 Copyright(c) 2013-2016 CloudMakers, s. r. o. All rights reserved.
 
 This library is free software; you can redistribute it and/or
 modify it under the terms of the GNU Library General Public
 License version 2 as published by the Free Software Foundation.
 
 This library is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 Library General Public License for more details.
 
 You should have received a copy of the GNU Library General Public License
 along with this library; see the file COPYING.LIB.  If not, write to
 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 Boston, MA 02110-1301, USA.
 *******************************************************************************/

IMAGER AGENT version 1.2

Purpose of this virtual driver is an unattended capture of a batch of groups of images.
Each group can have different settings for a number of images, binning, filter slot and
exposure duration. The point is, that no connected client and no network connection is
needed during batch execution.

1. Changes in recent version

- IMAGE_FOLDER property is renamed to IMAGE_NAME, IMAGE_PREFIX item is added.
- Debug logging added.
- Agent utilises local upload mode of CCD drivers.

2. How to use it

  Run in indiserver together with CCD driver and optional Filter wheel driver:

    e.g. $ indiserver indi_imager_agent indi_simulator_ccd indi_simulator_wheel

  Define batch and controlled devices:

    Property      Item                Type    Description
    ======================================================================================
    GROUPS        GROUP_COUNT         number  Number of groups in batch.
    
    GROUP_XX      IMAGE_COUNT         number  Number of images in group XX.
                  CCD_BINNING         number  Binning (both x and y) for images.
                  FILTER_SLOT         number  Filter slot for images. Set to 0 if you
                                              don't use Filter wheel.
                  CCD_EXPOSURE_VALUE  number  Exposure duration for images.
                  
    DEVICES       CCD                 text    Controlled CCD device name.
                  FILTER              text    Controlled Filter wheel device name.
                  
    IMAGE_NAME    IMAGE_FOLDER        text    Local folder to store the captured images.
                  IMAGE_PREFIX        text    File name prefix for the captured images.
    ======================================================================================

  Connect, disconnect control batch execution and monitor the status:

    Property      Item                Type    Description
    ======================================================================================
    CONNECTION    CONNECT             switch  Connect the agent and the controlled
                                              devices, if they are not already connected.
                  DISCONNECT          switch  Disconnect agent.
                  
    STATUS        CCD                 light   Status of the controlled CCD driver.
                  FILTER              light   Status of the controlled Filter driver.
                  
    BATCH         START               switch  Start the batch execution.
                  ABORT               switch  Abort the batch execution.
                  
    PROGRESS      GROUP               number  The current group in progress.
                  IMAGE               number  The current image in progress.
                  REMAINING_TIME      number  The remaining duration for the current
                                              image.
    ======================================================================================
    
  Download captured images:

    Property      Item                Type    Description
    ======================================================================================
    DOWNLOAD      GROUP               number  The group number for image to download.
                  IMAGE               number  The image number to download.
                  
    IMAGE         IMAGE               BLOB    The image data for image selected by
                                              DOWNLOAD property. The image is deleted from
                                              the image folder after download.
    ======================================================================================

3. Known issues and TODOs

  - The server host and port for controlled devices can't be configured, it is always
    localhost:7624.
  - Image format (compressed vs. raw image) can't be configured, the format of last captured
    image is always used for subsequent download.
  - It can't be reliable detected that CCD or filter wheel driver was disconnected during
    batch execution.
  - The images which are not downloaded remains in the image folder when the driver is
    stopped.