Pārlūkot izejas kodu

CAN通信协议处理完成,MTB上位机整体大概完成

huang_chao 1 gadu atpakaļ
vecāks
revīzija
f8451305a3

BIN
.vs/WindowsFormsApplication1/v14/.suo


Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 926 - 4371
WindowsFormsApplication1/Form1.Designer.cs


+ 179 - 55
WindowsFormsApplication1/Form1.cs

@@ -217,8 +217,13 @@ namespace WindowsFormsApplication1
 
         }
 
-
-
+        static int SubBoardsNUM = 6;
+        static int P_ALL_U_NUM = 34;
+        static int P_ALL_T_NUM = 10;
+        TextBox[] textboxs_U = new TextBox[SubBoardsNUM * P_ALL_U_NUM];
+        Label[] lables_U = new Label[SubBoardsNUM * P_ALL_U_NUM];
+        TextBox[] textboxs_T = new TextBox[SubBoardsNUM * P_ALL_T_NUM];
+        Label[] lables_T = new Label[SubBoardsNUM * P_ALL_T_NUM];
         private void Form1_Load(object sender, EventArgs e)
         {
 
@@ -260,15 +265,82 @@ namespace WindowsFormsApplication1
             //controllerChooseFlag = (byte)(comboBox_ControllerChoose.SelectedIndex + 1);
 
             //
-            TextBox[] test = new TextBox[10];
-            for (int i = 0; i < 10; i++)
+
+            FlowLayoutPanel[] flowLayoutPanelS = { flowLayoutPanel_1, flowLayoutPanel_2, flowLayoutPanel_3, flowLayoutPanel_4, flowLayoutPanel_5, flowLayoutPanel_6 };
+            flowLayoutPanel_1.Dock = DockStyle.Fill;
+            //flowLayoutPanel_1.FlowDirection = FlowDirection.TopDown;
+           
+
+            // 循环生成50个lable控件和50个textbox控件
+            for (int i = 0; i < SubBoardsNUM; i++)
             {
+                flowLayoutPanelS[i].WrapContents = true;
+                for (int j = 0; j < P_ALL_U_NUM; j++)
+                {
+                    // 创建lable控件和textbox控件
+                    Label label = new Label();
+                    TextBox textbox = new TextBox();
+                    // 设置lable控件的文本和位置
+
+                    label.Text = "U" + (j + 1).ToString();
+                    label.Location = new Point(0, 0);
+                    label.Size = new Size(25, 15);
+                    // 设置textbox控件的位置和大小
+                    textbox.Location = new Point(label.Width, 0);
+                    textbox.Size = new Size(50, 25);
+
+                    // 创建一个容器控件,用于存放每对lable控件和textbox控件
+                    Panel container = new Panel();
+                    container.Size = new Size(textbox.Width + label.Width + 20, textbox.Height);
+                    container.Controls.Add(label);
+                    container.Controls.Add(textbox);
+                    //container.Margin = new Padding(2,2,2,2);
+                    // 将容器控件添加到FlowLayoutPanel中
+                    flowLayoutPanelS[i].Controls.Add(container);
+
+                    // 每行有五个控件,如果已经添加了五个控件,就换行
+                    if ((j+1) % 7 == 0 || j  == 33)
+                    {
+                        flowLayoutPanelS[i].SetFlowBreak(container, true);
+                    }
+
+                    lables_U[i * 34 + j] = label;
+                    textboxs_U[i * 34 + j] = textbox;
 
+                }
+                for (int j = 0; j < P_ALL_T_NUM; j++)
+                {
+                    // 创建lable控件和textbox控件
+                    Label label = new Label();
+                    TextBox textbox = new TextBox();
+                    // 设置lable控件的文本和位置
+
+                    label.Text = "T" + (j + 1).ToString();
+                    label.Location = new Point(0, 0);
+                    label.Size = new Size(25, 15);
+                    // 设置textbox控件的位置和大小
+                    textbox.Location = new Point(label.Width, 0);
+                    textbox.Size = new Size(50, 25);
+
+                    // 创建一个容器控件,用于存放每对lable控件和textbox控件
+                    Panel container = new Panel();
+                    container.Size = new Size(textbox.Width + label.Width + 20, textbox.Height);
+                    container.Controls.Add(label);
+                    container.Controls.Add(textbox);
+                    //container.Margin = new Padding(2,2,2,2);
+                    // 将容器控件添加到FlowLayoutPanel中
+                    flowLayoutPanelS[i].Controls.Add(container);
+
+                    // 每行有五个控件,如果已经添加了五个控件,就换行
+                    if ((j + 1) % 7 == 0)
+                    {
+                        flowLayoutPanelS[i].SetFlowBreak(container, true);
+                    }
 
-                //test.Size = new System.Drawing.Size(400, 300);
-                test[i] = new TextBox();
-                test[i].Text = "标题" + i.ToString();//设置文本,i的值转成字符串与标题相加
-                test[i].Parent = flowLayoutPanel_1;
+                    lables_T[i * 10 + j] = label;
+                    textboxs_T[i * 10 + j] = textbox;
+                }
+               
             }
 
             comboBox_devtype.SelectedIndex = 1;
@@ -295,12 +367,12 @@ namespace WindowsFormsApplication1
         {
             if (buttStartCan == true)
             {
-                //VCI_CloseDevice(m_devtype, m_devind);
+                VCI_CloseDevice(m_devtype, m_devind);
             }
             //autoSaveFile();
             //UpdateStep = 0xFF;
             isForm1Colsed = true;
-            //setBoxAndButtonEnalbe(false);
+            //setBoxAndButtonEnalbe(false); 
         }
          
         private void button_StartCAN_Click(object sender, EventArgs e)
@@ -308,6 +380,8 @@ namespace WindowsFormsApplication1
             if (buttStartCan == true)
             {
                 buttStartCan = false;
+
+                VCI_CloseDevice(m_devtype, m_devind);
             }
             else
             {
@@ -460,8 +534,7 @@ namespace WindowsFormsApplication1
                         int VCU_BMSCutOffLV = 0;
                         int VCU_AllowChgCtrl = 0;
 
-                        if (VCU_V2B_CMD_AliveConter++ > 15)
-                            VCU_V2B_CMD_AliveConter = 0;
+
                         VCU_BMSHVOnOffReq = comboBox_VCU_BMSHVOnOffReq.SelectedIndex;
 
                         sendObj.Data[1] = (byte)((((VCU_V2B_CMD_AliveConter >> 0) & 0xF) << 0) | (((VCU_BMSHVOnOffReq >> 0) & 0x3) << 4));
@@ -474,9 +547,11 @@ namespace WindowsFormsApplication1
 
                         for (int i = 1; i < 8; i++)
                         {
-                            VCU_V2B_CMD_Checksum ^= sendObj.Data[1];
+                            VCU_V2B_CMD_Checksum ^= sendObj.Data[i];
                         }
                         sendObj.Data[0] = (byte)(((VCU_V2B_CMD_Checksum >> 0) & 0xFF) << 0);
+                        if (++VCU_V2B_CMD_AliveConter >= 15)
+                            VCU_V2B_CMD_AliveConter = 0;
                         break;
                     //tms
                     case 0x18F5C13A:
@@ -515,10 +590,19 @@ namespace WindowsFormsApplication1
                         break;
                     //rcb
                     case 0x18FFCBF3:
-                        int RCB_encryp1 = 0;
-                        int RCB_encryp2 = 0;
-                        int RCB_encryp3 = 0;
-                        int RCB_encryp4 = 0;
+                        UInt16 RCB_encryp1 = (UInt16)BMS_encryp1;
+                        UInt16 RCB_encryp2 = (UInt16)BMS_encryp2;
+                        UInt16 RCB_encryp3 = (UInt16)BMS_encryp3;
+                        UInt16 RCB_encryp4 = (UInt16)BMS_encryp4;
+                        if(comboBox_encryptionEnable.SelectedIndex == 0)
+                        {
+                            RCB_encryp1 = encryptionAlgorithm(RCB_encryp1);
+                            RCB_encryp2 = encryptionAlgorithm(RCB_encryp2);
+                            RCB_encryp3 = encryptionAlgorithm(RCB_encryp3);
+                            RCB_encryp4 = encryptionAlgorithm(RCB_encryp4);
+                        }
+
+
                         sendObj.Data[0] = (byte)(((RCB_encryp1 >> 0) & 0xFF) << 0);
                         sendObj.Data[1] = (byte)(((RCB_encryp1 >> 8) & 0xFF) << 0);
                         sendObj.Data[2] = (byte)(((RCB_encryp2 >> 0) & 0xFF) << 0);
@@ -535,14 +619,15 @@ namespace WindowsFormsApplication1
                         int Change_BattConSts = 0;
 
                         int Message_Checksum = 0;
-                        if (Message_Counter++ > 15)
-                            Message_Counter = 0;
+
                         Message_Checksum = Message_Counter;
-                        LockingPinStsFB = comboBox_LockingPinStsFB.SelectedIndex = 0;
+                        LockingPinStsFB = comboBox_LockingPinStsFB.SelectedIndex;
                         Change_BattConSts = comboBox_Change_BattConSts.SelectedIndex;
 
                         sendObj.Data[1] = (byte)((((LockingPinStsFB >> 0) & 0x3) << 0) | (((Change_BattConSts >> 0) & 0x3) << 2));
                         sendObj.Data[7] = (byte)((((Message_Counter >> 0) & 0xF) << 0) | (((Message_Checksum >> 0) & 0xF) << 4));
+                        if (++Message_Counter >= 15)
+                            Message_Counter = 0;
                         break;
                     default:
                         break;
@@ -551,6 +636,10 @@ namespace WindowsFormsApplication1
             }
 
         }
