Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1568 | - | 1 | package dongfang.mkt.main; |
2 | |||
3 | import java.io.BufferedReader; |
||
4 | import java.io.IOException; |
||
5 | import java.io.InputStreamReader; |
||
6 | import java.io.PrintStream; |
||
7 | |||
8 | import javax.swing.JFrame; |
||
9 | |||
10 | import dongfang.mkt.comm.FrameQueue; |
||
11 | import dongfang.mkt.comm.MKConnection; |
||
12 | import dongfang.mkt.comm.serial.RXTXSerialPort; |
||
13 | import dongfang.mkt.comm.tcp.MKTCPConnection; |
||
14 | import dongfang.mkt.frames.OSDDataRequestFrame; |
||
15 | import dongfang.mkt.frames.OSDDataResponseFrame; |
||
16 | import dongfang.mkt.ui.offscreendisplay.MapImageView; |
||
17 | import dongfang.mkt.ui.offscreendisplay.OSDDataConsumer; |
||
18 | import dongfang.mkt.ui.offscreendisplay.SimpleOSDView; |
||
19 | |||
20 | public class SimpleOSDTool { |
||
21 | private static final PrintStream STDERR = System.out; |
||
22 | |||
23 | private void osd(final FrameQueue q, final OSDDataConsumer consumer, final int interval) throws IOException { |
||
24 | long timer = 0; |
||
25 | OSDDataRequestFrame f = new OSDDataRequestFrame(); |
||
26 | f.setAutoSendInterval(interval); |
||
27 | BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); |
||
28 | Long firsttimestamp = null; |
||
29 | while (!in.ready()) |
||
30 | try { |
||
31 | long now = System.currentTimeMillis(); |
||
32 | if (now - timer > 3000) { |
||
33 | timer = now; |
||
34 | q.sendRequest(f); |
||
35 | } |
||
36 | OSDDataResponseFrame rf = (OSDDataResponseFrame) q.getResponseFor(f, 5000); |
||
37 | long timestamp = System.currentTimeMillis(); |
||
38 | if (firsttimestamp == null) { |
||
39 | firsttimestamp = timestamp; |
||
40 | timestamp = 0; |
||
41 | } else { |
||
42 | timestamp -= firsttimestamp; |
||
43 | } |
||
44 | consumer.update(rf, timestamp); |
||
45 | } catch (IOException ex) { |
||
46 | STDERR.println(ex); |
||
47 | } |
||
48 | } |
||
49 | |||
50 | public static void main(String[] args) throws IOException { |
||
51 | SimpleOSDTool test = new SimpleOSDTool(); |
||
52 | MKConnection _port = new MKTCPConnection(); // new RXTXSerialPort(); |
||
53 | _port.init("8080"); |
||
54 | FrameQueue q = new FrameQueue(_port); |
||
55 | SimpleOSDView v = new SimpleOSDView (); |
||
56 | v.init(); |
||
57 | JFrame f = new JFrame(); |
||
58 | f.getContentPane().add(v); |
||
59 | f.setSize(v.getSize()); |
||
60 | f.setVisible(true); |
||
61 | v.setThatWidth(); |
||
62 | test.osd(q, v, 20); |
||
63 | } |
||
64 | } |