Changeset 82 in tmcsimulator for branches/FEPSimulator
- Timestamp:
- 10/06/2017 06:54:21 PM (9 years ago)
- Location:
- branches/FEPSimulator
- Files:
-
- 8 edited
- 2 moved
-
DataPacker.h (modified) (1 diff)
-
FEPSim.cpp (moved) (moved from branches/FEPSimulator/FEPClient.cpp) (7 diffs)
-
FEPSim.h (moved) (moved from branches/FEPSimulator/FEPClient.h) (4 diffs)
-
NetworkReader.cpp (modified) (2 diffs)
-
nbproject/Makefile-Debug.mk (modified) (5 diffs)
-
nbproject/Makefile-impl.mk (modified) (1 diff)
-
nbproject/Makefile-variables.mk (modified) (1 diff)
-
nbproject/Package-Debug.bash (modified) (3 diffs)
-
nbproject/configurations.xml (modified) (5 diffs)
-
nbproject/private/configurations.xml (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/FEPSimulator/DataPacker.h
r80 r82 14 14 15 15 // Include dependencies 16 #include "network.h" ;16 #include "network.h" 17 17 #include <iostream> 18 18 #include <string.h> -
branches/FEPSimulator/FEPSim.cpp
r80 r82 1 #include "FEP Client.h"1 #include "FEPSim.h" 2 2 3 3 /** … … 7 7 * @param networkFile the xml network file 8 8 */ 9 FEP Client::FEPClient(char * host, char * networkFile) {10 networkReader = new NetworkReader( networkFile);11 createClient(host);9 FEPSim::FEPSim(char * ATMShost, char * xml) { 10 networkReader = new NetworkReader(xml); 11 this->ATMSHost = ATMShost; 12 12 updateATMS(); 13 13 } … … 16 16 * Destructor 17 17 */ 18 FEP Client::~FEPClient() {18 FEPSim::~FEPSim() { 19 19 cout << "Destroying client..." << endl; 20 20 clnt_destroy(clnt); … … 25 25 * @param response pointer to fep_reply struct 26 26 */ 27 void FEP Client::handleCallResponse(void *response) {27 void FEPSim::handleCallResponse(void *response) { 28 28 /* If ATMS reply call fails */ 29 29 if (response == NULL) { 30 30 clnt_perror(clnt, "RPC call failed"); 31 } /* If ATMS reply is successful */31 }/* If ATMS reply is successful */ 32 32 else { 33 33 cout << "Successful RPC call to ATMS..." << endl; … … 38 38 * Sends an fep_reply for every line in the FEP. 39 39 */ 40 void FEP Client::updateATMS() {40 void FEPSim::updateATMS() { 41 41 int i, j; // i == line_index, j == lds_index 42 42 void *rv; 43 44 43 vector<FEP_LINE*> lines = networkReader->getLines(); 45 44 vector<STATION*> ldsMap = networkReader->getStations(); … … 122 121 * @param host rpc server ip 123 122 */ 124 void FEP Client::createClient(char * host) {123 void FEPSim::createClient(char * host) { 125 124 /* Create RPC Client to communicate with ATMS */ 126 125 cout << "Creating RPC Client" << endl; … … 142 141 int main(int argc, char *argv[]) { 143 142 144 char *host; 145 char *networkFile; 146 147 if (argc < 3) { 148 cout << "usage: " << argv[0] << " server_host networkFile" << endl; 143 int sockfd, newsockfd, portno, clilen; 144 char buffer[BUFF_SIZE]; 145 struct sockaddr_in serv_addr, cli_addr; 146 int n; 147 148 char *FEPSimHost = argv[1]; 149 portno = atoi(argv[2]); 150 151 /* First call to socket() function */ 152 sockfd = socket(AF_INET, SOCK_STREAM, 0); 153 154 if (sockfd < 0) { 155 perror("ERROR opening socket"); 149 156 exit(1); 150 157 } 151 158 152 /* Create RPC Client to send an fep_reply to ATMS */ 153 host = argv[1]; 154 networkFile = argv[2]; 155 156 FEPClient *client = new FEPClient(host, networkFile); 157 delete client; 159 /* Initialize socket structure */ 160 bzero((char *) &serv_addr, sizeof (serv_addr)); 161 162 serv_addr.sin_family = AF_INET; 163 serv_addr.sin_addr.s_addr = INADDR_ANY; 164 serv_addr.sin_port = htons(portno); 165 166 /* Now bind the host address using bind() call.*/ 167 if (bind(sockfd, (struct sockaddr *) &serv_addr, sizeof (serv_addr)) < 0) { 168 perror("ERROR on binding"); 169 exit(1); 170 } 171 172 /* Now start listening for the clients, here process will 173 * go in sleep mode and will wait for the incoming connection 174 */ 175 176 listen(sockfd, 5); 177 clilen = sizeof (cli_addr); 178 179 /* Accept actual connection from the client */ 180 while(1) { 181 newsockfd = accept(sockfd, (struct sockaddr *) &cli_addr, (socklen_t *)&clilen); 182 183 if (newsockfd < 0) { 184 perror("ERROR on accept"); 185 exit(1); 186 } 187 188 /* If connection is established then start communicating */ 189 bzero(buffer, BUFF_SIZE); 190 191 // NEEDS OUTER LOOP TO GET WHOLE MESSAGE FROM TCP CONN 192 n = read(newsockfd, buffer, sizeof(buffer)); 193 194 if (n < 0) { 195 perror("ERROR reading from socket"); 196 exit(1); 197 } 198 199 /* Create RPC Client to send an fep_reply to ATMS */ 200 201 FEPSim *client = new FEPSim(FEPSimHost, buffer); 202 delete client; 203 } 158 204 159 205 return 0; -
branches/FEPSimulator/FEPSim.h
r80 r82 1 1 /* 2 * File: FEP Client.h2 * File: FEPSim.h 3 3 * 4 * The FEP Clientis an RPC Client which transfers network data to the4 * The FEPSim is an RPC Client which transfers network data to the 5 5 * ATMS Server. 6 6 * 7 * An FEP Clientis created every 30 seconds, and an fep_reply structure7 * An FEPSim is created every 30 seconds, and an fep_reply structure 8 8 * for every FEP_LINE_LDS is transferred to the ATMS through an RPC Call. 9 * After the FEP Clienthas transferred all fep_replys, it is destroyed.9 * After the FEPSim has transferred all fep_replys, it is destroyed. 10 10 * 11 * An FEP Clientis script-like in nature. There are no public methods other than12 * the constructor. To construct an FEP Client, an input file (containing network11 * An FEPSim is script-like in nature. There are no public methods other than 12 * the constructor. To construct an FEPSim, an input file (containing network 13 13 * data in xml form) and a host server_ip (for the ATMS) are necessary. The 14 14 * format of the xml input file can be fount in "networkReader.cpp" source file. … … 19 19 20 20 // Include guard 21 #ifndef __FEP CLIENT_H_INCLUDED__22 #define __FEP CLIENT_H_INCLUDED__21 #ifndef __FEPSIM_H_INCLUDED__ 22 #define __FEPSIM_H_INCLUDED__ 23 23 24 24 // Forward declared dependencies … … 28 28 #include "fep.h" 29 29 #include <iostream> 30 #include <stdio.h> 30 31 #include <stdlib.h> 31 32 #include "time.h" 32 33 #include "NetworkReader.h" 34 #include <netdb.h> 35 #include <sys/types.h> 36 #include <sys/socket.h> 37 #include <netinet/in.h> 38 #include <unistd.h> 33 39 34 class FEPClient 40 const int BUFF_SIZE = 1000000; 41 42 class FEPSim 35 43 { 36 44 public: … … 39 47 40 48 /* methods */ 41 FEP Client(char * host, char * networkFile); // Constructor42 ~FEP Client(); // Destructor49 FEPSim(char * host, char * networkFile); // Constructor 50 ~FEPSim(); // Destructor 43 51 44 52 private: 45 53 /* members */ 46 54 NetworkReader *networkReader; 47 55 char * ATMSHost; 56 48 57 /* methods */ 49 void handleCallResponse(void *response); //50 void createClient(char *host);58 void handleCallResponse(void *response); // 59 void createClient(char *host); 51 60 void updateATMS(); // updates ATMS 52 61 53 62 }; 54 63 55 #endif // __FEP CLIENT_H_INCLUDED__64 #endif // __FEPSIM_H_INCLUDED__ -
branches/FEPSimulator/NetworkReader.cpp
r80 r82 5 5 * @param networkFileName input xml file 6 6 */ 7 NetworkReader::NetworkReader(const char * networkFileName) {7 NetworkReader::NetworkReader(const char * xml) { 8 8 ldsIndex = 0; 9 loadLines( networkFileName);9 loadLines(xml); 10 10 } 11 11 … … 108 108 * @param networkFileName the input xml file 109 109 */ 110 void NetworkReader::loadLines(const char * networkFileName) {110 void NetworkReader::loadLines(const char * xml) { 111 111 // Load network xml file 112 TiXmlDocument doc(networkFileName); 113 if (!doc.LoadFile()) { 114 cerr << "TiXmlDocument did not load network file..." << endl; 115 return; 116 } 112 TiXmlDocument doc; 113 doc.Parse((const char*)xml, 0, TIXML_ENCODING_UTF8); 117 114 118 115 // grab <Network> element -
branches/FEPSimulator/nbproject/Makefile-Debug.mk
r80 r82 22 22 23 23 # Macros 24 CND_PLATFORM=GNU- Linux-x8625 CND_DLIB_EXT= so24 CND_PLATFORM=GNU-MacOSX 25 CND_DLIB_EXT=dylib 26 26 CND_CONF=Debug 27 27 CND_DISTDIR=dist … … 37 37 OBJECTFILES= \ 38 38 ${OBJECTDIR}/DataPacker.o \ 39 ${OBJECTDIR}/FEP Client.o \39 ${OBJECTDIR}/FEPSim.o \ 40 40 ${OBJECTDIR}/NetworkReader.o \ 41 41 ${OBJECTDIR}/fep_clnt.o \ … … 57 57 58 58 # Link Libraries and Options 59 LDLIBSOPTIONS=tinyxml/ tinyxml.a59 LDLIBSOPTIONS=tinyxml/libosxtinyxml.a 60 60 61 61 # Build Targets 62 62 .build-conf: ${BUILD_SUBPROJECTS} 63 "${MAKE}" -f nbproject/Makefile-${CND_CONF}.mk ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/fep _rpc_client63 "${MAKE}" -f nbproject/Makefile-${CND_CONF}.mk ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/fepsimulator 64 64 65 ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/fep _rpc_client: tinyxml/tinyxml.a65 ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/fepsimulator: tinyxml/libosxtinyxml.a 66 66 67 ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/fep _rpc_client: ${OBJECTFILES}67 ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/fepsimulator: ${OBJECTFILES} 68 68 ${MKDIR} -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM} 69 ${LINK.cc} -o ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/fep _rpc_client${OBJECTFILES} ${LDLIBSOPTIONS}69 ${LINK.cc} -o ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/fepsimulator ${OBJECTFILES} ${LDLIBSOPTIONS} 70 70 71 71 ${OBJECTDIR}/DataPacker.o: DataPacker.cpp … … 74 74 $(COMPILE.cc) -g -Itinyxml -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/DataPacker.o DataPacker.cpp 75 75 76 ${OBJECTDIR}/FEP Client.o: FEPClient.cpp76 ${OBJECTDIR}/FEPSim.o: FEPSim.cpp 77 77 ${MKDIR} -p ${OBJECTDIR} 78 78 ${RM} "$@.d" 79 $(COMPILE.cc) -g -Itinyxml -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/FEP Client.o FEPClient.cpp79 $(COMPILE.cc) -g -Itinyxml -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/FEPSim.o FEPSim.cpp 80 80 81 81 ${OBJECTDIR}/NetworkReader.o: NetworkReader.cpp … … 100 100 .clean-conf: ${CLEAN_SUBPROJECTS} 101 101 ${RM} -r ${CND_BUILDDIR}/${CND_CONF} 102 ${RM} ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/fep _rpc_client102 ${RM} ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/fepsimulator 103 103 104 104 # Subprojects -
branches/FEPSimulator/nbproject/Makefile-impl.mk
r77 r82 25 25 26 26 # Project Name 27 PROJECTNAME= fep_rpc_client27 PROJECTNAME=FEPSimulator 28 28 29 29 # Active Configuration -
branches/FEPSimulator/nbproject/Makefile-variables.mk
r77 r82 8 8 CND_DISTDIR=dist 9 9 # Debug configuration 10 CND_PLATFORM_Debug=GNU- Linux-x8611 CND_ARTIFACT_DIR_Debug=dist/Debug/GNU- Linux-x8612 CND_ARTIFACT_NAME_Debug=fep _rpc_client13 CND_ARTIFACT_PATH_Debug=dist/Debug/GNU- Linux-x86/fep_rpc_client14 CND_PACKAGE_DIR_Debug=dist/Debug/GNU- Linux-x86/package15 CND_PACKAGE_NAME_Debug=fep rpcclient.tar16 CND_PACKAGE_PATH_Debug=dist/Debug/GNU- Linux-x86/package/feprpcclient.tar10 CND_PLATFORM_Debug=GNU-MacOSX 11 CND_ARTIFACT_DIR_Debug=dist/Debug/GNU-MacOSX 12 CND_ARTIFACT_NAME_Debug=fepsimulator 13 CND_ARTIFACT_PATH_Debug=dist/Debug/GNU-MacOSX/fepsimulator 14 CND_PACKAGE_DIR_Debug=dist/Debug/GNU-MacOSX/package 15 CND_PACKAGE_NAME_Debug=fepsimulator.tar 16 CND_PACKAGE_PATH_Debug=dist/Debug/GNU-MacOSX/package/fepsimulator.tar 17 17 # Release configuration 18 18 CND_PLATFORM_Release=GNU-Linux-x86 -
branches/FEPSimulator/nbproject/Package-Debug.bash
r77 r82 7 7 # Macros 8 8 TOP=`pwd` 9 CND_PLATFORM=GNU- Linux-x869 CND_PLATFORM=GNU-MacOSX 10 10 CND_CONF=Debug 11 11 CND_DISTDIR=dist 12 12 CND_BUILDDIR=build 13 CND_DLIB_EXT= so13 CND_DLIB_EXT=dylib 14 14 NBTMPDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM}/tmp-packaging 15 15 TMPDIRNAME=tmp-packaging 16 OUTPUT_PATH=${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/fep _rpc_client17 OUTPUT_BASENAME=fep _rpc_client18 PACKAGE_TOP_DIR=fep rpcclient/16 OUTPUT_PATH=${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/fepsimulator 17 OUTPUT_BASENAME=fepsimulator 18 PACKAGE_TOP_DIR=fepsimulator/ 19 19 20 20 # Functions … … 61 61 # Copy files and create directories and links 62 62 cd "${TOP}" 63 makeDirectory "${NBTMPDIR}/fep rpcclient/bin"63 makeDirectory "${NBTMPDIR}/fepsimulator/bin" 64 64 copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}bin/${OUTPUT_BASENAME}" 0755 65 65 … … 67 67 # Generate tar file 68 68 cd "${TOP}" 69 rm -f ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/fep rpcclient.tar69 rm -f ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/fepsimulator.tar 70 70 cd ${NBTMPDIR} 71 tar -vcf ../../../../${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/fep rpcclient.tar *71 tar -vcf ../../../../${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/fepsimulator.tar * 72 72 checkReturnCode 73 73 -
branches/FEPSimulator/nbproject/configurations.xml
r80 r82 6 6 projectFiles="true"> 7 7 <itemPath>DataPacker.h</itemPath> 8 <itemPath>FEP Client.h</itemPath>8 <itemPath>FEPSim.h</itemPath> 9 9 <itemPath>NetworkReader.h</itemPath> 10 10 <itemPath>fep.h</itemPath> … … 19 19 projectFiles="true"> 20 20 <itemPath>DataPacker.cpp</itemPath> 21 <itemPath>FEP Client.cpp</itemPath>21 <itemPath>FEPSim.cpp</itemPath> 22 22 <itemPath>NetworkReader.cpp</itemPath> 23 23 <itemPath>fep_clnt.c</itemPath> … … 52 52 <linkerTool> 53 53 <linkerLibItems> 54 <linkerLibFileItem>tinyxml/ tinyxml.a</linkerLibFileItem>54 <linkerLibFileItem>tinyxml/libosxtinyxml.a</linkerLibFileItem> 55 55 </linkerLibItems> 56 56 </linkerTool> … … 60 60 <item path="DataPacker.h" ex="false" tool="3" flavor2="0"> 61 61 </item> 62 <item path="FEP Client.cpp" ex="false" tool="1" flavor2="0">62 <item path="FEPSim.cpp" ex="false" tool="1" flavor2="0"> 63 63 </item> 64 <item path="FEP Client.h" ex="false" tool="3" flavor2="0">64 <item path="FEPSim.h" ex="false" tool="3" flavor2="0"> 65 65 </item> 66 66 <item path="NetworkReader.cpp" ex="false" tool="1" flavor2="0"> … … 101 101 <item path="DataPacker.h" ex="false" tool="3" flavor2="0"> 102 102 </item> 103 <item path="FEP Client.cpp" ex="false" tool="1" flavor2="0">103 <item path="FEPSim.cpp" ex="false" tool="1" flavor2="0"> 104 104 </item> 105 <item path="FEP Client.h" ex="false" tool="3" flavor2="0">105 <item path="FEPSim.h" ex="false" tool="3" flavor2="0"> 106 106 </item> 107 107 <item path="NetworkReader.cpp" ex="false" tool="1" flavor2="0"> -
branches/FEPSimulator/nbproject/private/configurations.xml
r80 r82 6 6 <toolsSet> 7 7 <developmentServer>localhost</developmentServer> 8 <platform> 2</platform>8 <platform>4</platform> 9 9 </toolsSet> 10 10 <dbx_gdbdebugger version="1"> … … 28 28 <runcommandpicklistitem>"${OUTPUT_PATH}" localhost networkFile.txt</runcommandpicklistitem> 29 29 <runcommandpicklistitem>"${OUTPUT_PATH}" 192.168.251.27 networkFile.txt</runcommandpicklistitem> 30 <runcommandpicklistitem>"${OUTPUT_PATH}" 192.168.251.27</runcommandpicklistitem> 31 <runcommandpicklistitem>"${OUTPUT_PATH}" 192.168.251.27 8080</runcommandpicklistitem> 30 32 </runcommandpicklist> 31 <runcommand>"${OUTPUT_PATH}" 192.168.251.27 networkFile.txt</runcommand>33 <runcommand>"${OUTPUT_PATH}" 192.168.251.27 8080</runcommand> 32 34 <rundir></rundir> 33 35 <buildfirst>true</buildfirst>
Note: See TracChangeset
for help on using the changeset viewer.
