00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #pragma once
00020
00021
00022 #include <list>
00023 #include <map>
00024
00025 #include <ace/Service_Object.h>
00026
00027 #include "rt_parameters.h"
00028
00029 class LogAdapterContainer;
00030
00031 namespace rt_lib
00032 {
00033 class RTControl;
00034
00035 }
00036
00037 namespace rt_ctrl
00038 {
00039
00040 using namespace rt_lib;
00041
00049 struct IRobotInfoConsumer
00050 {
00052 virtual void process_message(const char* server_id, const char* robot_id, const char* buf, int len) = 0;
00053
00055 virtual void process_ACK_message(const std::string& server_id, RTControl&) = 0;
00057 virtual void process_logon_server(const std::string& server_id) = 0;
00059 virtual void process_logout_server(const std::string& server_id) = 0;
00061 virtual void process_available_robot_types(const std::string& server_id) = 0;
00063 virtual void process_active_robots(const std::string& server_id) = 0;
00065 virtual void process_xml_report(const std::string& server_id, const std::string& robot_id, const std::string& report_xml) = 0;
00066 };
00067
00075 struct RobotInstanceInfo
00076 {
00078 std::string trader_name_;
00080 std::string robot_name_;
00082 std::string robot_id_;
00084 time_t init_time_;
00086 int robot_state_;
00088 std::string status_str_;
00089
00092 std::map<std::string,std::string> xml_reports_;
00093 };
00094
00100 struct ServerInfo
00101 {
00102 ServerInfo()
00103 :heartbeat_interval_(10)
00104 ,last_heartbeat_time_(0)
00105 ,authorized_(false)
00106 ,robot_types_received_(false)
00107 ,active_robots_received_(false)
00108 {}
00109
00110 void logout()
00111 {
00112 authorized_ = false;
00113 robot_types_received_ = false;
00114 active_robots_received_ = false;
00115 last_heartbeat_time_ = 0;
00116 heartbeat_interval_ = 0;
00117 }
00118
00120 std::string server_id_;
00122 time_t last_heartbeat_time_;
00124 time_t heartbeat_interval_;
00126 bool authorized_;
00128 bool robot_types_received_;
00130 bool active_robots_received_;
00131
00133 std::map<std::string, RobotType> robot_types_;
00134
00136 std::map<std::string, RobotInstanceInfo> active_robots_;
00137 };
00138
00146 class IRTController
00147 {
00148 public:
00149
00151 virtual int init(const char* cfg_file) = 0;
00153 virtual int fini() = 0;
00155 virtual int init_log(const LogAdapterContainer* log_adapters, const char* cfg_file) = 0;
00157 virtual bool authorized() = 0;
00158
00160 virtual void get_available_robots_request(const std::string & server_id) = 0;
00162 virtual void get_active_robots_request(const std::string & server_id) = 0;
00163
00165 virtual void new_robot_instance_request( const std::string & robot_name, const std::string& server_id, std::list<RobotTypeParameter>& params) = 0;
00166
00168 virtual void start_robot_instance_request( const std::string & robot_name, const std::string& server_id, const std::string& robot_id) = 0;
00170 virtual void stop_robot_instance_request( const std::string & robot_name, const std::string& server_id, const std::string& robot_id) = 0;
00172 virtual void delete_robot_instance_request( const std::string & robot_name, const std::string& server_id, const std::string& robot_id) = 0;
00173
00175 virtual void init_robot_instance_request( const std::string & robot_name, const std::string& server_id, const std::string& robot_id) = 0;
00177 virtual void set_robot_instance_parameters_request( const std::string & robot_name, const std::string& server_id, const std::string& robot_id, std::list<RobotTypeParameter>& params) = 0;
00179 virtual void set_del_on_disconnect_flag_request(const std::string& server_id, bool kill_on_disconnect) = 0;
00180
00182 virtual void send_message(const char* server_id, const char* robot_id, const char* buf, int len) = 0;
00183
00184
00185 virtual IRobotInfoConsumer* robot_info_consumer() = 0;
00186 virtual void robot_info_consumer(IRobotInfoConsumer* val) = 0;
00187
00188 virtual const std::string& trader_name() = 0;
00189
00190 virtual std::map<std::string, ServerInfo >& server_map() = 0;
00191 };
00192
00198 struct IRTControllerService : public ACE_Service_Object
00199 {
00201 virtual IRTController* get_controller() = 0;
00202 };
00203
00204
00205
00206 }