EthercatMasterWithoutThread.hpp
Go to the documentation of this file.
1 #ifndef YOUBOT_ETHERCATMASTERWITHOUTTHREAD_H
2 #define YOUBOT_ETHERCATMASTERWITHOUTTHREAD_H
3 
4 /****************************************************************
5  *
6  * Copyright (c) 2011
7  * All rights reserved.
8  *
9  * Hochschule Bonn-Rhein-Sieg
10  * University of Applied Sciences
11  * Computer Science Department
12  *
13  * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
14  *
15  * Author:
16  * Jan Paulus, Nico Hochgeschwender, Michael Reckhaus, Azamat Shakhimardanov
17  * Supervised by:
18  * Gerhard K. Kraetzschmar
19  *
20  * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
21  *
22  * This sofware is published under a dual-license: GNU Lesser General Public
23  * License LGPL 2.1 and BSD license. The dual-license implies that users of this
24  * code may choose which terms they prefer.
25  *
26  * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
27  *
28  * Redistribution and use in source and binary forms, with or without
29  * modification, are permitted provided that the following conditions are met:
30  *
31  * * Redistributions of source code must retain the above copyright
32  * notice, this list of conditions and the following disclaimer.
33  * * Redistributions in binary form must reproduce the above copyright
34  * notice, this list of conditions and the following disclaimer in the
35  * documentation and/or other materials provided with the distribution.
36  * * Neither the name of the Hochschule Bonn-Rhein-Sieg nor the names of its
37  * contributors may be used to endorse or promote products derived from
38  * this software without specific prior written permission.
39  *
40  * This program is free software: you can redistribute it and/or modify
41  * it under the terms of the GNU Lesser General Public License LGPL as
42  * published by the Free Software Foundation, either version 2.1 of the
43  * License, or (at your option) any later version or the BSD license.
44  *
45  * This program is distributed in the hope that it will be useful,
46  * but WITHOUT ANY WARRANTY; without even the implied warranty of
47  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
48  * GNU Lesser General Public License LGPL and the BSD license for more details.
49  *
50  * You should have received a copy of the GNU Lesser General Public
51  * License LGPL and BSD license along with this program.
52  *
53  ****************************************************************/
54 
55 #include <vector>
56 #include <sstream>
57 #include <string>
58 #include <cstdio>
59 #include <stdexcept>
60 #include <iostream>
61 #include <boost/thread.hpp>
62 #include <boost/date_time/posix_time/posix_time.hpp>
72 
73 extern "C"{
76 }
77 
78 namespace youbot {
79 
85 friend class EthercatMaster;
86 friend class YouBotJoint;
87 friend class YouBotGripper;
88 friend class YouBotGripperBar;
89  private:
90  EthercatMasterWithoutThread(const std::string& configFile, const std::string& configFilePath);
91 
93 
94 
95  public:
96  bool isThreadActive();
97 
99  unsigned int getNumberOfSlaves() const;
100 
101  void AutomaticSendOn(const bool enableAutomaticSend);
102 
103  void AutomaticReceiveOn(const bool enableAutomaticReceive);
104 
107  void getEthercatDiagnosticInformation(std::vector<ec_slavet>& ethercatSlaveInfos);
108 
111  bool sendProcessData();
112 
115  bool receiveProcessData();
116 
119  bool isErrorInSoemDriver();
120 
122 
123  void registerJointLimitMonitor(JointLimitMonitor* object, const unsigned int JointNumber);
124 
125 
126  private:
128  void initializeEthercat();
129 
131  bool closeEthercat();
132 
136  void setMsgBuffer(const YouBotSlaveMsg& msgBuffer, const unsigned int jointNumber);
137 
141  void getMsgBuffer(const unsigned int jointNumber, YouBotSlaveMsg& returnMsg);
142 
146  void setMailboxMsgBuffer(const YouBotSlaveMailboxMsg& msgBuffer, const unsigned int jointNumber);
147 
151  bool getMailboxMsgBuffer(YouBotSlaveMailboxMsg& mailboxMsg, const unsigned int jointNumber);
152 
155  bool sendMailboxMessage(const YouBotSlaveMailboxMsg& mailboxMsg);
156 
160 
161  void parseYouBotErrorFlags(const YouBotSlaveMsg& messageBuffer);
162 
163  std::string ethernetDevice;
164 
165  std::vector<YouBotSlaveMsg> processDataBuffer;
166 
167  unsigned int nrOfSlaves;
168 
169  std::vector<SlaveMessageOutput*> ethercatOutputBufferVector;
170 
171  std::vector<SlaveMessageInput*> ethercatInputBufferVector;
172 
173  std::vector<YouBotSlaveMailboxMsg> firstMailboxBufferVector;
174 
176 
177  unsigned int mailboxTimeout;
178 
180 
182 
183  std::vector<ec_slavet> ethercatSlaveInfo;
184 
185  char IOmap_[4096];
186 
187  unsigned int ethercatTimeout;
188 
189  static std::string configFileName;
190 
191  static std::string configFilepath;
192 
194 
195 };
196 
197 } // namespace youbot
198 #endif
void registerJointLimitMonitor(JointLimitMonitor *object, const unsigned int JointNumber)
The Ethercat Master factory.
unsigned int getNumberOfSlaves() const
return the quantity of ethercat slave which have an input/output buffer
std::vector< YouBotSlaveMailboxMsg > firstMailboxBufferVector
bool closeEthercat()
closes the ethercat connection
Reads and writes a configuration file.
Definition: ConfigFile.hpp:125
void setMsgBuffer(const YouBotSlaveMsg &msgBuffer, const unsigned int jointNumber)
void AutomaticSendOn(const bool enableAutomaticSend)
The youBot gripper with one degree of freedom.
General typedefs and defines for EtherCAT.
EthercatMasterWithoutThread(const std::string &configFile, const std::string &configFilePath)
bool receiveMailboxMessage(YouBotSlaveMailboxMsg &mailboxMsg)
std::vector< SlaveMessageInput * > ethercatInputBufferVector
bool sendMailboxMessage(const YouBotSlaveMailboxMsg &mailboxMsg)
It monitors the joint position and will decelerate and stop the joint if it is close the limits...
EtherCAT mailbox message of the youBot slaves.
void setMailboxMsgBuffer(const YouBotSlaveMailboxMsg &msgBuffer, const unsigned int jointNumber)
void initializeEthercat()
establishes the ethercat connection
The Ethercat Master interface.
One bar of the youBot gripper.
std::vector< SlaveMessageOutput * > ethercatOutputBufferVector
void parseYouBotErrorFlags(const YouBotSlaveMsg &messageBuffer)
Headerfile for ethercatmain.c.
void getEthercatDiagnosticInformation(std::vector< ec_slavet > &ethercatSlaveInfos)
bool getMailboxMsgBuffer(YouBotSlaveMailboxMsg &mailboxMsg, const unsigned int jointNumber)
void AutomaticReceiveOn(const bool enableAutomaticReceive)
EtherCat message of the youBot EtherCat slaves.
uint8 ec_mbxbuft[EC_MAXMBX+1]
Definition: ethercatmain.h:341
void getMsgBuffer(const unsigned int jointNumber, YouBotSlaveMsg &returnMsg)


youbot_driver
Author(s): Jan Paulus
autogenerated on Mon Jun 10 2019 15:46:24