// Author: Thomas Hadig (Group EB SLAC Stanford CA USA)
// Last update: $Date: 2003/08/22 22:31:12 $
// Copyright: Thomas Hadig, hadig@slac.stanford.edu

#ifndef __CRTSCALER84BOARD_CXX
#define __CRTSCALER84BOARD_CXX

////////////////////////////////////////////////////////////////////////////////
//
// Cosmic Ray Telescope Data Aquisition Software
//
// generic driver for Camac module: Jorway 84 Scaler
//
// This module features:
// - 4 channels, 24 bit each
// - read-out is addressed
// - does not support Look-At-Me's
//
////////////////////////////////////////////////////////////////////////////////

#include <gendriver/scaler84board.hh>
#include <gendriver/camaccrate.hh>

namespace CRT
 { 
  //{{{}}}
  //{{{  constructor
   CrtScaler84Board::CrtScaler84Board() : CrtTdcAdcBoard()
   {
    // default constructor
    fOk=0;
   }
  //}}}
  //{{{  constructor CrtScaler84Board(const Char_t *inName, Int_t inBoardNumber, CrtCamacCrate *inCrate)
   CrtScaler84Board::CrtScaler84Board(const Char_t *inName, Int_t inBoardNumber, CrtCamacCrate *inCrate)
    : CrtTdcAdcBoard(inName, inBoardNumber, inCrate)
   {
    // constructor
    // inBoardNumber is the number of the Camac slot
    // inCrate       is a pointer to the Camac crate object
    Int_t i=0;
    while (i<4)
     //{{{  fill identity array
     {
      fIdents[i]=inCrate->GetIdentity(inBoardNumber, i);
      i++;
     }
     //}}}
    fOk=1;
   }
  //}}}
  //{{{  destructor
   CrtScaler84Board::~CrtScaler84Board()
   {
    // destructor
   }
  //}}}
  
  //{{{  Send
   Int_t CrtScaler84Board::Send(Int_t inCommand) const
   {
    // sends command to board
    // available commands:
    // CrtScaler84Board::C_SCALER84_ClearModule
    // CrtScaler84Board::C_SCALER84_Test

    if (fOk!=1) return -1;
    switch (inCommand)
     {
      case C_SCALER84_ClearModule:
        fInCrate->Send(fIdents[0], 9, 0);
        fInCrate->Send(fIdents[1], 9, 0);
        fInCrate->Send(fIdents[2], 9, 0);
        fInCrate->Send(fIdents[3], 9, 0);
        return 1;
      case C_SCALER84_Test:
        return fInCrate->Send(fIdents[0], 25, 0);
     }
    return -1;
   }
  //}}}
  //{{{  Enable
   Int_t CrtScaler84Board::Enable(Int_t inFlag, Int_t inChannel) const
   {
    // enables board features
    // Available features:
    // none

    return -1;
   }
  //}}}
  //{{{  Disable
   Int_t CrtScaler84Board::Disable(Int_t inFlag, Int_t inChannel) const
   {
    // disables board features
    // Available features:
    // none

    return -1;
   }
  //}}}
  //{{{  Clear
   Int_t CrtScaler84Board::Clear(Int_t inFlag, Int_t inChannel) const
   {
    // clears board features
    // Available features:
    // none
    
    return -1;
   }
  //}}}
  //{{{  Test
   Int_t CrtScaler84Board::Test(Int_t inFlag, Int_t inChannel) const
   {
    // tests board features
    // Available features:
    // none

    return -1;
   }
  //}}}
  //{{{  Query
   Int_t CrtScaler84Board::Query(Int_t inChannel, Int_t *outValue) const
   {
    // queries channels
    // available channels:
    // 0-3: individual input channels

    if (fOk!=1) return -1;
    if ((inChannel<0)||(inChannel>3)) return -1;
    return fInCrate->Read(fIdents[inChannel], 0, outValue);
   }
  //}}}
  //{{{  Assign
   Int_t CrtScaler84Board::Assign(Int_t inChannel, Int_t inValue) const
   {
    // assigns channels
    // available channels:
    // none

    return -1;
   }
  //}}}
  
  //{{{  Initialize
   Int_t CrtScaler84Board::Initialize() const
   {
    // initializes the board
    return Send(C_SCALER84_ClearModule);
   }
  //}}}
  //{{{  Prepare
   Int_t CrtScaler84Board::Prepare() const
   {
    // prepares the board for data taking 
    Send(C_SCALER84_ClearModule);
    return 1;
   }
  //}}}
  //{{{  HasData
   Int_t CrtScaler84Board::HasData() const
   {
    // tests whether the module has data available
    // as the board does not support LAM, we always have data
    return 1;
   }
  //}}}
  //{{{  ReadModule
   Int_t CrtScaler84Board::ReadModuleAndClear(Int_t *outChannels) const
   {
    // reads all channels and clears the data afterwards.
    Int_t ret= ((CrtCamacCrate *)fInCrate)->BlockRead(fIdents[0], 0, 12, outChannels);
    Send(C_SCALER84_ClearModule);
    return ret;
   }
  //}}}
  //{{{  GetNumberOfChannels
   Int_t CrtScaler84Board::GetNumberOfChannels() const
   {
    return 4;
   }
  //}}}
 }
 
ClassImp(CRT::CrtScaler84Board) //LeCroy 84 Scaler module driver

#endif


ROOT page - Class index - Class Hierarchy - Top of the page

This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.