View::View(QGraphicsScene *scene) : QGraphicsView(scene), m_timer(this) ,m_delay(30){ qDebug()<<"in View now"; QPixmap bgPix(":/images/koskipuisto_pieni.jpg"); m_pix = bgPix; setupWindow(); int h = height(); int y = qAbs(m_imageHeight-h)/2; setSceneRect(0, y, width(), h); m_sensors.append(InputController::QACCELEROMETER); m_sensors.append(InputController::QORIENTATIONSENSOR); m_sensors.append(InputController::QMAGNETOMETER); m_sensors.append(InputController::QROTATIONSENSOR); m_sensors.append(InputController::QTAPSENSOR); m_sensors.append(InputController::QCOMPASS); m_sensors.append(InputController::QKEYS); m_menu = new QMenu(this); createActions(); handleAction(NULL,InputController::QACCELEROMETER); m_timer.setSingleShot(false); m_timer.start(m_delay); connect(&m_timer, SIGNAL(timeout()), this, SLOT(update())); connect(this,SIGNAL(sceneRectChanged(QRectF)), this, SLOT(checkSensors(QRectF))); }
void MonitorProcessor::updateVariables() { hysteresis_flag = (hysteresis_CRN_steps > MAX_CLOSE_RANGE_HYSTERESIS); cda.lockArea(MONITOR_AREA); pCDAMonitor->monitor_hysteresis = hysteresis_flag; cda.unlockArea(MONITOR_AREA); collision_flag = checkSensors(); // flag_fn = checkFlagFN(); // printf("Variable:\nhysteresis=%d\ncollision=%d\nflag_fn =%d,hysteresis_CRN_steps=%d\n", // hysteresis_flag, collision_flag, flag_fn, hysteresis_CRN_steps); }
int MainWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QMainWindow::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: buildIFace(); break; case 1: onLineReceived((*reinterpret_cast< QString(*)>(_a[1]))); break; case 2: checkRelays(); break; case 3: checkSensors(); break; case 4: checkHiRes(); break; default: ; } _id -= 5; } return _id; }
void DirectionHandler::check(uint64_t now) { checkSensors(now); checkDirectionTimeout(now); checkFutureDirectionTimeout(now); checkCurrentDirectionTimeout(now); }
int main(void) { fprintf(stderr, "Beginning Structure Test\n"); //make stdin non blocking int flags = fcntl(fileno(stdin), F_GETFL, 0); flags |= O_NONBLOCK; flags = fcntl(fileno(stdin), F_SETFL, flags); char userInput; // setPriority(); fprintf(stderr, "Connecting to sensors.\n"); startSensors(); printf("Here 3"); //start data collection and print threads, initialize necessary mutex's startThreads(); fprintf(stderr, "Collecting data.\n"); data.outFile = fopen("/home/pi/Desktop/ArmTrack/ArmTrackData.bin", "wb"); data.errors = 0; data.reads = 0; struct timeval last; struct timeval curr; struct timeval temp; gettimeofday(&curr, NULL); //update current time while(read(fileno(stdin), &userInput, 1) < 0) { last.tv_sec = curr.tv_sec; last.tv_usec = curr.tv_usec; //update last time gettimeofday(&curr, NULL); //update current time data.time += (curr.tv_sec - last.tv_sec) + (curr.tv_usec - last.tv_usec) * .000001; //increment by difference between last and current time getData(); //signal print thread while (data.controlValues[4] != 2) {}; pthread_mutex_lock(&threadLocks[4]); data.controlValues[4] = 1; pthread_cond_signal(&threadSignals[4]); pthread_mutex_unlock(&threadLocks[4]); checkSensors(); //wait for 25ms cycle length if (data.EMG.id == -1) { do { gettimeofday(&temp, NULL); } while ( (temp.tv_sec - curr.tv_sec) + (temp.tv_usec - curr.tv_usec) * .000001 < .024993); } if (data.time > 13) { endSession(); return 1; } } endSession(); return 1; }
void relayPir::setPirFlag(bool pirFlag) { m_pirOnFlag = pirFlag; checkSensors(); }
void relayPir::setLightTrigger(int light) { m_lightTrigger = light; checkSensors(); }
void Vehicle::loop() { // TODO: check this loop for compatibility or suitability with 1 kHz wifi->loop(); // ESP8266Wifi housekeeping // Check for MQTT Messages while(wifi->mqtt->messagesWaiting()) { MqttMessage *msg = wifi->mqtt->nextMessage(); if (msg->topic == "vccs/blazer/command/setAuxMode") { Serial.print("setAuxMode = "); Serial.println(msg->payload); if (msg->payload.equalsIgnoreCase("off")) auxPowerMode = AUX_OFF; if (msg->payload.equalsIgnoreCase("on")) auxPowerMode = AUX_ON; if (msg->payload.equalsIgnoreCase("auto")) auxPowerMode = AUX_AUTO; } delete msg; } // perform sensor checks per 10 ms (100 Hz) // lastSensorCheck is set to 0 in constructor if ((millis() - lastSensorCheck) > 10) { checkSensors(); lastSensorCheck = millis(); } // A report is deemed due. This is set in a Ticker // timer callback if (reportDue) { reportDue = false; // Construct and send report only if we have both a wifi connection // and an MQTT connection if ((WiFi.status() == WL_CONNECTED) && wifi->mqtt->connected()) { String topic; String payload; // IO Status // payload = "{ "; // for ( int i = 0; i < NUM_IO; i++ ) { // payload += String(i); // payload += " : "; // if (io[i].logic_state) payload += "1"; // else payload += "0"; // if (i < (NUM_IO - 1)) payload += " , "; // } // payload += " }"; // wifi->mqtt->publish(String("vehicles/" + String(config->vehicleNameShort) + "/io").c_str(), payload.c_str()); // Voltage, Supply (usually battery) payload = String(voltageSupply, 1); payload.toCharArray(buff, 10); topic = "vehicles/"; topic += String(config->vehicleNameShort); topic += "/voltage"; wifi->mqtt->publish(topic.c_str(), buff); // Temperature, Onboard // payload = String(sensors->getTempCByIndex(0), 1); // payload.toCharArray(buff, 10); // wifi->mqttc->pubsubc->publish("vehicles/blazer/temperature", buff); // Acc Input Status if (io[MCP_IN_ACC].enabled) { topic = "vehicles/"; topic += String(config->vehicleNameShort); topic += "/input-acc/status"; if (io[MCP_IN_ACC].logic_state) wifi->mqtt->publish(topic.c_str(), "on"); else wifi->mqtt->publish(topic.c_str(), "off"); } // Power Status, AUX if (statusOutputPowerAux) { topic = "vehicles/"; topic += String(config->vehicleNameShort); topic += "/input-acc/status"; wifi->mqtt->publish("vehicles/blazer/aux-power/status", "on"); // Power Status, AUX - Time Remaining payload = String(powerAuxTimeUntilOffSecs); payload.toCharArray(buff, 10); wifi->mqtt->publish("vehicles/blazer/aux-power/time-remaining", buff); } else wifi->mqtt->publish("vehicles/blazer/aux-power/status", "off"); } } }