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

Revision 221, 3.0 KB checked in by jtorres, 8 years ago (diff)

FEPSim: fixed no matching function for call error message. Also, suppressed annoying deprecated conversion from string constant to char warning in ./buildLinuxVM

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 <fstream>
36#include <stdio.h>
37#include <stdlib.h>
38#include "time.h"
39#include "HighwaysParser.h"
40#include <netdb.h>
41#include <sys/types.h>
42#include <sys/socket.h>
43#include <netinet/in.h>
44#include <unistd.h>
45
46const int BUFF_SIZE = 1266341;
47static ofstream FEPLogFile;
48   
49class FEPSim {
50public:
51    // The RPC Client
52    CLIENT *clnt;
53
54    /**
55     * Constructor. Sets data values for RPC Client and socket server.
56     *
57     * @param ATMSHost The IP of ATMS Server
58     * @param FEP RPC program number
59     * @param FEP RPC program revision number
60     * @param Socket Server listen port
61     */
62    FEPSim(char * ATMSHost, int FEP_PROG, int FEP_REV, int SOCK_PORT);
63   
64    /**
65     * Creates a socket server and awaits the highway status XML responses from the
66     * ATMS Driver. Upon reciept of the highway status XML message, creates an RPC
67     * client and sends the fep_replys to the ATMS.
68     */
69    void runSockServer();
70   
71    /**
72     * Creates an RPC Client, and on successful creation, sends fep_replys to ATMS.
73     * @param The recieved highway status xml.
74     */
75    void manageClientConnection(char * xml);
76   
77    /**
78     * Destructor: Does nothing, no cleaning necessary
79     */
80    ~FEPSim(); // Destructor
81
82private:
83    /* members */
84    char * ATMSHost;
85    int FEP_PROG;
86    int FEP_REV;
87    int SOCK_PORT;
88    char * FEPLogFileName;
89   
90    /**
91     * Handler for the ATMS RPC Response (to the client RPC Call)
92     * @param response pointer to fep_reply struct
93     */
94    void handleCallResponse(void *response);
95   
96    /**
97     * Creates the RPC Client. If not successful, returns false.
98     */
99    bool createClient();
100   
101    /**
102     * Sends an fep_reply for each FEP_LINE. Gets highway status from recieved XML
103     * data.
104     * @param xml The recieved highway status XML.
105     */
106    void sendReplys(char * xml);
107   
108};
109
110#endif // __FEPSIM_H_INCLUDED__
Note: See TracBrowser for help on using the repository browser.