Package com.grt192.mechanism

Source Code of com.grt192.mechanism.GRTCompressor

package com.grt192.mechanism;

import com.grt192.actuator.GRTRelay;
import com.grt192.core.Mechanism;
import com.grt192.event.component.SwitchListener;
import com.grt192.sensor.GRTSwitch;

/**
*
* @author anand
*/
public class GRTCompressor extends Mechanism implements SwitchListener {

    private GRTRelay compressorPower;
    private GRTSwitch pressureSwitch;
   
    private boolean started;

    public GRTCompressor(int powerChannel, int switchChannel) {
        this(new GRTRelay(powerChannel), new GRTSwitch(switchChannel, 5));
    }

    public GRTCompressor(GRTRelay power, GRTSwitch limit) {
        compressorPower = power;
        compressorPower.start();
        addActuator("powerRelay", power);
        pressureSwitch = limit;
        pressureSwitch.start();
        addSensor("pressureSwitch", pressureSwitch);
        pressureSwitch.addSwitchListener(this);
        started = false;
    }

    public void switchPressed(GRTSwitch source) {
        stopCompressor();
    }

    public void switchReleased(GRTSwitch source) {
        startCompressor();
    }

    public void startCompressor() {
        compressorPower.enqueueCommand(GRTRelay.RELAY_FORWARD);
        started = true;
    }

    public void stopCompressor() {
        compressorPower.halt();
    }
   
    public boolean isPressurized(){
      return pressureSwitch.getState("Value") == GRTSwitch.CLOSED;
    }

  public boolean isStarted() {
    return started;
  }
   
}
TOP

Related Classes of com.grt192.mechanism.GRTCompressor

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.