Java 类edu.wpi.first.wpilibj.networktables.NetworkTablesJNI 实例源码

项目:Steamworks2017Robot    文件:Vision.java   
@Override
public void sendDataToSmartDashboard() {
  // phone handles vision data for us
  SmartDashboard.putBoolean("LED_On", isLedRingOn());

  boolean gearLiftPhone = false;
  boolean boilerPhone = false;
  ConnectionInfo[] connections = NetworkTablesJNI.getConnections();
  for (ConnectionInfo connInfo : connections) {
    if (System.currentTimeMillis() - connInfo.last_update < 100) {
      if (connInfo.remote_id.equals("Android_GEAR_LIFT")) {
        gearLiftPhone = true;
      } else if (connInfo.remote_id.equals("Android_BOILER")) {
        boilerPhone = true;
      }
    }
  }

  SmartDashboard.putBoolean("VisionGearLift", gearLiftPhone);
  SmartDashboard.putBoolean("VisionGearLift_data", isGearVisionDataValid());
  SmartDashboard.putBoolean("VisionBoiler", boilerPhone);
  SmartDashboard.putBoolean("VisionBoiler_data", isBoilerVisionDataValid());
}
项目:GRIP    文件:NTManager.java   
private void addListener() {
  entryListenerFunctionUid = NetworkTablesJNI.addEntryListener(path,
      (uid, key, value, flags) -> {
        object = value;
        listeners.forEach(c -> c.accept(object));
      },
      ITable.NOTIFY_IMMEDIATE
          | ITable.NOTIFY_NEW
          | ITable.NOTIFY_UPDATE
          | ITable.NOTIFY_DELETE
          | ITable.NOTIFY_LOCAL);
}
项目:GRIP    文件:NTManager.java   
@Override
public void close() {
  NetworkTablesJNI.removeEntryListener(entryListenerFunctionUid);

  synchronized (NetworkTable.class) {
    // This receiver is no longer used.
    if (NTManager.count.addAndGet(-1) == 0) {
      // We are the last resource using NetworkTables so shut it down
      NetworkTable.shutdown();
    }
  }
}
项目:FB2016    文件:Vision.java   
public double getAngle() {
    double offs = (NetworkTablesJNI.getDouble(NT_ANGLE, 0) + 30);
    double getting = ANGLE_MULTIPLIER * offs;
    movingAvg = (movingAvg + getting) / 2.;
    return movingAvg;
}
项目:FB2016    文件:Vision.java   
public double getRemainingDistance() {
    return NetworkTablesJNI.getDouble(NT_DISTANCE, 0);
}
项目:GRIP    文件:NTManager.java   
@Inject
NTManager() {
  // We may have another instance of this method lying around
  NetworkTable.shutdown();

  // Redirect NetworkTables log messages to our own log files.  This gets rid of console spam,
  // and it also lets
  // us grep through NetworkTables messages just like any other messages.
  NetworkTablesJNI.setLogger((level, file, line, msg) -> {
    String filename = new File(file).getName();
    logger.log(ntLogLevels.get(level), String.format("NetworkTables: %s:%d %s", filename, line,
        msg));
  }, 0);

  NetworkTable.setClientMode();

  // When in headless mode, start and stop the pipeline based on the "GRIP/run" key.  This
  // allows robot programs
  // to control GRIP without actually restarting the process.
  NetworkTable.getTable("GRIP").addTableListener("run", (source, key, value, isNew) -> {
    if (gripMode == GripMode.HEADLESS) {
      if (!(value instanceof Boolean)) {
        logger.warning("NetworkTables value GRIP/run should be a boolean!");
        return;
      }

      if ((Boolean) value) {
        if (!pipelineRunner.isRunning()) {
          logger.info("Starting GRIP from NetworkTables");
          pipelineRunner.startAsync();
        }
      } else if (pipelineRunner.isRunning()) {
        logger.info("Stopping GRIP from NetworkTables");
        pipelineRunner.stopAsync();

      }
    }
  }, true);

  NetworkTable.shutdown();
}