g.py
1.4 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import pickle
import os
import string
import logging
from config import Config
current_state: string
current_state='off'
sensorChangeFirstRun=True
Serl = None
basepath = os.path.dirname(__file__)
shelfconfigfile = basepath+"/../" + Config.STATE_PATH+'shelfconfig.pkl'
def ver():
return "1.92"
class _shelfconfig:
def __init__(self):
self.server_addr ="not_config"
self.serial_port="not_config"
self.cid="not_config"
self.addrs="not_config"
self.after_instore_close_light=False
self.after_instore_light_color='orange'
self.comport_carsh_timeout=30
self.comport_carsh_reboot=False
self.after_induction_preshow_color='white'
self.inok_blink_times=4;
self.single_side_tower=False;
def Save(self):
with open(shelfconfigfile, 'wb') as f:
pickle.dump(self, f)
shelfconfig:_shelfconfig
shelfconfig = _shelfconfig()
if os.path.exists(shelfconfigfile):
with open(shelfconfigfile, 'rb') as f:
a = pickle.load(f)
for it in a.__dict__.items():
if it[0].find('__')>=0 or it[0]=='Save':
continue
if shelfconfig.__dict__.get(it[0]) is not None:
shelfconfig.__dict__[it[0]]=a.__dict__[it[0]]
#print("shelfconfig",shelfconfig.__dict__.items())
#logging.warning("shelfconfig",shelfconfig.__dict__.items())