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
00008 using namespace Sct;
00009
00016 int findOther(const char*const partition, const char*const sid,
00017 const char*const cid, const char*const inputServerName) {
00018 IPCPartition p(partition);
00019 IPCServerIterator list( p, 0 );
00020
00021 IPCObjectVar<FitterI_T_FitterInterface> handle;
00022
00023 while ( list() ){
00024 if ( list.name()==string(sid) && list.context()==string(cid) ) {
00025 std::ostringstream txt;
00026 txt << "Server already exists in partition " << partition
00027 << " in context " << list.context()
00028 << " with name " << list.name();
00029 SctNames::Mrs() << MRS_TEXT(txt.str().c_str()) << MRS_INFORMATION << MRS_QUALIF("FITTER")
00030 << "PROCESS_DIED" << ENDM;
00031 return 1;
00032 }
00033
00034 handle = p.lookup( list.name(), list.context(),
00035 FitterI_T_FitterInterface::ILUClassRecord, false) ;
00036 if ( handle ){
00037 FitterIStatus s;
00038 s.returnCode=0;
00039 if (string( handle->ipcGetInputServerName(&s) ) == string (inputServerName) ) {
00040 std::ostringstream txt;
00041 txt << "Fitter already exists subscribing to the input server:"
00042 << inputServerName << ":";
00043 SctNames::Mrs() << "`" << list.name() << ":" << list.context() << "'"
00044 << MRS_TEXT(txt.str().c_str()) << MRS_INFORMATION << MRS_QUALIF("FITTER")
00045 << "PROCESS_DIED" << ENDM;
00046 return 2;
00047 }
00048 }
00049 }
00050 return 0;
00051 }
00052
00059 int main(int argc, char** argv) throw (){
00060 using namespace SctFitter;
00061 using namespace std;
00062
00063 setExceptionHandlers(argv[0]);
00064
00065 bool multiThreaded = false;
00066 IPCCore::init(multiThreaded);
00067
00068 try{
00069
00070 Fitter& f = Fitter::initialize();
00071
00072
00073
00074 try{
00075 f.setFitStrategy("NagFitStrategy");
00076 }
00077 catch(LogicError& e){
00078
00079 }
00080
00081 f.setFitOptions("NQR");
00082 if (!f.publish()){
00083 throw IpcObjectException("FittingService failed to publish", __FILE__, __LINE__);
00084 }
00085
00086
00087 f.go(1);
00088
00089 Fitter::getFitterServer().run();
00090 }
00091 catch (Throwable& e){e.sendToMrs(MRS_ERROR) ; terminate(); }
00092 }