Warning: Can't use blame annotator:
svn blame failed on branches/FEPSimulator/FEPSim.h: ("Can't find a temporary directory: Internal error", 20014)

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

Revision 233, 3.1 KB checked in by jtorres, 8 years ago (diff)

FEPSim: finalized comments, added to both header and source files.

RevLine 
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 actual FEP "polls" actual stations over serial communication lines, whereas
7 * the FEP Simulator receives highways status data over a socket from the Java
8 * ATMS Driver. The highways status data is then parsed by the Network Reader.
9 *
10 * The data is reconfigured into an fep_reply struct, then sent to the ATMS via
11 * RPC Calls. The RPC Calls to the ATMS Server send an the fep_reply structs.
12 * There is one fep_reply structure sent to the ATMS for every station.
13 *
14 * @author John A. Torres
15 * @version 9/8/2017
16 */
17
18// Include guard
19#ifndef __FEPSIM_H_INCLUDED__
20#define __FEPSIM_H_INCLUDED__
21
22// Forward declared dependencies
23class HighwaysParser;
24
25// Included dependencies
26#include "fep.h"
27#include <iostream>
28#include <fstream>
29#include <stdio.h>
30#include <stdlib.h>
31#include "time.h"
32#include "HighwaysParser.h"
33#include <netdb.h>
34#include <sys/types.h>
35#include <sys/socket.h>
36#include <netinet/in.h>
37#include <unistd.h>
38#include <time.h>
39
40// this buffer is the size of the entire highways data message + 1 for the
41// appended newline character, when sent over the socket
42const int BUFF_SIZE = 1266341;
43// Log file for FEPSimulator
44static ofstream FEPLogFile;
45   
46class FEPSim {
47public:
48    // The RPC Client
49    CLIENT *clnt;
50
51    /**
52     * Constructor. Sets data values for RPC Client and socket server.
53     *
54     * @param ATMSHost The IP of ATMS Server
55     * @param FEP RPC program number
56     * @param FEP RPC program revision number
57     * @param Socket Server listen port
58     */
59    FEPSim(char * ATMSHost, int FEP_PROG, int FEP_REV, int SOCK_PORT);
60   
61    /**
62     * Creates a socket server and awaits the highway status message from the
63     * ATMS Driver. Upon receipt of the highway status message, creates an RPC
64     * client and sends the fep_replys to the ATMS.
65     */
66    void runSockServer();
67   
68    /**
69     * Creates an RPC Client, and on successful creation, sends fep_replys to ATMS.
70     * @param The recieved highway status msg.
71     */
72    void manageClientConnection(char * buffer);
73   
74    /**
75     * Destructor: closes the log file if open
76     */
77    ~FEPSim(); // Destructor
78
79private:
80    // atms ip address
81    char * ATMSHost;
82    // rpc program number
83    int FEP_PROG;
84    // rpc revision number
85    int FEP_REV;
86    // socket port
87    int SOCK_PORT;
88    // name of logging file
89    char * FEPLogFileName;
90   
91    /**
92     * Handler for the ATMS RPC Response (to the client RPC Call)
93     * @param response pointer to fep_reply struct
94     */
95    void handleCallResponse(void *response);
96   
97    /**
98     * Creates an RPC Client to the ATMS Server. If unsuccessful, returns false
99     * @return bool success
100     */
101    bool createClient();
102   
103    /**
104     * Sends an fep_reply for each station on the FEPLine.
105     * Gets highway status from recieved socket msg.
106     *
107     * @param buffer The recieved highway status msg.
108     */
109    void sendReplys(char * buffer);
110};
111
112#endif // __FEPSIM_H_INCLUDED__
Note: See TracBrowser for help on using the repository browser.