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

#ifndef __CRTOUTPUT3016BOARD_CXX
#define __CRTOUTPUT3016BOARD_CXX

////////////////////////////////////////////////////////////////////////////////
//
// Cosmic Ray Telescope Data Aquisition Software
//
// generic driver for Camac module: DSP 3016 Digital Analog Converter
//
// This module features:
// - 16 channel with 16 bit (range -10V ... +10V)
//
////////////////////////////////////////////////////////////////////////////////

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

namespace CRT
 { 
  //{{{}}}
  //{{{  constructor
   CrtOutput3016Board::CrtOutput3016Board() : CrtCamacBoard()
   {
    // default constructor
    fOk=0;
   }
  //}}}
  //{{{  constructor CrtOutput3016Board(const Char_t *inName, Int_t inBoardNumber, CrtCamacCrate *inCrate)
   CrtOutput3016Board::CrtOutput3016Board(const Char_t *inName, Int_t inBoardNumber, CrtCamacCrate *inCrate)
    : CrtCamacBoard(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<16)
     //{{{  fill identity array
     {
      fIdents[i]=inCrate->GetIdentity(inBoardNumber, i);
      i++;
     }
     //}}}
    fOk=1;
   }
  //}}}
  //{{{  destructor
   CrtOutput3016Board::~CrtOutput3016Board()
   {
    // destructor
   }
  //}}}

  //{{{  Send
   Int_t CrtOutput3016Board::Send(Int_t inCommand) const
   {
    // sends command to board
    // available commands:
    // none

    return -1;
   }
  //}}}
  //{{{  Enable
   Int_t CrtOutput3016Board::Enable(Int_t inFlag, Int_t inChannel) const
   {
    // enables board features
    // Available features:
    // none

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

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

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

    return -1;
   }
  //}}}
  //{{{  Query
   Int_t CrtOutput3016Board::Query(Int_t inChannel, Int_t *outValue) const
   {
    // queries channels
    // available channels:
    // 0-15: current DAC value for this channel
    // 16 : module ID
    
    if (fOk!=1) return -1;
    if ((inChannel>=0)&&(inChannel<16)) 
      return fInCrate->Read(fIdents[inChannel], 0, outValue);
    if (inChannel==16)
      return fInCrate->Read(fIdents[0], 3, outValue);
    return -1;
   }
  //}}}
  //{{{  Assign
   Int_t CrtOutput3016Board::Assign(Int_t inChannel, Int_t inValue) const
   {
    // assigns channels
    // available channels:
    // 0-15: set current DAC value for the channel given

    if (fOk!=1) return -1;
    if ((inChannel>=0)&&(inChannel<16)) 
      return fInCrate->Send(fIdents[inChannel], 16, inValue);
    return -1;
   }
  //}}}
  //{{{  SetVoltage
   Int_t CrtOutput3016Board::SetVoltage(Int_t inChannel, Double_t inVoltage) const
   {
    Int_t value= (Int_t)((inVoltage+10)/20.*(Double_t)0xffff);
    return Assign(inChannel, value);
   }
  //}}}
  //{{{  GetVoltage
   Int_t CrtOutput3016Board::GetVoltage(Int_t inChannel, Double_t *outVoltage) const
   {
    Int_t value;
    Int_t ret = Query(inChannel, &value);
    *outVoltage = ((Double_t)(value &0x7fff))*10./((Double_t)0x7fff);
    if ((value & 0x8000)==0)
      *outVoltage = *outVoltage-10;
    return ret;
   }
  //}}}
  //{{{  GetNumberOfChannels
   Int_t CrtOutput3016Board::GetNumberOfChannels() const
   {
    return 16;
   }
  //}}}
 }
 
ClassImp(CRT::CrtOutput3016Board) //DSP 3016 Digital Analog Converter 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.