com.cesys.cebo.cebomsr
Class Device

java.lang.Object
  extended by com.cesys.cebo.cebomsr.Device

public final class Device
extends java.lang.Object

The primary object to communicate with a CeboMsr-compatible device. Every instance holds a single connection to a device. Instances are created during enumeration in LibraryInterface.enumerate().

Author:
Thomas Hoppe

Field Summary
static int FlagResetInputFifo
          Valid flags to use with Device.resetPeripherals().
 
Method Summary
 int calculateMaxBufferedInputFrames()
          Calculate maximum count of frames that can be buffered on the device when using multiple frame mode.
 void close()
          Close device.
 OutputFrame createOutputFrame()
          Create OutputFrame instance specific to this device.
 java.util.List<AnalogOutput> getAnalogOutputs()
          Return list of analog outputs.
 java.util.List<Counter> getCounters()
          Return list of counters.
 java.util.List<CurrentSource> getCurrentSources()
          Return list of current sources.
 DeviceType getDeviceType()
          Get actual type of device.
 java.util.List<AnalogInput> getDifferentialInputs()
          Return list of differential analog inputs.
 java.util.List<DigitalPort> getDigitalPorts()
          Return list of digital ports.
 java.lang.String getFirmwareVersion()
          Read string which contains the firmware version.
 java.lang.String getIdentifier()
          Return unique id of device.
 java.util.List<Led> getLeds()
          Return list of LED's.
 java.lang.String getSerialNumber()
          Return serial number of device.
 java.util.List<AnalogInput> getSingleEndedInputs()
          Return list of single ended analog inputs.
 float getTemperature()
          Read device temperature in degree celsius.
 java.util.List<Trigger> getTriggers()
          Return list of triggers.
static boolean isSystemAvailable()
          Check if the CeboMsr API is available.
 void open()
          Open device.
 void readBlock(long address, byte[] buffer)
          *** Internal use only ***
 void readBlock(long address, byte[] buffer, int size)
          *** Internal use only ***
 java.util.List<InputFrame> readBlocking(int frameCount)
          Read exact frameCount frames, return after completion, blocks until all data is available.
 InputFrame readFrame()
          Read multiple inputs using the previously defined list (setupInputFrame()).
 java.util.List<InputFrame> readNonBlocking()
          Read at much possible available frames, return immediately.
 long readRegister(long address)
          *** Internal use only ***
 void resetDevice()
          Restore startup defaults in device.
 void resetPeripherals(int mask)
          Reset specified elements in device.
 void setupInputFrame(Input[] inputs)
          Define the inputs that were included in the next frame request (readFrame(), readBlocking() and readNonBlocking()).
 void setupOutputFrame(Output[] outputs)
          Define the outputs that should be set using the next frame based out transfer.
 float startBufferedDataAcquisition(float frameRate, int frameCount, boolean externalStarted)
          Initialize a buffered data acquisition.
 void startBufferedExternalTimedDataAcquisition(int frameCount)
          Initialize a buffered data acquisition.
 float startContinuousDataAcquisition(float frameRate, boolean externalStarted)
          Initialize a continuous data acquisition.
 void startContinuousExternalTimedDataAcquisition()
          Initialize a continuous data acquisition.
 void stopDataAcquisition()
          Stop any form of hardware managed data acquisition.
 java.lang.String toString()
           
 void writeBlock(long address, byte[] buffer)
          *** Internal use only ***
 void writeBlock(long address, byte[] buffer, int size)
          *** Internal use only ***
 void writeFrame(OutputFrame frame)
          Write multiple outputs at once.
 void writeRegister(long address, long value)
          *** Internal use only ***
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

FlagResetInputFifo

public static final int FlagResetInputFifo
Valid flags to use with Device.resetPeripherals().

See Also:
Constant Field Values
Method Detail

open

public void open()
          throws java.io.IOException
Open device.

Throws:
java.io.IOException

close

public void close()
Close device.


resetDevice

public void resetDevice()
                 throws java.io.IOException
Restore startup defaults in device.

Throws:
java.io.IOException

resetPeripherals

public void resetPeripherals(int mask)
                      throws java.io.IOException
Reset specified elements in device.

Parameters:
mask - Bit vector constructed of Device.FlagReset*.
Throws:
java.io.IOException

getIdentifier

public java.lang.String getIdentifier()
Return unique id of device.


getDeviceType

public DeviceType getDeviceType()
Get actual type of device.


getFirmwareVersion

public java.lang.String getFirmwareVersion()
                                    throws java.io.IOException
Read string which contains the firmware version.

Throws:
java.io.IOException

getSerialNumber

public java.lang.String getSerialNumber()
                                 throws java.io.IOException
Return serial number of device.

Throws:
java.io.IOException

getTemperature

public float getTemperature()
                     throws java.io.IOException
Read device temperature in degree celsius.

Throws:
java.io.IOException

calculateMaxBufferedInputFrames

public int calculateMaxBufferedInputFrames()
                                    throws java.io.IOException
Calculate maximum count of frames that can be buffered on the device when using multiple frame mode. Depends on the actively selected inputs.

Returns:
Frame count.
Throws:
java.io.IOException

setupInputFrame

public void setupInputFrame(Input[] inputs)
                     throws java.io.IOException
Define the inputs that were included in the next frame request (readFrame(), readBlocking() and readNonBlocking()).

Parameters:
inputs - Collection of inputs.
Throws:
java.io.IOException

startBufferedDataAcquisition

