hey walter.
I just did up a section of code, i trimmed out about 125 lines. and I think this is a little more readable.
but on another note. I would set up a folder with a separate file for each hex list with a nice friendly name for the file. and you could make a small class that you would call asking for the name of the file and it would do the import and return the value. that way it will only load what is needed and you wouldn't have to have a heap of imports
Code: Select all
hexDict = {
('01', 'FF') : self.decode_000,
('03',) : self.decode_003,
('04', '02') : self.decode_002,
('06', '30', '04'): self.decode_030_1,
('06', '30') : self.decode_030_0,
('07', '70') : self.decode_070,
('07', '10') : self.decode_010,
('07', '16') : self.decode_016,
('07', '18') : self.decode_018,
('08', '42') : self.decode_042,
('08', '50') : self.decode_050,
('08', '51') : self.decode_051,
('08', '20') : self.decode_020,
('09', '57') : self.decode_057,
('09', '40') : self.decode_040,
('13',) : self.decode_013,
('10', '56') : self.decode_056,
('11', '5a', '01'): self.decode_05A_1,
('11', '5a', '02'): self.decode_05A_2,
('11', '60', '02'): self.decode_060_02,
('13', '5b') : self.decode_05B,
('14', '01', '00'): self.decode_14_00,
('14', '01', '01'): self.decode_01d,
('14', '01', '02'): self.decode_02d,
('14', '01', '03'): self.decode_03d,
('14', '01', '04'): self.decode_04d,
('14', '01', 'ff'): self.decode_ff,
('14', '01', '07'): self.decode_14_07,
('15', '60', '01'): self.decode_060_01,
('0a', '52') : self.decode_052,
('0a', '4e') : self.decode_04E,
('0a', '4f') : self.decode_04F,
('0a', '14', '00'): self.decode_014_00,
('0a', '14', '01'): self.decode_014_01,
('0a', '14', '02'): self.decode_014_02,
('0a', '14', '04'): self.decode_014_02,
('0a', '14', '03'): self.decode_014_03,
('0a', '14', '06'): self.decode_014_06,
('0a', '14', '07'): self.decode_014_07,
('0a', '14', '0d'): self.decode_014_0d,
('0a', '71') : self.decode_071,
('0b', '55') : self.decode_055,
('0b', '11') : self.decode_011,
('0b', '15') : self.decode_015,
('0d', '54') : self.decode_054,
('0d', '58') : self.decode_058,
('0d', '59') : self.decode_059,
('0d', '01', '00'): self.decode_00d,
('0d', '01', '01'): self.decode_01d,
('0d', '01', '02'): self.decode_02d,
('0d', '01', '03'): self.decode_03d,
('0d', '01', '04'): self.decode_04d,
('0d', '01', 'ff'): self.decode_ff,
('0f', '5c') : self.decode_05C,
('1c', '21') : self.decode_021
}
if msg[:2] == ['09', '19']:
tmpmsg = int(msg[2])
if int(msg[2],16) == 11:
self.decode_019_B(msg)
elif tmpmsg >= 8:
self.decode_019_8(msg)
elif tmpmsg >= 6:
self.decode_019_6(msg)
elif tmpmsg >= 2:
self.decode_019_2(msg)
elif tmpmsg >= 0:
self.decode_019(msg)
return
elif tuple(msg[:3]) in hexDict:
hexDixt[tuple(msg[:3])](msg)
return
but as an example this kind of information can be held elsewhere because it's static
and one other thing. make a changelog.txt file and deep six the 700 line header
but it appears that a whole lot of this code is static information, and coud be put into some kind of database. i am not sure if there is a means to read a function from a file. I don't think pickeling will work. but at any rate even just making the class thing as i mentioned to grab the data