Ejemplo n.º 1
0
 @Override
 public void addRecordStore(
     String name, DataComponent recordStructure, DataEncoding recommendedEncoding) {
   recordStructure.setName(name);
   TimeSeriesImpl newTimeSeries =
       new TimeSeriesImpl(getStorage(), recordStructure, recommendedEncoding);
   dataStores.put(name, newTimeSeries);
   modify();
 }
  protected DataBlock computeState(double time) {
    MechanicalState state = orbitPredictor.getECFState(time);

    // send to output
    DataBlock stateData = (lastRecord == null) ? outputDef.createDataBlock() : lastRecord.renew();
    stateData.setDoubleValue(0, state.julianTime);
    stateData.setDoubleValue(1, state.linearPosition.x);
    stateData.setDoubleValue(2, state.linearPosition.y);
    stateData.setDoubleValue(3, state.linearPosition.z);
    stateData.setDoubleValue(4, state.linearVelocity.x);
    stateData.setDoubleValue(5, state.linearVelocity.y);
    stateData.setDoubleValue(6, state.linearVelocity.z);

    return stateData;
  }
Ejemplo n.º 3
0
  @Override
  protected void init() {
    SWEHelper fac = new SWEHelper();

    // build SWE Common record structure
    laserData = fac.newDataRecord(5);
    laserData.setName(getName());
    laserData.setDefinition("http://sensorml.com/ont/swe/property/LaserRangeData");

    // add time, horizontalDistance, azimuth, inclination, and slopeDistance
    laserData.addComponent("time", fac.newTimeStampIsoUTC());
    laserData.addComponent(
        "horizDistance",
        fac.newQuantity(
            SWEHelper.getPropertyUri("HorizontalDistance"), "Horizontal Distance", null, "m"));
    laserData.addComponent(
        "slopeDistance",
        fac.newQuantity(
            SWEHelper.getPropertyUri("LineOfSightDistance"), "Line-of-Sight Distance", null, "m"));

    // for azimuth (trueHeading), we also specify a reference frame
    Quantity q =
        fac.newQuantity(SWEHelper.getPropertyUri("TrueHeading"), "True Heading", null, "deg");
    q.setReferenceFrame("http://sensorml.com/ont/swe/property/NED");
    q.setAxisID("z");
    laserData.addComponent("azimuth", q);

    // for inclination, we also specify a reference frame
    q = fac.newQuantity(SWEHelper.getPropertyUri("Inclination"), "Inclination", null, "deg");
    q.setReferenceFrame("http://sensorml.com/ont/swe/property/NED");
    q.setAxisID("y");
    laserData.addComponent("inclination", q);

    // also generate encoding definition as text block
    dataEncoding = fac.newTextEncoding(",", "\n");
  }
Ejemplo n.º 4
0
  @Override
  public CommandStatus execCommand(DataBlock command) throws SensorException {
    // associate command data to msg structure definition
    DataChoice commandMsg = (DataChoice) commandData.copy();
    commandMsg.setData(command);

    DataComponent component = ((DataChoiceImpl) commandMsg).getSelectedItem();
    String itemID = component.getName();
    DataBlock data = component.getData();
    String itemValue = data.getStringValue();

    // NOTE: you can use validate() method in DataComponent
    // component.validateData(errorList);  // give it a list so it can store the errors
    // if (errorList != empty)  //then you have an error

    try {
      // set parameter value on camera
      // NOTE: except for "presets", the item IDs are labeled the same as the Axis parameters so
      // just use those in the command
      if (itemID.equals(VideoCamHelper.TASKING_PTZPRESET)) {
        PtzPreset preset = presetsHandler.getPreset(data.getStringValue());

        // pan + tilt + zoom (supported since v2 at least)
        URL optionsURL =
            new URL(
                parentSensor.getHostUrl()
                    + "/com/ptz.cgi?pan="
                    + preset.pan
                    + "&tilt="
                    + preset.tilt
                    + "&zoom="
                    + preset.zoom);
        InputStream is = optionsURL.openStream();
        is.close();

      }

      // Act on full PTZ Position
      else if (itemID.equalsIgnoreCase(VideoCamHelper.TASKING_PTZ_POS)) {

        URL optionsURL =
            new URL(
                parentSensor.getHostUrl()
                    + "/com/ptz.cgi?pan="
                    + data.getStringValue(0)
                    + "&tilt="
                    + data.getStringValue(1)
                    + "&zoom="
                    + data.getStringValue(2));
        InputStream is = optionsURL.openStream();
        is.close();

      } else {
        String cmd = " ";
        if (itemID.equals(VideoCamHelper.TASKING_PAN)) cmd = "pan";
        else if (itemID.equals(VideoCamHelper.TASKING_RPAN)) cmd = "rpan";
        else if (itemID.equals(VideoCamHelper.TASKING_TILT)) cmd = "tilt";
        else if (itemID.equals(VideoCamHelper.TASKING_RTILT)) cmd = "rtilt";
        else if (itemID.equals(VideoCamHelper.TASKING_ZOOM)) cmd = "zoom";
        else if (itemID.equals(VideoCamHelper.TASKING_RZOOM)) cmd = "rzoom";

        URL optionsURL =
            new URL(parentSensor.getHostUrl() + "/com/ptz.cgi?" + cmd + "=" + itemValue);
        InputStream is = optionsURL.openStream();
        is.close();
      }

    } catch (Exception e) {
      throw new SensorException("Error connecting to Axis PTZ control", e);
    }

    CommandStatus cmdStatus = new CommandStatus();
    cmdStatus.status = StatusCode.COMPLETED;
    return cmdStatus;
  }
