API
 
Loading...
Searching...
No Matches
staticNode.hpp
Go to the documentation of this file.
1/** \file staticNode.hpp
2 * \brief The MagAO-X Instrument Graph staticNode header file
3 *
4 * \ingroup instGraph_files
5 */
6
7#ifndef staticNode_hpp
8#define staticNode_hpp
9
10#include "xigNode.hpp"
11
12/// An instGraph node which is static, with status set at config time and not changing.
13class staticNode : public xigNode
14{
15
16 protected:
17 std::set<std::string> m_inputsOn; ///< inputs which are always on
18 std::set<std::string> m_inputsOff; ///< inputs which are always off
19
20 std::set<std::string> m_outputsOn; ///< outputs which are always on
21 std::set<std::string> m_outputsOff; ///< outputs which are always off
22
23 public:
24 /// Only c'tor. Must be constructed with node name and a parent graph.
25 staticNode( const std::string &name, /** [in] the name of this node*/
26 ingr::instGraphXML *parentGraph /** [in] the graph which this node belongs to*/
27 );
28
29 /// Get the always on inputs
30 /**
31 * \returns the value of m_inputsOn
32 */
33 const std::set<std::string> &inputsOn() const;
34
35 /// Get the always off inputs
36 /**
37 * \returns the value of m_inputsOff
38 */
39 const std::set<std::string> &inputsOff() const;
40
41 /// Get the always on outputs
42 /**
43 * \returns the value of m_outputsOn
44 */
45 const std::set<std::string> &outputsOn() const;
46
47 /// Get the always off outputs
48 /**
49 * \returns the value of m_outputsOff
50 */
51 const std::set<std::string> &outputsOff() const;
52
53 public:
54 /// INDI SetProperty callback
55 virtual int handleSetProperty( const pcf::IndiProperty &ipRecv /**< [in] the received INDI property to handle*/ );
56
57 /// Toggle all puts to their static state
58 virtual void togglePutsAll();
59
60 /// Toggle all puts on
61 virtual void togglePutsOn();
62
63 /// Toggle all puts off
64 virtual void togglePutsOff();
65
66 /// Configure this node form an appConfigurator.
67 void loadConfig( mx::app::appConfigurator &config /**< [in] the loaded configuration */ );
68};
69
70staticNode::staticNode( const std::string &name, ingr::instGraphXML *parentGraph ) : xigNode( name, parentGraph )
71{
72}
73
74const std::set<std::string> &staticNode::inputsOn() const
75{
76 return m_inputsOn;
77}
78
79const std::set<std::string> &staticNode::inputsOff() const
80{
81 return m_inputsOff;
82}
83
84const std::set<std::string> &staticNode::outputsOn() const
85{
86 return m_outputsOn;
87}
88
89const std::set<std::string> &staticNode::outputsOff() const
90{
91 return m_outputsOff;
92}
93
94inline int staticNode::handleSetProperty( const pcf::IndiProperty &ipRecv )
95{
96 static_cast<void>( ipRecv );
97
98 return 0;
99}
100
102{
103 try
104 {
105 for( auto &iput : m_inputsOn )
106 {
107 m_node->input( iput )->state( ingr::putState::on );
108 }
109 }
110 catch( const std::exception &e )
111 {
112 std::string msg = XIGN_EXCEPTION( "staticNode::togglePutsAll", "exception changing state on inputs" );
113 msg += "\n ";
114 msg += e.what();
115 throw std::runtime_error( msg );
116 }
117
118 try
119 {
120 for( auto &iput : m_inputsOff )
121 {
122 m_node->input( iput )->state( ingr::putState::off );
123 }
124 }
125 catch( const std::exception &e )
126 {
127 std::string msg = XIGN_EXCEPTION( "staticNode::togglePutsAll", "parent graph is null" );
128 msg += "\n ";
129 msg += e.what();
130 throw std::runtime_error( msg );
131 }
132
133 try
134 {
135 for( auto &iput : m_outputsOn )
136 {
137 m_node->output( iput )->state( ingr::putState::on );
138 }
139 }
140 catch( const std::exception &e )
141 {
142 std::string msg = XIGN_EXCEPTION( "staticNode::togglePutsAll", "parent graph is null" );
143 msg += "\n ";
144 msg += e.what();
145 throw std::runtime_error( msg );
146 }
147
148 try
149 {
150 for( auto &iput : m_outputsOff )
151 {
152 m_node->output( iput )->state( ingr::putState::off );
153 }
154 }
155 catch( const std::exception &e )
156 {
157 std::string msg = XIGN_EXCEPTION( "staticNode::togglePutsAll", "parent graph is null" );
158 msg += "\n ";
159 msg += e.what();
160 throw std::runtime_error( msg );
161 }
162}
163
165{
167}
168
170{
172}
173
174inline void staticNode::loadConfig( mx::app::appConfigurator &config )
175{
176 if( !m_parentGraph )
177 {
178 std::string msg = XIGN_EXCEPTION( "staticNode::loadConfig", "parent graph is null" );
179 throw std::runtime_error( msg );
180 }
181
182 std::string type;
183 config.configUnused( type, mx::app::iniFile::makeKey( name(), "type" ) );
184
185 if( type != "static" )
186 {
187 std::string msg = XIGN_EXCEPTION( "staticNode::loadConfig", "node type is not static" );
188 throw std::runtime_error( msg );
189 }
190
191 std::vector<std::string> inputsOn;
192 config.configUnused( inputsOn, mx::app::iniFile::makeKey( name(), "inputsOn" ) );
193
194 try
195 {
196 m_inputsOn.clear();
197 for( auto &in : inputsOn )
198 {
199 m_inputsOn.insert( in );
200 }
201 }
202 catch(const std::exception & e)
203 {
204 std::string msg = XIGN_EXCEPTION( "staticNode::loadConfig", "exception caught loading inputsOn" );
205 msg += "\n ";
206 msg += e.what();
207 }
208
209 std::vector<std::string> inputsOff;
210 config.configUnused( inputsOff, mx::app::iniFile::makeKey( name(), "inputsOff" ) );
211
212 try
213 {
214 m_inputsOff.clear();
215 for( auto &in : inputsOff )
216 {
217 m_inputsOff.insert( in );
218 }
219 }
220 catch(const std::exception & e)
221 {
222 std::string msg = XIGN_EXCEPTION( "staticNode::loadConfig", "exception caught loading inputsOff" );
223 msg += "\n ";
224 msg += e.what();
225 }
226
227 std::vector<std::string> outputsOn;
228 config.configUnused( outputsOn, mx::app::iniFile::makeKey( name(), "outputsOn" ) );
229 try
230 {
231 m_outputsOn.clear();
232 for( auto &out : outputsOn )
233 {
234 m_outputsOn.insert( out );
235 }
236 }
237 catch(const std::exception & e)
238 {
239 std::string msg = XIGN_EXCEPTION( "staticNode::loadConfig", "exception caught loading outputsOn" );
240 msg += "\n ";
241 msg += e.what();
242 }
243
244 std::vector<std::string> outputsOff;
245 config.configUnused( outputsOff, mx::app::iniFile::makeKey( name(), "outputsOff" ) );
246 try
247 {
248 m_outputsOff.clear();
249 for( auto &out : outputsOff )
250 {
251 m_outputsOff.insert( out );
252 }
253 }
254 catch(const std::exception & e)
255 {
256 std::string msg = XIGN_EXCEPTION( "staticNode::loadConfig", "exception caught loading outputsOff" );
257 msg += "\n ";
258 msg += e.what();
259 }
260
262}
263
264#endif // staticNode_hpp
An instGraph node which is static, with status set at config time and not changing.
virtual int handleSetProperty(const pcf::IndiProperty &ipRecv)
INDI SetProperty callback.
std::set< std::string > m_outputsOn
outputs which are always on
std::set< std::string > m_inputsOff
inputs which are always off
const std::set< std::string > & inputsOff() const
Get the always off inputs.
std::set< std::string > m_inputsOn
inputs which are always on
std::set< std::string > m_outputsOff
outputs which are always off
virtual void togglePutsOff()
Toggle all puts off.
virtual void togglePutsAll()
Toggle all puts to their static state.
const std::set< std::string > & inputsOn() const
Get the always on inputs.
const std::set< std::string > & outputsOn() const
Get the always on outputs.
virtual void togglePutsOn()
Toggle all puts on.
staticNode(const std::string &name, ingr::instGraphXML *parentGraph)
Only c'tor. Must be constructed with node name and a parent graph.
const std::set< std::string > & outputsOff() const
Get the always off outputs.
void loadConfig(mx::app::appConfigurator &config)
Configure this node form an appConfigurator.
Implementation of basic instGraph node interface for MagAO-X.
Definition xigNode.hpp:31
ingr::instNode * m_node
The underlying instGraph node.
Definition xigNode.hpp:37
ingr::instGraphXML * m_parentGraph
The parent instGraph that this node is a part of.
Definition xigNode.hpp:35
std::string name()
Get the name of this node.
Definition xigNode.hpp:106
The base MagAO-X instGraph node header file.
#define XIGN_EXCEPTION(src, expl)
Definition xigNode.hpp:24