1 | /*! |
---|
2 | \file |
---|
3 | \brief DataSource for experiments with Aimsun |
---|
4 | \author Jan Prikryl. |
---|
5 | |
---|
6 | */ |
---|
7 | |
---|
8 | /* WIN32 stuff */ |
---|
9 | #include <windows.h> |
---|
10 | #include <stdio.h> |
---|
11 | #include <tchar.h> |
---|
12 | |
---|
13 | #include <base/loggers.h> |
---|
14 | |
---|
15 | extern "C" { |
---|
16 | #include "eh_hrd.h" |
---|
17 | #include "vgs_hrd.h" |
---|
18 | } |
---|
19 | |
---|
20 | using namespace bdm; |
---|
21 | |
---|
22 | //! Simulator of traffic - AIMSUN |
---|
23 | class AimsunDS : public DS |
---|
24 | { |
---|
25 | |
---|
26 | protected: |
---|
27 | //! Pointer to realised signal plans stored in local data space of eh_api. |
---|
28 | eh_els3hrd * p_rsp; |
---|
29 | |
---|
30 | //! Target buffer when querying VGS for last section statistics data. |
---|
31 | vgs_sections_stats sections_stats; |
---|
32 | |
---|
33 | public: |
---|
34 | //! Constructor with fixed sampling period |
---|
35 | AimsunDS (); |
---|
36 | |
---|
37 | //! Destructor |
---|
38 | ~AimsunDS (); |
---|
39 | |
---|
40 | //! Get measurements and signal plans from ELS3 controllers |
---|
41 | void getdata ( vec &dt ) const; |
---|
42 | |
---|
43 | //! Write new signal plans to ELS3 |
---|
44 | void write ( vec &ut ); |
---|
45 | |
---|
46 | //! Wait for new data and copy them out to local buffers |
---|
47 | void step(); |
---|
48 | |
---|
49 | //! number of steps |
---|
50 | int max_length() {return stopCycle;} |
---|
51 | |
---|
52 | //! converts i to string, if i has only one digit, adds 0 before it |
---|
53 | string int_to_string(int const i); |
---|
54 | |
---|
55 | virtual void from_setting ( const Setting &cfg ); |
---|
56 | virtual void validate ( void ); |
---|
57 | |
---|
58 | // TODO dodelat void to_setting( Setting &root ) const; |
---|
59 | private: |
---|
60 | //! Handle of the Aimsun process. Used to terminate Aimsun after simulation. |
---|
61 | intptr_t hPid; |
---|
62 | |
---|
63 | //! File name containing vehicle entrances into the network |
---|
64 | string entranceFileName; |
---|
65 | |
---|
66 | //! Stop time of the simulation |
---|
67 | string stopTime; |
---|
68 | |
---|
69 | //! Number of cycles of the simulation |
---|
70 | int stopCycle; |
---|
71 | |
---|
72 | void AimsunDS::initVGS ( |
---|
73 | const vgs_headway_mode headway, |
---|
74 | const string &entrancePath, |
---|
75 | const string §ionStatsPath, |
---|
76 | const string &globalStatsPath |
---|
77 | ); |
---|
78 | |
---|
79 | }; |
---|
80 | UIREGISTER(AimsunDS); |
---|