fdhwlib  2.0.25
TsBackgroundLoop Class Reference

#include <tsbackgroundloop.h>

Inheritance diagram for TsBackgroundLoop:
SimpleServer BaseServer

List of all members.

Classes

Public Types

Public Member Functions

Private Member Functions

Private Attributes


Detailed Description

Recorder process for background data.

The background data is collected at the telescopes and transfered to the central data collection point (this class).

The background data is collected using a client server concept. At every connected telescope a readout process is started that afterwards autonomuosly sends the data to the server running at the eyePC writing the data to the file.

The background data is stored in text format. The data of every parameter introduced by a header line containing certain parmeters necessary to interprete the data. There is a master header for a complete set of background data.

The following box shows a sample call of the background recorder.


  TsBackgroundLoop *bgrec;
  Pbus *thePbus;

  Pbus::init(inifile.c_str());


  // Create recorder
  bgrec = new TsBackgroundLoop();
  bgrec->readInifile(inifile.c_str());

  bgrec->setLogfile(stdout);

  // Set parameter: Period length, selected parameter, file, ....
  bgrec->setParameter(name, tSample, 0, selRecord, selDisplay, runType.c_str());  // no output to file, take data every 5s

  // Run background recorder
  // The readout process is started at all connected telescopes
  bgrec->runReadout(stdout);

  delete bgrec;
Todo:

Streamer methoden einfhren, es erscheint unsauber, die Methoden mit zu kopieren !!!

Wie kann man eine verlorene Verbindung erkennen? Wie kann der Server-Verbindungen lšsen?

  • Bleiben immer so viele Verbindungen liegen? Tw. wird eine weiterer Aufruf hierdurch sogar blockiert?!
  • Zeitnahmedaten mit in die Daten aufnehmen!!! Verarbeiten der display-Funktionen.
  • Definition des Befehlssatzen in einer Struktur, die von beiden Seiten verwendet wird!
  • Verwenden von ROOT-Trees zum Abspeichern der Daten
  • Integration in Pbusdaemon / oder ein separates Programm, das vom Pbusdaemon aufgerufen wird?!
  • Display-Programm, das sich ebenfalls an den Server ankoppelt.
  • Test mit echter Hardware: Werden die Daten korrekt bertragen
  • Test mit mehreren Teleskopen
  • Test mit automatischem Start ber Pbusdaemon
  • Erweiterung des TsBackground-Formates fŸr die neuen Variablen
  • Dokumentation der Background-Loop (Konzept / Start / Konfiguration / ...)
  • Speichern im Root-Format, Aufteilung in Branches
  • Beispielhaftes Display-Modul (ncurses) entwerfen
  • Histogramming-Modul / Stern-Monitor ankoppeln
Todo:
The recorder does not work with a connection started via ssh tunnel. The readout process at the mirrorpc's seem to have problems to connect to the proper recorder server?!

Definition at line 174 of file tsbackgroundloop.h.


Member Enumeration Documentation

Enumerator:
eDebug 

debug messages

eInfo 

General (informational) message.

eWarning 

Warning message.

eError 

Error message.

eCritical 

Critical error.

eSevere 

Severe error.

eFatal 

Fatal error message.

Definition at line 182 of file tsbackgroundloop.h.


Constructor & Destructor Documentation

TsBackgroundLoop::TsBackgroundLoop ( )
TsBackgroundLoop::~TsBackgroundLoop ( )

Member Function Documentation

void TsBackgroundLoop::changeToDataDir ( FILE *  fout)

Change directory for all files according to auger conventions.

void TsBackgroundLoop::checkStatus ( TsBackgroundBase bg)

Check the status of the telecopes.

Following errors can be detected:

  • hitrate overflow in complete columns
  • broken second counter
  • variance classifications: Shutters closed (< 5), normal night background (5 ... 200), high light level (> 200).
  • abnormal threshold - pedestal differences
  • missing data from telescope
  • increasing dead time /dead time rate
  • continuous triggers (ligthning indicator)
