Changeset 126 for hvcontrol


Ignore:
Timestamp:
12/08/09 13:29:04 (15 years ago)
Author:
ogrimm
Message:
Implemented DIM servers
Location:
hvcontrol
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • hvcontrol/History.txt

    r112 r126  
    262624/9/2009   Program is terminated if too many errors are encountered by the
    2727            monitor thread
     288/12/2009   Implemented DIM servers (currently only needs DIM_DNS_NODE
     29            environment variable)
  • hvcontrol/Makefile

    r93 r126  
    33#
    44
    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
     5SOURCES = 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
     6OBJECTS = $(addsuffix .o, $(basename $(SOURCES))) 
     7INCDIRS   = -I. -I./src -I../../Evidence/DIM/dim
    88
    9 CPPFLAGS = -O3 -Wall -DOS_LINUX
    10 LIBS = -lstdc++ -lpthread -lfl -lreadline -ltermcap
     9CPPFLAGS = -O3 -Wall -DOS_LINUX $(INCDIRS)
     10LDLIBS = -lstdc++ -lpthread -lfl -lreadline -ltermcap
    1111
    12 hvcontrol: $(OBJECTS)
    13         $(CC) $(CPPFLAGS) -o $@ $(OBJECTS) $(LIBS)
     12hvcontrol: $(OBJECTS) ../../Evidence/DIM/linux/libdim.a
     13#       $(CC) $(CPPFLAGS) -o $@ $(OBJECTS) $(LIBS)
    1414
    1515clean:
    16         @rm -f $(OBJECTS) $(SOBJECTS).so
     16        @rm -f $(OBJECTS)
    1717        @rm -f *.d
    1818        @rm -f *~
     
    2222# Implicit rules
    2323
    24 %.o : %.cc
    25         $(CC) $(CPPFLAGS) $(INCDIRS) -c -o $@ $<
    26 %.o : %.cpp
    27         $(CC) $(CPPFLAGS) $(INCDIRS) -c -o $@ $<
     24#%.o : %.cc
     25#       $(CC) $(CPPFLAGS) $(INCDIRS) -c -o $@ $<
     26#%.o : %.cpp
     27#       $(CC) $(CPPFLAGS) $(INCDIRS) -c -o $@ $<
    2828%.d :
    2929        @echo "Generating dependencies" $@
  • hvcontrol/hvcontrol.cpp

    r111 r126  
    3030void CCCommand(ProcessIO *);
    3131void HVMonitor(ProcessIO *);
    32 void SignalHandler(int);
     32void DummyHandler(int);
    3333void CrashHandler(int);
     34void ExitFunction();
    3435
    3536// ================
     
    7172 
    7273  // Install signal handler and set signal SIGUSR1 to interrupt blocking system calls
    73   signal(SIGUSR1, &SignalHandler);
     74  signal(SIGUSR1, &DummyHandler);
    7475  siginterrupt (SIGUSR1, true);
    7576
    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()
    7878  signal(SIGILL, &CrashHandler);
    7979  signal(SIGABRT, &CrashHandler);
     
    8181  signal(SIGSEGV, &CrashHandler);
    8282  signal(SIGBUS, &CrashHandler);
    83   signal(SIGTERM, &CrashHandler);
    84   signal(SIGINT, &CrashHandler);
    85   signal(SIGHUP, &CrashHandler);
    86 
     83  atexit(&ExitFunction);
     84 
    8785  // Construct main instance and create mutex for thread synchronization
    8886  ProcessIO pio(argc==3 ? argv[2] : DEFAULT_CONFIG);
     
    9189    throw;
    9290  }
     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);
    9397
    9498  // Create threads
     
    310314
    311315// Dummy signal handler to return from blocking syscalls
    312 void SignalHandler(int Signal) {
     316void DummyHandler(int Signal) {
    313317  return;         
    314318}
     319
     320// This function will be implicitly called by exit()
     321void ExitFunction() {
     322  remove(LOCKFILE);
     323  return;         
     324}
  • hvcontrol/src/HV.cc

    r113 r126  
    2626  BoardName = DeviceName;
    2727 
    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  }
    2941  ResetButton = false;
    3042  WrapOK = true;
     
    7486    Reset();
    7587    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    }
    7696  }
    7797}
     
    194214      HV[j][k] = 0;
    195215      HVV[j][k] = 0.0;
     216     
     217      // Update DIM services
     218      BiasVolt[j][k]->updateService();
     219      BiasDAC[j][k]->updateService();
    196220    }
    197221  }
  • hvcontrol/src/HV.h

    r113 r126  
    1010
    1111#include "HVConfig.h"
     12#include "dis.hxx"
    1213
    1314#define BAUDRATE B115200
     
    5253   double HVV[NUM_CHAINS][NUM_CHANNELS];  // HV value in volts
    5354
     55   DimService *Name;
     56   DimService *BiasVolt[NUM_CHAINS][NUM_CHANNELS];
     57   DimService *BiasDAC[NUM_CHAINS][NUM_CHANNELS];
     58
    5459   void ClearVoltageArrays();
    5560   int Reset();
  • hvcontrol/src/ProcessIO.cc

    r113 r126  
    1515
    1616
    17 ProcessIO::ProcessIO(const char *ConfigFile) {
     17ProcessIO::ProcessIO(const char *ConfigFile): EvidenceServer(SERVER_NAME) {
    1818
    1919  // Get program start time
     
    268268         
    269269          // 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();
    272275
    273276        } // Channels   
     
    316319            }
    317320            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
    318325            if(++Channel == NUM_CHANNELS) {
    319326              Chain++;
     
    625632  SlowDataClass->NewEntry("Value");
    626633  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 
    627638  return true;
    628639}
  • hvcontrol/src/ProcessIO.h

    r113 r126  
    77#include <math.h>
    88#include <signal.h>
     9
     10#define SERVER_NAME "BIAS"       // Name to use in DIM
     11#include "../../Evidence/Evidence.h"
    912
    1013#include "HVConfig.h"
     
    2225typedef enum stateenum { active, stopped, na } state_enum;
    2326
    24 class ProcessIO {
     27class ProcessIO: public EvidenceServer {
    2528
    2629  time_t StartTime;
Note: See TracChangeset for help on using the changeset viewer.