/********************************************************************\ Name: mdev_mscb.h Created by: Stefan Ritt Contents: MIDAS device drivers class for MSCB devices \********************************************************************/ #ifndef MDEV_MSCB_H #define MDEV_MSCB_H #include "mscbxx.h" #include "mdev.h" struct mscb_var { std::string var; std::string name; int index; bool output; std::function confirm; mscb_var(std::string &v, std::string &n, int i, bool o) : var(v), name(n), index(i), output(o), confirm(nullptr) {}; mscb_var(std::string &n, int i, bool o) : var(""), name(n), index(i), output(o), confirm(nullptr) {}; mscb_var(std::string &v, std::string &n, int i, bool o, std::function f) : var(v), name(n), index(i), output(o), confirm(f) {}; mscb_var(std::string &n, int i, bool o, std::function f) : var(""), name(n), index(i), output(o), confirm(f) {}; }; class mscb_node { public: std::string m_device; std::string m_pwd; int m_address; bool m_enabled; midas::mscb* m_mscb; std::vector m_mscb_var; public: mscb_node(std::string d, int a, std::string pwd = "", bool e=true) : m_device(d), m_pwd(pwd), m_address(a), m_enabled(e) {}; void add_input(std::string var, std::string name) { m_mscb_var.emplace_back(var, name, 0, false); } void add_input(int index, std::string name) { m_mscb_var.emplace_back(name, index, false); } void add_output(std::string var, std::string name) { m_mscb_var.emplace_back(var, name, 0, true); } void add_output(int index, std::string name) { m_mscb_var.emplace_back(name, index, true); } void add_output(std::string var, std::string name, std::function f) { m_mscb_var.emplace_back(var, name, 0, true, f); } void add_output(int index, std::string name, std::function f) { m_mscb_var.emplace_back(name, index, true, f); } }; class mdev_mscb : public mdev { private: midas::odb m_settings; midas::odb m_variables; int m_n_variables_input; int m_n_variables_output; std::vector m_output_mirror; std::vector m_node; public: mdev_mscb(int event_id, std::string equipment_name); ~mdev_mscb(void) override; void add_node(mscb_node n) { m_node.push_back(n); } void get_all(int i); void odb_setup(void) override; void init(void) override; void exit(void) override; void loop(void) override; int read_event(char *pevent, int off) override; }; #endif // MDEV_MPDC_H