int TsBackgroundLoop::compareFields ( char *  cmd,
std::string *  fields,
int  n 
) [private]

Compare first column of a sql query result with a given list of strings.

void TsBackgroundLoop::dbWrite ( const char *  cmd,
const char *  cmdBackup = 0 
) [private]

Write command to the database.

The function will detect the connection status and write alternatively the command to a file

void TsBackgroundLoop::disableDatabase ( )
void TsBackgroundLoop::disablePixelRecording ( )

Set pixel record status.

void TsBackgroundLoop::displayError ( const char *  msg,
int  tel = 0 
)

Display error message.

void TsBackgroundLoop::displayHeader ( TsBackgroundBase bg,
int  select 
)
void TsBackgroundLoop::displayParameter ( )

Display the parameter of the background loop.

void TsBackgroundLoop::displayRuns ( FILE *  fout,
char *  cmd = 0 
)

Display background data runs.

The runs can be selected using a valid sql query

void TsBackgroundLoop::displaySummary ( TsBackgroundBase bg,
int  select 
)
void TsBackgroundLoop::enableDaemonMode ( )

Run in background mode.

void TsBackgroundLoop::enableDatabase ( )
void TsBackgroundLoop::enableInteractiveMode ( )

Run in interactive mode.

void TsBackgroundLoop::enablePixelRecording ( )

Set pixel record status.

void TsBackgroundLoop::executeCmd ( int  client,
short  cmd,
unsigned long *  arg,
short  n 
) [virtual]

Execute the command.

Reimplemented from SimpleServer.

void TsBackgroundLoop::executeCmd ( int  client,
short  cmd,
unsigned int *  arg,
short  n 
) [virtual]

Execute a command - The instruction set on the client side remoteCall needs to fit to this implementation.

Reimplemented from SimpleServer.

unsigned long TsBackgroundLoop::getDisplayItems ( )

Get the list of displayed items.

const char* TsBackgroundLoop::getFilename ( )

Get filename of background file.

unsigned long TsBackgroundLoop::getItems ( )

Get the list of background data items that are stored.

void TsBackgroundLoop::getLocation ( const char *  name,
int *  id 
)

Get location name and id.

bool TsBackgroundLoop::getPixelStatus ( int  col,
int  row 
)

Get pixel status.

float TsBackgroundLoop::getSamplingTime ( )

Get sampling time [s].

unsigned long TsBackgroundLoop::getTelescopes ( )

Get the telescope mask.

unsigned long TsBackgroundLoop::getVarianceLimits ( )

Get the limits for the variance tolerance band.

int TsBackgroundLoop::loadFromDatabase ( TsBackgroundBase bg)

Load background array from mysql database.

int TsBackgroundLoop::openDatabase ( )

Open database.

int TsBackgroundLoop::openFile ( )

Interface to the readout processes at the telescopes.

For every incoming packages a record in the background file is written. Open the background file

void TsBackgroundLoop::readInifile ( const char *  inifile)

Read parameter from inifile.

void TsBackgroundLoop::replaceTemplates ( )

Replace templates.

void TsBackgroundLoop::runReadout ( FILE *  fout,
int  eyeId = 0 
)

Start the server and all the client recording the telescopes background data.

int TsBackgroundLoop::savePixelToDatabase ( TsBackgroundBase bg)

Save the background pixel data in mysql database The database connection has to be opened before.

int TsBackgroundLoop::saveSampleToDatabase ( TsBackgroundBase bg)

Save (mean) background data in database.

Only mean values of the pixel data distribution are recorded.

void TsBackgroundLoop::selectDisplayItems ( unsigned long  selDisplay)

Select display background data items.

void TsBackgroundLoop::selectItems ( unsigned long  selStore)

Select the background data items to be stored.

