// Author: Thomas Hadig (Group EB SLAC Stanford CA USA)
// Last update: $Date: 2004/10/06 20:02:01 $
// Copyright: Thomas Hadig, hadig@slac.stanford.edu
#ifndef __CRTVMEMMCRATE_CXX
#define __CRTVMEMMCRATE_CXX
////////////////////////////////////////////////////////////////////////////////
//
// Cosmic Ray Telescope Data Aquisition Software
//
// Generic driver for a VME crate.
// Connection from a PC to the crate is done via the Wiener VMEMM crate controller
// and the corresponding PCIADA PC board
//
////////////////////////////////////////////////////////////////////////////////
#include <iostream>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include <gendriver/vmemmcrate.hh>
#include <vme/pcivme_ni.h>
namespace CRT
{
//{{{}}}
//{{{ constructor
CrtVMEMMCrate::CrtVMEMMCrate() : CrtCrate()
{
// default constructor
fOk=-1;
}
//}}}
//{{{ constructor CrtVMEMMCrate(const Char_t *inName, Int_t inCrateNumber)
CrtVMEMMCrate::CrtVMEMMCrate(const Char_t *inName, Int_t inCrateNumber)
: CrtCrate(inName)
{
// constructor
// inCrateNumber: should always be 0 for this version
fOk=-1;
fCrateNumber=inCrateNumber;
if (fCrateNumber==0) fOk=0;
}
//}}}
//{{{ destructor
CrtVMEMMCrate::~CrtVMEMMCrate()
{
// destructor
if (fOk==1)
VMEclose(fFile);
}
//}}}
//{{{ GetIdentity
Int_t CrtVMEMMCrate::GetIdentity(Int_t inBoardNumber, Int_t inSubAdress) const
{
// calculates identity number for a crate/board/subadress number
if (fOk==-1) return -1;
if ((inBoardNumber<0)||(inBoardNumber>256)) return -1;
return inBoardNumber * 256;
}
//}}}
//{{{ Initialize
void CrtVMEMMCrate::Initialize()
{
int error;
if (fOk!=0) return;
error = VMEopen("/dev/vmemm_1", 0x39, &fFile);
if (error!=0)
{
fOk=-1;
std::cout<<"ERROR: could not open connection to VMEMM controller "<<errno
<<" "<<strerror(errno)<<std::endl;
exit(1);
}
fOk=1;
ClearInhibit();
}
//}}}
//{{{ Send
Int_t CrtVMEMMCrate::Send(Int_t inIdent, Int_t inFunction, Int_t inValue) const
{
// executes a function on a specific card in the crate. It passed the
// inValue to this function
// return code is the Q response
Int_t error;
if (fOk!=1) return -1;
error = VMEwrite(fFile, inIdent+inFunction, 2, 1, &inValue);
return (error==0 ? 1:0);
}
//}}}
//{{{ Read
Int_t CrtVMEMMCrate::Read(Int_t inIdent, Int_t inFunction, Int_t *outValue) const
{
// executes a function on a specific card in the crate. It passed the
// function return value to outValue
// return code is 1 if ok, -1 otherwise
Int_t data, ret, error;
if (fOk!=1) return -1;
error = VMEread(fFile, inIdent+inFunction, 2, 1, outValue);
return (error==0 ? 1:0);
}
//}}}
//{{{ Test
Int_t CrtVMEMMCrate::Test(Int_t inIdent, Int_t inFunction) const
{
// executes a function on a specific card in the crate.
// return code is the Q response
return Send(inIdent, inFunction, 0);
}
//}}}
//{{{ SetInhibit
void CrtVMEMMCrate::SetInhibit() const
{
// sets crate inhibit ... dummy version
}
//}}}
//{{{ ClearInhibit
void CrtVMEMMCrate::ClearInhibit() const
{
// clears crate inhibit ... dummy version
}
//}}}
}
ClassImp(CRT::CrtVMEMMCrate) // generic driver for a VME crate with Wiener VMEMM controller
#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.