Changeset 78 in tmcsimulator for branches


Ignore:
Timestamp:
10/01/2017 05:50:44 PM (9 years ago)
Author:
jtorres
Message:

All green dots are showing. This is a checkpoint before adding dynamic data packing.

Location:
branches/fep_rpc_client
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/fep_rpc_client/FEPClient.cpp

    r77 r78  
    8787 
    8888                /* for each LDS in the Line.... (constructs the short_answer message) */ 
    89                 for (j = 0; j < lines.at(i).ldsNum; j++) 
     89                for (j = 0; j < lines.at(i).lds.size(); j++) 
    9090                { 
    91                     cout << "Station num " << j << endl; 
    9291                        fep_shortanswer fsa; 
    93                         int index = lines.at(i).ldsIndex[j]; 
    94  
     92                        int index = lines.at(i).ldsIndex.at(j); 
     93                        cout << "LDS index: " << index << endl; 
    9594                        // msg: oa, od, ldsMap.at(index).dataPack, od, ff 
    9695                        fsa.msg.message_len = ldsMap.at(index).length + 2; 
     
    136135        /* Create RPC Client to communicate with ATMS */ 
    137136        cout << "Creating RPC Client" << endl; 
    138         clnt = clnt_create(host, 100090, /*103121,*/ 32, "tcp"); 
     137        clnt = clnt_create(host, /*100090,*/ 103121, 32, "tcp"); 
    139138        cout << "Client created" << endl; 
    140139        /* Check if client creation failed */ 
  • branches/fep_rpc_client/NetworkReader.cpp

    r77 r78  
    11#include "NetworkReader.h" 
     2 
    23/** 
    34 * Constructor 
    45 * @param networkFileName input xml file 
    56 */ 
    6 NetworkReader::NetworkReader(const char * networkFileName) 
    7 { 
     7NetworkReader::NetworkReader(const char * networkFileName) { 
    88    ldsIndex = 0; 
    99    loadLines(networkFileName); 
     
    1717 * @return the new station 
    1818 */ 
    19 LDS_LOOP NetworkReader::parseStation(TiXmlElement *stationElem, FEP_LINE line) 
    20 { 
     19LDS_LOOP NetworkReader::parseStation(TiXmlElement *stationElem, FEP_LINE *line) { 
    2120    LDS_LOOP station; 
    22      
     21 
    2322    TiXmlElement *stationSubElem = stationElem->FirstChildElement(); 
    2423    cout << "Station id: " << stationSubElem->GetText() << endl; 
    2524    station.lds = atol(stationSubElem->GetText()); 
    26     line.lds.push_back(station.lds); 
    27     line.ldsIndex.push_back(ldsIndex++); 
     25    line->lds.push_back(station.lds); 
     26    line->ldsIndex.push_back(ldsIndex++); 
    2827    stationSubElem = stationSubElem->NextSiblingElement(); 
    2928    station.line_num = atoi(stationSubElem->GetText()); 
     
    4241    // Add loops to station 
    4342    TiXmlElement *loopsElem = stationSubElem->NextSiblingElement(); 
    44     TiXmlElement *loopElem = loopsElem->FirstChildElement();  
     43    TiXmlElement *loopElem = loopsElem->FirstChildElement(); 
    4544    TiXmlElement *saveLoopElem = loopElem; 
    4645    // get number of loops in station and assign to station.num 
    4746    station.num = 0; 
    48     for(loopElem; loopElem; loopElem = loopElem->NextSiblingElement()) 
    49     { 
     47    for (loopElem; loopElem; loopElem = loopElem->NextSiblingElement()) { 
    5048        station.num += 1; 
    5149    } 
    52      
     50 
    5351    // get loopIDS and locations 
    5452    long int loopIDS[station.num]; 
    5553    char * loopLocs[station.num]; 
    5654    int index = 0; 
    57     for(saveLoopElem; saveLoopElem; saveLoopElem = saveLoopElem->NextSiblingElement() ) 
    58     { 
     55    for (saveLoopElem; saveLoopElem; saveLoopElem = saveLoopElem->NextSiblingElement()) { 
    5956        TiXmlElement *subLoopElem = saveLoopElem->FirstChildElement(); 
    6057        loopIDS[index] = atoi(subLoopElem->GetText()); 
     
    6764    // Data pack ATMS message 
    6865    station.length = station.num * 2 + CONTROL_DATA_LEN; 
    69     station.dataPack = msgDataPack(station); 
    70      
    71     return station; 
    72 } 
    73  
    74 /** 
    75  * Parses a "Line" xml element into an FEP_LINE 
    76  * @param lineElem the xml element 
    77  * @return FEP_LINE 
     66    station.dataPack = staticDataPack(station); 
     67/* 
     68    // fill in dynamic data to dataPack[] 
     69    for (i = 0; i < g_ldsNum; i++) { 
     70        // Loop detector data  
     71        int pos = 26; 
     72        pos = pp_data_packing(i, 5, pos); 
     73        pos = pp_data_packing(i, 6, pos); 
     74        pos = pp_data_packing(i, 7, pos); 
     75        pos = pp_data_packing(i, 8, pos); 
     76 
     77        // Update data for BYTE 9, 16, 21, 22, 23, 24 
     78 
     79        // what is the current metering rate? 
     80        // check each LDS, if there is demand detector, the downstream node the 
     81        // ldsMap[i].dataPack[22-1] = ldsMap[i].dataPack[9-1] = ; 
     82 
     83        // will need to check if queue override is enabled (Currently, no queue 
     84        // ldsMap[i].dataPack[16-1] = ; 
     85 
     86        // byte 23: MAINLINE total volume 
     87        ldsMap[i].dataPack[23 - 1] = ldsMap[i].MlTotVol; 
     88 
     89        // byte 24: opposite total volume 
     90        ldsMap[i].dataPack[24 - 1] = ldsMap[i].OppTotVol; 
     91 
     92        // last BYTE: checksum  
     93        ldsMap[i].dataPack[ldsMap[i].length - 1] = 
     94                chksum(ldsMap[i].dataPack, ldsMap[i].length - 1 - 1); 
     95 
     96        // print out 
     97        // print out 
     98        for (j = 0; j < ldsMap[i].length; j++) { 
     99            fprintf(fi_lds, "%02X", ldsMap[i].dataPack[j]); 
     100        } 
     101        fprintf(fi_lds, "\n"); 
     102        fflush(fi_lds); 
     103*/ 
     104 
     105        return station; 
     106    } 
     107 
     108    /** 
     109     * Parses a "Line" xml element into an FEP_LINE 
     110     * @param lineElem the xml element 
     111     * @return FEP_LINE 
     112     */ 
     113    FEP_LINE NetworkReader::parseLine(TiXmlElement * lineElem) { 
     114        FEP_LINE line; 
     115        TiXmlElement *lineSubElem = lineElem->FirstChildElement(); 
     116        line.lineNum = atoi(lineSubElem->GetText()); 
     117        cout << "Line: " << line.lineNum << endl; 
     118        lineSubElem = lineSubElem->NextSiblingElement(); 
     119        line.count = atoi(lineSubElem->GetText()); 
     120        lineSubElem = lineSubElem->NextSiblingElement(); 
     121        line.schedule = atoi(lineSubElem->GetText()); 
     122        lineSubElem = lineSubElem->NextSiblingElement(); 
     123        line.lineInfo = atoi(lineSubElem->GetText()); 
     124        lineSubElem = lineSubElem->NextSiblingElement(); 
     125        line.systemKey = atol(lineSubElem->GetText()); 
     126        lineSubElem = lineSubElem->NextSiblingElement(); 
     127        line.globalSeq = atol(lineSubElem->GetText()); 
     128        lineSubElem = lineSubElem->NextSiblingElement(); 
     129        line.schedleSeq = atol(lineSubElem->GetText()); 
     130 
     131        TiXmlElement *stationsElem = lineSubElem->NextSiblingElement(); 
     132        TiXmlElement *stationElem = stationsElem->FirstChildElement(); 
     133        for (stationElem; stationElem; stationElem = stationElem->NextSiblingElement()) { 
     134            stations.push_back(parseStation(stationElem, &line)); 
     135        } 
     136        return line; 
     137    } 
     138 
     139    /** 
     140     * Loads FEPLines from a specified xml file 
     141     * @param networkFileName the input xml file 
     142     */ 
     143    void NetworkReader::loadLines(const char * networkFileName) { 
     144        // Load network xml file 
     145        TiXmlDocument doc(networkFileName); 
     146        if (!doc.LoadFile()) { 
     147            cerr << "TiXmlDocument did not load network file..." << endl; 
     148            return; 
     149        } 
     150 
     151        // grab <Network> element 
     152        TiXmlHandle hDoc(&doc); 
     153        TiXmlElement *networkElem = hDoc.FirstChildElement().Element(); 
     154 
     155        // grab first <Line> element 
     156        TiXmlElement *lineElem = networkElem->FirstChildElement(); 
     157 
     158        // iterate through each line element to create FEP_LINE list 
     159        for (lineElem; lineElem; lineElem = lineElem->NextSiblingElement()) { 
     160            lines.push_back(parseLine(lineElem)); 
     161        } 
     162    } 
     163 
     164    // determine if a loop has data based on lane config data 
     165 
     166    bool NetworkReader::DataAvail(char flag, int num) { 
     167        int mag, fel; 
     168 
     169        // find mask value 
     170        if (num == 1) 
     171            mag = 0x01; 
     172        else if (num == 2) 
     173            mag = 0x02; 
     174        else if (num == 3) 
     175            mag = 0x04; 
     176        else if (num == 4) 
     177            mag = 0x08; 
     178        else if (num == 5) 
     179            mag = 0x10; 
     180        else if (num == 6) 
     181            mag = 0x20; 
     182        else if (num == 7) 
     183            mag = 0x40; 
     184        else if (num == 8) 
     185            mag = 0x80; 
     186 
     187        fel = flag & mag; 
     188        fel = fel >> (num - 1); 
     189 
     190        if (fel == 1) 
     191            return true; 
     192        else 
     193            return false; 
     194    } 
     195/* 
     196    int pp_data_packing(int index, int packNo, int pos) { 
     197        int i, j, k, vol, occ, lane, haveData; 
     198        LOOPAGG in; 
     199        DETECTOR *aaa; 
     200        VOLOCC bbb; 
     201        long loop; 
     202 
     203        i = index; 
     204 
     205        //used for data byte 23 and 24 
     206        ldsMap[i].MlTotVol = 0; 
     207        ldsMap[i].OppTotVol = 0; 
     208 
     209        for (j = 1; j <= 8; j++) { 
     210            if (DataAvail(ldsMap[i].dataPack[packNo - 1], j)) { 
     211                // loop at bit j has data 
     212                for (k = 0; k < ldsMap[i].num; k++) { 
     213                    // what's the corresponding loop of bit j 
     214                    if (packNo == 5) 
     215                        haveData = strcmp(ldsMap[i].loop_loc[k], dp5[j - 1]); 
     216                    else if (packNo == 6) 
     217                        haveData = strcmp(ldsMap[i].loop_loc[k], dp6[j - 1]); 
     218                    else if (packNo == 7) 
     219                        haveData = strcmp(ldsMap[i].loop_loc[k], dp7[j - 1]); 
     220                    else if (packNo == 8) 
     221                        haveData = strcmp(ldsMap[i].loop_loc[k], dp8[j - 1]); 
     222                    else 
     223                        return -1; 
     224 
     225                    if (haveData == 0) { 
     226                        loop = ldsMap[i].loopID[k]; 
     227                        if (strcmp(chu[loop].paramicsName, "?") == 0) { 
     228                            { 
     229                                vol = 0; 
     230                                occ = 900; 
     231                            } else { 
     232                                aaa = qpg_NET_detector(chu[loop].paramicsName); 
     233                                Bool status = uci_loop_aggregation(qpg_DTC_index(aaa), POLLING 
     234                                if (status) { 
     235                                    if (chu[loop].paramicsLane == 0) 
     236                                            lane = 0; 
     237                                    else 
     238                                        lane = chu[loop].paramicsLane - 1; 
     239                                            vol = in.vol[lane]; 
     240                                            occ = (int) (in.occ[lane] * 900 + 0.5); 
     241                                            //                   qps_GUI_printf("%d(%s), lane=%d, vol=%d(%d), occ=%.3f(%.3f, 
     242                                            //                      qpg_DTC_index(aaa), chu[loop].paramicsName, in.lane, in. 
     243                                            //                      vol, in.g_occ, in.occ[lane], occ); 
     244                                    } else 
     245                                    qps_GUI_printf("Data query error for %s\n", chu[loop].param 
     246                                } 
     247 
     248                            bbb = pp_vol_occ_word(vol, occ); 
     249                                    pos++; 
     250                                    ldsMap[i].dataPack[pos - 1] = bbb.high; 
     251                                    pos++; 
     252                                    ldsMap[i].dataPack[pos - 1] = bbb.low; 
     253 
     254                            if (packNo == 5) { 
     255                                ldsMap[i].MlTotVol += vol; 
     256                            } else if (packNo == 6) { 
     257 
     258                                ldsMap[i].OppTotVol += vol; 
     259                            } 
     260 
     261                            fprintf(fi_lds, "lds=%d, loop=%d, paramics=%s, lane=%d, vol=%d(%X 
     262                                    ldsMap[i].lds, loop, chu[loop].paramicsName, chu[loop].paramic 
     263                                    bbb.high, occ, bbb.low); 
     264                                    fflush(fi_lds); 
     265                        } 
     266                    } 
     267                } 
     268            } 
     269 
     270            return pos; 
     271        } 
    78272 */ 
    79 FEP_LINE NetworkReader::parseLine(TiXmlElement *lineElem) 
    80 { 
    81     FEP_LINE line; 
    82     TiXmlElement *lineSubElem = lineElem->FirstChildElement(); 
    83     line.lineNum = atoi(lineSubElem->GetText()); 
    84     cout << "Line: " << line.lineNum << endl; 
    85     lineSubElem = lineSubElem->NextSiblingElement(); 
    86     line.count = atoi(lineSubElem->GetText()); 
    87     lineSubElem = lineSubElem->NextSiblingElement(); 
    88     line.schedule = atoi(lineSubElem->GetText()); 
    89     lineSubElem = lineSubElem->NextSiblingElement(); 
    90     line.lineInfo = atoi(lineSubElem->GetText()); 
    91     lineSubElem = lineSubElem->NextSiblingElement(); 
    92     line.systemKey = atol(lineSubElem->GetText()); 
    93     lineSubElem = lineSubElem->NextSiblingElement(); 
    94     line.globalSeq = atol(lineSubElem->GetText()); 
    95     lineSubElem = lineSubElem->NextSiblingElement(); 
    96     line.schedleSeq = atol(lineSubElem->GetText()); 
    97  
    98     TiXmlElement *stationsElem = lineSubElem->NextSiblingElement(); 
    99     TiXmlElement *stationElem = stationsElem->FirstChildElement(); 
    100     for(stationElem; stationElem; stationElem = stationElem->NextSiblingElement()) 
    101     { 
    102         stations.push_back(parseStation(stationElem, line)); 
    103     } 
    104     return line; 
    105 } 
    106  
    107 /** 
    108  * Loads FEPLines from a specified xml file 
    109  * @param networkFileName the input xml file 
    110  */ 
    111 void NetworkReader::loadLines(const char * networkFileName) 
    112 { 
    113     // Load network xml file 
    114     TiXmlDocument doc(networkFileName); 
    115     if(!doc.LoadFile()) 
    116     { 
    117         cerr << "TiXmlDocument did not load network file..." << endl; 
    118         return; 
    119     } 
    120  
    121     // grab <Network> element 
    122     TiXmlHandle hDoc(&doc); 
    123     TiXmlElement *networkElem = hDoc.FirstChildElement().Element(); 
    124  
    125     // grab first <Line> element 
    126     TiXmlElement *lineElem = networkElem->FirstChildElement(); 
    127  
    128     // iterate through each line element to create FEP_LINE list 
    129     for(lineElem; lineElem; lineElem=lineElem->NextSiblingElement()) 
    130     { 
    131         lines.push_back(parseLine(lineElem)); 
    132     } 
    133 } 
    134  
    135 // determine if a loop has data based on lane config data 
    136 bool NetworkReader::DataAvail(char flag, int num) 
    137 { 
    138         int mag, fel; 
    139  
    140         // find mask value 
    141         if (num == 1) 
    142                 mag = 0x01; 
    143         else if (num == 2) 
    144                 mag = 0x02; 
    145         else if (num == 3) 
    146                 mag = 0x04; 
    147         else if (num == 4) 
    148                 mag = 0x08; 
    149         else if (num == 5) 
    150                 mag = 0x10; 
    151         else if (num == 6) 
    152                 mag = 0x20; 
    153         else if (num == 7) 
    154                 mag = 0x40; 
    155         else if (num == 8) 
    156                 mag = 0x80; 
    157  
    158         fel = flag & mag; 
    159         fel = fel >> (num - 1); 
    160  
    161         if (fel == 1) 
    162                 return true; 
    163         else 
    164                 return false; 
    165 } 
    166  
    167 // Initializes the LDS_LOOP dataPack with all necessary static data and default dynamic data 
    168 unsigned char * NetworkReader::msgDataPack(LDS_LOOP loop) 
    169 { 
    170         int j; 
    171         // Allocate memory for dataPack 
    172         unsigned char *dataPack = (unsigned char *) malloc(sizeof(unsigned char) * loop.length); 
    173  
    174         // dataPack 5-8: lane config 
    175         char d5 = 0, d6 = 0, d7 = 0, d8 = 0; 
    176         for (j = 0; j < loop.num; j++) 
    177         { 
    178                 for (int k = 0; k < 8; k++) 
    179                 { 
    180                         if (strcmp(loop.loop_loc[j], dp5[k]) == 0) 
    181                                 d5 += pow(2, k); 
    182                         if (strcmp(loop.loop_loc[j], dp6[k]) == 0) 
    183                                 d6 += pow(2, k); 
    184                         if (strcmp(loop.loop_loc[j], dp7[k]) == 0) 
    185                                 d7 += pow(2, k); 
    186                         if (strcmp(loop.loop_loc[j], dp8[k]) == 0) 
    187                                 d8 += pow(2, k); 
    188                 } 
    189         } 
    190         dataPack[5-1] = d5; 
    191         dataPack[6-1] = d6; 
    192         dataPack[7-1] = d7; 
    193         dataPack[8-1] = d8; 
    194  
    195         // dataPack 1: Drop number, i.e. station address 
    196         dataPack[1-1] = loop.drop; 
    197  
    198         // dataPack2 (2 bytes per loop) 
    199         dataPack[2-1] = loop.num * 2 + Fixed_Byte_To_Checksum; 
    200  
    201         // dataPacket 3 (lowbyte: # of mainline loops, highbyte: # of opposite loops) 
    202         int low = 0, high = 0; 
    203         for (j = 1; j <= 6; j++) 
    204         { 
    205                 low += DataAvail(dataPack[5-1], j); 
    206                 high += DataAvail(dataPack[6-1], j); 
    207         } 
    208         high = high << 4; 
    209         dataPack[3-1] = high | low; 
    210  
    211         // dataPack4 (Miscl. flags: samples are: 80, A0, E0, 00) 
    212         dataPack[4-1] = 0xA0; 
    213  
    214         // dataPack 9: initialized as 00 (meaning no metering); need to be updated every 30 sec 
    215         dataPack[9-1] = 0; 
    216  
    217         // datadataPack 10-13: lane malfunction? Assuming all functional 
    218         dataPack[10-1] = 0; 
    219         dataPack[11-1] = 0; 
    220         dataPack[12-1] = 0; 
    221         dataPack[13-1] = 0; 
    222  
    223         // dataPack 14-22: ramp metering data 
    224         // BYTE 16 and 22 need to be updated every 30 sec 
    225         bool found = false; 
    226         for (j = 0; j < loop.num; j++) 
    227         { 
    228                 if (strcmp(loop.loop_loc[j], "DEMAND") == 0) 
    229                 { 
    230                         found = true; 
    231                         break; 
    232                 } 
    233         } 
    234         if (found) 
    235         { 
    236                 // BYTE 14: mostly 07, some are 05, 03, 00 
    237                 dataPack[14-1] = 0x07; 
    238                 // mostly 06(TOD table 1); some are 0B (No metering) or 05(traffic responsive) 
    239                 dataPack[15-1] = 0x06; 
    240                 // most 00, some are 01 (queue override) or 80(Meter ON sign) 
    241                 dataPack[16-1] = 0x00; 
    242                 // Field Manual Rate 
    243                 dataPack[17-1] = 0xFF; 
    244                 // TOC Manual Rate 
    245                 dataPack[18-1] = 0xFF; 
    246                 // PSO Manual Rate 
    247                 dataPack[19-1] = 0xFF; 
    248                 // CORM Rate 
    249                 dataPack[20-1] = 0xFF; 
    250                 // Local Responsive Rate. DON'T UNDERSTAND YET 
    251                 dataPack[21-1] = 0x00; 
    252                 // TOD Rate: need to query RAMP plugin! 
    253                 dataPack[22-1] = 0x00; 
    254         } 
    255         // LDS: NO Metering 
    256         else 
    257         { 
    258                 dataPack[14-1] = 0x00; 
    259                 dataPack[15-1] = 0x0B; 
    260                 dataPack[16-1] = 0x00; 
    261                 dataPack[17-1] = 0xFF; 
    262                 dataPack[18-1] = 0xFF; 
    263                 dataPack[19-1] = 0xFF; 
    264                 dataPack[20-1] = 0xFF; 
    265                 dataPack[21-1] = 0x00; 
    266                 dataPack[22-1] = 0x00; 
    267         } 
    268  
    269         // dataPack 23-24: sum of mainline/Oppsite traffic data; need to be updated every 30 sec 
    270         loop.MlTotVol = 0; 
    271         loop.OppTotVol = 0; 
    272         dataPack[23-1] = loop.MlTotVol; 
    273         dataPack[24-1] = loop.OppTotVol; 
    274  
    275         // dataPack 25-26: BYTE 25 is fixed, i.e. 03; BYTE 26 is either 0xA2 or 0x84 
    276         dataPack[25-1] = 0x03; 
    277         dataPack[26-1] = 0x84; 
    278  
    279         /* printf("lds=%d (%d), p1=%2X, p2=%2X, p3=%2X, p5=%2X, p6=%X, p7=%X, p8=%2X\n", 
    280                 loop.lds, loop.length, dataPack[1-1], dataPack[2-1], 
    281                 dataPack[3-1], dataPack[5-1], 
    282                 dataPack[6-1], dataPack[7-1], dataPack[8-1]); 
    283     */ 
    284         return dataPack; 
    285 } 
    286  
    287 /** 
    288  * Getter for lines 
    289  * @return List of FEP_LINES 
    290  */ 
    291 vector<FEP_LINE> NetworkReader::getLines() 
    292 { 
    293     return lines; 
    294 } 
    295  
    296 /** 
    297  * Getter for stations 
    298  * @return List of LDS_LOOPs 
    299  */ 
    300 vector<LDS_LOOP> NetworkReader::getStations() 
    301 { 
    302     return stations; 
    303 } 
    304  
    305 NetworkReader::~NetworkReader() 
    306 { 
    307  
    308 } 
     273        // Initializes the LDS_LOOP dataPack with all necessary static data and default dynamic data 
     274        unsigned char * NetworkReader::staticDataPack(LDS_LOOP loop) { 
     275            int j; 
     276                    // Allocate memory for dataPack 
     277                    unsigned char *dataPack = (unsigned char *) calloc(1, sizeof (unsigned char) * loop.length); 
     278 
     279                    // dataPack 5-8: lane config 
     280                    char d5 = 0, d6 = 0, d7 = 0, d8 = 0; 
     281            for (j = 0; j < loop.num; j++) { 
     282                for (int k = 0; k < 8; k++) { 
     283                    if (strcmp(loop.loop_loc[j], dp5[k]) == 0) 
     284                            d5 += pow(2, k); 
     285                        if (strcmp(loop.loop_loc[j], dp6[k]) == 0) 
     286                                d6 += pow(2, k); 
     287                            if (strcmp(loop.loop_loc[j], dp7[k]) == 0) 
     288                                    d7 += pow(2, k); 
     289                                if (strcmp(loop.loop_loc[j], dp8[k]) == 0) 
     290                                        d8 += pow(2, k); 
     291                                } 
     292            } 
     293            dataPack[5 - 1] = d5; 
     294                    dataPack[6 - 1] = d6; 
     295                    dataPack[7 - 1] = d7; 
     296                    dataPack[8 - 1] = d8; 
     297 
     298                    // dataPack 1: Drop number, i.e. station address 
     299                    dataPack[1 - 1] = loop.drop; 
     300 
     301                    // dataPack2 (2 bytes per loop) 
     302                    dataPack[2 - 1] = loop.num * 2 + Fixed_Byte_To_Checksum; 
     303 
     304                    // dataPacket 3 (lowbyte: # of mainline loops, highbyte: # of opposite loops) 
     305                    int low = 0, high = 0; 
     306            for (j = 1; j <= 6; j++) { 
     307                low += DataAvail(dataPack[5 - 1], j); 
     308                        high += DataAvail(dataPack[6 - 1], j); 
     309            } 
     310            high = high << 4; 
     311                    dataPack[3 - 1] = high | low; 
     312 
     313                    // dataPack4 (Miscl. flags: samples are: 80, A0, E0, 00) 
     314                    dataPack[4 - 1] = 0xA0; 
     315 
     316                    // dataPack 9: initialized as 00 (meaning no metering); need to be updated every 30 sec 
     317                    dataPack[9 - 1] = 0; 
     318 
     319                    // datadataPack 10-13: lane malfunction? Assuming all functional 
     320                    dataPack[10 - 1] = 0; 
     321                    dataPack[11 - 1] = 0; 
     322                    dataPack[12 - 1] = 0; 
     323                    dataPack[13 - 1] = 0; 
     324 
     325                    // dataPack 14-22: ramp metering data 
     326                    // BYTE 16 and 22 need to be updated every 30 sec 
     327                    bool found = false; 
     328            for (j = 0; j < loop.num; j++) { 
     329                if (strcmp(loop.loop_loc[j], "DEMAND") == 0) { 
     330                    found = true; 
     331                    break; 
     332                } 
     333            } 
     334            if (found) { 
     335                // BYTE 14: mostly 07, some are 05, 03, 00 
     336                dataPack[14 - 1] = 0x07; 
     337                        // mostly 06(TOD table 1); some are 0B (No metering) or 05(traffic responsive) 
     338                        dataPack[15 - 1] = 0x06; 
     339                        // most 00, some are 01 (queue override) or 80(Meter ON sign) 
     340                        dataPack[16 - 1] = 0x00; 
     341                        // Field Manual Rate 
     342                        dataPack[17 - 1] = 0xFF; 
     343                        // TOC Manual Rate 
     344                        dataPack[18 - 1] = 0xFF; 
     345                        // PSO Manual Rate 
     346                        dataPack[19 - 1] = 0xFF; 
     347                        // CORM Rate 
     348                        dataPack[20 - 1] = 0xFF; 
     349                        // Local Responsive Rate. DON'T UNDERSTAND YET 
     350                        dataPack[21 - 1] = 0x00; 
     351                        // TOD Rate: need to query RAMP plugin! 
     352                        dataPack[22 - 1] = 0x00; 
     353            }                // LDS: NO Metering 
     354            else { 
     355                dataPack[14 - 1] = 0x00; 
     356                        dataPack[15 - 1] = 0x0B; 
     357                        dataPack[16 - 1] = 0x00; 
     358                        dataPack[17 - 1] = 0xFF; 
     359                        dataPack[18 - 1] = 0xFF; 
     360                        dataPack[19 - 1] = 0xFF; 
     361                        dataPack[20 - 1] = 0xFF; 
     362                        dataPack[21 - 1] = 0x00; 
     363                        dataPack[22 - 1] = 0x00; 
     364            } 
     365 
     366            // dataPack 23-24: sum of mainline/Oppsite traffic data; need to be updated every 30 sec 
     367            loop.MlTotVol = 0; 
     368                    loop.OppTotVol = 0; 
     369                    dataPack[23 - 1] = loop.MlTotVol; 
     370                    dataPack[24 - 1] = loop.OppTotVol; 
     371 
     372                    // dataPack 25-26: BYTE 25 is fixed, i.e. 03; BYTE 26 is either 0xA2 or 0x84 
     373                    dataPack[25 - 1] = 0x03; 
     374                    dataPack[26 - 1] = 0x84; 
     375 
     376            return dataPack; 
     377        } 
     378 
     379        /** 
     380         * Getter for lines 
     381         * @return List of FEP_LINES 
     382         */ 
     383        vector<FEP_LINE> NetworkReader::getLines() { 
     384 
     385            return lines; 
     386        } 
     387 
     388        /** 
     389         * Getter for stations 
     390         * @return List of LDS_LOOPs 
     391         */ 
     392        vector<LDS_LOOP> NetworkReader::getStations() { 
     393 
     394            return stations; 
     395        } 
     396 
     397        NetworkReader::~NetworkReader() { 
     398 
     399        } 
  • branches/fep_rpc_client/NetworkReader.h

    r77 r78  
    7171 
    7272        void loadLines(const char * networkFileName); 
    73         LDS_LOOP parseStation(TiXmlElement *stationElem, FEP_LINE line); 
     73        LDS_LOOP parseStation(TiXmlElement *stationElem, FEP_LINE *line); 
    7474        FEP_LINE parseLine(TiXmlElement *lineElem); 
    7575 
    7676        bool DataAvail(char flag, int num); // Helper function for msgDataPack 
    77         unsigned char * msgDataPack(LDS_LOOP loop); // Packs the message sent to ATMS 
     77        unsigned char * staticDataPack(LDS_LOOP loop); // Packs the static data in message sent to ATMS 
     78        // int pp_data_packing(int index, int packNo, int pos); // Packs dynamic data in message sent to ATMS 
    7879}; 
    7980 
  • branches/fep_rpc_client/nbproject/private/configurations.xml

    r77 r78  
    1414          <gdbinterceptoptions gdb_all="false" gdb_unhandled="true" gdb_unexpected="true"/> 
    1515        </gdb_interceptlist> 
     16        <gdb_signals> 
     17        </gdb_signals> 
    1618        <gdb_options> 
    1719          <DebugOptions> 
     
    2729          <runcommandpicklistitem>"${OUTPUT_PATH}"</runcommandpicklistitem> 
    2830          <runcommandpicklistitem>"${OUTPUT_PATH}" localhost networkFile.txt</runcommandpicklistitem> 
     31          <runcommandpicklistitem>"${OUTPUT_PATH}" 192.168.251.27 networkFile.txt</runcommandpicklistitem> 
    2932        </runcommandpicklist> 
    30         <runcommand>"${OUTPUT_PATH}" localhost networkFile.txt</runcommand> 
     33        <runcommand>"${OUTPUT_PATH}" 192.168.251.27 networkFile.txt</runcommand> 
    3134        <rundir></rundir> 
    3235        <buildfirst>true</buildfirst> 
  • branches/fep_rpc_client/nbproject/private/private.xml

    r77 r78  
    55        <activeConfIndexElem>0</activeConfIndexElem> 
    66    </data> 
     7    <editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/> 
     8    <open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2"> 
     9        <group> 
     10            <file>file:/home/andrew/tmcsim/branches/fep_rpc_client/NetworkReader.h</file> 
     11            <file>file:/home/andrew/tmcsim/branches/fep_rpc_client/FEPClient.cpp</file> 
     12            <file>file:/home/andrew/tmcsim/branches/fep_rpc_client/network.h</file> 
     13            <file>file:/home/andrew/tmcsim/branches/fep_rpc_client/fep.h</file> 
     14            <file>file:/home/andrew/tmcsim/branches/fep_rpc_client/NetworkReader.cpp</file> 
     15        </group> 
     16    </open-files> 
    717</project-private> 
Note: See TracChangeset for help on using the changeset viewer.