Relacs DAQ Library  0.9.8
Public Member Functions | Static Public Attributes | Protected Member Functions | List of all members
Attenuator Class Referenceabstract

#include <attenuator.h>

Inheritance diagram for Attenuator:
Inheritance graph
[legend]
Collaboration diagram for Attenuator:
Collaboration graph
[legend]

Public Member Functions

 Attenuator (void)
 
 Attenuator (const string &deviceclass)
 
virtual ~Attenuator (void)
 
virtual int lines (void) const =0
 
virtual double minLevel (void) const =0
 
virtual double maxLevel (void) const =0
 
virtual void levels (vector< double > &l) const =0
 
virtual int attenuate (int di, double &decibel)=0
 
virtual int testAttenuate (int di, double &decibel)=0
 
virtual int mute (int di)
 
virtual int testMute (int di)
 
- Public Member Functions inherited from Device
 Device (int type=MiscellaneousType)
 
 Device (const string &deviceclass, int type=MiscellaneousType)
 
virtual ~Device (void)
 
virtual int open (const string &device)
 
virtual int open (Device &device)
 
virtual bool isOpen (void) const =0
 
virtual void close (void)=0
 
virtual int reset (void)
 
virtual const Options & info (void) const
 
virtual const Options & settings (void) const
 
int deviceType (void) const
 
string deviceTypeStr (void) const
 
string deviceClass (void) const
 
string deviceFile (void) const
 
string deviceName (void) const
 
string deviceVendor (void) const
 
string deviceIdent (void) const
 
virtual void setDeviceIdent (const string &ident)
 
virtual void clearError (void)
 
virtual string errorStr (void) const
 
void setErrorStr (const string &strg)
 
void addErrorStr (const string &strg)
 
void setErrorStr (int errnum)
 
void addErrorStr (int errnum)
 
virtual bool success (void) const
 
virtual bool failed (void) const
 

Static Public Attributes

static const double MuteAttenuationLevel = -1.0e37
 
static const int Underflow = -5
 
static const int Overflow = -6
 
- Static Public Attributes inherited from Device
static const int NotOpen = -1
 
static const int InvalidDevice = -2
 
static const int ReadError = -3
 
static const int WriteError = -4
 
static const int InvalidParam = -5
 

Protected Member Functions

void setInfo (void)
 
- Protected Member Functions inherited from Device
void setDeviceType (int type)
 
void setDeviceClass (const string &deviceclass)
 
void setDeviceFile (const string &devicefile)
 
void setDeviceName (const string &devicename)
 
void setDeviceVendor (const string &devicevendor)
 
void addInfo (void)
 
void lock (void) const
 
void unlock (void) const
 
QMutex * mutex (void) const
 
virtual void initOptions (void)
 

Additional Inherited Members

- Public Types inherited from Device
enum  DeviceTypes {
  MiscellaneousType = 0, AnalogInputType = 1, AnalogOutputType = 2, DigitalIOType = 3,
  TriggerType = 4, AttenuatorType = 5, AttenuateType = 6, ManipulatorType = 7,
  TemperatureType = 8, CameraType = 9
}
 
- Static Public Member Functions inherited from Device
static int deviceTypes (void)
 
static string deviceTypeStr (int type)
 
static string getErrorStr (int ern)
 
- Protected Attributes inherited from Device
Options Info
 
Options Settings
 

Detailed Description

Interface for programming an attenuator.

Author
Jan Benda
Version
1.1 The Attenuator class defines an interface for accessing attenuator devices which are used to attenuate output signals. You have to reimplement open(), isOpen(), close(), lines(), minLevel(), maxLevel(), levels(), attenuate(), testAttenuate() for a specific attenuator. The open(), isOpen(), and close() functions are defined in the Device class.

Via a constructor or the open()-function a specific attenuator device is assigned to the Attenuator-class and opened. The isOpen()-function checks whether the device driver for the attenuator is valid and opened. With close() the device driver for the attenuator is closed.

The number of output lines that can be attenuated by the attenuator is returned by lines(). The minimum and maximum possible attenuation level is returned by minLevel() and maxLevel(), respectively. levels() returns all possible attenuation levels.

The attenuation level of an output line can be set by the attenuate()-function. Attenuators usually can be set to discrete attenuation levels only. If you request a specific attenuation level by attenuate(), than it is very likely that the actually set attenuation level differs slightly from the requested one. To make this attenuation level known to the user, attenuate() sets the decibel variable to the actually set attenuation level.

To check whether a requested attenuation level is possible and what level would be set without actually setting it, you can use the testAttenuate()-function.

The mute()-function can be used to mute an output line and testMute() checks whether the output line can be muted. Alternatively, you can call attenuate() with decibel set to MuteAttenuationLevel.

Possible return values of attenuate(), test() and mute() are:

In case you want to use a attenuator device within RELACS, your Attenuator implementation needs to provide a void default constructor (i.e. with no parameters) that does not open the device. Also, include the header file <relacs/relacsplugin.h> and make the Attenuator device known to RELACS with the addAttenuator( ClassNameOfYourAttenuatorImplementation, PluginSetName ) macro.

Constructor & Destructor Documentation

Attenuator ( void  )

Constructs an Attenuator.

Attenuator ( const string &  deviceclass)

Constructs an Attenuator with device class deviceclass.

See Also
setDeviceClass()
~Attenuator ( void  )
virtual

Destructor. Closes the attenuator device driver.

Member Function Documentation

virtual int lines ( void  ) const
pure virtual

Returns the number of output lines the attenuator device supports. Reimplement this function for a specific attenuator. The default implementation returns 1.

See Also
minLevel(), maxLevel(), levels()

Referenced by Attenuate::isOpen(), and Attenuator::setInfo().

virtual double minLevel ( void  ) const
pure virtual

Returns the minimum possible attenuation level in decibel. This number can be negative, indicating amplification.

See Also
maxLevel(), levels(), lines()

Referenced by Attenuate::maxIntensity(), Attenuate::minIntensity(), and Attenuator::setInfo().

virtual double maxLevel ( void  ) const
pure virtual

Returns the maximum possible attenuation level in decibel.

See Also
minLevel(), levels(), lines()

Referenced by Attenuate::maxIntensity(), Attenuate::minIntensity(), and Attenuator::setInfo().

virtual void levels ( vector< double > &  l) const
pure virtual

Returns in l all possible attenuation levels sorted by increasing attenuation levels (highest last).

See Also
minLevel(), maxLevel(), lines()

Referenced by Attenuate::intensities().

virtual int attenuate ( int  di,
double &  decibel 
)
pure virtual

Set the attenuation level of the output line specified by its index di to decibel decibel. decibel can also be set to MuteAttenuationLevel for requesting to mute the attenuator. Returns the actually set level in decibel. In case the attenuator was muted, MuteAttenuationLevel is returned in decibel. If the requested attenuation level is too high or too low (Underflow or Overflow), then the maximum or minimum possible attenuation level is set and returned in decibel. You have to reimplement this function for a specific attenuator.

Returns
  • 0 on success
  • NotOpen: The device driver for the attenuator is not open.
  • InvalidDevice: An invalid device index is requested, i.e. the requested output line is not supported by the attenuator device.
  • WriteError: Failed in setting the attenuation level.
  • Underflow: The requested attenuation level is too high, i.e. the requested signal amplitude is too small.
  • Overflow: The requested attenuation level is too low, i.e. the requested signal amplitude is too large.
See Also
testAtenuate(), mute()

Referenced by Attenuate::attenuate(), Attenuator::mute(), and Attenuate::write().

virtual int testAttenuate ( int  di,
double &  decibel 
)
pure virtual

Tests setting the attenuation level of the output line specified by its index di to decibel decibel. decibel can also be set to MuteAttenuationLevel for requesting to mute the attenuator. Returns the level that would be set in decibel. In case the attenuator would be muted, MuteAttenuationLevel is returned in decibel. If the requested attenuation level is too high or too low (Underflow or Overflow), then the maximum or minimum possible attenuation level is returned in decibel. You have to reimplement this function for a specific attenuator.

Returns
  • 0 on success
  • NotOpen: The device driver for the attenuator is not open.
  • InvalidDevice: An invalid device index is requested, i.e. the requested output line is not supported by the attenuator device.
  • Underflow: The requested attenuation level is too high, i.e. the requested signal amplitude is too small.
  • Overflow: The requested attenuation level is too low, i.e. the requested signal amplitude is too large.
See Also
attenuate(), testMute()

Referenced by Attenuate::testAttenuate(), Attenuator::testMute(), and Attenuate::testWrite().

int mute ( int  di)
virtual

Mutes the output line specified by its index di. The default implementation simply calls attenuate( di, MuteAttenuationLevel ).

Returns
  • 0 on success
  • NotOpen: The device driver for the attenuator is not open.
  • InvalidDevice: An invalid device index is requested, i.e. the requested output line is not supported by the attenuator device.
  • WriteError: Failed in setting the attenuation level.
See Also
attenuate(), testMute()

References Attenuator::attenuate(), and Attenuator::MuteAttenuationLevel.

Referenced by Attenuate::mute().

int testMute ( int  di)
virtual

Tests muting the output line specified by its index di. The default implementation simply calls testAttenuate( di, MuteAttenuationLevel ).

Returns
  • 0 on success
  • NotOpen: The device driver for the attenuator is not open.
  • InvalidDevice: An invalid device index is requested, i.e. the requested output line is not supported by the attenuator device.
  • WriteError: Failed in setting the attenuation level.
See Also
attenuate(), test(), mute()

References Attenuator::MuteAttenuationLevel, and Attenuator::testAttenuate().

Referenced by Attenuate::testMute().

void setInfo ( void  )
protected

Set the device info(). Call this function from open().

See Also
info()

References Device::addInfo(), Device::Info, Attenuator::lines(), Attenuator::maxLevel(), and Attenuator::minLevel().

Member Data Documentation

const double MuteAttenuationLevel = -1.0e37
static

The attenuation level for which the outputline is muted.

Referenced by Attenuator::mute(), and Attenuator::testMute().

const int Underflow = -5
static

Return code indicating a too high requested attenuation level, i.e. the requested signal amplitude is too small.

const int Overflow = -6
static

Return code indicating a too low requested attenuation level, i.e. the requested signal amplitude is too large.


The documentation for this class was generated from the following files: