#ifndef SENSOR_HEADERFILE
#define SENSOR_HEADERFILE

#include "Channel.h"
#include "Node.h"

#define MAX_NUM_OF_SCORES 10

#define LOWER_BOUNDARY 0
#define UPPER_BOUNDARY 1

#define LEARNED_BOUNDARY_DOES_EXIST true
#define LEARNED_BOUNDARY_DOESNT_EXIST false

#define USE_LEARNED_DATA true
#define DONT_USE_LEARNED_DATA false

#define VALID true
#define INVALID false

class Sensor : public Node {

private:
  // ----- Runtime -----
  float sensor_value;
  bool flag_sensor_value_is_valid;
  bool flag_sensor_value_has_changed;

  // ----- Setup Master -----
  bool flag_masteragent_is_mounted;
  Channel *mounted_masteragent_outputport;
  bool flag_masteragent_outputport_is_active; // unnötig?

  // ----- Setup Behavior -----
  bool flag_send_value_only_when_changed;

  // noch nicht überarbeitet
  bool active_state_flag;

  float hardcoded_thresholds[MAX_NUM_OF_SCORES][2];
  float learned_thresholds[MAX_NUM_OF_SCORES][2];
  bool flag_learned_boundary_exist[MAX_NUM_OF_SCORES][2];

  bool flag_use_learned_data;

  void initialize_sensor();

public:
  Sensor();
  Sensor(const char *name);

  // ----- Runtime Functions -----
  void set_sensorValue(float sensor_value);
  float get_sensorValue();
  void trigger();

  // ----- Setup -----
  bool mount_agent(Channel *outputport);

  void
  set_flag_send_value_only_when_changed(bool flag_send_value_only_when_changed);
  bool get_flag_send_value_only_when_changed();

  /*
  void set_sensor_id(unsigned int id);
  unsigned int get_sensor_id();
  */

  // ----- set/get -----
  void set_flag_sensor_value_is_valid(bool flag_sensor_value_is_valid);
  bool get_flag_sensor_value_is_valid();
  void set_flag_sensor_value_has_changed(bool flag_sensor_value_has_changed);
  bool get_flag_sensor_value_has_changed();

  void set_active_state_flag(bool flag);
  bool get_active_state_flag();

  float get_hardcoded_threshold(unsigned int score, unsigned int boundary);
  void set_hardcoded_threshold(unsigned int score, unsigned int boundary,
                               float value);

  float get_learned_threshold(unsigned int score, unsigned int boundary);
  void set_learned_threshold(unsigned int score, unsigned int boundary,
                             float value);

  void set_flag_learned_boundary_exist(unsigned int score,
                                       unsigned int boundary, bool flag);
  bool get_flag_learned_boundary_exist(unsigned int score,
                                       unsigned int boundary);

  void set_flag_use_learned_data(bool flag);
  bool get_flag_use_learned_data();
};

#endif
