Exemplo n.º 1
0
  public static Sensor createLSMSensor2(VSensorConfig vs) {
    SensorMetaData s = createSensorMetaData(vs);

    System.out.println("*************  NOW publishing *****" + "\n" + vs);
    System.out.println(s);

    Sensor sensor = new Sensor();
    sensor.setName(s.getSensorName());
    sensor.setAuthor(s.getAuthor());
    sensor.setSensorType(s.getSensorType());
    sensor.setSourceType(s.getSourceType());
    sensor.setInfor(s.getInformation());
    sensor.setSource(s.getSource());
    sensor.setTimes(new Date());

    Place place = new Place();
    place.setLat(vs.getLatitude());
    place.setLng(vs.getLongitude());
    sensor.setPlace(place);

    logger.warn("sensor created from file (metadata)");

    return sensor;
  }
Exemplo n.º 2
0
  public Sensor createLSMSensor(VSensorConfig vs) {
    SensorMetaData s = createSensorMetaData(vs);

    String id =
        TestLSM.addSensorToLSM(
            "swissex",
            "swissex1234",
            s.getSensorName(),
            s.getAuthor(),
            s.getSourceType(),
            s.getSensorType(),
            s.getInformation(),
            s.getSource(),
            0,
            0);

    System.out.println("SENSOR ID published to LSM => " + id);

    if (true) return null;

    Sensor sensor = null;
    LSMTripleStore lsmStore = null;

    try {

      System.out.println("Testing LSM...");

      // 1. Create an instanse of Sensor class and set the sensor metadata
      sensor = new Sensor();
      sensor.setName(s.getSensorName());
      sensor.setAuthor(s.getAuthor());
      sensor.setSensorType(s.getSensorType());
      sensor.setSourceType(s.getSourceType());
      sensor.setInfor(s.getInformation());
      sensor.setSource(s.getSource());
      sensor.setMetaGraph("http://lsm.deri.ie/OpenIoT/test/sensormeta#");
      sensor.setDataGraph("http://lsm.deri.ie/OpenIoT/test/sensordata#");
      sensor.setTimes(new Date());

      System.out.println(sensor.getId());

      // set sensor location information (latitude, longitude, city, country, continent...)
      Place place = new Place();
      place.setLat(vs.getLatitude());
      place.setLng(vs.getLongitude());
      sensor.setPlace(place);

      sensor.setUser(user);

      // create LSMTripleStore instance
      lsmStore = new LSMTripleStore();

      // set user information for authentication
      lsmStore.setUser(user);

      System.out.printf(sensor.getId());
      // call sensorAdd method
      lsmStore.sensorAdd(sensor);

      System.out.printf(sensor.getId());

    } catch (Exception e) {
      logger.warn("cannot send the data to server");
      logger.warn(e);
    }

    return sensor;
  }