#ifndef _BUOYLAUNCHERDRIVER_H
#define _BUOYLAUNCHERDRIVER_H

#include "PeriodicTask.h"
#include "SerialDevice.h"
#include "BuoyLauncherInput.h"
#include "BuoyLauncherOutput.h"
#include "BuoyLauncherIF.h"
#include "LcXmodem.h"

class BuoyLauncherDriver : public PeriodicTask {

public:

  BuoyLauncherDriver(SerialDevice *device, int period);

  virtual ~BuoyLauncherDriver();

protected:

  // Called on every cycle of control loop
  void periodicCallback();

  // Called when event is received from server
  void eventCallback(TaskInterface *taskIF, EventCode event);

  //load configuration data
  void loadConfiguration();

  Boolean launchBuoy(char real_or_dummy);

  void rotateBuoy();

  void rotateCarousel();

  void currentBuoy();

  void xferData(char);

  void status(char);

  Boolean sendCmdToLC(char);

  Boolean sendTimeToLC(time_t);

  Boolean readAckFromLC(unsigned timeout_in_secs);

  BuoyLauncherInput *_input;
  BuoyLauncherOutput *_output;
  SerialDevice *_device;
  LcXmodem *_lcx;
  Boolean _statusCalls;

  time_t _lastStatusCheck;

  int _period;

  // Interface to server. Driver subscribes to Initialize
  // and other events from server
  BuoyLauncherIF *_serverProxy;

  DeviceIF::Status initialize();

 };


#endif
