#include "Brooks0254Card.hh" #include "Brooks0254Par.hh" //! Initilize a card for Brooks0254 device //! The list of all parameters is hardcoded here //! To add a new parameter another curly bracket block needs to be //! created below and recompiled Brooks0254Card::Brooks0254Card( Brooks0254Module& module, unsigned cardNum ) : Brooks0254Module( module ), bcCardNum( cardNum ) { unsigned portNum = bmPort->GetID(); string dev = bmPort->GetDevice(); if ( bmDebFlag ) cout << "Creating card # " << cardNum << " for port #" << portNum << " on " << dev << endl; InitMutex(); //! Below we define input parameters for a Brooks0254 card //! Input port type { Brooks0254ParID parID( Brooks0254ParID::bpiInput, 0 ) ; Brooks0254Par* newPar = new Brooks0254Par( *this, parID ) ; MtxLock scopeLock( bmMutex ); bcPar[parID] = newPar ; } //! Decimal point { Brooks0254ParID parID( Brooks0254ParID::bpiInput, 3 ) ; Brooks0254Par* newPar = new Brooks0254Par( *this, parID ) ; MtxLock scopeLock( bmMutex ); bcPar[parID] = newPar ; newPar->SetWriteValue( Brooks0254BasePar::bbpDecPoint ); } //! Measuremnt units { Brooks0254ParID parID( Brooks0254ParID::bpiInput, 4 ) ; Brooks0254Par* newPar = new Brooks0254Par( *this, parID ) ; MtxLock scopeLock( bmMutex ); bcPar[parID] = newPar ; } //! Full scale { Brooks0254ParID parID( Brooks0254ParID::bpiInput, 9, 0.01 ) ; Brooks0254Par* newPar = new Brooks0254Par( *this, parID ) ; MtxLock scopeLock( bmMutex ); bcPar[parID] = newPar ; } //! Rate time base { Brooks0254ParID parID( Brooks0254ParID::bpiInput, 10 ) ; Brooks0254Par* newPar = new Brooks0254Par( *this, parID ) ; MtxLock scopeLock( bmMutex ); bcPar[parID] = newPar ; } //! Gas factor { Brooks0254ParID parID( Brooks0254ParID::bpiInput, 27, 0.01 ) ; Brooks0254Par* newPar = new Brooks0254Par( *this, parID ) ; MtxLock scopeLock( bmMutex ); bcPar[parID] = newPar ; } //! Non-resettbale totlizer { Brooks0254ParID parID( Brooks0254ParID::bpiInput, 101, 0.01 ) ; Brooks0254Par* newPar = new Brooks0254Par( *this, parID ) ; MtxLock scopeLock( bmMutex ); bcPar[parID] = newPar ; } //! Resettable totlizer { Brooks0254ParID parID( Brooks0254ParID::bpiInput, 102, 0.01 ) ; Brooks0254Par* newPar = new Brooks0254Par( *this, parID ) ; MtxLock scopeLock( bmMutex ); bcPar[parID] = newPar ; } //! Actual PV value { Brooks0254ParID parID( Brooks0254ParID::bpiInput, 103, 0.01 ) ; Brooks0254Par* newPar = new Brooks0254Par( *this, parID ) ; MtxLock scopeLock( bmMutex ); bcPar[parID] = newPar ; } // //! Below we define the output parameters for a Brooks0254 card //! Port type { Brooks0254ParID parID( Brooks0254ParID::bpiOutput, 0 ) ; Brooks0254Par* newPar = new Brooks0254Par( *this, parID ) ; MtxLock scopeLock( bmMutex ); bcPar[parID] = newPar ; } //! Set point rate { Brooks0254ParID parID( Brooks0254ParID::bpiOutput, 1, Brooks0254ParID::bpiDouble ) ; Brooks0254Par* newPar = new Brooks0254Par( *this, parID ) ; MtxLock scopeLock( bmMutex ); bcPar[parID] = newPar ; } //! Set point function { Brooks0254ParID parID( Brooks0254ParID::bpiOutput, 2 ) ; Brooks0254Par* newPar = new Brooks0254Par( *this, parID ) ; MtxLock scopeLock( bmMutex ); bcPar[parID] = newPar ; } //! Full scale { Brooks0254ParID parID( Brooks0254ParID::bpiOutput, 9, 0.01 ) ; Brooks0254Par* newPar = new Brooks0254Par( *this, parID ) ; MtxLock scopeLock( bmMutex ); bcPar[parID] = newPar ; } //! SP valve override state { Brooks0254ParID parID( Brooks0254ParID::bpiOutput, 29 ) ; Brooks0254Par* newPar = new Brooks0254Par( *this, parID ) ; MtxLock scopeLock( bmMutex ); bcPar[parID] = newPar ; } //! SP Batch amount { Brooks0254ParID parID( Brooks0254ParID::bpiOutput, 44, 0.01 ) ; Brooks0254Par* newPar = new Brooks0254Par( *this, parID ) ; MtxLock scopeLock( bmMutex ); bcPar[parID] = newPar ; } //! SP Blend { Brooks0254ParID parID( Brooks0254ParID::bpiOutput, 45, 0.01 ) ; Brooks0254Par* newPar = new Brooks0254Par( *this, parID ) ; MtxLock scopeLock( bmMutex ); bcPar[parID] = newPar ; } //! Set Point Programming source { Brooks0254ParID parID( Brooks0254ParID::bpiOutput, 46 ) ; Brooks0254Par* newPar = new Brooks0254Par( *this, parID ) ; MtxLock scopeLock( bmMutex ); bcPar[parID] = newPar ; } return; } Brooks0254Card::Brooks0254Card( Brooks0254Card& card ) : Brooks0254Module( card ) { MtxLock scopeLock( bmMutex ); bcCardNum = card.GetCardNum(); bcPar = card.GetParMap(); return; } Brooks0254Card::~Brooks0254Card() { // Loop over all parameters and destroy them MtxLock* scopeLock = new MtxLock( bmMutex ); map::iterator it; for( it = bcPar.begin(); it != bcPar.end(); it++ ) { Brooks0254BasePar* parPtr = it->second; if( parPtr != 0 ) delete parPtr; } delete scopeLock; return; } Brooks0254Card& Brooks0254Card::operator=( Brooks0254Card& card ) { if( this == &card ) return *this; Brooks0254Module::operator=( card ); MtxLock scopeLock( bmMutex ); bcCardNum = card.GetCardNum(); bcPar = card.GetParMap(); return *this; } Brooks0254BasePar* Brooks0254Card::GetPar( Brooks0254ParID& parID ) { MtxLock scopeLock( bmMutex ); Brooks0254BasePar* tmpPar = bcPar[parID]; return tmpPar ; } //! Loop over all parameters and synchronize them void Brooks0254Card::Sync( bool dir ) { if ( bmDebFlag > 1 ) cout << "Looping through parameters for card" << endl; map::iterator it; map::iterator itBegin; map::iterator itEnd; Brooks0254BasePar* parPtr = 0; { MtxLock scopeLock( bmMutex ); itBegin = bcPar.begin(); itEnd = bcPar.end(); } for( it = itBegin; it != itEnd; it++ ) { { MtxLock scopeLock( bmMutex ); parPtr = it->second; } if( bmDebFlag > 1 ) cout << "Brooks0254Card::Sync(): Will try to sync parameter #" << parPtr->GetType().GetNum() << endl; if( parPtr != 0 ) parPtr->Sync(); } return; }