1 #ifndef _DINO_DINO_HXX_ 2 #define _DINO_DINO_HXX_ 7 #include "umi/umi_task.hxx" 8 #include "dino/umipro_dino.hxx" 9 #include "cplRaw/sm.hxx" 21 RunIo* pur() {
return _pur; }
22 UseIo(RunIo *pur):_pur(pur) { }
27 class Chan:
public SmM {
30 ChanUser *pcu() {
return _pcu; }
31 Chan(ChanUser *pcu=0):_pcu(pcu) {}
34 std::vector<Chan> _vccn;
35 typedef std::vector<Chan>::iterator ItCn;
36 enum { sIdle, sSend, sRecv };
38 ChanUser *pucIo() {
return _vccn.at(0).pcu() ; }
41 void init(
UseIo *pui) { _pui=pui; }
42 void add(ChanUser *pucIo) {
43 _vccn.push_back(Chan(pucIo));
52 const Dino_dino_Proto theDino_dino_Proto ;
58 inline BitHandle bitHandle(
int iBits,
int iIndex,
int f) {
return ((iBits << 24) | (iIndex << 16) | f); }
59 inline int ibits(BitHandle bh) {
return bh >> 24; }
60 inline int index(BitHandle bh) {
return (bh >> 16) & 0xff; }
61 inline unsigned char flag(BitHandle bh) {
return bh & 0xff; }
67 class MultiPlex :
protected std::vector<Umi::TaskFunc> ,
public Umi::Plexer,
public Umi::TaskUser {
68 const Umi::Proto *_pup;
69 std::map<std::string, unsigned> _mpsi;
70 typedef std::map<std::string, unsigned>::iterator ItSi;
76 int findPort(std::string *psgPort,
const std::string &sgPath);
77 Umi::TaskFunc *pta(
int i) {
return &at(i); }
80 void sigDown(
int iCtx, Channel *pcn,
int hChan) { pta(hChan)->sigDown(iCtx, pcn); }
81 void sigUp(
int iCtx, Channel *pcn,
int hChan) { pta(hChan)->sigUp(iCtx, pcn); }
85 int init(
const std::string &sg, Umi::Channel *pcn);
86 MultiPlex(
const UmiProto *pup);
95 unsigned char _mpucOut[16];
96 unsigned char _mpucIn[16];
98 Bits(): _sIn(4), _sOut(4) {
99 memset(_mpucOut, 0,
sizeof(_mpucOut));
100 memset(_mpucIn, 0,
sizeof(_mpucIn));
104 std::vector<Bits> _vcbi;
105 typedef std::vector<Bits>::const_iterator IcBi;
106 friend class DinoSyncClientFunc;
109 bool getBit(BitHandle bh) {
return _vcbi[ibits(bh)]._mpucOut[index(bh)] & flag(bh); }
110 void setBit(BitHandle bh) { _vcbi[ibits(bh)]._mpucOut[index(bh)] |= flag(bh); }
111 void clrBit(BitHandle bh) { _vcbi[ibits(bh)]._mpucOut[index(bh)] &= ~flag(bh); }
112 void setBit(BitHandle bh,
bool b) {
return b ? setBit(bh) : clrBit(bh); }
114 bool isBit(BitHandle bh) {
return _vcbi[ibits(bh)]._mpucIn[index(bh)] & flag(bh); }
116 std::ostream &print(std::ostream &os);
118 int startOpen(
const std::string &sgPort);
119 BitHandle doneOpen(
int i);
123 int init(
const std::string &sg, Umi::Channel *pcn);
126 DinoPlex():MultiPlex(&theDino_dino_Proto) {
138 void done(Umi::Task *pta) ;
148 BitHandle callOpen(
const std::string &sgPort);
int BitHandle
A BitHandle is a compact (integer-type) representation of a bit at a port.
Definition: dino.hxx:57
Dino Protocol Plexer.
Definition: dino.hxx:93
Dino Protocol Plexer with blocking functions.
Definition: dino.hxx:135
namespace for the ines Digital I/O (Dino) interface
Definition: dino.hxx:50
base class for something that does have a failed/good state.
Definition: failable.hxx:13