Пример #1
0
QWidget* GUI::setupSensors() {
    QWidget* sensorList = new QWidget;
    QVBoxLayout* sensorListLayout = new QVBoxLayout;
    sensorList->setLayout(sensorListLayout);
    sensorListLayout->addWidget(new QLabel("Sensors"));

    std::map<std::string, Sensor*> sensors = this->entityHandler->sensors;

    for(auto o : sensors) {
        Sensor* s = o.second;

        QWidget* sensorRow = new QWidget;
        QHBoxLayout* sensorRowLayout = new QHBoxLayout;
        sensorRow->setLayout(sensorRowLayout);

        /*
           std::ostringstream buff;
           buff << s->getValue();
           QLabel* sensorValueLabel = new QLabel(buff.str().c_str());

           sensorRowLayout->addWidget(sensorValueLabel);
           */
        sensorRowLayout->addWidget(new QLabel(s->getName().c_str()));

        sensorListLayout->addWidget(sensorRow);
    }

    return sensorList;

}
Пример #2
0
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
InventoryTask::InventoryTask(Seiscomp::DataModel::Inventory *inv) : _inv(inv) {
	_logHandler = NULL;

	if ( _inv == NULL ) return;

	for ( size_t i = 0; i < _inv->dataloggerCount(); ++i ) {
		Datalogger *d = _inv->datalogger(i);
		_dataloggerNames[d->name()] = d;
	}

	for ( size_t i = 0; i < _inv->sensorCount(); ++i ) {
		Sensor *s = _inv->sensor(i);
		_sensorNames[s->name()] = s;
	}

	for ( size_t i = 0; i < _inv->auxDeviceCount(); ++i ) {
		AuxDevice *d = _inv->auxDevice(i);
		_auxDeviceNames[d->name()] = d;
	}

	for ( size_t i = 0; i < _inv->responseFIRCount(); ++i ) {
		ResponseFIR *r = _inv->responseFIR(i);
		_FIRNames[r->name()] = r;
	}

	for ( size_t i = 0; i < _inv->responsePAZCount(); ++i ) {
		ResponsePAZ *r = _inv->responsePAZ(i);
		_PAZNames[r->name()] = r;
	}

	for ( size_t i = 0; i < _inv->responsePolynomialCount(); ++i ) {
		ResponsePolynomial *r = _inv->responsePolynomial(i);
		_PolyNames[r->name()] = r;
	}
}
Пример #3
0
int main(int argc, char *argv[])
{
	int RXPIN = 1;
	int TXPIN = 0;

	if(wiringPiSetup() == -1)
		return 0;

	RCSwitch *rc = new RCSwitch(RXPIN,TXPIN);

	while (1)
	{
		if (rc->OokAvailable())
		{
			char message[100];

			rc->getOokCode(message);
			printf("%s\n",message);

			Sensor *s = Sensor::getRightSensor(message);
			if (s!= NULL)
			{
				printf("Temp : %f\n",s->getTemperature());
				printf("Humidity : %f\n",s->getHumidity());
				printf("Channel : %d\n",s->getChannel());
			}
			delete s;
		}
		delay(1000);
	}
}
Пример #4
0
int main()
{
	string doorCond = "";
	int data[] = {100, 101, 105, 110, 210, 100, 102, 110, 150, 100};
	
	Sensor sensor;
	Motor motor;
	Door_latch door_latch;

	printf("Please indicate whether the door is closed or open\nby typing 'closed' or 'open' below:\n");
	cin >> doorCond;
	printf("\n");

	if(door_latch.DoorClosed(doorCond)){	//if door is closed
		sensor.ReadData(data);				//reads the data
		if(sensor.Calibrate()){				//once the calibration is successful, operate the motor
			printf("calibration successful!\n");
			motor.MoveMotor(sensor.motor_position());
		}else
			printf("calibration unsuccessful, please provide another set of data\n");
	}else									//if the door is open, reset the motor
	{
		motor.ResetMotor();
		printf("Door is open\n");
	}
	system("PAUSE");
}
Пример #5
0
int main (int argc, const char * argv[])
{
    
    Sensor capture;
    capture.init("/Users/Gaston/dev/RDC/resources/media.mov");
    
    // number of corners on the chessboard
    Size boardSize(5,4);
    
    //init the system
    Mat image;
    while(1)
    {
        
              //Resize the images to a more reasonable size before treatment
        //resize(image, image, Size(800, 800*image.size().height/image.size().width) );
        
        imshow( "Camera: ", capture.grabFrame() );                   // Show our image inside it.
        if(waitKey(30) >=0 )
        {
            break;
        }

    }

    cvDestroyWindow("Display window");
    cout << "application ended: merci au revoir" << endl;
    return 0;
    
    
}
Пример #6
0
////////////////////////////////////////////////////////////////////////////////////
///
///   \brief This method is called by the mCheckServiceTimer.  It calls the
///          CheckServiceStatus method of each Service so that they can do
///          updates regularly if needed.
///
////////////////////////////////////////////////////////////////////////////////////
void Component::CheckServiceStatusEvent(void* args)
{
    Component* component = (Component *)args;
    if(component->mInitializedFlag)
    {
        Service::Map::iterator s;
        for(s = component->mServices.begin();
            s != component->mServices.end() && component->mInitializedFlag;
            s++)
        {
            if(s->second != component->mpEventsService && 
               s->second != component->mpLivenessService &&
               s->second != component->mpDiscoveryService &&
               s->second != component->mpAccessControlService &&
               s->second != component->mpManagementService &&
               s->second != component->mpTimeService &&
               s->second != component->mpTransportService)
            {
                s->second->CheckServiceStatus((unsigned int)(Time::GetUtcTimeMs() - component->mServiceCheckTimeMs));
                Sensor* sensor = dynamic_cast<Sensor *>(s->second);
                if(sensor)
                {
                    sensor->CheckServiceSynchronization((unsigned int)(Time::GetUtcTimeMs() - component->mServiceCheckTimeMs));
                }
            }
        }
        component->mServiceCheckTimeMs = Time::GetUtcTimeMs();
    }
}
Пример #7
0
//------------------------------------------------------------------------
void Sensors::skipChge(int state)
{
    for (int i = Sensor::kSensorStart; i < Sensor::kSensorMax; i++) {
        Sensor* s = fSensors[i];
        if (s) s->skipDuplicates (state);
    }
}
Пример #8
0
boolean Sensor::run()
{
    uint8_t i;
    boolean ret;

    Sensor *pObject = NULL;

    ret = true;

    if ( !runEnable )
    {
        return false;
    }

    for ( i = 0; i < objectNum ; i++ )
    {
        //todo,  add balance
        pObject = objectList[i].pObject;
        if ( NULL != pObject )
        {
            if ( false == pObject->run())
            {
                ret = false;
            }
        }
    }

    return ret;


}
Пример #9
0
void Level::loadExit(MvUint tileX, MvUint tileY)
{
    LOGME_CALL("Level::loadExit");
    LOGME_DEBUG("Exit at %d, %d", tileX, tileY);

    auto e = mEcsContext.e();
    auto c = mEcsContext.c();
    EngineContext& ctx = mEngineContext;

    MvAnimation::Ptr aSpawn(new MvAnimation(RepeatMode::Loop));

    for (int i = 0; i < 3; ++i) {
        StaticDrawable::Ptr ptr(new StaticDrawable(ctx, Tex::Blob, BlueSpawn[i]));
        aSpawn->addDrawable(std::move(ptr));
        aSpawn->addFrame(i, sf::milliseconds(240));
    }

    Entity eSpawn = createEntity();
    CrawlComponents& cSpawn = c->attach<Transform, Renderable, Sensor>(eSpawn);

    Renderable* cRenderable = cSpawn.get<Renderable>();
    Sensor*     cSensor     = cSpawn.get<Sensor>();
    Transform*  cTransform  = cSpawn.get<Transform>();

    cRenderable->setLayer(def::layer::BackgroundNear);
    cRenderable->setDrawable(std::move(aSpawn));
    cTransform->setPosition(tileX * TW, tileY * TH);
    cSensor->setShapeCircle(2.f, sf::Vector2f(tileX * TW, tileY * TH));
    cSensor->setCollisionCategory(Collision::World);
    cSensor->setCollisionWith(Collision::Player);
    cSensor->setCategory(Category::ExitSensor);

    mEcsContext.s()->get<PhysicsSystem>()->initialize(eSpawn);
}
Пример #10
0
		bool Tracker::StartTrackChecker(int nSampleFrequence /*= 100*/)
		{
			bool bRet = false;
			MOJING_FUNC_TRACE(g_Sensorlogger);

			if (AtomicOps<int>::ExchangeAdd_NoSync(&RefCount, 1) >= 1)
			{
				MOJING_TRACE(g_Sensorlogger, "Start Tracker do not match! Start already. ");
			}
			else
			{
				Manager* pManager = Manager::GetMojingManager();
				Sensor* pSensor = pManager->GetCheckSensor();

				int nCheck = pSensor->CheckSensors();

				if (nCheck & (SENSOR_GryoTooSlow | SENSOR_NoGryo))
				{
					MOJING_ERROR(g_Sensorlogger, "GryoTooSlow | SENSOR_NoGryo");
				}

				bRet = pSensor->StartSensor(nSampleFrequence);
			}
			return bRet;
		}
