source: proiecte/ptvs/src/vnsim/applications/vitp/ui/UserInterface.java @ 31

Last change on this file since 31 was 31, checked in by (none), 14 years ago
File size: 2.5 KB
Line 
1/************************************************************************************
2 * Copyright (C) 2008 by Politehnica University of Bucharest and Rutgers University
3 * All rights reserved.
4 * Refer to LICENSE for terms and conditions of use.
5 ***********************************************************************************/
6package vnsim.applications.vitp.ui;
7
8
9
10import java.util.*;
11import java.io.*;
12
13import javax.swing.*;
14
15import vnsim.applications.vitp.Statistics;
16import vnsim.applications.vitp.peer.*;
17import vnsim.applications.vitp.utils.*;
18import vnsim.map.object.Globals;
19
20
21
22public class UserInterface {
23
24        Peer peerModule;
25
26        public void attachModules(Peer p){
27                this.peerModule=p;
28        }
29
30        public boolean postMessage(VITPMessage msg){
31                //method to be called by other modules, in order to send a message
32                //to this user interface module; returns true if the module properly
33                //deals with the message, false, otherwise
34
35                //this module has received a packet; just display it (text)
36               
37//              Statistics.setReplyOK(msg.getId());
38//              Statistics.setText(msg.getId(), msg.getBody());
39//              Statistics.setReplyTime(msg.getId(), Globals.engine.crtTime);
40
41//              JOptionPane.showConfirmDialog(null, "OK");
42                int rd=peerModule.routingModule.car.getRoadIdx();
43                int pt=peerModule.routingModule.car.getPointIdx();
44//              System.out.println("***TIME="+Globals.engine.crtTime+"; ID="+peerModule.routingModule.car.getVehicleId()+"UI AT: "+rd+";"+pt+" has received a message:"+msg.getUserFriendlyText());
45
46                //              System.out.println("REPLYTIME="+Globals.engine.crtTime);
47
48                peerModule.routingModule.car.isInformed=true;
49               
50               
51                return true;
52        }
53
54//      public void run(){
55//              System.out.println("0 for quit; 1-9 to query");
56//
57//              try {
58//                      BufferedReader flux = new BufferedReader(new InputStreamReader(System.in));
59//                      do{
60//                              System.out.print("SegDest=");
61//                              int road1=new Integer(flux.readLine()).intValue();
62//                              System.out.print("From point=");
63//                              int pt1=new Integer(flux.readLine()).intValue();
64//                              System.out.print("To point=");
65//                              int pt2=new Integer(flux.readLine()).intValue();
66//
67//                              VITPRequest req=new VITPRequest(road1, pt1, pt2, 123, 0, 3, new Date(), new Date(), "none",
68//                                      -1, "A Query", "GET", "/vehicle/traffic");
69////                                    123,3 = current Location (should be taken from LocalInfo)
70//
71//                              peerModule.postMessageFromAbove(req);
72//                      } while(true);
73//              } catch (Exception ex){
74//                      System.out.println("UI Exception!:"+ex.toString());
75//              }
76//              return;
77//      }
78}
Note: See TracBrowser for help on using the repository browser.