mrfioc2  2.3.0
fct.cpp
Go to the documentation of this file.
1 /*************************************************************************\
2 * Copyright (c) 2018 Michael Davidsaver
3 * mrfioc2 is distributed subject to a Software License Agreement found
4 * in file LICENSE that is included with this distribution.
5 \*************************************************************************/
6 
7 #include <sstream>
8 
9 #include "fct.h"
10 #include "evgMrm.h"
11 #include "sfp.h"
12 
13 #define U32_Status 0
14 #define U32_Control 4
15 #define U32_UpDCValue 0x10
16 #define U32_FIFODCValue 0x14
17 #define U32_IntDCValue 0x18
18 #define U32_TOPID 0x2c
19 #define U32_PortNDCValue(N) (0x40 +(N)*4)
20 
21 FCT::FCT(evgMrm *evg, const std::string& id, volatile epicsUInt8* const base)
22  :mrf::ObjectInst<FCT>(id)
23  ,evg(evg)
24  ,base(base)
25  ,sfp(8)
26 {
27  for(size_t i=0; i<sfp.size(); i++) {
28  std::ostringstream name;
29  name<<id<<":SFP"<<(i+1); // manual numbers SFP from 1
30  sfp[i] = new SFP(name.str(), base + 0x1000 + 0x200*i);
31  }
32 }
33 
35 
36 epicsUInt16 FCT::statusRaw() const
37 {
38  epicsUInt32 cur = READ32(base, Status);
39  cur &= 0xff;
40  WRITE32(base, Control, cur); // clear VIO latches
41  return ~cur; // invert to get 1==Ok
42 }
43 
44 double FCT::dcUpstream() const
45 {
46  double period=1e3/evg->getFrequency(); // in nanoseconds
47  return double(READ32(base, UpDCValue))/65536.0*period;
48 }
49 
50 double FCT::dcFIFO() const
51 {
52  double period=1e3/evg->getFrequency(); // in nanoseconds
53  return double(READ32(base, FIFODCValue))/65536.0*period;
54 }
55 
56 double FCT::dcInternal() const
57 {
58  double period=1e3/evg->getFrequency(); // in nanoseconds
59  return double(READ32(base, IntDCValue))/65536.0*period;
60 }
61 
62 epicsUInt32 FCT::topoId() const
63 {
64  return READ32(base, TOPID);
65 }
66 
67 double FCT::dcPortN(unsigned port) const
68 {
69  double period=1e3/evg->getFrequency(); // in nanoseconds
70  return READ32(base, PortNDCValue(port))/65536.0*period;
71 }
72 
74  OBJECT_PROP1("Status", &FCT::statusRaw);
75  OBJECT_PROP1("DCUpstream", &FCT::dcUpstream);
76  OBJECT_PROP1("DCFIFO", &FCT::dcFIFO);
77  OBJECT_PROP1("DCInternal", &FCT::dcInternal);
78  OBJECT_PROP1("TopoID", &FCT::topoId);
79  OBJECT_PROP1("DCPort1", &FCT::dcPort<0>);
80  OBJECT_PROP1("DCPort2", &FCT::dcPort<1>);
81  OBJECT_PROP1("DCPort3", &FCT::dcPort<2>);
82  OBJECT_PROP1("DCPort4", &FCT::dcPort<3>);
83  OBJECT_PROP1("DCPort5", &FCT::dcPort<4>);
84  OBJECT_PROP1("DCPort6", &FCT::dcPort<5>);
85  OBJECT_PROP1("DCPort7", &FCT::dcPort<6>);
86  OBJECT_PROP1("DCPort8", &FCT::dcPort<7>);
epicsUInt16 statusRaw() const
Definition: fct.cpp:36
virtual ~FCT()
Definition: fct.cpp:34
#define READ32(base, offset)
Definition: mrfCommonIO.h:114
double dcInternal() const
Definition: fct.cpp:56
epicsFloat64 getFrequency() const
Definition: evgEvtClk.cpp:15
double dcFIFO() const
Definition: fct.cpp:50
Definition: fct.h:19
double dcUpstream() const
Definition: fct.cpp:44
#define OBJECT_BEGIN(klass)
Definition: object.h:513
double dcPortN(unsigned port) const
Definition: fct.cpp:67
#define OBJECT_END(klass)
Definition: object.h:523
const std::string & name() const
Definition: object.h:393
FCT(evgMrm *evg, const std::string &id, volatile epicsUInt8 *const base)
Definition: fct.cpp:21
Definition: sfp.h:16
Definition: flash.cpp:23
epicsUInt32 topoId() const
Definition: fct.cpp:62
#define WRITE32(base, offset, value)
Definition: mrfCommonIO.h:119
OBJECT_PROP1("Status", &FCT::statusRaw)
Definition: evgMrm.h:56