Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00026
00027 #ifndef SVHCONTROLCOMMAND_H
00028 #define SVHCONTROLCOMMAND_H
00029
00030 #include <icl_comm/ByteOrderConversion.h>
00031
00032 namespace driver_svh {
00033
00038 struct SVHControlCommand
00039 {
00041 int32_t position;
00042
00047 SVHControlCommand(const int32_t& _position = 0):
00048 position(_position)
00049 {}
00050
00052 bool operator == (const SVHControlCommand& other) const
00053 {
00054 return (position == other.position);
00055 }
00056
00057 };
00058
00063 struct SVHControlCommandAllChannels
00064 {
00066 std::vector<SVHControlCommand> commands;
00067
00080 SVHControlCommandAllChannels(const int32_t& _position0,const int32_t& _position1,const int32_t& _position2,
00081 const int32_t& _position3,const int32_t& _position4,const int32_t& _position5,
00082 const int32_t& _position6,const int32_t& _position7,const int32_t& _position8)
00083 {
00084 commands.push_back(SVHControlCommand(_position0));
00085 commands.push_back(SVHControlCommand(_position1));
00086 commands.push_back(SVHControlCommand(_position2));
00087 commands.push_back(SVHControlCommand(_position3));
00088 commands.push_back(SVHControlCommand(_position4));
00089 commands.push_back(SVHControlCommand(_position5));
00090 commands.push_back(SVHControlCommand(_position6));
00091 commands.push_back(SVHControlCommand(_position7));
00092 commands.push_back(SVHControlCommand(_position8));
00093 }
00094
00099 SVHControlCommandAllChannels(const std::vector<int32_t>& positions)
00100 {
00101 commands.insert(commands.begin(),positions.begin(),positions.begin()+9);
00102 }
00103
00108 SVHControlCommandAllChannels():
00109 commands(9,SVHControlCommand())
00110 { }
00111
00113 bool operator == (const SVHControlCommandAllChannels& other) const
00114 {
00115 return (commands == other.commands);
00116 }
00117 };
00118
00119
00122 inline icl_comm::ArrayBuilder& operator << (icl_comm::ArrayBuilder& ab, const SVHControlCommand& data)
00123 {
00124 ab << data.position;
00125 return ab;
00126 }
00127
00128
00130 inline icl_comm::ArrayBuilder& operator >> (icl_comm::ArrayBuilder& ab, SVHControlCommand& data)
00131 {
00132 ab >> data.position;
00133 return ab;
00134 }
00135
00137 inline std::ostream& operator << (std::ostream& o, const SVHControlCommand& cc)
00138 {
00139 o << "Pos: " << cc.position << std::endl;
00140 return o;
00141 }
00142
00144 inline icl_comm::ArrayBuilder& operator << (icl_comm::ArrayBuilder& ab, const SVHControlCommandAllChannels& data)
00145 {
00146
00147 for (std::vector<SVHControlCommand>::const_iterator it = data.commands.begin() ; it != data.commands.end(); ++it)
00148 {
00149 ab << *it;
00150 }
00151 return ab;
00152 }
00153
00154
00156 inline icl_comm::ArrayBuilder& operator >> (icl_comm::ArrayBuilder& ab, SVHControlCommandAllChannels& data)
00157 {
00158 for (std::vector<SVHControlCommand>::iterator it = data.commands.begin() ; it != data.commands.end(); ++it)
00159 {
00160 ab >> *it;
00161 }
00162 return ab;
00163 }
00164
00165
00167 inline std::ostream& operator << (std::ostream& o, const SVHControlCommandAllChannels& cc)
00168 {
00169 o << "Commands: " ;
00170 unsigned int i = 0;
00171 for (std::vector<SVHControlCommand>::const_iterator it = cc.commands.begin() ; it != cc.commands.end(); ++it)
00172 {
00173 o << "Chan " << i << " : "<< *it;
00174 ++i;
00175 }
00176 o << std::endl;
00177 return o;
00178 }
00179 }
00180
00181 #endif // SVHCONTROLCOMMAND_H