SVHControllerFeedback.h
Go to the documentation of this file.
00001 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
00002 
00003 // -- BEGIN LICENSE BLOCK ----------------------------------------------
00004 // This file is part of the SCHUNK SVH Driver suite.
00005 //
00006 // This program is free software licensed under the LGPL
00007 // (GNU LESSER GENERAL PUBLIC LICENSE Version 3).
00008 // You can find a copy of this license in LICENSE folder in the top
00009 // directory of the source code.
00010 //
00011 // © Copyright 2014 SCHUNK Mobile Greifsysteme GmbH, Lauffen/Neckar Germany
00012 // © Copyright 2014 FZI Forschungszentrum Informatik, Karlsruhe, Germany
00013 //
00014 // -- END LICENSE BLOCK ------------------------------------------------
00015 
00016 //----------------------------------------------------------------------
00027 //----------------------------------------------------------------------
00028 #ifndef SVHCONTROLLERFEEDBACK_H
00029 #define SVHCONTROLLERFEEDBACK_H
00030 
00031 #include <icl_comm/ByteOrderConversion.h>
00032 
00033 namespace driver_svh {
00034 
00038 struct SVHControllerFeedback
00039 {
00041   int32_t position;
00043   int16_t current;
00044 
00050   SVHControllerFeedback(const int32_t& _position = 0,const int16_t& _current = 0):
00051     position(_position),
00052     current(_current)
00053   {}
00054 
00056   bool operator == (const SVHControllerFeedback& other) const
00057   {
00058     return (position == other.position && current == other.current);
00059   }
00060 };
00061 
00065 struct SVHControllerFeedbackAllChannels
00066 {
00068   std::vector<SVHControllerFeedback> feedbacks;
00069 
00082   SVHControllerFeedbackAllChannels(const SVHControllerFeedback& _feedback0,const SVHControllerFeedback& _feedback1,
00083                                     const SVHControllerFeedback& _feedback2,const SVHControllerFeedback& _feedback3,
00084                                     const SVHControllerFeedback& _feedback4,const SVHControllerFeedback& _feedback5,
00085                                     const SVHControllerFeedback& _feedback6,const SVHControllerFeedback& _feedback7,
00086                                     const SVHControllerFeedback& _feedback8)
00087   {
00088     feedbacks.push_back(_feedback0);
00089     feedbacks.push_back(_feedback1);
00090     feedbacks.push_back(_feedback2);
00091     feedbacks.push_back(_feedback3);
00092     feedbacks.push_back(_feedback4);
00093     feedbacks.push_back(_feedback5);
00094     feedbacks.push_back(_feedback6);
00095     feedbacks.push_back(_feedback7);
00096     feedbacks.push_back(_feedback8);
00097   }
00098 
00104   SVHControllerFeedbackAllChannels(std::vector<SVHControllerFeedback> _feedbacks)
00105   {
00106     feedbacks.insert(feedbacks.begin(),_feedbacks.begin(),_feedbacks.end());
00107   }
00108 
00112   SVHControllerFeedbackAllChannels():
00113     feedbacks(9)
00114   { }
00115 
00116 
00118   bool operator == (const SVHControllerFeedbackAllChannels& other) const
00119   {
00120     return (feedbacks == other.feedbacks);
00121   }
00122 };
00123 
00125 inline icl_comm::ArrayBuilder& operator << (icl_comm::ArrayBuilder& ab,const SVHControllerFeedback& data)
00126 {
00127   ab << data.position
00128      << data.current;
00129   return ab;
00130 }
00131 
00132 
00134 inline icl_comm::ArrayBuilder& operator >> (icl_comm::ArrayBuilder& ab, SVHControllerFeedback& data)
00135 {
00136   ab >> data.position
00137      >> data.current;
00138   return ab;
00139 }
00140 
00142 inline std::ostream& operator << (std::ostream& o, const SVHControllerFeedback& cf)
00143 {
00144   o << "Pos: " << cf.position << " Cur: " << cf.current << std::endl;
00145   return o;
00146 }
00147 
00148 
00150 inline icl_comm::ArrayBuilder& operator << (icl_comm::ArrayBuilder& ab,SVHControllerFeedbackAllChannels& data)
00151 {
00152   // The Data is transmitted not channel by channel but rather position first, Currents afterwards for all channels
00153   for (std::vector<SVHControllerFeedback>::iterator it = data.feedbacks.begin() ; it != data.feedbacks.end(); ++it)
00154   {
00155     ab << it->position;
00156   }
00157 
00158   for (std::vector<SVHControllerFeedback>::iterator it = data.feedbacks.begin() ; it != data.feedbacks.end(); ++it)
00159   {
00160     ab << it->current;
00161   }
00162   return ab;
00163 }
00164 
00165 
00167 inline icl_comm::ArrayBuilder& operator >> (icl_comm::ArrayBuilder& ab, SVHControllerFeedbackAllChannels& data)
00168 {
00169   // The Data is transmitted not channel by channel but rather position first, Currents afterwards for all channels
00170   for (std::vector<SVHControllerFeedback>::iterator it = data.feedbacks.begin() ; it != data.feedbacks.end(); ++it)
00171   {
00172     ab >> it->position;
00173   }
00174 
00175   for (std::vector<SVHControllerFeedback>::iterator it = data.feedbacks.begin() ; it != data.feedbacks.end(); ++it)
00176   {
00177     ab >> it->current;
00178   }
00179   return ab;
00180 }
00181 
00183 inline std::ostream& operator << (std::ostream& o, const SVHControllerFeedbackAllChannels& cf)
00184 {
00185   o << "Feedbacks: " ;
00186   unsigned int i = 0;
00187   for (std::vector<SVHControllerFeedback>::const_iterator it = cf.feedbacks.begin() ; it != cf.feedbacks.end(); ++it,++i)
00188   {
00189     o << "Chan " << i << " : "<< *it;
00190   }
00191   o << std::endl;
00192   return o;
00193 }
00194 
00195 }
00196 
00197 #endif // SVHCONTROLLERFEEDBACK_H


schunk_svh_driver
Author(s): Georg Heppner
autogenerated on Fri Aug 28 2015 12:59:19