ICP  1
vme_simulation.h
Go to the documentation of this file.
1 #ifndef VME_SIMULATION_H
2 #define VME_SIMULATION_H
3 
4 #include "isisvme.h"
5 //#include "sim_environment_card.h"
6 //#include "sim_detector_card.h"
7 //#include "sim_period_card.h"
8 
9 class DAEstatus;
10 class DAE2Policy;
11 class DAE2CardPolicy;
13 class DAE2DetCardPolicy;
14 class DAE3Policy;
15 class DAE3CardPolicy;
17 class DAE3DetCardPolicy;
18 template <class DAECardPolicy> class SIMDAE2Card;
19 template <class EnvPeriodPolicy> class SIMEnvCard;
20 template <class EnvPeriodPolicy> class SIMEnvPeriodCard;
21 template <class DetCardPolicy> class SIMDetectorCard;
22 
24 {
25 protected:
26  static std::vector<VMESimulationIface*> m_sim_vme;
27 public:
28  virtual ~VMESimulationIface() { }
29  virtual int getCardIds(std::vector<int>& card_ids) = 0;
30  virtual bool shutdownRequested() = 0;
31  virtual void simulation_routineImpl() = 0;
32 
33  virtual bool isCrateVetoing() = 0;
34  virtual bool isCrateRunning() = 0;
35  virtual int frameNumberImpl() = 0;
36 
37 // bool ECusingHardwarePeriods() { return (!(m_runControlRegister & RCPERSZEQZERO)); }
38 
39  virtual int simulateRead(TransferProps props, unsigned long address, isisU16_t* data16, long nitems, DAEstatus& status) = 0;
40  virtual int simulateRead(TransferProps props, unsigned long address, isisU32_t* data32, long nitems, DAEstatus& status) = 0;
41  virtual int simulateRead(TransferProps props, unsigned long address, uint64_t* data64, long nitems, DAEstatus& status) = 0;
42  virtual int simulateWrite(TransferProps props, unsigned long address, isisU16_t* data16, long nitems, DAEstatus& status) = 0;
43  virtual int simulateWrite(TransferProps props, unsigned long address, isisU32_t* data32, long nitems, DAEstatus& status) = 0;
44  virtual int simulateWrite(TransferProps props, unsigned long address, uint64_t* data64, long nitems, DAEstatus& status) = 0;
45  virtual int incrementDetectorCardPeriod() = 0;
46  virtual int resetDetectorCardPeriod() = 0;
47  static bool isVetoing();
48  static bool isRunning();
49  static int frameNumber();
50  static void simulation_routine(void* arg);
51 };
52 
53 template <class DAEPolicy> class VMESimulation : public VMESimulationIface
54 {
55 private:
62 
63  public:
64  std::vector<MySIMDetectorCard*> m_det_card_list;
65  std::vector<MySIMEnvPeriodCard*> m_env_card_list;
66  int getCardIds(std::vector<int>& card_ids);
67 
68  public:
69  CRITICAL_SECTION m_critical;
71 
72  public: // functions
73  VMESimulation(DAEstatus& status);
74  virtual ~VMESimulation();
75  int open(const char* device, DAEstatus& status);
76  int openBackplane(const char* device_bp, DAEstatus& status);
77  int lockDevice(int timeout, DAEstatus& status);
78  int unlockDevice(DAEstatus& status);
79  void lockInterface(int /*timeout*/, DAEstatus& /*dstatus*/) { }
80  void unlockInterface(DAEstatus& /*dstatus*/) { }
81  int readU16noRetry(unsigned long address, isisU16_t* data16, TransferProps props, DAEstatus& dstatus);
82  int readU32noRetry(unsigned long address, isisU32_t* data32, TransferProps props, DAEstatus& dstatus);
83  int readU16(unsigned long address, isisU16_t* data16, TransferProps props, DAEstatus& status);
84  int readU32(unsigned long address, isisU32_t* data32, TransferProps props, DAEstatus& status);
85  int readBlockU16(unsigned long address, isisU16_t* data16, long nitems, TransferProps props, DAEstatus& status);
86  int readBlockU32(unsigned long address, isisU32_t* data32, long nitems, TransferProps props, DAEstatus& status);
87  int writeU16(unsigned long address, isisU16_t data16, TransferProps props, DAEstatus& status);
88  int writeU32(unsigned long address, isisU32_t data32, TransferProps props, DAEstatus& status);
89  int writeBlockU16(unsigned long address, isisU16_t* data16, long nitems, TransferProps props, DAEstatus& status);
90  int writeBlockU32(unsigned long address, isisU32_t* data32, long nitems, TransferProps props, DAEstatus& status);
91  int writeBlock(unsigned long address, isisU32_t* data, long nitems, TransferProps props, DAEstatus& status);
92  int writeBlock(unsigned long address, uint64_t* data, long nitems, TransferProps props, DAEstatus& status);
93  int readBlock(unsigned long address, isisU32_t* data, long nitems, TransferProps props, DAEstatus& status);
94  int readBlock(unsigned long address, uint64_t* data, long nitems, TransferProps props, DAEstatus& status);
95  int close(DAEstatus& status);
96  int scanBus(DAEstatus& status);
97  bool resetBus(DAEstatus& status);
98  bool initOK();
100  void simulation_routineImpl();
101 
102  bool isCrateVetoing();
103  bool isCrateRunning();
104  int frameNumberImpl();
105 
106 // bool ECusingHardwarePeriods() { return (!(m_runControlRegister & RCPERSZEQZERO)); }
107 
108  public:
111  const char* device() { return "simulation"; }
112  void setTriggerFunc(trigger_func_t* func, void* arg) { m_trigger_func = func; m_trigger_func_arg = arg; }
113  int onTrigger(time_t the_secs, unsigned short the_ms, int trig_id);
114  int simulateRead(TransferProps props, unsigned long address, isisU16_t* data16, long nitems, DAEstatus& status);
115  int simulateRead(TransferProps props, unsigned long address, isisU32_t* data32, long nitems, DAEstatus& status);
116  int simulateRead(TransferProps props, unsigned long address, uint64_t* data64, long nitems, DAEstatus& status);
117  int simulateWrite(TransferProps props, unsigned long address, isisU16_t* data16, long nitems, DAEstatus& status);
118  int simulateWrite(TransferProps props, unsigned long address, isisU32_t* data32, long nitems, DAEstatus& status);
119  int simulateWrite(TransferProps props, unsigned long address, uint64_t* data64, long nitems, DAEstatus& status);
120 
121 };
122 
123 #endif /* VME_SIMULATION_H */
std::vector< MySIMEnvPeriodCard * > m_env_card_list
uint32_t TransferProps
combination of TransferProp values
Definition: isisvme.h:16
int writeBlockU16(unsigned long address, isisU16_t *data16, long nitems, TransferProps props, DAEstatus &status)
virtual ~VMESimulation()
int readU16(unsigned long address, isisU16_t *data16, TransferProps props, DAEstatus &status)
int writeU32(unsigned long address, isisU32_t data32, TransferProps props, DAEstatus &status)
int readU32noRetry(unsigned long address, isisU32_t *data32, TransferProps props, DAEstatus &dstatus)
void setTriggerFunc(trigger_func_t *func, void *arg)
int writeU16(unsigned long address, isisU16_t data16, TransferProps props, DAEstatus &status)
void * m_trigger_func_arg
unsigned long isisU32_t
Definition: isisvme_types.h:8
void unlockInterface(DAEstatus &)
virtual ~VMESimulationIface()
virtual int resetDetectorCardPeriod()=0
static int frameNumber()
trigger_func_t * m_trigger_func
int getCardIds(std::vector< int > &card_ids)
SIMDAE2Card< typename DAEPolicy::card_t > MySIMDAE2Card
virtual int simulateWrite(TransferProps props, unsigned long address, isisU16_t *data16, long nitems, DAEstatus &status)=0
int writeBlockU32(unsigned long address, isisU32_t *data32, long nitems, TransferProps props, DAEstatus &status)
virtual int getCardIds(std::vector< int > &card_ids)=0
void simulation_routineImpl()
virtual int incrementDetectorCardPeriod()=0
int lockDevice(int timeout, DAEstatus &status)
virtual bool isCrateRunning()=0
int resetDetectorCardPeriod()
virtual bool isCrateVetoing()=0
int readBlockU16(unsigned long address, isisU16_t *data16, long nitems, TransferProps props, DAEstatus &status)
VMESimulation(DAEstatus &status)
virtual int simulateRead(TransferProps props, unsigned long address, isisU16_t *data16, long nitems, DAEstatus &status)=0
virtual bool shutdownRequested()=0
static bool isRunning()
bool shutdownRequested()
unsigned short isisU16_t
Definition: isisvme_types.h:7
static void simulation_routine(void *arg)
int readU32(unsigned long address, isisU32_t *data32, TransferProps props, DAEstatus &status)
virtual int frameNumberImpl()=0
bool resetBus(DAEstatus &status)
int open(const char *device, DAEstatus &status)
SIMEnvCard< typename DAEPolicy::env_t > MySIMEnvCard
static bool isVetoing()
int writeBlock(unsigned long address, isisU32_t *data, long nitems, TransferProps props, DAEstatus &status)
SIMEnvPeriodCard< typename DAEPolicy::env_t > MySIMEnvPeriodCard
int incrementDetectorCardPeriod()
int trigger_func_t(void *arg, time_t the_secs, unsigned short the_ms, int trig_id)
Definition: isisvme.h:8
int readBlockU32(unsigned long address, isisU32_t *data32, long nitems, TransferProps props, DAEstatus &status)
std::vector< MySIMDetectorCard * > m_det_card_list
const char * device()
int unlockDevice(DAEstatus &status)
int readBlock(unsigned long address, isisU32_t *data, long nitems, TransferProps props, DAEstatus &status)
int scanBus(DAEstatus &status)
CRITICAL_SECTION m_critical
int close(DAEstatus &status)
bool m_shutdown_requested
virtual void simulation_routineImpl()=0
int simulateRead(TransferProps props, unsigned long address, isisU16_t *data16, long nitems, DAEstatus &status)
SIMDetectorCard< typename DAEPolicy::det_t > MySIMDetectorCard
int onTrigger(time_t the_secs, unsigned short the_ms, int trig_id)
void lockInterface(int, DAEstatus &)
int simulateWrite(TransferProps props, unsigned long address, isisU16_t *data16, long nitems, DAEstatus &status)
int openBackplane(const char *device_bp, DAEstatus &status)
static std::vector< VMESimulationIface * > m_sim_vme
int readU16noRetry(unsigned long address, isisU16_t *data16, TransferProps props, DAEstatus &dstatus)