--- /dev/null
+#ifndef SCD_CONT_MAN_SLAVE_H
+#define SCD_CONT_MAN_SLAVE_H
+
+#include "scd_simulator.h"
+#include "scd_socket.h"
+#include "scd_out_connector.h"
+#include "scd_command_writer.h"
+#include "scd_command_reader.h"
+#include "scd_cont_man.h"
+#include "scd_sock_poller.h"
+
+#include "fsm/scd_cont_fsm.h"
+#include "fsm/scd_sts_init.h"
+#include "fsm/scd_sts_busy.h"
+#include "fsm/scd_sts_idle.h"
+#include "fsm/scd_sts_done.h"
+#include "fsm/scd_sts_time_ack.h"
+#include "fsm/scd_sts_time.h"
+#include "fsm/scd_sts_term_ack.h"
+#include "fsm/scd_sts_terminated.h"
+#include "fsm/scd_sts_fail.h"
+#include "fsm/scd_sts_failed.h"
+
+/**
+ * Control manager for a slave. Connects to the master controller and
+ * synchronizes the local and global simulation state.
+ */
+class scd_cont_man_slave : public scd_cont_man, public scd_cont_fsm,
+ public scd_sock_ev_handler_if
+{
+ friend class scd_sts_base;
+
+public:
+ /**
+ * Constructor.
+ * \param sim the simulation environment
+ */
+ scd_cont_man_slave(scd_simulator& sim);
+
+ virtual ~scd_cont_man_slave();
+
+ /**
+ * Sets the socket where to read from and write to after the connection
+ * has been established to the master.
+ */
+ void set_socket();
+
+ /**
+ * Sends a command to the master.
+ * \param cmd the command to send
+ */
+ void send_command(scd_command* cmd);
+
+ /**
+ * Indicates if a command is being sent to the master (and did not finish
+ * yet).
+ * \return true if a command is currently being sent
+ */
+ bool is_sending();
+
+ /**
+ * Closes the connection to the master controller.
+ */
+ void close();
+
+ /* scd_cont_man */
+ void set_master(const std::string& host, uint16_t port);
+ void register_slave(const std::string& name);
+
+ /* scd_cont_fsm_if */
+ void set_idle(const sc_core::sc_time& t) { return _state->set_idle(t); }
+ void set_busy() { return _state->set_busy(); }
+ void set_done() { return _state->set_done(); }
+ void set_fail() { return _state->set_fail(); }
+ void process() { return _state->process(); }
+ bool active() const { return _state->active(); }
+ bool busy() const { return _state->busy(); }
+ bool failed() const { return _state->failed(); }
+ bool advance_time() const { return _state->advance_time(); }
+ const sc_core::sc_time& get_time_step() { return _state->get_time_step(); }
+
+ /* scd_sock_ev_handler_if */
+ void handle_sock_ev(sock_ev events);
+ const scd_socket& get_sock();
+
+private:
+ scd_simulator& _sim;
+
+ scd_socket* _socket;
+ scd_out_connector _connector;
+ scd_command_writer _writer;
+ scd_command_reader _reader;
+ bool _has_master;
+
+ /* states */
+ scd_sts_init _st_init;
+ scd_sts_busy _st_busy;
+ scd_sts_idle _st_idle;
+ scd_sts_done _st_done;
+ scd_sts_time_ack _st_time_ack;
+ scd_sts_time _st_time;
+ scd_sts_term_ack _st_term_ack;
+ scd_sts_terminated _st_terminated;
+ scd_sts_fail _st_fail;
+ scd_sts_failed _st_failed;
+
+ /* member functions */
+ void _process_cmd(scd_command& cmd);
+};
+
+#endif