Cypress  1.0
C++ Spiking Neural Network Simulation Framework
Public Member Functions | List of all members
cypress::energenie Class Reference

#include <energenie.hpp>

Inheritance diagram for cypress::energenie:
Inheritance graph
[legend]
Collaboration diagram for cypress::energenie:
Collaboration graph
[legend]

Public Member Functions

 energenie (cypress::Json &config)
 
 ~energenie () override=default
 
 energenie (const std::string &config_filename=".energenie.json")
 
bool has_config () override
 
bool connected ()
 
int device_port (const std::string &device)
 
bool state (int port)
 
void switch_on (int port)
 
void switch_off (int port)
 
bool state (const std::string &device) override
 
bool switch_on (const std::string &device) override
 
bool switch_off (const std::string &device) override
 

Detailed Description

Class used to communicate with a energenie intelligent power outlet. This is used to switch neuromorphic hardware devices on and off, as bugs in the hardware sometimes cause them to become responseless, causing experiments to crash with an exception.

Constructor & Destructor Documentation

cypress::energenie::energenie ( cypress::Json config)

Reads the energenie configuration from the given json configuration. The configuration must have the following format:

{ "address": "192.168.240.254", "password": "1", "device_map": { "spikey": 3, "nmmc1": 2 } }

cypress::energenie::~energenie ( )
overridedefault
cypress::energenie::energenie ( const std::string &  config_filename = ".energenie.json")
explicit

Reads the energenie configuration from the given JSON file. See the other constructor for the expected format. If the file is not found, the energenie class will simply do nothing.

Parameters
config_filenameis the name of the file from which the configuration should be read.

Member Function Documentation

bool cypress::energenie::connected ( )

Returns true if the class can successfully communicate with the device.

int cypress::energenie::device_port ( const std::string &  device)

Returns the port the given device is connected to. The device name must be the cannonical backend name as returned by "backend.name()". Returns -1 if no port is mapped to the given device.

bool cypress::energenie::has_config ( )
inlineoverridevirtual

Returns true if the configuration was successfully read in the constructor.

Implements cypress::PowerDevice.

bool cypress::energenie::state ( int  port)

Returns true if the port with the given port id is currently switched on, false if the device is switched off. Throws an exception if the communication with the device fails or the given port does not exist.

bool cypress::energenie::state ( const std::string &  device)
overridevirtual

Returns the state of the device with the given name. If the device cannot be controlled, false should be returned.

Parameters
deviceis the canonical backend name (returned by backend.name()) of the device for which the state should be returned.
Returns
true if the device is currently switched on, false in all other cases.

Implements cypress::PowerDevice.

void cypress::energenie::switch_off ( int  port)
bool cypress::energenie::switch_off ( const std::string &  device)
overridevirtual

Switches the device with teh given name off.

Parameters
deviceis the canonical backend name (returned by backend.name()) of the device that should be controlled.
Returns
true if the operation was successful, false otherwise.

Implements cypress::PowerDevice.

void cypress::energenie::switch_on ( int  port)
bool cypress::energenie::switch_on ( const std::string &  device)
overridevirtual

Switches the device with teh given name on.

Parameters
deviceis the canonical backend name (returned by backend.name()) of the device that should be controlled.
Returns
true if the operation was successful, false otherwise.

Implements cypress::PowerDevice.


The documentation for this class was generated from the following file: