root/applications/doprava/traffic_agent.cpp @ 941

Revision 941, 1.2 kB (checked in by ondrak, 14 years ago)

greenwave agents sending and receiving some expectations
very basic expected_output counting in Lane_Handler

Line 
1#include "traffic_agent.h"
2
3void LaneHandler::connect_data(BaseTrafficAgent& agent0)
4{
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}
14
15double LaneHandler::expected_output(double green_time){
16        double last_inputs=0.0;
17
18        agentin2input.filldown(agent->inputs, inputs);
19        queue = agent->queues(queue_index);
20       
21        double exp_output=0.0;
22       
23        /////////
24        //Velmi jednoduchy odhad
25        agentin2input.filldown(agent->inputs,inputs);
26
27                for (int i=0;i<inputs.length();i+=2) {
28                last_inputs+=inputs(i);
29        }
30
31        exp_output=last_inputs*(green_time/agent->step_time);
32
33        ////////
34        return exp_output;
35}
36
37
38void BaseTrafficAgent::from_setting(const Setting& set)
39{
40    bdm::Participant::from_setting(set);
41       
42        // load from file
43        if (set.exists("lanes")){
44                Setting &Slanes=set["lanes"];
45                lanes.set_length(Slanes.getLength());
46                for(int l=0; l<lanes.length(); l++){
47                        lanes(l).from_setting(Slanes[l]);
48                }
49        }
50        //UI::get(lanes,set,"lanes", UI::compulsory);
51        UI::get(neighbours, set, "neighbours", UI::optional);
52}
Note: See TracBrowser for help on using the browser.