/********************************************************************\ ProcessIO.cc Main class processing user input Sebastian Commichau, Sabrina Stark-Schneebeli, Oliver Grimm \********************************************************************/ #include "ProcessIO.h" static char* state_str[] = {"active", "stopped", "n.a."}; ProcessIO::ProcessIO(const char *ConfigFile) { // Get program start time time (&StartTime); // Create instances config = new HVConfig(ConfigFile); calib = new HVCalib(config); pm = new PixelMap(config->fPixMapTable); // Initialize status variables state = active; Exit = false; Verbose = false; CmdFromSocket = false; Socket = -1; NumHVBoards = 0; FirstBoard = 0; LastBoard = -1; FirstChain = 0; LastChain = NUM_CHAINS-1; if (config->fStatusRefreshRate >= MIN_RATE && config->fStatusRefreshRate <= MAX_RATE) fStatusRefreshRate = config->fStatusRefreshRate; else fStatusRefreshRate = 1.; // Open HV devices fHVBoard = new HVBoard* [config->NumHVBoards]; for (int i=0; iNumHVBoards; i++) { fHVBoard[NumHVBoards] = new HVBoard(i, config->fUSBDevice[i], this); if(fHVBoard[NumHVBoards]->fDescriptor >= 0) { printf("Synchronized and reset HV board %d (%s)\n",i,config->fUSBDevice[i]); NumHVBoards++; } else { printf("Failed to synchronize to HV board %d (%s)\n",i,config->fUSBDevice[i]); delete fHVBoard[NumHVBoards]; } } LastBoard = NumHVBoards-1; // Open log file if ((Logfile = fopen(config->fLogFile, "a")) == NULL) printf("Warning: Could not open log file '%s'\n", config->fLogFile); PrintMessage(MsgToLog,"********** Logging started **********\n"); // Create instance of slow data class SlowDataClass = new SlowData("HV", config->fSlowDir); if (SlowDataClass->ErrorCode != 0) { PrintMessage("Warning: Could not open slowdata file (%s)\n", strerror(SlowDataClass->ErrorCode)); } SlowDataClass->NewEntry("Value-Info", "Issued if new HV value set successfull: Board-Num HV-Board-Name Chain Channel DAC-Target Converted-Value"); SlowDataClass->NewEntry("Error-Info", "Issued if error occurs when trying to set new HV value: Board-Num HV-Board-Name Chain Channel Attempted-DAC-Target Converted-Value"); } ProcessIO::~ProcessIO() { delete SlowDataClass; for (int i=0; iGetBoardNumber(), fHVBoard[i]->BoardName); } return; } //Select board(s) if (Match(Param[1],"all")) { FirstBoard = 0; LastBoard = NumHVBoards-1; } else if (NParam==2 && atoi(Param[1])>=0 && atoi(Param[1])=0 && atoi(Param[1])0 && atoi(Param[2])=0 && atoi(Param[1])=0 && atoi(Param[1])0 && atoi(Param[2])fLogFile, config->fPixMapTable, config->NumHVBoards); for (int i=0; iNumHVBoards; i++) { PrintMessage(" Board %d: %s\n ", i, config->fUSBDevice[i]); } PrintMessage( " TimeOut: %.2f s\n" " StatusRefreshRate: %.2f Hz\n" " CCPort: %d\n" " DACMin value: %d\n" " DACMax value: %d\n" " HVCalibOffset : %f\n" " HVCalibSlope : %f\n" " HVMaxDiff : %u\n", config->fTimeOut, config->fStatusRefreshRate, config->fCCPort, config->DACMin, config->DACMax, config->fHVCalibOffset, config->fHVCalibSlope, config->fHVMaxDiff); return; } // Print help if (Match(Param[0], "help")) { puts(" board | | Address board i, boards i-j or all boards or list boards"); puts(" chain | | Address chain i, chains i-j or all chains"); puts(" hv || Set HV of pixel ID, ch. or all ch. of active chain(s)/board(s)"); puts(" hvdiff || Change HV by "); puts(" status [dac] Show status information (DAC values if requested)"); puts(" config Print configuration"); puts(" load Load HV settings from "); puts(" save Save current HV settings to [file]"); puts(" exit Exit program"); puts(" rate Set status refresh rate to [Hz]"); puts(" timeout