+        int BMS_encryp1 = 0;
+        int BMS_encryp2 = 0;
+        int BMS_encryp3 = 0;
+        int BMS_encryp4 = 0;
         void CANRec(UInt32 ID, VCI_CAN_OBJ sendObj)
         {
             unsafe
@@ -559,9 +648,9 @@ namespace WindowsFormsApplication1
                 {
 
                     case 0x1801D0F3:
-                        string[] strs_BMS_CutOffHVReq = { "0:预留 ","请求下高压","不请求下高压","无效 "};
+                        string[] strs_BMS_CutOffHVReq = { "预留 ","请求下高压","不请求下高压","无效 "};
                         int BMS_CutOffHVReq = (byte)((((sendObj.Data[0] >> 2) & 0x3) << 0));        //是否请求下高压
-                        BMS_CutOffHVReq = BMS_CutOffHVReq > strs_BMS_CutOffHVReq.Length ? BMS_CutOffHVReq : strs_BMS_CutOffHVReq.Length - 1;
+                        BMS_CutOffHVReq = BMS_CutOffHVReq < strs_BMS_CutOffHVReq.Length ? BMS_CutOffHVReq : strs_BMS_CutOffHVReq.Length - 1;
                         textBox_BMS_CutOffHVReq.Text = strs_BMS_CutOffHVReq[BMS_CutOffHVReq];
                         //int BMS_PmtCutoffLVFb = (byte)((((sendObj.Data[0]>>4)&0x3)<<0));       //BMS允许下低压
                         //int BMS_EmergCutoffHVReq = (byte)((((sendObj.Data[0]>>6)&0x3)<<0));    //BMS紧急下高压请求
@@ -593,13 +682,13 @@ namespace WindowsFormsApplication1
                         int BMS_ChgPosConnSts2 = (byte)((((sendObj.Data[2] >> 6) & 0x3) << 0));    //充电正2继电器状态
                         int BMS_ChgNegConnSts2 = (byte)((((sendObj.Data[3] >> 0) & 0x3) << 0));    //充电负2继电器状态
 
-                        BMS_MainPosConnSts = BMS_MainPosConnSts > BMS_ConnSts.Length ? BMS_MainPosConnSts : BMS_ConnSts.Length - 1;
-                        BMS_MainNegConnSts = BMS_MainNegConnSts > BMS_ConnSts.Length ? BMS_MainNegConnSts : BMS_ConnSts.Length - 1;
-                        BMS_ChgPosConnSts1 = BMS_ChgPosConnSts1 > BMS_ConnSts.Length ? BMS_ChgPosConnSts1 : BMS_ConnSts.Length - 1;
-                        BMS_PreChgConnSts = BMS_PreChgConnSts > BMS_ConnSts.Length ? BMS_PreChgConnSts : BMS_ConnSts.Length - 1;
-                        BMS_ChgNegConnSts1 = BMS_ChgNegConnSts1 > BMS_ConnSts.Length ? BMS_ChgNegConnSts1 : BMS_ConnSts.Length - 1;
-                        BMS_ChgPosConnSts2 = BMS_ChgPosConnSts2 > BMS_ConnSts.Length ? BMS_ChgPosConnSts2 : BMS_ConnSts.Length - 1;
-                        BMS_ChgNegConnSts2 = BMS_ChgNegConnSts2 > BMS_ConnSts.Length ? BMS_ChgNegConnSts2 : BMS_ConnSts.Length - 1;
+                        BMS_MainPosConnSts = BMS_MainPosConnSts < BMS_ConnSts.Length ? BMS_MainPosConnSts : BMS_ConnSts.Length - 1;
+                        BMS_MainNegConnSts = BMS_MainNegConnSts < BMS_ConnSts.Length ? BMS_MainNegConnSts : BMS_ConnSts.Length - 1;
+                        BMS_ChgPosConnSts1 = BMS_ChgPosConnSts1 < BMS_ConnSts.Length ? BMS_ChgPosConnSts1 : BMS_ConnSts.Length - 1;
+                        BMS_PreChgConnSts = BMS_PreChgConnSts < BMS_ConnSts.Length ? BMS_PreChgConnSts : BMS_ConnSts.Length - 1;
+                        BMS_ChgNegConnSts1 = BMS_ChgNegConnSts1 < BMS_ConnSts.Length ? BMS_ChgNegConnSts1 : BMS_ConnSts.Length - 1;
+                        BMS_ChgPosConnSts2 = BMS_ChgPosConnSts2 < BMS_ConnSts.Length ? BMS_ChgPosConnSts2 : BMS_ConnSts.Length - 1;
+                        BMS_ChgNegConnSts2 = BMS_ChgNegConnSts2 < BMS_ConnSts.Length ? BMS_ChgNegConnSts2 : BMS_ConnSts.Length - 1;
 
                         textBox_BMS_MainPosConnSts.Text = BMS_ConnSts[BMS_MainPosConnSts];
                         textBox_BMS_MainNegConnSts.Text = BMS_ConnSts[BMS_MainNegConnSts];
@@ -642,11 +731,11 @@ namespace WindowsFormsApplication1
                         int BMS_GBT32960FltNum = (byte)((((sendObj.Data[7] >> 3) & 0x1F) << 0));    //故障数目
                         int BMS_BattCurrentSts = (byte)((((sendObj.Data[1] >> 4) & 0x3) << 0));    //BMS当前工作状态
 
-                        BMS_FaultLevel = BMS_FaultLevel > strs_BMS_FaultLevel.Length ? BMS_BattCurrentSts : strs_BMS_FaultLevel.Length - 1;
+                        BMS_FaultLevel = BMS_FaultLevel < strs_BMS_FaultLevel.Length ? BMS_FaultLevel : strs_BMS_FaultLevel.Length - 1;
                         textBox_BMS_FaultLevel.Text = strs_BMS_FaultLevel[BMS_FaultLevel];
 
-                        textBox_BMS_GBT32960FltNum.Text = textBox_BMS_GBT32960FltNum.ToString();
-                        BMS_BattCurrentSts = BMS_BattCurrentSts > sts_BMS_BattCurrentSts.Length ? BMS_BattCurrentSts : sts_BMS_BattCurrentSts.Length - 1;
+                        textBox_BMS_GBT32960FltNum.Text = BMS_GBT32960FltNum.ToString();
+                        BMS_BattCurrentSts = BMS_BattCurrentSts < sts_BMS_BattCurrentSts.Length ? BMS_BattCurrentSts : sts_BMS_BattCurrentSts.Length - 1;
                         textBox_BMS_BattCurrentSts.Text = sts_BMS_BattCurrentSts[BMS_BattCurrentSts];
                         /*
                         int BMS_B2V_ST1Checksum = (byte)((((sendObj.Data[0]>>0)&0xFF)<<0));    //校验
@@ -690,7 +779,7 @@ namespace WindowsFormsApplication1
                         textBox_BMS_BattSOC.Text = ((BMS_BattSOC + 0.0) * 0.4).ToString("F2");
                         textBox_BMS_BattSOH.Text = ((BMS_BattSOH + 0.0) * 0.4).ToString("F2");
                         textBox_BMS_BattCurr.Text = ((BMS_BattCurr + 0.0) * 0.1 - 2000.0).ToString("F2");
-                        textBox_BMS_MaxPmtDischgCurr.Text = ((BMS_BattCurr + 0.0) * 0.1).ToString();
+                        textBox_BMS_MaxPmtDischgCurr.Text = ((BMS_MaxPmtDischgCurr + 0.0) * 0.1).ToString();
 
                         break;
                     case 0x1883D0F3:
@@ -710,8 +799,8 @@ namespace WindowsFormsApplication1
                         int BMS_BattMaxTemp = (byte)((((sendObj.Data[0] >> 0) & 0xFF) << 0));    //电芯温度最大值
                         int BMS_BattMinTemp = (byte)((((sendObj.Data[1] >> 0) & 0xFF) << 0));    //电芯温度最小值
 
-                        textBox_BMS_BattMaxTemp.Text = BMS_BattMaxTemp.ToString();
-                        textBox_BMS_BattMinTemp.Text = BMS_BattMinTemp.ToString();
+                        textBox_BMS_BattMaxTemp.Text = (BMS_BattMaxTemp - 40).ToString();
+                        textBox_BMS_BattMinTemp.Text = (BMS_BattMinTemp - 40).ToString();
                         /*int BMS_Cell_Avg_Temp = (byte)((((sendObj.Data[2]>>0)&0xFF)<<0));    //电芯温度平均值
                         int BMS_MaxTemp1PackNum = (byte)((((sendObj.Data[3]>>0)&0xFF)<<0));    //电芯温度最大值所在CSC编号
                         int BMS_MaxTemp1SnsNum = (byte)((((sendObj.Data[4]>>0)&0xFF)<<0));    //电芯温度最大值所在CSC内温度探针编号
@@ -734,10 +823,10 @@ namespace WindowsFormsApplication1
                     case 0x1888D0F3:
                         //int BMS_BattTermVolOutMainPos = (UInt16)((((sendObj.Data[0]>>0)&0xFF)<<0)|(((sendObj.Data[1]>>0)&0xFF)<<8));    //主正继电器外侧电池端电压
                         //int BMS_BattTermVolOutMainNeg = (UInt16)((((sendObj.Data[2]>>0)&0xFF)<<0)|(((sendObj.Data[3]>>0)&0xFF)<<8));    //主负继电器外侧电池端电压
-                        string[] strs_BMS_DCChgPlugSts = { "未连接", "仅充电口A连接", "仅充电口B连接", "充电口A和B充都连接"};
-                        string[] strs_BMS_ChgSts = { "可以充电", "正在充电", "充电结束", "充电故障" };
-                        string[] strs_BMS_CnctSt = { "车", "站" };
-                        string[] strs_BMS_chrgIReq = { "30s", "60s" };
+                        string[] strs_BMS_DCChgPlugSts = { "未连接", "仅充电口A连接", "仅充电口B连接", "充电口A和B充都连接", "ERROR"};
+                        string[] strs_BMS_ChgSts = { "可以充电", "正在充电", "充电结束", "充电故障" , "ERROR"};
+                        string[] strs_BMS_CnctSt = { "车", "站" , "ERROR"};
+                        string[] strs_BMS_chrgIReq = { "30s", "60s" , "ERROR"};
 
                         int BMS_DCChgPlugSts = (byte)((((sendObj.Data[4] >> 0) & 0x7) << 0));    //充电枪连接状态
                         int BMS_ChgSts = (byte)((((sendObj.Data[4] >> 5) & 0x7) << 0));    //充电状态
@@ -745,26 +834,41 @@ namespace WindowsFormsApplication1
                         //int BMS_ChgMode = (byte)((((sendObj.Data[4]>>3)&0x3)<<0));    //充电模式
 
                         int BMS_CnctSt = (byte)((((sendObj.Data[5] >> 4) & 0x1) << 0));    //BMS连接状态
-                                                                                           //int BMS_BattPulseTime = (byte)((((sendObj.Data[5]>>5)&0x7)<<0));    //脉冲时间
+                        //int BMS_BattPulseTime = (byte)((((sendObj.Data[5]>>5)&0x7)<<0));    //脉冲时间
                         int BMS_chrgIReq = (UInt16)((((sendObj.Data[6] >> 0) & 0xFF) << 0) | (((sendObj.Data[7] >> 0) & 0xFF) << 8));    //充电需求电流
 
-                        BMS_DCChgPlugSts = BMS_DCChgPlugSts > strs_BMS_DCChgPlugSts.Length ? BMS_DCChgPlugSts : strs_BMS_DCChgPlugSts.Length - 1;
+                        BMS_DCChgPlugSts = BMS_DCChgPlugSts < strs_BMS_DCChgPlugSts.Length ? BMS_DCChgPlugSts : strs_BMS_DCChgPlugSts.Length - 1;
                         textBox_BMS_DCChgPlugSts.Text = strs_BMS_DCChgPlugSts[BMS_DCChgPlugSts];
-                        BMS_ChgSts = BMS_ChgSts > strs_BMS_ChgSts.Length ? BMS_ChgSts : strs_BMS_ChgSts.Length - 1;
-                        textBox_BMS_DCChgPlugSts.Text = strs_BMS_ChgSts[BMS_ChgSts];
-                        BMS_CnctSt = BMS_CnctSt > strs_BMS_CnctSt.Length ? BMS_CnctSt : strs_BMS_CnctSt.Length - 1;
-                        textBox_BMS_DCChgPlugSts.Text = strs_BMS_CnctSt[BMS_CnctSt];
-                        BMS_chrgIReq = BMS_chrgIReq > strs_BMS_chrgIReq.Length ? BMS_chrgIReq : strs_BMS_chrgIReq.Length - 1;
-                        textBox_BMS_chrgIReq.Text = strs_BMS_chrgIReq[BMS_chrgIReq];
+                        BMS_ChgSts = BMS_ChgSts < strs_BMS_ChgSts.Length ? BMS_ChgSts : strs_BMS_ChgSts.Length - 1;
+                        textBox_BMS_ChgSts.Text = strs_BMS_ChgSts[BMS_ChgSts];
+                        BMS_CnctSt = BMS_CnctSt < strs_BMS_CnctSt.Length ? BMS_CnctSt : strs_BMS_CnctSt.Length - 1;
+                        textBox_BMS_CnctSt.Text = strs_BMS_CnctSt[BMS_CnctSt];
+
+                        textBox_BMS_chrgIReq.Text = ((BMS_chrgIReq + 0.0) * 0.1 - 2000).ToString("F2"); ;
                         break;
                     case 0x18C1D0F3:
                         int BMS_CellVolMsgCode = (byte)((((sendObj.Data[0] >> 0) & 0xFF) << 0));    //帧序号
                         int BMS_CellVolCSCNum = (byte)((((sendObj.Data[1] >> 0) & 0xFF) << 0));    //CSC 编号
+                        
                         int BMS_CellVolt1 = (UInt16)((((sendObj.Data[2] >> 0) & 0xFF) << 0) | (((sendObj.Data[3] >> 0) & 0xFF) << 8));    //单体电池电压(V1)
                         int BMS_CellVolt2 = (UInt16)((((sendObj.Data[4] >> 0) & 0xFF) << 0) | (((sendObj.Data[5] >> 0) & 0xFF) << 8));    //单体电池电压(V2)
                         int BMS_CellVolt3 = (UInt16)((((sendObj.Data[6] >> 0) & 0xFF) << 0) | (((sendObj.Data[7] >> 0) & 0xFF) << 8));    //单体电池电压(V3)
-
-
+                        int[] bmsValue = { BMS_CellVolt1, BMS_CellVolt2, BMS_CellVolt3 };
+                        if (BMS_CellVolMsgCode < ((SubBoardsNUM * P_ALL_U_NUM) / 3))
+                        {
+                            for (int i = 0; i < 3; i++)
+                            {
+                                textboxs_U[BMS_CellVolMsgCode * 3 + i].Text = (((bmsValue[i] + 0.0) * 0.001)).ToString("F3");
+                            }
+                        }
+                        else if(BMS_CellVolMsgCode < (SubBoardsNUM * P_ALL_U_NUM) / 3 + (((SubBoardsNUM * P_ALL_U_NUM)) % 3 > 0 ? 1 : 0))
+                        {
+                            for(int i = 0; i < (((SubBoardsNUM * P_ALL_U_NUM)) % 3); i++)
+                            {
+                                textboxs_U[((SubBoardsNUM * P_ALL_U_NUM) / 3 * 3) + i].Text = (((bmsValue[i] + 0.0) * 0.001)).ToString("F3");
+                            }
+                        }
+                            
                         //int BCUCellU[BMS_CellVolMsgCode * 3 - 3]=BMS_CellVolt1*0.001;
                         //int BCUCellU[BMS_CellVolMsgCode * 3 - 2]=BMS_CellVolt2*0.001;
                         //int BCUCellU[BMS_CellVolMsgCode * 3 - 1]=BMS_CellVolt3*0.001;
@@ -778,6 +882,22 @@ namespace WindowsFormsApplication1
                         int BMS_BattTemp4 = (byte)((((sendObj.Data[5] >> 0) & 0xFF) << 0));    //温度探针4对应的温度值
                         int BMS_BattTemp5 = (byte)((((sendObj.Data[6] >> 0) & 0xFF) << 0));    //温度探针5对应的温度值
                         int BMS_BattTemp6 = (byte)((((sendObj.Data[7] >> 0) & 0xFF) << 0));    //温度探针6对应的温度值
+
+                        int[] tempValue = { BMS_BattTemp1, BMS_BattTemp2, BMS_BattTemp3, BMS_BattTemp4, BMS_BattTemp5, BMS_BattTemp6 };
+                        if (BMS_TempMsgCode < ((SubBoardsNUM * P_ALL_T_NUM) / 6))
+                        {
+                            for (int i = 0; i < 6; i++)
+                            {
+                                textboxs_T[BMS_TempMsgCode * 6 + i].Text = (tempValue[i] - 40).ToString();
+                            }
+                        }
+                        else if (BMS_TempMsgCode < (SubBoardsNUM * P_ALL_T_NUM) / 6 + (((SubBoardsNUM * P_ALL_T_NUM)) % 6 > 0 ? 1 : 0))
+                        {
+                            for (int i = 0; i < (((SubBoardsNUM * P_ALL_T_NUM)) % 6); i++)
+                            {
+                                textboxs_T[((SubBoardsNUM * P_ALL_T_NUM) / 6 * 6) + i].Text = (tempValue[i] - 40).ToString();
+                            }
+                        }
                         // int BCUModT[BMS_TempMsgCode * 6 - 6]=BMS_BattTemp1-40;
                         // int BCUModT[BMS_TempMsgCode * 6 - 5]=BMS_BattTemp1-40;
                         // int BCUModT[BMS_TempMsgCode * 6 - 4]=BMS_BattTemp1-40;
@@ -802,10 +922,11 @@ namespace WindowsFormsApplication1
 
                         break;
                     case 0x18FFF3CB:
-                        int BMS_encryp1 = (byte)((((sendObj.Data[0] >> 0) & 0xFF) << 0));    //BMS认证数据1
-                        int BMS_encryp2 = (byte)((((sendObj.Data[1] >> 0) & 0xFF) << 0));    //BMS认证数据2
-                        int BMS_encryp3 = (byte)((((sendObj.Data[2] >> 0) & 0xFF) << 0));    //BMS认证数据3
-                        int BMS_encryp4 = (byte)((((sendObj.Data[3] >> 0) & 0xFF) << 0));    //BMS认证数据4
+
+                         BMS_encryp1 = (byte)((((sendObj.Data[0] >> 0) & 0xFF) << 0));    //BMS认证数据1
+                         BMS_encryp2 = (byte)((((sendObj.Data[1] >> 0) & 0xFF) << 0));    //BMS认证数据2
+                         BMS_encryp3 = (byte)((((sendObj.Data[2] >> 0) & 0xFF) << 0));    //BMS认证数据3
+                         BMS_encryp4 = (byte)((((sendObj.Data[3] >> 0) & 0xFF) << 0));    //BMS认证数据4
                         break;
                     default:
                         break;
@@ -819,6 +940,7 @@ namespace WindowsFormsApplication1
             UInt16 cipherText = 1;
             UInt32 privateKeyE = 207521;
             UInt16 privateKeyN = 54127;
+            byte c = 1;
             plainText = (UInt16)(plainText % privateKeyN);
             while (privateKeyE > 0)
             {
@@ -828,9 +950,13 @@ namespace WindowsFormsApplication1
                 }
                 privateKeyE = privateKeyE / 2;
                 plainText = (UInt16)((plainText * plainText) % privateKeyN);
+                c++;
             }
+
             return cipherText;
         }
+
+
         int Message_Counter = 0;
 
 
@@ -871,7 +997,5 @@ namespace WindowsFormsApplication1
                 e.Handled = true;
             }
         }
-
-
     }
 }

+ 3 - 0
WindowsFormsApplication1/Form1.resx

@@ -123,4 +123,7 @@
   <metadata name="timer_send.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
     <value>142, 17</value>
   </metadata>
+  <metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+    <value>280, 17</value>
+  </metadata>
 </root>

+ 2 - 2
WindowsFormsApplication1/bin/Debug/WindowsFormsApplication1.application

@@ -7,14 +7,14 @@
     <framework targetVersion="4.5.2" profile="Full" supportedRuntime="4.0.30319" />
   </compatibleFrameworks>
   <dependency>
-    <dependentAssembly dependencyType="install" codebase="WindowsFormsApplication1.exe.manifest" size="4608">
+    <dependentAssembly dependencyType="install" codebase="WindowsFormsApplication1.exe.manifest" size="4607">
       <assemblyIdentity name="WindowsFormsApplication1.exe" version="1.0.0.0" publicKeyToken="0000000000000000" language="neutral" processorArchitecture="msil" type="win32" />
       <hash>
         <dsig:Transforms>
           <dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
         </dsig:Transforms>
         <dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
-        <dsig:DigestValue>8ZG7aNbXVruDqf7boQLg9IdhPOD8xT7qRrzmZScW22Q=</dsig:DigestValue>
+        <dsig:DigestValue>5QaA7DbTrvGTLrr1UitF0kutC8ZNQSdGBOC0nQwlmzo=</dsig:DigestValue>
       </hash>
     </dependentAssembly>
   </dependency>

BIN
WindowsFormsApplication1/bin/Debug/WindowsFormsApplication1.exe


+ 2 - 2
WindowsFormsApplication1/bin/Debug/WindowsFormsApplication1.exe.manifest

@@ -41,14 +41,14 @@
     </dependentAssembly>
   </dependency>
   <dependency>
-    <dependentAssembly dependencyType="install" allowDelayedBinding="true" codebase="WindowsFormsApplication1.exe" size="102912">
+    <dependentAssembly dependencyType="install" allowDelayedBinding="true" codebase="WindowsFormsApplication1.exe" size="48640">
       <assemblyIdentity name="WindowsFormsApplication1" version="1.0.0.0" language="neutral" processorArchitecture="msil" />
       <hash>
         <dsig:Transforms>
           <dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
         </dsig:Transforms>
         <dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
-        <dsig:DigestValue>DhlVjnejdXjFOa3CE50BcnBniIEwZoOvKkEMswf9d5w=</dsig:DigestValue>
+        <dsig:DigestValue>O4zOsaRw7oXOg0Zs1dxpF/sfkJMgVwNtcJxw7Y5bQSE=</dsig:DigestValue>
       </hash>
     </dependentAssembly>
   </dependency>

BIN
WindowsFormsApplication1/bin/Debug/WindowsFormsApplication1.pdb


+ 2 - 2
WindowsFormsApplication1/bin/Debug/WindowsFormsApplication1.vshost.application

@@ -7,14 +7,14 @@
     <framework targetVersion="4.5.2" profile="Full" supportedRuntime="4.0.30319" />
   </compatibleFrameworks>
   <dependency>
-    <dependentAssembly dependencyType="install" codebase="WindowsFormsApplication1.exe.manifest" size="4608">
+    <dependentAssembly dependencyType="install" codebase="WindowsFormsApplication1.exe.manifest" size="4607">
       <assemblyIdentity name="WindowsFormsApplication1.exe" version="1.0.0.0" publicKeyToken="0000000000000000" language="neutral" processorArchitecture="msil" type="win32" />
       <hash>
         <dsig:Transforms>
           <dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
         </dsig:Transforms>
         <dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
-        <dsig:DigestValue>8ZG7aNbXVruDqf7boQLg9IdhPOD8xT7qRrzmZScW22Q=</dsig:DigestValue>
+        <dsig:DigestValue>5QaA7DbTrvGTLrr1UitF0kutC8ZNQSdGBOC0nQwlmzo=</dsig:DigestValue>
       </hash>
     </dependentAssembly>
   </dependency>

+ 2 - 2
WindowsFormsApplication1/bin/Debug/WindowsFormsApplication1.vshost.exe.manifest

@@ -41,14 +41,14 @@
     </dependentAssembly>
   </dependency>
   <dependency>
-    <dependentAssembly dependencyType="install" allowDelayedBinding="true" codebase="WindowsFormsApplication1.exe" size="102912">
+    <dependentAssembly dependencyType="install" allowDelayedBinding="true" codebase="WindowsFormsApplication1.exe" size="48640">
       <assemblyIdentity name="WindowsFormsApplication1" version="1.0.0.0" language="neutral" processorArchitecture="msil" />
       <hash>
         <dsig:Transforms>
           <dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
         </dsig:Transforms>
         <dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
-        <dsig:DigestValue>DhlVjnejdXjFOa3CE50BcnBniIEwZoOvKkEMswf9d5w=</dsig:DigestValue>
+        <dsig:DigestValue>O4zOsaRw7oXOg0Zs1dxpF/sfkJMgVwNtcJxw7Y5bQSE=</dsig:DigestValue>
       </hash>
     </dependentAssembly>
   </dependency>

BIN
WindowsFormsApplication1/bin/Debug/app.publish/WindowsFormsApplication1.exe


BIN
WindowsFormsApplication1/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache


+ 2 - 2
WindowsFormsApplication1/obj/Debug/WindowsFormsApplication1.application

@@ -7,14 +7,14 @@
     <framework targetVersion="4.5.2" profile="Full" supportedRuntime="4.0.30319" />
   </compatibleFrameworks>
   <dependency>
-    <dependentAssembly dependencyType="install" codebase="WindowsFormsApplication1.exe.manifest" size="4608">
+    <dependentAssembly dependencyType="install" codebase="WindowsFormsApplication1.exe.manifest" size="4607">
       <assemblyIdentity name="WindowsFormsApplication1.exe" version="1.0.0.0" publicKeyToken="0000000000000000" language="neutral" processorArchitecture="msil" type="win32" />
       <hash>
         <dsig:Transforms>
           <dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
         </dsig:Transforms>
         <dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
-        <dsig:DigestValue>8ZG7aNbXVruDqf7boQLg9IdhPOD8xT7qRrzmZScW22Q=</dsig:DigestValue>
+        <dsig:DigestValue>5QaA7DbTrvGTLrr1UitF0kutC8ZNQSdGBOC0nQwlmzo=</dsig:DigestValue>
       </hash>
     </dependentAssembly>
   </dependency>

+ 14 - 0
WindowsFormsApplication1/obj/Debug/WindowsFormsApplication1.csproj.FileListAbsolute.txt

@@ -26,3 +26,17 @@ D:\Project\forC#\WindowsFormsApplication1_CAN_OK\WindowsFormsApplication1\obj\De
 D:\Project\forC#\WindowsFormsApplication1_CAN_OK\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.TrustInfo.xml
 D:\Project\forC#\WindowsFormsApplication1_CAN_OK\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.exe.manifest
 D:\Project\forC#\WindowsFormsApplication1_CAN_OK\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.application
+D:\Project\forC#\MTB_SWJ\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.exe.config
+D:\Project\forC#\MTB_SWJ\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.exe
+D:\Project\forC#\MTB_SWJ\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.pdb
+D:\Project\forC#\MTB_SWJ\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.exe.manifest
+D:\Project\forC#\MTB_SWJ\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.application
+D:\Project\forC#\MTB_SWJ\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.exe
+D:\Project\forC#\MTB_SWJ\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.pdb
+D:\Project\forC#\MTB_SWJ\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.csprojResolveAssemblyReference.cache
+D:\Project\forC#\MTB_SWJ\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.Form1.resources
+D:\Project\forC#\MTB_SWJ\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.Properties.Resources.resources
+D:\Project\forC#\MTB_SWJ\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.csproj.GenerateResource.Cache
+D:\Project\forC#\MTB_SWJ\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.TrustInfo.xml
+D:\Project\forC#\MTB_SWJ\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.exe.manifest
+D:\Project\forC#\MTB_SWJ\WindowsFormsApplication1\obj\Debug\WindowsFormsApplication1.application

BIN
WindowsFormsApplication1/obj/Debug/WindowsFormsApplication1.csproj.GenerateResource.Cache


BIN
WindowsFormsApplication1/obj/Debug/WindowsFormsApplication1.exe


+ 2 - 2
WindowsFormsApplication1/obj/Debug/WindowsFormsApplication1.exe.manifest

@@ -41,14 +41,14 @@
     </dependentAssembly>
   </dependency>
   <dependency>
-    <dependentAssembly dependencyType="install" allowDelayedBinding="true" codebase="WindowsFormsApplication1.exe" size="102912">
+    <dependentAssembly dependencyType="install" allowDelayedBinding="true" codebase="WindowsFormsApplication1.exe" size="48640">
       <assemblyIdentity name="WindowsFormsApplication1" version="1.0.0.0" language="neutral" processorArchitecture="msil" />
       <hash>
         <dsig:Transforms>
           <dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
         </dsig:Transforms>
         <dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
-        <dsig:DigestValue>DhlVjnejdXjFOa3CE50BcnBniIEwZoOvKkEMswf9d5w=</dsig:DigestValue>
+        <dsig:DigestValue>O4zOsaRw7oXOg0Zs1dxpF/sfkJMgVwNtcJxw7Y5bQSE=</dsig:DigestValue>
       </hash>
     </dependentAssembly>
   </dependency>

BIN
WindowsFormsApplication1/obj/Debug/WindowsFormsApplication1.pdb


Daži faili netika attēloti, jo izmaiņu fails ir pārāk liels