ns2::ActivityWriter Class Reference


Detailed Description

class for writing ns2 activity files activity files enable vehicles at first occurence and disable vehicles at last occurence
Author:
Thimor Bohn <bohn@itm.uni-luebeck.de>

Definition at line 15 of file ActivityWriter.java.


Static Public Member Functions

static void write (String activity, List< String > wantedVehicle, List< String > vehicleNewId, Map< String, Double > vehicleFirstOcc, Map< String, Double > vehicleLastOcc, double begin, double penetration, boolean hasPenetration)

Member Function Documentation

static void ns2::ActivityWriter::write ( String  activity,
List< String >  wantedVehicle,
List< String >  vehicleNewId,
Map< String, Double >  vehicleFirstOcc,
Map< String, Double >  vehicleLastOcc,
double  begin,
double  penetration,
boolean  hasPenetration 
) [inline, static]

working method

Parameters:
activity name of ns2 activity file
wantedVehicle list of vehicles to be selected for ns2
vehicleNewId list of vehicle ids for ns2
vehicleFirstOcc map: vehicle id -> first occurence of vehicle in sumo
vehicleLastOcc map: vehicle id -> last occurence of vehicle in sumo
begin sumo time at which ns2 should start to simulate

Definition at line 25 of file ActivityWriter.java.

00033                                     {
00034         try {
00035             PrintWriter out = new PrintWriter(activity);
00036             for (String id: wantedVehicle) {
00037                 String newId =  vehicleNewId.get(wantedVehicle.indexOf(id));
00038                 double minP =  Double.parseDouble(newId)/wantedVehicle.size();
00039                 if (hasPenetration) {
00040                     if (penetration > minP) {
00041                         out.println("$ns_ at " + (vehicleFirstOcc.get(id)-begin) + " \"$g(" + newId + ") start\"" + "\t;# SUMO-ID: " + id);
00042                         out.println("$ns_ at " + (vehicleLastOcc.get(id)-begin) + " \"$g(" + newId + ") stop\"" + "\t;# SUMO-ID: " + id);
00043                     }
00044                 } else {
00045                     out.println("if { $opt(penetration) > " + minP  + " } { ");
00046                     out.println("  $ns_ at " + (vehicleFirstOcc.get(id)-begin) + " \"$g(" + newId + ") start\"" + "\t;# SUMO-ID: " + id);
00047                     out.println("  $ns_ at " + (vehicleLastOcc.get(id)-begin) + " \"$g(" + newId + ") stop\"" + "\t;# SUMO-ID: " + id);
00048                     out.println("}");
00049                 }
00050             }
00051             out.flush();
00052             out.close();
00053         } catch (FileNotFoundException ex) {
00054             System.err.println(ex);
00055         }
00056     }


The documentation for this class was generated from the following file:

Generated on Wed May 5 00:07:02 2010 for Sumo - Simulation of Urban MObility by  doxygen 1.5.6