Пример #11
0
//------------------------------------------------------------------------
// Q_INVOKABLE methods
//------------------------------------------------------------------------
void Sensors::activate(int index, bool state)
{
    Sensor* s = fSensors[index];
    if (s) s->activate(state);
    else if (index == Sensor::kSensorMax)
        skipChge(state);
}
Пример #12
0
std::wstring DeviceManager::getSensorValue(const std::wstring &protocol, const std::wstring &model, int id, int dataType) const {
	TelldusCore::MutexLocker sensorListLocker(&d->lock);
	Sensor *sensor = 0;
	for (std::list<Sensor *>::iterator it = d->sensorList.begin(); it != d->sensorList.end(); ++it) {
		TelldusCore::MutexLocker sensorLocker(*it);
		if (!TelldusCore::comparei((*it)->protocol(), protocol)) {
			continue;
		}
		if (!TelldusCore::comparei((*it)->model(), model)) {
			continue;
		}
		if ((*it)->id() != id) {
			continue;
		}
		sensor = *it;
		break;
	}

	if (!sensor) {
		return L"";
	}
	TelldusCore::MutexLocker sensorLocker(sensor);
	TelldusCore::Message msg;
	std::string value = sensor->value(dataType);
	if (value.length() > 0) {
		msg.addArgument(TelldusCore::charToWstring(value.c_str()));
		msg.addArgument(static_cast<int>(sensor->timestamp()));
	}
	return msg;
}
Пример #13
0
int main()
{
    Sensor* p = new Adapter( new FahrenheitSensor);
    cout << "Celsius temperature = " << p->getTemperature() << endl;
    delete p;
    return 0;
}
SensorFusion::SensorFusion()
    : mSensorDevice(SensorDevice::getInstance()),
      mEnabled(false), mGyroTime(0)
{
    sensor_t const* list;
    Sensor uncalibratedGyro;
    ssize_t count = mSensorDevice.getSensorList(&list);
    if (count > 0) {
        for (size_t i=0 ; i<size_t(count) ; i++) {
            if (list[i].type == SENSOR_TYPE_ACCELEROMETER) {
                mAcc = Sensor(list + i);
            }
            if (list[i].type == SENSOR_TYPE_MAGNETIC_FIELD) {
                mMag = Sensor(list + i);
            }
            if (list[i].type == SENSOR_TYPE_GYROSCOPE) {
                mGyro = Sensor(list + i);
            }
            if (list[i].type == SENSOR_TYPE_GYROSCOPE_UNCALIBRATED) {
                uncalibratedGyro = Sensor(list + i);
            }
        }

        // Use the uncalibrated gyroscope for sensor fusion when available
        if (uncalibratedGyro.getType() == SENSOR_TYPE_GYROSCOPE_UNCALIBRATED) {
            mGyro = uncalibratedGyro;
        }

        // 200 Hz for gyro events is a good compromise between precision
        // and power/cpu usage.
        mEstimatedGyroRate = 200;
        mTargetDelayNs = 1000000000LL/mEstimatedGyroRate;
        mFusion.init();
    }
}
Пример #15
0
void GUIServer::getAllSensors() {
	//errorcode 0
	m_UdpServer.write((uint8_t) 0);
	//num of sensors
	m_UdpServer.write((uint8_t) __aquaduino->getNrOfSensors());
	//Serial.println("NrOfSensors()");
	// Serial.println(__aquaduino->getNrOfSensors());
	//sensor information
	Sensor* sensor;
	__aquaduino->resetSensorIterator();
	while (__aquaduino->getNextSensor(&sensor) != -1) {
		m_UdpServer.write(__aquaduino->getSensorID(sensor));
		//Name:String
		m_UdpServer.write(strlen(sensor->getName()));
		m_UdpServer.write(sensor->getName());
		//Type:int
		m_UdpServer.write(sensor->getType());
		//Unit:String
		m_UdpServer.write((uint8_t) 8);
		m_UdpServer.write("TestUnit");
		//visible:Boolean
		m_UdpServer.write(true);
		//calibrationInterval(days):int
		m_UdpServer.write((uint8_t) 0);
	}
}
Пример #16
0
Файл: main.cpp Проект: Sir2B/Uni
void Display::update(Subject * o)
{
    Sensor * s = dynamic_cast< Sensor *>(o);
    if ( s )
    {
        cout << "New Temp: " << s->getReading();
    }
}
Пример #17
0
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Sensor *Check::findSensor(const string &id) const {
	for ( size_t i = 0; i < _inv->sensorCount(); ++i ) {
		Sensor *sensor = _inv->sensor(i);
		if ( sensor->publicID() == id ) return sensor;
	}

	return NULL;
}
Пример #18
0
int main() {
	float threshold = 2.5;
	unsigned int numSamples = 10000;
	Sensor * s = new Sensor(threshold);
	s->read(numSamples);
	delete s;
	return 0;
}
/*
 * Class:     com_nokia_mj_impl_sensor_SensorConnectionImpl
 * Method:    _startServer
 * Signature: (I)V
 */