void TsBackgroundLoop::selectTelescopes ( unsigned long  selTelelescopes)

Select the telescopes.

int TsBackgroundLoop::setDatabaseParameter ( const char *  server,
const char *  user,
const char *  password,
const char *  database,
const char *  runtable,
const char *  sampletable,
const char *  errortable,
const char *  pixeltable = 0 
)

Set the parameter for the database access.

void TsBackgroundLoop::setFDDASRunId ( unsigned long  runId)

Set the corresponding FDDAS run number.

void TsBackgroundLoop::setFilename ( const char *  file)

Set filename of background file.

void TsBackgroundLoop::setLocation ( const char *  name,
int  id 
)

Set location This function will overwrite the default implemented in the code and obtained from the inifile, initialisation by inifile is used.

void TsBackgroundLoop::setLogfile ( FILE *  flog)

Set file descriptor for logfile.

int TsBackgroundLoop::setParameter ( char *  file = "bg_bayX.txt",
float  tSample = 30,
int  selTelescopes = 0,
int  selStore = 0,
int  selDisplay = 0,
const char *  runType = "test" 
)

Set the parameter for the background loop.

void TsBackgroundLoop::setPixelStatus ( int  col,
int  row,
bool  enabled 
)

Set pixel status.

Parameters:
colcolumn of the pixel
rowron of the pixel
enabledtrue normal operation, false pixel is noisy or defect and not considered in analysis.
void TsBackgroundLoop::setSamplingTime ( float  tSample)

Set sampling time [s].

void TsBackgroundLoop::setVarianceLevel ( int  low,
int  high 
)

Set level for variance check.

The lower value is used to distuguish between shutter open and close state. The higher level defines the maximal allowed light level for the operation of the telescopes.

void TsBackgroundLoop::setVarianceLimits ( unsigned int  limit)

Set variance tolerance band for normal pixel.

void TsBackgroundLoop::writeLogfileFooter ( )
void TsBackgroundLoop::writeLogfileHeader ( )

Write a header line to the logfile.

void TsBackgroundLoop::writeMessageToDatabase ( const char *  msg,
DBMessageSeverity  severity = eInfo,
int  tel = 0 
)

Write error message to the database (table ErrorTab).

Possible constants for the severity are: 'info','warn','error','critical','severe','fatal'


Member Data Documentation

unsigned long TsBackgroundLoop::actualTimeStamp [private]

Actual time stamp.

Definition at line 606 of file tsbackgroundloop.h.

Array with the actual variances.

Definition at line 600 of file tsbackgroundloop.h.

std::string TsBackgroundLoop::basedir [private]

Basedir of the auger file.

Definition at line 402 of file tsbackgroundloop.h.

std::string TsBackgroundLoop::basedirTmpl [private]

Template for the basedir of the auger file.

Definition at line 405 of file tsbackgroundloop.h.

std::string TsBackgroundLoop::bgcalFile [private]

Filename template for the calibration mode.

Definition at line 467 of file tsbackgroundloop.h.

Sampling time for calibration mode.

Definition at line 473 of file tsbackgroundloop.h.

FILE* TsBackgroundLoop::bgFile [private]

File descriptor for back.

Definition at line 420 of file tsbackgroundloop.h.

std::string TsBackgroundLoop::bgrunFile [private]

Filename template for the run mode.

Definition at line 464 of file tsbackgroundloop.h.

Sampling time for run mode.

Definition at line 470 of file tsbackgroundloop.h.

MYSQL* TsBackgroundLoop::db [private]

MySQL database connection pointer.

Definition at line 543 of file tsbackgroundloop.h.

FILE* TsBackgroundLoop::dbBackup [private]

File descriptor for the backup file with sql commands in case a lost connection to the database server.

Definition at line 548 of file tsbackgroundloop.h.

std::string TsBackgroundLoop::dbErrortable [private]

Database table name for error messages.

Definition at line 516 of file tsbackgroundloop.h.

