Snapshot refactor
This commit is contained in:
parent
109a9e4e73
commit
97684de33e
@ -426,12 +426,15 @@ class ECU:
|
|||||||
print "Press any key to exit"
|
print "Press any key to exit"
|
||||||
|
|
||||||
for dr in datarefs:
|
for dr in datarefs:
|
||||||
datastr = dr.name;
|
datastr = dr.name
|
||||||
help = dr.type
|
help = dr.type
|
||||||
if dr.type=='State':
|
if dr.type=='State':
|
||||||
datastr, help, csvd = get_state( self.States[dr.name], self.Mnemonics, self.Services, self.elm, self.calc )
|
if self.DataIds and DTCpos and dr in self.Defaults[mod_globals.ext_cur_DTC[:4]].ssdatarefs:
|
||||||
|
datastr, help, csvd = get_state( self.States[dr.name], self.Mnemonics, self.Services, self.elm, self.calc, self.DataIds )
|
||||||
|
else:
|
||||||
|
datastr, help, csvd = get_state( self.States[dr.name], self.Mnemonics, self.Services, self.elm, self.calc )
|
||||||
if dr.type=='Parameter':
|
if dr.type=='Parameter':
|
||||||
if self.DataIds and dr in self.Defaults[mod_globals.ext_cur_DTC[:4]].datarefs:
|
if self.DataIds and DTCpos and dr in self.Defaults[mod_globals.ext_cur_DTC[:4]].ssdatarefs:
|
||||||
datastr, help, csvd = get_parameter( self.Parameters[dr.name], self.Mnemonics, self.Services, self.elm, self.calc, self.DataIds )
|
datastr, help, csvd = get_parameter( self.Parameters[dr.name], self.Mnemonics, self.Services, self.elm, self.calc, self.DataIds )
|
||||||
else:
|
else:
|
||||||
datastr, help, csvd = get_parameter( self.Parameters[dr.name], self.Mnemonics, self.Services, self.elm, self.calc )
|
datastr, help, csvd = get_parameter( self.Parameters[dr.name], self.Mnemonics, self.Services, self.elm, self.calc )
|
||||||
@ -439,6 +442,8 @@ class ECU:
|
|||||||
datastr, help, csvd = get_identification( self.Identifications[dr.name], self.Mnemonics, self.Services, self.elm, self.calc )
|
datastr, help, csvd = get_identification( self.Identifications[dr.name], self.Mnemonics, self.Services, self.elm, self.calc )
|
||||||
if dr.type=='Command':
|
if dr.type=='Command':
|
||||||
datastr = dr.name + " [Command] " + self.Commands[dr.name].label
|
datastr = dr.name + " [Command] " + self.Commands[dr.name].label
|
||||||
|
if dr.type=="Text":
|
||||||
|
datastr = dr.name
|
||||||
|
|
||||||
if mod_globals.opt_csv and csvf!=0 and (dr.type=='State' or dr.type=='Parameter'):
|
if mod_globals.opt_csv and csvf!=0 and (dr.type=='State' or dr.type=='Parameter'):
|
||||||
csvline += ";" + (pyren_encode(csvd) if mod_globals.opt_csv_human else str(csvd))
|
csvline += ";" + (pyren_encode(csvd) if mod_globals.opt_csv_human else str(csvd))
|
||||||
@ -751,7 +756,13 @@ class ECU:
|
|||||||
|
|
||||||
path = path+' -> '+defstr[dtchex]+'\n\n'+hlpstr[dtchex]+'\n'
|
path = path+' -> '+defstr[dtchex]+'\n\n'+hlpstr[dtchex]+'\n'
|
||||||
|
|
||||||
tmp_dtrf = self.Defaults[dtchex[:4]].datarefs + self.Defaults[dtchex[:4]].ssdatarefs + self.ext_de
|
mem_dtrf_txt = mod_globals.language_dict['299'] + " DTC" + mod_globals.ext_cur_DTC + "\n"
|
||||||
|
|
||||||
|
cur_dtrf = [ecu_screen_dataref(0, "\n" + mod_globals.language_dict['300'] + "\n", 'Text')] + self.Defaults[dtchex[:4]].datarefs
|
||||||
|
mem_dtrf = [ecu_screen_dataref(0, mem_dtrf_txt, 'Text')] + self.Defaults[dtchex[:4]].ssdatarefs
|
||||||
|
ext_info_dtrf = [ecu_screen_dataref(0, "\n" + mod_globals.language_dict['1691'] + "\n", 'Text')] + self.ext_de
|
||||||
|
|
||||||
|
tmp_dtrf = mem_dtrf + cur_dtrf + ext_info_dtrf
|
||||||
|
|
||||||
#self.show_datarefs(self.Defaults[dtchex[:4]].datarefs, path)
|
#self.show_datarefs(self.Defaults[dtchex[:4]].datarefs, path)
|
||||||
self.show_datarefs(tmp_dtrf, path)
|
self.show_datarefs(tmp_dtrf, path)
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
from mod_ecu_service import *
|
from mod_ecu_service import *
|
||||||
from mod_globals import curPosInSnapshotResp
|
|
||||||
|
|
||||||
from mod_utils import Choice
|
from mod_utils import Choice
|
||||||
from xml.dom.minidom import parse
|
from xml.dom.minidom import parse
|
||||||
@ -96,6 +95,7 @@ def get_mnemonic( m, se, elm, raw = 0 ):
|
|||||||
|
|
||||||
def get_SnapShotMnemonic(m, se, elm, dataids):
|
def get_SnapShotMnemonic(m, se, elm, dataids):
|
||||||
snapshotService = ""
|
snapshotService = ""
|
||||||
|
posInResp = 0
|
||||||
for sid in se:
|
for sid in se:
|
||||||
if len(se[sid].params) > 1:
|
if len(se[sid].params) > 1:
|
||||||
if se[sid].params[1]['type'] == 'Snapshot':
|
if se[sid].params[1]['type'] == 'Snapshot':
|
||||||
@ -107,24 +107,27 @@ def get_SnapShotMnemonic(m, se, elm, dataids):
|
|||||||
resp = resp.strip().replace(' ','')
|
resp = resp.strip().replace(' ','')
|
||||||
if not all(c in string.hexdigits for c in resp): resp = ''
|
if not all(c in string.hexdigits for c in resp): resp = ''
|
||||||
resp = ' '.join(a+b for a,b in zip(resp[::2], resp[1::2]))
|
resp = ' '.join(a+b for a,b in zip(resp[::2], resp[1::2]))
|
||||||
|
numberOfIdentifiers = int("0x" + resp[7*3:8*3-1],16)
|
||||||
resp = resp[8*3:]
|
resp = resp[8*3:]
|
||||||
|
|
||||||
if mod_globals.curPosInSnapshotResp >= len(resp):
|
didDict = {}
|
||||||
mod_globals.curPosInSnapshotResp = 0
|
for x in range(numberOfIdentifiers):
|
||||||
|
dataId = resp[posInResp:posInResp + 2*3].replace(" ", "")
|
||||||
dataId = resp[mod_globals.curPosInSnapshotResp:mod_globals.curPosInSnapshotResp + 2*3].replace(" ", "")
|
posInResp += 2*3
|
||||||
|
didDataLength = int(dataids[dataId].dataBitLength)/8
|
||||||
didDataLength = int(dataids[dataId].dataBitLength)/8
|
didData = resp[posInResp: posInResp + didDataLength*3]
|
||||||
didData = resp[mod_globals.curPosInSnapshotResp + 2*3: mod_globals.curPosInSnapshotResp + 2*3 + didDataLength*3]
|
posInResp += didDataLength*3
|
||||||
mod_globals.curPosInSnapshotResp += 2*3 + didDataLength * 3
|
didDict[dataId] = didData
|
||||||
|
|
||||||
startByte = ""
|
startByte = ""
|
||||||
startBit = ""
|
startBit = ""
|
||||||
|
dataId = ""
|
||||||
for mn in dataids[dataId].mnemolocations.keys():
|
for did in dataids.keys():
|
||||||
if mn == m.name:
|
for mn in dataids[did].mnemolocations.keys():
|
||||||
startByte = dataids[dataId].mnemolocations[m.name].startByte
|
if mn == m.name:
|
||||||
startBit = dataids[dataId].mnemolocations[m.name].startBit
|
dataId = did
|
||||||
|
startByte = dataids[dataId].mnemolocations[m.name].startByte
|
||||||
|
startBit = dataids[dataId].mnemolocations[m.name].startBit
|
||||||
|
|
||||||
#prepare local variables
|
#prepare local variables
|
||||||
sb = int(startByte) - 1
|
sb = int(startByte) - 1
|
||||||
@ -134,11 +137,11 @@ def get_SnapShotMnemonic(m, se, elm, dataids):
|
|||||||
rshift = ((bytes+1)*8 - (bits+sbit))%8
|
rshift = ((bytes+1)*8 - (bits+sbit))%8
|
||||||
|
|
||||||
#check length of responce
|
#check length of responce
|
||||||
if (sb*3+bytes*3-1)>(len(didData)):
|
if (sb*3+bytes*3-1)>(len(didDict[dataId])):
|
||||||
return '00'
|
return '00'
|
||||||
|
|
||||||
#extract hex
|
#extract hex
|
||||||
hexval = didData[sb*3:(sb+bytes)*3-1]
|
hexval = didDict[dataId][sb*3:(sb+bytes)*3-1]
|
||||||
hexval = hexval.replace(" ","")
|
hexval = hexval.replace(" ","")
|
||||||
|
|
||||||
#shift and mask
|
#shift and mask
|
||||||
|
@ -7,11 +7,14 @@ from xml.dom.minidom import parseString
|
|||||||
import xml.dom.minidom
|
import xml.dom.minidom
|
||||||
import mod_globals
|
import mod_globals
|
||||||
|
|
||||||
def get_state( st, mn, se, elm, calc ):
|
def get_state( st, mn, se, elm, calc, dataids = {} ):
|
||||||
comp = st.computation
|
comp = st.computation
|
||||||
comp = comp.replace("&","&")
|
comp = comp.replace("&","&")
|
||||||
for m in sorted(st.mnemolist, key=len, reverse=True):
|
for m in sorted(st.mnemolist, key=len, reverse=True):
|
||||||
hex_val = get_mnemonic( mn[m], se, elm )
|
if dataids:
|
||||||
|
hex_val = get_SnapShotMnemonic(mn[m], se, elm, dataids )
|
||||||
|
else:
|
||||||
|
hex_val = get_mnemonic( mn[m], se, elm )
|
||||||
comp = comp.replace(m, "0x"+hex_val)
|
comp = comp.replace(m, "0x"+hex_val)
|
||||||
tmp_val = calc.calculate(comp)
|
tmp_val = calc.calculate(comp)
|
||||||
|
|
||||||
|
@ -40,7 +40,6 @@ state_scan = False
|
|||||||
currentDDTscreen = None
|
currentDDTscreen = None
|
||||||
|
|
||||||
ext_cur_DTC = "000000"
|
ext_cur_DTC = "000000"
|
||||||
curPosInSnapshotResp = 0
|
|
||||||
|
|
||||||
none_val = "None"
|
none_val = "None"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user