File: TemperatureDisplay.java

package info (click to toggle)
lcm 1.3.1%2Brepack1-9
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,848 kB
  • sloc: ansic: 16,186; java: 6,843; cs: 2,266; cpp: 1,594; python: 989; makefile: 352; xml: 252; sh: 59
file content (33 lines) | stat: -rw-r--r-- 860 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import lcm.lcm.*;
import java.io.*;

import lcmtypes.*;

public class TemperatureDisplay implements LCMSubscriber
{
    public void messageReceived(LCM lcm, String channel, LCMDataInputStream ins)
    {
        try {
            temperature_t temp = new temperature_t(ins);
            System.out.println("The temperature is: "+temp.deg_celsius);
        } catch (IOException ex) {
            System.out.println("Error decoding temperature message: "+ex);
        }
    }

    public static void main(String args[])
    {
        LCM myLCM = LCM.getSingleton();

        myLCM.subscribe("HALLWAY_TEMPERATURE", new TemperatureDisplay());

        // Sleep forever: if we quit, so will the LCM thread.
        while (true)
	    {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException ex) {
            }
	    }
    }
}