source: tmcsimulator/branches/FEPSimulator/FEPSim.h @ 182

Revision 182, 2.9 KB checked in by jdalbey, 9 years ago (diff)

FEPSimulator: commit updated .h files and runFEPSim script

Line 
1/*
2 * File: FEPSim.h
3 *
4 * The FEP Simulator simulates the Front End Processor(FEP), which has the
5 * responsibility of "polling" Loop Detector Stations for highway status data.
6 * The real FEP "polls" real stations over serial communication lines, whereas
7 * the FEP Simulator recieves highway status data through a socket from the Java
8 * ATMS Driver.
9 *
10 * Highway status data is transmitted to the FEP Simulator over the socket in
11 * XML Form. The XML highway status data is then parsed by the Network Reader.
12 *
13 * The data is then sent to the ATMS, using RPC Calls. The RPC Calls to the
14 * ATMS Server send an fep_reply structure. There is one fep_reply structure
15 * sent to the ATMS for every FEP_LINE.
16 *
17 * The FEP Simulator is a socket server that runs persistently and awaits the
18 * XML highway status data over the socket. When the XML highway status data is
19 * recieved, it executes the RPC Calls to update the ATMS.
20 *
21 * @author John A. Torres
22 * @version 9/8/2017
23 */
24
25// Include guard
26#ifndef __FEPSIM_H_INCLUDED__
27#define __FEPSIM_H_INCLUDED__
28
29// Forward declared dependencies
30class HighwaysParser;
31
32// Included dependencies
33#include "fep.h"
34#include <iostream>
35#include <stdio.h>
36#include <stdlib.h>
37#include "time.h"
38#include "NetworkReader.h"
39#include <netdb.h>
40#include <sys/types.h>
41#include <sys/socket.h>
42#include <netinet/in.h>
43#include <unistd.h>
44
45const int BUFF_SIZE = 5500000;
46
47class FEPSim {
48public:
49    // The RPC Client
50    CLIENT *clnt;
51
52    /**
53     * Constructor. Sets data values for RPC Client and socket server.
54     *
55     * @param ATMSHost The IP of ATMS Server
56     * @param FEP RPC program number
57     * @param FEP RPC program revision number
58     * @param Socket Server listen port
59     */
60    FEPSim(char * ATMSHost, int FEP_PROG, int FEP_REV, int SOCK_PORT);
61   
62    /**
63     * Creates a socket server and awaits the highway status XML responses from the
64     * ATMS Driver. Upon reciept of the highway status XML message, creates an RPC
65     * client and sends the fep_replys to the ATMS.
66     */
67    void runSockServer();
68   
69    /**
70     * Creates an RPC Client, and on successful creation, sends fep_replys to ATMS.
71     * @param The recieved highway status xml.
72     */
73    void manageClientConnection(char * xml);
74   
75    /**
76     * Destructor: Does nothing, no cleaning necessary
77     */
78    ~FEPSim(); // Destructor
79
80private:
81    /* members */
82    char * ATMSHost;
83    int FEP_PROG;
84    int FEP_REV;
85    int SOCK_PORT;
86
87    /**
88     * Handler for the ATMS RPC Response (to the client RPC Call)
89     * @param response pointer to fep_reply struct
90     */
91    void handleCallResponse(void *response);
92   
93    /**
94     * Creates the RPC Client. If not successful, returns false.
95     */
96    bool createClient();
97   
98    /**
99     * Sends an fep_reply for each FEP_LINE. Gets highway status from recieved XML
100     * data.
101     * @param xml The recieved highway status XML.
102     */
103    void sendReplys(char * xml);
104
105};
106
107#endif // __FEPSIM_H_INCLUDED__
Note: See TracBrowser for help on using the repository browser.