26 #include <epicsTime.h>
27 #include <epicsThread.h>
28 #include <epicsMessageQueue.h>
30 #include <epicsMutex.h>
32 #include "drvemInput.h"
33 #include "drvemOutput.h"
34 #include "drvemPrescaler.h"
35 #include "drvemPulser.h"
37 #include "drvemTSBuffer.h"
38 #include "delayModule.h"
39 #include "drvemRxBuf.h"
40 #include "mrmevrseq.h"
44 #include "mrmtimesrc.h"
45 #include "mrmDataBufTx.h"
47 #include "configurationInfo.h"
63 typedef std::set<EVRMRMTSBuffer*> tbufs_t;
68 typedef std::list<std::pair<EVR::eventCallback,void*> > notifiees_t;
69 notifiees_t notifiees;
79 eventCode():owner(0), interested(0), last_sec(0)
80 ,last_evt(0), waitingfor(0), again(false)
96 public TimeStampSource
111 size_t nOFP, nOFPUV, nORB, nOBack;
115 MRMCML::outkind kind;
120 EVRMRM(
const std::string& n, bus_configuration& busConfig,
122 volatile unsigned char*,epicsUInt32);
129 virtual void lock() const OVERRIDE FINAL {evrLock.lock();}
130 virtual void unlock() const OVERRIDE FINAL {evrLock.unlock();};
132 virtual std::string model() const OVERRIDE FINAL;
133 epicsUInt32 fpgaFirmware();
134 formFactor getFormFactor();
135 std::
string formFactorStr();
136 virtual MRFVersion version() const OVERRIDE FINAL;
139 virtual
bool enabled() const OVERRIDE FINAL;
140 virtual
void enable(
bool v) OVERRIDE FINAL;
142 virtual
bool mappedOutputState() const OVERRIDE FINAL;
146 virtual
bool specialMapped(epicsUInt32 code, epicsUInt32 func) const OVERRIDE FINAL;
147 virtual
void specialSetMap(epicsUInt32 code, epicsUInt32 func,
bool) OVERRIDE FINAL;
149 virtual
double clock() const OVERRIDE FINAL
150 {SCOPED_LOCK(evrLock);
return eventClock;}
151 virtual void clockSet(
double) OVERRIDE FINAL;
153 epicsUInt16 clockMode()
const;
154 void clockModeSet(epicsUInt16 mode);
156 virtual bool pllLocked() const OVERRIDE FINAL;
158 virtual
void setPLLBandwidth(epicsUInt16 pllBandwidth);
159 virtual epicsUInt16 getPLLBandwidth() const;
161 virtual epicsUInt32 irqCount() const OVERRIDE FINAL {
return count_hardware_irq;}
163 virtual bool linkStatus() const OVERRIDE FINAL;
164 virtual IOSCANPVT linkChanged() const OVERRIDE FINAL{
return IRQrxError;}
165 virtual epicsUInt32 recvErrorCount() const OVERRIDE FINAL{
return count_recv_error;}
167 virtual epicsUInt32 uSecDiv() const OVERRIDE FINAL;
170 virtual
bool extInhib() const OVERRIDE FINAL;
171 virtual
void setExtInhib(
bool) OVERRIDE FINAL;
173 virtual epicsUInt32 tsDiv() const OVERRIDE FINAL
174 {SCOPED_LOCK(evrLock);
return shadowCounterPS;}
176 virtual void setSourceTS(TSSource) OVERRIDE FINAL;
177 virtual TSSource SourceTS() const OVERRIDE FINAL
178 {SCOPED_LOCK(evrLock);
return shadowSourceTS;}
179 virtual double clockTS() const OVERRIDE FINAL;
180 virtual
void clockTSSet(
double) OVERRIDE FINAL;
181 virtual
bool interestedInEvent(epicsUInt32 event,
bool set) OVERRIDE FINAL;
183 virtual
bool TimeStampValid() const OVERRIDE FINAL;
184 virtual IOSCANPVT TimeStampValidEvent() const OVERRIDE FINAL {
return timestampValidChange;}
186 virtual bool getTimeStamp(epicsTimeStamp *ts,epicsUInt32 event) OVERRIDE FINAL;
187 virtual bool getTicks(epicsUInt32 *tks) OVERRIDE FINAL;
188 virtual IOSCANPVT eventOccurred(epicsUInt32 event)
const OVERRIDE FINAL;
189 virtual void eventNotifyAdd(epicsUInt32, eventCallback,
void*) OVERRIDE FINAL;
190 virtual void eventNotifyDel(epicsUInt32, eventCallback,
void*) OVERRIDE FINAL;
192 bool convertTS(epicsTimeStamp* ts);
194 virtual epicsUInt16 dbus() const OVERRIDE FINAL;
196 virtual epicsUInt32 heartbeatTIMOCount() const OVERRIDE FINAL {
return count_heartbeat;}
197 virtual IOSCANPVT heartbeatTIMOOccured() const OVERRIDE FINAL {
return IRQheartbeat;}
199 virtual epicsUInt32 FIFOFullCount() const OVERRIDE FINAL
200 {SCOPED_LOCK(evrLock);
return count_FIFO_overflow;}
201 virtual epicsUInt32 FIFOOverRate() const OVERRIDE FINAL
202 {SCOPED_LOCK(evrLock);
return count_FIFO_sw_overrate;}
203 virtual epicsUInt32 FIFOEvtCount() const OVERRIDE FINAL {
return count_fifo_events;}
204 virtual epicsUInt32 FIFOLoopCount() const OVERRIDE FINAL {
return count_fifo_loops;}
206 virtual epicsUTag getUtag(
const epicsUInt32 event)
const OVERRIDE FINAL;
207 virtual void setUtag(epicsUTag tag,
const epicsUInt32 event) OVERRIDE FINAL;
209 void enableIRQ(
void);
211 bool dcEnabled()
const;
212 void dcEnable(
bool v);
213 double dcTarget()
const;
214 void dcTargetSet(
double);
218 double dcInternal()
const;
219 epicsUInt32 dcStatusRaw()
const;
220 epicsUInt32 topId()
const;
222 bool psPolarity()
const;
223 void psPolaritySet(
bool v);
225 epicsUInt32 dummy()
const {
return 0; }
226 void setEvtCode(epicsUInt32 code) OVERRIDE FINAL;
228 epicsUInt32 timeSrc()
const;
229 void setTimeSrc(epicsUInt32 mode);
231 static void isr(
EVRMRM *evr,
bool pci);
232 static void isr_pci(
void*);
233 static void isr_vme(
void*);
234 static void isr_poll(
void*);
235 #if defined(__linux__) || defined(_WIN32)
236 const void *isrLinuxPvt;
239 const Config *
const conf;
240 volatile unsigned char *
const base;
244 mrf::auto_ptr<SFP> sfp;
248 volatile epicsUInt32 count_recv_error;
249 volatile epicsUInt32 count_hardware_irq;
250 volatile epicsUInt32 count_heartbeat;
251 volatile epicsUInt32 count_fifo_events;
252 volatile epicsUInt32 count_fifo_loops;
254 epicsUInt32 shadowIRQEna;
257 epicsUInt32 count_FIFO_overflow;
260 IOSCANPVT IRQmappedEvent;
261 IOSCANPVT IRQheartbeat;
262 IOSCANPVT IRQrxError;
263 IOSCANPVT IRQfifofull;
266 IOSCANPVT timestampValidChange;
270 typedef std::vector<MRMInput*> inputs_t;
273 typedef std::map<std::pair<OutputType,epicsUInt32>,
MRMOutput*> outputs_t;
276 std::vector<DelayModule*> delays;
278 typedef std::vector<MRMPreScaler*> prescalers_t;
279 prescalers_t prescalers;
281 typedef std::vector<MRMPulser*> pulsers_t;
284 typedef std::vector<MRMCML*> shortcmls_t;
285 shortcmls_t shortcmls;
289 mrf::auto_ptr<EvrSeqManager> seq;
293 epicsThreadRunableMethod<EVRMRM, &EVRMRM::drain_fifo> drain_fifo_method;
294 epicsThread drain_fifo_task;
295 epicsMessageQueue drain_fifo_wakeup;
296 static void sentinel_done(CALLBACK*);
298 epicsUInt32 count_FIFO_sw_overrate;
300 eventCode events[256];
306 CALLBACK poll_link_cb;
307 static void poll_link(CALLBACK*);
322 TSSource shadowSourceTS;
323 epicsUInt32 shadowCounterPS;
326 epicsUInt32 timestampValid;
327 epicsUInt32 lastInvalidTimestamp;
328 epicsUInt32 lastValidTimestamp;
329 static void seconds_tick(
void*, epicsUInt32);
333 epicsUInt32 _mapped[256];
335 void _map(epicsUInt8 evt, epicsUInt8 func) { _mapped[evt] |= 1<<(func); }
336 void _unmap(epicsUInt8 evt, epicsUInt8 func) { _mapped[evt] &= ~( 1<<(func) );}
337 bool _ismap(epicsUInt8 evt, epicsUInt8 func)
const {
return (_mapped[evt] & 1<<(func)) != 0; }
339 friend struct EVRMRMTSBuffer;
Modular Register Map Event Receivers.
Definition: drvem.h:97
epicsMutex evrLock
Guards access to instance All callers must take this lock before any operations on this object.
Definition: drvem.h:104
Definition: drvemOutput.h:27
User implementation hook.
Definition: object.h:460
Definition: mrmDataBufTx.h:20