JNIEXPORT void JNICALL Java_com_nokia_mj_impl_sensor_SensorConnectionImpl__1stopServer
(JNIEnv *, jobject, jint aConnectionHandle)
{
    JELOG2(ESensor);
    SensorConnection* conn = reinterpret_cast< SensorConnection* >(aConnectionHandle);
    Sensor* sensor = conn->GetSensor();
    sensor->StopServer();
}
/*
 * Class:     com_nokia_mj_impl_sensor_SensorConnectionImpl
 * Method:    _startConditionListening
 * Signature: (II)V
 */
JNIEXPORT void JNICALL Java_com_nokia_mj_impl_sensor_SensorConnectionImpl__1startConditionListening
(JNIEnv *, jobject, jint aConnectionHandle , jint aListeningType)
{
    JELOG2(ESensor);
    SensorConnection* conn = reinterpret_cast< SensorConnection* >(aConnectionHandle);
    Sensor* sensor = conn->GetSensor();
    sensor->StartConditionListening(aListeningType);
}
/*
 * Class:     com_nokia_mj_impl_sensor_SensorConnectionImpl
 * Method:    _cancelDataListening
 * Signature: (I)I
 */
JNIEXPORT jint JNICALL Java_com_nokia_mj_impl_sensor_SensorConnectionImpl__1cancelDataListening
(JNIEnv *, jobject, jint aSensorConnection)
{
    JELOG2(ESensor);
    SensorConnection* conn = reinterpret_cast< SensorConnection* >(aSensorConnection);
    Sensor* sensor = conn->GetSensor();
    return sensor->CancelDataListening();
}
Пример #22
0
void CaptureParticleProcess::bindResource(const std::string &name, int id) {
	if (name == "sensor") {
		Sensor *sensor = static_cast<Sensor *>(Scheduler::getInstance()->getResource(id));
		m_film = sensor->getFilm();
		m_accum = new ImageBlock(Bitmap::ESpectrum, m_film->getCropSize(), NULL);
		m_accum->clear();
	}
	ParticleProcess::bindResource(name, id);
}
void Wrapper::setRefreshRate(WbDeviceTag tag, int rate) {
  Device *device = DeviceManager::instance()->findDeviceFromTag(tag);
  Sensor *sensor = dynamic_cast<Sensor *>(device);
  if (sensor) {
    sensor->setLastRefreshTime(0);
    sensor->setRate(rate);
  } else
    cerr << "Wrapper::setRefreshRate: unknown device" << endl;
}
Пример #24
0
SensorReading::SensorReading(Sensor s)
{
	//copia la lettura dal sensore
	this->average = s.media();
	this->variance = s.varianza();
	this->local_feed_id = s.local_feed_id;
	this->tags = s.tags;
	this->units = s.units;
    this->timestamp = CrowdSensing::getCurrentDateUTC();
}
Пример #25
0
/**
 * Cleanup all sensors
 */
