Package de.tfh.pdvl.hp.serialServer

Examples of de.tfh.pdvl.hp.serialServer.SerialServerException


public class HpDataValidator {
   
    public boolean validate(DataMessage data) throws SerialServerException {
       
        if (data.getFrequency() < 0.0001) {
            throw new SerialServerException(5, "frequency out of range");
        }
       
        if (data.getAmplitude() < 0.05 ||
            data.getAmplitude() > 10 ) {
            throw new SerialServerException(4, "amplitude out of range");
        }
    
        if (data.getWaveShape().equals(WaveShape.DC)) {
           
        }
        else if (data.getWaveShape().equals(WaveShape.NOISE)) {
          
        }
        else if (data.getWaveShape().equals(WaveShape.RAMP)) {
            if (data.getFrequency() > 100000) {
                throw new SerialServerException(5, "frequency out of range");
            }
        }
        else if (data.getWaveShape().equals(WaveShape.SINE)) {
            if (data.getFrequency() > 15000000) {
                throw new SerialServerException(5, "frequency out of range");
            }
        }
        else if (data.getWaveShape().equals(WaveShape.SQUARE)) {
            if (data.getFrequency() > 15000000) {
                throw new SerialServerException(5, "frequency out of range");
            }
        }
        else if (data.getWaveShape().equals(WaveShape.TRIANGLE)) {
            if (data.getFrequency() > 100000) {
                throw new SerialServerException(5, "frequency out of range");
            }
        }
        if (! ( (Math.abs(data.getOffset()) + (data.getAmplitude()/2)) < 10
                &&
                Math.abs(data.getOffset()) <= 2* data.getAmplitude()
            ) ) {
            throw new SerialServerException(3, "offset out of range");
        }
       
       
       
        return true;
View Full Code Here


      if (debug) {
        System.err.println("SERIAL: using " + aPort);
      }
     
    } catch (PortInUseException e) {
      throw new SerialServerException("Can't open serial port " + aPort, e);
    } catch (UnsupportedCommOperationException e) {
        throw new SerialServerException("Can't open serial port " + aPort, e);
    } catch (IOException e) {
        throw new SerialServerException("Can't open serial port " + aPort, e);
    }
   
  }
View Full Code Here

TOP

Related Classes of de.tfh.pdvl.hp.serialServer.SerialServerException

Copyright © 2018 www.massapicom. 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.