loop():: app_task and data record is every 5 sec.
This commit is contained in:
parent
e5c1cf88ee
commit
fda68cd1e9
|
@ -1,6 +1,7 @@
|
||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
import serial
|
import serial
|
||||||
import os
|
import os
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
import influxdb_client
|
import influxdb_client
|
||||||
from influxdb_client import InfluxDBClient, Point, WritePrecision
|
from influxdb_client import InfluxDBClient, Point, WritePrecision
|
||||||
|
@ -171,6 +172,9 @@ while True:
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# os.system(cmd)
|
# os.system(cmd)
|
||||||
|
now = datetime.now() # current date and time
|
||||||
|
date_time = now.strftime("%m/%d/%Y, %H:%M:%S")
|
||||||
|
print("==================== date-time:", date_time )
|
||||||
print(point)
|
print(point)
|
||||||
print(point2)
|
print(point2)
|
||||||
print(point3)
|
print(point3)
|
||||||
|
|
|
@ -63,7 +63,7 @@ STATES currentState = startup;
|
||||||
* Specify the trouble condition each input would trigger
|
* Specify the trouble condition each input would trigger
|
||||||
*
|
*
|
||||||
******/
|
******/
|
||||||
STATES alarm[16] = {
|
const STATES alarm[16] = {
|
||||||
normal, // Reset switch
|
normal, // Reset switch
|
||||||
trouble3, // Emergency source trip switch
|
trouble3, // Emergency source trip switch
|
||||||
trouble1, // Cage door contact
|
trouble1, // Cage door contact
|
||||||
|
@ -90,22 +90,22 @@ STATES alarm[16] = {
|
||||||
*****/
|
*****/
|
||||||
bool input_normal[16] = {
|
bool input_normal[16] = {
|
||||||
|
|
||||||
OPEN, // Reset switch
|
OPEN, // 0 , lvl= 0, Reset switch
|
||||||
CLOSED, // Emergency source trip switch
|
CLOSED, // 1 , lvl= 3, Emergency source trip switch
|
||||||
CLOSED, // Cage door contact
|
CLOSED, // 2 , lvl= 1, Cage door contact, level-1
|
||||||
CLOSED, // Fume hood flow switch
|
CLOSED, // 3 , lvl= 3, Fume hood flow switch, level-3
|
||||||
OPEN, // Vacuum condition - gnd
|
OPEN, // 4 , lvl= 2, Vacuum condition - gnd, level-2
|
||||||
CLOSED, // Tritium monitor
|
CLOSED, // 5 , lvl= 3, Tritium monitor
|
||||||
OPEN, // UNUSED
|
OPEN, // 6 , lvl= 0, UNUSED
|
||||||
CLOSED, // Power failure
|
CLOSED, // 7 , lvl= 3, Power failure
|
||||||
CLOSED, // Coolant flow - gnd
|
CLOSED, // 8 , lvl= 2, Coolant flow - gnd
|
||||||
OPEN, // Vacuum condition - mid
|
OPEN, // 9 , lvl= 2, Vacuum condition - mid
|
||||||
OPEN, // UNUSED
|
OPEN, // 10 , lvl= 0, UNUSED
|
||||||
CLOSED, // Coolant flow - high
|
CLOSED, // 11 , lvl= 2, Coolant flow - high
|
||||||
OPEN, // Smoke detector - high
|
OPEN, // 12 , lvl= 3, Smoke detector - high
|
||||||
OPEN, // UNUSED
|
OPEN, // 13 , lvl= 0, UNUSED
|
||||||
OPEN, // UNUSED
|
OPEN, // 14 , lvl= 0, UNUSED
|
||||||
OPEN // UNUSED
|
OPEN // 15 , lvl= 0, UNUSED
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ int lcdLooper = 0;
|
||||||
int lcdLine2 = 16;
|
int lcdLine2 = 16;
|
||||||
|
|
||||||
// Timer for Serial output
|
// Timer for Serial output
|
||||||
unsigned long previousMillis = 0;
|
//unsigned long previousMillis = 0;
|
||||||
const unsigned long interval = 5000; // 1000 milliseconds = 1 second
|
const unsigned long interval = 5000; // 1000 milliseconds = 1 second
|
||||||
|
|
||||||
/*******
|
/*******
|
||||||
|
@ -110,9 +110,8 @@ void loop() {
|
||||||
// Reset the watchdog timer
|
// Reset the watchdog timer
|
||||||
P1.petWD();
|
P1.petWD();
|
||||||
|
|
||||||
unsigned long currentMillis = millis();
|
//unsigned long currentMillis = millis();
|
||||||
|
//if (currentMillis - previousMillis >= interval) {
|
||||||
if (currentMillis - previousMillis >= interval) {
|
|
||||||
//Serial.print("server is at ");
|
//Serial.print("server is at ");
|
||||||
//Serial.println(Ethernet.localIP());
|
//Serial.println(Ethernet.localIP());
|
||||||
|
|
||||||
|
@ -138,6 +137,8 @@ void loop() {
|
||||||
}
|
}
|
||||||
Serial.println("");
|
Serial.println("");
|
||||||
|
|
||||||
previousMillis = currentMillis; // Reset the timer
|
//previousMillis = currentMillis; // Reset the timer
|
||||||
}
|
//}
|
||||||
|
|
||||||
|
delay(interval);
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ void app_Tasks(void){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Read analog values and scale to the unit ranges
|
// Read analog values and scale to the unit ranges
|
||||||
analog1 = P1.readAnalog(anin1)*10.0/8191.0; // voltage
|
analog1 = P1.readAnalog(anin1)*10.0/8191.0; // voltage
|
||||||
analog2 = P1.readAnalog(anin2)*10.0/8191.0; // voltage
|
analog2 = P1.readAnalog(anin2)*10.0/8191.0; // voltage
|
||||||
|
@ -45,23 +46,12 @@ void app_Tasks(void){
|
||||||
// If there's a new alarm or a higher priority alarm, execute the new functions
|
// If there's a new alarm or a higher priority alarm, execute the new functions
|
||||||
if (newState > currentState) {
|
if (newState > currentState) {
|
||||||
|
|
||||||
if (currentState == startup) {
|
if (currentState == startup) normal_state();
|
||||||
normal_state();
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (newState) {
|
switch (newState) {
|
||||||
|
case trouble1:trouble1_state();break;
|
||||||
case trouble1:
|
case trouble2:trouble2_state();break;
|
||||||
trouble1_state();
|
case trouble3:trouble3_state();break;
|
||||||
break;
|
|
||||||
|
|
||||||
case trouble2:
|
|
||||||
trouble2_state();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case trouble3:
|
|
||||||
trouble3_state();
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (newState == normal) {
|
} else if (newState == normal) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user