void Compass::init() { m_azymuth = 0; m_accuracy = 0; m_compassSource = new QCompass(this); m_compassSource->connectToBackend(); m_compassSource->start(); connect(m_compassSource,SIGNAL(readingChanged()), SLOT(updateSensor())); }
Compass::Compass(QObject *parent) : QObject(parent), m_azimuth(0), m_calibrationLevel(0) { m_compass = new QCompass (this); m_compass->connectToBackend (); m_compass->start (); connect (m_compass, SIGNAL(readingChanged()), SLOT(updateSensor())); }
Accelerometer::Accelerometer(QObject *parent) : QObject(parent), m_x(0), m_y(0), m_z(0) { m_accelerometer = new QAccelerometer (this); m_accelerometer->connectToBackend (); m_accelerometer->start (); connect (m_accelerometer, SIGNAL(readingChanged()), SLOT(updateSensor())); }
DeviceOrientation::DeviceOrientation(Cordova *cordova): CPlugin(cordova), _validData(false) { _compass.connectToBackend(); connect(&_compass, SIGNAL(readingChanged()), SLOT(updateSensor())); connect(&_compass, SIGNAL(sensorError(int)), SLOT(sensorError(int))); }
DeviceMotion::DeviceMotion(Cordova *cordova): CPlugin(cordova), _scId(0), _ecId(0) { _accelerometerSource = QSharedPointer<QAccelerometer>(new QAccelerometer()); _sensorAvaliable = _accelerometerSource->start(); connect(_accelerometerSource.data(), SIGNAL(readingChanged()), SLOT(updateSensor())); }
int Simulator::simulateSingleStep(AbstractAlgorithm* alg) { int currRow = currLocations[alg].first; int currCol = currLocations[alg].second; House& house = housePerAlg[alg]; Battery& battery = batteryPerAlg[alg]; //cout << &house << endl; updateSensor(alg); // update the sensor with the current house info Direction d = alg->step(); int r = currRow, c = currCol; if (d == Direction::North) { r--; } else if (d == Direction::South) { r++; } else if (d == Direction::East) { c++; } else if (d == Direction::West) { c--; } currLocations[alg].first = r; currLocations[alg].second = c; // will print a "animated" cleaning of the house if (DEBUG){ cout << "\033[2J\033[1;1H" << endl; HRprint(cout, house, r, c); usleep(80000); } if (house.isWall(r, c)) { //cout << "walked into wall" << endl; return ALG_BAD_MOVE; } if (house.isDock(r, c)) { //cout << "back at dock" << endl; if (house.isClean()) { return ALG_FINISHED; } battery.charge(); } else { house.clean(r, c); battery.consume(); if (battery.isDead()) { return ALG_BATTERY_DEAD; } } return ALG_CONTINUE; // continue running this algorithm }