YouBotSlaveMsg.hpp
Go to the documentation of this file.
00001 /****************************************************************
00002  *
00003  * Copyright (c) 2011
00004  * All rights reserved.
00005  *
00006  * Hochschule Bonn-Rhein-Sieg
00007  * University of Applied Sciences
00008  * Computer Science Department
00009  *
00010  * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00011  *
00012  * Author:
00013  * Jan Paulus, Nico Hochgeschwender, Michael Reckhaus, Azamat Shakhimardanov
00014  * Supervised by:
00015  * Gerhard K. Kraetzschmar
00016  *
00017  * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00018  *
00019  * This sofware is published under a dual-license: GNU Lesser General Public
00020  * License LGPL 2.1 and BSD license. The dual-license implies that users of this
00021  * code may choose which terms they prefer.
00022  *
00023  * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00024  *
00025  * Redistribution and use in source and binary forms, with or without
00026  * modification, are permitted provided that the following conditions are met:
00027  *
00028  *     * Redistributions of source code must retain the above copyright
00029  *       notice, this list of conditions and the following disclaimer.
00030  *     * Redistributions in binary form must reproduce the above copyright
00031  *       notice, this list of conditions and the following disclaimer in the
00032  *       documentation and/or other materials provided with the distribution.
00033  *     * Neither the name of the Hochschule Bonn-Rhein-Sieg nor the names of its
00034  *       contributors may be used to endorse or promote products derived from
00035  *       this software without specific prior written permission.
00036  *
00037  * This program is free software: you can redistribute it and/or modify
00038  * it under the terms of the GNU Lesser General Public License LGPL as
00039  * published by the Free Software Foundation, either version 2.1 of the
00040  * License, or (at your option) any later version or the BSD license.
00041  *
00042  * This program is distributed in the hope that it will be useful,
00043  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00044  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00045  * GNU Lesser General Public License LGPL and the BSD license for more details.
00046  *
00047  * You should have received a copy of the GNU Lesser General Public
00048  * License LGPL and BSD license along with this program.
00049  *
00050  ****************************************************************/
00051 
00052 #ifndef _YOUBOT_SLAVE_MESSAGE_H
00053 #define _YOUBOT_SLAVE_MESSAGE_H
00054 
00055 #include <youbot_driver/generic/dataobjectlockfree/DataObjectLockFree.hpp>
00056 #include <youbot_driver/soem/ethercattype.h>
00057 #include <string>
00058 #include <time.h>
00059 
00060 namespace youbot
00061 {
00062 
00064 
00065 struct SlaveMessageOutput
00066 {
00067   int32 value;
00068   uint8 controllerMode;
00069   SlaveMessageOutput() :
00070       value(0), controllerMode(0)
00071   {
00072   }
00073   ;
00074 }__attribute__((__packed__));
00075 
00077 
00078 struct SlaveMessageInput
00079 {
00080   int32 actualPosition;   // encoder ticks
00081   int32 actualCurrent;    // mA
00082   int32 actualVelocity;   // rpm motor axis
00083   uint32 errorFlags;
00084   int32 targetPosition;
00085   int32 targetCurrent;
00086   int32 targetVelocity;
00087   int32 rampGeneratorVelocity;
00088 
00089   SlaveMessageInput() :
00090       actualPosition(0), actualCurrent(0), actualVelocity(0), errorFlags(0), targetPosition(0), targetCurrent(0), targetVelocity(
00091           0), rampGeneratorVelocity(0)
00092   {
00093   }
00094   ;
00095 }__attribute__((__packed__));
00096 
00100 class YouBotSlaveMsg
00101 {
00102 public:
00103 
00104   SlaveMessageOutput stctOutput;
00105   SlaveMessageInput stctInput;
00106   unsigned int jointNumber;
00107 
00108   // Constructor
00109 
00110   YouBotSlaveMsg()
00111   {
00112     jointNumber = 0;
00113   }
00114 
00115   // Copy-Constructor
00116 
00117   YouBotSlaveMsg(const YouBotSlaveMsg &copy)
00118   {
00119     stctOutput = copy.stctOutput;
00120     stctInput = copy.stctInput;
00121     jointNumber = copy.jointNumber;
00122   }
00123 
00124   // Destructor
00125 
00126   ~YouBotSlaveMsg()
00127   {
00128   }
00129 
00130   // assignment operator
00131 
00132   YouBotSlaveMsg & operator=(const YouBotSlaveMsg &copy)
00133   {
00134     stctOutput = copy.stctOutput;
00135     stctInput = copy.stctInput;
00136     jointNumber = copy.jointNumber;
00137     return *this;
00138   }
00139 };
00140 
00144 class YouBotSlaveMsgThreadSafe
00145 {
00146 public:
00147 
00148   DataObjectLockFree<SlaveMessageOutput> stctOutput;
00149   DataObjectLockFree<SlaveMessageInput> stctInput;
00150   DataObjectLockFree<unsigned int> jointNumber;
00151 
00152   // Constructor
00153   YouBotSlaveMsgThreadSafe()
00154   {
00155     jointNumber.Set(0);
00156   }
00157 
00158   // Copy-Constructor
00159   YouBotSlaveMsgThreadSafe(const YouBotSlaveMsgThreadSafe &copy)
00160   {
00161     SlaveMessageOutput tempOutput;
00162     SlaveMessageInput tempInput;
00163     unsigned int tempjointNo;
00164 
00165     copy.stctOutput.Get(tempOutput);
00166     stctOutput.Set(tempOutput);
00167 
00168     copy.stctInput.Get(tempInput);
00169     stctInput.Set(tempInput);
00170 
00171     copy.jointNumber.Get(tempjointNo);
00172     jointNumber.Set(tempjointNo);
00173   }
00174 
00175   // Destructor
00176   ~YouBotSlaveMsgThreadSafe()
00177   {
00178   }
00179 
00180   // assignment operator
00181   YouBotSlaveMsgThreadSafe & operator=(const YouBotSlaveMsgThreadSafe &copy)
00182   {
00183     SlaveMessageOutput tempOutput;
00184     SlaveMessageInput tempInput;
00185     unsigned int tempjointNo;
00186 
00187     copy.stctOutput.Get(tempOutput);
00188     stctOutput.Set(tempOutput);
00189 
00190     copy.stctInput.Get(tempInput);
00191     stctInput.Set(tempInput);
00192 
00193     copy.jointNumber.Get(tempjointNo);
00194     jointNumber.Set(tempjointNo);
00195 
00196     return *this;
00197   }
00198 
00199 };
00200 
00201 } // namespace youbot
00202 
00203 #endif  /* _YOUBOT_SLAVE_MESSAGE_H */


youbot_driver
Author(s): Jan Paulus
autogenerated on Mon Oct 6 2014 09:08:02