コード例 #1
0
  public boolean measurementStart(MeasureSetting mode, int length, int diameter) {
    boolean res = false;

    if (connection.isConnected()) {
      Lights l = null;
      switch (mode) {
        case DIAMETER:
          l = Lights.DIAMETER;
          break;
        case LENGTH:
          l = Lights.LENGTH;
          break;
        case BOTH:
          l = Lights.BOTH;
          break;
      }

      boolean r1 =
          setDelay(
              Register.SINGLE_LENGTH_TURN_TIME,
              Utility.calcTime(PlcConstants.TRACK_LENGTH / 2, PlcConstants.TRACK_SPEED) + 1);
      boolean r2 =
          setDelay(
              Register.SENSOR_RELOCATION,
              Utility.calcSensorDelay(
                  PlcConstants.SENSOR_DISTANCE,
                  PlcConstants.TRACK_SPEED,
                  PlcConstants.LIGHTING_CYCLE_TIME));
      boolean r3 =
          setFrequencies(
              Utility.calcMotorFrequency(PlcConstants.TRACK_SPEED),
              Utility.calcMotorFrequency(PlcConstants.TRACK_SPEED));
      boolean r4 = setCylinderDistance(diameter);
      boolean r5 = setLights(l);
      boolean r6 =
          setDelay(
              Register.CONGESTION_2_WAIT_TIME,
              Utility.calcCongestion2Time(
                  PlcConstants.CONGESTION2_SENSING_LENGTH, length, PlcConstants.TRACK_SPEED));
      boolean r7 =
          setDelay(
              Register.LENGTH_LED_DELAY,
              Utility.calcTriggerDelayFromLength(
                  length, PlcConstants.EXPOSITION_LENGTH, PlcConstants.TRACK_SPEED));
      boolean r8 = setMode(Mode.LENGTH_AND_DIAMETER_MEASUREMENT.getValue());

      res = r1 && r2 && r3 && r4 && r5 && r6 && r7 && r8;
    }

    return res;
  }
コード例 #2
0
  public boolean cleaningStart() {
    boolean res = false;

    if (connection.isConnected()) {
      boolean r1 = setCylinderDistance(PlcConstants.SERVO_MAX_POSITION);
      boolean r2 =
          setFrequencies(
              Utility.calcMotorFrequency(PlcConstants.SLOW_TRACK_SPEED),
              Utility.calcMotorFrequency(PlcConstants.SLOW_TRACK_SPEED));
      boolean r3 = setMode(Mode.CLEANING.getValue());

      res = r1 && r2 && r3;
    }

    return res;
  }
コード例 #3
0
  public boolean checkCleanliness() {
    boolean res = false;

    if (connection.isConnected()) {
      boolean r1 =
          setFrequencies(
              Utility.calcMotorFrequency(PlcConstants.TRACK_SPEED),
              Utility.calcMotorFrequency(PlcConstants.TRACK_SPEED));

      // sleep 2s until the track is started
      try {
        Thread.sleep(2000);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }

      boolean r2 = setMode(Mode.CLARITY_CHECKING.getValue());

      res = r1 && r2;
    }

    return res;
  }