Package uk.co.brunella.osgi.bdt.example.sensor.temperature

Examples of uk.co.brunella.osgi.bdt.example.sensor.temperature.TemperatureSensor


import uk.co.brunella.osgi.bdt.example.sensor.temperature.TemperatureSensor;

public class Activator implements BundleActivator {

  public void start(BundleContext context) throws Exception {
    TemperatureSensor sensor = new EngineTemperatureSensor();
    Dictionary<Object, Object> properties = new Hashtable<Object, Object>();
    properties.put(TemperatureSensor.SENSOR_NAME, "Engine Sensor");
    properties.put(TemperatureSensor.MIN_TEMPERATURE, -10.0);
    properties.put(TemperatureSensor.MAX_TEMPERATURE, 110.0);
    context.registerService(TemperatureSensor.class.getName(), sensor, properties);
View Full Code Here


import uk.co.brunella.osgi.bdt.example.sensor.temperature.TemperatureSensor;

public class Activator implements BundleActivator {

  public void start(BundleContext context) throws Exception {
    TemperatureSensor sensor = new IceTemperatureSensor();
    Dictionary<Object, Object> properties = new Hashtable<Object, Object>();
    properties.put(TemperatureSensor.SENSOR_NAME, "Ice Sensor");
    properties.put(TemperatureSensor.MIN_TEMPERATURE, 0.0);
    properties.put(TemperatureSensor.MAX_TEMPERATURE, Double.MAX_VALUE);
    context.registerService(TemperatureSensor.class.getName(), sensor, properties);
View Full Code Here

  public void callback() {
    ServiceReference[] references = tracker.getServiceReferences();
    if (references != null) {
      for (ServiceReference reference : references) {
        TemperatureSensor sensor = (TemperatureSensor) tracker.getService(reference);
        Double minTemperature = (Double) reference.getProperty(TemperatureSensor.MIN_TEMPERATURE);
        Double maxTemperature = (Double) reference.getProperty(TemperatureSensor.MAX_TEMPERATURE);
        String sensorName = (String) reference.getProperty(TemperatureSensor.SENSOR_NAME);
       
        double temperature = sensor.readTemperature();
        if (temperature >= minTemperature && temperature <= maxTemperature) {
          reportNormal(sensorName, temperature);
        } else if (temperature < minTemperature) {
          reportTooLow(sensorName, temperature);
        } else {
View Full Code Here

TOP

Related Classes of uk.co.brunella.osgi.bdt.example.sensor.temperature.TemperatureSensor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.