ToolDAQFramework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
MyToolServiceAdd.cpp
Go to the documentation of this file.
1 #include "MyToolServiceAdd.h"
2 
4 
5 
6 bool MyToolServiceAdd::Initialise(std::string configfile, DataModel &data){
7 
8  if(configfile!="") m_variables.Initialise(configfile);
9  //m_variables.Print();
10 
11  m_data= &data;
12  m_log= m_data->Log;
13 
14  if(!m_variables.Get("verbose",m_verbose)) m_verbose=1;
15  if(!m_variables.Get("Port",m_port)) m_port=5555;
16 
17  m_util=new Utilities(m_data->context);
18 
19  sock = new zmq::socket_t(*(m_data->context), ZMQ_DEALER);
20 
21  std::stringstream tmp;
22  tmp<<"tcp://*:"<<m_port;
23 
24  sock->bind(tmp.str().c_str());
25 
26  if (!m_util->AddService("MyService",m_port,false)) return false;
27 
28  return true;
29 }
30 
31 
33 
34  return true;
35 }
36 
37 
39 
40  bool ret=m_util->RemoveService("MyService");
41 
42  delete sock;
43  sock=0;
44 
45  if(!ret) return false;
46 
47  return true;
48 }
bool Execute()
Executre function used to perform Tool perpose.
Utilities * m_util
Pointer to utilities class to help with threading.
bool AddService(std::string ServiceName, unsigned int port, bool StatusQuery=false)
Broadcasts an available service (only in remote mode)
Definition: Utilities.cpp:8
bool Initialise(std::string configfile, DataModel &data)
Initialise Function for setting up Tool resorces.
int m_port
Port to advertise.
Logging * Log
Log class pointer for use in Tools, it can be used to send messages which can have multiple error lev...
Definition: DataModel.h:60
zmq::socket_t * sock
zmq socket pointer for socket to advertise
MyToolServiceAdd()
Simple constructor.
bool Finalise()
Finalise funciton used to clean up resorces.
bool RemoveService(std::string ServiceName)
Removes service broadcasts for a service.
Definition: Utilities.cpp:28