-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Switch from zope to simple callback - De-lint
- Loading branch information
Showing
4 changed files
with
115 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,36 @@ | ||
"""aqualogic command line test app.""" | ||
|
||
from core import AquaLogic, Keys, States | ||
import zope.event | ||
import socket | ||
import threading | ||
import logging | ||
import sys | ||
from core import AquaLogic, States | ||
|
||
logging.basicConfig(level=logging.INFO) | ||
PORT = 23 | ||
|
||
|
||
def data_changed(aq): | ||
print('Pool Temp: {}'.format(aq.pool_temp)) | ||
print('Air Temp: {}'.format(aq.air_temp)) | ||
print('Pump Speed: {}'.format(aq.pump_speed)) | ||
print('Pump Power: {}'.format(aq.pump_power)) | ||
print('States: {}'.format(aq.states())) | ||
if aq.get_state(States.CHECK_SYSTEM): | ||
print('Check System: {}'.format(aq.check_system_msg)) | ||
def _data_changed(panel): | ||
print('Pool Temp: {}'.format(panel.pool_temp)) | ||
print('Air Temp: {}'.format(panel.air_temp)) | ||
print('Pump Speed: {}'.format(panel.pump_speed)) | ||
print('Pump Power: {}'.format(panel.pump_power)) | ||
print('States: {}'.format(panel.states())) | ||
if panel.get_state(States.CHECK_SYSTEM): | ||
print('Check System: {}'.format(panel.check_system_msg)) | ||
|
||
|
||
PANEL = AquaLogic() | ||
print('Connecting to {}:{}...'.format(sys.argv[1], PORT)) | ||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | ||
s.connect((sys.argv[1], PORT)) | ||
reader = s.makefile(mode='rb') | ||
writer = s.makefile(mode='wb') | ||
PANEL.connect(sys.argv[1], PORT) | ||
print('Connected!') | ||
|
||
aq = AquaLogic(reader, writer) | ||
|
||
zope.event.subscribers.append(data_changed) | ||
|
||
reader_thread = threading.Thread(target=aq.process) | ||
reader_thread.start() | ||
READER_THREAD = threading.Thread(target=PANEL.process, args=[_data_changed]) | ||
READER_THREAD.start() | ||
|
||
while True: | ||
line = input() | ||
LINE = input() | ||
try: | ||
state = States[line] | ||
aq.set_state(state, not aq.get_state(state)) | ||
STATE = States[LINE] | ||
PANEL.set_state(STATE, not PANEL.get_state(STATE)) | ||
except KeyError: | ||
print('Invalid key {}'.format(line)) | ||
print('Invalid key {}'.format(LINE)) |
Oops, something went wrong.