// =====================================================================
//  $Id: TSoftwareScalerModule.cc,v 1.1.1.1 2003/06/27 02:56:41 goiwai Exp $
//  $Name: CLDAQ-1-06-02 $
// =====================================================================
#include "TSoftwareScalerModule.hh"
#include "TDataSegment.hh"
#include "TDataElement.hh"

TSoftwareScalerModule::TSoftwareScalerModule( Tint nchannel )
  : TSoftwareModule( nchannel ), theChannel( nchannel, 0 )
{;}

TSoftwareScalerModule::TSoftwareScalerModule( const TSoftwareScalerModule& right )
  : TSoftwareModule( right ), theChannel( right.theChannel )
{;}

TSoftwareScalerModule::~TSoftwareScalerModule()
{;}

Tvoid TSoftwareScalerModule::FillData( TDataElement& element, Tint channel )
{
  if ( channel < 0 || channel >= theNumberOfChannels ) {
    Tcerr << "TSoftwareScalerModule::FillData: invalid ID " << channel << Tendl;
    theStatus = -EFAULT;
    element.FillData( &theStatus, tTypeInt, 1 );
  } else {
    element.FillData( &theChannel[ channel ], tTypeInt, 1 );
  }
  return;
}

const TSoftwareScalerModule& TSoftwareScalerModule::operator=( const TSoftwareScalerModule& right )
{
  *( (TSoftwareModule*)this ) = *( (TSoftwareModule*)(&right) );
  theChannel = right.theChannel;
  return( *this );
}

Tbool TSoftwareScalerModule::operator==( const TSoftwareScalerModule& right ) const
{
  Tbool ret = Ttrue;
  ret &= ( *( (TSoftwareModule*)this ) == *( (TSoftwareModule*)(&right) ) );
  ret &= ( theChannel == right.theChannel );
  return( ret );
}

Tbool TSoftwareScalerModule::operator!=( const TSoftwareScalerModule& right ) const
{
  Tbool ret = Tfalse;
  ret |= ( *( (TSoftwareModule*)this ) != *( (TSoftwareModule*)(&right) ) );
  ret |= ( theChannel != right.theChannel );
  return( ret );
}
