/********************************************************************\ Name: ProcessIO.cc Created by: Sebastian Commichau, November 2008 commichau@phys.ethz.ch Contents: Main class processing user input \********************************************************************/ #include "ProcessIO.h" ProcessIO::ProcessIO(char *ConfigFile) { // Get program start time - only needed for uptime command time (&StartTime); status = new Status; config = new HVConfig(stdout,ConfigFile); calib = new HVCalib(config); log = new Log(config->fLogPath); hv = new HV(config->fUSBDevice,config->USBDeviceNumber,stdout); pm = new PixelMap(config->fPixMapTable); printf("PixMapTable = %s. \n",config->fPixMapTable); // Initialize status structure (HVStatus.cc/h) InitStatus(status,config); // Print HV control configuration to the log file config->PrintHVConfig(log->logptr); // The following loop was added to allow for an arbitrary numeration of the HV boards for (int i=0;iGetNumberOfBoards();i++) { sprintf(status->fUSBDevice[i],"%s",(hv->GetHVBoard(i))->GetSerial()); status->USBDeviceNumber[i] = (hv->GetHVBoard(i))->GetBoardNumber(); if ((hv->GetHVBoard(i))->GetBoardNumber() > status->USBMaxDeviceNumber) status->USBMaxDeviceNumber = (hv->GetHVBoard(i))->GetBoardNumber(); if ((hv->GetHVBoard(i))->GetBoardNumber() < status->USBMinDeviceNumber) status->USBMinDeviceNumber = (hv->GetHVBoard(i))->GetBoardNumber(); (hv->GetHVBoard(i))->SetTimeOut(config->fTimeOut); } // Initialize HV boards (see below) InitializeHV(); status->FirstBoard = 0; status->NumHVBoards = hv->GetNumberOfBoards(); status->LastBoard = hv->GetNumberOfBoards()-1; // Print status information to the log file PrintStatus(status,config,log->logptr); // Send reset command to all boards ResetAllBoards(); // Print some information sprintf(str,"status monitor: %s\n", GetStateStr(status)); if (hv->GetNumberOfBoards()>0) DoPrompt(str); sprintf(str,"type (h)elp to get a list of available commands\n"); DoPrompt(str); // Print empty prompt DoPrompt(NULL); // Initialize mutex variable for thread synchronization pthread_mutex_init (&control_mutex, NULL); pthread_cond_init (&control_cond, NULL); } ProcessIO::~ProcessIO() { pthread_mutex_destroy (&control_mutex); pthread_cond_destroy (&control_cond); config->fStatusRefreshRate = status->fStatusRefreshRate; config->fTimeOut = status->fTimeOut; config->WriteHVConfig(stdout,config->FileName); delete hv; delete status; delete config; delete log; delete pm; } // Print list of all commands void ProcessIO::PrintHelp() { puts(""); puts("********************************************** HELP *********************************************\n"); puts(" board | | Address board i, boards i-j or all boards"); puts(" chain | | Address chain i, chains i-j or all chains"); puts(" clear Clear screen"); puts(" config Print configuration"); puts(" help Print help"); puts(" hv | [b][x] Set chan. | chan. of active chain(s)/board(s) to "); // puts(" hvdiff | [b][x] Set chan. | chan. of active chain(s)/board(s) to "); puts(" hvdiff Set HV difference of pixel PXL id to "); puts(" list List all HV boards"); puts(" load Load HV settings from "); puts(" log | Enable|disable logging"); puts(" quit|exit Exit program"); puts(" rate Set status refresh rate to [Hz]"); puts(" reset Reset active HV board"); puts(" save [file] Save current HV settings to [file]"); puts(" start Start HV status monitor"); puts(" status Show status information"); puts(" stop Stop HV status monitor - not recommended!"); puts(" time Print current date and time"); puts(" timeout