fdhwlib
2.0.25
|
#include <Pbus.h>
The class Pbus provides basic PBUS+ commands for access to the data aquisition electronics.
The Pbus class provides serveral variants using different interfaces and some only for test purpose:
The physical parameters to access the microEnable are static. This is necessary because all instances of the class in one process will use the same hardware. It is sufficient to initialize the microEnable once. Things are different if a second process wants to use the interface. Here it becomes system specific (Win NT and Linux). With Linux a second call of initialize_microenable() is allowed. The normal alternative should be the command reinitialize_mircoenable().
The performance of the class is determined by the microEnable interface. The C++ syntax makes rather no significant difference (inline, function call, ...) but don't use stream output (eq. to fdebug) in the loop - means rawRead /rawWrite. This will decrease the transfer rate dramatically.
An effect has also the request/release pair of the semaphores. It is advisable to protect larger blocks than each single read/write operation.
For further information:
Changes:
Insert version number
Try-catch block for load_design() required!
IP: The proxy interface will not recognise if the connection close by the other side. Automatically try to make a new connection if possible!
Handling of the pbusd version!!!
Redesign required: Separation between Pbus and PbusControl!
int Pbus::checkIR | ( | ) |
There is no interrupt generaition on the microEnable by now, so use this function from time to time to ensure that there is no interrupt.
void Pbus::clearBlock | ( | unsigned long | addr, |
unsigned long | data, | ||
unsigned long | n, | ||
unsigned long | incr = 1 |
||
) |
Fill a block of size <n> statring from address <addr> with with <data> (means always the same long word at every address).
void Pbus::cont | ( | ) |
Continues the access to the microEnable.
static void Pbus::debugMsg | ( | const char * | msg, |
... | |||
) | [static] |
Debug output.
The function accepts a varible number of arguments in the printf-format.
void Pbus::displayVersion | ( | FILE * | fout | ) |
static int Pbus::free | ( | int | host = 0 | ) | [static] |
Close the connection to the hardware interface.
This command has a different meaning depending on the type of Pbus interface (with microEnable or IP). Using the IP connection it is possible to specify the host where the connection should be closed.
host | 0 localhost == close the connection to the pbusdaemon or microenable, 1 remote host == connection of the pbusdaemon to the hardware |
int Pbus::get | ( | std::string | item, |
std::string * | value | ||
) |
Get parameter of the Pbus implementation.
item | Name of the parameter requested. |
value | Value of the parameter |
int Pbus::getIRorigin | ( | unsigned long | irvector | ) |
Calculate the origin form the interrupt acknoledge vector.
The command makes no access to the pbus. It is more based on the definition of the hardware than on the pbus layer - but it is very comfortable to have the information about the slotid at this layer?!
Reimplemented in SltIRvector.
unsigned long Pbus::getIRvector | ( | ) |
Read the interrupt vector.
const char* Pbus::getMode | ( | ) |
Reimplemented in KaFltControlStatusReg.
int Pbus::getModeId | ( | ) |
Return the Id of the current mode.
The modes are
static int Pbus::getNTelescopes | ( | ) | [static] |
Returns the number of avalibale telescopes This does not mean that all of them are configured.
PbusVersion* Pbus::getPbusVersion | ( | ) |
unsigned long Pbus::getState | ( | ) |
Show the status of the PBUS+ master; bits 4-6 of the status register.
unsigned long Pbus::getState | ( | unsigned long | addr | ) |
Show the status of the PBUS Implementation There are different implementation specific adresses possible.
static int Pbus::getTelescope | ( | ) | [static] |
Get the id of the selected telescope.
This parameter is used only in PbusIP mode.
const char* Pbus::getVersion | ( | ) |
Reimplemented in FltCntrlStatus, and KaFltControlStatusReg.
static int Pbus::init | ( | const char * | inifile = "FE.ini" , |
int | host = 0 |
||
) | [static] |
Function to initialize the microEnable and load the specified hap-file to the FPGA.
The function can not be used on the initialized board - use free() before. Optional it is possible to set the frequency of the plx_clock and the fpga_clock (default 40Mhz).
This command has a different meaning depending on the type of Pbus interface (with microEnable or IP). Using the IP connection it is possible to specify the host where the connection should be initialized.
inifile | Name of the inifile used to read the initialization parameters |
host | 0 localhost == initialize the connection to the pbusdaemon or microenable, 1 remote host == initialize connection of the pbusdaemon to the hardware |
static bool Pbus::isAvailable | ( | ) | [static] |
Has the Pbus been initialized?
static bool Pbus::isConnected | ( | int | id = 0 | ) | [static] |
Return information about the connection to the electronic.
id | Number if the telescope requested. 0 (default) will select the current telescope. With all menable or test based connections there is only this one possible. |
unsigned long Pbus::read | ( | unsigned long | addr | ) |
Read a single long word from the specified address addr.
Reimplemented in FltMemory, FltRegister, and KaFltTriggerMemory.
int Pbus::readBlock | ( | unsigned long | addr, |
unsigned long * | data, | ||
unsigned long | n, | ||
unsigned long | incr = 1 |
||
) |
Read a block of <n> long words beginning with address <addr>.
The <addr> will be incremented by <incr>. The argument <status> informs about possible overflows.
The meaning of the <status> values is
WARNING: The try/catch block won't get a segmentation fault. In this case the semaphore will be left locked!
void Pbus::readRegisterBlock | ( | unsigned long | addr, |
unsigned long * | data, | ||
unsigned long | nPix, | ||
unsigned long | incrPix, | ||
unsigned long | nSlots = 0 , |
||
unsigned long | incrSlots = 0 |
||
) |
Read register for all pixel.
int Pbus::reset | ( | ) |
Reset the PBUS+ master on the microEnable.
Reimplemented in KaFltControlStatusReg, and FltCurrent.
static void Pbus::selectTelescope | ( | int | id | ) | [static] |
Select a telescope to connect to.
This parameter is used only in PbusIP mode.
int Pbus::set | ( | std::string | item, |
std::string | value | ||
) |
Set a parameter.
void Pbus::setBitsToHigh | ( | unsigned long | addr, |
unsigned long | mask | ||
) |
All bits in the maks are set to high.
void Pbus::setBitsToLow | ( | unsigned long | addr, |
unsigned long | mask | ||
) |
All bits in the maks are set to low.
static void Pbus::setDebugLevel | ( | int | level | ) | [static] |
unsigned long Pbus::simReadIRvector | ( | ) |
Read the IR vector.
This function is only intended for simulation mode.
void Pbus::simWriteIRvector | ( | unsigned long | vector | ) |
Write an IR vector.
An IR vector > 0 will automatically lead to an interupt state. This function is only intended for simulation mode.
void Pbus::stop | ( | ) |
Stops the all access to the microEnable by requesting the semaphore.
To resume operation use the function cont() in the same process. The functions stop() and cont() are intended to reach a defined state of the system to terminate processes using the microEnable and leave the semaphore in a defined state. A monitor task may use stop, maintain the process table and continue afterwards.
int Pbus::waitForIR | ( | int | timeout = 0 | ) |
not implemented
void Pbus::write | ( | unsigned long | addr, |
unsigned long | data | ||
) |
Write a single long word <data> to the specified address <addr>
Reimplemented in FltRegister, and KaFltTriggerMemory.
void Pbus::writeBits | ( | unsigned long | addr, |
unsigned long | data, | ||
unsigned long | mask, | ||
int | shift | ||
) |
Write a a bit sequence to the specified address.
The rest of the register is not changed.
addr | Address of the register |
data | Data to be filled in the bit sequence |
mask | bit sequence filled with 1 - but not shifted! E.g. 0x1f for a sequence of 5 bit length. |
shift | Argument of the shift operator equals the position of the lowest bit. |
void Pbus::writeBlock | ( | unsigned long | addr, |
unsigned long * | data, | ||
unsigned long | n, | ||
unsigned long | incr = 1 |
||
) |
Writing a block of <n> long words to the address <addr>.
The argument <data> contains a pointer to an array containing the data to be tranfered. The addr will be incremented by <incr>.
void* Pbus::dllHandle [static, private] |
int Pbus::fltVersion [static] |
PbusImp* Pbus::pImp [static] |
bool Pbus::pImpAvailable [static, private] |
bool Pbus::pImpConnected [static, private] |
PbusVersion* Pbus::pver [static, private] |
int Pbus::sltVersion [static] |