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 "Sct_SctApi/SctApiCrateServer.h"
00007 #include "sctConfIPC/configipc.h"
00008 #include "SctApi/Idiosyncrasy.h"
00009 
00010 #include <ipc/core.h>
00011 #include <ipc/object.h>
00012 #include <ipc/server.h>
00013 #include <pmg/pmg_initSync.h>
00014 #include <Sct/Addressing.h>
00015 
00016 #include <iostream>
00017 #include <boost/shared_ptr.hpp>
00018 
00019 using namespace std;
00020 using namespace boost;
00021 using namespace SctConfiguration;
00022 using namespace SctTest;
00023 
00024 IPCServer ipcServer;
00025 shared_ptr<SctConfiguration::Configuration> configServer;
00026 
00027 /*
00028  Obsolete:
00029   void pmgSynch(void *) {
00030     pmg_initSync();
00031 }
00032 */
00033 
00034 int main(int argc, char** argv) {
00035     Sct::setExceptionHandlers(argv[0]);
00036 
00037     IPCCore::init(argc,argv);
00038     IPCPartition p("SCT");
00039     // Obsolete: ipcServer.reset(new IPCServer(Sct_SctApi_C_SctApi_serverName, p));
00040 
00041     try {
00042         //For some reason these 2 lines don't work - really strange bug...so use default constructor trick
00043         //configServer.reset(new ConfigIPC());
00044         //auto_ptr<TestApi> api(new TestApi(configServer));
00045     const Sct::UCID arbitraryUcid(0,0);
00046         SctApi::Idiosyncrasy id(arbitraryUcid);
00047 
00048         auto_ptr<TestApi> api(new TestApi(id));
00049 
00050         if (!SctTest::Configuration::instance().publish()) {
00051             cout << "Failed to publish Configuration" << endl;
00052             return 2;
00053         }
00054 
00055 //        if (!HighLevelApi::instance().publish()) {
00056 //            cout << "Failed to publish HighLevelApi" << endl;
00057 //            return 3;
00058 //        }
00059     
00060         auto_ptr<SctApiCrateServer> h2(new SctApiCrateServer(*api)); // probably this should be updated to be a "_destroy"ing deleter.
00061     
00062     SctApiServer::CrateDescriptors d; d.push_back(arbitraryUcid);
00063         auto_ptr<SctApiServer> h(new SctApiServer(d, Sct_SctApi::SctApiIPC::instanceName)); // probably this should be updated to be a "_destroy"ing deleter.
00064 
00065         // Try publishing it
00066         if (!h->publish()) {
00067             cout << "Failed to publish SctTestApi" << std::endl;
00068             return 2;
00069         }
00070 
00071         cout << "Serving...\n";
00072 
00073     // Obsolete:       ipcServer->doSoon(pmgSynch, NULL);
00074     pmg_initSync();
00075     ipcServer.run();
00076 
00077         cout << "Run over" << std::endl;
00078         h->withdraw();
00079         SctTest::Configuration::instance().withdraw();
00080 //        HighLevelApi::instance().withdraw();
00081 
00082     } catch(SctConfiguration::ConfigurationException &c) {
00083         std::cout << "ConfigurationException: " << c.what() << std::endl;
00084 
00085         MRSStream mrsStream(p);
00086         mrsStream << "SctTestApi" << MRS_FATAL << MRS_QUALIF("SctTestApi") << MRS_TEXT("Configuration server not running!") << ENDM;
00087 
00088         exit(1);
00089     }
00090 }

Generated on Fri Sep 16 18:01:58 2005 for SCT DAQ/DCS Software - C++ by doxygen 1.3.5