|
@@ -5,6 +5,7 @@ import config
|
5
|
5
|
import os
|
6
|
6
|
import protocol
|
7
|
7
|
import report
|
|
8
|
+import socket_protocol
|
8
|
9
|
import sys
|
9
|
10
|
import tcp_socket
|
10
|
11
|
|
|
@@ -22,16 +23,16 @@ def help_msg():
|
22
|
23
|
|
23
|
24
|
|
24
|
25
|
if __name__ == '__main__':
|
25
|
|
- report.appLoggingConfigure(os.path.dirname(__file__), config.LOGTARGET, ((config.APP_NAME, 'DEBUG'), ), fmt=config.formatter, host=config.LOGHOST, port=config.LOGPORT)
|
|
26
|
+ report.appLoggingConfigure(os.path.dirname(__file__), config.LOGTARGET, ((config.APP_NAME, config.LOGLVL), ), fmt=config.formatter, host=config.LOGHOST, port=config.LOGPORT)
|
26
|
27
|
c = tcp_socket.tcp_client_stp(config.server_ip, config.server_port)
|
27
|
28
|
prot = protocol.my_client_protocol(c, secret=config.secret, channel_name='leyk')
|
28
|
29
|
target_dict = {
|
29
|
|
- 'bakehouse': [prot.DID_BAKE_HOUSE, ],
|
30
|
|
- 'bakery': [prot.DID_BAKERY, ],
|
31
|
|
- 'mill': [prot.DID_MILL, ],
|
32
|
|
- 'ploenlein': [prot.DID_PLOENLEIN, ],
|
33
|
|
- 'reesehouse': [prot.DID_REESE_HOUSE, ],
|
34
|
|
- 'all': [prot.DID_BAKE_HOUSE, prot.DID_BAKERY, prot.DID_MILL, prot.DID_PLOENLEIN, prot.DID_REESE_HOUSE]
|
|
30
|
+ 'bakehouse': [protocol.DID_BAKE_HOUSE, ],
|
|
31
|
+ 'bakery': [protocol.DID_BAKERY, ],
|
|
32
|
+ 'mill': [protocol.DID_MILL, ],
|
|
33
|
+ 'ploenlein': [protocol.DID_PLOENLEIN, ],
|
|
34
|
+ 'reesehouse': [protocol.DID_REESE_HOUSE, ],
|
|
35
|
+ 'all': [protocol.DID_BAKE_HOUSE, protocol.DID_BAKERY, protocol.DID_MILL, protocol.DID_PLOENLEIN, protocol.DID_REESE_HOUSE]
|
35
|
36
|
}
|
36
|
37
|
if prot.authentificate():
|
37
|
38
|
help_msg()
|
|
@@ -42,18 +43,18 @@ if __name__ == '__main__':
|
42
|
43
|
if cmd == 'help':
|
43
|
44
|
help_msg()
|
44
|
45
|
elif cmd in ["auto", "automatic"]:
|
45
|
|
- prot.send(prot.SID_EXECUTE_REQUEST, prot.DID_MODE, 'automatic')
|
|
46
|
+ prot.send(socket_protocol.SID_EXECUTE_REQUEST, protocol.DID_MODE, 'automatic')
|
46
|
47
|
elif cmd in ["man", "manual"]:
|
47
|
|
- prot.send(prot.SID_EXECUTE_REQUEST, prot.DID_MODE, 'manual')
|
|
48
|
+ prot.send(socket_protocol.SID_EXECUTE_REQUEST, protocol.DID_MODE, 'manual')
|
48
|
49
|
elif cmd == "mode":
|
49
|
|
- prot.send(prot.SID_READ_REQUEST, prot.DID_MODE, None)
|
|
50
|
+ prot.send(socket_protocol.SID_READ_REQUEST, protocol.DID_MODE, None)
|
50
|
51
|
elif cmd == "state":
|
51
|
|
- prot.send(prot.SID_READ_REQUEST, prot.DID_STATE, None)
|
|
52
|
+ prot.send(socket_protocol.SID_READ_REQUEST, protocol.DID_STATE, None)
|
52
|
53
|
elif cmd.startswith('get '):
|
53
|
54
|
target = target_dict.get(cmd.split(' ')[1])
|
54
|
55
|
if target is not None:
|
55
|
56
|
for t in target:
|
56
|
|
- prot.send(prot.SID_READ_REQUEST, t, None)
|
|
57
|
+ prot.send(socket_protocol.SID_READ_REQUEST, t, None)
|
57
|
58
|
elif cmd.startswith('set '):
|
58
|
59
|
target = target_dict.get(cmd.split(' ')[1])
|
59
|
60
|
try:
|
|
@@ -62,5 +63,5 @@ if __name__ == '__main__':
|
62
|
63
|
state = None
|
63
|
64
|
if target is not None and state is not None:
|
64
|
65
|
for t in target:
|
65
|
|
- prot.send(prot.SID_EXECUTE_REQUEST, t, state)
|
|
66
|
+ prot.send(socket_protocol.SID_EXECUTE_REQUEST, t, state)
|
66
|
67
|
c.close()
|