00001 // File: HawkFreezer.H 00002 // Author: Josh Villbrandt <josh.villbrandt@usc.edu> 00003 // Date: April 2010 00004 00005 #include <string> 00006 #include <vector> 00007 #include <fstream> 00008 #include <Ice/Ice.h> 00009 #include "Util/Timer.H" 00010 #include "Robots/BeoHawk/core/HawkMessages.ice.H" 00011 #include "Robots/BeoHawk/computer/HawkAgent.H" 00012 00013 class HawkFreezer : public HawkAgent { 00014 public: 00015 // These functions must be defined in all HawkAgents 00016 HawkFreezer(std::string myName, int argc, char* argv[]); 00017 bool scheduler(); 00018 void registerTopics(); 00019 void catchMessage(const HawkMessages::MessagePtr& msg, const Ice::Current&); 00020 00021 private: 00022 // These functions are specific to the individual agents 00023 enum States {INIT_FAIL, LOAD_PLAYBACK, PLAYBACK, RECORD}; 00024 States state; 00025 Timer timer; 00026 struct Message { 00027 double timestamp; 00028 HawkMessages::SensorDataMessagePtr sensorData; 00029 }; 00030 std::vector<Message> messages; 00031 double frequency; // messages per seconds 00032 double duration; // seconds 00033 double period; 00034 double lastMessageSeconds; 00035 std::string file; 00036 void playNextMessages(); 00037 void loadMessages(); 00038 void saveMessages(); 00039 };