void SensorfwProximitySensor::slotDataAvailable(const Unsigned& data) { bool close = data.x()? true: false; if (close == m_exClose) return; m_reading.setClose(close); m_reading.setTimestamp(data.UnsignedData().timestamp_); newReadingAvailable(); m_exClose = close; }
void meegoals::slotDataAvailable(const Unsigned& data) { QAmbientLightReading::LightLevel level = getLightLevel(data.x()); if (level != m_reading.lightLevel()) { m_reading.setLightLevel(level); m_reading.setTimestamp(data.UnsignedData().timestamp_); newReadingAvailable(); } }
void Unsigned::Subtract(Unsigned& b) { assert(_width == b.Width()); Unsigned one_val(b.Width(),"_b1"); Unsigned tmp(b.Width()); tmp = b; tmp.Complement(); tmp.Add(one_val); this->Add(tmp); }
void Unsigned::Multiply(Unsigned& b ) { assert(this->_width == b.Width()); if(b.Width() > 64) { cerr << "Error: multiply supported for integers which are up to 64 bits wide" << endl; cerr << " will return junk " << endl; return; } this->_bit_field[0] = this->_bit_field[0] * b._bit_field[0]; }
rtlValue* Perform_Unary_Operation(rtlOperation op, rtlValue* v) { if((op == __NOT) && (v->Is("rtlUnsignedValue"))) { rtlUnsignedValue* uv = (rtlUnsignedValue*)v; Unsigned* nv = new Unsigned(*((Unsigned*)(uv->Get_Value()))); nv->Complement(); rtlValue* ret_val = new rtlUnsignedValue(v->Get_Type(), nv); return(ret_val); } else { return(NULL); } }
void Unsigned::Concatenate(Unsigned& b) { Unsigned tmp(_width + b._width); for(int idx = 0; idx < b.Width(); idx++) { tmp.Set_Bit(idx, (b.Get_Bit(idx) ? true : false)); } for(int idx = 0; idx < this->_width; idx++) { tmp.Set_Bit(idx + b.Width(), (this->Get_Bit(idx) ? true : false)); } this->Swap(tmp); }
void Unsigned::Add(Unsigned& b) { bool carry = false; assert(this->_width == b.Width()); for(int idx = 0; idx < b.Width(); idx++) { bool abit = this->Get_Bit(idx); bool bbit = b.Get_Bit(idx); bool sum = (abit ^ bbit ^ carry); this->Set_Bit(idx,sum); carry = (abit & bbit) | ((abit | bbit) & carry); } this->Sign_Extend(); }
bool Unsigned::Greater(Unsigned& b) { bool ret_val = true; assert(this->Width() == b.Width()); for(int idx = this->Width()-1; idx >= 0; idx--) { if((!this->Get_Bit(idx) && b.Get_Bit(idx))) { ret_val = false; break; } else if(this->Get_Bit(idx) && !b.Get_Bit(idx)) break; } return(ret_val); }
// unsigned int <-> int type conversion void Unsigned::Assign(Unsigned& v) { for(int idx = 0; idx < this->Array_Size() ; idx++) this->_bit_field[idx] = 0; for(int idx = 0; idx < __MIN__(this->Array_Size(),v.Array_Size()); idx++) _bit_field[idx] = v._bit_field[idx]; }
void Unsigned::Divide(Unsigned& b) { assert(_width == b.Width()); if(_width > 64) { cerr << "Error: divide supported for integers which are up to 64 bits wide" << endl; cerr << " will return junk " << endl; return; } this->_bit_field[0] = this->_bit_field[0] / b._bit_field[0]; }
void SensorfwLightSensor::slotDataAvailable(const Unsigned& data) { m_reading.setLux(data.x()); m_reading.setTimestamp(data.UnsignedData().timestamp_); newReadingAvailable(); }
void SensorfwOrientationSensor::slotDataAvailable(const Unsigned& data) { m_reading.setOrientation(SensorfwOrientationSensor::getOrientation(data.x())); m_reading.setTimestamp(data.UnsignedData().timestamp_); newReadingAvailable(); }
bool Unsigned::Greater_Equal(Unsigned& b) { return(this->Greater(b) && !b.Greater(*this)); }
bool Unsigned::Less_Than(Unsigned& b) { return(b.Greater(*this)); }
void Unsigned::Xor(Unsigned& b) { assert(this->Width() == b.Width()); for(int idx = 0; idx < this->Array_Size(); idx++) this->_bit_field[idx] = (this->_bit_field[idx] ^ b._bit_field[idx]); }