void Sensor_Cleanup()
{
	for (int i = 0; i < g_num_sensors; ++i)
	{
		Sensor * s = g_sensors+i;
		if (s->cleanup != NULL)
			s->cleanup(s->user_id);
	}
	g_num_sensors = 0;
}
/*
 * Class:     com_nokia_mj_impl_sensor_SensorConnectionImpl
 * Method:    _startServer
 * Signature: (I)V
 */
JNIEXPORT void JNICALL Java_com_nokia_mj_impl_sensor_SensorConnectionImpl__1startServer
(JNIEnv* aJniEnv, jobject, jint aConnectionHandle)
{
    JELOG2(ESensor);
    SensorConnection* conn = reinterpret_cast< SensorConnection* >(aConnectionHandle);
    Sensor* sensor = conn->GetSensor();
    // Store JNI env from this thread
    conn->SetJni(aJniEnv);
    sensor->StartServer();
}
Пример #27
0
void FlowMeter::childAdded(Component *child)
{  
  Sensor *s = 0;
  if ((s = dynamic_cast<Sensor *>(child))) {
    s->setMin(min());
    s->setMax(max());
    s->setUnit(unit());
  }
  Component::childAdded(child);
}
Пример #28
0
void GUIServer::setSensorConfig(uint8_t sensorId, uint8_t type, char* value) {
	Sensor* sensor = __aquaduino->getSensor(sensorId);
	if (type == 2) {
		sensor->setName(value);
	}
	if (type == 3) {
		//sensorUnit����not implemented yet
	}
	__aquaduino->writeConfig(sensor);
}
Пример #29
0
		int Tracker::GetMaxSensorsSampleRate()
		{
			Manager* pManager = Manager::GetMojingManager();
			if (pManager)
			{
				Sensor* pSensor = pManager->GetSensor();
				if (pSensor)
					return pSensor->GetMaxSampleRate();
			}
			return -1;
		}
