/** * Create a new instance of an analog module. * * Create an instance of the analog module object. Initialize all the parameters * to reasonable values on start. * Setting a global value on an analog module can be done only once unless subsequent * values are set the previously set value. * Analog modules are a singleton, so the constructor is never called outside of this class. * * @param slot The slot in the chassis that the module is plugged into. */ AnalogModule::AnalogModule(UINT32 slot) : Module(slot) , m_module (NULL) , m_sampleRateSet (false) , m_numChannelsToActivate (0) { status = 0; AddToSingletonList(); m_module = new tAI(SlotToIndex(slot), &status); SetNumChannelsToActivate(kAnalogChannels); SetSampleRate(kDefaultSampleRate); for (UINT32 i = 0; i < kAnalogChannels; i++) { m_module->writeScanList(i, i, &status); SetAverageBits(i + 1, kDefaultAverageBits); SetOversampleBits(i + 1, kDefaultOversampleBits); } if (m_registerWindowSemaphore == NULL) { // Needs to be global since the protected resource spans both module singletons. m_registerWindowSemaphore = semMCreate(SEM_Q_PRIORITY | SEM_DELETE_SAFE | SEM_INVERSION_SAFE); } wpi_assertCleanStatus(status); }
/** * Create a new instance of an analog module. * * Create an instance of the analog module object. Initialize all the parameters * to reasonable values on start. * Setting a global value on an analog module can be done only once unless subsequent * values are set the previously set value. * Analog modules are a singleton, so the constructor is never called outside of this class. * * @param moduleNumber The analog module to create (1 or 2). */ AnalogModule::AnalogModule(UINT8 moduleNumber) : Module(nLoadOut::kModuleType_Analog, moduleNumber) , m_module (NULL) , m_sampleRateSet (false) , m_numChannelsToActivate (0) { AddToSingletonList(); tRioStatusCode localStatus = NiFpga_Status_Success; m_module = tAI::create(m_moduleNumber - 1, &localStatus); wpi_setError(localStatus); SetNumChannelsToActivate(kAnalogChannels); SetSampleRate(kDefaultSampleRate); for (UINT32 i = 0; i < kAnalogChannels; i++) { m_module->writeScanList(i, i, &localStatus); wpi_setError(localStatus); SetAverageBits(i + 1, kDefaultAverageBits); SetOversampleBits(i + 1, kDefaultOversampleBits); } if (m_registerWindowSemaphore == NULL) { // Needs to be global since the protected resource spans both module singletons. m_registerWindowSemaphore = semMCreate(SEM_Q_PRIORITY | SEM_DELETE_SAFE | SEM_INVERSION_SAFE); } }