This repository has been archived on 2024-02-23. You can view files and clone it, but cannot push or open issues or pull requests.
memberPlumbing/doorUtil.py

26 lines
616 B
Python

#!/usr/bin/env python3
import requests
import csv
from io import StringIO
from common import *
def hexToCode(hex):
b = bin(int(hex, 16))[2:]
facility = int(b[0:8], 2)
code = int(b[9:24], 2)
return((facility, code))
def codeToHex(facility, code):
return "{:08X}".format(int(bin(facility)[2:] + "0" + bin(code)[2:] + "1", 2))
# hexToCode("01E29DA1") <-> codeToHex(241, 20176)
def forEachDoor(fxn):
for door in doors.values():
print(door.name)
fxn(door)
#forEachDoor(lambda door: door.sendCardFormat("A901146A-244", 1, 244))
#forEachDoor(lambda door: door.sendSchedules())