ICP  1
sim_environment_card.cpp
Go to the documentation of this file.
1 #include "stdafx.h"
2 
3 #include "vme_simulation.h"
4 #include "sim_environment_card.h"
5 #include "isisvme.h"
6 
7 template <class EnvPeriodPolicy>
9  SIMDAE2Card(position, vme, (1 << 30), false, Working, status)
10 {
11  setLoggerName("SIMEnvironmentCard");
12  m_type = EnvCard;
13  addMapping(ISISVME::TransferIORegisterSpace, FCOUNTR, 1, &m_raw_frames, "", true, true, NULL, 0, false, false, fault_mode);
14  addMapping(ISISVME::TransferIORegisterSpace, FCOUNTG, 1, &m_good_frames, "", true, true, NULL, 0, false, false, fault_mode);
15  addMapping(ISISVME::TransferIORegisterSpace, PCOUNTR0, 1, &m_raw_proton_low, "", true, true, NULL, 0, false, false, fault_mode);
16  addMapping(ISISVME::TransferIORegisterSpace, PCOUNTR1, 1, &m_raw_proton_high, "", true, true, NULL, 0, false, false, fault_mode);
17  addMapping(ISISVME::TransferIORegisterSpace, PCOUNTG0, 1, &m_good_proton_low, "", true, true, NULL, 0, false, false, fault_mode);
18  addMapping(ISISVME::TransferIORegisterSpace, PCOUNTG1, 1, &m_good_proton_high, "", true, true, NULL, 0, false, false, fault_mode);
19  addMapping(ISISVME::TransferIORegisterSpace, FIFOVETFRM, 1, &m_fifo_veto, "", true, true, NULL, 0, false, false, fault_mode);
20  addMapping(ISISVME::TransferIORegisterSpace, SMPVETFRM, 1, &m_smp_veto, "", true, true, NULL, 0, false, false, fault_mode);
21  addMapping(ISISVME::TransferIORegisterSpace, FC0VETFRM, 1, &m_chopper_veto, "", true, true, NULL, 0, false, false, fault_mode);
22  addMapping(ISISVME::TransferIORegisterSpace, TS2PVETFRM, 1, &m_ts2_pulse_veto, "", true, true, NULL, 0, false, false, fault_mode);
23  addMapping(ISISVME::TransferIORegisterSpace, HZ50VETFRM, 1, &m_50hz_veto, "", true, true, NULL, 0, false, false, fault_mode);
24  addMapping(ISISVME::TransferIORegisterSpace, EXT0VETFRM, 1, &m_ext_veto0, "", true, true, NULL, 0, false, false, fault_mode);
25  addMapping(ISISVME::TransferIORegisterSpace, EXT1VETFRM, 1, &m_ext_veto1, "", true, true, NULL, 0, false, false, fault_mode);
26  addMapping(ISISVME::TransferIORegisterSpace, EXT2VETFRM, 1, &m_ext_veto2, "", true, true, NULL, 0, false, false, fault_mode);
27  addMapping(ISISVME::TransferIORegisterSpace, EXT3VETFRM, 1, &m_ext_veto3, "", true, true, NULL, 0, false, false, fault_mode);
28  addMapping(ISISVME::TransferIORegisterSpace, FSDELAY, 1, &m_fs_delay, "", true, true, NULL, 0, false, false, fault_mode);
29  addMapping(ISISVME::TransferIORegisterSpace, RCONTROL, 1, &m_run_control, "", true, true, NULL, 0, false, false, fault_mode);
30  addMapping(ISISVME::TransferIORegisterSpace, RVETO, 1, &m_veto, "", true, true, NULL, 0, false, false, fault_mode);
31  addMapping(ISISVME::TransferIORegisterSpace, FC0WINDLY, 1, &m_chopper_window_delay, "", true, true, NULL, 0, false, false, fault_mode);
32  addMapping(ISISVME::TransferIORegisterSpace, FC0WINWTH, 1, &m_chopper_window_width, "", true, true, NULL, 0, false, false, fault_mode);
33 
34 
35  m_run_control = 0;
36  m_veto = 0;
38 
39  m_is_running = (m_run_control & RCSTART ? true : false);
40  m_veto_raised = false;
41 }
42 
43 template <class EnvPeriodPolicy>
45 {
46  os << "SIMEnv card at position " << m_position;
47 }
48 
49 
50 template <class EnvPeriodPolicy>
52 {
53  if (m_run_control & RCFCLEAR)
54  {
55  m_raw_frames = 0;
56  m_good_frames = 0;
57  m_fifo_veto = 0;
58  m_smp_veto = 0;
59  m_ext_veto0 = m_ext_veto1 = m_ext_veto2 = m_ext_veto3 = 0;
60  }
61  if (m_run_control & RCPCLEAR)
62  {
63  m_raw_proton_low = m_raw_proton_high = 0;
64  m_good_proton_low = m_good_proton_high = 0;
65  }
66  if (m_run_control & RCSTART)
67  {
68  m_is_running = true;
69  }
70  else
71  {
72  m_is_running = false;
73  }
74 
75 }
76 
77 // this is here just so we can set a breakpoint easily on a card read
78 template <class EnvPeriodPolicy>
80 {
81 }
82 
83 
84 template <class EnvPeriodPolicy>
86 {
87  delay = 20; // we don't want to add more than 1 frame at a time now, so no scaling to 50Hz
88  int frame_incr = delay / 20; // an isis frame is 20 milliseconds
89  int proton_incr = (int)( 180.0 * (double)delay / (1000.0 * 3600.0 * 1.738e-6) ) ; // 180uA current at 50Hz
90 // if ( (m_run_control & RCFSSEL) == RCFSTOF1P ) // running at 10Hz?
91 // {
92 // frame_incr /= 5;
93 // proton_incr /= 5;
94 // }
95  if (m_vme->isRunning())
96  {
97  increment(frame_incr, m_raw_frames);
98  increment32(proton_incr, m_raw_proton_low, m_raw_proton_high);
99  if ( !m_vme->isVetoing() )
100  {
101  increment(frame_incr, m_good_frames);
102  increment32(proton_incr, m_good_proton_low, m_good_proton_high);
103  }
104 
105  }
106 }
107 
108 template <class EnvPeriodPolicy>
110 {
111 }
112 
113 template class SIMEnvCard<DAE2EnvPeriodPolicy>;
114 template class SIMEnvCard<DAE3EnvPeriodPolicy>;
115 
virtual void updateCardAfterWrite(DAEstatus &status)
isisU32_t m_fs_delay
virtual void printStatus(std::ostream &os)
isisU32_t m_smp_veto
isisU32_t m_good_proton_high
isisU32_t m_good_proton_low
isisU32_t m_ts2_pulse_veto
isisU32_t m_raw_proton_high
SIMEnvCard(int position, VMESimulationIface *vme, FaultMode fault_mode, DAEstatus &status)
isisU32_t m_ext_veto2
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_chopper_veto
isisU32_t m_ext_veto1
isisU32_t m_chopper_window_delay
isisU32_t m_chopper_window_width
isisU32_t m_raw_frames
isisU32_t m_50hz_veto
isisU32_t m_run_control
isisU32_t m_ext_veto0
void setLoggerName(const std::string &logger_name)
Definition: IsisBase.h:17
isisU32_t m_ext_veto3
isisU32_t m_good_frames
isisU32_t m_fifo_veto
virtual void simulate(int delay)
FaultMode
Definition: sim_dae2_card.h:10
virtual void updateCardAfterRead(DAEstatus &status)
isisU32_t m_raw_proton_low