本文整理汇总了C++中Sensor类的典型用法代码示例。如果您正苦于以下问题:C++ Sensor类的具体用法?C++ Sensor怎么用?C++ Sensor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Sensor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QLabel
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: _inv
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
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: main
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: main
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: main
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: CheckServiceStatusEvent
////////////////////////////////////////////////////////////////////////////////////
///
/// \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: skipChge
//------------------------------------------------------------------------
void Sensors::skipChge(int state)
{
for (int i = Sensor::kSensorStart; i < Sensor::kSensorMax; i++) {
Sensor* s = fSensors[i];
if (s) s->skipDuplicates (state);
}
}
示例8: run
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: LOGME_CALL
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: MOJING_FUNC_TRACE
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: if
//------------------------------------------------------------------------
// 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: sensorListLocker
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: main
int main()
{
Sensor* p = new Adapter( new FahrenheitSensor);
cout << "Celsius temperature = " << p->getTemperature() << endl;
delete p;
return 0;
}
示例14: mSensorDevice
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: while
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);
}
}