Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "Simulator.h"
00010
00011 #include <stdlib.h>
00012 #include <stdio.h>
00013 #include <string.h>
00014
00015 int main(int argc, char* argv[])
00016 {
00017 printf("ROC simulator, v.2.0. Usage:\n");
00018 printf("rocsimul rocNum [-lost lostRate] [-sync syncScale] [-aux0 period0] [-aux1 period1] [-port ctrlPort]\n");
00019 printf(" lostRate : relative artificial 'lost' of inp/out packets\n");
00020 printf(" syncScale : scale down factor of for sync messages - should be 0, 1, 2, .., 31\n");
00021 printf(" period0 : period of AUX0 signal in ns, -1 disable AUX0\n");
00022 printf(" period1 : period of AUX1 signal in ns, -1 disable AUX1\n");
00023 printf(" ctrlPort : port number for communication, default is 13132\n");
00024
00025 int rocNum(0), syncscale(2), period0(0), period1(0), ctrlport(0);
00026 double lostRate(0.);
00027
00028 if (argc>1) rocNum = atoi(argv[1]);
00029
00030 int cnt = 2;
00031 while (cnt<argc) {
00032 if (strcmp(argv[cnt],"-lost")==0) {
00033 if (++cnt < argc) lostRate = atof(argv[cnt]);
00034 } else
00035 if (strcmp(argv[cnt],"-sync")==0) {
00036 if (++cnt < argc) syncscale = atoi(argv[cnt]);
00037 } else
00038 if (strcmp(argv[cnt],"-aux0")==0) {
00039 if (++cnt < argc) period0 = atoi(argv[cnt]);
00040 } else
00041 if (strcmp(argv[cnt],"-aux1")==0) {
00042 if (++cnt < argc) period1 = atoi(argv[cnt]);
00043 } else
00044 if (strcmp(argv[cnt],"-port")==0) {
00045 if (++cnt < argc) ctrlport = atoi(argv[cnt]);
00046 }
00047
00048 cnt++;
00049 }
00050
00051 printf("Apply rocNum:%d lostRate:%5.3f syncScale:%d", rocNum, lostRate, syncscale);
00052 if (period0>0) printf(" aux0 period:%d",period0);
00053 if (period1>0) printf(" aux1 period:%d",period1);
00054 if (ctrlport>0) printf(" port:%d",ctrlport);
00055 printf("\n");
00056 UdpSimulator simulator(rocNum, syncscale, period0, period1, ctrlport);
00057 simulator.setLostRates(lostRate, lostRate);
00058
00059 if (!simulator.initNewSockets()) return -1;
00060
00061 simulator.mainLoop();
00062
00063 return 0;
00064 }