/********************************************************************\ 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): DimCommand((char *) SERVER_NAME"/Command", (char *) "C"), EvidenceServer(SERVER_NAME) { // Get program start time time (&StartTime); // Create DIM text output service Textout = new DimService (SERVER_NAME"/Textout", (char *) ""); // Initialize status variables state = active; Exit = false; CmdFromSocket = false; Socket = -1; NumHVBoards = 0; FirstBoard = 0; LastBoard = -1; FirstChain = 0; LastChain = NUM_CHAINS-1; // Get configuration data char *Boards = GetConfig(SERVER_NAME " Boards"); fPixMapTable = GetConfig(SERVER_NAME " PixMapTable"); fTimeOut = atof(GetConfig(SERVER_NAME " TimeOut")); fStatusRefreshRate = atof(GetConfig(SERVER_NAME " StatusRefreshRate")); fCCPort = atoi(GetConfig(SERVER_NAME " CCPort")); DACMin = atoi(GetConfig(SERVER_NAME " DACMin")); DACMax = atoi(GetConfig(SERVER_NAME " DACMax")); fHVCalibOffset = atof(GetConfig(SERVER_NAME " HVCalibOffset")); fHVCalibSlope = atof(GetConfig(SERVER_NAME " HVCalibSlope")); fHVMaxDiff = atoi(GetConfig(SERVER_NAME " HVMaxDiff")); if (fStatusRefreshRate < MIN_RATE || fStatusRefreshRate > MAX_RATE) fStatusRefreshRate = 1; // Open HV devices fHVBoard = new HVBoard* [strlen(Boards)]; char *Token = strtok(Boards, " \t"); while (Token != NULL) { fHVBoard[NumHVBoards] = new HVBoard(NumHVBoards, Token, this); if(fHVBoard[NumHVBoards]->fDescriptor >= 0) { PrintMessage("Synchronized and reset board %d (%s)\n",NumHVBoards,fHVBoard[NumHVBoards]->BoardName); NumHVBoards++; } else { PrintMessage(All, "Failed to synchronize board %d (%s)\n",NumHVBoards,fHVBoard[NumHVBoards]->BoardName); delete fHVBoard[NumHVBoards]; } Token = strtok(NULL, " \t"); } LastBoard = NumHVBoards-1; // Create instances calib = new HVCalib(this); pm = new PixelMap(fPixMapTable); } ProcessIO::~ProcessIO() { 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])BoardName); } 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", fTimeOut, fStatusRefreshRate, fCCPort, DACMin, DACMax, fHVCalibOffset, fHVCalibSlope, fHVMaxDiff); return; } // Print help if (Match(Param[0], "help")) { PrintMessage(" board | | Address board i, boards i-j or all boards or list boards\n" " chain | | Address chain i, chains i-j or all chains\n" " hv || Set bias of pixel ID, ch. or all ch. of active chain(s)/board(s)\n" " hvdiff || Change bias by \n" " status [dac] Show status information (DAC values if requested)\n" " config Print configuration\n" " load Load and set bias settings from \n" " save Save current bias settings to [file]\n" " exit Exit program\n" " rate Set status refresh rate to [Hz]\n" " timeout