#pragma once

#include <fsfw/devicehandlers/DeviceHandlerBase.h>
#include <fsfw/power/DummyPowerSwitcher.h>

class PcduHandlerDummy : public PowerSwitchIF,
                         public HasLocalDataPoolIF,
                         public SystemObject,
                         public ExecutableObjectIF {
 public:
  static const DeviceCommandId_t SIMPLE_COMMAND = 1;
  static const DeviceCommandId_t PERIODIC_REPLY = 2;

  static const uint8_t SIMPLE_COMMAND_DATA = 1;
  static const uint8_t PERIODIC_REPLY_DATA = 2;

  PcduHandlerDummy(object_id_t objectId);
  virtual ~PcduHandlerDummy();

 protected:
  MessageQueueIF* queue;
  LocalDataPoolManager manager;
  MutexIF* switcherLock;
  DummyPowerSwitcher dummySwitcher;
  using SwitcherBoolArray = std::array<bool, 18>;

  ReturnValue_t performOperation(uint8_t opCode) override;
  SwitcherBoolArray switchChangeArray{};

  ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
                                        LocalDataPoolManager& poolManager) override;

  ReturnValue_t sendSwitchCommand(power::Switch_t switchNr, ReturnValue_t onOff) override;
  ReturnValue_t sendFuseOnCommand(uint8_t fuseNr) override;
  ReturnValue_t getSwitchState(power::Switch_t switchNr) const override;
  ReturnValue_t getFuseState(uint8_t fuseNr) const override;
  uint32_t getSwitchDelayMs(void) const override;

  object_id_t getObjectId() const override;

  /** Command queue for housekeeping messages. */
  MessageQueueId_t getCommandQueue() const override;

  dur_millis_t getPeriodicOperationFrequency() const override;

  /**
   * Every class implementing this interface should have a local data pool manager. This
   * function will return a reference to the manager.
   * @return
   */
  LocalDataPoolManager* getHkManagerHandle() override;

  /**
   * This function is used by the pool manager to get a valid dataset
   * from a SID. This function is protected to prevent users from
   * using raw data set pointers which could not be thread-safe. Users
   * should use the #ProvidesDataPoolSubscriptionIF.
   * @param sid Corresponding structure ID
   * @return
   */
  LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override;
};