00001
00002 #ifndef INCLUDED_RunSequenceControl_h_
00003 #define INCLUDED_RunSequenceControl_h_
00004
00005 #include "FileBrowserControl.h"
00006 #include "Motion/MotionSequenceMC.h"
00007 #include "Shared/TimeET.h"
00008 #include "Shared/Config.h"
00009 #include <string>
00010
00011
00012
00013
00014
00015
00016 template<unsigned int SequenceSize>
00017 class RunSequenceControl : public FileBrowserControl, public EventListener {
00018 public:
00019
00020 RunSequenceControl(const std::string& n, MotionManager::MC_ID estop_id)
00021 : FileBrowserControl(n,"Runs a motion sequence from a user-specified file",config->motion.root), estopid(estop_id)
00022 {
00023 setFilter("*.mot");
00024 }
00025
00026
00027 virtual void processEvent(const EventBase& event) {
00028 erouter->removeListener(this,event);
00029 MMAccessor<EmergencyStopMC> estop(estopid);
00030 estop->takeSnapshot();
00031 estop->setActive(true);
00032 }
00033
00034 protected:
00035
00036 virtual ControlBase* selectedFile(const std::string& f) {
00037
00038 SharedObject< MotionSequenceMC<SequenceSize> > s(f.c_str());
00039
00040 MMAccessor<EmergencyStopMC>(estopid)->setActive(false);
00041 MotionManager::MC_ID id=motman->addMotion(s,MotionManager::kEmergencyPriority+1,true);
00042 erouter->addListener(this,EventBase::motmanEGID,id,EventBase::deactivateETID);
00043 return this;
00044 }
00045
00046 MotionManager::MC_ID estopid;
00047 };
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060 #endif