AlcapDAQ  1
Data Structures | Macros | Functions | Variables
s500.cpp File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#include <time.h>
#include "midas.h"
#include "crate.h"
#include "mcstd.h"
#include "odb_wrapper.h"
#include "diag.h"

Go to the source code of this file.

Data Structures

struct  s500
 

Macros

#define N_CH_S500   6
 
#define MAX_S500   8
 

Functions

INT s500_bor ()
 
INT s500_read (char *pevent)
 
INT s500_bor1 (struct s500 *s500)
 

Variables

struct readout_module s500_module
 
struct s500 s500 [MAX_S500]
 

Macro Definition Documentation

#define MAX_S500   8

Definition at line 41 of file s500.cpp.

Referenced by s500_bor(), and s500_read().

#define N_CH_S500   6

Definition at line 31 of file s500.cpp.

Referenced by s500_bor1(), and s500_read().

Function Documentation

INT s500_bor ( )

Definition at line 76 of file s500.cpp.

References crate_number, diag_print(), enabled, s500::enabled, MAX_S500, odb_find_key(), odb_get_bool(), s500::odb_name, s500_bor1(), sprintf(), and SUCCESS.

77 {
78  // Use the ODB to find any S500 modules
79  for(int j = 0; j < MAX_S500; j++) {
80 
81  bool enabled = false;
82 
83  if (odb_find_key("/Equipment/Crate %d/Settings/S500 %d", crate_number, j)) {
84  diag_print(1, "ODB says S500 %d is present, ", j);
85  enabled =
86  odb_get_bool("/Equipment/Crate %d/Settings/S500 %d/enabled status",
87  crate_number, j);
88  if (enabled) {
89  diag_print(1, "and is enabled. Initializing...\n");
90  } else {
91  diag_print(1, "but is disabled.\n");
92  }
93  }
94 
95  s500[j].enabled = enabled;
96 
97  // Set up the name of the MIDAS bank associated with the module
98  sprintf(s500[j].odb_name, "S500 %d", j);
99 
100  if(enabled) {
101  s500_bor1(&s500[j]);
102  }
103  }
104 
105  return SUCCESS;
106 }
INT s500_bor1 ( struct s500 s500)

Definition at line 49 of file s500.cpp.

References s500::acum, camo(), s500::crate, crate_number, i, N_CH_S500, odb_get_int(), s500::odb_name, s500::slot, and SUCCESS.

Referenced by s500_bor().

50 {
51  // Get the VME base address of the module
52  s500->crate = odb_get_int("/Equipment/Crate %d/Settings/%s/Crate",
53  crate_number, s500->odb_name);
54  s500->slot = odb_get_int("/Equipment/Crate %d/Settings/%s/Slot",
55  crate_number, s500->odb_name);
56 
57  // clear all channels
58  for(int i = 0; i < N_CH_S500; i++) {
59  camo(s500->crate, s500->slot, i, 9, 0);
60  }
61 
62  // clear the accumulated values
63  for(int i = 0; i < N_CH_S500; i++) {
64  s500->acum[i] = 0;
65  }
66 
67  return SUCCESS;
68 }
INT s500_read ( char *  pevent)

Definition at line 114 of file s500.cpp.

References s500::acum, cam24i(), crate, enabled, i, MAX_S500, N_CH_S500, s500::slot, and SUCCESS.

115 {
116  DWORD *pdata;
117 
118  // first fill in the raw values
119  bk_create(pevent, "S500", TID_DWORD, &pdata);
120  for(int i = 0; i < MAX_S500; i++) {
121  if(s500[i].enabled) {
122  for(int j = 0; j < N_CH_S500; j++) {
123  DWORD val;
124  cam24i(s500[i].crate, s500[i].slot, j, 2, &val);
125  *pdata++ = val;
126  s500[i].acum[j] += val;
127  }
128  }
129  }
130  bk_close(pevent, pdata);
131 
132  // now the accumulated values
133  bk_create(pevent, "ACUM", TID_DWORD, &pdata);
134  for(int i = 0; i < MAX_S500; i++) {
135  if(s500[i].enabled) {
136  for(int j = 0; j < N_CH_S500; j++) {
137  *pdata++ = s500[i].acum[j];
138  }
139  }
140  }
141  bk_close(pevent, pdata);
142 
143  return SUCCESS;
144 }

Variable Documentation

struct s500 s500[MAX_S500]

Definition at line 42 of file s500.cpp.

struct readout_module s500_module
Initial value:
= {
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
}

Definition at line 18 of file s500.cpp.