43 #ifndef _MIRA_SCITOSMANAGER_H_ 44 #define _MIRA_SCITOSMANAGER_H_ 57 namespace mira {
namespace robot {
74 category(
"HWError"), text(iText) {}
76 category(iCategory), text(iText) {}
86 std::ostringstream ss;
87 ss << std::hex << std::showbase << id;
93 std::istringstream ss(s);
95 ss >> std::setbase(0) >> i;
103 template<
typename Reflector>
108 setter<std::string>([&](
const std::string& s){node = fromPrefixedString(s);}),
111 r.property(
"VendorID",
113 setter<std::string>([&](
const std::string& s){vendorID = fromPrefixedString(s);}),
116 r.property(
"ProductID",
118 setter<std::string>([&](
const std::string& s){productID = fromPrefixedString(s);}),
122 bool match(uint8 n, uint32 vID, uint32 pID)
const 124 return (((node == 0) || (node == n)) &&
125 ((vendorID == 0) || (vendorID == vID)) &&
126 ((productID == 0) || (productID == pID)));
131 uint32 productID = 0;
135 mInitializationFinished(false) {}
138 template<
typename Reflector>
141 r.property(
"DeadModuleTimeout", mRemoveNodeTimeout,
143 r.roproperty(
"IgnoreModules", mIgnoreModules,
144 "List of CAN modules to be ignored.\n" 145 "Each entry consists of Node+VendorID+ProductID. " 146 "A module is ignored if it matches ALL specified elements, default=0=wildcard.");
147 auto it = mModules.begin();
148 for(; it != mModules.end(); ++it)
149 r.property(it->second->getName().c_str(), it->second,
"Module");
158 return mCANInterface;
178 return mHasHWTimeSync;
197 boost::mutex::scoped_lock lock(mErrorMutex);
198 mErrorDescriptions[errorNr] = ed;
208 boost::mutex::scoped_lock lock(mErrorMutex);
209 auto errorDesc = mErrorDescriptions.find(errorNr);
211 if (errorDesc != mErrorDescriptions.end())
212 return errorDesc->second;
213 std::string category(
"Unknown error");
214 std::string text =
MakeString() <<
"Error ID " << std::hex << errorNr;
226 uint32 diff = hwTime-getHWTime(pcTime);
227 int64 signedDiff = *
reinterpret_cast<int32*
>(&diff);
240 uint16 diff = hwTime-getHWTime(pcTime);
241 int32 signedDiff = *
reinterpret_cast<int16*
>(&diff);
249 return mRobotModelProvider->getRobotModel();
252 void updateProperties();
257 virtual void initialize();
258 virtual void finalize();
260 virtual void resume();
261 virtual void pause();
279 boost::mutex mErrorMutex;
280 boost::mutex mPropertyMutex;
284 std::map<uint8, SCITOSModulePtr> mModules;
285 std::map<uint8, std::pair<mira::can::CANOpenNodeInfo, Time>> mNodeInfos;
287 std::vector<ModuleID> mIgnoreModules;
288 std::set<uint8> mIgnoredNodes;
289 std::string mRobotType;
290 uint32 mLastHWTimeValue;
293 bool mInitializationFinished;
295 std::map<uint32, ErrorDescription> mErrorDescriptions;
296 boost::shared_ptr<robot::RobotModelProvider> mRobotModelProvider;
void reflect(Reflector &r)
Reflect method for serialization.
Definition: SCITOSManager.h:139
tick_type milliseconds() const
SCITOSManager()
Definition: SCITOSManager.h:134
ErrorDescription(const std::string &iCategory, const std::string &iText)
Definition: SCITOSManager.h:75
ErrorDescription getErrorDescription(uint32 errorNr)
Returns the error description of the given error number.
Definition: SCITOSManager.h:206
Time correctPCTime(Time pcTime, uint16 hwTime)
Correct the PC time relative to given hardware time.
Definition: SCITOSManager.h:236
boost::shared_ptr< robot::RobotModel > getRobotModel()
Returns the SCITOS robot model.
Definition: SCITOSManager.h:247
std::string text
Definition: SCITOSManager.h:79
void addErrorDescription(uint32 errorNr, const ErrorDescription &ed)
Adds an error description for the given error number.
Definition: SCITOSManager.h:195
std::string category
Definition: SCITOSManager.h:78
boost::shared_ptr< CANOpenNMTMaster > CANOpenNMTMasterPtr
bool hasHWTime() const
Returns true if a hardware timestamp exists.
Definition: SCITOSManager.h:176
mira::can::CANOpenNMTMasterPtr getNMTMaster()
Returns the can NMT master pointer.
Definition: SCITOSManager.h:168
void reflect(Reflector &r)
Definition: SCITOSManager.h:104
boost::shared_ptr< CANOpenSDOClient > CANOpenSDOClientPtr
tick_type totalMilliseconds() const
bool match(uint8 n, uint32 vID, uint32 pID) const
Definition: SCITOSManager.h:122
static std::string toHexString(uint32 id)
Definition: SCITOSManager.h:84
ErrorDescription(const std::string &iText)
Definition: SCITOSManager.h:73
void reflect(Reflector &r, LogRecord &record)
#define MLAB_SCITOS_EXPORT
Definition: SCITOSDefines.h:57
#define MIRA_OBJECT(classIdentifier)
Base class for a SCITOS driver module.
boost::shared_ptr< CANChannelInterface > CANChannelInterfacePtr
ErrorDescription()
Definition: SCITOSManager.h:72
static uint32 fromPrefixedString(const std::string &s)
Definition: SCITOSManager.h:91
Defines for the SCITOS robot drivers.
mira::can::CANChannelInterfacePtr getCANInterface()
Returns the can interface pointer.
Definition: SCITOSManager.h:156
mira::can::CANOpenSDOClientPtr getCANSDOClient()
Returns the can sdo client pointer.
Definition: SCITOSManager.h:162
static Time now() static Time eternity()
The SCITOSManager manages all driver modules of a SCITOS robot.
Definition: SCITOSManager.h:64
Time correctPCTime(Time pcTime, uint32 hwTime)
Correct the PC time relative to given hardware time.
Definition: SCITOSManager.h:222
A description of a hardware error. Used to map error ids to text.
Definition: SCITOSManager.h:70
uint32 getHWTime(Time time=Time::now())
Return the hardware time that corresponds with the given PC time.
Definition: SCITOSManager.h:186
Definition: SCITOSManager.h:101