00001
00002 #ifndef INCLUDED_LoadPostureControl_h_
00003 #define INCLUDED_LoadPostureControl_h_
00004
00005 #include "FileBrowserControl.h"
00006 #include "Motion/PostureMC.h"
00007 #include "Motion/MMAccessor.h"
00008 #include "Motion/EmergencyStopMC.h"
00009 #include <string>
00010
00011
00012
00013 class LoadPostureControl : public FileBrowserControl, public EventListener {
00014 public:
00015
00016 LoadPostureControl(const std::string& n, MotionManager::MC_ID estop_id)
00017 : FileBrowserControl(n,"Loads a posture from user-selected file",config->motion.root), estopid(estop_id), file()
00018 {
00019 setFilter("*.pos");
00020 }
00021
00022 virtual ~LoadPostureControl() {}
00023
00024
00025 virtual void processEvent(const EventBase& event) {
00026
00027
00028 erouter->removeListener(this,event);
00029 MMAccessor<EmergencyStopMC> estop(estopid);
00030
00031
00032
00033 estop->LoadFile(file.c_str());
00034 estop->setActive(true);
00035 }
00036
00037 virtual void deactivate() {
00038 erouter->forgetListener(this);
00039 }
00040
00041 protected:
00042
00043 virtual ControlBase* selectedFile(const std::string& f) {
00044 file=f;
00045 SharedObject<PostureMC> post;
00046 post->LoadFile(file.c_str());
00047 MMAccessor<EmergencyStopMC>(estopid)->setActive(false);
00048 MotionManager::MC_ID id=motman->addMotion(post,MotionManager::kEmergencyPriority+1,true);
00049 erouter->addListener(this,EventBase::motmanEGID,id,EventBase::deactivateETID);
00050 return this;
00051 }
00052
00053 MotionManager::MC_ID estopid;
00054 std::string file;
00055 };
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068 #endif