7 template <
class EnvPeriodPolicy>
18 m_rawproton0 =
new EnvPeriodPolicy::ppp_memory_t[RPCNT0SIZE];
19 m_goodproton0 =
new EnvPeriodPolicy::ppp_memory_t[GPCNT0SIZE];
29 addMapping(
ISISVME::TransferIORegisterSpace,
LOOKTAR, 1, &
m_lookup,
"",
true,
true, NULL, 0,
false,
false, fault_mode);
31 addMapping(
ISISVME::TransferIORegisterSpace,
MPCNT, 1, &
m_main_period_counter,
"",
true,
false, NULL, 0,
false,
false, fault_mode);
32 addMapping(
ISISVME::TransferIORegisterSpace,
MPLIM, 1, &
m_main_period_limit,
"",
true,
true, NULL, 0,
false,
false, fault_mode);
33 addMapping(
ISISVME::TransferIORegisterSpace,
PSCNT, 1, &
m_period_sequence_counter,
"",
true,
false, NULL, 0,
false,
false, fault_mode);
34 addMapping(
ISISVME::TransferIORegisterSpace,
PSLR, 1, &
m_period_sequence_limit,
"",
true,
true, NULL, 0,
false,
false, fault_mode);
35 addMapping(
ISISVME::TransferIORegisterSpace, EXTPEROVFVC, 1, &
m_ext_period_overflow_veto_counter,
"",
true,
true, NULL, 0,
false,
false, fault_mode);
36 addMapping(
ISISVME::TransferIORegisterSpace, PERINCTOT, 1, &
m_period_increment_total,
"",
true,
true, NULL, 0,
false,
false, fault_mode);
38 addMapping(
ISISVME::TransferIORegisterSpace, PEROUTDEL, 1, &
m_period_output_delay,
"",
true,
true, NULL, 0,
false,
false, fault_mode);
39 addMapping(
ISISVME::TransferIORegisterSpace,
PCREG, 1, &
m_period_control,
"",
true,
true, NULL, 0,
false,
false, fault_mode);
40 addMapping(
ISISVME::TransferIORegisterSpace, ALT1SFV, 1, &
m_alt1_fw,
"",
true,
false, NULL, 0,
false,
false, fault_mode);
41 addMapping(
ISISVME::TransferLUTSpace,
PERLUTSTART,
PERLUTSIZE,
m_perlut,
"perlut",
true,
true, lookup_reg,
TARPERLUT,
false,
false, fault_mode);
42 addMapping(
ISISVME::TransferLUTSpace,
OUTLUTSTART,
OUTLUTSIZE,
m_outlut,
"outlut",
true,
true, lookup_reg,
TAROUTLUT,
false,
false, fault_mode);
43 addMapping(
ISISVME::TransferLUTSpace,
RFCNT0START,
RFCNT0SIZE,
m_rawframes,
"raw frames",
true,
true, NULL, 0,
false,
false, fault_mode);
44 addMapping(
ISISVME::TransferLUTSpace,
GFCNT0START,
GFCNT0SIZE,
m_goodframes,
"good frames",
true,
true, NULL, 0,
false,
false, fault_mode);
45 addMapping(
ISISVME::TransferLUTSpace,
RPCNT0START, RPCNT0SIZE,
m_rawproton0,
"raw proton0",
true,
true, NULL, 0,
false,
false, fault_mode);
46 addMapping(
ISISVME::TransferLUTSpace,
GPCNT0START, GPCNT0SIZE,
m_goodproton0,
"good proton0",
true,
true, NULL, 0,
false,
false, fault_mode);
47 addMapping(
ISISVME::TransferLUTSpace, RPCNT1START, RPCNT1SIZE,
m_rawproton1,
"raw proton1",
true,
true, NULL, 0,
false,
false, fault_mode);
48 addMapping(
ISISVME::TransferLUTSpace, GPCNT1START, GPCNT1SIZE,
m_goodproton1,
"good proton1",
true,
true, NULL, 0,
false,
false, fault_mode);
49 addMapping(
ISISVME::TransferLUTSpace, SPARE0START, SPARE0SIZE,
m_spare0,
"spare0",
true,
true, NULL, 0,
false,
false, fault_mode);
50 addMapping(
ISISVME::TransferLUTSpace, SPARE1START, SPARE1SIZE,
m_spare1,
"spare1",
true,
true, NULL, 0,
false,
false, fault_mode);
53 addMapping(
ISISVME::TransferIORegisterSpace, FCOUNTR, 1, &
m_raw_frames,
"",
true,
false, NULL, 0,
false,
false, fault_mode);
54 addMapping(
ISISVME::TransferIORegisterSpace, FCOUNTG, 1, &
m_good_frames,
"",
true,
false, NULL, 0,
false,
false, fault_mode);
55 addMapping(
ISISVME::TransferIORegisterSpace, PCOUNTR0, 1, &
m_raw_proton_low,
"",
true,
false, NULL, 0,
false,
false, fault_mode);
56 addMapping(
ISISVME::TransferIORegisterSpace, PCOUNTR1, 1, &
m_raw_proton_high,
"",
true,
false, NULL, 0,
false,
false, fault_mode);
57 addMapping(
ISISVME::TransferIORegisterSpace, PCOUNTG0, 1, &
m_good_proton_low,
"",
true,
false, NULL, 0,
false,
false, fault_mode);
58 addMapping(
ISISVME::TransferIORegisterSpace, PCOUNTG1, 1, &
m_good_proton_high,
"",
true,
false, NULL, 0,
false,
false, fault_mode);
59 addMapping(
ISISVME::TransferIORegisterSpace, FIFOVETFRM, 1, &
m_fifo_veto_frames,
"",
true,
false, NULL, 0,
false,
false, fault_mode);
60 addMapping(
ISISVME::TransferIORegisterSpace, SMPVETFRM, 1, &
m_smp_veto_frames,
"",
true,
false, NULL, 0,
false,
false, fault_mode);
61 addMapping(
ISISVME::TransferIORegisterSpace, INTVETFRM, 1, &
m_internal_veto_frames,
"",
true,
false, NULL, 0,
false,
false, fault_mode);
62 addMapping(
ISISVME::TransferIORegisterSpace, EXT0VETFRM, 1, &
m_external_veto0_frames,
"",
true,
false, NULL, 0,
false,
false, fault_mode);
63 addMapping(
ISISVME::TransferIORegisterSpace, EXT1VETFRM, 1, &
m_external_veto1_frames,
"",
true,
false, NULL, 0,
false,
false, fault_mode);
64 addMapping(
ISISVME::TransferIORegisterSpace, EXT2VETFRM, 1, &
m_external_veto2_frames,
"",
true,
false, NULL, 0,
false,
false, fault_mode);
65 addMapping(
ISISVME::TransferIORegisterSpace, EXT3VETFRM, 1, &
m_external_veto3_frames,
"",
true,
false, NULL, 0,
false,
false, fault_mode);
66 addMapping(
ISISVME::TransferIORegisterSpace, FSDELAY, 1, &
m_fs_delay,
"",
true,
true, NULL, 0,
false,
false, fault_mode);
67 addMapping(
ISISVME::TransferIORegisterSpace, FC0WINDLY, 1, &
m_chopper_window_delay,
"",
true,
true, NULL, 0,
false,
false, fault_mode);
68 addMapping(
ISISVME::TransferIORegisterSpace, FC0WINWTH, 1, &
m_chopper_window_width,
"",
true,
true, NULL, 0,
false,
false, fault_mode);
69 addMapping(
ISISVME::TransferIORegisterSpace, FC0VETFRM, 1, &
m_chopper_veto_frames,
"",
true,
false, NULL, 0,
false,
false, fault_mode);
70 addMapping(
ISISVME::TransferIORegisterSpace, MSMVETFRM, 1, &
m_ms_veto_frames,
"",
true,
false, NULL, 0,
false,
false, fault_mode);
71 addMapping(
ISISVME::TransferIORegisterSpace, RCONTROL, 1, &
m_run_control,
"",
true,
true, NULL, 0,
false,
false, fault_mode);
72 addMapping(
ISISVME::TransferIORegisterSpace, RVETO, 1, &
m_veto,
"",
true,
true, NULL, 0,
false,
false, fault_mode);
73 addMapping(
ISISVME::TransferIORegisterSpace, TS2PVETFRM, 1, &
m_ts2_pulse_veto_frames,
"",
true,
true, NULL, 0,
false,
false, fault_mode);
74 addMapping(
ISISVME::TransferIORegisterSpace, HZ50VETFRM, 1, &
m_50hz_veto_frames,
"",
true,
true, NULL, 0,
false,
false, fault_mode);
76 addMapping(
ISISVME::TransferIORegisterSpace, FRAMETIME0, 1, &
m_frame_time_low,
"",
true,
true, NULL, 0,
false,
false, fault_mode);
77 addMapping(
ISISVME::TransferIORegisterSpace, FRAMETIME1, 1, &
m_frame_time_high,
"",
true,
true, NULL, 0,
false,
false, fault_mode);
90 template <
class EnvPeriodPolicy>
93 os <<
"SIMEnvPeriod card at position " << m_position <<
" using policy " << EnvPeriodPolicy::env_period_policy_name;
96 template <
class EnvPeriodPolicy>
101 m_main_period_counter = 0;
104 m_period_sequence_counter = 0;
106 if (m_period_control &
PCCLRPC)
108 m_main_period_counter = 0;
109 m_period_sequence_counter = 0;
111 if (m_run_control & RCFCLEAR)
115 m_fifo_veto_frames = 0;
116 m_smp_veto_frames = 0;
117 m_internal_veto_frames = 0;
118 m_external_veto0_frames = 0;
119 m_external_veto1_frames = 0;
120 m_external_veto2_frames = 0;
121 m_external_veto3_frames = 0;
122 m_chopper_veto_frames = 0;
123 m_ms_veto_frames = 0;
125 if (m_run_control & RCPCLEAR)
127 m_raw_proton_low = m_raw_proton_high = 0;
128 m_good_proton_low = m_good_proton_high = 0;
130 if (m_run_control & RCSTART)
136 m_is_running =
false;
141 template <
class EnvPeriodPolicy>
146 template <
class EnvPeriodPolicy>
151 int frame_incr = delay / 20;
152 int proton_incr = (int)( 180.0 * (
double)delay / (1000.0 * 3600.0 * 1.738e-6) ) ;
159 if (!(m_run_control & RCPERSZEQZERO))
163 if (m_vme->isRunning())
165 m_raw_frames += frame_incr;
166 increment32(proton_incr, m_raw_proton_low, m_raw_proton_high);
167 if ( !m_vme->isVetoing() )
169 m_good_frames += frame_incr;
170 increment32(proton_incr, m_good_proton_low, m_good_proton_high);
173 if (!(m_period_control &
PCENAB))
178 int current_period, max_period, max_frames;
179 current_period = m_main_period_counter & 0x3fff;
180 is_dwell = ((m_main_period_counter & (1 << 14)) != 0);
181 max_period = m_main_period_limit & 0x3fff;
182 max_frames = 1 + (m_perlut[current_period] & 0xffff);
183 if ( m_vme->isRunning() )
187 m_veto_raised =
true;
188 increment(frame_incr, m_internal_veto_frames);
189 increment(frame_incr, m_rawframes[current_period]);
190 increment32(proton_incr, m_rawproton0[current_period], m_rawproton1[current_period]);
194 m_veto_raised =
true;
195 increment(frame_incr, m_internal_veto_frames);
196 increment(frame_incr, m_rawframes[current_period]);
197 increment(frame_incr, m_goodframes[current_period]);
198 increment32(proton_incr, m_rawproton0[current_period], m_rawproton1[current_period]);
202 m_veto_raised =
false;
203 increment(frame_incr, m_rawframes[current_period]);
204 increment(frame_incr, m_goodframes[current_period]);
205 increment32(proton_incr, m_rawproton0[current_period], m_rawproton1[current_period]);
206 increment32(proton_incr, m_goodproton0[current_period], m_goodproton1[current_period]);
208 if (m_goodframes[current_period] >= max_frames*(1+m_period_sequence_counter) )
210 if (++current_period < max_period)
212 m_main_period_counter = (current_period & 0x3fff) |
213 ((m_perlut[current_period] & 0x80000000) >> 17);
214 if (!(m_perlut[current_period] & 0x80000000))
216 m_vme->incrementDetectorCardPeriod();
224 else if ((m_period_control &
PCMULENAB) &&
225 (m_period_sequence_counter > m_period_sequence_limit))
232 m_period_sequence_counter++;
233 m_main_period_counter = (current_period & 0x3fff) |
234 ((m_perlut[current_period] & 0x80000000) >> 17);
235 m_vme->resetDetectorCardPeriod();
242 template <
class EnvPeriodPolicy>
247 delete[] m_rawframes;
248 delete[] m_goodframes;
isisU32_t m_frame_time_high
virtual void updateCardAfterRead(DAEstatus &status)
isisU32_t m_internal_veto_frames
isisU32_t m_smp_veto_frames
isisU32_t m_chopper_veto_frames
virtual void simulate(int delay)
isisU32_t m_main_period_limit
isisU32_t m_raw_proton_high
SIMEnvPeriodCard(int position, VMESimulationIface *vme, FaultMode fault_mode, DAEstatus &status)
isisU32_t m_frame_time_low
int addMapping(ISISVME::TransferProps props, isisU32_t address, int n, isisU32_t *var, const char *name, bool readable, bool writable, isisU32_t *access_reg, unsigned access_bit, bool wrap, bool sixteen_bit_access, FaultMode fault_mode)
isisU32_t m_main_period_counter
isisU32_t m_fifo_veto_frames
isisU32_t m_period_sequence_limit
bool isRegisterUsed(const T &address)
registers are either "unsigned" or "unused_t"
isisU32_t m_good_proton_low
isisU32_t m_period_output_delay
isisU32_t * m_goodproton1
#define LOGSTR_INFORMATION(__arg)
isisU32_t m_external_veto0_frames
isisU32_t m_external_veto2_frames
EnvPeriodPolicy::ppp_memory_t * m_goodproton0
isisU32_t m_raw_proton_low
isisU32_t m_period_sequence_counter
virtual ~SIMEnvPeriodCard()
isisU32_t m_ext_period_overflow_veto_counter
void setLoggerName(const std::string &logger_name)
isisU32_t m_chopper_window_delay
isisU32_t m_external_veto1_frames
virtual void printStatus(std::ostream &os)
EnvPeriodPolicy::ppp_memory_t * m_rawproton0
isisU32_t m_ts2_pulse_veto_frames
virtual void updateCardAfterWrite(DAEstatus &status)
isisU32_t m_period_control
isisU32_t m_period_increment_total
isisU32_t m_external_veto3_frames
isisU32_t m_50hz_veto_frames
isisU32_t m_chopper_window_width
isisU32_t m_good_proton_high
isisU32_t m_ms_veto_frames