/*
 * Solenoid.h
 *
 *  Created on: Aug 2, 2018
 *      Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
 */

#ifndef _SRC_OUTPUT_SOLENOID_H_
#define _SRC_OUTPUT_SOLENOID_H_

#include "output/items/Solenoid.h"
#include "output/items/detail/Item.h"
#include "output/items/detail/DriverBoardItem.h"

#include "output/DriverBoardPinController.h"

#include <future>
#include <chrono>

namespace flippR_driver
{
namespace output
{
namespace items
{
namespace detail
{

class Solenoid : public DriverBoardItem, public detail::Item, public items::Solenoid
{
public:
  Solenoid(std::shared_ptr<DriverBoardPinController> pin_controller, const uint8_t & address, const uint8_t & pin_base, const std::string & name, const std::chrono::milliseconds & deactivation_time);
  ~Solenoid() override = default;

  void trigger() override;

private:
  virtual void triggerTask();

private:
  const std::shared_ptr<DriverBoardPinController> pin_controller;
  const std::chrono::milliseconds deactivation_time;

  std::future<void> trigger_task;

};

}
} /* namespace output */
}
}
#endif