Ejemplo n.º 5
0
  /* TODO: only using HV message; add support for HT and ML */
  private synchronized void pollAndSendMeasurement() {
    long msgTime = System.currentTimeMillis();

    double hd = Double.NaN;
    double incl = Double.NaN;
    double az = Double.NaN;
    double sd = Double.NaN;

    try {
      boolean gotHvMsg = false;
      while (!gotHvMsg) {
        String line = msgReader.readLine();
        String val, unit;

        // parse the data string
        TruPulseSensor.log.debug("Message received: {}", line);
        String[] tokens = line.split(",");

        val = tokens[0];
        if (!val.equals(MSG_PREFIX)) {
          TruPulseSensor.log.warn(
              "Message initial token does NOT equal expected string {}", MSG_PREFIX);
          continue;
        }

        // check for desired message type HV
        val = tokens[1];
        if (!val.equals(MSG_TYPE_HV)) {
          TruPulseSensor.log.warn("Unsupported message type {}", val);
          continue;
        }

        // get horizontal distance measure and check units (convert if not meters)
        val = tokens[2];
        unit = tokens[3];
        if (val.length() > 0 && unit.length() > 0) {
          hd = Double.parseDouble(val);
          hd = convert(hd, unit);
        }

        // get azimuth angle measure (units should be degrees)
        val = tokens[4];
        unit = tokens[5];
        if (val.length() > 0 && unit.length() > 0) az = Double.parseDouble(val);

        // get inclination angle measure (units should be degrees)
        val = tokens[6];
        unit = tokens[7];
        if (val.length() > 0 && unit.length() > 0) incl = Double.parseDouble(val);

        // get slope distance measure and check units (should be meters)
        val = tokens[8];
        unit = tokens[9];
        if (val.length() > 0 && unit.length() > 0) {
          sd = Double.parseDouble(val);
          sd = convert(hd, unit);
        }

        gotHvMsg = true;
      }
    } catch (IOException e) {
      TruPulseSensor.log.error("Unable to parse TruPulse message", e);
    }

    // create and populate datablock
    DataBlock dataBlock;
    if (latestRecord == null) dataBlock = laserData.createDataBlock();
    else dataBlock = latestRecord.renew();

    dataBlock.setDoubleValue(0, msgTime / 1000.);
    dataBlock.setDoubleValue(1, hd);
    dataBlock.setDoubleValue(2, sd);
    dataBlock.setDoubleValue(4, az);
    dataBlock.setDoubleValue(3, incl);

    // update latest record and send event
    latestRecord = dataBlock;
    latestRecordTime = msgTime;
    eventHandler.publishEvent(
        new SensorDataEvent(latestRecordTime, TruPulseOutput.this, dataBlock));
  }
