VPTissue Reference Manual
WorkerRepresentative.h
Go to the documentation of this file.
1 #ifndef SIMPT_PAREX_WORKER_REPRESENTATIVE_H_INCLUDED
2 #define SIMPT_PAREX_WORKER_REPRESENTATIVE_H_INCLUDED
3 /*
4  * Copyright 2011-2016 Universiteit Antwerpen
5  *
6  * Licensed under the EUPL, Version 1.1 or as soon they will be approved by
7  * the European Commission - subsequent versions of the EUPL (the "Licence");
8  * You may not use this work except in compliance with the Licence.
9  * You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl5
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the Licence is distributed on an "AS IS" basis,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the Licence for the specific language governing
15  * permissions and limitations under the Licence.
16  */
24 #include "parex_protocol/SimTask.h"
25 
26 #include <QObject>
27 #include <QHostAddress>
28 #include <QTcpSocket>
29 #include <iostream>
30 
31 namespace SimPT_Parex {
32 
37 {
38  Q_OBJECT
39 public:
41  WorkerRepresentative(const QHostAddress &addr, quint16 port);
42 
44  WorkerRepresentative(const QHostAddress &addr, quint16 port, int taskId, std::string taskName);
45 
47  virtual ~WorkerRepresentative();
48 
50  const QHostAddress* GetSenderAddress() const;
51 
53  int GetSenderPort() const;
54 
56  std::string GetExplName() const;
57 
59  int GetTaskId() const;
60 
62  void StopTask();
63 
65  void Delete(const std::string name);
66 
67 signals:
69  void ReadyToWork();
70 
72  void FinishedWork(const SimResult&);
73 
75  void Disconnected();
76 
77 public slots:
79  void Setup();
80 
82  void DoWork(const SimTask&);
83 
84 private slots:
85  void Connected();
86  void Finished(const SimResult&);
87  void DisplayError(QAbstractSocket::SocketError error) const;
88  void DisplayError(const std::string &s) const;
89 
90 private:
91  void Init();
92 
93 private:
94  QHostAddress* m_addr;
95  quint16 m_port;
96  QTcpSocket* m_socket;
97  ServerNodeProtocol* m_protocol;
98  int m_currentTaskId;
99  std::string m_currentTaskName;
100 };
101 
102 } // namespace
103 
104 #endif // end-of-include-guard
void Setup()
Tries to connect to the worker and sets up the signals.
A container class for the final result of a simulation.
Definition: SimResult.h:29
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.
Interface for SimResult.
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.
Interface for SimTask.
std::string GetExplName() const
Gets the name current tasks' exploration.
Namespace for SimPT parameter explorer package.
Definition: Client.cpp:52
Contains all information needed for a transmitable simulation task.
Definition: SimTask.h:31
see the online Qt documentation
void Disconnected()
Emitted when the worker has disconnected.
A worker taken as representative for multiple workers (handles the communication with the node)...