public void run() {
      int count = 0;
      while (count < 5) {
        display(value);
        Service.sleep(delay);
        display("   ");
        Service.sleep(delay);
        ++count;
      }

      if (leaveOn) {
        display(value);
      }
    }
示例#2
0
  public void startService() {
    super.startService();

    try {
      serial = getSerial();
      // setting callback / message route
      serial.addListener("publishByte", getName(), "byteReceived");
      serial.startService();
      if (model == null) {
        model = MODEL_SICK_LMS200;
      }

      // start LIDAR hardware initialization here
      // data coming back from the hardware will be in byteRecieved
      if (MODEL_SICK_LMS200.equals(model)) {
        serial.write(new byte[] {1, 38, 32, 43});
      }
      state = STATE_INITIALIZATION_STAGE_1;
    } catch (Exception e) {
      error(e.getMessage());
    }
  }
示例#3
0
  public static void main(String[] args) throws ClassNotFoundException {
    // Logger root = (Logger)LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
    Logging logging = LoggingFactory.getInstance();
    logging.configure();
    logging.setLevel(Level.INFO);
    // LoggingFactory.getInstance().setLevel(Level.INFO);

    int test = 35;
    log.info("{}", test);

    log.debug("hello");
    log.trace("trace");
    log.error("error");
    log.info("info");

    PID pid = new PID("pid");
    pid.startService();
    pid.setPID(2.0, 5.0, 1.0);
    pid.setControllerDirection(DIRECTION_DIRECT);
    pid.setMode(MODE_AUTOMATIC);
    pid.setOutputRange(0, 255);
    pid.setSetpoint(100);
    pid.setSampleTime(40);

    GUIService gui = new GUIService("gui");
    gui.startService();

    for (int i = 0; i < 200; ++i) {
      pid.setInput(i);
      Service.sleep(30);
      if (pid.compute()) {
        log.info(String.format("%d %f", i, pid.getOutput()));
      } else {
        log.warn("not ready");
      }
    }
  }
示例#4
0
 public void addPoseListener(Service service) {
   addListener("publishPose", service.getName(), "onPose", Pose.class);
 }
示例#5
0
 public void addOrientationDataListener(Service service) {
   addListener("publishOrientationData", service.getName(), "onOrientationData");
 }
 @Override
 public void startService() {
   super.startService();
   arduino.startService();
   attach(arduino);
 }
示例#7
0
 public void releaseService() {
   detach();
   super.releaseService();
 }