/*
********************************************************
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;
  
  
  typedef char Filename[128];
  
  ////////////////////////////////////////////////////////////
  // Launcher status
  struct LC_status {
    short launcherError;
    // Error code 
    Boolean lastLaunchOK;
    // Last bouy launch succeed? 
    Boolean buoyInLaunchPosition;
    // Buoy in launch Position? 
    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 armsRetracted;
    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 
  ///////////////////////////////////////////////////////////////////
  // Is the buoy launcher ready to accept a command?
  // 
  Boolean ready();

  ///////////////////////////////////////////////////////////////////
  // 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 ('X' for ARGOS, 'D' for archive)
  // [input] filename: File containing data to download
  // [input] type_of_data: Char denoting what type of  data to 
  // download 'X' => data for ARGOS 'D' => data to store on the buoy
  DeviceIF::Status loadData(BuoyLauncherIF::Filename filename, char type_of_data);

  ///////////////////////////////////////////////////////////////////
  // Upload the log file from the launcher to the MVC
  // Uploads the last number of minutes from the Launcher log
  // file (instead of the whole file). Valid range is 0 to 255
  // minutes. 0 minutes means to upload the whole log file.
  DeviceIF::Status uploadLog(short numMinutesToUpload);

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

  ///////////////////////////////////////////////////////////////////
  // Rotate the "current buoy" to the Launch Position
  DeviceIF::Status rotateToLaunchPosition(Boolean realBuoy);

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

  //////////////////////////////////////////////////////////////////
  // Launch the "current" buoy. This is the "full launch", meaning
  // the Launcher will first rotate the current buoy to the launch
  // position, then eject the buoy. Parameter is the actual command
  // character specifying whether to instruct the buoy to "fire" or
  // not.
  DeviceIF::Status launch(char hot_or_cold);

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

  //////////////////////////////////////////////////////////////////
  // Eject the buoy that is in the launch position. This function
  // will first check to see if the buoy is in the launch position.
  DeviceIF::Status ejectBuoy();

  ///////////////////////////////////////////////////////////////////
  // 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);

  ///////////////////////////////////////////////////////////////////
  // Reinitialize the Launcher computer - reset state, etc.
  DeviceIF::Status reinitLauncher();

  ///////////////////////////////////////////////////////////////////
  // Retract the launcher arms from an extended position
  DeviceIF::Status retractArms();

  ///////////////////////////////////////////////////////////////////
  // Push arms out and retract
  DeviceIF::Status pushAndRetract();

  ///////////////////////////////////////////////////////////////////
  // Rotate to next launch ('P') or data ('Z') position 
  DeviceIF::Status rotateAPosition(char launch_or_data);

  
  protected:

  // Message codes for each method
  enum BuoyLauncherIFMsgCode {
    ReadyMsgCode = 6,
    NBuoysMsgCode,
    StatusOnMsgCode,
    CurrentBuoyMsgCode,
    LoadDataMsgCode,
    UploadLogMsgCode,
    RotateBuoyMsgCode,
    RotateToLaunchPositionMsgCode,
    RotateCarouselMsgCode,
    LaunchMsgCode,
    LaunchDummyBuoyMsgCode,
    EjectBuoyMsgCode,
    LaunchedMsgCode,
    GetLauncherStatusMsgCode,
    GetBuoyStatusMsgCode,
    ReinitLauncherMsgCode,
    RetractArmsMsgCode,
    PushAndRetractMsgCode,
    RotateAPositionMsgCode
  };

  // Define message structure for each method
  struct ReadyMsg : Request, Reply {
    Boolean returnVal;
  
  } _readyMsg;

  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;
    char type_of_data;
  
  } _loadDataMsg;

  struct UploadLogMsg : Request, Reply {
    DeviceIF::Status returnVal;
    short numMinutesToUpload;
  
  } _uploadLogMsg;

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

  struct RotateToLaunchPositionMsg : Request, Reply {
    DeviceIF::Status returnVal;
    Boolean realBuoy;
  
  } _rotateToLaunchPositionMsg;

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

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

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

  struct EjectBuoyMsg : Request, Reply {
    DeviceIF::Status returnVal;
  
  } _ejectBuoyMsg;

  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;

  struct ReinitLauncherMsg : Request, Reply {
    DeviceIF::Status returnVal;
  
  } _reinitLauncherMsg;

  struct RetractArmsMsg : Request, Reply {
    DeviceIF::Status returnVal;
  
  } _retractArmsMsg;

  struct PushAndRetractMsg : Request, Reply {
    DeviceIF::Status returnVal;
  
  } _pushAndRetractMsg;

  struct RotateAPositionMsg : Request, Reply {
    DeviceIF::Status returnVal;
    char launch_or_data;
  
  } _rotateAPositionMsg;

};

#endif

