Index: applications/doprava/traffic_agent.h
===================================================================
--- applications/doprava/traffic_agent.h (revision 836)
+++ applications/doprava/traffic_agent.h (revision 840)
@@ -29,9 +29,8 @@
 //! detector fo incomming flow
 class DetectorIn : public Detector{
-	string from; // from agent
+	public:
 	Array<string> to_sg; // to signal plans
 	void from_setting(const Setting &set){
 		Detector::from_setting(set);
-		UI::get(from,set,"from",UI::compulsory);
 		UI::get(to_sg, set, "to_sg", UI::compulsory);
 	}
@@ -76,8 +75,8 @@
 		datalink data2out;
 	public:
-		SignalGroupHandler(SignalGroup *sg0, const string &agent_name):rv_det_data(){
-			sg=sg0;
+		void connect_sg(SignalGroup &sg0, const string &agent_name){
+			sg=&sg0;
 			for (int i=0;i<sg->detectors.length();i++){
-				rv_det_data.add(RV(agent_name + sg->detectors(i).name, 1)); //TODO intensity occupancy
+				rv_det_data.add(RV(agent_name +"_"+ sg->detectors(i).name, 2)); //TODO intensity occupancy
 			}
 			
@@ -101,8 +100,8 @@
 		datalink outdata2out;
 	public:
-		RequestHandler(RequestOut *rq0, const string &agent_name){
-			rq=rq0;
+		void connect_request(RequestOut &rq0, const string &agent_name){
+			rq=&rq0;
 			for (int i=0;i<rq->from.length();i++){
-				rv.add(RV(agent_name + rq->from(i), 1)); //TODO intensity occupancy
+				rv.add(RV(agent_name +"_"+ rq->from(i), 2)); //TODO intensity occupancy
 			}
 		}
@@ -131,16 +130,20 @@
 		//! description of broadcast dataind
 		RV output_rv;
-			
-		RV action_rv;
-		
-		datalink_part action2ds;
-		
+					
 		//! output recepient
 		Array<RequestOut> requests;
 		Array<RequestHandler> request_handler;
 		
+		//! action description
+		RV action_rv;
+		
+		datalink_part action2ds;
+		
 	public:
 		void validate(){
 			// write internal checks if all was loaded OK
+			
+			// set action variable == this is a feature of the agent!
+			action_rv = RV(name+"_Tc", 1); // <======= example
 		}
 		void receive(const Setting &msg){
@@ -150,10 +153,11 @@
 			if (what=="data"){ // 
 				// field data 
-				//! decription of detected data
+				// extract decription of teh received datavector
 				shared_ptr<RV> rv=UI::build<RV>(msg,"rv",UI::compulsory);
+				// find if it is needed
 				ivec ind=rv->dataind(input_rv); // position of rv in in_rv;
-				if (ind.length()>0){ //data belong here
+				if (ind.length()>0){ //data are interesting
 					vec dt;
-					UI::get(dt, msg, "value",UI::compulsory);
+					UI::get(dt, msg, "value",UI::compulsory); // get data
 					set_subvector(input_data, ind,  dt); //check size?
 				}				
@@ -162,4 +166,23 @@
 			}
 		}
+		void log_register(logger &L, const string &prefix){
+			root::log_register ( L, prefix );
+			logrec->ids.set_size(sg.length()+2);
+			int i;
+			for (i=0;i <sg.length(); i++) {
+				logrec->ids(i)=logrec->L.add_vector(sgh(i).rv_det_data, "");
+			}
+			logrec->ids(i)=logrec->L.add_vector(input_rv,"in_"); i++;
+			logrec->ids(i)=logrec->L.add_vector(output_rv,"out_");
+		}
+		void log_write() const {
+			int i;
+			for (i=0;i <sg.length(); i++) {
+				logrec->L.log_vector(logrec->ids(i), sgh(i).det_data);
+			}
+			logrec->L.log_vector(logrec->ids(i),input_data); i++;
+			logrec->L.log_vector(logrec->ids(i),output_data); i++;
+		}
+		
 		void broadcast(Setting& set){
 			// broadcast data to all neighbours
@@ -169,4 +192,5 @@
 				
 				// copy from create message
+				// create msg with fields {to=..., what=data, rv=..., value = ...}
 				Setting &m_to=msg.add("to",Setting::TypeString);
 				m_to=requests(i).to;
@@ -181,5 +205,5 @@
 			}
 		}
-		void adapt(const vec &glob_dt){			
+		void adapt(const vec &glob_dt){
 			// copy data from global vector to sSGHandlers
 			for (int i=0; i<sgh.length();i++){
@@ -193,5 +217,5 @@
 				needs(i) = sgh(i).expected_load();
 			}
-			vec action = needs/sum(needs); // trivial stuff
+			vec action; // trivial stuff
 			action2ds.filldown(action,glob_ut);
 		}
@@ -199,7 +223,7 @@
 		void ds_register(const DS &ds){
 			for (int i=0; i<sgh.length(); i++){
-				sgh(i).ds2data.set_connection(ds._drv(), sgh(i).rv_det_data);
-			}
-			action2ds.set_connection(action_rv, ds._urv());
+				sgh(i).ds2data.set_connection(sgh(i).rv_det_data, ds._drv());
+			}
+			action2ds.set_connection( ds._urv(), action_rv);
 		}
 		
