Show
Ignore:
Timestamp:
05/06/10 17:42:05 (14 years ago)
Author:
smidl
Message:

traffic agents -- pro BDM > r904

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • applications/doprava/traffic_agent.cpp

    r842 r927  
    11#include "traffic_agent.h" 
    22 
    3 void SignalGroup::from_setting(const libconfig::Setting& set) 
     3void LaneHandler::connect_data(BaseTrafficAgent& agent0) 
    44{ 
    5 UI::get(name,set, "name", UI::compulsory); 
    6 UI::get(detectors, set, "detectors", UI::optional); 
    7 // 
    8 // TODO make some analysis of the detectors 
     5        agent = &agent0; 
     6        agentin2input.set_connection(rv_inputs, agent->rv_inputs); 
     7        ivec queue_index_tmp = agent->rv_queues.dataind(rv_queue); 
     8        if (queue_index_tmp.length()==1){ 
     9                queue_index=queue_index_tmp(0); 
     10        } else { 
     11                bdm_error("queue " + lane.queue + " not found"); 
     12        }                
     13} 
    914 
     15double LaneHandler::expected_output(double green_time){ 
     16        agentin2input.filldown(agent->inputs, inputs); 
     17        queue = agent->queues(queue_index); 
     18         
     19        double exp_output=0.0; 
     20        ///////// 
     21         
     22         
     23        //////// 
     24        return exp_output; 
    1025} 
     26 
    1127 
    1228void BaseTrafficAgent::from_setting(const Setting& set) 
     
    1531         
    1632        // load from file 
    17         UI::get(sg,set,"sg", UI::compulsory); 
    18         UI::get(requests,set,"output",UI::compulsory); 
    19         Array<DetectorIn> det_in; 
    20         UI::get(det_in, set, "input",UI::compulsory); 
    21          
    22         // process sg == create handles 
    23         sgh.set_length(sg.length()); 
    24         for(int i=0;i<sg.length();i++){ 
    25                 sgh(i).connect_sg(sg(i),name); 
     33        if (set.exists("lanes")){ 
     34                Setting &Slanes=set["lanes"]; 
     35                lanes.set_length(Slanes.getLength()); 
     36                for(int l=0; l<lanes.length(); l++){ 
     37                        lanes(l).from_setting(Slanes[l]); 
     38                } 
    2639        } 
    27          
    28         // process output == handles 
    29         request_handler.set_length(requests.length()); 
    30         for(int i=0;i<requests.length();i++){ 
    31                 request_handler(i).connect_request(requests(i),name); 
    32                 output_rv.add(request_handler(i).rv); 
    33         } 
    34  
    35         // process DetIn - create input 
    36         for (int i=0; i<det_in.length(); i++){ 
    37                 input_rv.add(RV(det_in(i).name,2)); 
    38         } 
    39         input_data.set_size(input_rv._dsize()); 
     40        //UI::get(lanes,set,"lanes", UI::compulsory); 
     41        UI::get(neighbours, set, "neighbours", UI::optional); 
    4042}