forked from nebhead/PiFire
-
Notifications
You must be signed in to change notification settings - Fork 0
/
distance_prototype.py
36 lines (30 loc) · 1013 Bytes
/
distance_prototype.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
30
31
32
33
34
35
36
#!/usr/bin/env python3
# *****************************************
# PiFire Prototype Distance Interface Library
# *****************************************
#
# Description: This library supports getting the hopper level from stored value
#
# *****************************************
from common import WriteLog
import random
class HopperLevel:
def __init__(self, empty=22, full=4, test=False):
self.empty = empty # Empty is greater than distance measured for empty
self.full = full # Full is less than or equal to the minimum full distance.
self.test = test # Test mode will generate random pellet levels.
if self.empty <= self.full:
event = 'ERROR: Invalid Hopper Level Configuration Empty Level <= Full Level (forcing defaults)'
WriteLog(event)
# Set defaults that are valid
self.empty = 22
self.full = 4
self.SetLevel()
def SetLevel(self, level=100):
# Do nothing
return()
def GetLevel(self):
if(self.test):
return random.randint(10, 100)
else:
return (100)