Commit 6d35340b 刘韬

修正单面灯塔时的,B面黄灯不亮的问题

1 个父辈 1286c3b0
正在显示 50 个修改的文件 包含 47 行增加26 行删除
...@@ -265,7 +265,8 @@ def setconfig(): ...@@ -265,7 +265,8 @@ def setconfig():
data = request.get_json() data = request.get_json()
cf={} cf={}
for k,v in shelfconfig.__dict__.items(): for k,v in shelfconfig.__dict__.items():
if data.get(k): if k in data:
print(k,v,data.get(k))
setattr(shelfconfig,k,data.get(k)) setattr(shelfconfig,k,data.get(k))
cf[k]=data.get(k) cf[k]=data.get(k)
if len(cf)>0: if len(cf)>0:
...@@ -315,7 +316,7 @@ def testCidExists(): ...@@ -315,7 +316,7 @@ def testCidExists():
data = {"cid":cid} data = {"cid":cid}
try: try:
response = requests.get(testurl, params=data,timeout=2) response = requests.get(testurl, params=data,timeout=2)
if response.status_code is not 200: if response.status_code != 200:
return None return None
response=response.json() response=response.json()
except Exception as e: except Exception as e:
......
...@@ -47,6 +47,7 @@ def startpost(): ...@@ -47,6 +47,7 @@ def startpost():
is_start = True is_start = True
ser = SerialCommunication() ser = SerialCommunication()
logging.warning("启动复位参数 comport_carsh_reboot:{}".format(shelfconfig.comport_carsh_reboot)) logging.warning("启动复位参数 comport_carsh_reboot:{}".format(shelfconfig.comport_carsh_reboot))
logging.warning("shelfconfig: {}".format(shelfconfig.__dict__.items()))
if not shelfconfig.comport_carsh_reboot: if not shelfconfig.comport_carsh_reboot:
reset_tower() reset_tower()
time.sleep(1) time.sleep(1)
...@@ -322,7 +323,7 @@ def server_post(seq): ...@@ -322,7 +323,7 @@ def server_post(seq):
if os.name != 'nt': if os.name != 'nt':
t = time.gmtime(time.mktime(t)+8*60*60) t = time.gmtime(time.mktime(t)+8*60*60)
dd= 'date '+time.strftime('%m%d%H%M%Y.%S',t) dd= 'date '+time.strftime('%m%d%H%M%Y.%S',t)
#os.system(dd) os.system(dd)
logging.warning("执行时间设定:{}:{}".format(currentdate,dd)) logging.warning("执行时间设定:{}:{}".format(currentdate,dd))
# response = requests.post("http://jsonplaceholder.typicode.com/posts", data = "some dummy content") # response = requests.post("http://jsonplaceholder.typicode.com/posts", data = "some dummy content")
ele_json = response.json() ele_json = response.json()
...@@ -653,11 +654,11 @@ def show_blink(): ...@@ -653,11 +654,11 @@ def show_blink():
outlocside='a' outlocside='a'
blink_status['side'] = outlocside blink_status['side'] = outlocside
blink_status['status'] = True blink_status['status'] = True
logging.warning('locside:{},{}'.format(outlocside,locations[locnum]['addr'])) logging.warning('locside_out:{},{}'.format(outlocside,locations[locnum]['addr']))
if outlocside=='both': if outlocside=='both':
break break
end = timeit.default_timer() end = timeit.default_timer()
print("show_blink end",end,(end-start)) print("show_blink end",end,(end-start),blink_status['status'])
blink_convert(blink_leds) blink_convert(blink_leds)
update_tower(blink_status,ng_status) update_tower(blink_status,ng_status)
time.sleep(0.5) time.sleep(0.5)
...@@ -740,6 +741,7 @@ def blink_convert(blink_leds): ...@@ -740,6 +741,7 @@ def blink_convert(blink_leds):
time.sleep(0.01) time.sleep(0.01)
#ser.read_alldata() #ser.read_alldata()
print("blink_convert",timeit.default_timer(),line) print("blink_convert",timeit.default_timer(),line)
#logging.warning("blink_convert",timeit.default_timer(),line)
#time.sleep(0.005) #time.sleep(0.005)
gg.sensorChangeFirstRun=True gg.sensorChangeFirstRun=True
# return texts # return texts
...@@ -809,18 +811,22 @@ else: ...@@ -809,18 +811,22 @@ else:
RedTWLed = '1@4' RedTWLed = '1@4'
YellowTWLed = '2@5' YellowTWLed = '2@5'
GreenTWLed = '3@6' GreenTWLed = '3@6'
logging.warning("LEDTOWER {}, {}, {}".format(RedTWLed,YellowTWLed,GreenTWLed))
def update_tower(blink_status,ng_status): def update_tower(blink_status,ng_status):
global tower_state global tower_state
global ServerErrorTimes global ServerErrorTimes
#print (blinks,ngs) print ("blink_status",blink_status['status'],blink_status['side'])
thisYellowTWLed = YellowTWLed thisYellowTWLed = YellowTWLed
if blink_status['side'].lower()=='a': if blink_status['side'].lower()=='a':
thisYellowTWLed=YellowTWLed.partition('@')[0] thisYellowTWLed=YellowTWLed.partition('@')[0]
elif blink_status['side'].lower()=='b': elif blink_status['side'].lower()=='b':
thisYellowTWLed=YellowTWLed.partition('@')[2] thisYellowTWLed=YellowTWLed.partition('@')[2]
elif blink_status['side'].lower()=='both' and YellowTWLed.partition('@')[0]==YellowTWLed.partition('@')[2]:
thisYellowTWLed=YellowTWLed.partition('@')[0]
if blink_status['status']: if blink_status['status']:
for led in thisYellowTWLed.split('@'): for led in thisYellowTWLed.split('@'):
print ("tower_state",led,tower_state[led]['status'])
if tower_state[led]['status'] == 'off': if tower_state[led]['status'] == 'off':
tower_state[led]['action'] = True tower_state[led]['action'] = True
tower_state[led]['status'] = 'on' tower_state[led]['status'] = 'on'
......
import pickle import pickle
import os import os
import string import string
import logging
from config import Config from config import Config
current_state: string current_state: string
...@@ -11,7 +12,7 @@ basepath = os.path.dirname(__file__) ...@@ -11,7 +12,7 @@ basepath = os.path.dirname(__file__)
shelfconfigfile = basepath+"/../" + Config.STATE_PATH+'shelfconfig.pkl' shelfconfigfile = basepath+"/../" + Config.STATE_PATH+'shelfconfig.pkl'
def ver(): def ver():
return "1.9" return "1.92"
class _shelfconfig: class _shelfconfig:
def __init__(self): def __init__(self):
...@@ -39,6 +40,5 @@ if os.path.exists(shelfconfigfile): ...@@ -39,6 +40,5 @@ if os.path.exists(shelfconfigfile):
continue continue
if shelfconfig.__dict__.get(it[0]) is not None: if shelfconfig.__dict__.get(it[0]) is not None:
shelfconfig.__dict__[it[0]]=a.__dict__[it[0]] shelfconfig.__dict__[it[0]]=a.__dict__[it[0]]
print("shelfconfig",shelfconfig.__dict__.items()) #print("shelfconfig",shelfconfig.__dict__.items())
#logging.warning("shelfconfig",shelfconfig.__dict__.items())
\ No newline at end of file \ No newline at end of file
...@@ -18167,3 +18167,9 @@ KeyError: 'code' ...@@ -18167,3 +18167,9 @@ KeyError: 'code'
2024-04-26 09:10:29,959 - WARNING : ('---异常---:', SerialException("could not open port '1': FileNotFoundError(2, '系统找不到指定的文件。', None, 2)")) 2024-04-26 09:10:29,959 - WARNING : ('---异常---:', SerialException("could not open port '1': FileNotFoundError(2, '系统找不到指定的文件。', None, 2)"))
2024-04-26 09:10:49,427 - WARNING : config:D:\rick\python\induction_shelf\smartshelf\app/state/, ip&cid...:{'post': 'wait', 'ip': 'http://192.168.1.243/smf-core', 'cid': 'S10392'} 2024-04-26 09:10:49,427 - WARNING : config:D:\rick\python\induction_shelf\smartshelf\app/state/, ip&cid...:{'post': 'wait', 'ip': 'http://192.168.1.243/smf-core', 'cid': 'S10392'}
2024-04-26 09:10:51,072 - WARNING : ('---异常---:', SerialException("could not open port '1': FileNotFoundError(2, '系统找不到指定的文件。', None, 2)")) 2024-04-26 09:10:51,072 - WARNING : ('---异常---:', SerialException("could not open port '1': FileNotFoundError(2, '系统找不到指定的文件。', None, 2)"))
2024-06-11 15:45:56,522 - WARNING : config:D:\rick\python\induction_shelf\smartshelf\app/state/, ip&cid...:{'post': 'wait', 'ip': 'http://192.168.1.243/smf-core', 'cid': 'S10392'}
2024-06-11 16:17:49,705 - WARNING : config:D:\rick\python\induction_shelf\smartshelf\app/state/, ip&cid...:{'post': 'wait', 'ip': 'http://192.168.1.243/smf-core', 'cid': 'S10392'}
2024-06-11 17:18:26,949 - WARNING : config:D:\rick\python\induction_shelf\smartshelf\app/state/, ip&cid...:{'post': 'wait', 'ip': 'http://192.168.1.243/smf-core', 'cid': 'S10392'}
2024-06-11 17:19:13,463 - WARNING : config:D:\rick\python\induction_shelf\smartshelf\app/state/, ip&cid...:{'post': 'wait', 'ip': 'http://192.168.1.243/smf-core', 'cid': 'S10392'}
2024-07-21 21:50:35,086 - WARNING : config:D:\rick\python\induction_shelf\smartshelf\app/state/, ip&cid...:{'post': 'wait', 'ip': 'http://192.168.1.243/smf-core', 'cid': 'S10392'}
2024-07-21 21:51:23,560 - WARNING : config:D:\rick\python\induction_shelf\smartshelf\app/state/, ip&cid...:{'post': 'wait', 'ip': 'http://192.168.1.243/smf-core', 'cid': 'S10392'}
{"192.168.101.222":{"IP":"192.168.101.222","Mac":"","Host":null,"BoardType":0,"Ver":0.0,"MCAddr":null,"PingDelay":70,"shelfState":{"isupdate":false,"state":"off","msg":"未进行测试动作","ipconfig":{"post":"wait","ip":"http://192.168.101.58/smf-core","cid":"1245-02"},"version":"1.871","serial_state":"串口连接正常","ad_serial":"串口号:/dev/ttyUSBN,地址:A1@A2@A3@A4@A5@B1@B2@B3"},"memo":null},"192.168.101.221":{"IP":"192.168.101.221","Mac":"","Host":null,"BoardType":0,"Ver":0.0,"MCAddr":null,"PingDelay":71,"shelfState":{"isupdate":false,"state":"na","msg":null,"ipconfig":null,"version":null,"serial_state":"na","ad_serial":null},"memo":null},"192.168.101.111":{"IP":"192.168.101.111","Mac":"","Host":null,"BoardType":0,"Ver":0.0,"MCAddr":null,"PingDelay":34,"shelfState":{"isupdate":true,"state":"on","msg":"未进行测试动作","ipconfig":{"post":"failed","ip":"http://192.168.101.77/smf-core","cid":"01"},"version":"1.873","serial_state":"串口连接正常","ad_serial":"串口号:/dev/ttyUSB0,地址:A1@A2@A3@A4@A5@A6@A7@B1@B2@B3@B4@B5@B6@B7"},"memo":null},"192.168.101.113":{"IP":"192.168.101.113","Mac":"","Host":null,"BoardType":0,"Ver":0.0,"MCAddr":null,"PingDelay":25,"shelfState":{"isupdate":false,"state":"on","msg":"未进行测试动作","ipconfig":{"post":"failed","ip":"http://192.168.10.200/smf-core","cid":"001"},"version":"1.4","serial_state":null,"ad_serial":null},"memo":null},"192.168.101.115":{"IP":"192.168.101.115","Mac":"","Host":null,"BoardType":0,"Ver":0.0,"MCAddr":null,"PingDelay":9,"shelfState":{"isupdate":true,"state":"on","msg":"未进行测试动作","ipconfig":{"post":"failed","ip":"http://192.168.101.77/smf-core","cid":"01"},"version":"1.873","serial_state":"串口连接正常","ad_serial":"串口号:/dev/ttyUSB0,地址:A1@A2@A3@A4@A5@A6@A7@B1@B2@B3@B4@B5@B6@B7"},"memo":null},"192.168.101.116":{"IP":"192.168.101.116","Mac":"","Host":null,"BoardType":0,"Ver":0.0,"MCAddr":null,"PingDelay":72,"shelfState":{"isupdate":true,"state":"on","msg":"未进行测试动作","ipconfig":{"post":"failed","ip":"http://192.168.101.77/smf-core","cid":"01"},"version":"1.873","serial_state":"串口连接正常","ad_serial":"串口号:/dev/ttyUSB0,地址:A1@A2@A3@A4@A5@B1@B2"},"memo":null},"192.168.101.117":{"IP":"192.168.101.117","Mac":"","Host":null,"BoardType":0,"Ver":0.0,"MCAddr":null,"PingDelay":20,"shelfState":{"isupdate":false,"state":"na","msg":null,"ipconfig":null,"version":null,"serial_state":"na","ad_serial":null},"memo":null}}
\ No newline at end of file \ No newline at end of file
此文件太大,无法显示。
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<config ver="10"> <config ver="10">
<item key="ipstart" ver="10" value="192.168.101.111" /> <item key="ipstart" ver="10" value="192.168.101.132" />
<item key="ipend" ver="10" value="118" /> <item key="ipend" ver="10" value="133" />
</config> </config>
\ No newline at end of file \ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<config ver="10"> <config ver="10">
<item key="ipstart" ver="10" value="192.168.101.111" /> <item key="ipstart" ver="10" value="192.168.101.132" />
<item key="ipend" ver="10" value="118" /> <item key="ipend" ver="10" value="133" />
</config> </config>
\ No newline at end of file \ No newline at end of file
{"192.168.101.132":{"IP":"192.168.101.132","Mac":"","Host":null,"BoardType":0,"Ver":0.0,"MCAddr":null,"PingDelay":91,"shelfState":{"isupdate":true,"state":"on","msg":"未进行测试动作","ipconfig":{"post":"success","ip":"http://192.168.101.108/smf-core","cid":"SO1484"},"version":"1.92","serial_state":"串口连接正常","ad_serial":"串口号:/dev/ttyUSB0,地址:A1@A2@A3@B1@B2"},"memo":null}}
\ No newline at end of file \ No newline at end of file
...@@ -265,7 +265,8 @@ def setconfig(): ...@@ -265,7 +265,8 @@ def setconfig():
data = request.get_json() data = request.get_json()
cf={} cf={}
for k,v in shelfconfig.__dict__.items(): for k,v in shelfconfig.__dict__.items():
if data.get(k): if k in data:
print(k,v,data.get(k))
setattr(shelfconfig,k,data.get(k)) setattr(shelfconfig,k,data.get(k))
cf[k]=data.get(k) cf[k]=data.get(k)
if len(cf)>0: if len(cf)>0:
...@@ -315,7 +316,7 @@ def testCidExists(): ...@@ -315,7 +316,7 @@ def testCidExists():
data = {"cid":cid} data = {"cid":cid}
try: try:
response = requests.get(testurl, params=data,timeout=2) response = requests.get(testurl, params=data,timeout=2)
if response.status_code is not 200: if response.status_code != 200:
return None return None
response=response.json() response=response.json()
except Exception as e: except Exception as e:
......
...@@ -47,6 +47,7 @@ def startpost(): ...@@ -47,6 +47,7 @@ def startpost():
is_start = True is_start = True
ser = SerialCommunication() ser = SerialCommunication()
logging.warning("启动复位参数 comport_carsh_reboot:{}".format(shelfconfig.comport_carsh_reboot)) logging.warning("启动复位参数 comport_carsh_reboot:{}".format(shelfconfig.comport_carsh_reboot))
logging.warning("shelfconfig: {}".format(shelfconfig.__dict__.items()))
if not shelfconfig.comport_carsh_reboot: if not shelfconfig.comport_carsh_reboot:
reset_tower() reset_tower()
time.sleep(1) time.sleep(1)
...@@ -322,7 +323,7 @@ def server_post(seq): ...@@ -322,7 +323,7 @@ def server_post(seq):
if os.name != 'nt': if os.name != 'nt':
t = time.gmtime(time.mktime(t)+8*60*60) t = time.gmtime(time.mktime(t)+8*60*60)
dd= 'date '+time.strftime('%m%d%H%M%Y.%S',t) dd= 'date '+time.strftime('%m%d%H%M%Y.%S',t)
#os.system(dd) os.system(dd)
logging.warning("执行时间设定:{}:{}".format(currentdate,dd)) logging.warning("执行时间设定:{}:{}".format(currentdate,dd))
# response = requests.post("http://jsonplaceholder.typicode.com/posts", data = "some dummy content") # response = requests.post("http://jsonplaceholder.typicode.com/posts", data = "some dummy content")
ele_json = response.json() ele_json = response.json()
...@@ -653,11 +654,11 @@ def show_blink(): ...@@ -653,11 +654,11 @@ def show_blink():
outlocside='a' outlocside='a'
blink_status['side'] = outlocside blink_status['side'] = outlocside
blink_status['status'] = True blink_status['status'] = True
logging.warning('locside:{},{}'.format(outlocside,locations[locnum]['addr'])) logging.warning('locside_out:{},{}'.format(outlocside,locations[locnum]['addr']))
if outlocside=='both': if outlocside=='both':
break break
end = timeit.default_timer() end = timeit.default_timer()
print("show_blink end",end,(end-start)) print("show_blink end",end,(end-start),blink_status['status'])
blink_convert(blink_leds) blink_convert(blink_leds)
update_tower(blink_status,ng_status) update_tower(blink_status,ng_status)
time.sleep(0.5) time.sleep(0.5)
...@@ -740,6 +741,7 @@ def blink_convert(blink_leds): ...@@ -740,6 +741,7 @@ def blink_convert(blink_leds):
time.sleep(0.01) time.sleep(0.01)
#ser.read_alldata() #ser.read_alldata()
print("blink_convert",timeit.default_timer(),line) print("blink_convert",timeit.default_timer(),line)
#logging.warning("blink_convert",timeit.default_timer(),line)
#time.sleep(0.005) #time.sleep(0.005)
gg.sensorChangeFirstRun=True gg.sensorChangeFirstRun=True
# return texts # return texts
...@@ -809,18 +811,23 @@ else: ...@@ -809,18 +811,23 @@ else:
RedTWLed = '1@4' RedTWLed = '1@4'
YellowTWLed = '2@5' YellowTWLed = '2@5'
GreenTWLed = '3@6' GreenTWLed = '3@6'
logging.warning("LEDTOWER {}, {}, {}".format(RedTWLed,YellowTWLed,GreenTWLed))
def update_tower(blink_status,ng_status): def update_tower(blink_status,ng_status):
global tower_state global tower_state
global ServerErrorTimes global ServerErrorTimes
#print (blinks,ngs) print ("blink_status",blink_status['status'])
thisYellowTWLed = YellowTWLed thisYellowTWLed = YellowTWLed
if blink_status['side'].lower()=='a': if blink_status['side'].lower()=='a':
thisYellowTWLed=YellowTWLed.partition('@')[0] thisYellowTWLed=YellowTWLed.partition('@')[0]
elif blink_status['side'].lower()=='b': elif blink_status['side'].lower()=='b':
thisYellowTWLed=YellowTWLed.partition('@')[2] if YellowTWLed.partition('@')[0]==YellowTWLed.partition('@')[2]:
thisYellowTWLed=YellowTWLed.partition('@')[0]
else:
thisYellowTWLed=YellowTWLed.partition('@')[2]
if blink_status['status']: if blink_status['status']:
for led in thisYellowTWLed.split('@'): for led in thisYellowTWLed.split('@'):
print ("tower_state",led,tower_state[led]['status'])
if tower_state[led]['status'] == 'off': if tower_state[led]['status'] == 'off':
tower_state[led]['action'] = True tower_state[led]['action'] = True
tower_state[led]['status'] = 'on' tower_state[led]['status'] = 'on'
......
import pickle import pickle
import os import os
import string import string
import logging
from config import Config from config import Config
current_state: string current_state: string
...@@ -11,7 +12,7 @@ basepath = os.path.dirname(__file__) ...@@ -11,7 +12,7 @@ basepath = os.path.dirname(__file__)
shelfconfigfile = basepath+"/../" + Config.STATE_PATH+'shelfconfig.pkl' shelfconfigfile = basepath+"/../" + Config.STATE_PATH+'shelfconfig.pkl'
def ver(): def ver():
return "1.9" return "1.92"
class _shelfconfig: class _shelfconfig:
def __init__(self): def __init__(self):
...@@ -39,6 +40,5 @@ if os.path.exists(shelfconfigfile): ...@@ -39,6 +40,5 @@ if os.path.exists(shelfconfigfile):
continue continue
if shelfconfig.__dict__.get(it[0]) is not None: if shelfconfig.__dict__.get(it[0]) is not None:
shelfconfig.__dict__[it[0]]=a.__dict__[it[0]] shelfconfig.__dict__[it[0]]=a.__dict__[it[0]]
print("shelfconfig",shelfconfig.__dict__.items()) #print("shelfconfig",shelfconfig.__dict__.items())
#logging.warning("shelfconfig",shelfconfig.__dict__.items())
\ No newline at end of file \ No newline at end of file
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!