std::map<std::string,MsgInfo> TsBackgroundLoop::dbMessageMap [private]

Map to store messages in order not to write them too often into the DB.

Definition at line 540 of file tsbackgroundloop.h.

std::string TsBackgroundLoop::dbName [private]

Database name.

Definition at line 500 of file tsbackgroundloop.h.

std::string TsBackgroundLoop::dbNameTmpl [private]

Template for database name.

Definition at line 503 of file tsbackgroundloop.h.

std::string TsBackgroundLoop::dbPassword [private]

Database password.

Definition at line 497 of file tsbackgroundloop.h.

std::string TsBackgroundLoop::dbPixeltable [private]

Database table name for background data.

Definition at line 513 of file tsbackgroundloop.h.

unsigned long TsBackgroundLoop::dbRunId [private]

Run number in database.

Definition at line 519 of file tsbackgroundloop.h.

std::string TsBackgroundLoop::dbRuntable [private]

Database table name for background data runs.

Definition at line 507 of file tsbackgroundloop.h.

unsigned long TsBackgroundLoop::dbSampleId [private]

Sample number in the database.

Definition at line 522 of file tsbackgroundloop.h.

std::string TsBackgroundLoop::dbSampletable [private]

Database table name for bachground data sampling sets.

Definition at line 510 of file tsbackgroundloop.h.

std::string TsBackgroundLoop::dbServer [private]

Database server name.

Definition at line 491 of file tsbackgroundloop.h.

std::string TsBackgroundLoop::dbUser [private]

Database account name.

Definition at line 494 of file tsbackgroundloop.h.

Deadtime active.

Definition at line 627 of file tsbackgroundloop.h.

int TsBackgroundLoop::debug [private]

Debug level (0 = no debug)

Reimplemented from BaseServer.

Definition at line 391 of file tsbackgroundloop.h.

unsigned long TsBackgroundLoop::disabledPixel[20] [private]

Bits mask to mark the faulty pixel that should not be included in the calculation of the mean values.

Definition at line 454 of file tsbackgroundloop.h.

Error in one of the telescopes.

Definition at line 618 of file tsbackgroundloop.h.

int TsBackgroundLoop::errorLevel[24] [private]

Error level of the telescope (0 Ok, 1 warning, 2 error )

Definition at line 615 of file tsbackgroundloop.h.

unsigned long TsBackgroundLoop::fddasRunId [private]

Number of the corresponding FDDAS run.

Definition at line 461 of file tsbackgroundloop.h.

std::string TsBackgroundLoop::filename [private]

Record filename.

Definition at line 396 of file tsbackgroundloop.h.

std::string TsBackgroundLoop::filenameTmpl [private]

Template for the record filename.

Definition at line 399 of file tsbackgroundloop.h.

FILE* TsBackgroundLoop::flog [private]

FEalarm log file name.

Definition at line 562 of file tsbackgroundloop.h.

FILE* TsBackgroundLoop::fout [private]

Log file output.

Reimplemented from BaseServer.

Definition at line 417 of file tsbackgroundloop.h.

Flag to indicate colums with hitrate overflow.

Definition at line 582 of file tsbackgroundloop.h.

std::string TsBackgroundLoop::inifile [private]

Definition at line 393 of file tsbackgroundloop.h.

unsigned long TsBackgroundLoop::lastDataSec[24] [private]

Time stamp of last received data set.

Definition at line 579 of file tsbackgroundloop.h.

unsigned long long TsBackgroundLoop::lastDeadtime[24] [private]

List of faulty pixel (0 Ok, > 1 errors)

Last dead time

Definition at line 624 of file tsbackgroundloop.h.

unsigned long TsBackgroundLoop::lastSecondDiff[24] [private]

Last difference between PC and HW second counter.

Definition at line 585 of file tsbackgroundloop.h.

unsigned long TsBackgroundLoop::lastTimeStamp [private]

