/* ===================================================================== * The Active Channel List. This class provides some functionality around * it. This is used in the RCU Firmware V1. In V2 we use the Readout List. * ===================================================================== */ /* *Author: C. Lippmann, Christian.Lippmann@cern.ch */ #include "Acl.h" Acl::Acl() { // Constructor fLogger=Logger::getInstance(); reset(); } Acl::~Acl() { // Destructor } uint32_t Acl::size() { return 256; } void Acl::reset() { fACL.clear(); fACL.resize(size(), 0); } void Acl::fill(uint32_t branch, uint32_t fec, uint32_t altro, uint32_t channel, bool chOn) { // Fill the ACL with one channel value if ( branch > 1 ) { char desc[256]; sprintf(desc, "Acl::fill: fec branch out of range: %d", branch); fLogger->appendError(desc); //throw TpcException( (string) desc); return; } if ( fec > 15 ) { char desc[256]; sprintf(desc, "Acl::fill: fec number out of range: %d", fec); fLogger->appendError(desc); //throw TpcException( (string) desc); return; } if ( altro > 7 ) { char desc[256]; sprintf(desc, "Acl::fill: altro number out of range: %d", altro); fLogger->appendError(desc); //throw TpcException( (string) desc); return; } if ( channel > 15 ) { char desc[256]; sprintf(desc, "Acl::fill: channel number out of range: %d", channel); fLogger->appendError(desc); //throw TpcException( (string) desc); return; } int32_t position = (branch*16+fec)*8 + altro; fill2(position, (fACL.at(position) | ((uint32_t)chOn << channel))); } void Acl::fill2(uint32_t position, uint32_t data) { // Fill the ACL if ( position >= size() ) { char desc[256]; sprintf(desc, "Acl::fill2: Position out of range: %d", position); fLogger->appendError(desc); //throw TpcException( (string) desc); return; } fACL.at(position) = data; } void Acl::fill2(uint32_t branch, uint32_t fec, uint32_t altro, uint32_t data) { // Fill the ACL if ( branch > 1 ) { char desc[256]; sprintf(desc, "Acl::fill2: fec branch out of range: %d", branch); fLogger->appendError(desc); //throw TpcException( (string) desc); return; } if ( fec > 15 ) { char desc[256]; sprintf(desc, "Acl::fill2: fec out of range: %d", fec); fLogger->appendError(desc); //throw TpcException( (string) desc); return; } if ( altro > 7 ) { char desc[256]; sprintf(desc, "Acl::fill2: altro out of range: %d", altro); fLogger->appendError(desc); //throw TpcException( (string) desc); return; } int32_t position = (branch*16+fec)*8 + altro; fill2(position, data); } uint32_t Acl::at(uint32_t position) { // Get value at certain position if ( position >= size() ) { char desc[256]; sprintf(desc, "Acl::at: Position of range: %d", position); fLogger->appendError(desc); //throw TpcException( (string) desc); return 0; } return fACL.at(position); } uint32_t* Acl::get() { // Get the ACL as 256 32bit values (filled with only 16bit each) return &fACL[0]; } bool Acl::isChannelActive(uint32_t branch, uint32_t fec, uint32_t altro, uint32_t channel) { if ( branch > 1 ) { char desc[256]; sprintf(desc, "Acl::isChannelActive: Fec branch out of range: %d", branch); fLogger->appendError(desc); //throw TpcException( (string) desc); } if ( fec > 15 ) { char desc[256]; sprintf(desc, "Acl::isChannelActive: Fec out of range: %d", fec); fLogger->appendError(desc); //throw TpcException( (string) desc); } if ( altro > 7 ) { char desc[256]; sprintf(desc, "Acl::isChannelActive: Altro out of range: %d", altro); fLogger->appendError(desc); //throw TpcException( (string) desc); } if ( channel > 15 ) { char desc[256]; sprintf(desc, "Acl::isChannelActive: Channel out of range: %d", channel); fLogger->appendError(desc); //throw TpcException( (string) desc); } uint32_t value = at((branch*16+fec)*8 + altro); if ( (value >> channel) & 0x1 ) return true; return false; }