Cypress  1.0
C++ Spiking Neural Network Simulation Framework
netio4.hpp
Go to the documentation of this file.
1 /*
2  * Cypress -- C++ Spiking Neural Network Simulation Framework
3  * Copyright (C) 2016 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_NETIO4_HPP
28 #define CPPNAM_BACKEND_POWER_NETIO4_HPP
29 
31 #include <cypress/util/json.hpp>
32 
33 #include <map>
34 #include <string>
35 
36 namespace cypress {
43 class NetIO4: public PowerDevice {
44 private:
45  std::string m_addr;
46  int m_port;
47  std::string m_user;
48  std::string m_passwd;
49  std::map<std::string, int> m_device_port_map;
50 
51  bool m_has_config = false;
52 
53  void read_json_config(cypress::Json &config);
54  std::string control(const std::string &cmd = std::string()) const;
55 
56 public:
72  NetIO4(cypress::Json &config);
73 
74  ~NetIO4() override {};
75 
84  explicit NetIO4(const std::string &config_filename = ".netio4_config.json");
85 
90  bool has_config() override { return m_has_config; }
91 
95  bool connected();
96 
102  int device_port(const std::string &device);
103 
109  bool state(int port);
110 
111  void switch_on(int port);
112  void switch_off(int port);
113 
114  bool state(const std::string &device) override;
115  bool switch_on(const std::string &device) override;
116  bool switch_off(const std::string &device) override;
117 };
118 }
119 
120 #endif /* CPPNAM_BACKEND_POWER_NETIO4_HPP */
121 
~NetIO4() override
Definition: netio4.hpp:74
nlohmann::json Json
Definition: json.hpp:27
void switch_on(int port)
int device_port(const std::string &device)
Definition: netio4.hpp:43
NetIO4(cypress::Json &config)
bool state(int port)
Definition: brainscales_lib.hpp:39
bool has_config() override
Definition: netio4.hpp:90
Definition: power.hpp:45
void switch_off(int port)