/********************************************************************** * Project Name: Fix Engine * * Program Name: fix_receiver.cpp * * Auther : Changpeng Yu * * Date : 03/24/2008 * * * * Copyright @ 2008 FT Computer Solutions * * * * Date Name PNO Description * * ------------------------------------------------------------------- * * 03/24/08 Changpeng Yu Create program module * * 12/20/12 Changpeng Yu Improvement for Release 8 * ****************************************#*****************************/ #include #include #include #include #include #include #include #include using namespace std; #include "../inc/Common.h" #include "../inc/Shm.h" #include "../inc/MsgQueue.h" int main(int argc, char *argv[]) { if (argc < 3) { cout << "Usage: fix_receiver shm mq site [mtype]\n" << endl; exit(-1); } try { string shm_name(argv[1]); Shm shm(shm_name); Cell *cell; string site; if (argc > 2) { site = argv[2]; cell = shm.getCell(site); } else { cell = shm.getCell(0); site = cell->name; } int mtype = 0; if (argc > 3) mtype = atoi(argv[4]); string mq_name(argv[2]); mq_name += ".i"; MsgQueue *mq = new MsgQueue(mq_name, mtype); string msg; for (;;) { msg = mq->read(mtype); cell->In.pend--; cell->In.proc++; for (unsigned int i = 0; i < msg.length(); i++) { if (msg.at(i) == Soh) cout << ""; else cout << msg.at(i); } cout << "\n" << endl; } } catch (ShmException &me) { cerr << me.what() << "\n" << endl; exit (-1); } catch (MQException &e) { cerr << e.what() << "\n" << endl; exit (-1); }; return 0; }