HighLevelMain.cpp

00001 #include "HighLevelApi.h"
00002 #include "Configuration.h"
00003 #include "Sct/Exception.h"
00004 
00005 #include "sctConfIPC/configipc.h"
00006 #include "Sct/SctNames.h"
00007 
00008 #include <ipc/core.h>
00009 #include <ipc/object.h>
00010 #include <ipc/server.h>
00011 #include <pmg/pmg_initSync.h>
00012 
00013 #include <iostream>
00014 #include <boost/shared_ptr.hpp>
00015 
00016 using namespace std;
00017 using namespace boost;
00018 using namespace SctConfiguration;
00019 using namespace SctTest;
00020 
00021 IPCServer ipcServer;
00022 shared_ptr<SctConfiguration::Configuration> configServer;
00023 
00024 /* Obsolete:
00025  void pmgSynch(void *) {
00026     pmg_initSync();
00027 }
00028 */
00029 
00030 int main(int argc, char** argv) {
00031     Sct::setExceptionHandlers(argv[0]);
00032 
00033     IPCCore::init(argc,argv); // Try reentrant for DDC IS callbacks
00034     IPCPartition p(::Sct::SctNames::getPartitionName());
00035     //Obsolete: ?
00036     //ipcServer.reset(new IPCServer(SctTestApi_C_HighLevelApi_serverName, p));
00037 
00038     try {
00039         configServer = shared_ptr<SctConfiguration::Configuration>(new SctConfiguration::ConfigIPC());
00040         if (!HighLevelApi::instance().publish()) {
00041             cout << "Failed to publish HighLevelApi" << endl;
00042             return 3;
00043         }
00044 
00045         cout << "Serving...\n";
00046 
00047         // obsolete:
00048     //  ipcServer->doSoon(pmgSynch, NULL);
00049         pmg_initSync();
00050     ipcServer.run();
00051 
00052         cout << "Run over" << std::endl;
00053         HighLevelApi::instance().withdraw();
00054 
00055     } catch(SctConfiguration::ConfigurationException &c) {
00056         std::cout << "ConfigurationException: " << c.what() << std::endl;
00057 
00058         MRSStream mrsStream(p);
00059         mrsStream << "SctTestApi" << MRS_FATAL << MRS_QUALIF("SctTestApi") << MRS_TEXT("Configuration server not running!") << ENDM;
00060 
00061         exit(1);
00062     }
00063 }

Generated on Mon Feb 6 14:01:21 2006 for SCT DAQ/DCS Software - C++ by  doxygen 1.4.6