fdhwlib  2.0.25
Pbus Class Reference

#include <Pbus.h>

Inheritance diagram for Pbus:
FltMemory FltPixRegister FltRegister hw4::BaseRegister IRhandler PbusControl SltMemory SltRegister SltRegisterVector

List of all members.

Public Member Functions

Static Public Member Functions

Static Public Attributes

Static Private Attributes


Detailed Description

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 original driver used the PCI interface microEnable, Silicon Software. (Variants: direct, test)
  • Together with the pbusdaemon a TCPIP variant can be used. (ip)
  • Simulation mode (sim)
  • IEEE1394 / Firewire (1394). The driver also detects if a device is added od removed.

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:

  • D. Bormann: PBUS+ specification, 1999.
  • D. Tcherniakhovski: PBUS master for uEnable, xxxx.
  • Silicon Software: microEnable Benutzerhandbuch WinNT und Linux, Version 1.3 August 1999.

Changes:

  • ak 12.06.02: Created new files for special code only used in the modes IP and Sim (PbusSim.cpp, PbusProxy.cpp).
  • ak 14.7.01: Problems with Pbus Timing. Added additional statement to the loop witimg for the PBUS_DONE state???
  • ak 18.4.01: PBUS_FAST mode implemented. The command Pbus::readBlock() will use an auto increment of the address pointer - omiting this asignement leads to incredible speed enhancement!?
  • ak, 11.4.01: Block size restricted to 1000 Bytes. This was necessary to increase the performance?! But unfortunately I don't really know the reasons. The alogrithm is also capable to handle block of 2000 long word as they come from the slt pixel trigger memory.
Todo:

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!

Todo:
IP: Throw PbusErrors if a error occures!
Todo:
Du musst dazu einen Signalhandler fuer SIGPIPE installieren, der aber nichts tut, oder SIG_IGN. Dann kommt write(socket,...) mit -1 und errno=EPIPE zurueck. Auf diesen Fehler kann man dann geeignet reagieren. Ein read(socket,...) kommt mit 0 gelesenen Bytes zurueck, wenn der Socket gestorben ist, aber dass weisst Du sicherlich.
Todo:
IP: Add IP instructions for the new commands stop and cont!
Todo:
Implement test functions in pbus class that can be used by all registers to determine access speed and reliability.

Definition at line 484 of file Pbus.h.


Member Function Documentation

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.

Parameters:
host0 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.

Parameters:
itemName of the parameter requested.
valueValue 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?!

Returns:
The slotid of the board generating the interrupt

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

  • PBUS_MODE_SIM - Simulation mode
  • PBUS_MODE_TEST - Test mode for uEnable connection
  • PBUS_MODE_DIRECT - Standard direct connction via uEnable
  • PBUS_MODE_IP - IP connection via the Pbusdaemon
  • PBUS_MODE_DMA - Direct connection using DMA blocktransfer
  • PBUS_MODE_FAST - Direct mode using auto increment addressing for blocktransfer
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.

Parameters:
inifileName of the inifile used to read the initialization parameters
host0 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.

Parameters:
idNumber 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

  • PBUS_OVFL_UNKNOWN - no information retrieved,
  • PBUS_OVFL_NONE - no overflow detected
  • PBUS_OVFL_ACTIVE - overflow in at least one sample.

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.

Parameters:
addrAddress of the register
dataData to be filled in the bit sequence
maskbit sequence filled with 1 - but not shifted! E.g. 0x1f for a sequence of 5 bit length.
shiftArgument 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>.


Member Data Documentation

void* Pbus::dllHandle [static, private]

Handle for the dynamic library.

Definition at line 762 of file Pbus.h.

int Pbus::fltVersion [static]

Version of the actual connected Flt boards.

The version information is requested during the initialization of the subrack class. The variable contains the lowest version number available.

Definition at line 695 of file Pbus.h.

PbusImp* Pbus::pImp [static]

Pointer to the Pbus-Layer in the dynamic library.

Pbus implementation

Definition at line 772 of file Pbus.h.

bool Pbus::pImpAvailable [static, private]

The pbus implementation has been created.

Definition at line 748 of file Pbus.h.

bool Pbus::pImpConnected [static, private]

The pbus implementation is connected to an available interface.

Definition at line 752 of file Pbus.h.

PbusVersion* Pbus::pver [static, private]

Definition at line 756 of file Pbus.h.

int Pbus::sltVersion [static]

Version of the actual connected Slt boards The version information is requested during the initialization of the subrack class.

Definition at line 688 of file Pbus.h.


The documentation for this class was generated from the following file: