Compare commits
No commits in common. "b9033521a24953529ff1905fc918d9d73a70efc4" and "e5c1cf88ee492d5b7bb2608a38750764e6a8f467" have entirely different histories.
b9033521a2
...
e5c1cf88ee
|
@ -1,7 +1,6 @@
|
||||||
#!/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
|
||||||
|
@ -38,7 +37,7 @@ input_normal= [
|
||||||
CLOSED, #// 4 Fume hood flow switch
|
CLOSED, #// 4 Fume hood flow switch
|
||||||
OPEN, #// 5 Vacuum condition - gnd
|
OPEN, #// 5 Vacuum condition - gnd
|
||||||
CLOSED, #// 6 Tritium monitor
|
CLOSED, #// 6 Tritium monitor
|
||||||
OPEN, #// 7 Control Room Emergency Switch
|
OPEN, #// 7 UNUSED
|
||||||
CLOSED, #// 8 Power failure
|
CLOSED, #// 8 Power failure
|
||||||
CLOSED, #// 9 Coolant flow - gnd
|
CLOSED, #// 9 Coolant flow - gnd
|
||||||
OPEN, #//10 Vacuum condition - mid
|
OPEN, #//10 Vacuum condition - mid
|
||||||
|
@ -56,7 +55,7 @@ in_txt = [ "Reset Button", #1
|
||||||
"Fume Hood Flow", #4
|
"Fume Hood Flow", #4
|
||||||
"Vacuum Gauge 2", #5
|
"Vacuum Gauge 2", #5
|
||||||
"Tritium Monitor", #6
|
"Tritium Monitor", #6
|
||||||
"Emergency Switch", #7
|
"error: port map", #7
|
||||||
"Bldg Power Fail", #8
|
"Bldg Power Fail", #8
|
||||||
"Coolant Flow 2", #9
|
"Coolant Flow 2", #9
|
||||||
"Vacuum Gauge 1", #10
|
"Vacuum Gauge 1", #10
|
||||||
|
@ -75,7 +74,7 @@ in_short_txt = [
|
||||||
"FumeHoodFlow", #4
|
"FumeHoodFlow", #4
|
||||||
"VacuumGauge2", #5
|
"VacuumGauge2", #5
|
||||||
"TritiumMonitor", #6
|
"TritiumMonitor", #6
|
||||||
"EmergencySwitch", #7
|
"NotUsed", #7
|
||||||
"BldgPowerFail", #8
|
"BldgPowerFail", #8
|
||||||
"CoolantFlow2", #9
|
"CoolantFlow2", #9
|
||||||
"VacuumGauge1", #10
|
"VacuumGauge1", #10
|
||||||
|
@ -172,9 +171,6 @@ 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,14 +63,14 @@ STATES currentState = startup;
|
||||||
* Specify the trouble condition each input would trigger
|
* Specify the trouble condition each input would trigger
|
||||||
*
|
*
|
||||||
******/
|
******/
|
||||||
const STATES alarm[16] = {
|
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
|
||||||
trouble3, // Fume hood flow switch
|
trouble3, // Fume hood flow switch
|
||||||
trouble2, // Vacuum condition - gnd
|
trouble2, // Vacuum condition - gnd
|
||||||
trouble3, // Tritium monitor
|
trouble3, // Tritium monitor
|
||||||
trouble3, // Control Room Emergency Switch
|
normal, // UNUSED
|
||||||
trouble3, // Power failure
|
trouble3, // Power failure
|
||||||
trouble3, // Coolant flow - gnd
|
trouble3, // Coolant flow - gnd
|
||||||
trouble2, // Vacuum condition - mid
|
trouble2, // Vacuum condition - mid
|
||||||
|
@ -90,22 +90,22 @@ const STATES alarm[16] = {
|
||||||
*****/
|
*****/
|
||||||
bool input_normal[16] = {
|
bool input_normal[16] = {
|
||||||
|
|
||||||
OPEN, // 0 , lvl= 0, Reset switch
|
OPEN, // Reset switch
|
||||||
CLOSED, // 1 , lvl= 3, Emergency source trip switch
|
CLOSED, // Emergency source trip switch
|
||||||
CLOSED, // 2 , lvl= 1, Cage door contact, level-1
|
CLOSED, // Cage door contact
|
||||||
CLOSED, // 3 , lvl= 3, Fume hood flow switch, level-3
|
CLOSED, // Fume hood flow switch
|
||||||
OPEN, // 4 , lvl= 2, Vacuum condition - gnd, level-2
|
OPEN, // Vacuum condition - gnd
|
||||||
CLOSED, // 5 , lvl= 3, Tritium monitor
|
CLOSED, // Tritium monitor
|
||||||
CLOSED, // 6 , lvl= 3, Control Room Emergency Switch
|
OPEN, // UNUSED
|
||||||
CLOSED, // 7 , lvl= 3, Power failure
|
CLOSED, // Power failure
|
||||||
CLOSED, // 8 , lvl= 2, Coolant flow - gnd
|
CLOSED, // Coolant flow - gnd
|
||||||
OPEN, // 9 , lvl= 2, Vacuum condition - mid
|
OPEN, // Vacuum condition - mid
|
||||||
OPEN, // 10 , lvl= 0, UNUSED
|
OPEN, // UNUSED
|
||||||
CLOSED, // 11 , lvl= 2, Coolant flow - high
|
CLOSED, // Coolant flow - high
|
||||||
OPEN, // 12 , lvl= 3, Smoke detector - high
|
OPEN, // Smoke detector - high
|
||||||
OPEN, // 13 , lvl= 0, UNUSED
|
OPEN, // UNUSED
|
||||||
OPEN, // 14 , lvl= 0, UNUSED
|
OPEN, // UNUSED
|
||||||
OPEN // 15 , lvl= 0, UNUSED
|
OPEN // UNUSED
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -141,7 +141,7 @@ String in_txt[] = { "Reset Button",
|
||||||
"Fume Hood Flow",
|
"Fume Hood Flow",
|
||||||
"Vacuum Gauge 2",
|
"Vacuum Gauge 2",
|
||||||
"Tritium Monitor",
|
"Tritium Monitor",
|
||||||
"Control Room Emergency Switch",
|
"error: port map",
|
||||||
"Bldg Power Fail",
|
"Bldg Power Fail",
|
||||||
"Coolant Flow 2",
|
"Coolant Flow 2",
|
||||||
"Vacuum Gauge 1",
|
"Vacuum Gauge 1",
|
||||||
|
|
|
@ -30,8 +30,8 @@ int lcdLooper = 0;
|
||||||
int lcdLine2 = 16;
|
int lcdLine2 = 16;
|
||||||
|
|
||||||
// Timer for Serial output
|
// Timer for Serial output
|
||||||
const unsigned long interval = 100; // 1000 milliseconds = 1 second
|
unsigned long previousMillis = 0;
|
||||||
unsigned int count = 0;
|
const unsigned long interval = 5000; // 1000 milliseconds = 1 second
|
||||||
|
|
||||||
/*******
|
/*******
|
||||||
*Setup function runs once on startup
|
*Setup function runs once on startup
|
||||||
|
@ -97,11 +97,7 @@ void loop() {
|
||||||
delay(2000);
|
delay(2000);
|
||||||
if (P1.readDiscrete(in1) == CLOSED){ //Reset to normal condition
|
if (P1.readDiscrete(in1) == CLOSED){ //Reset to normal condition
|
||||||
newState = normal;
|
newState = normal;
|
||||||
} //unsigned long currentMillis = millis();
|
}
|
||||||
//if (currentMillis - previousMillis >= interval) {
|
|
||||||
//Serial.print("server is at ");
|
|
||||||
//Serial.println(Ethernet.localIP());
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check the inputs and update the state
|
// Check the inputs and update the state
|
||||||
|
@ -114,8 +110,12 @@ void loop() {
|
||||||
// Reset the watchdog timer
|
// Reset the watchdog timer
|
||||||
P1.petWD();
|
P1.petWD();
|
||||||
|
|
||||||
if( count % 50 == 0 ) {
|
unsigned long currentMillis = millis();
|
||||||
|
|
||||||
|
if (currentMillis - previousMillis >= interval) {
|
||||||
|
//Serial.print("server is at ");
|
||||||
|
//Serial.println(Ethernet.localIP());
|
||||||
|
|
||||||
Serial.print("State: ");
|
Serial.print("State: ");
|
||||||
Serial.print(currentState);
|
Serial.print(currentState);
|
||||||
Serial.print(";");
|
Serial.print(";");
|
||||||
|
@ -137,11 +137,7 @@ void loop() {
|
||||||
Serial.print(";");
|
Serial.print(";");
|
||||||
}
|
}
|
||||||
Serial.println("");
|
Serial.println("");
|
||||||
|
|
||||||
count = 0;
|
previousMillis = currentMillis; // Reset the timer
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
delay(interval);
|
|
||||||
count ++;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
#define in4 1,4 // Fume hood flow switch
|
#define in4 1,4 // Fume hood flow switch
|
||||||
#define in5 1,5 // Vacuum condition - gnd
|
#define in5 1,5 // Vacuum condition - gnd
|
||||||
#define in6 1,6 // Tritium monitor
|
#define in6 1,6 // Tritium monitor
|
||||||
#define in7 1,7 // Control Room Emergency trip
|
#define in7 1,7 // UNUSED
|
||||||
#define in8 1,8 // Power failure
|
#define in8 1,8 // Power failure
|
||||||
#define in9 1,9 // Coolant flow - gnd
|
#define in9 1,9 // Coolant flow - gnd
|
||||||
#define in10 1,10 // Vacuum condition - mid
|
#define in10 1,10 // Vacuum condition - mid
|
||||||
|
|
|
@ -29,7 +29,6 @@ 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
|
||||||
|
@ -46,12 +45,23 @@ 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) normal_state();
|
if (currentState == startup) {
|
||||||
|
normal_state();
|
||||||
|
}
|
||||||
|
|
||||||
switch (newState) {
|
switch (newState) {
|
||||||
case trouble1:trouble1_state();break;
|
|
||||||
case trouble2:trouble2_state();break;
|
case trouble1:
|
||||||
case trouble3:trouble3_state();break;
|
trouble1_state();
|
||||||
|
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