forked from richibrics/PyMonitorMQTT
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBitOptions.py
More file actions
29 lines (25 loc) · 873 Bytes
/
BitOptions.py
File metadata and controls
29 lines (25 loc) · 873 Bytes
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
class BitOptions():
@staticmethod
def SetOptions(list_of_entries, default_starting_options=0):
options = default_starting_options
for option in list_of_entries:
options+=option
return options
@staticmethod
def AddToOptions(options, list_of_entries):
for option in list_of_entries:
options+=option
return options
@staticmethod
def GetBitList(options):
# return bit from options number
bit = "{0:b}".format(options)
return [int(char) for char in bit]
@staticmethod
def CheckOption(options, option): # Option is the bit number from left (1=bit on the right LSB)\
bit = BitOptions.GetBitList(options)
size = len(bit)
if(options <= size):
if options[size-option] == 1:
return True
return False