00001 #include "Fitter.h"
00002 #include "Sct/SctNames.h"
00003 #include "Sct/IpcObjectException.h"
00004 #include "FitterI.hh"
00005 #include <mrs/message.h>
00006 #include <ipc/core.h>
00007 #include <pmg/pmg_initSync.h>
00008
00009 using namespace Sct;
00010
00017 int findOther(const char*const partition, const char*const sid,
00018 const char*const cid, const char*const inputServerName) {
00019 IPCPartition p(partition);
00020 IPCServerIterator list( p, 0 );
00021
00022 IPCObjectVar<FitterI_T_FitterInterface> handle;
00023
00024 while ( list() ){
00025 if ( list.name()==string(sid) && list.context()==string(cid) ) {
00026 std::ostringstream txt;
00027 txt << "Server already exists in partition " << partition
00028 << " in context " << list.context()
00029 << " with name " << list.name();
00030 SctNames::Mrs() << MRS_TEXT(txt.str().c_str()) << MRS_INFORMATION << MRS_QUALIF("FITTER")
00031 << "PROCESS_DIED" << ENDM;
00032 return 1;
00033 }
00034
00035 handle = p.lookup( list.name(), list.context(),
00036 FitterI_T_FitterInterface::ILUClassRecord, false) ;
00037 if ( handle ){
00038 FitterIStatus s;
00039 s.returnCode=0;
00040 if (string( handle->getInputServerName(&s) ) == string (inputServerName) ) {
00041 std::ostringstream txt;
00042 txt << "Fitter already exists subscribing to the input server:"
00043 << inputServerName << ":";
00044 SctNames::Mrs() << "`" << list.name() << ":" << list.context() << "'"
00045 << MRS_TEXT(txt.str().c_str()) << MRS_INFORMATION << MRS_QUALIF("FITTER")
00046 << "PROCESS_DIED" << ENDM;
00047 return 2;
00048 }
00049 }
00050 }
00051 return 0;
00052 }
00053
00054 void pmgSynch(void *) {
00055 pmg_initSync();
00056 }
00057
00064 int main(int argc, char** argv) throw (){
00065 using namespace SctFitter;
00066 using namespace std;
00067
00068 setExceptionHandlers(argv[0]);
00069
00070 bool multiThreaded = true;
00071 IPCCore::init(multiThreaded);
00072
00073 try{
00074
00075 Fitter& f = Fitter::initialize();
00076
00077
00078
00079 try{
00080 f.setFitStrategy("NagFitStrategy");
00081 }
00082 catch(LogicError& e){
00083
00084 }
00085
00086 f.setFitOptions("NQR");
00087 if (!f.publish()){
00088 throw IpcObjectException("FittingService failed to publish", __FILE__, __LINE__);
00089 }
00090
00091
00092 f.go(1);
00093
00094 Fitter::getFitterServer().doSoon(pmgSynch, NULL);
00095 Fitter::getFitterServer().run();
00096 }
00097 catch (Throwable& e){e.sendToMrs(MRS_ERROR) ; terminate(); }
00098 }