Commit 48c1a495 刘韬

修正最后一次感应后和服务器同步状态

1 个父辈 0d11a2d5
正在显示 48 个修改的文件 包含 23 行增加17 行删除
...@@ -20,7 +20,6 @@ from app.utils.serial_communication import SerialCommunication ...@@ -20,7 +20,6 @@ from app.utils.serial_communication import SerialCommunication
from app.induction_config import read_addrs,ip_config,testCidExists from app.induction_config import read_addrs,ip_config,testCidExists
#from serial_config import ReadConfig #from serial_config import ReadConfig
from app.utils.location import Location from app.utils.location import Location
config_dict,convert_dict = Location().read_location_file() config_dict,convert_dict = Location().read_location_file()
sensorindex={} sensorindex={}
print('convert_dict',convert_dict) print('convert_dict',convert_dict)
...@@ -328,6 +327,7 @@ def ProcessLastSensor(cur_dict,last_sensor_dict): ...@@ -328,6 +327,7 @@ def ProcessLastSensor(cur_dict,last_sensor_dict):
if len(list)>0: if len(list)>0:
command = '{{"ADDR":{},"color":{}}}\n'.format(k[1:],list) command = '{{"ADDR":{},"color":{}}}\n'.format(k[1:],list)
print("ProcessLastSensor",command,len(list)) print("ProcessLastSensor",command,len(list))
gg.sensorChangeFirstRun=True
ser.send_data(command,False) ser.send_data(command,False)
return True return True
else: else:
......
...@@ -235,8 +235,7 @@ def serverboard(): ...@@ -235,8 +235,7 @@ def serverboard():
global last_sensor_dict global last_sensor_dict
global lastupdatetime global lastupdatetime
global ServerAliveTime global ServerAliveTime
global sensorChangeFirstRun gg.sensorChangeFirstRun = True
sensorChangeFirstRun = True
# serial_cf = ReadConfig() # serial_cf = ReadConfig()
command = "" command = ""
# addrs = serial_cf.get_serial("addrs") # addrs = serial_cf.get_serial("addrs")
...@@ -475,7 +474,6 @@ def filter_ng(in_loc,out_loc): ...@@ -475,7 +474,6 @@ def filter_ng(in_loc,out_loc):
logging.warning('入库ng恢复:{}'.format(out)) logging.warning('入库ng恢复:{}'.format(out))
return in_loc,out_loc return in_loc,out_loc
sensorChangeFirstRun=True
# 发送入库/出库库位到服务器 # 发送入库/出库库位到服务器
def send_loc_server(in_loc,out_loc): def send_loc_server(in_loc,out_loc):
# http://ip/smdbox/service/store/sensorShelf/sensorChange # http://ip/smdbox/service/store/sensorShelf/sensorChange
...@@ -484,7 +482,6 @@ def send_loc_server(in_loc,out_loc): ...@@ -484,7 +482,6 @@ def send_loc_server(in_loc,out_loc):
# print ('--------------------origin_out_loc',out_loc) # print ('--------------------origin_out_loc',out_loc)
global locations global locations
global ServerErrorTimes global ServerErrorTimes
global sensorChangeFirstRun
in_ng_loc = [] in_ng_loc = []
out_ng_loc = [] out_ng_loc = []
for locnum, locvalue in locations.items(): for locnum, locvalue in locations.items():
...@@ -493,11 +490,11 @@ def send_loc_server(in_loc,out_loc): ...@@ -493,11 +490,11 @@ def send_loc_server(in_loc,out_loc):
if locvalue['outloc_ng']: if locvalue['outloc_ng']:
out_ng_loc.append(locnum) out_ng_loc.append(locnum)
if not sensorChangeFirstRun and len(in_loc)==0 and len(out_loc)==0 and len(in_ng_loc)==0 and len(out_ng_loc)==0 : if not gg.sensorChangeFirstRun and len(in_loc)==0 and len(out_loc)==0 and len(in_ng_loc)==0 and len(out_ng_loc)==0 :
print("send_loc_server,nochange") print("send_loc_server,nochange")
return return
sensorChangeFirstRun=False gg.sensorChangeFirstRun=False
headers = {'content-type': "application/x-www-form-urlencoded"} headers = {'content-type': "application/x-www-form-urlencoded"}
url = ip_config['ip'] + '/service/store/sensorShelf/sensorChange' url = ip_config['ip'] + '/service/store/sensorShelf/sensorChange'
data = {"cid":ip_config['cid'],"hasReelPosList":in_loc,"hasReelPosErrorList": in_ng_loc,"noReelPosList":out_loc,"noReelPosErrorList":out_ng_loc} data = {"cid":ip_config['cid'],"hasReelPosList":in_loc,"hasReelPosErrorList": in_ng_loc,"noReelPosList":out_loc,"noReelPosErrorList":out_ng_loc}
...@@ -642,7 +639,7 @@ def show_blink(): ...@@ -642,7 +639,7 @@ def show_blink():
ng_status['side'] = locside ng_status['side'] = locside
ng_status['status'] = True ng_status['status'] = True
outlocside = '' outlocside = ''
for locnum in outTaskInfo.keys(): for locnum in list(outTaskInfo.keys()):
#logging.warning('有出库任务闪黄灯:{}'.format(locnum)) #logging.warning('有出库任务闪黄灯:{}'.format(locnum))
if len(locations[locnum]['addr'])==3: if len(locations[locnum]['addr'])==3:
if outlocside=='a': if outlocside=='a':
...@@ -744,6 +741,7 @@ def blink_convert(blink_leds): ...@@ -744,6 +741,7 @@ def blink_convert(blink_leds):
#ser.read_alldata() #ser.read_alldata()
print("blink_convert",timeit.default_timer(),line) print("blink_convert",timeit.default_timer(),line)
#time.sleep(0.005) #time.sleep(0.005)
gg.sensorChangeFirstRun=True
# return texts # return texts
#blink_leds={} #blink_leds={}
...@@ -798,6 +796,7 @@ def send_tower_status_light(): ...@@ -798,6 +796,7 @@ def send_tower_status_light():
command_dicts = {"ADDR":"0","lighton":lightons,"lightoff":lightoffs} command_dicts = {"ADDR":"0","lighton":lightons,"lightoff":lightoffs}
maincommand = str(json.dumps(command_dicts)) + '\n' maincommand = str(json.dumps(command_dicts)) + '\n'
# print ('------------------maincommand',maincommand) # print ('------------------maincommand',maincommand)
gg.sensorChangeFirstRun=True
ser.send_data(maincommand) ser.send_data(maincommand)
#1@4 红色 #1@4 红色
#3@6 绿色 #3@6 绿色
......
...@@ -5,14 +5,13 @@ from config import Config ...@@ -5,14 +5,13 @@ from config import Config
current_state: string current_state: string
current_state='off' current_state='off'
sensorChangeFirstRun=True
Serl = None Serl = None
basepath = os.path.dirname(__file__) 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.874" return "1.876"
class _shelfconfig: class _shelfconfig:
def __init__(self): def __init__(self):
......
...@@ -18161,3 +18161,5 @@ KeyError: 'code' ...@@ -18161,3 +18161,5 @@ KeyError: 'code'
2023-08-18 11:22:40,979 - WARNING : ("串口发送数据错误,'NoneType' object has no attribute 'out_waiting'",) 2023-08-18 11:22:40,979 - WARNING : ("串口发送数据错误,'NoneType' object has no attribute 'out_waiting'",)
2023-08-18 11:22:40,980 - WARNING : 灯条:all已关闭 2023-08-18 11:22:40,980 - WARNING : 灯条:all已关闭
2023-08-18 11:22:47,454 - WARNING : ('---异常---:', SerialException("could not open port '1': FileNotFoundError(2, '系统找不到指定的文件。', None, 2)")) 2023-08-18 11:22:47,454 - WARNING : ('---异常---:', SerialException("could not open port '1': FileNotFoundError(2, '系统找不到指定的文件。', None, 2)"))
2024-01-10 11:45:48,511 - 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-01-10 11:46:49,513 - WARNING : config:D:\rick\python\induction_shelf\smartshelf\app/state/, ip&cid...:{'post': 'wait', 'ip': 'http://192.168.1.243/smf-core', 'cid': 'S10392'}
...@@ -23,6 +23,7 @@ from app.utils.location import Location ...@@ -23,6 +23,7 @@ from app.utils.location import Location
config_dict,convert_dict = Location().read_location_file() config_dict,convert_dict = Location().read_location_file()
sensorindex={} sensorindex={}
print('convert_dict',convert_dict)
for k,v in convert_dict.items(): for k,v in convert_dict.items():
d=k.split('@') d=k.split('@')
if d[1] not in sensorindex: if d[1] not in sensorindex:
...@@ -307,9 +308,10 @@ def ProcessLastSensor(cur_dict,last_sensor_dict): ...@@ -307,9 +308,10 @@ def ProcessLastSensor(cur_dict,last_sensor_dict):
closelist=[] closelist=[]
lv = last_sensor_dict.get(k) lv = last_sensor_dict.get(k)
hv= sensorindex.get(k) hv= sensorindex.get(k)
print('HV',k,hv)
ledcount=0; ledcount=0;
if lv and len(lv)==len(v): if lv and len(lv)==len(v):
for i in range(0,len(lv)): for i in range(0,len(lv)):
if hv[i]=='1': if hv[i]=='1':
ledcount=ledcount+1 ledcount=ledcount+1
if v[i]=='1' and v[i]!=lv[i]: if v[i]=='1' and v[i]!=lv[i]:
......
...@@ -235,6 +235,8 @@ def serverboard(): ...@@ -235,6 +235,8 @@ def serverboard():
global last_sensor_dict global last_sensor_dict
global lastupdatetime global lastupdatetime
global ServerAliveTime global ServerAliveTime
global sensorChangeFirstRun
sensorChangeFirstRun = True
# serial_cf = ReadConfig() # serial_cf = ReadConfig()
command = "" command = ""
# addrs = serial_cf.get_serial("addrs") # addrs = serial_cf.get_serial("addrs")
...@@ -473,7 +475,7 @@ def filter_ng(in_loc,out_loc): ...@@ -473,7 +475,7 @@ def filter_ng(in_loc,out_loc):
logging.warning('入库ng恢复:{}'.format(out)) logging.warning('入库ng恢复:{}'.format(out))
return in_loc,out_loc return in_loc,out_loc
sensorChangeFirstRun=True
# 发送入库/出库库位到服务器 # 发送入库/出库库位到服务器
def send_loc_server(in_loc,out_loc): def send_loc_server(in_loc,out_loc):
# http://ip/smdbox/service/store/sensorShelf/sensorChange # http://ip/smdbox/service/store/sensorShelf/sensorChange
...@@ -482,6 +484,7 @@ def send_loc_server(in_loc,out_loc): ...@@ -482,6 +484,7 @@ def send_loc_server(in_loc,out_loc):
# print ('--------------------origin_out_loc',out_loc) # print ('--------------------origin_out_loc',out_loc)
global locations global locations
global ServerErrorTimes global ServerErrorTimes
global sensorChangeFirstRun
in_ng_loc = [] in_ng_loc = []
out_ng_loc = [] out_ng_loc = []
for locnum, locvalue in locations.items(): for locnum, locvalue in locations.items():
...@@ -490,11 +493,11 @@ def send_loc_server(in_loc,out_loc): ...@@ -490,11 +493,11 @@ def send_loc_server(in_loc,out_loc):
if locvalue['outloc_ng']: if locvalue['outloc_ng']:
out_ng_loc.append(locnum) out_ng_loc.append(locnum)
if len(in_loc)==0 and len(out_loc)==0 and len(in_ng_loc)==0 and len(out_ng_loc)==0 : if not sensorChangeFirstRun and len(in_loc)==0 and len(out_loc)==0 and len(in_ng_loc)==0 and len(out_ng_loc)==0 :
print("send_loc_server,nochange") print("send_loc_server,nochange")
return return
sensorChangeFirstRun=False
headers = {'content-type': "application/x-www-form-urlencoded"} headers = {'content-type': "application/x-www-form-urlencoded"}
url = ip_config['ip'] + '/service/store/sensorShelf/sensorChange' url = ip_config['ip'] + '/service/store/sensorShelf/sensorChange'
data = {"cid":ip_config['cid'],"hasReelPosList":in_loc,"hasReelPosErrorList": in_ng_loc,"noReelPosList":out_loc,"noReelPosErrorList":out_ng_loc} data = {"cid":ip_config['cid'],"hasReelPosList":in_loc,"hasReelPosErrorList": in_ng_loc,"noReelPosList":out_loc,"noReelPosErrorList":out_ng_loc}
...@@ -639,7 +642,7 @@ def show_blink(): ...@@ -639,7 +642,7 @@ def show_blink():
ng_status['side'] = locside ng_status['side'] = locside
ng_status['status'] = True ng_status['status'] = True
outlocside = '' outlocside = ''
for locnum in outTaskInfo.keys(): for locnum in list(outTaskInfo.keys()):
#logging.warning('有出库任务闪黄灯:{}'.format(locnum)) #logging.warning('有出库任务闪黄灯:{}'.format(locnum))
if len(locations[locnum]['addr'])==3: if len(locations[locnum]['addr'])==3:
if outlocside=='a': if outlocside=='a':
......
...@@ -58,6 +58,7 @@ def transfer(origin_value): ...@@ -58,6 +58,7 @@ def transfer(origin_value):
c_list.pop(-1) c_list.pop(-1)
keyword = 'A' + addr.group() keyword = 'A' + addr.group()
cur_dict[keyword] = c_list cur_dict[keyword] = c_list
print('cur_dict',keyword,cur_dict[keyword])
except Exception as e: except Exception as e:
logging.warning("读取传感器状态出错:{}".format(repr(e))) logging.warning("读取传感器状态出错:{}".format(repr(e)))
logging.warning("当前解析值:{}".format(receive_data)) logging.warning("当前解析值:{}".format(receive_data))
......
...@@ -10,7 +10,7 @@ basepath = os.path.dirname(__file__) ...@@ -10,7 +10,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.873" return "1.874"
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!