1 files deleted
10 files modified
| | |
| | | |
| | | self.retranslateUi(MainWindow) |
| | | |
| | | self.tabWidget.setCurrentIndex(1) |
| | | self.tabWidget.setCurrentIndex(2) |
| | | self.tabWidget_2.setCurrentIndex(0) |
| | | |
| | | |
| | |
| | | BA_ "GenMsgCycleTime" BO_ 329 10; |
| | | BA_ "GenMsgCycleTime" BO_ 534 10; |
| | | BA_ "GenMsgCycleTime" BO_ 530 10; |
| | | BA_ "GenMsgDelayTime" BO_ 1056 20; |
| | | BA_ "GenMsgNrOfRepetition" BO_ 1056 3; |
| | | BA_ "GenMsgCycleTimeFast" BO_ 1056 20; |
| | | BA_ "GenMsgCycleTime" BO_ 1056 100; |
| | | BA_ "GenMsgCycleTimeFast" BO_ 1056 20; |
| | | BA_ "GenMsgNrOfRepetition" BO_ 1056 3; |
| | | BA_ "GenMsgDelayTime" BO_ 1056 20; |
| | | BA_ "GenMsgCycleTime" BO_ 16 10; |
| | | BA_ "GenMsgCycleTime" BO_ 512 20; |
| | | BA_ "GenMsgSendType" BO_ 1858 8; |
| | | BA_ "GenMsgCycleTime" BO_ 1858 0; |
| | | BA_ "GenMsgILSupport" BO_ 1914 1; |
| | | BA_ "GenMsgSendType" BO_ 1914 1; |
| | | BA_ "GenMsgSendType" BO_ 1858 8; |
| | | BA_ "GenMsgCycleTime" BO_ 1914 0; |
| | | BA_ "GenMsgSendType" BO_ 2015 8; |
| | | BA_ "GenMsgSendType" BO_ 1914 1; |
| | | BA_ "GenMsgILSupport" BO_ 1914 1; |
| | | BA_ "GenMsgCycleTime" BO_ 2015 0; |
| | | BA_ "GenMsgSendType" BO_ 2015 8; |
| | | BA_ "GenSigStartValue" SG_ 530 brake_pedal_status 3; |
| | | BA_ "GenSigStartValue" SG_ 1056 SA1_Status_GearShftPosReq 15; |
| | | BA_ "GenSigSendType" SG_ 1056 SA1_Status_GearShftPosReq 4; |
| | | BA_ "GenSigStartValue" SG_ 1056 SA1_Status_GearShftPosReq 15; |
| | | BA_ "GenSigStartValue" SG_ 1056 SA1_Status_PRNDL 7; |
| | | BA_ "GenSigStartValue" SG_ 16 ShiftLeverPos 7; |
| | | BA_ "GenSigStartValue" SG_ 16 ActualGear 15; |
| | |
| | | VAL_TABLE_ Shifter_Lever_Signals_VT 15 "Invalid" 11 "Z4(Between D and L)" 10 "Z3(Between N and D)" 9 "Z2(Between R and N)" 8 "Z1(Between P and R)" 7 "P" 6 "R" 5 "N" 4 "D" 3 "Sport mode,display PWR on IC" 0 "Unkown" ; |
| | | |
| | | |
| | | BO_ 534 CVT1: 1 Vector__XXX |
| | | BO_ 3221225472 VECTOR__INDEPENDENT_SIG_MSG: 0 Vector__XXX |
| | | SG_ Angle2 : 0|16@0+ (1,0) [0|0] "" Vector__XXX |
| | | SG_ Angle1 : 0|16@0+ (1,0) [0|0] "" Vector__XXX |
| | | SG_ Calibartion : 0|8@0+ (1,0) [0|0] "" Vector__XXX |
| | | |
| | | BO_ 534 CVT1: 8 Vector__XXX |
| | | SG_ Shifter_Lever_Signals : 63|8@0+ (1,0) [0|0] "" Vector__XXX |
| | | |
| | | BO_ 329 IC1: 3 Vector__XXX |
| | | BO_ 329 IC1: 8 Vector__XXX |
| | | SG_ odometer_value : 47|24@0+ (1,0) [0|0] "" Vector__XXX |
| | | |
| | | BO_ 530 Engine2: 1 Vector__XXX |
| | | BO_ 530 Engine2: 8 Vector__XXX |
| | | SG_ brake_pedal_status : 57|2@0+ (1,0) [0|0] "" Vector__XXX |
| | | |
| | | BO_ 512 ABS1: 3 Vector__XXX |
| | | SG_ vehicle_speed : 15|13@0+ (0.05625,0) [0|0] "" Vector__XXX |
| | | |
| | | BO_ 16 TCU2: 3 Vector__XXX |
| | | SG_ Calibartion : 23|8@0+ (1,0) [0|0] "" Vector__XXX |
| | | BO_ 16 TCU2: 2 Vector__XXX |
| | | SG_ ActualGear : 11|4@1+ (1,0) [0|0] "" Vector__XXX |
| | | SG_ TCUDrivingMode : 10|3@0+ (1,0) [0|0] "" Vector__XXX |
| | | SG_ ShiftLeverPos : 2|3@0+ (1,0) [0|0] "" Vector__XXX |
| | | |
| | | BO_ 1056 SA1: 8 Vector__XXX |
| | | SG_ Angle2 : 55|16@0+ (1,0) [0|0] "" Vector__XXX |
| | | SG_ Angle1 : 39|16@0+ (1,0) [0|0] "" Vector__XXX |
| | | SG_ SA1_Status_ShiftPosValidFlag : 27|1@0+ (1,0) [0|0] "" Vector__XXX |
| | | SG_ SA1_Status_ShiftPosValidFlag : 32|1@0+ (1,0) [0|0] "" Vector__XXX |
| | | SG_ SA1_Status_RqGearPosInV : 31|4@0+ (1,0) [0|0] "" Vector__XXX |
| | | SG_ SA1_Status_GearShftPosReq : 23|4@0+ (1,0) [0|0] "" Vector__XXX |
| | | SG_ SA1_Status_ParkButtonReq : 19|2@0+ (1,0) [0|0] "" Vector__XXX |
| | |
| | | |
| | | |
| | | |
| | | CM_ BO_ 3221225472 "This is a message for not used signals, created by Vector CANdb++ DBC OLE DB Provider."; |
| | | BA_DEF_ "BusType" STRING ; |
| | | BA_DEF_DEF_ "BusType" "CAN"; |
| | | VAL_ 3221225472 Calibartion 10 "Finish" 9 "CAL_GAP" 8 "CAL_Y2" 7 "CAL_Y1" 6 "CAL_X1" 5 "CAL_X2" 4 "CAL_MN" 3 "CAL_MP" 2 "CAL_M" 1 "CAL_Z" 0 "start" ; |
| | | VAL_ 534 Shifter_Lever_Signals 15 "Invalid" 11 "Z4(Between D and L)" 10 "Z3(Between N and D)" 9 "Z2(Between R and N)" 8 "Z1(Between P and R)" 7 "P" 6 "R" 5 "N" 4 "D" 3 "Sport mode,display PWR on IC" 0 "Unkown" ; |
| | | VAL_ 530 brake_pedal_status 3 "Invalid" 2 "Not specified" 1 "Brake actuated" 0 "Brake not actuated" ; |
| | | VAL_ 16 Calibartion 10 "Finish" 9 "CAL_GAP" 8 "CAL_Y2" 7 "CAL_Y1" 6 "CAL_X1" 5 "CAL_X2" 4 "CAL_MN" 3 "CAL_MP" 2 "CAL_M" 1 "CAL_Z" 0 "start" ; |
| | | VAL_ 16 ActualGear 15 "Invalid" 14 "Reserved" 13 "Current_gear_P" 12 "Reserved" 11 "Current_gear_R" 10 "Reserved" 9 "Reserved" 8 "Reserved" 7 "Current_gear_7" 6 "Current_gear_6" 5 "Current_gear_5" 4 "Current_gear_4" 3 "Current_gear_3" 2 "Current_gear_2" 1 "Current_gear_1" 0 "Current_gear_N" ; |
| | | VAL_ 16 TCUDrivingMode 7 "Invalid" 6 "Reserved" 5 "Reserved" 4 "Sport" 3 "Reserved" 2 "Manual" 1 "Snow Mode" 0 "Standard" ; |
| | | VAL_ 16 ShiftLeverPos 7 "Invalid" 6 "M-" 5 "M+" 4 "M" 3 "R" 2 "N" 1 "D" 0 "P" ; |
| | |
| | | from email.message import Message |
| | | from ShifterDefine import * |
| | | import struct |
| | | from udsoncan import DidCodec |
| | | |
| | | import configparser |
| | | from dbc import * |
| | | import cantools |
| | | |
| | | ProjectDBC = cantools.database.load_file("DBC/SX7H.dbc") |
| | | |
| | | |
| | | class AsciiCodec(DidCodec): |
| | |
| | | class ShifterClass(): |
| | | |
| | | def __init__(self): |
| | | self.position = ShifterPosition(0) |
| | | self.Pbutton = 0 |
| | | self.UnlockButton = 0 |
| | | self.position = None |
| | | self.Pbutton = None |
| | | self.UnlockButton = None |
| | | self.Voltage = 0 |
| | | self.canid = ShifterCANID() |
| | | |
| | |
| | | self.canid.phy_rxId = 0x742 |
| | | self.canid.fun_rxId = 0x7df |
| | | self.canid.normalid = 0x420 |
| | | self.dbc = DBC("DBC/DFLZM.dbc") |
| | | self.SA1_message = ProjectDBC.get_message_by_name('SA1') |
| | | |
| | | def FramUnpack(self, id=0x420, frame=[]): |
| | | data = [] |
| | | data.append(' '.join( |
| | | ['{:0>2x}'.format(a).upper() for a in list(frame)])) |
| | | # print(data) |
| | | unpackframe = self.dbc.analyzer(msgid=0x420, data=str(data[0])) |
| | | # print(unpackframe[5]['value']['raw']) |
| | | self.Pbutton = unpackframe[5]['value']['raw'] |
| | | print(unpackframe[5]["name"], unpackframe[5]['value']['raw']) |
| | | # print(unpackframe[6]['value']['raw']) |
| | | self.UnlockButton = unpackframe[4]['value']['raw'] |
| | | print(unpackframe[4]["name"], unpackframe[4]['value']['raw']) |
| | | # print(unpackframe[4]['value']['raw']) |
| | | self.position = unpackframe[7]['value']['raw'] |
| | | print(unpackframe[7]["name"], unpackframe[7]['value']['raw']) |
| | | input_signal = ProjectDBC.decode_message(id, frame) |
| | | # part_str = str(input_signal['SA1_Status_ParkButtonReq']) |
| | | # print(type(part_str)) |
| | | # if input_signal['SA1_Status_ParkButtonReq'] == 'No request': |
| | | # print('yes') |
| | | # print(SA1_Status_ParkButtonReq_dic[part_str]) |
| | | self.Pbutton = SA1_Status_ParkButtonReq_dic[str( |
| | | input_signal['SA1_Status_ParkButtonReq'])] |
| | | self.UnlockButton = SA1_Status_UnlockButtonReq_dic[str( |
| | | input_signal['SA1_Status_UnlockButtonReq'])] |
| | | self.position = SA1_Status_GearShftPosReq_dic[str( |
| | | input_signal['SA1_Status_GearShftPosReq'])] |
| | | |
| | | def PackFrame(self, dic): |
| | | data = self.SA1_message.encode({ |
| | | 'SA1_Status_PRNDL': |
| | | 0, |
| | | 'SA1_Status_GearShftPosReq': |
| | | SA1_Status_GearShftPosReq_dic[self.position], |
| | | 'SA1_Status_ParkButtonReq': |
| | | SA1_Status_ParkButtonReq_dic[self.Pbutton], |
| | | "SA1_ShifterManualSignal": |
| | | 0, |
| | | "SA1_ShifterModeSignal": |
| | | 0, |
| | | "SA1_Status_ShftSensSng_Fault": |
| | | 0, |
| | | "SA1_IND_ShifterMisUsd": |
| | | 0, |
| | | "SA1_Live_counter": |
| | | 1, |
| | | "SA1_Status_UnlockButtonReq": |
| | | SA1_Status_UnlockButtonReq_dic[self.UnlockButton], |
| | | "SA1_Status_EcoShifterModeReq": |
| | | 0, |
| | | "SA1_Status_RqGearPosInV": |
| | | 0xf, |
| | | "SA1_Status_ShiftPosValidFlag": |
| | | 0, |
| | | }) |
| | | return data |
| | | |
| | | |
| | | class VehicleClass(): |
| | | |
| | | def __init__(self): |
| | | self.Odm = 0 |
| | | self.speed = 0 |
| | | self.brake = 0 |
| | | self.ShiftLeverPos = 'P' |
| | | self.pre_ShiftLeverPos = 'P' |
| | | self.max_pos = 'Shifter position Zero' |
| | | self.IC1_message = ProjectDBC.get_message_by_name('IC1') |
| | | self.TCU2_message = ProjectDBC.get_message_by_name('TCU2') |
| | | self.ABS1_message = ProjectDBC.get_message_by_name('ABS1') |
| | | self.Engine2_message = ProjectDBC.get_message_by_name('Engine2') |
| | | |
| | | def pack_IC1(self, odm): |
| | | self.Odm = odm |
| | | data = self.IC1_message.encode({"odometer_value": odm}) |
| | | return data |
| | | |
| | | def pack_TCU2(self, shiftpos): |
| | | #from value get key |
| | | self.ShiftLeverPos = [ |
| | | k for k, v in TCU2_ShiterLevel_dic.items() if v == shiftpos |
| | | ][0] |
| | | data = self.TCU2_message.encode({ |
| | | "ShiftLeverPos": shiftpos, |
| | | "TCUDrivingMode": 0, |
| | | "ActualGear": 0 |
| | | }) |
| | | return data |
| | | |
| | | def pack_ABS1(self, speed): |
| | | self.speed = speed |
| | | data = self.ABS1_message.encode({"vehicle_speed": speed}) |
| | | return data |
| | | |
| | | def pack_Engine2(self, brake): |
| | | self.brake = brake |
| | | data = self.Engine2_message.encode({"brake_pedal_status ": brake}) |
| | | return data |
| | | |
| | | def ShiftLogic(self, shift: ShifterClass): |
| | | reqpos = 0 |
| | | if shift.Pbutton == SA1_Status_ParkButtonReq_dic[ |
| | | 'Driver request park button']: |
| | | reqpos = TCU2_ShiterLevel_dic['P'] |
| | | self.pre_ShiftLeverPos = "P" |
| | | self.max_pos = 'Shifter position Zero' |
| | | elif (shift.position >= SA1_Status_GearShftPosReq_dic['M-']) and ( |
| | | shift.position <= SA1_Status_GearShftPosReq_dic['M']): |
| | | reqpos = TCU2_ShiterLevel_dic['M'] |
| | | self.pre_ShiftLeverPos = "P" |
| | | self.max_pos = 'Shifter position Zero' |
| | | else: |
| | | if shift.position is not SA1_Status_GearShftPosReq_dic[ |
| | | 'Shifter position Zero']: |
| | | self.max_pos = ShiftMaxPosMap_dic[self.max_pos][shift.position] |
| | | reqpos = GearShiftMap_dic[self.pre_ShiftLeverPos][self.max_pos] |
| | | else: |
| | | reqpos = GearShiftMap_dic[self.pre_ShiftLeverPos][self.max_pos] |
| | | self.max_pos = 'Shifter position Zero' |
| | | self.pre_ShiftLeverPos = [ |
| | | k for k, v in TCU2_ShiterLevel_dic.items() if v == reqpos |
| | | ][0] |
| | | data = self.pack_TCU2(reqpos) |
| | | return data |
| | |
| | | self.fun_rxId = 0 |
| | | |
| | | |
| | | class ShifterPosition(IntEnum): |
| | | ShiftPosZero = 0 |
| | | ShiftPosX2 = 2 |
| | | ShiftPosX1 = 3 |
| | | ShiftPosY1 = 4 |
| | | ShiftPosY2 = 5 |
| | | ShiftPosNotInit = 8 |
| | | ShiftPosM_Minus = 0xc |
| | | ShiftPosM_Plus = 0xd |
| | | ShiftPosM = 0xe |
| | | ShiftNotAvailable = 0xF |
| | | # class ShifterPosition(IntEnum): |
| | | # ShiftPosZero = 0 |
| | | # ShiftPosX2 = 2 |
| | | # ShiftPosX1 = 3 |
| | | # ShiftPosY1 = 4 |
| | | # ShiftPosY2 = 5 |
| | | # ShiftPosNotInit = 8 |
| | | # ShiftPosM_Minus = 0xc |
| | | # ShiftPosM_Plus = 0xd |
| | | # ShiftPosM = 0xe |
| | | # ShiftNotAvailable = 0xF |
| | | SA1_Status_ParkButtonReq_dic = { |
| | | 'No request': 0x0, |
| | | 'Driver request park button': 1, |
| | | 'Park Button fault': 2, |
| | | 'Reserved': 3 |
| | | } |
| | | SA1_Status_UnlockButtonReq_dic = { |
| | | 'No request': 0, |
| | | 'Driver request unlock button': 1 |
| | | } |
| | | |
| | | SA1_Status_GearShftPosReq_dic = { |
| | | 'Shifter position Zero': 0x0, |
| | | 'Reserved1': 0x1, |
| | | 'X2 forward twice': 0x2, |
| | | 'X1 forward once': 0x3, |
| | | 'Y1 backward once': 0x4, |
| | | 'Y2 backward twice': 0x5, |
| | | 'Reserved6': 0x6, |
| | | 'Reserved7': 0x7, |
| | | 'Shifter not initialized': 0x8, |
| | | 'M-': 0xC, |
| | | 'M+': 0xD, |
| | | 'M': 0xE, |
| | | 'Signal not available': 0xF |
| | | } |
| | | |
| | | DID_dic = { |
| | | "ProgrammingCounter": 0x2100, |
| | |
| | | "ReadFingerPrint": 0xf15b, |
| | | "IndicationLEDControl": 0x8101 |
| | | } |
| | | |
| | | TCU2_ShiterLevel_dic = { |
| | | 'P': 0x0, |
| | | 'D': 0x1, |
| | | 'N': 0x2, |
| | | 'R': 0x3, |
| | | 'M': 0x4, |
| | | 'M+': 0x5, |
| | | 'M-': 0x6, |
| | | "Invalid": 7 |
| | | } |
| | | |
| | | GearShiftMap_dic = { |
| | | "P": { |
| | | 'X2 forward twice': 0x3, |
| | | 'X1 forward once': 2, |
| | | 'Shifter position Zero': 0x0, |
| | | 'Y1 backward once': 0x2, |
| | | 'Y2 backward twice': 1 |
| | | }, |
| | | "R": { |
| | | 'X2 forward twice': 0x3, |
| | | 'X1 forward once': 3, |
| | | 'Shifter position Zero': 0x3, |
| | | 'Y1 backward once': 0x2, |
| | | 'Y2 backward twice': 1 |
| | | }, |
| | | "N": { |
| | | 'X2 forward twice': 0x3, |
| | | 'X1 forward once': 3, |
| | | 'Shifter position Zero': 2, |
| | | 'Y1 backward once': 1, |
| | | 'Y2 backward twice': 1 |
| | | }, |
| | | "D": { |
| | | 'X2 forward twice': 0x3, |
| | | 'X1 forward once': 2, |
| | | 'Shifter position Zero': 1, |
| | | 'Y1 backward once': 1, |
| | | 'Y2 backward twice': 1 |
| | | } |
| | | } |
| | | # 'X2 forward twice': 0x2, |
| | | # 'X1 forward once': 0x3, |
| | | # 'Y1 backward once': 0x4, |
| | | # 'Y2 backward twice': 0x5, |
| | | ShiftMaxPosMap_dic = { |
| | | 'Shifter position Zero': { |
| | | 0: 'Shifter position Zero', |
| | | 2: 'X2 forward twice', |
| | | 3: 'X1 forward once', |
| | | 4: 'Y1 backward once', |
| | | 5: 'Y2 backward twice' |
| | | }, |
| | | 'X1 forward once': { |
| | | 0: 'X1 forward once', |
| | | 2: 'X2 forward twice', |
| | | 3: 'X1 forward once', |
| | | 4: 'Y1 backward once', |
| | | 5: 'Y2 backward twice' |
| | | }, |
| | | 'X2 forward twice': { |
| | | 0: 'X2 forward twice', |
| | | 2: 'X2 forward twice', |
| | | 3: 'X2 forward twice', |
| | | 4: 'Y1 backward once', |
| | | 5: 'Y2 backward twice' |
| | | }, |
| | | 'Y1 backward once': { |
| | | 0: 'Y1 backward once', |
| | | 2: 'X2 forward twice', |
| | | 3: 'X1 forward once', |
| | | 4: 'Y1 backward once', |
| | | 5: 'Y2 backward twice' |
| | | }, |
| | | 'Y2 backward twice': { |
| | | 0: 'Y2 backward twice', |
| | | 2: 'X2 forward twice', |
| | | 3: 'X1 forward once', |
| | | 4: 'Y2 backward twice', |
| | | 5: 'Y2 backward twice' |
| | | } |
| | | } |
| | | |
| | | # {GearDisplay_R, GearDisplay_R, GearDisplay_R, GearDisplay_R}, |
| | | # {GearDisplay_N, GearDisplay_R, GearDisplay_R, GearDisplay_N}, |
| | | # {GearDisplay_P, GearDisplay_R, GearDisplay_N, GearDisplay_D}, |
| | | # {GearDisplay_N, GearDisplay_N, GearDisplay_D, GearDisplay_D}, |
| | | # {GearDisplay_D, GearDisplay_D, GearDisplay_D, GearDisplay_D} |
| | |
| | | raw_message.TimeStamp = (c_uint)(0) |
| | | raw_message.TimeFlag = (c_ubyte)(0) |
| | | raw_message.SendType = (c_ubyte)(1) |
| | | raw_message.RemoteFlag = (c_ubyte)(msg.is_remote_frame) |
| | | raw_message.RemoteFlag = False |
| | | raw_message.ExternFlag = (c_ubyte)(msg.is_extended_id) |
| | | raw_message.DataLen = (c_ubyte)(msg.dlc) |
| | | raw_message.Data = (c_ubyte * 8)(*[c_ubyte(c) for c in msg.data]) |
| | |
| | | <string notr="true"/> |
| | | </property> |
| | | <property name="currentIndex"> |
| | | <number>1</number> |
| | | <number>2</number> |
| | | </property> |
| | | <widget class="QWidget" name="tab"> |
| | | <attribute name="title"> |
| | |
| | | FunctionButton_activeStyle = "background-color: rgb(0, 255, 0);\n" + "color: rgb(255,255,255); \n" + "border-radius: 30px; \n" + "font: 9pt \"AcadEref\";\n" + "border-style: outset;" |
| | | FunctionButton_faultStyle = "background-color: rgb(255,0, 0);\n" + "color: rgb(255,255,255); \n" + "border-radius: 30px; \n" + "font: 9pt \"AcadEref\";\n" + "border-style: outset;" |
| | | |
| | | Color_activeStyle = "background-color: rgb(0, 255, 0);\n" |
| | | Color_defaultStyle = "background-color: rgb(123, 123, 123);\n" |
| | | Style_dic = { |
| | | 0: FunctionButton_defaultStyle, |
| | | 1: FunctionButton_activeStyle, |
| | | 2: FunctionButton_faultStyle |
| | | } |
| | | |
| | | ColorStyle_dic = {0: Color_defaultStyle, 1: Color_activeStyle} |
| | |
| | | # # meg = Message() |
| | | # # msg = VCI_CAN_OBJ() |
| | | from ast import arg |
| | | import encodings |
| | | import threading |
| | | from tkinter.tix import Tree |
| | | from USBCAN import * |
| | |
| | | from multiprocessing import Process, Queue, Value, Pipe |
| | | import datetime |
| | | from ShifterDefine import * |
| | | import cantools |
| | | from pprint import pprint |
| | | # def rece_msg(bus): |
| | | # msg = bus.Receive(0.1) |
| | | # if msg[0] is not None: |
| | |
| | | # # w.show() |
| | | |
| | | # sys.exit(app.exec_()) |
| | | |
| | | dbc = cantools.database.load_file("DBC/SX7H.dbc") |
| | | # print(dbc.messages) |
| | | sa_message = dbc.get_message_by_name('SA1') |
| | | # print(sa_message) |
| | | # pprint(sa_message.signals) |
| | | frame = [0x00, 0x0A, 0x00, 0xF0, 0, 0, 0, 0] |
| | | input_signal = dbc.decode_message(0x420, frame) |
| | | part_str = str(input_signal['SA1_Status_ParkButtonReq']) |
| | | pprint(part_str) |
| | | if input_signal['SA1_Status_ParkButtonReq'] == 'No request': |
| | | print('yes') |
| | | |
| | | data = sa_message.encode({ |
| | | 'SA1_Status_PRNDL': 0, |
| | | 'SA1_Status_GearShftPosReq': 0, #'Shifter position Zero', |
| | | 'SA1_Status_ParkButtonReq': 2, |
| | | "SA1_ShifterManualSignal": 0, |
| | | "SA1_ShifterModeSignal": 1, |
| | | "SA1_Status_ShftSensSng_Fault": 0, |
| | | "SA1_IND_ShifterMisUsd": 0, |
| | | "SA1_Live_counter": 1, |
| | | "SA1_Status_UnlockButtonReq": 1, |
| | | "SA1_Status_EcoShifterModeReq": 0, |
| | | "SA1_Status_RqGearPosInV": 0xf, |
| | | "SA1_Status_ShiftPosValidFlag": 0, |
| | | }) |
| | | # print(data) |
| | | # print(SA1_Status_ParkButtonReq_dic['No request']) |
| | |
| | | self.sendQueue = Queue() # can layer send queue |
| | | self.CANtoIsoTPQueue = Queue() # CAN --> isotp |
| | | self.shifter = ShifterClass() |
| | | self.Vehicle = VehicleClass() |
| | | self.devicedescription = HardwreDevice() |
| | | self.windows = QtWidgets.QMainWindow() |
| | | self.UI = Ui_MainWindow() |
| | | self.UI.setupUi(window) |
| | | self._dev_info = None |
| | | self.dbc = cantools.database.load_file("DBC/SX7H.dbc") |
| | | self.can_thread = threading.Thread(target=self.can_thread) |
| | | self.TestPresentTimer = QtCore.QTimer() |
| | | self.TestPresentTimer.timeout.connect(self.creat_testpresentReq) |
| | |
| | | msg.channel = 0 |
| | | msg.data = [0x02, 0x3e, 0x80, 0, 0, 0, 0, 0] |
| | | msg.is_extended_id = False |
| | | msg.is_remote_frame = False |
| | | self._usbcan.send(msg) |
| | | |
| | | def send_VehiclePosition(self, data=[]): |
| | | msg = Message() |
| | | msg.arbitration_id = 0x10 |
| | | msg.dlc = 8 |
| | | msg.channel = 0 |
| | | msg.data = data |
| | | msg.is_extended_id = False |
| | | msg.is_remote_frame = False |
| | | self._usbcan.send(msg) |
| | | |
| | | def open_close(self): |
| | |
| | | self.UI.pushButton_41.setStyleSheet( |
| | | Style_dic[self.shifter.UnlockButton]) |
| | | self.UI.pushButton_40.setStyleSheet(Style_dic[self.shifter.Pbutton]) |
| | | #X2 |
| | | self.UI.pushButton_37.setStyleSheet( |
| | | Style_dic[self.shifter.position == 2]) |
| | | #X1 |
| | | self.UI.pushButton_38.setStyleSheet( |
| | | Style_dic[self.shifter.position == 3]) |
| | | #Z |
| | | self.UI.pushButton_30.setStyleSheet( |
| | | Style_dic[self.shifter.position == 0]) |
| | | #Y1 |
| | | self.UI.pushButton_33.setStyleSheet( |
| | | Style_dic[self.shifter.position == 4]) |
| | | #Y2 |
| | | self.UI.pushButton_34.setStyleSheet( |
| | | Style_dic[self.shifter.position == 5]) |
| | | #M |
| | | self.UI.pushButton_39.setStyleSheet( |
| | | Style_dic[self.shifter.position == 0xe]) |
| | | #M+ |
| | | self.UI.pushButton_35.setStyleSheet( |
| | | Style_dic[self.shifter.position == 0xd]) |
| | | #M- |
| | | self.UI.pushButton_36.setStyleSheet( |
| | | Style_dic[self.shifter.position == 0xc]) |
| | | self.UI.pushButton_42.setStyleSheet( |
| | | ColorStyle_dic[self.Vehicle.ShiftLeverPos == "P"]) |
| | | self.UI.pushButton_43.setStyleSheet( |
| | | ColorStyle_dic[self.Vehicle.ShiftLeverPos == "D"]) |
| | | self.UI.pushButton_44.setStyleSheet( |
| | | ColorStyle_dic[self.Vehicle.ShiftLeverPos == "N"]) |
| | | self.UI.pushButton_45.setStyleSheet( |
| | | ColorStyle_dic[self.Vehicle.ShiftLeverPos == "R"]) |
| | | |
| | | def _updateRootList(self): |
| | | _dataSize = self.msgQueue.qsize() |
| | |
| | | for i in range(_dataSize): |
| | | receiveNum += 1 |
| | | msg = self.msgQueue.get() |
| | | # self.shifter.FramUnpack(msg.arbitration_id, msg.data) |
| | | if msg.arbitration_id == 0x420: |
| | | self.shifter.FramUnpack(msg.arbitration_id, msg.data) |
| | | resp_data = self.Vehicle.ShiftLogic(self.shifter) |
| | | self.send_VehiclePosition(resp_data) |
| | | formateddata.append(self._formatMsgData( |
| | | receiveNum, msg, True)) # return a data list |
| | | self._insertDataSmooth(data=formateddata, datasize=_dataSize) |
| | | # self.dispShiftstatus() |
| | | self.dispShiftstatus() |
| | | |
| | | def _insertDataSmooth(self, data, datasize): |
| | | # row = 6-datasize |