claraty::Device Class Reference
#include <device.h>
Inheritance diagram for claraty::Device:


Public Member Functions | |
| bool | on () |
| bool | off () |
| bool | is_on () |
| void | set_power_switch (Power_Switch &sw) |
| std::string | get_name () const |
| bool | io (FDM_Map map) |
| std::ostream & | display_xml (const char *p, std::ostream &os=std::cout) const |
Protected Attributes | |
| std::string | _name |
| Power_Switch * | _power_switch |
Detailed Description
Definition at line 44 of file device.h.
Constructor & Destructor Documentation
| claraty::Device::Device | ( | const std::string & | device_name = "", |
|
| Power_Switch * | power_switch = NULL | |||
| ) |
Create a device. Each thread will use their own device copies. These are logical devices.
- Parameters:
-
[in] device_name A device name. Name can be of the form "Camera/My_1394_Camera". If no name is specified a default name will be used. device will be on by default [in] power_switch The function for changing the swtich state.
Definition at line 47 of file device.cc.
00049 : _name ( (device_name.size() == 0) ? 00050 "def_device" : device_name), 00051 _power_switch(power_switch) 00052 { 00053 }
| claraty::Device::Device | ( | const std::string & | device_name = "", |
|
| Power_Switch * | power_switch = NULL | |||
| ) |
Create a device. Each thread will use their own device copies. These are logical devices.
- Parameters:
-
[in] device_name A device name. Name can be of the form "Camera/My_1394_Camera". If no name is specified a default name will be used. device will be on by default [in] power_switch The function for changing the swtich state.
Definition at line 47 of file device.cc.
00049 : _name ( (device_name.size() == 0) ? 00050 "def_device" : device_name), 00051 _power_switch(power_switch) 00052 { 00053 }
Member Function Documentation
| bool claraty::Device::on | ( | ) |
Turn on the device.
- Returns:
- Returns true on success, false on failure.
Definition at line 61 of file device.cc.
References _power_switch, and claraty::Power_Switch::set().
00062 { 00063 if (_power_switch == NULL) 00064 return true; 00065 else 00066 return _power_switch->set(true); 00067 }
Here is the call graph for this function:

| bool claraty::Device::off | ( | ) |
Turn off a device
- Returns:
- Returns true on success, false on failure.
Definition at line 75 of file device.cc.
References _power_switch, and claraty::Power_Switch::set().
00076 { 00077 if (_power_switch == NULL) 00078 return false; 00079 else 00080 return _power_switch->set(false); 00081 }
Here is the call graph for this function:

| bool claraty::Device::is_on | ( | ) |
Check if a device is turned on.
- Returns:
- Returns true if this device is on, false if this device is off.
Definition at line 89 of file device.cc.
References _power_switch, and claraty::Power_Switch::get().
00090 { 00091 if (_power_switch == NULL) 00092 return true; 00093 else 00094 return _power_switch->get(); 00095 }
Here is the call graph for this function:

| void claraty::Device::set_power_switch | ( | Power_Switch & | new_sw | ) |
Initialize the power switch functor. This should typically only be called at initialization time to bind a hardware switch, or other switching method, to this device.
- Parameters:
-
[in] new_sw power switch function object
Definition at line 106 of file device.cc.
References _power_switch.
00107 { 00108 _power_switch = &new_sw; 00109 }
| std::string claraty::Device::get_name | ( | ) | const |
Gets the name of the device
- Returns:
- Returns string containing name of this device.
Definition at line 117 of file device.cc.
References _name.
Referenced by display_xml().
00118 { 00119 return _name; 00120 };
| bool claraty::Device::io | ( | FDM_Map | map | ) |
Maps the data members of the device object for sending over a serial medium
- Parameters:
-
[out] map A serial object that contains the device data members
- Returns:
- true is serialization succeeds, false otherwise.
Reimplemented in claraty::Camera.
Definition at line 131 of file device.cc.
References _name, _power_switch, and claraty::FDM_Map::field().
Referenced by claraty::Camera::io().
00132 { 00133 bool ok = true; 00134 ok &= map.field ("name", _name); 00135 if (_power_switch) 00136 ok &= map.field ("power_switch", *_power_switch); 00137 return ok; 00138 }
Here is the call graph for this function:

| std::ostream & claraty::Device::display_xml | ( | const char * | pmsg, | |
| std::ostream & | os = std::cout | |||
| ) | const |
Output the contents of device in an XML format
- Parameters:
-
[in] pmsg a text message to display before the output [in] os output stream with cout as a default
- Returns:
- the formatted output stream
Definition at line 148 of file device.cc.
References claraty::XML_Out::get_indentation_space(), and get_name().
Referenced by claraty::operator<<().
00149 { 00150 // Set up the spacing for the indentation of the fields in the file 00151 std::string spacing = ""; 00152 spacing.append(XML_Out::get_indentation_space(), ' '); 00153 os << spacing << "<Device "; 00154 os << "name = \"" << get_name() << "\" "; 00155 os << " >"; 00156 return os; 00157 }
Here is the call graph for this function:

Member Data Documentation
std::string claraty::Device::_name [protected] |
Power_Switch* claraty::Device::_power_switch [protected] |
The documentation for this class was generated from the following files: