analog_out.cc
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <iostream>
00025 #include "claraty/analog_out.h"
00026
00027 #ifdef RTS_VXWORKS
00028 #include <sysLib.h>
00029
00030 #endif
00031
00032
00033
00034 namespace claraty {
00035
00036
00037
00038
00039
00040 AO::AO (AO_impl& ao_impl, int channel, float gain, float offset) :
00041 _ao_impl (ao_impl),
00042 _channel (channel),
00043 _gain (gain),
00044 _offset (offset)
00045 {
00046
00047
00048
00049 if (gain == 0.0) {
00050 set_gain_for_V();
00051 set_offset_for_V();
00052 }
00053
00054 #ifdef VERBOSE
00055
00056 cout << "AO: channel = " << channel << "; gain = " << _gain << "; offset = " << _offset << endl;
00057 #endif
00058
00059
00060 output(0.);
00061
00062 }
00063
00064 int AO::output(float data)
00065 {
00066
00067 int data2 = (int) (data * _gain + _offset);
00068
00069 _ao_impl.output(_channel, data2);
00070
00071 #ifdef VERBOSE
00072
00073 cout << "AO::output(" << dec << data << "): _ao_impl.output("
00074 << _channel << ", " << hex << data2 << "): " << dec << endl;
00075 #endif
00076
00077 return 0;
00078 }
00079
00080
00081 void AO::set_gain_for_V()
00082 {
00083 _gain = _ao_impl.get_gain_for_V(_channel);
00084 }
00085
00086
00087 void AO::set_offset_for_V()
00088 {
00089 _offset = _ao_impl.get_offset_for_V(_channel);
00090 }
00091
00092
00093 }