Changeset 136 in tmcsimulator
- Timestamp:
- 10/18/2017 12:17:26 AM (9 years ago)
- Files:
-
- 6 added
- 3 edited
-
branches/SimpleFEPclient/DataPacker.cpp (added)
-
branches/SimpleFEPclient/DataPacker.h (added)
-
branches/SimpleFEPclient/build (modified) (1 diff)
-
branches/SimpleFEPclient/fep_client.cpp (modified) (2 diffs)
-
branches/SimpleFEPclient/fep_client.h (added)
-
branches/SimpleFEPclient/network.h (added)
-
branches/SimpleFEPclient/runclient (added)
-
trunk/IDE_metadata/NetBeans/TMCSim/nbproject/configs/ConsoleDriver.properties (added)
-
trunk/src/tmcsim/application.properties (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/SimpleFEPclient/build
r131 r136 1 1 #!/bin/bash 2 2 3 g cc*.cpp *.c -o client3 g++ -w *.cpp *.c -o client -
branches/SimpleFEPclient/fep_client.cpp
r106 r136 1 #include "fep_client.h" 1 2 #include "fep.h" 2 3 #include <stdio.h> 3 4 #include <stdlib.h> 5 #include <vector> 6 #include "network.h" 7 #include "DataPacker.h" 4 8 5 9 /* Author: John A. Torres … … 8 12 reply is sent, the ATMS Sends a response and the RPC Client 9 13 is destroyed. 14 */ 15 void FEPClient::fep_program_32(char *host) 16 { 17 CLIENT *clnt; 18 19 /* Declerations to construct an fep_reply */ 20 fep_answer_info fai; 21 fep_answer_short_msg fasm; 22 fep_shortanswer fsa; 23 fep_reply fep_reply; // the reply to be sent to ATMS 24 25 /* Var to recieve message back from ATMS */ 26 void *rv; 27 28 /* Create RPC Client to communicate with ATMS */ 29 printf("Preparing to create RPC client\n"); 30 clnt = clnt_create(host, FEP_PROGRAM, FEP_VERSION, "tcp"); 31 32 /* Check if client creation failed */ 33 if (clnt == (CLIENT *) NULL) 34 { 35 fprintf(stderr, "can't create client to %s\n", host); 36 /* Show why rpc handle couldn't be created */ 37 clnt_pcreateerror(""); 38 exit(1); 39 } 40 41 /* Populate fep_shortmessage data */ 42 printf("setting reply values\n"); 43 44 // DUMMY DATA FOR SINGLE GREEN DOT 45 // STATION 46 // lds_id line drop sch lineinfo system_key sch_seq glo_seq count freeway Dir ca_pm lds_name 47 // 1204666 45 10 11 11 1123005841 26484 1357646 19 5 N 20 LAKE FOR2 48 49 // LOOPS 50 // FWY Dir POSTMI LDS_ID VDS_ID LOOP_ID LOC LANE LOOP_LOC PARAMICS_NAME PARAMICS_LANE 51 // 52 53 vector<LOOP*> loops; 54 /* 55 LOOP * newLoopOne = new LOOP; 56 newLoopOne->loopID = 1210490; 57 newLoopOne->loop_loc = "ML_1"; 58 newLoopOne->vol = 0; 59 newLoopOne->occ = 0; 60 newLoopOne->spd = 0; 61 62 LOOP * newLoopTwo = new LOOP; 63 newLoopTwo->loopID = 1210492; 64 newLoopTwo->loop_loc = "ML_2"; 65 newLoopTwo->vol = 0; 66 newLoopTwo->occ = 0; 67 newLoopTwo->spd = 0; 68 69 LOOP * newLoopThree = new LOOP; 70 newLoopThree->loopID = 1210493; 71 newLoopThree->loop_loc = "ML_3"; 72 newLoopThree->vol = 0; 73 newLoopThree->occ = 0; 74 newLoopThree->spd = 0; 75 76 LOOP * newLoopFour = new LOOP; 77 newLoopFour->loopID = 1210769; 78 newLoopFour->loop_loc = "RAMP_ON"; 79 newLoopFour->vol = 0; 80 newLoopFour->occ = 0; 81 newLoopFour->spd = 0; 82 83 loops.push_back(newLoopOne); 84 loops.push_back(newLoopTwo); 85 loops.push_back(newLoopThree); 86 loops.push_back(newLoopFour); 10 87 */ 11 void fep_program_32(char *host) 12 { 13 CLIENT *clnt; 14 15 /* Declerations to construct an fep_reply */ 16 fep_answer_info fai; 17 fep_pollerror fpe; 18 fep_answer_short_msg fasm; 19 fep_shortanswer fsa; 20 fep_reply fep_reply_xfer_32_arg; // the reply to be sent to ATMS 21 22 /* Var to recieve message back from ATMS */ 23 void *rv; 24 25 /* Create RPC Client to communicate with ATMS */ 26 printf("Preparing to create RPC client\n"); 27 clnt = clnt_create(host, FEP_PROGRAM, FEP_VERSION, "tcp"); 28 29 /* Check if client creation failed */ 30 if (clnt == (CLIENT *) NULL) 31 { 32 fprintf(stderr, "can't create client to %s\n", host); 33 /* Show why rpc handle couldn't be created */ 34 clnt_pcreateerror(""); 35 exit(1); 36 } 37 38 /* Populate fep_shortmessage data */ 39 printf("setting reply values\n"); 40 41 fasm.message_len = 5; 42 fasm.message[0] = 0x0a; 43 fasm.message[1] = 0x0d; 44 fasm.message[2] = 0x11; 45 fasm.message[3] = 0x12; 46 fasm.message[4] = 0x13; 47 48 fpe.msgerror = (enum answererror) 0; 49 fpe.state = (enum Polling_FSM_States) 0x00; 50 fpe.perrno = 0; 51 fpe.termination = 0; 52 fpe.count = 0; 53 54 fai.poll_time = 1111443466; 55 fai.status = (enum replystatus) 1; 56 fai.poll_user_info1 = 1; 57 fai.poll_user_info2 = 2; 58 fai.retries = 0; 59 fai.poll_error_count = 1; 60 fai.pollerror[0] = fpe; 61 62 fsa.info = fai; 63 fsa.msg = fasm; 64 65 fep_reply_xfer_32_arg.reply = 0; 66 fep_reply_xfer_32_arg.schedule = 0; 67 fep_reply_xfer_32_arg.lineinfo = 0; 68 fep_reply_xfer_32_arg.kind = (enum polltype)0; 69 fep_reply_xfer_32_arg.flag = (enum replykind) 0; 70 fep_reply_xfer_32_arg.schedule_sequence = 0; 71 fep_reply_xfer_32_arg.global_sequence = 0; 72 fep_reply_xfer_32_arg.schedule_time = 1111443466; 73 fep_reply_xfer_32_arg.user_info1 = 0; 74 fep_reply_xfer_32_arg.user_info2 = 0; 75 fep_reply_xfer_32_arg.system_key = 0; 76 fep_reply_xfer_32_arg.answers.size = 0; 77 fep_reply_xfer_32_arg.answers.fep_answer_list_u.shortp.count = 1; 78 fep_reply_xfer_32_arg.answers.fep_answer_list_u.shortp.answers[0] = fsa; 79 80 /* Make RPC Call to transfer reply to ATMS */ 81 printf("transferring data\n"); 82 rv = fep_reply_xfer_32(&fep_reply_xfer_32_arg, clnt); 83 printf("checking reply`\n"); 84 85 /* If ATMS reply call fails */ 86 if (rv == (void *) NULL) 87 { 88 clnt_perror(clnt, "call failed"); 89 } 90 /* If recieved reply is successful, but empty */ 91 else if ((char *) rv == "") 92 { 93 printf("rv is empty\n"); 94 } 95 /* If recieved reply is successful */ 96 else 97 { 98 printf("Result = %s\n", (char *)rv); 99 } 100 101 /* Destroy client */ 102 printf("destroying client\n"); 103 clnt_destroy(clnt); 104 printf("returning to main\n"); 88 STATION * dummyStation = new STATION; 89 dummyStation->lds = 1204666; 90 dummyStation->line_num = 45; 91 dummyStation->drop = 10; 92 // dummyStation->loops = loops; 93 94 dummyStation->MlTotVol = 0; 95 dummyStation->OppTotVol = 0; 96 dummyStation->length = dummyStation->loops.size() * 2 + 27 /* CONTROL_DATA_LEN */; 97 98 printf("Station length: %d\n", dummyStation->length); 99 // CHECK TO SEE IF I AM UPDATING THIS EVERY 30S 100 /* 101 for(int i = 0; i < 3; i++) 102 { 103 dummyStation->MlTotVol += loops.at(i)->vol; 104 } 105 */ 106 printf("Station MLTOTVOL: %d\n", dummyStation->MlTotVol); 107 108 dummyStation->dataPack = DataPacker::packData(dummyStation); 109 110 111 fep_reply.reply = SHORTPOLL; 112 fep_reply.schedule = 0; 113 fep_reply.lineinfo = 0; 114 fep_reply.kind = (enum polltype) 0; 115 fep_reply.flag = (enum replykind) 0; 116 117 fep_reply.schedule_sequence = 0; 118 fep_reply.global_sequence = 0; 119 120 fep_reply.schedule_time = time(NULL); 121 122 fep_reply.user_info1 = dummyStation->line_num; // LINE NUM; 123 fep_reply.user_info2 = dummyStation->line_num; // LINE NUM; 124 fep_reply.system_key = 0; 125 126 fep_reply.answers.size = 1; 127 fep_reply.answers.fep_answer_list_u.shortp.count = 1; 128 129 fasm.message_len = dummyStation->length + 2; // MESSAGE LEN; 130 fasm.message[0] = 0x0d; 131 fasm.message[1] = 0x0a; 132 133 for (int k = 0; k < dummyStation->length; k++) { 134 printf("Adding: %d %02X\n", k, dummyStation->dataPack[k]); 135 fasm.message[2 + k] = dummyStation->dataPack[k]; 136 } 137 138 int length = dummyStation->length + 2; // NEED CORRECT LENGTH 139 fasm.message[length + 2] = 0x0d; 140 fasm.message[length + 3] = 0xff; 141 142 for(int l = 0; l < fasm.message_len + 2; l++) 143 { 144 printf("%02X", (unsigned char) fasm.message[l]); 145 } 146 printf("\n"); 147 148 fai.poll_error_count = 0; 149 fai.poll_user_info1 = 0 ;// DROP NUMBER HERE 150 fai.poll_user_info2 = 1; 151 fai.retries = 0; 152 fai.status = (enum replystatus) 1; 153 154 fsa.info = fai; 155 fsa.msg = fasm; 156 fep_reply.answers.fep_answer_list_u.shortp.answers[0] = fsa; 157 158 /* Make RPC Call to transfer reply to ATMS */ 159 printf("transferring data\n"); 160 rv = fep_reply_xfer_32(&fep_reply, clnt); 161 printf("checking reply`\n"); 162 163 /* If ATMS reply call fails */ 164 if (rv == (void *) NULL) 165 { 166 clnt_perror(clnt, "call failed"); 167 } 168 /* If recieved reply is successful, but empty */ 169 else if ((char *) rv == "") 170 { 171 printf("rv is empty\n"); 172 } 173 /* If recieved reply is successful */ 174 else 175 { 176 printf("Result = %s\n", (char *)rv); 177 } 178 179 /* Destroy client */ 180 printf("destroying client\n"); 181 clnt_destroy(clnt); 182 printf("returning to main\n"); 105 183 } 106 184 107 185 /* Creates a single client and sends an fep_reply to the ATMS */ 108 186 int main(int argc, char *argv[]) { 109 char *host; 110 111 if (argc < 2) 112 { 113 printf("usage: %s server_host\n", argv[0]); 114 exit(1); 115 } 116 117 /* Create RPC Client to send an fep_reply to ATMS */ 118 host = argv[1]; 119 fep_program_32(host); 120 121 return 0; 187 char *host; 188 189 if (argc < 2) 190 { 191 printf("usage: %s server_host\n", argv[0]); 192 exit(1); 193 } 194 195 /* Create RPC Client to send an fep_reply to ATMS */ 196 host = argv[1]; 197 FEPClient cli; 198 cli.fep_program_32(host); 199 200 return 0; 122 201 } -
trunk/src/tmcsim/application.properties
r135 r136 1 # Tue, 17 Oct 2017 18:13:47-07001 #Wed, 18 Oct 2017 01:22:49 -0700 2 2 3 Application.revision=13 33 Application.revision=135 4 4 5 5 Application.buildnumber=53
Note: See TracChangeset
for help on using the changeset viewer.
