コード例 #1
0
ファイル: ros_main.cpp プロジェクト: ChingHengWang/Scripts
void ros_main(void* p)
{
	//xTaskCreate( Monitor, (const signed char*)"load", TSK_Monitor_STACK_SIZE, NULL, TSK_monitor_PRIO, NULL);
	xTaskCreate(TerminalTask, (const signed char*)"TerminalTask", 128, NULL, tskIDLE_PRIORITY + 2, NULL);
	enableTiming();
	// TODO: Why is this delay necessary? Put a signaling mechanism instead, if the tasks below have to wait for some initialization.
	vTaskDelay(4000);
	XMLRPCServer::start();
	//xTaskCreate(highLoadTask, (const signed char*)"HighLoadTask", 128, NULL, tskIDLE_PRIORITY + 3, NULL);

    xTaskCreate(InitNodesTask, (const signed char*)"InitNodesTask", 128, NULL, tskIDLE_PRIORITY + 2, NULL);

    vTaskDelete(NULL);
}
コード例 #2
0
void loop()
{
	if (timing) {
		timerTime += millis() - lastTime;
		lastTime = millis();
	}

	if (state == WAITING || state == TIMER_COUNTDOWN) {
		if (state == WAITING && timing) disableTiming();
		if (readRFID()) {
			//Serial.print("RFID: ");
			//Serial.println(rfidNum);

			convertRFID();
			if (serverRequest()) {
				state = SERVER_WAIT;
				enableTiming();
			}
			else state = WAITING;
		}
	}
	else if (state == SERVER_WAIT){
		//Serial.println(timerTime);
		if (timerTime < TIMEOUT) {
			if (readServerResponse()) {
				disableTiming();
				parseResponse();
				if (authorized) {
					state = TIMER_COUNTDOWN;
					turnOn();
				}
				else state = DENIED;
			}
		}
		else {
			state = WAITING;
		}
	}
	else if (state == DENIED) {
		Serial.println("DENIED");
		state = WAITING;
	}

	if (state == TIMER_COUNTDOWN && timing && currentOn()) {
		disableTiming();
	}
	else if (state == TIMER_COUNTDOWN && (!timing && !currentOn())) {
		enableTiming();
	}

	if (state == TIMER_COUNTDOWN) {
		if ((timing && (timerTime > authorizedTime)) || checkButton()) {
			state = WAITING;
			disableTiming();
			turnOff();
		}
	}

	/*if (timerTime > 0)
		Serial.println(timerTime);*/
}
コード例 #3
0
void turnOn() {
	Serial.print("Device On: ");
	Serial.println(millis());
	if (authorizedTime > 0) enableTiming();
	digitalWrite(DEVICE_PIN, HIGH);
}