/////////////////////////////////////////////////////////////////////////////////// // ChildChange() // // Called when a channel is added, deleted or changed on the ai object. /////////////////////////////////////////////////////////////////////////////////// STDMETHODIMP CetfarduinoAin::ChildChange(DWORD typeofchange, NESTABLEPROP* pChan) { if ((typeofchange & CHILDCHANGE_REASON_MASK) == ADD_CHILD) { if (_nChannels == MAX_CHANNELS) { // Maximum number of channels was reached -- unable to add more. return Error(CComBSTR("etfarduino: Maximum number of channels reached, unable to add more.")); } if (pChan->HwChan < 0 || pChan->HwChan > 1) { return Error(CComBSTR("etfarduino: Only channels 0 and 1 are supported.")); } } if (typeofchange & END_CHANGE) { // Update the number of channels that have been added, by querying the engine long numChans; _EngineChannelList->GetNumberOfChannels(&numChans); _nChannels = numChans; // Store data in the local variable _nChannels // Treba dodati ConversionOffset za sve kanale for (int i = 0; i < _nChannels; ++i) { AICHANNEL* aichan = NULL; _EngineChannelList->GetChannelStructLocal(i, (NESTABLEPROP**)&aichan); aichan->ConversionOffset = 1 << (Bits - 1); } // Update all related channel information UpdateChans(true); // Update the sample rate given the additional channel if (pClockSource != CLOCKSOURCE_SOFTWARE) { CalculateSampleRate(pSampleRate); } } return S_OK; }
STDMETHODIMP CbDevice::ChildChange(ULONG typeofchange, tagNESTABLEPROP * pChan) { HRESULT retval=S_OK; //int progress=typeofchange & ~CHILDCHANGE_REASON_MASK; int type=typeofchange & CHILDCHANGE_REASON_MASK; if (pChan) // if we have a channel { switch (type) { case ADD_CHILD : ++_nChannels; retval=UpdateChans(false); // must exist in base class // resizes channel arrrays _updateChildren=true; // now set the new range RANGE_INFO *NewInfo; if (!retval) { retval=FindRange(static_cast<float>(reinterpret_cast<AICHANNEL*>(pChan)->VoltRange[0]), static_cast<float>(reinterpret_cast<AICHANNEL*>(pChan)->VoltRange[1]),NewInfo); if (!retval) _chanRange[_nChannels-1]=NewInfo->rangeInt; } if (retval) --_nChannels; return retval; case DELETE_CHILD : --_nChannels; break; case REINDEX_CHILD : break; } } if (typeofchange & END_CHANGE) { retval=UpdateChans(false); // must exist in base class _updateChildren=true; } return retval; }