8 #include "cplRaw/flags.hxx" 9 #include "cplRaw/dbg.hxx" 10 #include "umi/umi_task.hxx" 11 #include "umipro_tina.hxx" 12 #include "tina/tico_pub.hxx" 30 typedef Umi::Time Time;
31 typedef std::pair<Counter, Timer> Edge;
32 typedef std::pair<Timer, Timer> Pulse;
55 int timeout(Timer tmCur,
bool fReset);
57 const TiCore *ptc()
const {
return _ptc; }
65 unsigned cBlock()
const {
return _cBlock; }
66 int cFifo()
const {
return _cFifo; }
67 int cCapt()
const {
return _cFifo; }
68 Umi::Time tiTmo() {
return _tiTmo; }
72 bool fEdgeRise(
int i)
const {
return i; }
73 bool fModeFilt(
int i)
const {
return 0; }
75 virtual void sample( std::streambuf *psb,
int iFifo ) = 0;
76 virtual void init(
const TiCore *ptc );
77 virtual bool isDone()
const =0;
78 virtual unsigned cSamp()
const =0;
80 TinaMode(
int cFifo,
unsigned cBlock,
const Umi::Time &tiTmo);
95 std::deque<Timer> _dqTimes;
98 void init(
const TiCore *ptc );
101 void sample( std::streambuf *psb,
int iFifo );
107 bool isDone()
const {
return cBlock() && _dqTimes.size() > cBlock(); }
112 unsigned cMeas()
const {
return _dqTimes.size() > 1 ? _dqTimes.size() -1 : 0; }
113 unsigned cSamp()
const {
return cMeas() ; }
137 ModeAvg(
unsigned cAverage,
unsigned cBlock=1,
const Umi::Time &tiTmo=Umi::Time(1));
148 typedef std::deque<Timer> Segment;
149 std::deque<Segment> _mpdqSeg[2];
153 std::deque<Timer>& dqTimes(
int i) {
return _mpdqSeg[i].back() ; }
154 const std::deque<Timer>& dqTimes(
int i)
const {
return _mpdqSeg[i].back(); }
157 const unsigned _cExtraLE;
161 void sample( std::streambuf *psb,
int iFifo );
162 void init(
const TiCore *ptc );
166 unsigned sizeLE()
const {
return dqTimes(LE).size()<_cExtraLE ? 0:dqTimes(LE).size()-_cExtraLE; }
167 unsigned sizeTE()
const {
return dqTimes(TE).size(); }
169 unsigned cSamp()
const {
return std::min(sizeLE(), sizeTE()); }
170 bool isDone()
const {
return cBlock() && cSamp() >= cBlock(); }
173 ModeDual(
unsigned cSampRq,
const Umi::Time &tiTmo,
unsigned cExtraLE):
TinaMode(2, cSampRq, tiTmo),_cExtraLE(cExtraLE) {
174 _mpdqSeg[LE].push_back(Segment());
175 _mpdqSeg[TE].push_back(Segment());
192 double rdPulseWidth();
197 ModePulseWidth(
int eMode=
'H',
unsigned cSampRq=1,
const Umi::Time &tiTmo=Umi::Time(1));
208 std::pair<double, double> _pardPulse;
211 std::pair<double, double> pardPulse();
212 double rdFirst()
const {
return _pardPulse.first; }
213 double rdSecond()
const {
return _pardPulse.second; }
217 ModePulse(
int eMode=
'H',
unsigned cSampRq=1,
const Umi::Time &tiTmo=Umi::Time(1));
234 void sample( std::streambuf *psb,
int iFifo );
235 void init(
const TiCore *ptc );
237 std::deque<Counter> _dqCounts;
240 bool isDone()
const {
return cBlock() && _dqCounts.size() >= cBlock(); }
241 unsigned cSamp()
const {
return _dqCounts.size(); }
242 Counter ctCurrent() {
return begin()->first; }
246 int setEdge(
int eMode) {
return (eMode ==
'R' || eMode ==
'F') ? _eMode=eMode, 0 : -1 ; }
247 ModeTotalCount(
int eMode=
'R',
unsigned cSampRq=1,
const Umi::Time &tiTmo=Umi::Time(1));
257 Time tiCurrent() {
return *begin(); }
270 void sample(
const char mpch[6] ) ;
273 Failable &setTimeout(
const Time &ti) ;
283 Pulse puCurrent() {
return *begin(); }
303 bool fChip()
const {
return _fChip; }
304 PulseLine(
const Time &ti,
bool f):Time(ti), _fChip(f) { }
310 virtual int cPulse( ) {
return size(); }
311 virtual void pulse(
char mpch[6],
const TiCore *ptc );
315 extern Time ti(
double rd);
321 void init(
double rdWidthLow,
double rdWidthHigh) {
322 push_front(
PulseLine(ti(rdWidthLow), 0));
323 push_front(
PulseLine(ti(rdWidthHigh), 1));
326 PumoFreq(
double rdFreq,
double rdDuty=0.5) {
327 if (rdDuty > 1.0) rdDuty=1.0;
328 if (rdDuty < 0.0) rdDuty=0.0;
329 init(rdDuty/rdFreq,(1.0-rdDuty)/rdFreq);
346 int cnServer()
const {
return _cnServer; }
349 int func(
int eState ) {
352 return setup(1, fCanput(cnServer()));
357 while(_ppm->cPulse()) {
359 _ppm->pulse(mpch, _ptc);
360 for (
unsigned i=0; i < 6; i++) {
361 assert(pmu(cnServer())->pup()->canput());
362 pmu(cnServer())->pup()->sputc(mpch[i]);
365 return setup(2, fCanget(cnServer()), fSendup(cnServer()));
369 TinaResp* ptr=pTinaResp(pmd(cnServer())->puc());
372 return setup(-1, 0, fReleasedown(cnServer()));
387 Umi::ChanUser *_pucIo;
393 void done(Umi::Task *pta) {
401 void run(Umi::TaskFunc::Func *ptf) {
423 int callPulseConfig(
PumoFreq *ptm) {
430 TinaPlex(Umi::Channel *puc, Umi::ChanUser *pucIo):Umi::TaskPlex(puc),
bool isGood() const
fine
Definition: failable.hxx:40
Pulse Width.
Definition: tina.hxx:189
Failable & clear()
user clear of failed/bad state
Definition: failable.hxx:87
Edge counts sampled on interval or external signal.
Definition: tina.hxx:229
Pulse Generator Mode.
Definition: tina.hxx:300
bool isDone() const
true when the requested count of measurements (defined by the cBlock constructor argument) is availab...
Definition: tina.hxx:107
Tina Protocol Plexer.
Definition: tina.hxx:386
Definition: umipro_tina.hxx:172
Frequency/Period Average measurement mode.
Definition: tina.hxx:88
namespace for the ines Timing Analyzer (Tina) interface
Definition: protocols.cxx:7
Delay A to B channel.
Definition: tina.hxx:183
base class for something that does have a failed/good state.
Definition: failable.hxx:13
unsigned cMeas() const
current count of measurements available for read via rdFreq(), rdPeriod()
Definition: tina.hxx:112
Definition: umipro_tina.hxx:73
Definition: tinacp.cxx:82
Definition: umipro_tina.hxx:19
Timing Analyzer Mode.
Definition: tina.hxx:38
Pulse Width REMIND: implement sampled mode (one capt per sample clock) REMIND: implement pulse mode (...
Definition: tina.hxx:206