From 989919a73c5ebd46368991b6c3ff6959e32490b6 Mon Sep 17 00:00:00 2001
From: tao_z <tzj0429@163.com>
Date: Tue, 23 Aug 2022 22:06:32 +0800
Subject: [PATCH] 完善did读取显示

---
 ShifterDefine.py |  208 ++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 195 insertions(+), 13 deletions(-)

diff --git a/ShifterDefine.py b/ShifterDefine.py
index e2e3577..9408d48 100644
--- a/ShifterDefine.py
+++ b/ShifterDefine.py
@@ -1,10 +1,78 @@
-
-
 from enum import Enum, IntEnum
+
 Security_dic = {"0x01请求种子": 1, "0x02发送密钥": 2}
+DTCGroup_dic = {"排放相关": 0, "动力组": 0x100000, "所有组": 0xFFFFFF}
+DTC_Control_dic = {"DTC开": 1, "DTC关": 2}
+ReportBymask_DTC = {'mask_0x0': 0, 'mask_0x1': 1, 'mask_0x8': 8, 'mask_0x9': 9}
+DTC_Dic = {
+    "DTC_B1D0004": {
+        0: 0x009D0004
+    },
+    "DTC_B1D0005": {
+        1: 0x009D0005
+    },
+    "DTC_B1D0006": {
+        2: 0x009D0006
+    },
+    "DTC_B1D0007": {
+        3: 0x009D0007
+    },
+    "DTC_B1D0008": {
+        4: 0x009D0008
+    },
+    "DTC_B1D0009": {
+        5: 0x009D0009
+    },
+    "DTC_B1D000A": {
+        6: 0x009D000A
+    },
+    "DTC_B1D000B": {
+        7: 0x009D000B
+    },
+    "DTC_B1D000C": {
+        8: 0x009D000C
+    },
+    "DTC_B1D0001": {
+        9: 0x009D0001
+    },
+    "DTC_B1D0000": {
+        10: 0x009D0000
+    },
+    "DTC_U007300": {
+        11: 0x00C07300
+    },
+    "DTC_U010100": {
+        12: 0x00C10100
+    },
+}
+DTC_DescriptionDic = {
+    0x009D0004: "hall sensor error",
+    0x009D0005: "P button short to gnd",
+    0x009D0006: "P button short to power",
+    0x009D0007: "P open",
+    0x009D0008: "P stuck",
+    0x009D0009: "Unlock  short to gnd",
+    0x009D000A: "Unlock  short to power",
+    0x009D000B: "Unlock  OPEN",
+    0x009D000C: "Unlock stuck",
+    0x009D0001: "高电压",
+    0x009D0000: "低电压",
+    0x00C07300: "CAN BUS OFF",
+    0x00C10100: "Lost Communication With TCU1 "
+}
+
+DTC_SanpshotDescriptionDic = {
+    0xDF00: "ECU Power Voltage",
+    0xDF01: "Vehicle Speed",
+    0xDF02: "Occurrence Counter",
+    0xDF03: "The  Odometer Of First Malfunction",
+    0xDF04: "The  Odometer Of Last Malfunction",
+    0x1000: "EGSM sensor position"
+}
 
 
 class ShifterCANID():
+
     def __init__(self):
         self.normalid = 0
         self.phy_txId = 0
@@ -12,18 +80,43 @@
         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,
@@ -58,3 +151,92 @@
     "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}

--
Gitblit v1.8.0