34 : m_addr(new QHostAddress(addr)), m_port(port), m_socket(nullptr),
35 m_protocol(nullptr), m_currentTaskId(-1), m_currentTaskName(
"")
40 quint16 port,
int taskId, std::string taskName)
41 : m_addr(new QHostAddress(addr)), m_port(port), m_socket(nullptr),
42 m_protocol(nullptr), m_currentTaskId(taskId), m_currentTaskName(taskName)
50 void WorkerRepresentative::Connected()
52 if (m_currentTaskId != -1) {
54 connect(m_protocol, SIGNAL(Error(
const std::string&)),
55 this, SLOT(DisplayError(
const std::string&)));
56 connect(m_protocol, SIGNAL(ResultReceived(
const SimResult&)),
70 void WorkerRepresentative::DisplayError(
const std::string& error)
const
72 cerr <<
"WorkerRepresentative Error: " << error << endl;
75 void WorkerRepresentative::DisplayError(QAbstractSocket::SocketError error)
const
77 cerr <<
"WorkerRepresentative Socket Error: " << error << endl;
83 m_currentTaskId = task.
GetId();
88 void WorkerRepresentative::Finished(
const SimResult& res)
98 return m_currentTaskName;
113 return m_currentTaskId;
116 void WorkerRepresentative::Init()
120 connect(m_protocol, SIGNAL(Error(
const std::string&)),
121 this, SLOT(DisplayError(
const std::string&)));
122 connect(m_protocol, SIGNAL(ResultReceived(
const SimResult&)),
129 m_socket =
new QTcpSocket();
130 m_socket->connectToHost(*m_addr, m_port);
132 connect(m_socket, SIGNAL(connected()),
this, SLOT(Connected()));
133 connect(m_socket, SIGNAL(disconnected()),
this, SIGNAL(
Disconnected()));
135 connect(m_socket, SIGNAL(error(QAbstractSocket::SocketError)),
136 this, SLOT(DisplayError(QAbstractSocket::SocketError)));
void Setup()
Tries to connect to the worker and sets up the signals.
void StopTask()
Orders the node to stop its current task.
A container class for the final result of a simulation.
void SendTask(const SimTask &task)
Sends a task to the server.
void DoWork(const SimTask &)
Pass the job to the worker.
Protocol at the server side to communicate with the node.
WorkerRepresentative(const QHostAddress &addr, quint16 port)
Constructor for a worker without work.
int GetSenderPort() const
Gets the port of the worker.
void ReadyToWork()
Emitted when the worker is ready to do a new job.
Interface for ServerNodeProtocol.
void FinishedWork(const SimResult &)
Emitted when the worker has finished his job and has the result ready.
void StopTask()
Stop the current task.
int GetTaskId() const
Gets the id of the currently executing task.
const QHostAddress * GetSenderAddress() const
Gets the address of the worker.
void Delete(const std::string name)
Delete an exploration.
std::string GetExplName() const
Gets the name current tasks' exploration.
void Delete(const std::string &name)
Orders the node to delete all files it has for a certain exploration.
Namespace for SimPT parameter explorer package.
std::string GetExploration() const
Get the name of the exploration.
Contains all information needed for a transmitable simulation task.
int GetId() const
Get the id of the task in the exploration.
void Disconnected()
Emitted when the worker has disconnected.
virtual ~WorkerRepresentative()
Destructor.
Interface for WorkerRepresentative.