Last time stamp.

Definition at line 603 of file tsbackgroundloop.h.

int TsBackgroundLoop::lastVariance[24] [private]

Array with the last variances.

Definition at line 597 of file tsbackgroundloop.h.

Limit of allows deviation from the mean variance The limit is given in percent from the mean value.

This value is intended to be used with the noisy pixel analysis.

Definition at line 444 of file tsbackgroundloop.h.

std::string TsBackgroundLoop::location [private]

Name of the location.

Definition at line 411 of file tsbackgroundloop.h.

Location Id.

Definition at line 408 of file tsbackgroundloop.h.

std::string TsBackgroundLoop::logfile [private]

Name of the logfile.

Definition at line 565 of file tsbackgroundloop.h.

int TsBackgroundLoop::missingTel[24] [private]

Flag for all missing telesopes.

Definition at line 612 of file tsbackgroundloop.h.

unsigned long TsBackgroundLoop::nCmdsInFile [private]

Number of sql commands in file.

Definition at line 528 of file tsbackgroundloop.h.

unsigned long TsBackgroundLoop::nSamples [private]

Number of stored samples.

Reimplemented from BaseServer.

Definition at line 525 of file tsbackgroundloop.h.

unsigned long TsBackgroundLoop::pixelStatus[20][24] [private]

Matrix of the pixel status.

Definition at line 458 of file tsbackgroundloop.h.

bool TsBackgroundLoop::record [private]

Flag for writing to database.

Definition at line 423 of file tsbackgroundloop.h.

Flag that indivates that the connection to the server is broken.

In this case the sql commands are buffered in a file, after reconnection the database is updated.

Definition at line 488 of file tsbackgroundloop.h.

Flag for writing to database.

Definition at line 480 of file tsbackgroundloop.h.

Flag to control writing to the pixel table.

Definition at line 483 of file tsbackgroundloop.h.

Status flag to run in interactive or daemon mode.

Default: Start run in interactive mode.

Definition at line 476 of file tsbackgroundloop.h.

Mode of operation (-1 unkown, 0 cal/test mode = record every thing, 1 run mode = record only open telescopes.

Definition at line 570 of file tsbackgroundloop.h.

std::string TsBackgroundLoop::runType [private]

Run type (run, cal, test)

Definition at line 573 of file tsbackgroundloop.h.

Selected parameter for display.

Definition at line 435 of file tsbackgroundloop.h.

Selected parameter for recording.

Definition at line 432 of file tsbackgroundloop.h.

Selected telescopes.

Definition at line 438 of file tsbackgroundloop.h.

unsigned long TsBackgroundLoop::statOffset [private]

Offset used for the calculation of the pedestal.

Definition at line 450 of file tsbackgroundloop.h.

unsigned long TsBackgroundLoop::statSamples [private]

Number of samples used for calculation of the satistics.

Definition at line 447 of file tsbackgroundloop.h.

Duration of database storage.

Definition at line 630 of file tsbackgroundloop.h.

int TsBackgroundLoop::telActive[24] [private]

Run mode of telescope (0 no, 1 yes)

Definition at line 576 of file tsbackgroundloop.h.

Mean threshold pedestal difference.

Definition at line 609 of file tsbackgroundloop.h.

Reference time of the background loop.

Reimplemented from BaseServer.

Definition at line 426 of file tsbackgroundloop.h.

float TsBackgroundLoop::tSample [private]

Sampling time.

Reimplemented from BaseServer.

Definition at line 429 of file tsbackgroundloop.h.

Flag to switch between unique and relative telescope id's.

Definition at line 414 of file tsbackgroundloop.h.

Level for closed shutters.

Definition at line 591 of file tsbackgroundloop.h.

Level of the mean variance (do not include obvious wrong pixel!?)

Definition at line 588 of file tsbackgroundloop.h.

Level for too much light.

Definition at line 594 of file tsbackgroundloop.h.


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