/*
********************************************************
Copyright 2000 MBARI.
MBARI Proprietary Information. All rights reserved.
NOTE: This file is automatically generated.
DO NOT MODIFY.
********************************************************
*/

#ifndef __BuoyLauncherIF_H
#define __BuoyLauncherIF_H

#include "TaskInterface.h"

#include "DeviceIF.h"

#define BuoyLauncherIFServerName "BuoyLauncherIFServer"

class BuoyLauncherIF : public DeviceIF {

  friend class BuoyLauncherIF_SK;

  public:

  // Forward declarations of public structures
  struct LC_status;
  struct BC_status;
  
  ////////////////////////////////////////////////////////////
  // Events generated by BuoyLauncher device driver, and 
  // broadcast to interested subscribers.
  enum Event {
    Launched,
    Misfired
  };

  
  typedef char Filename[128];
  
  ////////////////////////////////////////////////////////////
  // Launcher status
  struct LC_status {
    short launcherError;
    // Error code 
    Boolean lastLaunchOK;
    // Last bouy launch succeed? 
    Boolean buoyResponsive;
    // Current buoy talking? 
    Boolean nextBuoyReady;
    short currentBuoyNumber;
    // What buoy is in the comm position? 
    short numTotalBuoys;
    // How many buoys did we start with? 
    short numBuoysRemain;
    // How many buoys remain in the launcher? 
    short numBuoysLaunched;
    // How many buoys have been launched? 
    long timeSec;
    // Launcher UTC time (time_t) 
    long argosBytes;
    // How many ARGOS bytes are available 
    long archiveBytes;
    // How many archive bytes are available 
    long picoBytes;
    // How many ARGOS bytes are available 
    long dataMemory;
    // Memory pointer 
    Boolean lastLaunchDone;
    Boolean inLaunchPosition;
  };
  ////////////////////////////////////////////////////////////
  // Buoy status
  struct BC_status {
    short buoyNumber;
    // "current" buoy number 
    short mainBattVolts;
    // Voltage from the main battery 
    short auxBattVolts;
    // Voltage from the aux battery 
    short tempDegC;
    // Buoy temperature in Celsius 
    long timeSecBuoy;
    // Buoy time 
    long argosBytes;
    // How many ARGOS bytes available 
    long archiveBytes;
    // How many archive bytes available 
    long picoBytes;
    // How many pico bytes available 
    long dataMemory;
  };
  BuoyLauncherIF(const char *name, int timeout = 10);

  BuoyLauncherIF(const char *name, const char *serverName, int timeout = 10);

  ~BuoyLauncherIF();

  // Memory pointer 
  ///////////////////////////////////////////////////////////////////
  // Number of buoys (total, and launched)
  // [output] total: Total number of buoys
  // [output] launched: Number of buoys already launched
  DeviceIF::Status nBuoys(short *total, short *launched);

  // Send true to turn on the status calls
  DeviceIF::Status statusOn(Boolean on);

  ///////////////////////////////////////////////////////////////////
  // Specify the current buoy
  // [input] data: Data object to be loaded into the comm position
  DeviceIF::Status currentBuoy(short buoyNo);

  ///////////////////////////////////////////////////////////////////
  // Load data into the current buoy
  // [input] filename: File containing data to download
  DeviceIF::Status loadData(BuoyLauncherIF::Filename filename);

  ///////////////////////////////////////////////////////////////////
  // Rotate to the "next good" or "new current" buoy.
  DeviceIF::Status rotateBuoy();

  ///////////////////////////////////////////////////////////////////
  // Rotate carousel to the next buoy slot regardless if there is
  // a buoy there or not.
  DeviceIF::Status rotateCarousel();

  //////////////////////////////////////////////////////////////////
  // Launch the "current" buoy.
  DeviceIF::Status launch();

  // Launch the "current" buoy.
  DeviceIF::Status launchDummyBuoy();

  ///////////////////////////////////////////////////////////////////
  // Has the current buoy been launched?
  // [output] launched: True if buoy has been launched
  DeviceIF::Status launched(Boolean *launched);

  ///////////////////////////////////////////////////////////////////
  // Get BuoyLauncher status. Kinda vague right now.
  // [output] bitmask: Health and status of BuoyLauncher device
  DeviceIF::Status getLauncherStatus(BuoyLauncherIF::LC_status *status);

  ///////////////////////////////////////////////////////////////////
  // Get status of specified buoy. Kinda vague right now.
  // [output] bitmask: Health and status of buoy
  DeviceIF::Status getBuoyStatus(BuoyLauncherIF::BC_status *status);

  
  protected:

  // Message codes for each method
  enum BuoyLauncherIFMsgCode {
    NBuoysMsgCode = 6,
    StatusOnMsgCode,
    CurrentBuoyMsgCode,
    LoadDataMsgCode,
    RotateBuoyMsgCode,
    RotateCarouselMsgCode,
    LaunchMsgCode,
    LaunchDummyBuoyMsgCode,
    LaunchedMsgCode,
    GetLauncherStatusMsgCode,
    GetBuoyStatusMsgCode
  };

  // Define message structure for each method
  struct NBuoysMsg : Request, Reply {
    DeviceIF::Status returnVal;
    short total;
    short launched;
  
  } _nBuoysMsg;

  struct StatusOnMsg : Request, Reply {
    DeviceIF::Status returnVal;
    Boolean on;
  
  } _statusOnMsg;

  struct CurrentBuoyMsg : Request, Reply {
    DeviceIF::Status returnVal;
    short buoyNo;
  
  } _currentBuoyMsg;

  struct LoadDataMsg : Request, Reply {
    DeviceIF::Status returnVal;
    BuoyLauncherIF::Filename filename;
  
  } _loadDataMsg;

  struct RotateBuoyMsg : Request, Reply {
    DeviceIF::Status returnVal;
  
  } _rotateBuoyMsg;

  struct RotateCarouselMsg : Request, Reply {
    DeviceIF::Status returnVal;
  
  } _rotateCarouselMsg;

  struct LaunchMsg : Request, Reply {
    DeviceIF::Status returnVal;
  
  } _launchMsg;

  struct LaunchDummyBuoyMsg : Request, Reply {
    DeviceIF::Status returnVal;
  
  } _launchDummyBuoyMsg;

  struct LaunchedMsg : Request, Reply {
    DeviceIF::Status returnVal;
    Boolean launched;
  
  } _launchedMsg;

  struct GetLauncherStatusMsg : Request, Reply {
    DeviceIF::Status returnVal;
    BuoyLauncherIF::LC_status status;
  
  } _getLauncherStatusMsg;

  struct GetBuoyStatusMsg : Request, Reply {
    DeviceIF::Status returnVal;
    BuoyLauncherIF::BC_status status;
  
  } _getBuoyStatusMsg;

};

#endif

