// // This provides some python-callable C routines so // the hdmongui.py script can access cMsg. // #include #include #include using namespace std; #include "jc_cmsg.h" extern "C" { void Init_cMsg(const char *udl); void Quit_cMsg(void); void ListRemoteProcesses(void); void GetRemoteProcesses(double max_time, NodeInfo_t *nodes, unsigned int &Nnodes); void GetCommandLine(const char *name, char *cmd, unsigned int len); void GetSource(const char *name, char *src, unsigned int len); void TestCall(NodeInfo_t &nodeInfo); void QuitNode(const char *node); void KillNode(const char *node); } //--------------------- // Init_cMsg //--------------------- void Init_cMsg(const char *udl) { const char *descr = "Hall-D Data Monitoring Nodes"; // Create a unique name for ourself char hostname[256]; gethostname(hostname, 256); for(int i=0; i<256; i++) if(hostname[i] == '.'){ hostname[i] = 0; break; } char name[512]; sprintf(name, "hdmongui_%s_%d", hostname, getpid()); new jc_cmsg(udl, name, descr); // (automatically sets JC_CMSG global) } //--------------------- // Quit_cMsg //--------------------- void Quit_cMsg(void) { if(JC_CMSG){ cout << "Disconnecting from cMsg system ..." << endl; delete JC_CMSG; } } //--------------------- // ListRemoteProcesses //--------------------- void ListRemoteProcesses(void) { if(JC_CMSG) JC_CMSG->ListRemoteProcesses(); } //--------------------- // GetRemoteProcesses //--------------------- void GetRemoteProcesses(double max_time, NodeInfo_t *nodes, unsigned int &Nnodes) { if(JC_CMSG){ JC_CMSG->GetRemoteProcesses(max_time,nodes, Nnodes); }else{ Nnodes = 0; } } //--------------------- // GetCommandLine //--------------------- void GetCommandLine(const char *name, char *cmd, unsigned int len) { if(JC_CMSG) JC_CMSG->GetCommandLine(name, cmd, len); } //--------------------- // GetSource //--------------------- void GetSource(const char *name, char *src, unsigned int len) { if(JC_CMSG) JC_CMSG->GetSource(name, src, len); } //--------------------- // QuitNode //--------------------- void QuitNode(const char *node) { if(JC_CMSG) JC_CMSG->QuitNode(node); } //--------------------- // KillNode //--------------------- void KillNode(const char *node) { if(JC_CMSG) JC_CMSG->KillNode(node); } //--------------------- // TestCall //--------------------- void TestCall(NodeInfo_t &nodeInfo) { cout << "&nodeInfo="<<&nodeInfo<