@anonymous/

OblongDarkseagreenAnhinga

Python

No description

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import random
import time

def readSensorData():
    rdmValue = random.randint(52, 55) # generate random number (5 - 8)
    
    if (random.randint(0, 3) == 0): # simulate random fault data
        rdmValue = rdmValue - 20
        
    time.sleep(1)
        
    return rdmValue
    
    
val = 52 # val represents the sensor data

while(1):
    
    newVal = readSensorData()
    maxDiff = newVal / 10 # 10 percentage
    
    print( "Sensor data: " + str(newVal) ) 
    
    if (abs(newVal - val) > maxDiff):
        print( "   !!! Don't save that one :/" )
    
    else:
        val = newVal