LCOV - code coverage report
Current view: top level - TRIGGER - AliTrigConnector.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 46 2.2 %
Date: 2016-06-14 17:26:59 Functions: 1 8 12.5 %

          Line data    Source code
       1             : /**************************************************************************
       2             :  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
       3             :  *                                                                        *
       4             :  * Author: The ALICE Off-line Project.                                    *
       5             :  * Contributors are mentioned in the code where appropriate.              *
       6             :  *                                                                        *
       7             :  * Permission to use, copy, modify and distribute this software and its   *
       8             :  * documentation strictly for non-commercial purposes is hereby granted   *
       9             :  * without fee, provided that the above copyright notice appears in all   *
      10             :  * copies and that both the copyright notice and this permission notice   *
      11             :  * appear in the supporting documentation. The authors make no claims     *
      12             :  * about the suitability of this software for any purpose. It is          *
      13             :  * provided "as is" without express or implied warranty.                  *
      14             :  **************************************************************************/
      15             : 
      16             : /* $Id$ */
      17             : // Author: Andrei Gheata, 28/07/2009
      18             : 
      19             : //==============================================================================
      20             : //   AliTrigConnector - General connector class. A connector links a feeder
      21             : // device output to a number of other device inputs (clients). It transmits the 
      22             : // signal to all clients and calls their SetInput() method.
      23             : //==============================================================================
      24             : 
      25             : #include "AliTrigConnector.h"
      26             : 
      27             : #include <TObjArray.h>
      28             : #include <TClass.h>
      29             : 
      30             : #include "AliTrigDevice.h"
      31             : #include "AliTrigEvent.h"
      32             : 
      33             : 
      34          12 : ClassImp(AliTrigConnector)
      35             : 
      36             : //______________________________________________________________________________
      37             : AliTrigConnector::~AliTrigConnector()
      38           0 : {
      39             : // Destructor.
      40           0 :   if (fInputs) delete [] fInputs;
      41           0 :   if (fDevices) delete fDevices;
      42           0 : }
      43             : 
      44             : //______________________________________________________________________________
      45             : void AliTrigConnector::Connect(AliTrigDevice *client, Int_t input)
      46             : {
      47             : // Adds the device and its input to the list of clients.
      48             :   // Loop array of inputs to check if this input is already connected.
      49           0 :   for (Int_t i=0; i<fNclients; i++) {
      50           0 :     if (fInputs[i]==input && fDevices->At(i)==client) {
      51           0 :       Info("Connect", "Output #%d of device %s already connected to input #%d of device%s",
      52           0 :            fOutput, fFeeder->GetName(), input, client->GetName());
      53           0 :       return;
      54             :     } 
      55             :   }
      56             : //  if (strcmp(client->GetInputType(fFeeder->GetOutputType(fOutput))) {
      57             : //    Fatal("Cannot connect output slot #%d (type %s) of device %s to input slot #%d of device %s. Aborting",
      58             : //            fOutput, fFeeder->GetInputType(fOutput), fFeeder->GetName(), input, client->GetName());
      59             : //  }          
      60           0 :   if (!fArraySize) {
      61           0 :     fArraySize = 8;
      62           0 :     fInputs = new Int_t[fArraySize];
      63           0 :     fDevices = new TObjArray(fArraySize);
      64           0 :   }
      65           0 :   if (fNclients >= fArraySize) {
      66           0 :     fArraySize *= 2;
      67           0 :     Int_t *array = new Int_t[fArraySize];
      68           0 :     memcpy(array, fInputs, fNclients*sizeof(Int_t));
      69           0 :     delete [] fInputs;
      70           0 :     fInputs = array;
      71           0 :   }
      72           0 :   fInputs[fNclients] = input;
      73           0 :   fDevices->Add(client);
      74           0 :   fNclients++;
      75           0 : }    
      76             : 
      77             : //______________________________________________________________________________
      78             : void AliTrigConnector::Print(Option_t */*option*/) const
      79             : {
      80             : // Print info about this connector.
      81           0 :   Printf("   feeder: output #%d of device %s\n", fOutput, fFeeder->GetName());
      82           0 :   Printf("   client devices:\n");
      83           0 :   for (Int_t i=0; i<fNclients; i++) Printf("      #%d %s\n", fInputs[i], fDevices->At(i)->GetName());
      84           0 : }
      85             : 
      86             : //______________________________________________________________________________
      87             : Bool_t AliTrigConnector::Transmit(Bool_t value)
      88             : {
      89             : // Transmit Boolean signal from feeder to all clients.
      90             :   AliTrigDevice *nextclient;
      91             :   Bool_t transmit = kTRUE;
      92           0 :   for (Int_t i=0; i<fNclients; i++) {
      93           0 :     nextclient = (AliTrigDevice*)fDevices->At(i);
      94           0 :     Bool_t done = nextclient->SetInputValue(fInputs[i], value);
      95           0 :     if (!done) {
      96           0 :       Error("Transmit", "Connector %s: Boolean value cannot be transmitted to input %d of device %s",
      97           0 :             GetName(), i,  nextclient->GetName());
      98             :       transmit = kFALSE;      
      99           0 :     }
     100             :   }
     101           0 :   return transmit;
     102             : }
     103             : 
     104             : //______________________________________________________________________________
     105             : Bool_t AliTrigConnector::Transmit(AliTrigEvent *event)
     106             : {
     107             : // Transmit Boolean signal from feeder to all clients.
     108             :   AliTrigDevice *nextclient;
     109             :   Bool_t transmit = kTRUE;
     110           0 :   for (Int_t i=0; i<fNclients; i++) {
     111           0 :     nextclient = (AliTrigDevice*)fDevices->At(i);
     112           0 :     Bool_t done = nextclient->SetInputValue(fInputs[i], event);
     113           0 :     if (!done) {
     114           0 :       Error("Transmit", "Connector %s: Event cannot be transmitted to input %d of device %s",
     115           0 :             GetName(), i,  nextclient->GetName());
     116             :       transmit = kFALSE;      
     117           0 :     }
     118             :   }
     119           0 :   return transmit;    
     120             : }

Generated by: LCOV version 1.11