Cypress  1.0
C++ Spiking Neural Network Simulation Framework
energenie.hpp
Go to the documentation of this file.
1 /*
2  * Cypress -- C++ Spiking Neural Network Simulation Framework
3  * Copyright (C) 2018 Christoph Ostrau, Andreas Stöckel
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
27 #ifndef CPPNAM_BACKEND_POWER_ENERGENIE_HPP
28 #define CPPNAM_BACKEND_POWER_ENERGENIE_HPP
29 
31 #include <cypress/util/json.hpp>
32 
33 #include <map>
34 #include <string>
35 
36 namespace cypress {
43 class energenie : public PowerDevice {
44 private:
45  std::string m_addr;
46  std::string m_passwd;
47  std::map<std::string, int> m_device_port_map;
48 
49  bool m_has_config = false;
50 
51  void read_json_config(cypress::Json &config);
52  std::string control(const std::string &cmd = std::string()) const;
53 
54 public:
68  energenie(cypress::Json &config);
69 
70  ~energenie() override = default;
71 
80  explicit energenie(const std::string &config_filename = ".energenie.json");
81 
86  bool has_config() override { return m_has_config; }
87 
91  bool connected();
92 
98  int device_port(const std::string &device);
99 
105  bool state(int port);
106 
107  void switch_on(int port);
108  void switch_off(int port);
109 
110  bool state(const std::string &device) override;
111  bool switch_on(const std::string &device) override;
112  bool switch_off(const std::string &device) override;
113 };
114 } // namespace cypress
115 
116 #endif /* CPPNAM_BACKEND_POWER_ENERGENIE_HPP */
~energenie() override=default
bool state(int port)
nlohmann::json Json
Definition: json.hpp:27
int device_port(const std::string &device)
void switch_off(int port)
energenie(cypress::Json &config)
void switch_on(int port)
Definition: brainscales_lib.hpp:39
Definition: power.hpp:45
Definition: energenie.hpp:43
bool has_config() override
Definition: energenie.hpp:86