Changeset 819
- Timestamp:
- 02/23/10 01:17:00 (15 years ago)
- Files:
-
- 2 added
- 4 modified
Legend:
- Unmodified
- Added
- Removed
-
applications/doprava/Zlicin.cfg
r816 r819 1 1 agents = { 2 2 { // agent 1 3 class = "BaseTrafficAgent"; 3 4 name = "495"; 4 5 sg = { … … 18 19 } 19 20 }; 20 input = { 21 input = { // remote detectors 21 22 { 22 from = "601";23 name = "DVA1";23 name = "601DVA1"; 24 distance = 100; 24 25 to = {"VC","VD"}; 25 26 }, 26 27 { 27 from = "601";28 name = "DVA";28 name = "601DVA"; 29 distance = 100; 29 30 to = {"VC","VD"}; 30 31 } 31 32 }; 32 output = { 33 output = { // 33 34 { 34 from = {"DVC","DVD"}; 35 from = "VC"; 36 detector ="495DVC"; 35 37 to = "601"; 36 38 } … … 40 42 }, 41 43 { // agent 2 44 class = "BaseTrafficAgent"; 42 45 name = "601"; 43 46 sg = { -
applications/doprava/main_loop.cpp
r814 r819 2 2 /*! 3 3 \file 4 \brief Multi-Estimator (developped for PMSM)5 4 \brief Distributed Traffic light Control Scenario 5 \author Vasek Smidl 6 6 7 7 */ … … 9 9 #include "base/user_info.h" 10 10 #include "base/loggers.h" 11 #include "estim/kalman.h"12 #include "pmsmDS.h"13 #include "filters.h"14 11 #include "aimsun_bdm/aimsun_ds.h" 15 12 #include "traffic_agent.h" 16 13 17 14 using namespace bdm; 15 18 16 int main ( int argc, char* argv[] ) { 19 17 const char *fname; 20 18 if ( argc>1 ) {fname = argv[1]; } 21 19 else { cout << "Missing configuration file.\n Usage: \n $> estimator config_file.cfg"<<endl; abort(); } 22 UIFile F( fname );20 UIFile Cfg ( fname ); 23 21 24 AimsunDS DS; 25 shared_ptr<logger> L = UI::build <logger>( F, "logger" ); 22 // SYSTEM TO CONTROL 23 AimsunDS Ds; //hard-coded so far 24 25 // AGENTS 26 Array<shared_ptr<Participant> > Ags; 27 UI::get ( Ags,Cfg, "agents" ); 28 29 // LOGGER 30 shared_ptr<logger> L = UI::build <logger>( Cfg, "logger" ); 31 if (!L) {L=new stdlog();} // DEFAULT LOGGER <== poor choice, use better ones 32 33 Config MsgStore; 34 MsgStore.setAutoConvert(true); 35 Setting& Queue = MsgStore.getRoot().add("queue", Setting::TypeList); 36 37 // REGISTER ACTIVE OBJECTS IN LOGGER 38 Ds.log_register ( *L, "DS" ); 39 for ( int i=0; i<Ags.length(); i++ ) { 40 Ags ( i )->log_register ( *L,Ags(i)->_name() ); // estimate 41 Ags ( i )->ds_register(Ds); // allows agents to update their datalinks 42 } 43 L->init(); 44 45 vec glob_dt(Ds._drv()._dsize() ); 46 vec glob_ut(Ds._urv()._dsize() ); 47 for ( int tK=0;tK<Ds.max_length();tK++ ) { 48 Ds.log_write ( ); // write stuff to 49 Ds.getdata(glob_dt); 50 51 for ( int i=0; i<Ags.length(); i++ ) { 52 Ags(i) -> adapt(glob_dt); 53 } 54 for ( int i=0; i<Ags.length(); i++ ) { 55 Ags(i) -> broadcast(Queue); 56 } 57 // parse message queue 58 for ( int m=Queue.getLength()-1; m>=0; m-- ) { // go backwards - last mesages are discarded 59 for ( int i=0; i<Ags.length(); i++ ) { 60 Setting& msg=Queue[m]; 61 string m_to=msg["to"]; 62 if (m_to==Ags(i)->_name()) { 63 Ags(i)->receive(msg); 64 Queue.remove(m); 65 break; 66 // message delivered; 67 } 68 } 69 } 70 if (Queue.getLength()>0){bdm_error("undelivered messages - probably unknown neighbours");} 71 72 for ( int i=0; i<Ags.length(); i++ ) { 73 Ags(i) -> act(glob_ut); 74 } 75 76 L->step(); 77 Ds.write(glob_ut); 78 Ds.step(); // simulator step 79 80 for ( int i=0; i<Ags.length(); i++ ) { 81 Ags(i) -> step(); 82 } 83 84 } 26 85 27 86 L->finalize(); 28 87 29 for (int i=0; i<nE; i++){30 delete Dls(i);31 delete Dlsc(i);32 }33 88 return 0; 34 89 } -
library/bdm/base/participants.h
r776 r819 29 29 //! name - ID of the participant 30 30 string name; 31 //! Pointers to neighbours32 Array<string > neighbours;33 31 public: 34 32 //! Empty constructor -
library/bdm/mpdm/arx_agent.h
r787 r819 22 22 class ARXAgent : public Participant { 23 23 protected: 24 //! Pointers to neighbours 25 Array<string > neighbours; 24 26 25 27 //! Internal ARX Controller