1 #ifndef SCD_CONT_MAN_SLAVE_H
2 #define SCD_CONT_MAN_SLAVE_H
4 #include "scd_simulator.h"
5 #include "scd_socket.h"
6 #include "scd_out_connector.h"
7 #include "scd_command_writer.h"
8 #include "scd_command_reader.h"
9 #include "scd_cont_man.h"
10 #include "scd_sock_poller.h"
12 #include "fsm/scd_cont_fsm.h"
13 #include "fsm/scd_sts_init.h"
14 #include "fsm/scd_sts_busy.h"
15 #include "fsm/scd_sts_idle.h"
16 #include "fsm/scd_sts_done.h"
17 #include "fsm/scd_sts_time_ack.h"
18 #include "fsm/scd_sts_time.h"
19 #include "fsm/scd_sts_term_ack.h"
20 #include "fsm/scd_sts_terminated.h"
21 #include "fsm/scd_sts_fail.h"
22 #include "fsm/scd_sts_failed.h"
25 * Control manager for a slave. Connects to the master controller and
26 * synchronizes the local and global simulation state.
28 class scd_cont_man_slave : public scd_cont_man, public scd_cont_fsm,
29 public scd_sock_ev_handler_if
31 friend class scd_sts_base;
36 * \param sim the simulation environment
38 scd_cont_man_slave(scd_simulator& sim);
40 virtual ~scd_cont_man_slave();
43 * Sets the socket where to read from and write to after the connection
44 * has been established to the master.
49 * Sends a command to the master.
50 * \param cmd the command to send
52 void send_command(scd_command* cmd);
55 * Indicates if a command is being sent to the master (and did not finish
57 * \return true if a command is currently being sent
62 * Closes the connection to the master controller.
67 void set_master(const std::string& host, uint16_t port);
68 void register_slave(const std::string& name);
71 void set_idle(const sc_core::sc_time& t) { return _state->set_idle(t); }
72 void set_busy() { return _state->set_busy(); }
73 void set_done() { return _state->set_done(); }
74 void set_fail() { return _state->set_fail(); }
75 void process() { return _state->process(); }
76 bool active() const { return _state->active(); }
77 bool busy() const { return _state->busy(); }
78 bool failed() const { return _state->failed(); }
79 bool advance_time() const { return _state->advance_time(); }
80 const sc_core::sc_time& get_time_step() { return _state->get_time_step(); }
82 /* scd_sock_ev_handler_if */
83 void handle_sock_ev(sock_ev events);
84 const scd_socket& get_sock();
90 scd_out_connector _connector;
91 scd_command_writer _writer;
92 scd_command_reader _reader;
96 scd_sts_init _st_init;
97 scd_sts_busy _st_busy;
98 scd_sts_idle _st_idle;
99 scd_sts_done _st_done;
100 scd_sts_time_ack _st_time_ack;
101 scd_sts_time _st_time;
102 scd_sts_term_ack _st_term_ack;
103 scd_sts_terminated _st_terminated;
104 scd_sts_fail _st_fail;
105 scd_sts_failed _st_failed;
107 /* member functions */
108 void _process_cmd(scd_command& cmd);