com.gatespace.service.adc.impl
Class ADCServiceImpl

java.lang.Object
  |
  +--com.gatespace.service.adc.impl.ADCServiceImpl

public class ADCServiceImpl
extends java.lang.Object
implements ADCService, java.lang.Runnable

Implementation of ADCService. To init, construct with ADCServiceImpl(javax.comm.SerialPort) then start with start().

This code uses a low-level implementation in an ADCLowLevel to actually read data from the port.


Field Summary
protected  boolean bInitialized
           
protected  ADCLowLevel low
           
protected  int readDelay
           
protected  java.lang.Thread runner
           
protected  com.gatespace.service.adc.impl.SerialPort serialPort
           
 
Fields inherited from interface com.gatespace.service.adc.ADCService
CLASS_NAME
 
Constructor Summary
ADCServiceImpl(com.gatespace.service.adc.impl.SerialPort serialPort, ADCLowLevel low)
          Construct the service.
 
Method Summary
 Channel[] getChannels()
          Get all available A/D channels.
 int getType()
          Get ADC unit type.
 int getVersion()
          Get ADC unit version.
 boolean isStarted()
          Get current status of service.
protected  int readValue(Channel ch)
           
 void run()
          Run thread.
protected  void start()
          Set up ADC unit
protected  void stop()
          From ADCService interface.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialPort

protected com.gatespace.service.adc.impl.SerialPort serialPort

runner

protected java.lang.Thread runner

readDelay

protected int readDelay

bInitialized

protected boolean bInitialized

low

protected ADCLowLevel low
Constructor Detail

ADCServiceImpl

public ADCServiceImpl(com.gatespace.service.adc.impl.SerialPort serialPort,
                      ADCLowLevel low)
Construct the service.
Method Detail

getChannels

public Channel[] getChannels()
Description copied from interface: ADCService
Get all available A/D channels.
Specified by:
getChannels in interface ADCService

isStarted

public boolean isStarted()
Description copied from interface: ADCService
Get current status of service.
Specified by:
isStarted in interface ADCService
Tags copied from interface: ADCService
Returns:
true if ADC is started, false if stopped.

getType

public int getType()
Description copied from interface: ADCService
Get ADC unit type. This is '16' for the ADC16
Specified by:
getType in interface ADCService

getVersion

public int getVersion()
Description copied from interface: ADCService
Get ADC unit version.
Specified by:
getVersion in interface ADCService

start

protected void start()
Set up ADC unit

stop

protected void stop()
From ADCService interface. Stop poll thread etc

run

public void run()
Run thread. Poll data each readDelay for all channels. Notify listeners when values change.
Specified by:
run in interface java.lang.Runnable

readValue

protected int readValue(Channel ch)
                 throws java.io.IOException