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

Revision 195, 3.1 KB checked in by jtorres, 9 years ago (diff)

FEPSim.h: changed buffer size. HighwaysParser?.cpp: began new condensed format parsing, not finished. atms_driver_config_local.properties: changed properties file for new highways_fullmap.txt. Highways.java: comments.

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 "HighwaysParser.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
45// const int BUFF_SIZE = 5500000; // where it was
46// const int BUFF_SIZE = 11522291; // what it couldnt be :)
47const int BUFF_SIZE = 950401; // where it is now :)
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
89    /**
90     * Handler for the ATMS RPC Response (to the client RPC Call)
91     * @param response pointer to fep_reply struct
92     */
93    void handleCallResponse(void *response);
94   
95    /**
96     * Creates the RPC Client. If not successful, returns false.
97     */
98    bool createClient();
99   
100    /**
101     * Sends an fep_reply for each FEP_LINE. Gets highway status from recieved XML
102     * data.
103     * @param xml The recieved highway status XML.
104     */
105    void sendReplys(char * xml);
106
107};
108
109#endif // __FEPSIM_H_INCLUDED__
Note: See TracBrowser for help on using the repository browser.