28 #ifndef FAKEDIGITALDEVICE_HPP 29 #define FAKEDIGITALDEVICE_HPP 52 mchannels(channels, false)
57 if ( n < mchannels.size() )
63 if ( n < mchannels.size() )
67 virtual void setBit(
unsigned int bit,
bool value )
69 if ( bit < mchannels.size() )
70 mchannels[bit] = value;
73 virtual void setSequence(
unsigned int start_bit,
unsigned int stop_bit,
unsigned int value)
75 if ( start_bit < mchannels.size() && stop_bit < mchannels.size() )
76 for (
unsigned int i = start_bit; i <= stop_bit; ++i)
77 mchannels[i] = (value & ( 1<<( i - start_bit ) )) != 0 ;
82 if ( n < mchannels.size() )
88 virtual unsigned int checkSequence(
unsigned int start_bit,
unsigned int stop_bit )
const 90 unsigned int result = 0;
91 if ( start_bit < mchannels.size() && stop_bit < mchannels.size() )
92 for (
unsigned int i = start_bit; i <= stop_bit; ++i)
93 result += (mchannels[i] & 1)<<i;
99 return mchannels.size();
104 return mchannels.size();
107 virtual bool isOn(
unsigned int bit = 0)
const 109 if ( bit < mchannels.size() )
110 return mchannels[bit];
114 virtual bool isOff(
unsigned int bit = 0)
const 116 if ( bit < mchannels.size() )
117 return !mchannels[bit];
121 virtual bool readBit(
unsigned int bit = 0)
const 123 if ( bit < mchannels.size() )
124 return mchannels[bit];
128 virtual unsigned int readSequence(
unsigned int start_bit,
unsigned int stop_bit)
const 130 if ( start_bit < mchannels.size() && stop_bit < mchannels.size() )
131 return checkSequence(start_bit, stop_bit);
virtual unsigned int checkSequence(unsigned int start_bit, unsigned int stop_bit) const
virtual bool isOff(unsigned int bit=0) const
virtual void setBit(unsigned int bit, bool value)
virtual bool isOn(unsigned int bit=0) const
std::vector< bool > mchannels
virtual unsigned int readSequence(unsigned int start_bit, unsigned int stop_bit) const
virtual void setSequence(unsigned int start_bit, unsigned int stop_bit, unsigned int value)
virtual void switchOn(unsigned int n)
virtual void switchOff(unsigned int n)
virtual bool readBit(unsigned int bit=0) const
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
virtual bool checkBit(unsigned int n) const
FakeDigitalDevice(unsigned int channels=32)
virtual unsigned int nbOfOutputs() const
virtual unsigned int nbOfInputs() const