public float startBufferedDataAcquisition(float frameRate,
                                          int frameCount,
                                          boolean externalStarted)
                                   throws java.io.IOException
Initialize a buffered data acquisition. Frames are buffered in the device memory, so frame loss is not possible.

Parameters:
frameRate - Frequency in Hz to capture frame.
frameCount - Maximum count of frames to capture. Maximum possible frames can calculated using calculateMaxBufferedInputFrames().
externalStarted - If true, sampling starts if an external trigger is detected, immediately otherwise.
Returns:
Corrected frame rate.
Throws:
java.io.IOException

startBufferedExternalTimedDataAcquisition

public void startBufferedExternalTimedDataAcquisition(int frameCount)
                                               throws java.io.IOException
Initialize a buffered data acquisition. Frames are buffered in the device memory, so frame loss is not possible. For every detected trigger, one frame is captured. Too high frequency on the external trigger will create frame loss.

Parameters:
frameCount - Maximum count of frames to capture. Maximum possible frames can calculated using calculateMaxBufferedInputFrames().
Throws:
java.io.IOException

startContinuousDataAcquisition

public float startContinuousDataAcquisition(float frameRate,
                                            boolean externalStarted)
                                     throws java.io.IOException
Initialize a continuous data acquisition. Data must be read as fast as possible using readBlocking()/readNonBlocking(), otherwise an device buffer overflow may occur.

Parameters:
frameRate - Frequency in Hz to capture frame.
externalStarted - If true, sampling starts if an external trigger is detected, immediately otherwise.
Returns:
Corrected frame rate.
Throws:
java.io.IOException

startContinuousExternalTimedDataAcquisition

public void startContinuousExternalTimedDataAcquisition()
                                                 throws java.io.IOException
Initialize a continuous data acquisition. Data must be read as fast as possible using readBlocking()/readNonBlocking(), otherwise an device buffer overflow may occur. For every detected trigger, one frame is captured. Too high frequency on the external trigger will create frame loss.

Throws:
java.io.IOException

stopDataAcquisition

public void stopDataAcquisition()
                         throws java.io.IOException
Stop any form of hardware managed data acquisition.

Throws:
java.io.IOException

readBlocking

public java.util.List<InputFrame> readBlocking(int frameCount)
                                        throws java.io.IOException
Read exact frameCount frames, return after completion, blocks until all data is available.

Parameters:
frameCount - Count of frames to read.
Returns:
Collection of read frames.
Throws:
java.io.IOException

readNonBlocking

public java.util.List<InputFrame> readNonBlocking()
                                           throws java.io.IOException
Read at much possible available frames, return immediately.

Returns:
Collection of frames available at the moment of reading, 0 <= count <= max possible.
Throws:
java.io.IOException

readFrame

public InputFrame readFrame()
                     throws java.io.IOException
Read multiple inputs using the previously defined list (setupInputFrame()).

Returns:
Frame that contains the values of all specified inputs.
Throws:
java.io.IOException

setupOutputFrame

public void setupOutputFrame(Output[] outputs)
                      throws java.io.IOException
Define the outputs that should be set using the next frame based out transfer.

Parameters:
outputs - Collection of outputs.
Throws:
java.io.IOException

writeFrame

public void writeFrame(OutputFrame frame)
                throws java.io.IOException
Write multiple outputs at once. All outputs specified using setupOutputFrame() are modified using the values in the frame.

Parameters:
frame - Instance that holds all values to set.
Throws:
java.io.IOException

createOutputFrame

public OutputFrame createOutputFrame()
Create OutputFrame instance specific to this device.

Returns:
New instance of OutputFrame.

getSingleEndedInputs

public java.util.List<AnalogInput> getSingleEndedInputs()
Return list of single ended analog inputs.


getDifferentialInputs

public java.util.List<AnalogInput> getDifferentialInputs()
Return list of differential analog inputs.


getAnalogOutputs

public java.util.List<AnalogOutput> getAnalogOutputs()
Return list of analog outputs.


getDigitalPorts

public java.util.List<DigitalPort> getDigitalPorts()
Return list of digital ports.


getCounters

public java.util.List<Counter> getCounters()
Return list of counters.


getTriggers

public java.util.List<Trigger> getTriggers()
Return list of triggers.


getCurrentSources

public java.util.List<CurrentSource> getCurrentSources()
Return list of current sources.


getLeds

public java.util.List<Led> getLeds()
Return list of LED's.


isSystemAvailable

public static boolean isSystemAvailable()
Check if the CeboMsr API is available. (If compatible system library can be found.)


readBlock

public void readBlock(long address,
                      byte[] buffer)
               throws java.io.IOException
*** Internal use only ***

Throws:
java.io.IOException

readBlock

public void readBlock(long address,
                      byte[] buffer,
                      int size)
               throws java.io.IOException
*** Internal use only ***

Throws:
java.io.IOException

readRegister

public long readRegister(long address)
                  throws java.io.IOException
*** Internal use only ***

Throws:
java.io.IOException

writeBlock

public void writeBlock(long address,
                       byte[] buffer)
                throws java.io.IOException
*** Internal use only ***

Throws:
java.io.IOException

writeBlock

public void writeBlock(long address,
                       byte[] buffer,
                       int size)
                throws java.io.IOException
*** Internal use only ***

Throws:
java.io.IOException

writeRegister

public void writeRegister(long address,
                          long value)
                   throws java.io.IOException
*** Internal use only ***

Throws:
java.io.IOException

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object