Ejemplo n.º 6
0
  protected void init() {
    GeoPosHelper fac = new GeoPosHelper();

    // SWE Common data structure
    dataStruct = fac.newDataRecord(7);
    dataStruct.setName(getName());
    dataStruct.setDefinition(SWEHelper.getPropertyUri("AVLData"));

    // time
    dataStruct.addComponent("time", fac.newTimeStampIsoUTC());

    // Mobile Data Terminal ID
    dataStruct.addComponent(
        "mdt-id",
        fac.newCategory(
            SWEHelper.getPropertyUri("MDT-ID"), "MDT-ID", "Mobile Data Terminal ID", null));

    // Unit and Vehicle ID (often the same)
    dataStruct.addComponent(
        "unit-id",
        fac.newCategory(SWEHelper.getPropertyUri("Unit-ID"), "Unit ID", "Mobile Unit ID", null));
    dataStruct.addComponent(
        "veh-id",
        fac.newCategory(
            SWEHelper.getPropertyUri("Vehicle-ID"),
            "Vehicle ID",
            "Mobile Vehicle Identification",
            null));

    // location (latitude-longitude)
    Vector locVector = fac.newLocationVectorLatLon(SWEConstants.DEF_SENSOR_LOC);
    locVector.setLabel("Vehicle Location");
    dataStruct.addComponent("location", locVector);

    // status constraints: (AQ - at-station; ER - enroute; AR - arrived?, OS - out-of-service, AK -
    // completed-returning)
    Category status =
        fac.newCategory(
            SWEHelper.getPropertyUri("Vehicle-Status"),
            "Unit Status",
            "Unit-Vehicle Status (AQ, OS, AK, ER, AR)",
            null);
    AllowedTokens constraints = fac.newAllowedTokens();
    constraints.addValue("AQ");
    constraints.addValue("ER");
    constraints.addValue("AR");
    constraints.addValue("OS");
    constraints.addValue("AK");
    status.setConstraint(constraints);
    dataStruct.addComponent("status", status);

    // event (empty if AQ, OS, or AK; event number if ER or AR)
    dataStruct.addComponent(
        "event-id",
        fac.newCategory(
            SWEHelper.getPropertyUri("Event-ID"),
            "Event ID",
            "Assigned ID to an emergency event",
            null));

    // set encoding to CSV
    dataEncoding = fac.newTextEncoding(",", "\n");
  }
Ejemplo n.º 7
0
  private void pollAndSendMeasurement() {
    double julianTime = 0.0;
    String mdtID = " ";
    String vehID = " ";
    String unitID = " ";
    double lat = Double.NaN;
    double lon = Double.NaN;
    String status = " ";
    String eventID = " ";

    try {
      boolean gotMsg = false;
      while (!gotMsg) {
        String line = msgReader.readLine();
        if (line == null || line.length() == 0) return;
        String timeString;
        Date time;

        // parse the data string
        AVLDriver.log.debug("Message received: {}", line);

        // split tokens based on one or more white spaces
        String[] tokens = line.trim().split("\\s+");

        // get time tag in pseudo standard string
        timeString = tokens[0];

        // add "T" at end to make recognizable time zone (e.g. CDT) and then
        //   parse according to predefined Intergraph 911 format
        try {
          time = timeFormat.parse(timeString + "T");
        } catch (ParseException e) {
          AVLDriver.log.warn("Exception parsing date-time string ", timeString + "T");
          continue;
        }

        if (time != null) julianTime = time.getTime() / 1000.0;

        // skip tokens[1]
        mdtID = tokens[2];
        unitID = tokens[3];
        vehID = tokens[4];

        lat = Double.parseDouble(tokens[5]);
        lon = Double.parseDouble(tokens[6]);

        // skip tokens[7 - 15]
        status = tokens[16];
        if (tokens.length > 17) // event id is not always present
        eventID = tokens[17];
        else eventID = "NONE";

        gotMsg = true;
      }
    } catch (IOException e) {
      if (sendData) AVLDriver.log.error("Unable to parse AVL message", e);
      return;
    }

    // create new FOI if needed
    parentSensor.addFoi(julianTime, vehID);

    // create and populate datablock
    DataBlock dataBlock;
    if (latestRecord == null) dataBlock = dataStruct.createDataBlock();
    else dataBlock = latestRecord.renew();

    dataBlock.setDoubleValue(0, julianTime);
    dataBlock.setStringValue(1, mdtID);
    dataBlock.setStringValue(2, unitID);
    dataBlock.setStringValue(3, vehID);
    dataBlock.setDoubleValue(4, lat);
    dataBlock.setDoubleValue(5, lon);
    dataBlock.setStringValue(6, status);
    dataBlock.setStringValue(7, eventID);

    // update latest record and send event
    latestRecord = dataBlock;
    latestRecordTime = System.currentTimeMillis();
    eventHandler.publishEvent(
        new SensorDataEvent(latestRecordTime, vehID, AVLOutput.this, dataBlock));
  }