/************************************************************************************ * Copyright (C) 2008 by Politehnica University of Bucharest and Rutgers University * All rights reserved. * Refer to LICENSE for terms and conditions of use. ***********************************************************************************/ package vnsim.applications.vitp.ui; import java.util.*; import java.io.*; import javax.swing.*; import vnsim.applications.vitp.Statistics; import vnsim.applications.vitp.peer.*; import vnsim.applications.vitp.utils.*; import vnsim.map.object.Globals; public class UserInterface { Peer peerModule; public void attachModules(Peer p){ this.peerModule=p; } public boolean postMessage(VITPMessage msg){ //method to be called by other modules, in order to send a message //to this user interface module; returns true if the module properly //deals with the message, false, otherwise //this module has received a packet; just display it (text) // Statistics.setReplyOK(msg.getId()); // Statistics.setText(msg.getId(), msg.getBody()); // Statistics.setReplyTime(msg.getId(), Globals.engine.crtTime); // JOptionPane.showConfirmDialog(null, "OK"); int rd=peerModule.routingModule.car.getRoadIdx(); int pt=peerModule.routingModule.car.getPointIdx(); // System.out.println("***TIME="+Globals.engine.crtTime+"; ID="+peerModule.routingModule.car.getVehicleId()+"UI AT: "+rd+";"+pt+" has received a message:"+msg.getUserFriendlyText()); // System.out.println("REPLYTIME="+Globals.engine.crtTime); peerModule.routingModule.car.isInformed=true; return true; } // public void run(){ // System.out.println("0 for quit; 1-9 to query"); // // try { // BufferedReader flux = new BufferedReader(new InputStreamReader(System.in)); // do{ // System.out.print("SegDest="); // int road1=new Integer(flux.readLine()).intValue(); // System.out.print("From point="); // int pt1=new Integer(flux.readLine()).intValue(); // System.out.print("To point="); // int pt2=new Integer(flux.readLine()).intValue(); // // VITPRequest req=new VITPRequest(road1, pt1, pt2, 123, 0, 3, new Date(), new Date(), "none", // -1, "A Query", "GET", "/vehicle/traffic"); //// 123,3 = current Location (should be taken from LocalInfo) // // peerModule.postMessageFromAbove(req); // } while(true); // } catch (Exception ex){ // System.out.println("UI Exception!:"+ex.toString()); // } // return; // } }