1 : |
agomez |
1 |
#ifndef slavecommunication_h
|
2 : |
|
|
#define slavecommunication_h
|
3 : |
|
|
|
4 : |
|
|
#include "mpi.h"
|
5 : |
|
|
#include "netdata.h" |
6 : |
|
|
#include "pvmconstants.h" |
7 : |
|
|
#include "doublevector.h" |
8 : |
|
|
#include "parametervector.h" |
9 : |
|
|
|
10 : |
|
|
// AJ, 07.09.99
|
11 : |
|
|
/**
|
12 : |
|
|
* \class SlaveCommunication
|
13 : |
|
|
* \brief The class SlaveCommunication handles netcommunication for a slave process communicating with a master process using PVM. It provides functions for starting/stopping communication with master and sending/receiving data to/from master. The class can receive data of the type: NetDataVariables and CharPtrVector and send data of the type: NetDataResult. To successfully start netcommunication pvmd must be running on host and the process must have been spawned by a master process.
|
14 : |
|
|
*/
|
15 : |
|
|
|
16 : |
|
|
class SlaveCommunication {
|
17 : |
|
|
private:
|
18 : |
|
|
int MAXWAIT;
|
19 : |
|
|
PVMConstants* pvmConst;
|
20 : |
|
|
int typeReceived;
|
21 : |
|
|
//identities for netcommunication
|
22 : |
|
|
/**
|
23 : |
|
|
* \brief id of my master recognized by pvm.parenttid = -1 if has not started communications with master.
|
24 : |
|
|
*/
|
25 : |
|
|
int parenttid;
|
26 : |
|
|
/**
|
27 : |
|
|
* \brief id of myself recognized by pvm.mytid = -1 if has not enrolled in pvm else >= 0.
|
28 : |
|
|
*/
|
29 : |
|
|
int mytid;
|
30 : |
|
|
/**
|
31 : |
|
|
*\brief id recognized by master, equals -1 if has not started initial communication with master,
|
32 : |
|
|
*/
|
33 : |
|
|
int myID;
|
34 : |
|
|
|
35 : |
|
|
int numVar;
|
36 : |
|
|
NetDataVariables* netDataVar;
|
37 : |
|
|
DoubleVector netDataDouble;
|
38 : |
|
|
struct timeval tmout;
|
39 : |
|
|
ParameterVector netDataStr;
|
40 : |
|
|
|
41 : |
|
|
public:
|
42 : |
|
|
SlaveCommunication();
|
43 : |
|
|
~SlaveCommunication();
|
44 : |
|
|
void printErrorMsg(const char* errorMsg);
|
45 : |
|
|
int startNetCommunication();
|
46 : |
|
|
void stopNetCommunication();
|
47 : |
|
|
int receive();
|
48 : |
|
|
int receiveFromMaster();
|
49 : |
|
|
int send(NetDataResult* sendData);
|
50 : |
|
|
int sendToMaster(double res);
|
51 : |
|
|
int receivedVector();
|
52 : |
|
|
//void getVector(DoubleVector& vec);
|
53 : |
|
|
void getVector(double* vec);
|
54 : |
|
|
int getReceiveType();
|
55 : |
|
|
int receiveString();
|
56 : |
|
|
int receiveBound();
|
57 : |
|
|
int receivedString();
|
58 : |
|
|
int receivedBounds();
|
59 : |
|
|
//void getBound(DoubleVector& vec);
|
60 : |
|
|
void getBound(double* vec);
|
61 : |
|
|
const Parameter& getString(int num);
|
62 : |
|
|
const ParameterVector& getStringVector();
|
63 : |
|
|
};
|
64 : |
|
|
#endif
|