Changeset 126
- Timestamp:
- 12/08/09 13:29:04 (15 years ago)
- Location:
- hvcontrol
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
hvcontrol/History.txt
r112 r126 26 26 24/9/2009 Program is terminated if too many errors are encountered by the 27 27 monitor thread 28 8/12/2009 Implemented DIM servers (currently only needs DIM_DNS_NODE 29 environment variable) -
hvcontrol/Makefile
r93 r126 3 3 # 4 4 5 SOURCES = hvcontrol.cpp src/HV.cc src/HVConfig.cc src/HVCalib.cc src/ProcessIO.cc ../pixelmap/Pixel.cc ../pixelmap/PixelMap.cc ../drsdaq/SlowData.cc 6 OBJECTS = $(addsuffix .o, $(basename $(SOURCES))) 7 INCDIRS = -I. -I./src 5 SOURCES = hvcontrol.cpp src/HV.cc src/HVConfig.cc src/HVCalib.cc src/ProcessIO.cc ../pixelmap/Pixel.cc ../pixelmap/PixelMap.cc ../drsdaq/SlowData.cc ../../Evidence/Evidence.cc 6 OBJECTS = $(addsuffix .o, $(basename $(SOURCES))) 7 INCDIRS = -I. -I./src -I../../Evidence/DIM/dim 8 8 9 CPPFLAGS = -O3 -Wall -DOS_LINUX 10 L IBS = -lstdc++ -lpthread -lfl -lreadline -ltermcap9 CPPFLAGS = -O3 -Wall -DOS_LINUX $(INCDIRS) 10 LDLIBS = -lstdc++ -lpthread -lfl -lreadline -ltermcap 11 11 12 hvcontrol: $(OBJECTS) 13 $(CC) $(CPPFLAGS) -o $@ $(OBJECTS) $(LIBS)12 hvcontrol: $(OBJECTS) ../../Evidence/DIM/linux/libdim.a 13 # $(CC) $(CPPFLAGS) -o $@ $(OBJECTS) $(LIBS) 14 14 15 15 clean: 16 @rm -f $(OBJECTS) $(SOBJECTS).so16 @rm -f $(OBJECTS) 17 17 @rm -f *.d 18 18 @rm -f *~ … … 22 22 # Implicit rules 23 23 24 %.o : %.cc25 $(CC) $(CPPFLAGS) $(INCDIRS) -c -o $@ $<26 %.o : %.cpp27 $(CC) $(CPPFLAGS) $(INCDIRS) -c -o $@ $<24 #%.o : %.cc 25 # $(CC) $(CPPFLAGS) $(INCDIRS) -c -o $@ $< 26 #%.o : %.cpp 27 # $(CC) $(CPPFLAGS) $(INCDIRS) -c -o $@ $< 28 28 %.d : 29 29 @echo "Generating dependencies" $@ -
hvcontrol/hvcontrol.cpp
r111 r126 30 30 void CCCommand(ProcessIO *); 31 31 void HVMonitor(ProcessIO *); 32 void SignalHandler(int);32 void DummyHandler(int); 33 33 void CrashHandler(int); 34 void ExitFunction(); 34 35 35 36 // ================ … … 71 72 72 73 // Install signal handler and set signal SIGUSR1 to interrupt blocking system calls 73 signal(SIGUSR1, & SignalHandler);74 signal(SIGUSR1, &DummyHandler); 74 75 siginterrupt (SIGUSR1, true); 75 76 76 // Install signals to assure that the lock file is deleted in case of a program crash 77 signal(SIGQUIT, &CrashHandler); 77 // Assure lock file is deleted in case of a program crash or call to exit() 78 78 signal(SIGILL, &CrashHandler); 79 79 signal(SIGABRT, &CrashHandler); … … 81 81 signal(SIGSEGV, &CrashHandler); 82 82 signal(SIGBUS, &CrashHandler); 83 signal(SIGTERM, &CrashHandler); 84 signal(SIGINT, &CrashHandler); 85 signal(SIGHUP, &CrashHandler); 86 83 atexit(&ExitFunction); 84 87 85 // Construct main instance and create mutex for thread synchronization 88 86 ProcessIO pio(argc==3 ? argv[2] : DEFAULT_CONFIG); … … 91 89 throw; 92 90 } 91 92 // These signals were set during construction of EvidenceServer 93 signal(SIGQUIT, &CrashHandler); // CTRL-Backspace 94 signal(SIGINT, &CrashHandler); // CTRL-C 95 signal(SIGHUP, &CrashHandler); // CTRL-Backspace 96 signal(SIGTERM, &CrashHandler); 93 97 94 98 // Create threads … … 310 314 311 315 // Dummy signal handler to return from blocking syscalls 312 void SignalHandler(int Signal) {316 void DummyHandler(int Signal) { 313 317 return; 314 318 } 319 320 // This function will be implicitly called by exit() 321 void ExitFunction() { 322 remove(LOCKFILE); 323 return; 324 } -
hvcontrol/src/HV.cc
r113 r126 26 26 BoardName = DeviceName; 27 27 28 for (int i=0; i<NUM_CHAINS; i++) Overcurrent[i] = false; 28 // Create DIM services 29 snprintf(Buffer, sizeof(Buffer), SERVER_NAME"/NAME/ID%.2d", BoardNumber); 30 Name = new DimService (Buffer, BoardName); 31 32 for (int i=0; i<NUM_CHAINS; i++) { 33 for (int j=0; j<NUM_CHANNELS; j++) { 34 snprintf(Buffer, sizeof(Buffer), SERVER_NAME"/VOLT/ID%.2d/%.2d-%.3d", BoardNumber, i, j); 35 BiasVolt[i][j] = new DimService (Buffer, HVV[i][j]); 36 snprintf(Buffer, sizeof(Buffer), SERVER_NAME"/DAC/ID%.2d/%.2d-%.3d", BoardNumber, i, j); 37 BiasDAC[i][j] = new DimService (Buffer, HV[i][j]); 38 } 39 Overcurrent[i] = false; 40 } 29 41 ResetButton = false; 30 42 WrapOK = true; … … 74 86 Reset(); 75 87 close(fDescriptor); 88 } 89 90 delete Name; 91 for (int i=0; i<NUM_CHAINS; i++) { 92 for (int j=0; j<NUM_CHANNELS; j++) { 93 delete BiasVolt[i][j]; 94 delete BiasDAC[i][j]; 95 } 76 96 } 77 97 } … … 194 214 HV[j][k] = 0; 195 215 HVV[j][k] = 0.0; 216 217 // Update DIM services 218 BiasVolt[j][k]->updateService(); 219 BiasDAC[j][k]->updateService(); 196 220 } 197 221 } -
hvcontrol/src/HV.h
r113 r126 10 10 11 11 #include "HVConfig.h" 12 #include "dis.hxx" 12 13 13 14 #define BAUDRATE B115200 … … 52 53 double HVV[NUM_CHAINS][NUM_CHANNELS]; // HV value in volts 53 54 55 DimService *Name; 56 DimService *BiasVolt[NUM_CHAINS][NUM_CHANNELS]; 57 DimService *BiasDAC[NUM_CHAINS][NUM_CHANNELS]; 58 54 59 void ClearVoltageArrays(); 55 60 int Reset(); -
hvcontrol/src/ProcessIO.cc
r113 r126 15 15 16 16 17 ProcessIO::ProcessIO(const char *ConfigFile) {17 ProcessIO::ProcessIO(const char *ConfigFile): EvidenceServer(SERVER_NAME) { 18 18 19 19 // Get program start time … … 268 268 269 269 // Set new voltage (if DAC value, update calibrated value) 270 if(!RampVoltage(DACValue, i, j, k)) Errors++; 271 if(SetDac) fHVBoard[i]->HVV[j][k] = calib->DACToHV(fHVBoard[i]->HV[j][k], i, j, k); 270 if (!RampVoltage(DACValue, i, j, k)) Errors++; 271 if (SetDac) fHVBoard[i]->HVV[j][k] = calib->DACToHV(fHVBoard[i]->HV[j][k], i, j, k); 272 273 // Update DIM services 274 fHVBoard[i]->BiasVolt[j][k]->updateService(); 272 275 273 276 } // Channels … … 316 319 } 317 320 fHVBoard[Board]->HVV[Chain][Channel] = calib->DACToHV(fHVBoard[Board]->HV[Chain][Channel], Board, Chain, Channel); 321 322 // Update DIM services 323 fHVBoard[Board]->BiasVolt[Chain][Channel]->updateService(); 324 318 325 if(++Channel == NUM_CHANNELS) { 319 326 Chain++; … … 625 632 SlowDataClass->NewEntry("Value"); 626 633 SlowDataClass->AddToEntry("%s %d %d %d %d %.2f ",fHVBoard[Board]->BoardName,Board, Chain, Channel, Target, calib->DACToHV(Target,Board,Chain,Channel)); 634 635 // Update DIM service 636 fHVBoard[Board]->BiasDAC[Chain][Channel]->updateService(); 637 627 638 return true; 628 639 } -
hvcontrol/src/ProcessIO.h
r113 r126 7 7 #include <math.h> 8 8 #include <signal.h> 9 10 #define SERVER_NAME "BIAS" // Name to use in DIM 11 #include "../../Evidence/Evidence.h" 9 12 10 13 #include "HVConfig.h" … … 22 25 typedef enum stateenum { active, stopped, na } state_enum; 23 26 24 class ProcessIO {27 class ProcessIO: public EvidenceServer { 25 28 26 29 time_t StartTime;
Note:
See TracChangeset
for help on using the changeset viewer.