Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Related Pages

SctTestMain.cpp

00001 #include "TestApi.h"
00002 #include "Configuration.h"
00003 #include "Sct/Exception.h"
00004 
00005 #include "Sct_SctApi/SctApiServer.h"
00006 #include "sctConfIPC/configipc.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 /*
00025  Obsolete:
00026   void pmgSynch(void *) {
00027     pmg_initSync();
00028 }
00029 */
00030 
00031 int main(int argc, char** argv) {
00032     Sct::setExceptionHandlers(argv[0]);
00033 
00034     IPCCore::init(argc,argv);
00035     IPCPartition p("SCT");
00036     // Obsolete: ipcServer.reset(new IPCServer(Sct_SctApi_C_SctApi_serverName, p));
00037 
00038     try {
00039         //For some reason these 2 lines don't work - really strange bug...so use default constructor trick
00040         //configServer.reset(new ConfigIPC());
00041         //auto_ptr<TestApi> api(new TestApi(configServer));
00042         auto_ptr<TestApi> api(new TestApi());
00043 
00044         if (!SctTest::Configuration::instance().publish()) {
00045             cout << "Failed to publish Configuration" << endl;
00046             return 2;
00047         }
00048 
00049 //        if (!HighLevelApi::instance().publish()) {
00050 //            cout << "Failed to publish HighLevelApi" << endl;
00051 //            return 3;
00052 //        }
00053 
00054         auto_ptr<SctApiServer> h(new SctApiServer(*api, Sct_SctApi::SctApiIPC::instanceName));
00055 
00056         // Try publishing it
00057         if (!h->publish()) {
00058             cout << "Failed to publish SctTestApi" << std::endl;
00059             return 2;
00060         }
00061 
00062         cout << "Serving...\n";
00063 
00064     // Obsolete:       ipcServer->doSoon(pmgSynch, NULL);
00065     pmg_initSync();
00066     ipcServer.run();
00067 
00068         cout << "Run over" << std::endl;
00069         h->withdraw();
00070         SctTest::Configuration::instance().withdraw();
00071 //        HighLevelApi::instance().withdraw();
00072 
00073     } catch(SctConfiguration::ConfigurationException &c) {
00074         std::cout << "ConfigurationException: " << c.what() << std::endl;
00075 
00076         MRSStream mrsStream(p);
00077         mrsStream << "SctTestApi" << MRS_FATAL << MRS_QUALIF("SctTestApi") << MRS_TEXT("Configuration server not running!") << ENDM;
00078 
00079         exit(1);
00080     }
00081 }

Generated on Thu Feb 10 02:40:16 2005 for SCT DAQ/DCS Software - C++ by doxygen 1.3.5