YouBotSlaveMailboxMsg.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_MAILBOX_MESSAGE_H
00053 #define _YOUBOT_SLAVE_MAILBOX_MESSAGE_H
00054 
00055 #include <youbot_driver/soem/ethercattype.h>
00056 #include <string>
00057 #include <time.h>
00058 #include <youbot_driver/generic/dataobjectlockfree/DataObjectLockFree.hpp>
00059 
00060 namespace youbot
00061 {
00062 
00064 
00065 struct mailboxOutputBuffer
00066 {
00067   uint8 moduleAddress; //0 = Drive  1 = Gripper
00068   uint8 commandNumber;
00069   uint8 typeNumber;
00070   uint8 motorNumber; //always zero
00071   uint32 value; //MSB first!
00072 
00073   mailboxOutputBuffer() :
00074       moduleAddress(0), commandNumber(0), typeNumber(0), motorNumber(0), value(0)
00075   {
00076   }
00077   ;
00078 }__attribute__((__packed__));
00079 
00081 
00082 struct mailboxInputBuffer
00083 {
00084   uint8 replyAddress;
00085   uint8 moduleAddress;
00086   uint8 status; //(e.g. 100 means “no error”)
00087   uint8 commandNumber;
00088   uint32 value; //MSB first!
00089 
00090   mailboxInputBuffer() :
00091       replyAddress(0), moduleAddress(0), status(0), commandNumber(0), value(0)
00092   {
00093   }
00094   ;
00095 }__attribute__((__packed__));
00096 
00100 
00101 class YouBotSlaveMailboxMsg
00102 {
00103 public:
00104 
00105   mailboxOutputBuffer stctOutput;
00106   mailboxInputBuffer stctInput;
00107 
00108   // Constructor
00109   YouBotSlaveMailboxMsg()
00110   {
00111     slaveNumber = 1000;
00112   }
00113 
00114   // Constructor
00115 
00116   YouBotSlaveMailboxMsg(unsigned int slaveNo)
00117   {
00118     slaveNumber = slaveNo;
00119   }
00120   // Copy-Constructor
00121 
00122   YouBotSlaveMailboxMsg(const YouBotSlaveMailboxMsg& copy)
00123   {
00124     stctOutput = copy.stctOutput;
00125     stctInput = copy.stctInput;
00126     slaveNumber = copy.slaveNumber;
00127     parameterName = copy.parameterName;
00128   }
00129 
00130   // Destructor
00131 
00132   ~YouBotSlaveMailboxMsg()
00133   {
00134   }
00135 
00136   // assignment operator
00137 
00138   YouBotSlaveMailboxMsg & operator=(const YouBotSlaveMailboxMsg& copy)
00139   {
00140     stctOutput = copy.stctOutput;
00141     stctInput = copy.stctInput;
00142     slaveNumber = copy.slaveNumber;
00143     parameterName = copy.parameterName;
00144     return *this;
00145   }
00146 
00147   std::string parameterName;
00148   unsigned int slaveNumber;
00149 };
00150 
00154 class YouBotSlaveMailboxMsgThreadSafe
00155 {
00156 public:
00157 
00158   DataObjectLockFree<mailboxOutputBuffer> stctOutput;
00159   DataObjectLockFree<mailboxInputBuffer> stctInput;
00160 
00161   // Constructor
00162   YouBotSlaveMailboxMsgThreadSafe()
00163   {
00164     slaveNumber.Set(1000);
00165   }
00166 
00167   // Constructor
00168 
00169   YouBotSlaveMailboxMsgThreadSafe(unsigned int slaveNo)
00170   {
00171     slaveNumber.Set(slaveNo);
00172   }
00173   // Copy-Constructor
00174 
00175   YouBotSlaveMailboxMsgThreadSafe(const YouBotSlaveMailboxMsgThreadSafe& copy)
00176   {
00177     mailboxOutputBuffer tempStctOutput;
00178     mailboxInputBuffer tempStctInput;
00179     std::string tempParameterName;
00180     unsigned int SlaveNumber;
00181 
00182     copy.stctOutput.Get(tempStctOutput);
00183     stctOutput.Set(tempStctOutput);
00184 
00185     copy.stctInput.Get(tempStctInput);
00186     stctInput.Set(tempStctInput);
00187 
00188     copy.slaveNumber.Get(SlaveNumber);
00189     slaveNumber.Set(SlaveNumber);
00190 
00191     copy.parameterName.Get(tempParameterName);
00192     parameterName.Set(tempParameterName);
00193   }
00194 
00195   // Destructor
00196 
00197   ~YouBotSlaveMailboxMsgThreadSafe()
00198   {
00199   }
00200 
00201   // assignment operator
00202 
00203   YouBotSlaveMailboxMsgThreadSafe & operator=(const YouBotSlaveMailboxMsgThreadSafe& copy)
00204   {
00205     mailboxOutputBuffer tempStctOutput;
00206     mailboxInputBuffer tempStctInput;
00207     std::string tempParameterName;
00208     unsigned int SlaveNumber;
00209 
00210     copy.stctOutput.Get(tempStctOutput);
00211     stctOutput.Set(tempStctOutput);
00212 
00213     copy.stctInput.Get(tempStctInput);
00214     stctInput.Set(tempStctInput);
00215 
00216     copy.slaveNumber.Get(SlaveNumber);
00217     slaveNumber.Set(SlaveNumber);
00218 
00219     copy.parameterName.Get(tempParameterName);
00220     parameterName.Set(tempParameterName);
00221     return *this;
00222   }
00223 
00224   DataObjectLockFree<std::string> parameterName;
00225 
00226   DataObjectLockFree<unsigned int> slaveNumber;
00227 };
00228 
00229 } // namespace youbot
00230 
00231 #endif  /* _YOUBOT_SLAVE_MESSAGE_H */


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