00001 #ifndef YOUBOT_ETHERCATMASTERINTERFACE_H 00002 #define YOUBOT_ETHERCATMASTERINTERFACE_H 00003 00004 /**************************************************************** 00005 * 00006 * Copyright (c) 2011 00007 * All rights reserved. 00008 * 00009 * Hochschule Bonn-Rhein-Sieg 00010 * University of Applied Sciences 00011 * Computer Science Department 00012 * 00013 * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00014 * 00015 * Author: 00016 * Jan Paulus, Nico Hochgeschwender, Michael Reckhaus, Azamat Shakhimardanov 00017 * Supervised by: 00018 * Gerhard K. Kraetzschmar 00019 * 00020 * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00021 * 00022 * This sofware is published under a dual-license: GNU Lesser General Public 00023 * License LGPL 2.1 and BSD license. The dual-license implies that users of this 00024 * code may choose which terms they prefer. 00025 * 00026 * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00027 * 00028 * Redistribution and use in source and binary forms, with or without 00029 * modification, are permitted provided that the following conditions are met: 00030 * 00031 * * Redistributions of source code must retain the above copyright 00032 * notice, this list of conditions and the following disclaimer. 00033 * * Redistributions in binary form must reproduce the above copyright 00034 * notice, this list of conditions and the following disclaimer in the 00035 * documentation and/or other materials provided with the distribution. 00036 * * Neither the name of the Hochschule Bonn-Rhein-Sieg nor the names of its 00037 * contributors may be used to endorse or promote products derived from 00038 * this software without specific prior written permission. 00039 * 00040 * This program is free software: you can redistribute it and/or modify 00041 * it under the terms of the GNU Lesser General Public License LGPL as 00042 * published by the Free Software Foundation, either version 2.1 of the 00043 * License, or (at your option) any later version or the BSD license. 00044 * 00045 * This program is distributed in the hope that it will be useful, 00046 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00047 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00048 * GNU Lesser General Public License LGPL and the BSD license for more details. 00049 * 00050 * You should have received a copy of the GNU Lesser General Public 00051 * License LGPL and BSD license along with this program. 00052 * 00053 ****************************************************************/ 00054 #include "youbot/YouBotSlaveMsg.hpp" 00055 #include "youbot/YouBotSlaveMailboxMsg.hpp" 00056 #include "youbot/JointLimitMonitor.hpp" 00057 extern "C"{ 00058 #include <ethercattype.h> 00059 #include <ethercatmain.h> 00060 } 00061 00062 namespace youbot { 00063 00064 /////////////////////////////////////////////////////////////////////////////// 00065 /// The Ethercat Master interface 00066 /////////////////////////////////////////////////////////////////////////////// 00067 class EthercatMasterInterface { 00068 friend class EthercatMaster; 00069 friend class YouBotJoint; 00070 friend class YouBotGripper; 00071 friend class YouBotGripperBar; 00072 protected: 00073 EthercatMasterInterface() {}; 00074 00075 virtual ~EthercatMasterInterface() {}; 00076 00077 00078 public: 00079 virtual bool isThreadActive() = 0; 00080 00081 ///return the quantity of ethercat slave which have an input/output buffer 00082 virtual unsigned int getNumberOfSlaves() const = 0; 00083 00084 virtual void AutomaticSendOn(const bool enableAutomaticSend) = 0; 00085 00086 virtual void AutomaticReceiveOn(const bool enableAutomaticReceive) = 0; 00087 00088 ///provides all ethercat slave informations from the SOEM driver 00089 ///@param ethercatSlaveInfos ethercat slave informations 00090 virtual void getEthercatDiagnosticInformation(std::vector<ec_slavet>& ethercatSlaveInfos) = 0; 00091 00092 ///sends ethercat messages to the motor controllers 00093 /// returns a true if everything it OK and returns false if something fail 00094 virtual bool sendProcessData() = 0; 00095 00096 /// receives ethercat messages from the motor controllers 00097 /// returns a true if everything it OK and returns false if something fail 00098 virtual bool receiveProcessData() = 0; 00099 00100 /// checks if an error has occurred in the soem driver 00101 /// returns a true if an error has occurred 00102 virtual bool isErrorInSoemDriver() = 0; 00103 00104 virtual bool isEtherCATConnectionEstablished() = 0; 00105 00106 virtual void registerJointLimitMonitor(JointLimitMonitor* object, const unsigned int JointNumber) = 0; 00107 00108 00109 private: 00110 ///stores a ethercat message to the buffer 00111 ///@param msgBuffer ethercat message 00112 ///@param jointNumber joint number of the sender joint 00113 virtual void setMsgBuffer(const YouBotSlaveMsg& msgBuffer, const unsigned int jointNumber) = 0; 00114 00115 ///get a ethercat message form the buffer 00116 ///@param msgBuffer ethercat message 00117 ///@param jointNumber joint number of the receiver joint 00118 virtual void getMsgBuffer(const unsigned int jointNumber, YouBotSlaveMsg& returnMsg) = 0; 00119 00120 ///stores a mailbox message in a buffer which will be sent to the motor controllers 00121 ///@param msgBuffer ethercat mailbox message 00122 ///@param jointNumber joint number of the sender joint 00123 virtual void setMailboxMsgBuffer(const YouBotSlaveMailboxMsg& msgBuffer, const unsigned int jointNumber) = 0; 00124 00125 ///gets a mailbox message form the buffer which came form the motor controllers 00126 ///@param msgBuffer ethercat mailbox message 00127 ///@param jointNumber joint number of the receiver joint 00128 virtual bool getMailboxMsgBuffer(YouBotSlaveMailboxMsg& mailboxMsg, const unsigned int jointNumber) = 0; 00129 00130 }; 00131 00132 } // namespace youbot 00133 #endif