public boolean init() { boolean res = false; if (connection.isConnected()) { // TODO get configuration (this can be put somewhere else, too) // set delays and time variables boolean r1 = setDelay(Register.DIAMETER_LED_DELAY, PlcConstants.DIAMETER_LED_DELAY); boolean r2 = setDelay( Register.CONGESTION_1_WAIT_TIME, Utility.calcCongestion1Time( PlcConstants.CONGESTION1_SENSING_LENGTH, PlcConstants.TRACK_SPEED)); boolean r3 = setDelay(Register.CONGESTION_1_TOLERANCE, PlcConstants.CONGESTION_TOLERANCE); boolean r4 = setDelay(Register.CONGESTION_2_TOLERANCE, PlcConstants.CONGESTION_TOLERANCE_2ND); boolean r5 = setDelay(Register.SHUT_DOWN_DELAY, PlcConstants.SHUTDOWN_DELAY_SECS); boolean r6 = setDelay( Register.SINGLE_WHOLE_TURN_TIME, Utility.calcTime(PlcConstants.TRACK_LENGTH, PlcConstants.TRACK_SPEED)); boolean r7 = setDelay( Register.BLOWER_ONE_DELAY, Utility.calcTime(PlcConstants.FRONT_BLOWER_ON, PlcConstants.TRACK_SPEED)); boolean r8 = setDelay( Register.BLOWER_ONE_TIME, Utility.calcTime(PlcConstants.FRONT_BLOWER_OFF, PlcConstants.TRACK_SPEED)); boolean r9 = setDelay( Register.BLOWER_TWO_DELAY, Utility.calcTime(PlcConstants.REAR_BLOWER_ON, PlcConstants.TRACK_SPEED)); boolean r10 = setDelay( Register.BLOWER_TWO_TIME, Utility.calcTime(PlcConstants.REAR_BLOWER_RUNNING_TIME, PlcConstants.TRACK_SPEED)); // set the servo null position boolean r11 = setServoNullPosition(PlcConstants.SERVO_NULL_POSITION); res = r1 && r2 && r3 && r4 && r5 && r6 && r7 && r8 && r9 && r10 && r11; } return res; }
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; }
public boolean cleaningStop() { boolean res = false; if (connection.isConnected()) { boolean r1 = setDelay( Register.SINGLE_LENGTH_TURN_TIME, Utility.calcTime(PlcConstants.TRACK_LENGTH / 2, PlcConstants.SLOW_TRACK_SPEED)); boolean r2 = setMode(Mode.TRACK_EMPTYING.getValue()); res = r1 && r2; } return res; }