Пример #30
0
void Shape::addChild(const std::string &name, ConfigurableObject *child) {
	const Class *cClass = child->getClass();
	if (cClass->derivesFrom(MTS_CLASS(BSDF))) {
		m_bsdf = static_cast<BSDF *>(child);
	} else if (cClass->derivesFrom(MTS_CLASS(Emitter))) {
		Emitter *emitter = static_cast<Emitter *>(child);
		if (m_emitter != NULL)
			Log(EError, "Tried to attach multiple emitters to a shape!");
		if (emitter) {
			if (!emitter->isOnSurface())
				Log(EError, "Tried to attach an incompatible emitter to a surface!");
			if (m_exteriorMedium)
				emitter->setMedium(m_exteriorMedium);
		}
		m_emitter = emitter;
	} else if (cClass->derivesFrom(MTS_CLASS(Sensor))) {
		Sensor *sensor = static_cast<Sensor *>(child);
		if (m_sensor != NULL)
			Log(EError, "Tried to attach multiple sensors to a shape!");
		if (sensor) {
			if (!sensor->isOnSurface())
				Log(EError, "Tried to attach an incompatible sensor to a surface!");
			if (m_exteriorMedium)
				sensor->setMedium(m_exteriorMedium);
		}
		m_sensor = sensor;
	} else if (cClass->derivesFrom(MTS_CLASS(Subsurface))) {
		Assert(m_subsurface == NULL);
		if (m_interiorMedium != NULL)
			Log(EError, "Shape \"%s\" has both an interior medium "
				"and a subsurface scattering model -- please choose one or the other!", getName().c_str());
		m_subsurface = static_cast<Subsurface *>(child);
	} else if (cClass->derivesFrom(MTS_CLASS(Medium))) {
		if (name == "interior") {
			Assert(m_interiorMedium == NULL || m_interiorMedium == child);
			if (m_subsurface != NULL)
				Log(EError, "Shape \"%s\" has both an interior medium "
					"and a subsurface scattering model -- please choose one or the other!", getName().c_str());
			m_interiorMedium = static_cast<Medium *>(child);
		} else if (name == "exterior") {
			Assert(m_exteriorMedium == NULL || m_exteriorMedium == child);
			m_exteriorMedium = static_cast<Medium *>(child);
			if (m_emitter)
				m_emitter->setMedium(m_exteriorMedium);
			if (m_sensor)
				m_sensor->setMedium(m_exteriorMedium);
		} else {
			Log(EError, "Shape: Invalid medium child (must be named "
				"'interior' or 'exterior')!");
		}
	} else {
		ConfigurableObject::addChild(name, child);
	}
}