- Timestamp:
- 10/06/2017 11:44:52 PM (9 years ago)
- Location:
- branches
- Files:
-
- 13 edited
-
FEPSimulator/FEPSim.cpp (modified) (13 diffs)
-
FEPSimulator/FEPSim.h (modified) (1 diff)
-
FEPSimulator/NetworkReader.cpp (modified) (3 diffs)
-
trunk/IDE_metadata/NetBeans/TMCSim/build/built-jar.properties (modified) (1 diff)
-
trunk/IDE_metadata/NetBeans/TMCSim/build/classes/atmsdriver/ATMSDriver$PROPERTIES.class (modified) (previous)
-
trunk/IDE_metadata/NetBeans/TMCSim/build/classes/atmsdriver/ATMSDriver.class (modified) (previous)
-
trunk/IDE_metadata/NetBeans/TMCSim/build/classes/atmsdriver/model/HighwayStatusWriter.class (modified) (previous)
-
trunk/IDE_metadata/NetBeans/TMCSim/build/classes/tmcsim/application.properties (modified) (1 diff)
-
trunk/IDE_metadata/NetBeans/TMCSim/dist/TMCSim.jar (modified) (previous)
-
trunk/src/atmsdriver/ATMSDriver.java (modified) (1 diff)
-
trunk/src/atmsdriver/NetworkLoader.java (modified) (1 diff)
-
trunk/src/atmsdriver/model/HighwayStatusWriter.java (modified) (1 diff)
-
trunk/src/tmcsim/application.properties (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/FEPSimulator/FEPSim.cpp
r82 r84 7 7 * @param networkFile the xml network file 8 8 */ 9 FEPSim::FEPSim(char * ATMShost, char * xml) { 10 networkReader = new NetworkReader(xml); 9 FEPSim::FEPSim(char * ATMShost) { 11 10 this->ATMSHost = ATMShost; 12 updateATMS();13 11 } 14 12 … … 26 24 */ 27 25 void FEPSim::handleCallResponse(void *response) { 28 / * If ATMS reply call fails */26 // Failed RPC Call 29 27 if (response == NULL) { 30 28 clnt_perror(clnt, "RPC call failed"); 31 }/* If ATMS reply is successful */ 29 } 30 // Successful RPC Call 32 31 else { 33 32 cout << "Successful RPC call to ATMS..." << endl; … … 35 34 } 36 35 37 /** 38 * Sends an fep_reply for every line in the FEP. 39 */ 40 void FEPSim::updateATMS() { 41 int i, j; // i == line_index, j == lds_index 42 void *rv; 43 vector<FEP_LINE*> lines = networkReader->getLines(); 44 vector<STATION*> ldsMap = networkReader->getStations(); 45 46 // Send one reply for every "line" in the FEP 47 for (i = 0; i < lines.size(); i++) { 36 void FEPSim::sendReplys(char * xml) 37 { 38 NetworkReader networkReader = NetworkReader(xml); 39 vector<FEP_LINE*> lines = networkReader.getLines(); 40 vector<STATION*> ldsMap = networkReader.getStations(); 41 42 // Send one reply for every FEPLine 43 for (int i = 0; i < lines.size(); i++) { 48 44 fep_reply fepReply; 49 45 cout << "Sending fepReply for line #" << lines.at(i)->lineNum << endl; … … 56 52 57 53 /*********************************** 58 This is an update to an extern, this should happen on the Java driver side?? 54 * We might need to handle this on the java side if its an 55 * issue 59 56 lines.at(i).schedleSeq += 1; 60 57 lines.at(i).globalSeq += 51; … … 63 60 fepReply.schedule_sequence = lines.at(i)->schedleSeq; 64 61 fepReply.global_sequence = lines.at(i)->globalSeq; 65 /************************************ 66 Need to find out what appropriate schedule time is: look at uci_unix_simulation_time src code 67 fepReply.schedule_time = 68 uci_unix_simulation_time(uci_simulation_time()); // GMT time 69 */ 62 63 // using current unix time, may need to look at later 70 64 fepReply.schedule_time = time(NULL); 71 65 … … 77 71 fepReply.answers.fep_answer_list_u.shortp.count = 1; 78 72 79 / * for each LDS in the Line.... (constructs the short_answer message) */80 for ( j = 0; j < lines.at(i)->lds.size(); j++) {73 // construct a shortanswer for each station in line 74 for (int j = 0; j < lines.at(i)->lds.size(); j++) { 81 75 fep_shortanswer fsa; 82 76 int index = lines.at(i)->ldsIndex.at(j); … … 90 84 int aa = ldsMap.at(index)->length; 91 85 fsa.msg.message[2 + aa] = 0x0d; 92 fsa.msg.message[3 + aa] = 0xff; //????????????? warning ?????86 fsa.msg.message[3 + aa] = 0xff; 93 87 94 88 // info 95 89 fsa.info.poll_error_count = 0; 96 /***************************************97 Need to find out polltime uci time function src code98 fsa.info.poll_time = uci_unix_simulation_time(uci_simulation_time());99 */100 90 fsa.info.poll_user_info1 = ldsMap.at(index)->drop; // drop number 101 91 fsa.info.poll_user_info2 = 1; //always 1 … … 103 93 fsa.info.status = (enum replystatus) 1; 104 94 105 //fepReply.answers.fep_answer_list_u.shortp.answers[j +1] = fsa;106 95 fepReply.answers.fep_answer_list_u.shortp.answers[0] = fsa; 107 96 108 97 // send out data 109 98 printf("Transferring line=%d, lds_drop_no=%d...\n", lines.at(i)->lineNum, ldsMap.at(index)->drop); 110 rv = fep_reply_xfer_32(&fepReply, clnt); 111 112 /* Handle ATMS response to RPC Call */ 99 // Make RPC Call and handle response 113 100 printf("Handling ATMS response...\n"); 114 handleCallResponse(rv); 115 } 101 handleCallResponse(fep_reply_xfer_32(&fepReply, clnt)); 102 } 103 } 104 } 105 106 /** 107 * Sends an fep_reply for every line in the FEP. 108 */ 109 void FEPSim::updateATMS(char * xml) { 110 if(createClient(this->ATMSHost)) 111 { 112 sendReplys(xml); 116 113 } 117 114 } … … 121 118 * @param host rpc server ip 122 119 */ 123 voidFEPSim::createClient(char * host) {120 bool FEPSim::createClient(char * host) { 124 121 /* Create RPC Client to communicate with ATMS */ 122 bool success = true; 125 123 cout << "Creating RPC Client" << endl; 126 124 clnt = clnt_create(host, /*100090,*/ 103121, 32, "tcp"); 127 cout << "Client created" << endl;128 125 /* Check if client creation failed */ 129 126 if (clnt == (CLIENT *) NULL) { 130 127 cerr << "Can't create client to " << host << endl; 131 exit(1); 132 } 128 success = false; 129 } 130 else { 131 cout << "Client created" << endl; 132 } 133 return success; 133 134 } 134 135 … … 140 141 */ 141 142 int main(int argc, char *argv[]) { 142 143 if(argc != 3) 144 { 145 cerr << "Usage: FEPSim <ATMS_Host> <FEP_ATMSDriver_PortNo" << endl; 146 exit(1); 147 } 148 char *FEPSimHost = argv[1]; 149 FEPSim fep = FEPSim(FEPSimHost); 150 143 151 int sockfd, newsockfd, portno, clilen; 144 152 char buffer[BUFF_SIZE]; 145 153 struct sockaddr_in serv_addr, cli_addr; 146 154 int n; 147 148 char *FEPSimHost = argv[1];149 155 portno = atoi(argv[2]); 150 156 … … 177 183 clilen = sizeof (cli_addr); 178 184 179 /* Accept actual connection from the client */185 /* Accept actual connections from the client */ 180 186 while(1) { 181 187 newsockfd = accept(sockfd, (struct sockaddr *) &cli_addr, (socklen_t *)&clilen); … … 187 193 188 194 /* If connection is established then start communicating */ 195 // zero out buffer 189 196 bzero(buffer, BUFF_SIZE); 190 197 191 // NEEDS OUTER LOOP TO GET WHOLE MESSAGE FROM TCP CONN 192 n = read(newsockfd, buffer, sizeof(buffer)); 193 198 // read XML from socket 199 int totBytes = 0; 200 while ((n = recv(newsockfd, &buffer[totBytes], sizeof(buffer), 0)) > 0) { 201 totBytes += n; 202 } 203 194 204 if (n < 0) { 195 205 perror("ERROR reading from socket"); … … 197 207 } 198 208 199 /* Create RPC Client to send an fep_reply to ATMS */ 200 201 FEPSim *client = new FEPSim(FEPSimHost, buffer); 202 delete client; 209 // send data to atms 210 fep.updateATMS(buffer); 203 211 } 204 212 -
branches/FEPSimulator/FEPSim.h
r82 r84 40 40 const int BUFF_SIZE = 1000000; 41 41 42 class FEPSim 43 { 44 public: 45 /* members */ 46 CLIENT *clnt; // RPC Client 42 class FEPSim { 43 public: 44 /* members */ 45 CLIENT *clnt; // RPC Client 47 46 48 /* methods */ 49 FEPSim(char * host, char * networkFile); // Constructor 50 ~FEPSim(); // Destructor 47 /* methods */ 48 FEPSim(char * ATMSHost); // Constructor 49 50 void updateATMS(char * xml); // updates ATMS 51 51 52 private: 53 /* members */ 54 NetworkReader *networkReader; 55 char * ATMSHost; 56 57 /* methods */ 58 void handleCallResponse(void *response); // 59 void createClient(char *host); 60 void updateATMS(); // updates ATMS 52 ~FEPSim(); // Destructor 53 54 private: 55 /* members */ 56 char * ATMSHost; 57 58 /* methods */ 59 void handleCallResponse(void *response); // 60 bool createClient(char *host); 61 void sendReplys(char * xml); 61 62 62 63 }; -
branches/FEPSimulator/NetworkReader.cpp
r82 r84 15 15 TiXmlElement *subLoopElem = loopElem->FirstChildElement(); 16 16 loop->loopID = atoi(subLoopElem->GetText()); 17 cout << "LOOPID: " << subLoopElem->GetText() << endl;18 17 subLoopElem = subLoopElem->NextSiblingElement(); 19 18 loop->loop_loc = (char *) subLoopElem->GetText(); … … 40 39 TiXmlElement *stationSubElem = stationElem->FirstChildElement(); 41 40 station->lds = atol(stationSubElem->GetText()); 41 cout << "Station: " << station->lds << endl; 42 42 line->lds.push_back(station->lds); 43 43 line->ldsIndex.push_back(ldsIndex++); … … 63 63 station->loops.push_back(loop); 64 64 } 65 65 cout << "Number of Loops: " << station->loops.size() << endl; 66 66 // Data pack ATMS message 67 67 station->length = station->loops.size() * 2 + CONTROL_DATA_LEN; -
branches/trunk/IDE_metadata/NetBeans/TMCSim/build/built-jar.properties
r82 r84 1 # Fri, 06 Oct 2017 19:49:49-07001 #Sat, 07 Oct 2017 00:43:14 -0700 2 2 3 3 -
branches/trunk/IDE_metadata/NetBeans/TMCSim/build/classes/tmcsim/application.properties
r82 r84 1 # Fri, 06 Oct 2017 19:49:49-07001 #Sat, 07 Oct 2017 00:43:14 -0700 2 2 3 Application.revision= 03 Application.revision=83 4 4 5 Application.buildnumber=5 05 Application.buildnumber=58 -
branches/trunk/src/atmsdriver/ATMSDriver.java
r83 r84 53 53 54 54 /** Sleep Time (10 seconds). **/ 55 private static final int SLEEP_TIME = 10000;55 private static final int SLEEP_TIME = 30000; 56 56 57 57 /** Exchange Reader */ -
branches/trunk/src/atmsdriver/NetworkLoader.java
r82 r84 143 143 private void constructFEPLines() 144 144 { 145 try { 146 System.out.println("Building network..."); 147 145 try { 148 146 // Get FEPLine IDs 149 147 ArrayList<Integer> lineNums = getLineNums(new Scanner(LDSFile)); -
branches/trunk/src/atmsdriver/model/HighwayStatusWriter.java
r82 r84 31 31 Socket sock = new Socket(host, port); 32 32 PrintWriter out = new PrintWriter(sock.getOutputStream(), true); 33 out.print (xml);33 out.println(xml); 34 34 sock.close(); 35 35 } -
branches/trunk/src/tmcsim/application.properties
r82 r84 1 # Fri, 06 Oct 2017 19:49:49-07001 #Sat, 07 Oct 2017 00:43:14 -0700 2 2 3 Application.revision= 03 Application.revision=83 4 4 5 Application.buildnumber=5 05 Application.buildnumber=58
Note: See TracChangeset
for help on using the changeset viewer.
