2023-11-06 09:10:46 +00:00
|
|
|
from espmega_mqtt import ESPMegaMQTT
|
|
|
|
from time import sleep
|
2023-11-06 06:53:10 +00:00
|
|
|
|
2023-11-13 12:12:30 +00:00
|
|
|
class access_control:
|
2023-11-06 09:10:46 +00:00
|
|
|
def __init__(self):
|
|
|
|
self.plc = ESPMegaMQTT()
|
2023-11-06 06:53:10 +00:00
|
|
|
pass
|
|
|
|
|
|
|
|
def light_on(self):
|
2023-11-06 09:10:46 +00:00
|
|
|
self.plc.write_pwm(0,1,4095)
|
2023-11-06 06:53:10 +00:00
|
|
|
def light_off(self):
|
2023-11-06 09:10:46 +00:00
|
|
|
self.plc.write_pwm(0,0,4095)
|
2023-11-06 06:53:10 +00:00
|
|
|
def get_door_state(self) -> bool:
|
2023-11-06 09:10:46 +00:00
|
|
|
return self.plc.read_digital(0)
|
2023-11-06 06:53:10 +00:00
|
|
|
def get_scan_state(self) -> bool:
|
2023-11-06 09:10:46 +00:00
|
|
|
return self.plc.read_digital(1)
|
2023-11-06 06:53:10 +00:00
|
|
|
def lock_door(self):
|
2023-11-06 09:10:46 +00:00
|
|
|
self.plc.write_pwm(1,1,4095)
|
2023-11-06 06:53:10 +00:00
|
|
|
def unlock_door(self):
|
2023-11-06 09:10:46 +00:00
|
|
|
self.plc.write_pwm(1,0,4095)
|