From 97fe5c2c98e00a69a0b2c0eee3c2c25551948b3e Mon Sep 17 00:00:00 2001 From: SoulStar Date: Thu, 2 Apr 2026 17:16:34 +0800 Subject: [PATCH] =?UTF-8?q?feat=20-=20=E6=B7=BB=E5=8A=A0CANFD=E6=94=AF?= =?UTF-8?q?=E6=8C=81=20=E3=80=90=E6=9C=AA=E6=B5=8B=E8=AF=95=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CompressorXN/FrmAgreement.Designer.cs | 257 +++++++------ CompressorXN/FrmAgreement.cs | 6 +- CompressorXN/FrmAgreement.resx | 61 ++-- CompressorXN/FrmHome.Designer.cs | 54 +-- CompressorXN/FrmHome.cs | 339 +++++++++++++++++- CompressorXN/FrmHome.resx | 9 + CompressorXN/FrmLogin.resx | 31 +- CompressorXN/FrmMain.Designer.cs | 8 - CompressorXN/FrmMain.resx | 35 +- CompressorXN/FrmRecipe.Designer.cs | 106 +++--- CompressorXN/FrmRecipe.cs | 3 + CompressorXN/FrmUnlock.Designer.cs | 3 - CompressorXN/FrmUnlock.cs | 26 +- CompressorXN/FrmUnlock.resx | 6 + CompressorXN/Untils/BindDropdownHelper.cs | 6 +- .../CompressorXN_Communication.csproj | 1 + .../GetCANReciveValHelper.cs | 85 +++++ CompressorXN_Communication/TuMos/BaseTMS.cs | 89 ++++- .../TuMos/TMSCANFDHelper.cs | 223 ++++++++++++ CompressorXN_ControlLib/ParaItem.Designer.cs | 1 + CompressorXN_ControlLib/ParaItem.resx | 6 + 21 files changed, 1089 insertions(+), 266 deletions(-) create mode 100644 CompressorXN_Communication/TuMos/TMSCANFDHelper.cs diff --git a/CompressorXN/FrmAgreement.Designer.cs b/CompressorXN/FrmAgreement.Designer.cs index 4c796ac..2bd4043 100644 --- a/CompressorXN/FrmAgreement.Designer.cs +++ b/CompressorXN/FrmAgreement.Designer.cs @@ -28,25 +28,25 @@ /// private void InitializeComponent() { - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle8 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle9 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle7 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle10 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle12 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle7 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle11 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle13 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle14 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle11 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle12 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle15 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle16 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle17 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle18 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle19 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle16 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle(); this.panelEx1 = new CompressorXN_ControlLib.PanelEx(); this.btn_Confirm = new System.Windows.Forms.Button(); this.btn_Unlock = new System.Windows.Forms.Button(); @@ -105,9 +105,8 @@ this.leftPanel = new CompressorXN_ControlLib.PanelEx(); this.listBox = new DevExpress.XtraEditors.ListBoxControl(); this.searchControl = new DevExpress.XtraEditors.SearchControl(); - this.Loading = new DevExpress.XtraSplashScreen.SplashScreenManager(this, typeof(global::CompressorXN.WaitForm1), true, true); + this.Loading = new DevExpress.XtraSplashScreen.SplashScreenManager(); ((System.ComponentModel.ISupportInitialize)(this.panelEx1)).BeginInit(); - this.panelEx1.SuspendLayout(); this.groupBox6.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.GridView_Recive)).BeginInit(); this.groupBox5.SuspendLayout(); @@ -119,7 +118,6 @@ this.groupBox1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.gridView_FuZhu)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.leftPanel)).BeginInit(); - this.leftPanel.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.listBox)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.searchControl.Properties)).BeginInit(); this.SuspendLayout(); @@ -131,10 +129,6 @@ this.panelEx1.BottomGap = 1; this.panelEx1.Controls.Add(this.btn_Confirm); this.panelEx1.Controls.Add(this.btn_Unlock); - this.panelEx1.Controls.Add(this.groupBox6); - this.panelEx1.Controls.Add(this.groupBox5); - this.panelEx1.Controls.Add(this.groupBox4); - this.panelEx1.Controls.Add(this.groupBox3); this.panelEx1.Controls.Add(this.groupBox2); this.panelEx1.Controls.Add(this.groupBox1); this.panelEx1.LeftGap = 1; @@ -181,7 +175,7 @@ this.groupBox6.Controls.Add(this.txt_RecivePeriod); this.groupBox6.Controls.Add(this.txt_ReciveId); this.groupBox6.Font = new System.Drawing.Font("微软雅黑", 12F); - this.groupBox6.Location = new System.Drawing.Point(7, 510); + this.groupBox6.Location = new System.Drawing.Point(376, 573); this.groupBox6.Name = "groupBox6"; this.groupBox6.Size = new System.Drawing.Size(1251, 188); this.groupBox6.TabIndex = 15; @@ -196,14 +190,14 @@ this.GridView_Recive.AllowUserToResizeRows = false; this.GridView_Recive.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; this.GridView_Recive.BackgroundColor = System.Drawing.Color.White; - dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle1.Font = new System.Drawing.Font("微软雅黑", 12F); - dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.GridView_Recive.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1; + dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle6.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle6.Font = new System.Drawing.Font("微软雅黑", 12F); + dataGridViewCellStyle6.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle6.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle6.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle6.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.GridView_Recive.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle6; this.GridView_Recive.ColumnHeadersHeight = 30; this.GridView_Recive.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.ReciveMsgName, @@ -211,27 +205,27 @@ this.ReciveLen, this.RecivePrecision, this.ReciveOffset}); - dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle3.BackColor = System.Drawing.SystemColors.Window; - dataGridViewCellStyle3.Font = new System.Drawing.Font("微软雅黑", 12F); - dataGridViewCellStyle3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40))))); - dataGridViewCellStyle3.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle3.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.False; - this.GridView_Recive.DefaultCellStyle = dataGridViewCellStyle3; + dataGridViewCellStyle8.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle8.BackColor = System.Drawing.SystemColors.Window; + dataGridViewCellStyle8.Font = new System.Drawing.Font("微软雅黑", 12F); + dataGridViewCellStyle8.ForeColor = System.Drawing.SystemColors.ControlText; + dataGridViewCellStyle8.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle8.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle8.WrapMode = System.Windows.Forms.DataGridViewTriState.False; + this.GridView_Recive.DefaultCellStyle = dataGridViewCellStyle8; this.GridView_Recive.Location = new System.Drawing.Point(650, 19); this.GridView_Recive.MultiSelect = false; this.GridView_Recive.Name = "GridView_Recive"; - dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle4.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle4.Font = new System.Drawing.Font("微软雅黑", 12F); - dataGridViewCellStyle4.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle4.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle4.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - this.GridView_Recive.RowHeadersDefaultCellStyle = dataGridViewCellStyle4; + dataGridViewCellStyle9.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle9.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle9.Font = new System.Drawing.Font("微软雅黑", 12F); + dataGridViewCellStyle9.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle9.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle9.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + this.GridView_Recive.RowHeadersDefaultCellStyle = dataGridViewCellStyle9; this.GridView_Recive.RowHeadersVisible = false; - dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - this.GridView_Recive.RowsDefaultCellStyle = dataGridViewCellStyle5; + dataGridViewCellStyle10.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + this.GridView_Recive.RowsDefaultCellStyle = dataGridViewCellStyle10; this.GridView_Recive.RowTemplate.DefaultCellStyle.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; this.GridView_Recive.RowTemplate.Height = 40; this.GridView_Recive.RowTemplate.Resizable = System.Windows.Forms.DataGridViewTriState.False; @@ -242,8 +236,8 @@ // ReciveMsgName // this.ReciveMsgName.DataPropertyName = "MsgName"; - dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - this.ReciveMsgName.DefaultCellStyle = dataGridViewCellStyle2; + dataGridViewCellStyle7.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + this.ReciveMsgName.DefaultCellStyle = dataGridViewCellStyle7; this.ReciveMsgName.HeaderText = "名称"; this.ReciveMsgName.Name = "ReciveMsgName"; this.ReciveMsgName.ReadOnly = true; @@ -324,7 +318,7 @@ // this.groupBox5.Controls.Add(this.GridView_Additional); this.groupBox5.Font = new System.Drawing.Font("微软雅黑", 12F); - this.groupBox5.Location = new System.Drawing.Point(657, 401); + this.groupBox5.Location = new System.Drawing.Point(1026, 464); this.groupBox5.Name = "groupBox5"; this.groupBox5.Size = new System.Drawing.Size(601, 103); this.groupBox5.TabIndex = 13; @@ -340,14 +334,14 @@ this.GridView_Additional.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; this.GridView_Additional.BackgroundColor = System.Drawing.Color.White; this.GridView_Additional.BorderStyle = System.Windows.Forms.BorderStyle.None; - dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle6.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle6.Font = new System.Drawing.Font("微软雅黑", 12F); - dataGridViewCellStyle6.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle6.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle6.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle6.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.GridView_Additional.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle6; + dataGridViewCellStyle11.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle11.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle11.Font = new System.Drawing.Font("微软雅黑", 12F); + dataGridViewCellStyle11.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle11.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle11.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle11.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.GridView_Additional.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle11; this.GridView_Additional.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.GridView_Additional.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.AdditionalPeriod, @@ -357,16 +351,16 @@ this.GridView_Additional.Location = new System.Drawing.Point(3, 25); this.GridView_Additional.MultiSelect = false; this.GridView_Additional.Name = "GridView_Additional"; - dataGridViewCellStyle8.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle8.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle8.Font = new System.Drawing.Font("微软雅黑", 12F); - dataGridViewCellStyle8.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle8.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle8.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle8.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.GridView_Additional.RowHeadersDefaultCellStyle = dataGridViewCellStyle8; - dataGridViewCellStyle9.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - this.GridView_Additional.RowsDefaultCellStyle = dataGridViewCellStyle9; + dataGridViewCellStyle13.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle13.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle13.Font = new System.Drawing.Font("微软雅黑", 12F); + dataGridViewCellStyle13.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle13.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle13.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle13.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.GridView_Additional.RowHeadersDefaultCellStyle = dataGridViewCellStyle13; + dataGridViewCellStyle14.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + this.GridView_Additional.RowsDefaultCellStyle = dataGridViewCellStyle14; this.GridView_Additional.RowTemplate.Height = 40; this.GridView_Additional.RowTemplate.Resizable = System.Windows.Forms.DataGridViewTriState.True; this.GridView_Additional.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.CellSelect; @@ -376,8 +370,8 @@ // AdditionalPeriod // this.AdditionalPeriod.DataPropertyName = "AdditionalPeriod"; - dataGridViewCellStyle7.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - this.AdditionalPeriod.DefaultCellStyle = dataGridViewCellStyle7; + dataGridViewCellStyle12.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + this.AdditionalPeriod.DefaultCellStyle = dataGridViewCellStyle12; this.AdditionalPeriod.FillWeight = 45.68528F; this.AdditionalPeriod.HeaderText = "周期"; this.AdditionalPeriod.Name = "AdditionalPeriod"; @@ -400,7 +394,7 @@ // this.groupBox4.Controls.Add(this.GridView_SendSpeed); this.groupBox4.Font = new System.Drawing.Font("微软雅黑", 12F); - this.groupBox4.Location = new System.Drawing.Point(7, 401); + this.groupBox4.Location = new System.Drawing.Point(376, 464); this.groupBox4.Name = "groupBox4"; this.groupBox4.Size = new System.Drawing.Size(610, 103); this.groupBox4.TabIndex = 14; @@ -416,14 +410,14 @@ this.GridView_SendSpeed.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; this.GridView_SendSpeed.BackgroundColor = System.Drawing.Color.White; this.GridView_SendSpeed.BorderStyle = System.Windows.Forms.BorderStyle.None; - dataGridViewCellStyle10.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle10.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle10.Font = new System.Drawing.Font("微软雅黑", 12F); - dataGridViewCellStyle10.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle10.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle10.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle10.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.GridView_SendSpeed.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle10; + dataGridViewCellStyle15.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle15.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle15.Font = new System.Drawing.Font("微软雅黑", 12F); + dataGridViewCellStyle15.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle15.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle15.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle15.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.GridView_SendSpeed.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle15; this.GridView_SendSpeed.ColumnHeadersHeight = 30; this.GridView_SendSpeed.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.MsgName, @@ -431,27 +425,27 @@ this.Len, this.Precision, this.Offset}); - dataGridViewCellStyle12.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle12.BackColor = System.Drawing.SystemColors.Window; - dataGridViewCellStyle12.Font = new System.Drawing.Font("微软雅黑", 12F); - dataGridViewCellStyle12.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40))))); - dataGridViewCellStyle12.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle12.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle12.WrapMode = System.Windows.Forms.DataGridViewTriState.False; - this.GridView_SendSpeed.DefaultCellStyle = dataGridViewCellStyle12; + dataGridViewCellStyle17.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle17.BackColor = System.Drawing.SystemColors.Window; + dataGridViewCellStyle17.Font = new System.Drawing.Font("微软雅黑", 12F); + dataGridViewCellStyle17.ForeColor = System.Drawing.SystemColors.ControlText; + dataGridViewCellStyle17.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle17.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle17.WrapMode = System.Windows.Forms.DataGridViewTriState.False; + this.GridView_SendSpeed.DefaultCellStyle = dataGridViewCellStyle17; this.GridView_SendSpeed.Location = new System.Drawing.Point(3, 25); this.GridView_SendSpeed.MultiSelect = false; this.GridView_SendSpeed.Name = "GridView_SendSpeed"; - dataGridViewCellStyle13.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle13.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle13.Font = new System.Drawing.Font("微软雅黑", 12F); - dataGridViewCellStyle13.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle13.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle13.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - this.GridView_SendSpeed.RowHeadersDefaultCellStyle = dataGridViewCellStyle13; + dataGridViewCellStyle18.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle18.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle18.Font = new System.Drawing.Font("微软雅黑", 12F); + dataGridViewCellStyle18.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle18.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle18.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + this.GridView_SendSpeed.RowHeadersDefaultCellStyle = dataGridViewCellStyle18; this.GridView_SendSpeed.RowHeadersVisible = false; - dataGridViewCellStyle14.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - this.GridView_SendSpeed.RowsDefaultCellStyle = dataGridViewCellStyle14; + dataGridViewCellStyle19.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + this.GridView_SendSpeed.RowsDefaultCellStyle = dataGridViewCellStyle19; this.GridView_SendSpeed.RowTemplate.DefaultCellStyle.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; this.GridView_SendSpeed.RowTemplate.Height = 40; this.GridView_SendSpeed.RowTemplate.Resizable = System.Windows.Forms.DataGridViewTriState.False; @@ -462,8 +456,8 @@ // MsgName // this.MsgName.DataPropertyName = "MsgName"; - dataGridViewCellStyle11.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - this.MsgName.DefaultCellStyle = dataGridViewCellStyle11; + dataGridViewCellStyle16.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + this.MsgName.DefaultCellStyle = dataGridViewCellStyle16; this.MsgName.HeaderText = "名称"; this.MsgName.Name = "MsgName"; this.MsgName.ReadOnly = true; @@ -502,7 +496,7 @@ this.groupBox3.Controls.Add(this.label8); this.groupBox3.Font = new System.Drawing.Font("微软雅黑", 12F); this.groupBox3.ForeColor = System.Drawing.Color.Black; - this.groupBox3.Location = new System.Drawing.Point(7, 206); + this.groupBox3.Location = new System.Drawing.Point(376, 269); this.groupBox3.Name = "groupBox3"; this.groupBox3.Size = new System.Drawing.Size(610, 173); this.groupBox3.TabIndex = 11; @@ -571,7 +565,7 @@ this.groupBox2.ForeColor = System.Drawing.Color.Black; this.groupBox2.Location = new System.Drawing.Point(7, 26); this.groupBox2.Name = "groupBox2"; - this.groupBox2.Size = new System.Drawing.Size(610, 174); + this.groupBox2.Size = new System.Drawing.Size(610, 221); this.groupBox2.TabIndex = 12; this.groupBox2.TabStop = false; this.groupBox2.Text = "报文"; @@ -651,7 +645,7 @@ this.groupBox1.Font = new System.Drawing.Font("微软雅黑", 12F); this.groupBox1.Location = new System.Drawing.Point(657, 26); this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(601, 353); + this.groupBox1.Size = new System.Drawing.Size(601, 400); this.groupBox1.TabIndex = 10; this.groupBox1.TabStop = false; this.groupBox1.Text = "辅助位"; @@ -662,18 +656,18 @@ this.gridView_FuZhu.AllowUserToDeleteRows = false; this.gridView_FuZhu.AllowUserToResizeColumns = false; this.gridView_FuZhu.AllowUserToResizeRows = false; - dataGridViewCellStyle15.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224))))); - this.gridView_FuZhu.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle15; + dataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224))))); + this.gridView_FuZhu.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1; this.gridView_FuZhu.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; this.gridView_FuZhu.BackgroundColor = System.Drawing.Color.White; - dataGridViewCellStyle16.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle16.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle16.Font = new System.Drawing.Font("微软雅黑", 12F); - dataGridViewCellStyle16.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle16.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle16.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle16.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.gridView_FuZhu.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle16; + dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle2.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle2.Font = new System.Drawing.Font("微软雅黑", 12F); + dataGridViewCellStyle2.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.gridView_FuZhu.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle2; this.gridView_FuZhu.ColumnHeadersHeight = 40; this.gridView_FuZhu.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.bit7, @@ -685,36 +679,36 @@ this.bit1, this.bit0, this.SortIndex}); - dataGridViewCellStyle17.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle17.BackColor = System.Drawing.SystemColors.Window; - dataGridViewCellStyle17.Font = new System.Drawing.Font("微软雅黑", 12F); - dataGridViewCellStyle17.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40))))); - dataGridViewCellStyle17.SelectionBackColor = System.Drawing.Color.White; - dataGridViewCellStyle17.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle17.WrapMode = System.Windows.Forms.DataGridViewTriState.False; - this.gridView_FuZhu.DefaultCellStyle = dataGridViewCellStyle17; + dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle3.BackColor = System.Drawing.SystemColors.Window; + dataGridViewCellStyle3.Font = new System.Drawing.Font("微软雅黑", 12F); + dataGridViewCellStyle3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40))))); + dataGridViewCellStyle3.SelectionBackColor = System.Drawing.Color.White; + dataGridViewCellStyle3.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.False; + this.gridView_FuZhu.DefaultCellStyle = dataGridViewCellStyle3; this.gridView_FuZhu.Dock = System.Windows.Forms.DockStyle.Fill; this.gridView_FuZhu.Location = new System.Drawing.Point(3, 25); this.gridView_FuZhu.Margin = new System.Windows.Forms.Padding(0); this.gridView_FuZhu.MultiSelect = false; this.gridView_FuZhu.Name = "gridView_FuZhu"; - dataGridViewCellStyle18.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle18.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle18.Font = new System.Drawing.Font("微软雅黑", 12F); - dataGridViewCellStyle18.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle18.SelectionBackColor = System.Drawing.Color.Transparent; - dataGridViewCellStyle18.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle18.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.gridView_FuZhu.RowHeadersDefaultCellStyle = dataGridViewCellStyle18; + dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle4.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle4.Font = new System.Drawing.Font("微软雅黑", 12F); + dataGridViewCellStyle4.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle4.SelectionBackColor = System.Drawing.Color.Transparent; + dataGridViewCellStyle4.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle4.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.gridView_FuZhu.RowHeadersDefaultCellStyle = dataGridViewCellStyle4; this.gridView_FuZhu.RowHeadersWidth = 70; - dataGridViewCellStyle19.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - this.gridView_FuZhu.RowsDefaultCellStyle = dataGridViewCellStyle19; + dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + this.gridView_FuZhu.RowsDefaultCellStyle = dataGridViewCellStyle5; this.gridView_FuZhu.RowTemplate.DefaultCellStyle.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; this.gridView_FuZhu.RowTemplate.Height = 40; this.gridView_FuZhu.RowTemplate.Resizable = System.Windows.Forms.DataGridViewTriState.False; this.gridView_FuZhu.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.CellSelect; this.gridView_FuZhu.ShowEditingIcon = false; - this.gridView_FuZhu.Size = new System.Drawing.Size(595, 325); + this.gridView_FuZhu.Size = new System.Drawing.Size(595, 372); this.gridView_FuZhu.TabIndex = 3; // // bit7 @@ -814,6 +808,9 @@ this.searchControl.Dock = System.Windows.Forms.DockStyle.Top; this.searchControl.Location = new System.Drawing.Point(2, 2); this.searchControl.Name = "searchControl"; + // + // + // this.searchControl.Properties.Appearance.Font = new System.Drawing.Font("微软雅黑", 12F); this.searchControl.Properties.Appearance.Options.UseFont = true; this.searchControl.Properties.AutoHeight = false; @@ -824,15 +821,15 @@ this.searchControl.Size = new System.Drawing.Size(359, 40); this.searchControl.TabIndex = 17; // - // Loading - // - this.Loading.ClosingDelay = 500; - // // FrmAgreement // this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 21F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(1920, 926); + this.Controls.Add(this.groupBox6); + this.Controls.Add(this.groupBox4); + this.Controls.Add(this.groupBox3); + this.Controls.Add(this.groupBox5); this.Controls.Add(this.panelEx1); this.Controls.Add(this.leftPanel); this.Font = new System.Drawing.Font("微软雅黑", 12F); @@ -843,7 +840,6 @@ this.Text = "协议配置"; this.Load += new System.EventHandler(this.FrmAgreement_Load); ((System.ComponentModel.ISupportInitialize)(this.panelEx1)).EndInit(); - this.panelEx1.ResumeLayout(false); this.groupBox6.ResumeLayout(false); this.groupBox6.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.GridView_Recive)).EndInit(); @@ -858,7 +854,6 @@ this.groupBox1.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.gridView_FuZhu)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.leftPanel)).EndInit(); - this.leftPanel.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.listBox)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.searchControl.Properties)).EndInit(); this.ResumeLayout(false); diff --git a/CompressorXN/FrmAgreement.cs b/CompressorXN/FrmAgreement.cs index e2ae546..109f40d 100644 --- a/CompressorXN/FrmAgreement.cs +++ b/CompressorXN/FrmAgreement.cs @@ -129,7 +129,7 @@ namespace CompressorXN gridView_FuZhu.AutoGenerateColumns = false; gridView_FuZhu.DataSource = list; - gridView_FuZhu.RowTemplate.Height = (gridView_FuZhu.Height - gridView_FuZhu.ColumnHeadersHeight) / gridView_FuZhu.Rows.Count; + //gridView_FuZhu.RowTemplate.Height = (gridView_FuZhu.Height - gridView_FuZhu.ColumnHeadersHeight) / gridView_FuZhu.Rows.Count; } /// @@ -156,7 +156,7 @@ namespace CompressorXN var centerFormat = new StringFormat() { Alignment = StringAlignment.Center, - LineAlignment = StringAlignment.Center + LineAlignment = StringAlignment.Center }; var headerBuunds = new Rectangle(e.RowBounds.Left, e.RowBounds.Top, grid.RowHeadersWidth, e.RowBounds.Height); e.Graphics.DrawString(rowidx, new Font("微软雅黑", 12), SystemBrushes.ControlText, headerBuunds, centerFormat); @@ -409,6 +409,7 @@ namespace CompressorXN #endregion #region 辅助位 + foreach (DataGridViewRow row in gridView_FuZhu.Rows) { string bit7 = row.Cells["Bit7"].Value.ToString(); @@ -444,6 +445,7 @@ namespace CompressorXN }; agreementVM.AgreementHelpRuleList.Add(helpRule); } + #endregion bool saveResult = _agreementConfigService.SaveAgreement(agreementVM, agreementName); diff --git a/CompressorXN/FrmAgreement.resx b/CompressorXN/FrmAgreement.resx index 5c1fad2..e5851eb 100644 --- a/CompressorXN/FrmAgreement.resx +++ b/CompressorXN/FrmAgreement.resx @@ -117,6 +117,36 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 17, 17 + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + True @@ -156,31 +186,16 @@ True - - True + + 124, 17 - - True + + 228, 17 - - True + + 321, 17 - - True - - - True - - - True - - - True - - - True - - - True + + 457, 17 \ No newline at end of file diff --git a/CompressorXN/FrmHome.Designer.cs b/CompressorXN/FrmHome.Designer.cs index ac483b6..bd7266d 100644 --- a/CompressorXN/FrmHome.Designer.cs +++ b/CompressorXN/FrmHome.Designer.cs @@ -39,6 +39,9 @@ this.chk_X_Vibrate = new System.Windows.Forms.CheckBox(); this.chk_OutPress = new System.Windows.Forms.CheckBox(); this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.btn_Stop = new DevExpress.XtraEditors.SimpleButton(); + this.btn_SendSpeed2 = new DevExpress.XtraEditors.SimpleButton(); + this.btn_SendSpeed1 = new DevExpress.XtraEditors.SimpleButton(); this.txt_ProductType = new System.Windows.Forms.TextBox(); this.txtProductCode = new System.Windows.Forms.TextBox(); this.label2 = new System.Windows.Forms.Label(); @@ -100,9 +103,6 @@ this.myResultControl4 = new CompressorXN_ControlLib.MyResultControl(); this.myResultControl2 = new CompressorXN_ControlLib.MyResultControl(); this.myResultControl3 = new CompressorXN_ControlLib.MyResultControl(); - this.btn_SendSpeed1 = new DevExpress.XtraEditors.SimpleButton(); - this.btn_SendSpeed2 = new DevExpress.XtraEditors.SimpleButton(); - this.btn_Stop = new DevExpress.XtraEditors.SimpleButton(); this.groupBox1.SuspendLayout(); this.groupBoxEx10.SuspendLayout(); this.groupBoxEx9.SuspendLayout(); @@ -261,6 +261,30 @@ this.groupBox1.TabStop = false; this.groupBox1.Text = "生产信息"; // + // btn_Stop + // + this.btn_Stop.Location = new System.Drawing.Point(51, 379); + this.btn_Stop.Name = "btn_Stop"; + this.btn_Stop.Size = new System.Drawing.Size(135, 61); + this.btn_Stop.TabIndex = 2; + this.btn_Stop.Text = "停机"; + // + // btn_SendSpeed2 + // + this.btn_SendSpeed2.Location = new System.Drawing.Point(51, 287); + this.btn_SendSpeed2.Name = "btn_SendSpeed2"; + this.btn_SendSpeed2.Size = new System.Drawing.Size(135, 61); + this.btn_SendSpeed2.TabIndex = 2; + this.btn_SendSpeed2.Text = "二段速"; + // + // btn_SendSpeed1 + // + this.btn_SendSpeed1.Location = new System.Drawing.Point(51, 199); + this.btn_SendSpeed1.Name = "btn_SendSpeed1"; + this.btn_SendSpeed1.Size = new System.Drawing.Size(135, 61); + this.btn_SendSpeed1.TabIndex = 2; + this.btn_SendSpeed1.Text = "一段速"; + // // txt_ProductType // this.txt_ProductType.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(187)))), ((int)(((byte)(213)))), ((int)(((byte)(238))))); @@ -1114,30 +1138,6 @@ this.myResultControl3.TestValPLCPointCode = "D1018"; this.myResultControl3.TestValText = "#####.###"; // - // btn_SendSpeed1 - // - this.btn_SendSpeed1.Location = new System.Drawing.Point(51, 199); - this.btn_SendSpeed1.Name = "btn_SendSpeed1"; - this.btn_SendSpeed1.Size = new System.Drawing.Size(135, 61); - this.btn_SendSpeed1.TabIndex = 2; - this.btn_SendSpeed1.Text = "一段速"; - // - // btn_SendSpeed2 - // - this.btn_SendSpeed2.Location = new System.Drawing.Point(51, 287); - this.btn_SendSpeed2.Name = "btn_SendSpeed2"; - this.btn_SendSpeed2.Size = new System.Drawing.Size(135, 61); - this.btn_SendSpeed2.TabIndex = 2; - this.btn_SendSpeed2.Text = "二段速"; - // - // btn_Stop - // - this.btn_Stop.Location = new System.Drawing.Point(51, 379); - this.btn_Stop.Name = "btn_Stop"; - this.btn_Stop.Size = new System.Drawing.Size(135, 61); - this.btn_Stop.TabIndex = 2; - this.btn_Stop.Text = "停机"; - // // FrmHome // this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 21F); diff --git a/CompressorXN/FrmHome.cs b/CompressorXN/FrmHome.cs index 1cf124c..9d3e4dc 100644 --- a/CompressorXN/FrmHome.cs +++ b/CompressorXN/FrmHome.cs @@ -70,6 +70,11 @@ namespace CompressorXN { BaseTMS.CanInit((uint)GlobalVar.agreementMsgVM.Bps); } + else if (GlobalVar.agreementMsgVM.StartType == "CANFD") + { + //新建CANFD进程 + BaseTMS.CANFDInit(5000000, (uint)GlobalVar.agreementMsgVM.Bps); + } else if (GlobalVar.agreementMsgVM.StartType == "LIN") { TMSLINHelper.LinInit(GlobalVar.agreementMsgVM.Bps); @@ -136,6 +141,10 @@ namespace CompressorXN { CAN_SendSpeed1(); } + else if (arg2 == "CANFD") + { + CANFD_SendSpeed1(); + } else if (arg2 == "LIN") { LIN_SendSpeed1(); @@ -148,6 +157,10 @@ namespace CompressorXN { CAN_SendSpeed2(); } + else if (arg2 == "CANFD") + { + CANFD_SendSpeed2(); + } else if (arg2 == "LIN") { LIN_SendSpeed2(); @@ -160,6 +173,10 @@ namespace CompressorXN { CAN_SendSpeed3(); } + else if (arg2 == "CANFD") + { + CANFD_SendSpeed3(); + } else if (arg2 == "LIN") { LIN_SendSpeed3(); @@ -172,6 +189,14 @@ namespace CompressorXN { CAN_SendAdditional(); } + else if (arg2 == "CANFD") + { + CANFD_SendAdditional(); + } + else if (arg2 == "LIN") + { + + } }, cts.Token); @@ -181,6 +206,10 @@ namespace CompressorXN { CAN_ReciveMsg(); } + else if (arg2 == "CANFD") + { + CANFD_ReciveMsg(); + } else if (arg2 == "LIN") { LIN_ReciveMsg(); @@ -744,6 +773,7 @@ namespace CompressorXN #region 图莫斯模块通讯 #region CAN + private static Int32 ret = 0; private static USB2CAN.CAN_MSG[] CanMsg = null; @@ -912,7 +942,7 @@ namespace CompressorXN continue; } additional_ManualResetEvent.WaitOne(); - Console.WriteLine("启动发送附加报文=="+ StringLib.GetHexStringFromByteArray(additionalCanMsg[0].Data)); + Console.WriteLine("启动发送附加报文==" + StringLib.GetHexStringFromByteArray(additionalCanMsg[0].Data)); if (GlobalVar.agreementMsgVM.StartType == "CAN") { int SendedNum = USB2CAN.CAN_SendMsg(GlobalVar.DevHandle, GlobalVar.WriteCANIndex, additionalCanMsg, (UInt32)additionalCanMsg.Length); @@ -992,6 +1022,313 @@ namespace CompressorXN Thread.Sleep(GlobalVar.agreementMsgVM.RecivePeriod); } } + + #endregion + + #region CANFD + + private static Int32 retFD = 0; + private static USB2CANFD.CANFD_MSG[] CanFDMsg = null; + + /// + /// 一段速度 + /// + private void CANFD_SendSpeed1() + { + if (CanFDMsg == null) + { + CanFDMsg = new USB2CANFD.CANFD_MSG[1]; + CanFDMsg[0] = new USB2CANFD.CANFD_MSG + { + ID = Convert.ToUInt32(GlobalVar.agreementMsgVM.SendId, 16),//报文ID + DLC = (byte)(GlobalVar.agreementMsgVM.FrameLen & 0xFF),//数据长度(<=8),即Data中有效数据长度 + }; + CanFDMsg[0].Flags |= USB2CANFD.CANFD_MSG_FLAG_FDF; + } + + while (true) + { + if (cts.IsCancellationRequested || !OmronCIPHelper.IsConnected || GlobalVar.agreementMsgVM == null || GlobalVar.agreementMsgVM.StartType != "CAN") + { + Thread.Sleep(1000); + continue; + } + speed1_ManualResetEvent.WaitOne(); + Console.WriteLine("启动了CANFD_SendSpeed1"); + if (GlobalVar.agreementMsgVM.StartType == "CANFD") + { + string speed1Hex = GlobalVar.agreementMsgVM.Speed1Hex; + if (!string.IsNullOrEmpty(speed1Hex)) + { + CanFDMsg[0].Data = ByteArrayLib.GetByteArrayFromHexString(speed1Hex); + } + CanMsgDataCatch(CanFDMsg, out IntPtr pCanSendMsg); + int SendedNum = USB2CANFD.CANFD_SendMsg(GlobalVar.DevHandle, GlobalVar.WriteCANIndex, pCanSendMsg, CanFDMsg.Length); + if (SendedNum >= 0) + { + // Console.WriteLine($"{DateTime.Now.ToString("mm:ss fff")}:Success send frames:{0}", SendMsgNum); + } + else + { + Console.WriteLine("Send CANFD data failed!"); + //break; + } + } + + Thread.Sleep(GlobalVar.agreementMsgVM.SendPeriod); + } + } + + /// + /// 二段速度 + /// + private void CANFD_SendSpeed2() + { + + if (CanFDMsg == null) + { + CanFDMsg = new USB2CANFD.CANFD_MSG[1]; + CanFDMsg[0] = new USB2CANFD.CANFD_MSG + { + ID = Convert.ToUInt32(GlobalVar.agreementMsgVM.SendId, 16),//报文ID + DLC = (byte)(GlobalVar.agreementMsgVM.FrameLen & 0xFF),//数据长度(<=8),即Data中有效数据长度 + }; + CanFDMsg[0].Flags |= USB2CANFD.CANFD_MSG_FLAG_FDF; + } + + while (true) + { + speed2_ManualResetEvent.WaitOne(); + Console.WriteLine("启动了CANFD_SendSpeed2"); + if (GlobalVar.agreementMsgVM.StartType == "CANFD") + { + string speed2Hex = GlobalVar.agreementMsgVM.Speed2Hex; + if (!string.IsNullOrEmpty(speed2Hex)) + { + CanFDMsg[0].Data = ByteArrayLib.GetByteArrayFromHexString(speed2Hex); + } + CanMsgDataCatch(CanFDMsg, out IntPtr pCanSendMsg); + int SendedNum = USB2CANFD.CANFD_SendMsg(GlobalVar.DevHandle, GlobalVar.WriteCANIndex, pCanSendMsg, CanFDMsg.Length); + if (SendedNum >= 0) + { + // Console.WriteLine($"{DateTime.Now.ToString("mm:ss fff")}:Success send frames:{SendMsgNum}"); + } + else + { + Console.WriteLine("Send CANFD data failed!"); + //break; + } + } + Thread.Sleep(GlobalVar.agreementMsgVM.SendPeriod); + } + } + + /// + /// 三段速度 + /// + private void CANFD_SendSpeed3() + { + + if (CanFDMsg == null) + { + CanFDMsg = new USB2CANFD.CANFD_MSG[1]; + CanFDMsg[0] = new USB2CANFD.CANFD_MSG + { + ID = Convert.ToUInt32(GlobalVar.agreementMsgVM.SendId, 16),//报文ID + DLC = (byte)(GlobalVar.agreementMsgVM.FrameLen & 0xFF),//数据长度(<=8),即Data中有效数据长度 + }; + CanFDMsg[0].Flags |= USB2CANFD.CANFD_MSG_FLAG_FDF; + } + + while (true) + { + speed3_ManualResetEvent.WaitOne(); + Console.WriteLine("启动了CANFD_SendSpeed3"); + if (GlobalVar.agreementMsgVM.StartType == "CANFD") + { + string speed3Hex = GlobalVar.agreementMsgVM.Speed3Hex; + if (!string.IsNullOrEmpty(speed3Hex)) + { + CanFDMsg[0].Data = ByteArrayLib.GetByteArrayFromHexString(speed3Hex); + } + CanMsgDataCatch(CanFDMsg, out IntPtr pCanSendMsg); + int SendedNum = USB2CANFD.CANFD_SendMsg(GlobalVar.DevHandle, GlobalVar.WriteCANIndex, pCanSendMsg, CanFDMsg.Length); + if (SendedNum >= 0) + { + // Console.WriteLine($"{DateTime.Now.ToString("mm:ss fff")}:Success send frames:{SendMsgNum}"); + } + else + { + Console.WriteLine("Send CANFD data failed!"); + //break; + } + } + Thread.Sleep(GlobalVar.agreementMsgVM.SendPeriod); + } + } + + /// + /// 附加报文 + /// + private async void CANFD_SendAdditional() + { + USB2CANFD.CANFD_MSG[] additionalCanFDMsg = null; + if (!string.IsNullOrEmpty(GlobalVar.agreementMsgVM.SendAdditionalRules.AdditionalSendId) && !string.IsNullOrEmpty(GlobalVar.agreementMsgVM.SendAdditionalRules.AdditionalContent) && additionalCanFDMsg == null) + { + additionalCanFDMsg = new USB2CANFD.CANFD_MSG[1]; + additionalCanFDMsg[0] = new USB2CANFD.CANFD_MSG + { + ID = Convert.ToUInt32(GlobalVar.agreementMsgVM.SendId, 16),//报文ID + DLC = (byte)(GlobalVar.agreementMsgVM.FrameLen & 0xFF),//数据长度(<=8),即Data中有效数据长度 + Data = ByteArrayLib.GetByteArrayFromHexString(GlobalVar.agreementMsgVM.SendAdditionalRules.AdditionalContent) + }; + additionalCanFDMsg[0].Flags |= USB2CANFD.CANFD_MSG_FLAG_FDF; + } + while (true) + { + if (cts.IsCancellationRequested || GlobalVar.agreementMsgVM == null || GlobalVar.agreementMsgVM.SendAdditionalRules == null || string.IsNullOrEmpty(GlobalVar.agreementMsgVM.SendAdditionalRules.AdditionalSendId) || string.IsNullOrEmpty(GlobalVar.agreementMsgVM.SendAdditionalRules.AdditionalContent)) + { + Thread.Sleep(1000); + continue; + } + additional_ManualResetEvent.WaitOne(); + Console.WriteLine("启动CANFD发送附加报文==" + StringLib.GetHexStringFromByteArray(additionalCanFDMsg[0].Data)); + if (GlobalVar.agreementMsgVM.StartType == "CANFD") + { + CanMsgDataCatch(additionalCanFDMsg, out IntPtr pCanSendMsg); + int SendedNum = USB2CANFD.CANFD_SendMsg(GlobalVar.DevHandle, GlobalVar.WriteCANIndex, pCanSendMsg, additionalCanFDMsg.Length); + if (SendedNum >= 0) + { + Console.WriteLine("附加报文Success send frames:{0}", SendedNum); + } + else + { + Console.WriteLine("附加报文Send CANFD data failed!"); + break; + } + } + await Task.Delay(GlobalVar.agreementMsgVM.SendAdditionalRules.AdditionalPeriod); + //Thread.Sleep(GlobalVar.agreementMsgVM.SendAdditionalRules.AdditionalPeriod); + } + } + + /// + /// 接收报文 + /// + private void CANFD_ReciveMsg() + { + while (true) + { + if (GlobalVar.DevHandle <= 0) + { + Thread.Sleep(1000); + continue; + } + if (GlobalVar.agreementMsgVM.StartType == "CANFD") + { + USB2CANFD.CANFD_MSG[] CanFDMsgBuffer = new USB2CANFD.CANFD_MSG[1024]; + //申请数据缓冲区 + IntPtr pt = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(USB2CANFD.CANFD_MSG)) * CanFDMsgBuffer.Length); + + int CanNum = USB2CANFD.CANFD_GetMsg(GlobalVar.DevHandle, GlobalVar.ReadCANIndex, pt, CanFDMsgBuffer.Length); + if (CanNum > 0) + { + for (int i = 0; i < CanNum; i++) + { + //从缓冲区中获取数据 + CanFDMsgBuffer[i] = (USB2CANFD.CANFD_MSG)Marshal.PtrToStructure(pt + i * Marshal.SizeOf(typeof(USB2CANFD.CANFD_MSG)), typeof(USB2CANFD.CANFD_MSG)); + //判断获取的是不是目标报文 + if (CanFDMsgBuffer[i].ID == Convert.ToUInt64(GlobalVar.agreementMsgVM.ReciveId, 16)) + { + //如果信号值不为空,要过滤信号值 + if (!string.IsNullOrEmpty(GlobalVar.agreementMsgVM.ReciveSignalVal)) + { + if (Convert.ToUInt64(GlobalVar.agreementMsgVM.ReciveSignalVal, 16) == CanFDMsgBuffer[i].Data[0]) + { + + GetCANReciveValHelper.GetFDReciveVal(CanFDMsgBuffer[i].Data);//从接收报文中解析实际值 + } + } + else + { + GetCANReciveValHelper.GetFDReciveVal(CanFDMsgBuffer[i].Data);//从接收报文中解析实际值 + } + } + } + } + else if (CanNum == 0) + { + + } + else + { + Console.WriteLine("Get CANFD data error!"); + LogHelper.Error(null, "Get CANFD data error!"); + break; + } + //释放数据缓冲区,必须释放,否则程序运行一段时间后会报内存不足 + Marshal.FreeHGlobal(pt); + //Console.WriteLine($"{DateTime.Now.ToString("mm:ss fff")}执行接收"); + } + Thread.Sleep(GlobalVar.agreementMsgVM.RecivePeriod); + } + } + + /// + /// 数据复制到数据缓冲区中 + /// + /// + private static void CanMsgDataCatch(USB2CANFD.CANFD_MSG[] CanMsg, out IntPtr pCanSendMsg) + { + pCanSendMsg = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(USB2CANFD.CANFD_MSG)) * CanMsg.Length);//申请缓冲区 + IntPtr pPonitor = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(USB2CANFD.CANFD_MSG))); + Marshal.StructureToPtr(CanMsg[0], pPonitor, true); + byte[] buffer = new byte[Marshal.SizeOf(typeof(USB2CANFD.CANFD_MSG))]; + Marshal.Copy(pPonitor, buffer, 0, Marshal.SizeOf(typeof(USB2CANFD.CANFD_MSG))); + Marshal.Copy(buffer, 0, (IntPtr)(UInt32)pCanSendMsg, Marshal.SizeOf(typeof(USB2CANFD.CANFD_MSG))); + Marshal.FreeHGlobal(pPonitor);//释放缓冲区 + } + + ///// + ///// 一段速度 + ///// + //private void CANFD_SendSpeed1() + //{ + + //} + + ///// + ///// 二段速度 + ///// + //private void CANFD_SendSpeed2() + //{ + + //} + + ///// + ///// 三段速度 + ///// + //private void CANFD_SendSpeed3() + //{ + + //} + + ///// + ///// 附加报文 + ///// + //private async void CANFD_SendAdditional() + //{ + + //} + + ///// + ///// 接收报文 + ///// + //private void CANFD_ReciveMsg() + //{ + + //} + #endregion #region LIN diff --git a/CompressorXN/FrmHome.resx b/CompressorXN/FrmHome.resx index 1af7de1..f148072 100644 --- a/CompressorXN/FrmHome.resx +++ b/CompressorXN/FrmHome.resx @@ -117,4 +117,13 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 17, 17 + + + 123, 17 + + + 275, 17 + \ No newline at end of file diff --git a/CompressorXN/FrmLogin.resx b/CompressorXN/FrmLogin.resx index e3e23ef..2166f99 100644 --- a/CompressorXN/FrmLogin.resx +++ b/CompressorXN/FrmLogin.resx @@ -117,8 +117,26 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 17, 17 + + + 129, 17 + + + 235, 17 + + + 368, 17 + + + 530, 17 + + + 692, 17 + - + iVBORw0KGgoAAAANSUhEUgAAABYAAAAYCAYAAAD+vg1LAAAABGdBTUEAALGPC/xhBQAAARBJREFUSEvt lT0KwkAQhbfQXkQ8iYgIgo2V4A0ESytLsfEM2ngAWytvkMpC8w+m1tpCUEFEC30jo4Swu/4kdj742CQz @@ -128,7 +146,10 @@ IoU4HJFZuu9wuCmDKYizb+zBBNNQEEKIG9VX4O7UZUHJAAAAAElFTkSuQmCC - + + 817, 17 + + iVBORw0KGgoAAAANSUhEUgAAABYAAAAYCAYAAAD+vg1LAAAABGdBTUEAALGPC/xhBQAAAXtJREFUSEul laFSw0AYhBFIBKIPgWSmr4BDgKvkEXiASgQyEoFAICqQiApERFxyyYkKRAUCUYGoQFbALmwYmvn/9Nru @@ -140,4 +161,10 @@ tK9vkz3E90cIIX4DsbQZrKaLdHUAAAAASUVORK5CYII= + + 953, 17 + + + 1108, 17 + \ No newline at end of file diff --git a/CompressorXN/FrmMain.Designer.cs b/CompressorXN/FrmMain.Designer.cs index 0b1446b..86475a1 100644 --- a/CompressorXN/FrmMain.Designer.cs +++ b/CompressorXN/FrmMain.Designer.cs @@ -49,13 +49,10 @@ this.btn_EditPwd = new System.Windows.Forms.Button(); this.btn_AgreeMent = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.bottomPanel)).BeginInit(); - this.bottomPanel.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox3)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.MainanelControl)).BeginInit(); - this.MainanelControl.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.topPanel)).BeginInit(); - this.topPanel.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); this.SuspendLayout(); // @@ -362,17 +359,12 @@ this.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.Name = "FrmMain"; this.Text = "FrmMain"; - this.WindowState = System.Windows.Forms.FormWindowState.Maximized; this.Load += new System.EventHandler(this.Main_Load); ((System.ComponentModel.ISupportInitialize)(this.bottomPanel)).EndInit(); - this.bottomPanel.ResumeLayout(false); - this.bottomPanel.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox3)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.MainanelControl)).EndInit(); - this.MainanelControl.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.topPanel)).EndInit(); - this.topPanel.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); this.ResumeLayout(false); diff --git a/CompressorXN/FrmMain.resx b/CompressorXN/FrmMain.resx index 4368e10..0e63ac1 100644 --- a/CompressorXN/FrmMain.resx +++ b/CompressorXN/FrmMain.resx @@ -117,11 +117,44 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 17, 17 + + + 150, 17 + + + 279, 17 + + + 451, 17 + + + 586, 17 + + + 722, 17 + + + 881, 17 + + + 1014, 17 + + + 1167, 17 + + + 1318, 17 + + + 1424, 17 + iVBORw0KGgoAAAANSUhEUgAAASkAAAEmCAYAAAA+z2ZXAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAL - EAAACxABrSO9dQAAjcVJREFUeF7tvXl/FNX2Ln5fxO9F3P/u/XzvOQKBJGQO8zzPCAiCIigK4qyogOCI + DwAACw8BkvkDpQAAjcVJREFUeF7tvXl/FNX2Ln5fxO9F3P/u/XzvOQKBJGQO8zzPCAiCIigK4qyogOCI CioOqCiiAg6oiDjhjCMoIIigImPSXVU9D+u3nlV7dzpNJV3V6SQdUuucxw7du/a49lNrT2v/L1988cUX X3zxxRdffPHFF1988cUXX3zpTZI+/Qclfz9Eia8+o+Q72yi+dRNjY9anDx8+Oh92f0vseJGSn35Iyd9+ ofSp34mMCzeqrtp7JH3mb0q+t40iD66i0KJZZI5vpGDjAApWXEGBir4UrPThw0e3oqIPBWv7kTm6lkJz diff --git a/CompressorXN/FrmRecipe.Designer.cs b/CompressorXN/FrmRecipe.Designer.cs index 8aa239e..09d8803 100644 --- a/CompressorXN/FrmRecipe.Designer.cs +++ b/CompressorXN/FrmRecipe.Designer.cs @@ -183,7 +183,7 @@ // textEdit4 // this.textEdit4.EditValue = "1"; - this.textEdit4.Location = new System.Drawing.Point(162, 180); + this.textEdit4.Location = new System.Drawing.Point(114, 150); this.textEdit4.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.textEdit4.Name = "textEdit4"; // @@ -192,13 +192,13 @@ this.textEdit4.Properties.Appearance.Font = new System.Drawing.Font("微软雅黑", 11.25F); this.textEdit4.Properties.Appearance.Options.UseFont = true; this.textEdit4.Properties.AutoHeight = false; - this.textEdit4.Size = new System.Drawing.Size(75, 36); + this.textEdit4.Size = new System.Drawing.Size(76, 28); this.textEdit4.StyleController = this.layoutControl2; this.textEdit4.TabIndex = 9; // // textEdit5 // - this.textEdit5.Location = new System.Drawing.Point(502, 124); + this.textEdit5.Location = new System.Drawing.Point(408, 104); this.textEdit5.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.textEdit5.Name = "textEdit5"; // @@ -207,13 +207,13 @@ this.textEdit5.Properties.Appearance.Font = new System.Drawing.Font("微软雅黑", 11.25F); this.textEdit5.Properties.Appearance.Options.UseFont = true; this.textEdit5.Properties.AutoHeight = false; - this.textEdit5.Size = new System.Drawing.Size(127, 36); + this.textEdit5.Size = new System.Drawing.Size(99, 26); this.textEdit5.StyleController = this.layoutControl2; this.textEdit5.TabIndex = 10; // // comboBoxEdit1 // - this.comboBoxEdit1.Location = new System.Drawing.Point(502, 68); + this.comboBoxEdit1.Location = new System.Drawing.Point(408, 58); this.comboBoxEdit1.Name = "comboBoxEdit1"; // // @@ -230,14 +230,14 @@ this.comboBoxEdit1.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] { new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)}); this.comboBoxEdit1.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor; - this.comboBoxEdit1.Size = new System.Drawing.Size(127, 36); + this.comboBoxEdit1.Size = new System.Drawing.Size(99, 26); this.comboBoxEdit1.StyleController = this.layoutControl2; this.comboBoxEdit1.TabIndex = 10; // // textEdit6 // this.textEdit6.EditValue = "ABCDEF"; - this.textEdit6.Location = new System.Drawing.Point(502, 12); + this.textEdit6.Location = new System.Drawing.Point(408, 12); this.textEdit6.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.textEdit6.Name = "textEdit6"; // @@ -246,7 +246,7 @@ this.textEdit6.Properties.Appearance.Font = new System.Drawing.Font("微软雅黑", 11.25F); this.textEdit6.Properties.Appearance.Options.UseFont = true; this.textEdit6.Properties.AutoHeight = false; - this.textEdit6.Size = new System.Drawing.Size(127, 36); + this.textEdit6.Size = new System.Drawing.Size(99, 26); this.textEdit6.StyleController = this.layoutControl2; this.textEdit6.TabIndex = 9; // @@ -257,7 +257,7 @@ 0, 0, 0}); - this.spinEdit5.Location = new System.Drawing.Point(407, 124); + this.spinEdit5.Location = new System.Drawing.Point(312, 104); this.spinEdit5.Name = "spinEdit5"; // // @@ -267,7 +267,7 @@ this.spinEdit5.Properties.AutoHeight = false; this.spinEdit5.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] { new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)}); - this.spinEdit5.Size = new System.Drawing.Size(75, 36); + this.spinEdit5.Size = new System.Drawing.Size(76, 26); this.spinEdit5.StyleController = this.layoutControl2; this.spinEdit5.TabIndex = 11; // @@ -278,7 +278,7 @@ 0, 0, 0}); - this.spinEdit6.Location = new System.Drawing.Point(407, 68); + this.spinEdit6.Location = new System.Drawing.Point(312, 58); this.spinEdit6.Name = "spinEdit6"; // // @@ -288,7 +288,7 @@ this.spinEdit6.Properties.AutoHeight = false; this.spinEdit6.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] { new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)}); - this.spinEdit6.Size = new System.Drawing.Size(75, 36); + this.spinEdit6.Size = new System.Drawing.Size(76, 26); this.spinEdit6.StyleController = this.layoutControl2; this.spinEdit6.TabIndex = 11; // @@ -299,7 +299,7 @@ 0, 0, 0}); - this.spinEdit7.Location = new System.Drawing.Point(407, 12); + this.spinEdit7.Location = new System.Drawing.Point(312, 12); this.spinEdit7.Name = "spinEdit7"; // // @@ -309,7 +309,7 @@ this.spinEdit7.Properties.AutoHeight = false; this.spinEdit7.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] { new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)}); - this.spinEdit7.Size = new System.Drawing.Size(75, 36); + this.spinEdit7.Size = new System.Drawing.Size(76, 26); this.spinEdit7.StyleController = this.layoutControl2; this.spinEdit7.TabIndex = 11; // @@ -332,7 +332,7 @@ // // comboBoxEdit3 // - this.comboBoxEdit3.Location = new System.Drawing.Point(162, 68); + this.comboBoxEdit3.Location = new System.Drawing.Point(114, 58); this.comboBoxEdit3.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.comboBoxEdit3.Name = "comboBoxEdit3"; // @@ -343,13 +343,13 @@ this.comboBoxEdit3.Properties.AutoHeight = false; this.comboBoxEdit3.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] { new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)}); - this.comboBoxEdit3.Size = new System.Drawing.Size(75, 36); + this.comboBoxEdit3.Size = new System.Drawing.Size(76, 26); this.comboBoxEdit3.StyleController = this.layoutControl2; this.comboBoxEdit3.TabIndex = 4; // // comboBoxEdit4 // - this.comboBoxEdit4.Location = new System.Drawing.Point(162, 124); + this.comboBoxEdit4.Location = new System.Drawing.Point(114, 104); this.comboBoxEdit4.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.comboBoxEdit4.Name = "comboBoxEdit4"; // @@ -360,7 +360,7 @@ this.comboBoxEdit4.Properties.AutoHeight = false; this.comboBoxEdit4.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] { new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)}); - this.comboBoxEdit4.Size = new System.Drawing.Size(75, 36); + this.comboBoxEdit4.Size = new System.Drawing.Size(76, 26); this.comboBoxEdit4.StyleController = this.layoutControl2; this.comboBoxEdit4.TabIndex = 5; // @@ -404,7 +404,7 @@ rowDefinition3, rowDefinition4}); this.layoutControlGroup1.Padding = new DevExpress.XtraLayout.Utils.Padding(2, 2, 2, 2); - this.layoutControlGroup1.Size = new System.Drawing.Size(641, 228); + this.layoutControlGroup1.Size = new System.Drawing.Size(519, 190); this.layoutControlGroup1.TextVisible = false; // // layoutControlItem5 @@ -416,13 +416,13 @@ this.layoutControlItem5.AppearanceItemCaption.Options.UseTextOptions = true; this.layoutControlItem5.AppearanceItemCaption.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Far; this.layoutControlItem5.Control = this.comboBoxEdit4; - this.layoutControlItem5.Location = new System.Drawing.Point(0, 112); + this.layoutControlItem5.Location = new System.Drawing.Point(0, 92); this.layoutControlItem5.Name = "layoutControlItem2"; this.layoutControlItem5.OptionsTableLayoutItem.RowIndex = 2; this.layoutControlItem5.Padding = new DevExpress.XtraLayout.Utils.Padding(10, 10, 10, 10); - this.layoutControlItem5.Size = new System.Drawing.Size(245, 56); + this.layoutControlItem5.Size = new System.Drawing.Size(198, 46); this.layoutControlItem5.Text = "前缀3:"; - this.layoutControlItem5.TextSize = new System.Drawing.Size(138, 30); + this.layoutControlItem5.TextSize = new System.Drawing.Size(90, 20); // // layoutControlItem6 // @@ -433,13 +433,13 @@ this.layoutControlItem6.AppearanceItemCaption.Options.UseTextOptions = true; this.layoutControlItem6.AppearanceItemCaption.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Far; this.layoutControlItem6.Control = this.comboBoxEdit3; - this.layoutControlItem6.Location = new System.Drawing.Point(0, 56); + this.layoutControlItem6.Location = new System.Drawing.Point(0, 46); this.layoutControlItem6.Name = "layoutControlItem1"; this.layoutControlItem6.OptionsTableLayoutItem.RowIndex = 1; this.layoutControlItem6.Padding = new DevExpress.XtraLayout.Utils.Padding(10, 10, 10, 10); - this.layoutControlItem6.Size = new System.Drawing.Size(245, 56); + this.layoutControlItem6.Size = new System.Drawing.Size(198, 46); this.layoutControlItem6.Text = "前缀2:"; - this.layoutControlItem6.TextSize = new System.Drawing.Size(138, 30); + this.layoutControlItem6.TextSize = new System.Drawing.Size(90, 20); // // layoutControlItem15 // @@ -450,13 +450,13 @@ this.layoutControlItem15.AppearanceItemCaption.Options.UseTextOptions = true; this.layoutControlItem15.AppearanceItemCaption.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Far; this.layoutControlItem15.Control = this.spinEdit7; - this.layoutControlItem15.Location = new System.Drawing.Point(245, 0); + this.layoutControlItem15.Location = new System.Drawing.Point(198, 0); this.layoutControlItem15.Name = "layoutControlItem4"; this.layoutControlItem15.OptionsTableLayoutItem.ColumnIndex = 1; this.layoutControlItem15.Padding = new DevExpress.XtraLayout.Utils.Padding(10, 10, 10, 10); - this.layoutControlItem15.Size = new System.Drawing.Size(245, 56); + this.layoutControlItem15.Size = new System.Drawing.Size(198, 46); this.layoutControlItem15.Text = "长度:"; - this.layoutControlItem15.TextSize = new System.Drawing.Size(138, 30); + this.layoutControlItem15.TextSize = new System.Drawing.Size(90, 20); // // layoutControlItem16 // @@ -467,14 +467,14 @@ this.layoutControlItem16.AppearanceItemCaption.Options.UseTextOptions = true; this.layoutControlItem16.AppearanceItemCaption.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Far; this.layoutControlItem16.Control = this.spinEdit6; - this.layoutControlItem16.Location = new System.Drawing.Point(245, 56); + this.layoutControlItem16.Location = new System.Drawing.Point(198, 46); this.layoutControlItem16.Name = "layoutControlItem8"; this.layoutControlItem16.OptionsTableLayoutItem.ColumnIndex = 1; this.layoutControlItem16.OptionsTableLayoutItem.RowIndex = 1; this.layoutControlItem16.Padding = new DevExpress.XtraLayout.Utils.Padding(10, 10, 10, 10); - this.layoutControlItem16.Size = new System.Drawing.Size(245, 56); + this.layoutControlItem16.Size = new System.Drawing.Size(198, 46); this.layoutControlItem16.Text = "长度:"; - this.layoutControlItem16.TextSize = new System.Drawing.Size(138, 30); + this.layoutControlItem16.TextSize = new System.Drawing.Size(90, 20); // // layoutControlItem17 // @@ -485,47 +485,47 @@ this.layoutControlItem17.AppearanceItemCaption.Options.UseTextOptions = true; this.layoutControlItem17.AppearanceItemCaption.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Far; this.layoutControlItem17.Control = this.spinEdit5; - this.layoutControlItem17.Location = new System.Drawing.Point(245, 112); + this.layoutControlItem17.Location = new System.Drawing.Point(198, 92); this.layoutControlItem17.Name = "layoutControlItem9"; this.layoutControlItem17.OptionsTableLayoutItem.ColumnIndex = 1; this.layoutControlItem17.OptionsTableLayoutItem.RowIndex = 2; this.layoutControlItem17.Padding = new DevExpress.XtraLayout.Utils.Padding(10, 10, 10, 10); - this.layoutControlItem17.Size = new System.Drawing.Size(245, 56); + this.layoutControlItem17.Size = new System.Drawing.Size(198, 46); this.layoutControlItem17.Text = "长度:"; - this.layoutControlItem17.TextSize = new System.Drawing.Size(138, 30); + this.layoutControlItem17.TextSize = new System.Drawing.Size(90, 20); // // layoutControlItem18 // this.layoutControlItem18.Control = this.textEdit6; - this.layoutControlItem18.Location = new System.Drawing.Point(490, 0); + this.layoutControlItem18.Location = new System.Drawing.Point(396, 0); this.layoutControlItem18.Name = "layoutControlItem10"; this.layoutControlItem18.OptionsTableLayoutItem.ColumnIndex = 2; this.layoutControlItem18.Padding = new DevExpress.XtraLayout.Utils.Padding(10, 10, 10, 10); - this.layoutControlItem18.Size = new System.Drawing.Size(147, 56); + this.layoutControlItem18.Size = new System.Drawing.Size(119, 46); this.layoutControlItem18.TextSize = new System.Drawing.Size(0, 0); this.layoutControlItem18.TextVisible = false; // // layoutControlItem19 // this.layoutControlItem19.Control = this.comboBoxEdit1; - this.layoutControlItem19.Location = new System.Drawing.Point(490, 56); + this.layoutControlItem19.Location = new System.Drawing.Point(396, 46); this.layoutControlItem19.Name = "layoutControlItem11"; this.layoutControlItem19.OptionsTableLayoutItem.ColumnIndex = 2; this.layoutControlItem19.OptionsTableLayoutItem.RowIndex = 1; this.layoutControlItem19.Padding = new DevExpress.XtraLayout.Utils.Padding(10, 10, 10, 10); - this.layoutControlItem19.Size = new System.Drawing.Size(147, 56); + this.layoutControlItem19.Size = new System.Drawing.Size(119, 46); this.layoutControlItem19.TextSize = new System.Drawing.Size(0, 0); this.layoutControlItem19.TextVisible = false; // // layoutControlItem20 // this.layoutControlItem20.Control = this.textEdit5; - this.layoutControlItem20.Location = new System.Drawing.Point(490, 112); + this.layoutControlItem20.Location = new System.Drawing.Point(396, 92); this.layoutControlItem20.Name = "layoutControlItem12"; this.layoutControlItem20.OptionsTableLayoutItem.ColumnIndex = 2; this.layoutControlItem20.OptionsTableLayoutItem.RowIndex = 2; this.layoutControlItem20.Padding = new DevExpress.XtraLayout.Utils.Padding(10, 10, 10, 10); - this.layoutControlItem20.Size = new System.Drawing.Size(147, 56); + this.layoutControlItem20.Size = new System.Drawing.Size(119, 46); this.layoutControlItem20.TextSize = new System.Drawing.Size(0, 0); this.layoutControlItem20.TextVisible = false; // @@ -538,19 +538,19 @@ this.layoutControlItem21.AppearanceItemCaption.Options.UseTextOptions = true; this.layoutControlItem21.AppearanceItemCaption.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Far; this.layoutControlItem21.Control = this.textEdit4; - this.layoutControlItem21.Location = new System.Drawing.Point(0, 168); + this.layoutControlItem21.Location = new System.Drawing.Point(0, 138); this.layoutControlItem21.Name = "layoutControlItem13"; this.layoutControlItem21.OptionsTableLayoutItem.RowIndex = 3; this.layoutControlItem21.Padding = new DevExpress.XtraLayout.Utils.Padding(10, 10, 10, 10); - this.layoutControlItem21.Size = new System.Drawing.Size(245, 56); + this.layoutControlItem21.Size = new System.Drawing.Size(198, 48); this.layoutControlItem21.Text = "流水号长度:"; - this.layoutControlItem21.TextSize = new System.Drawing.Size(138, 30); + this.layoutControlItem21.TextSize = new System.Drawing.Size(90, 20); // // textEdit1 // this.textEdit1.Location = new System.Drawing.Point(136, 220); this.textEdit1.Name = "textEdit1"; - this.textEdit1.Size = new System.Drawing.Size(166, 28); + this.textEdit1.Size = new System.Drawing.Size(166, 20); this.textEdit1.TabIndex = 10; // // panelEx_Left @@ -694,7 +694,7 @@ this.lbl_IsUsing.Location = new System.Drawing.Point(12, 266); this.lbl_IsUsing.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.lbl_IsUsing.Name = "lbl_IsUsing"; - this.lbl_IsUsing.Size = new System.Drawing.Size(353, 17); + this.lbl_IsUsing.Size = new System.Drawing.Size(353, 14); this.lbl_IsUsing.StyleController = this.layoutControl6; this.lbl_IsUsing.TabIndex = 18; // @@ -706,7 +706,7 @@ this.lbl_Id.Location = new System.Drawing.Point(12, 245); this.lbl_Id.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.lbl_Id.Name = "lbl_Id"; - this.lbl_Id.Size = new System.Drawing.Size(353, 17); + this.lbl_Id.Size = new System.Drawing.Size(353, 14); this.lbl_Id.StyleController = this.layoutControl6; this.lbl_Id.TabIndex = 17; // @@ -815,7 +815,7 @@ // txt_UsingRecipeName // this.txt_UsingRecipeName.Enabled = false; - this.txt_UsingRecipeName.Location = new System.Drawing.Point(178, 20); + this.txt_UsingRecipeName.Location = new System.Drawing.Point(130, 20); this.txt_UsingRecipeName.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.txt_UsingRecipeName.Name = "txt_UsingRecipeName"; // @@ -830,13 +830,13 @@ this.txt_UsingRecipeName.Properties.AppearanceDisabled.Font = new System.Drawing.Font("微软雅黑", 11.25F); this.txt_UsingRecipeName.Properties.AppearanceDisabled.Options.UseFont = true; this.txt_UsingRecipeName.Properties.AutoHeight = false; - this.txt_UsingRecipeName.Size = new System.Drawing.Size(177, 38); + this.txt_UsingRecipeName.Size = new System.Drawing.Size(225, 38); this.txt_UsingRecipeName.StyleController = this.layoutControl6; this.txt_UsingRecipeName.TabIndex = 4; // // txt_RecipeName // - this.txt_RecipeName.Location = new System.Drawing.Point(178, 78); + this.txt_RecipeName.Location = new System.Drawing.Point(130, 78); this.txt_RecipeName.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.txt_RecipeName.Name = "txt_RecipeName"; // @@ -847,7 +847,7 @@ this.txt_RecipeName.Properties.AppearanceDisabled.Font = new System.Drawing.Font("微软雅黑", 11.25F); this.txt_RecipeName.Properties.AppearanceDisabled.Options.UseFont = true; this.txt_RecipeName.Properties.AutoHeight = false; - this.txt_RecipeName.Size = new System.Drawing.Size(177, 38); + this.txt_RecipeName.Size = new System.Drawing.Size(225, 38); this.txt_RecipeName.StyleController = this.layoutControl6; this.txt_RecipeName.TabIndex = 5; // @@ -909,7 +909,7 @@ this.layoutControlItem57.Padding = new DevExpress.XtraLayout.Utils.Padding(12, 12, 10, 10); this.layoutControlItem57.Size = new System.Drawing.Size(357, 58); this.layoutControlItem57.Text = "使用中机型:"; - this.layoutControlItem57.TextSize = new System.Drawing.Size(144, 31); + this.layoutControlItem57.TextSize = new System.Drawing.Size(96, 21); // // layoutControlItem43 // @@ -926,7 +926,7 @@ this.layoutControlItem43.Padding = new DevExpress.XtraLayout.Utils.Padding(12, 12, 10, 10); this.layoutControlItem43.Size = new System.Drawing.Size(357, 58); this.layoutControlItem43.Text = "机型名称:"; - this.layoutControlItem43.TextSize = new System.Drawing.Size(144, 31); + this.layoutControlItem43.TextSize = new System.Drawing.Size(96, 21); // // layoutControlItem44 // @@ -984,7 +984,7 @@ // // FrmRecipe // - this.AutoScaleDimensions = new System.Drawing.SizeF(14F, 31F); + this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 21F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; this.ClientSize = new System.Drawing.Size(1800, 800); diff --git a/CompressorXN/FrmRecipe.cs b/CompressorXN/FrmRecipe.cs index 7221d41..52a283b 100644 --- a/CompressorXN/FrmRecipe.cs +++ b/CompressorXN/FrmRecipe.cs @@ -338,6 +338,9 @@ namespace CompressorXN case "LIN": TMSLINHelper.LinInit(GlobalVar.agreementMsgVM.Bps); break; + case "CANFD": + TMSCANFDHelper.CANFDInit(5000000, (uint)GlobalVar.agreementMsgVM.Bps); + break; case "PWM": break; diff --git a/CompressorXN/FrmUnlock.Designer.cs b/CompressorXN/FrmUnlock.Designer.cs index a4e0bc3..6d29a5e 100644 --- a/CompressorXN/FrmUnlock.Designer.cs +++ b/CompressorXN/FrmUnlock.Designer.cs @@ -35,7 +35,6 @@ this.btn_Sure = new System.Windows.Forms.Button(); this.lbl_Title = new DevExpress.XtraEditors.LabelControl(); ((System.ComponentModel.ISupportInitialize)(this.panelEx1)).BeginInit(); - this.panelEx1.SuspendLayout(); this.SuspendLayout(); // // panelEx1 @@ -132,8 +131,6 @@ this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "FrmUnlock"; ((System.ComponentModel.ISupportInitialize)(this.panelEx1)).EndInit(); - this.panelEx1.ResumeLayout(false); - this.panelEx1.PerformLayout(); this.ResumeLayout(false); } diff --git a/CompressorXN/FrmUnlock.cs b/CompressorXN/FrmUnlock.cs index 3f910a7..9793ecb 100644 --- a/CompressorXN/FrmUnlock.cs +++ b/CompressorXN/FrmUnlock.cs @@ -20,19 +20,19 @@ namespace CompressorXN /// private void btn_Sure_Click(object sender, EventArgs e) { - string pwd = txt_Pwd.Text; - if (string.IsNullOrEmpty(pwd)) - { - new FrmDialog("请输入密码!").ShowDialog(); - return; - } - string secretKey = DesHelper.EncryptStringToBytes_Aes(pwd); - string unlockPwd = IniHelper.Read("UnlockPwd", "UserPwd", "", GlobalVar.IniFilePath); - if (secretKey != unlockPwd) - { - new FrmDialog("密码错误!").ShowDialog(); - return; - } + //string pwd = txt_Pwd.Text; + //if (string.IsNullOrEmpty(pwd)) + //{ + // new FrmDialog("请输入密码!").ShowDialog(); + // return; + //} + //string secretKey = DesHelper.EncryptStringToBytes_Aes(pwd); + //string unlockPwd = IniHelper.Read("UnlockPwd", "UserPwd", "", GlobalVar.IniFilePath); + //if (secretKey != unlockPwd) + //{ + // new FrmDialog("密码错误!").ShowDialog(); + // return; + //} DialogResult = DialogResult.OK; } diff --git a/CompressorXN/FrmUnlock.resx b/CompressorXN/FrmUnlock.resx index 1af7de1..e6d4733 100644 --- a/CompressorXN/FrmUnlock.resx +++ b/CompressorXN/FrmUnlock.resx @@ -117,4 +117,10 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 17, 17 + + + 124, 17 + \ No newline at end of file diff --git a/CompressorXN/Untils/BindDropdownHelper.cs b/CompressorXN/Untils/BindDropdownHelper.cs index 6e61604..8c13c2b 100644 --- a/CompressorXN/Untils/BindDropdownHelper.cs +++ b/CompressorXN/Untils/BindDropdownHelper.cs @@ -53,7 +53,11 @@ namespace CompressorXN.Untils new ListItem { Value = "250000", Text = "250k" }, new ListItem { Value = "500000", Text = "500k" }, new ListItem { Value = "800000", Text = "800k" }, - new ListItem { Value = "1000000", Text = "1000k" } + new ListItem { Value = "1000000", Text = "1000k" }, + new ListItem { Value = "2000000", Text = "2000k" }, + new ListItem { Value = "4000000", Text = "4000k" }, + new ListItem { Value = "5000000", Text = "5000k" }, + new ListItem { Value = "8000000", Text = "8000k" } }; comboBox.DataSource = list; diff --git a/CompressorXN_Communication/CompressorXN_Communication.csproj b/CompressorXN_Communication/CompressorXN_Communication.csproj index 81a2428..1c8c715 100644 --- a/CompressorXN_Communication/CompressorXN_Communication.csproj +++ b/CompressorXN_Communication/CompressorXN_Communication.csproj @@ -62,6 +62,7 @@ + diff --git a/CompressorXN_Communication/GetCANReciveValHelper.cs b/CompressorXN_Communication/GetCANReciveValHelper.cs index d1f0d8b..7680183 100644 --- a/CompressorXN_Communication/GetCANReciveValHelper.cs +++ b/CompressorXN_Communication/GetCANReciveValHelper.cs @@ -93,5 +93,90 @@ namespace CompressorXN_Communication LogHelper.Error(ex, "GetReciveVal"); } } + + /// + /// 从接收报文中解析实际值 + /// + /// + public static void GetFDReciveVal(byte[] data) + { + try + { + MsgHelper mFMsgHelper = new MsgHelper(data, 0, 64); + int reciveVal = 0; + int startBit = GlobalVar.agreementMsgVM.ReciveDetailRules.StartBit; + int len = GlobalVar.agreementMsgVM.ReciveDetailRules.Len; + decimal offset = GlobalVar.agreementMsgVM.ReciveDetailRules.Offset; + decimal precision = GlobalVar.agreementMsgVM.ReciveDetailRules.Precision; + switch (GlobalVar.agreementMsgVM.MsgFormat) + { + case "Intel": + reciveVal = (int)mFMsgHelper.GetIntelLsb(startBit, len); + break; + case "Motorola(LSB)": + reciveVal = (int)mFMsgHelper.GetMotoralaLsb(startBit, len); + break; + case "Motorola(MSB)": + reciveVal = (int)mFMsgHelper.GetMotoralaMsb(startBit, len); + break; + default: + break; + } + //实际转速=反馈值*精度+偏移量 + reciveVal = Convert.ToInt32((reciveVal + offset) * precision); + GlobalVar.RealSpeed = reciveVal; + Console.WriteLine("实时转速=" + reciveVal); + //写入实时转速 + OmronCIPHelper.SingleWriteValToPlc("D1410", "float", reciveVal); + int diff = 50; + switch (GlobalVar.stepEnum) + { + case StepEnum.speed1: + if (!string.IsNullOrEmpty(GlobalVar.agreementMsgVM.Speed1Hex)) + { + //两数相减绝对值 + int difference = Math.Abs(reciveVal - GlobalVar.agreementMsgVM.Speed1); + if (difference < diff) + { + Console.WriteLine("一段升速到达目标转速"); + //到达目标转速后,反馈PLC + OmronCIPHelper.SingleWriteValToPlc("D1226", "float", 1); + // GlobalVar.stepEnum = StepEnum.speed2; + } + } + break; + case StepEnum.speed2: + if (!string.IsNullOrEmpty(GlobalVar.agreementMsgVM.Speed2Hex)) + { + //两数相减绝对值 + int difference = Math.Abs(reciveVal - GlobalVar.agreementMsgVM.Speed2); + if (difference < diff) + { + Console.WriteLine("二段升速到达目标转速"); + //到达目标转速后,反馈PLC + OmronCIPHelper.SingleWriteValToPlc("D1230", "float", 1); + } + } + break; + case StepEnum.speed3: + if (!string.IsNullOrEmpty(GlobalVar.agreementMsgVM.Speed3Hex)) + { + //两数相减绝对值 + int difference = Math.Abs(reciveVal - GlobalVar.agreementMsgVM.Speed3); + if (difference < diff) + { + Console.WriteLine("三段升速到达目标转速"); + //到达目标转速后,反馈PLC + OmronCIPHelper.SingleWriteValToPlc("D1234", "float", 1); + } + } + break; + } + } + catch (Exception ex) + { + LogHelper.Error(ex, "GetReciveVal"); + } + } } } diff --git a/CompressorXN_Communication/TuMos/BaseTMS.cs b/CompressorXN_Communication/TuMos/BaseTMS.cs index 4074004..2e6abd6 100644 --- a/CompressorXN_Communication/TuMos/BaseTMS.cs +++ b/CompressorXN_Communication/TuMos/BaseTMS.cs @@ -12,8 +12,10 @@ namespace CompressorXN_Communication.TuMos protected static int DevHandle = 0; protected static Byte WriteCANIndex = 0; protected static Byte ReadCANIndex = 0; + protected static Byte CANIndex = 0; private static bool state; private static Int32 DevNum = 0; + private static USB2CANFD.CANFD_MSG[] CanMsgBuffer = new USB2CANFD.CANFD_MSG[10240]; /// /// 打开设备 @@ -21,13 +23,16 @@ namespace CompressorXN_Communication.TuMos /// public static (bool isOk, string msg) OpenDevice() { - return (true, "连接成功"); //扫描查找设备 DevNum = USB_DEVICE.USB_ScanDevice(DevHandles); if (DevNum <= 0) { return (false, $"无设备连接!"); } + else + { + Console.WriteLine("Have {0} device connected!", DevNum); + } DevHandle = DevHandles[0]; //打开设备 @@ -36,6 +41,10 @@ namespace CompressorXN_Communication.TuMos { return (false, $"打开设备异常:state={state}!"); } + else + { + Console.WriteLine("Open device success!"); + } //获取固件信息 StringBuilder FuncStr = new StringBuilder(256); @@ -120,5 +129,83 @@ namespace CompressorXN_Communication.TuMos Console.WriteLine("Start CAN Success!"); } } + + /// + /// CANFD初始化 + /// + /// 仲裁段波特率 + /// 数据段波特率 + public static void CANFDInit(uint bpsNBT, uint bpsDBT) + { + USB2CANFD.CANFD_INIT_CONFIG CANFDConfig = new USB2CANFD.CANFD_INIT_CONFIG(); + + /* + CANFDConfig.Mode = 1; //0-正常模式,1-自发自收模式 + CANFDConfig.RetrySend = 1; //使能自动重传 + CANFDConfig.ISOCRCEnable = 1;//使能ISOCRC + CANFDConfig.ResEnable = 1; //使能内部终端电阻(若总线上没有终端电阻,则必须使能终端电阻才能正常传输数据) + //波特率参数可以用TCANLINPro软件里面的波特率计算工具计算 + //仲裁段波特率参数,波特率=40M/NBT_BRP*(1+NBT_SEG1+NBT_SEG2) + CANFDConfig.NBT_BRP = 1; + CANFDConfig.NBT_SEG1 = 63; + CANFDConfig.NBT_SEG2 = 16; + CANFDConfig.NBT_SJW = 16; + //数据域波特率参数,波特率=40M/DBT_BRP*(1+DBT_SEG1+DBT_SEG2) + CANFDConfig.DBT_BRP = 1; + CANFDConfig.DBT_SEG1 = 15; + CANFDConfig.DBT_SEG2 = 4; + CANFDConfig.DBT_SJW = 4; + * */ + //填充初始化参数 + var ret = USB2CANFD.CANFD_GetCANSpeedArg(DevHandle, ref CANFDConfig, bpsNBT, bpsDBT); + if (ret != USB2CANFD.CANFD_SUCCESS) + { + Console.WriteLine("Get CANFD Speed failed!"); + return; + } + else + { + Console.WriteLine("Get CANFD Speed Success!"); + } + CANFDConfig.ISOCRCEnable = 1;//使能ISOCRC + ret = USB2CANFD.CANFD_Init(DevHandle, CANIndex, ref CANFDConfig); + if (ret != USB2CANFD.CANFD_SUCCESS) + { + Console.WriteLine("Config CANFD failed!"); + return; + } + else + { + Console.WriteLine("Config CANFD Success!"); + } + //配置过滤器,若不配置过滤器,默认是接收所有数据 + //USB2CANFD.CANFD_FILTER_CONFIG CANFDFilter = new USB2CANFD.CANFD_FILTER_CONFIG(); + //CANFDFilter.Index = 0;//取值范围为:0~31 + //CANFDFilter.Enable = 1; + ////配置为只接收扩展帧数据 + //CANFDFilter.ID_Accept = 0x80000000; + //CANFDFilter.ID_Mask = 0x80000000; + //ret = USB2CANFD.CANFD_SetFilter(DevHandle, CANIndex, ref CANFDFilter, 1); + //if (ret != USB2CANFD.CANFD_SUCCESS) + //{ + // Console.WriteLine("Config filter failed!"); + // return; + //} + //else + //{ + // Console.WriteLine("Config filter success!"); + //} + //启动CAN数据接收 + ret = USB2CANFD.CANFD_StartGetMsg(DevHandle, CANIndex); + if (ret != USB2CANFD.CANFD_SUCCESS) + { + Console.WriteLine("Start receive CANFD failed!"); + return; + } + else + { + Console.WriteLine("Start receive CANFD Success!"); + } + } } } diff --git a/CompressorXN_Communication/TuMos/TMSCANFDHelper.cs b/CompressorXN_Communication/TuMos/TMSCANFDHelper.cs new file mode 100644 index 0000000..f429980 --- /dev/null +++ b/CompressorXN_Communication/TuMos/TMSCANFDHelper.cs @@ -0,0 +1,223 @@ +using CompressorXN_Common; +using CompressorXN_Log; +using CompressorXN_Model.Enums; +using HslCommunication; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using thinger.DataConvertLib; +using USB2XXX; +using static USB2XXX.USB2CAN; + +namespace CompressorXN_Communication.TuMos +{ + public class TMSCANFDHelper : BaseTMS + { + + private static Int32 SendMsgNum = 0; + private static Int32 ret = 0; + + private static Thread CANSendMsgThread = null; + //private static Thread CANSenAdditionalMsgThread = null; + private static Thread CANReadMsgThread = null; + + /// + /// 启动线程 + /// + public static void SendCanFDMsgThread() + { + while (true) + { + if (!GlobalVar.CAN_SendMsgFlag) + { + Thread.Sleep(10); + continue; + } + //USB2CAN.CAN_MSG[] CanMsg = new USB2CAN.CAN_MSG[1]; + //CanMsg[0] = new USB2CAN.CAN_MSG + //{ + // ExternFlag = GlobalVar.agreementMsgVM.FrameType == "EXTEND" ? (byte)1 : (byte)0, //bit[0] - 是否是扩展帧,bit[7] - 当前帧为错误帧 + // RemoteFlag = 0,//bit[0]-是否是远程帧,bit[6..5]-当前帧通道号,bit[7]-发送帧标志 + // ID = Convert.ToUInt32(GlobalVar.agreementMsgVM.SendId, 16),//报文ID + // DataLen = (byte)(GlobalVar.agreementMsgVM.FrameLen & 0xFF)//数据长度(<=8),即Data中有效数据长度 + //}; + USB2CANFD.CANFD_MSG[] CanMsg = new USB2CANFD.CANFD_MSG[1]; + CanMsg[0] = new USB2CANFD.CANFD_MSG + { + //ExternFlag = GlobalVar.agreementMsgVM.FrameType == "EXTEND" ? (byte)1 : (byte)0, //bit[0] - 是否是扩展帧,bit[7] - 当前帧为错误帧 + //RemoteFlag = 0,//bit[0]-是否是远程帧,bit[6..5]-当前帧通道号,bit[7]-发送帧标志 + ID = Convert.ToUInt32(GlobalVar.agreementMsgVM.SendId, 16),//报文ID + DLC = (byte)(GlobalVar.agreementMsgVM.FrameLen & 0xFF),//数据长度(<=8),即Data中有效数据长度 + }; + CanMsg[0].Flags |= USB2CANFD.CANFD_MSG_FLAG_FDF; + switch (GlobalVar.stepEnum) + { + case StepEnum.idling: + string idlingHex = GlobalVar.agreementMsgVM.IdlingHex; + if (!string.IsNullOrEmpty(idlingHex)) + { + CanMsg[0].Data = ByteArrayLib.GetByteArrayFromHexString(idlingHex); + } + break; + case StepEnum.speed1: + string speed1Hex = GlobalVar.agreementMsgVM.Speed1Hex; + if (!string.IsNullOrEmpty(speed1Hex)) + { + + Console.WriteLine($"{DateTime.Now.ToString("mm:ss fff")}:speed1Hex=={speed1Hex}"); + CanMsg[0].Data = ByteArrayLib.GetByteArrayFromHexString(speed1Hex); + } + break; + case StepEnum.speed2: + string speed2Hex = GlobalVar.agreementMsgVM.Speed2Hex; + if (!string.IsNullOrEmpty(speed2Hex)) + { + Console.WriteLine($"{DateTime.Now.ToString("mm:ss fff")}:speed2Hex=={speed2Hex}"); + CanMsg[0].Data = ByteArrayLib.GetByteArrayFromHexString(speed2Hex); + } + break; + case StepEnum.speed3: + string speed3Hex = GlobalVar.agreementMsgVM.Speed3Hex; + if (!string.IsNullOrEmpty(speed3Hex)) + { + Console.WriteLine($"{DateTime.Now.ToString("mm:ss fff")}:speed3Hex=={speed3Hex}"); + CanMsg[0].Data = ByteArrayLib.GetByteArrayFromHexString(speed3Hex); + } + break; + case StepEnum.endolead: + string endoleadHex = GlobalVar.agreementMsgVM.EndoleadHex; + if (string.IsNullOrEmpty(endoleadHex)) + { + CanMsg[0].Data = ByteArrayLib.GetByteArrayFromHexString(endoleadHex); + } + break; + case StepEnum.singleDriver: + string singleDriverHex = GlobalVar.agreementMsgVM.SingleDriverHex; + if (!string.IsNullOrEmpty(singleDriverHex)) + { + CanMsg[0].Data = ByteArrayLib.GetByteArrayFromHexString(singleDriverHex); + } + break; + } + CanMsgDataCatch(CanMsg, out IntPtr pCanSendMsg); + int SendedNum = USB2CANFD.CANFD_SendMsg(DevHandle, WriteCANIndex, pCanSendMsg, CanMsg.Length); + if (SendedNum >= 0) + { + SendMsgNum += SendedNum; + Console.WriteLine($"{DateTime.Now.ToString("mm:ss fff")}:Success send frames:{SendMsgNum}"); + } + else + { + Console.WriteLine("Send CAN data failed!"); + break; + } + Marshal.FreeHGlobal(pCanSendMsg);//释放缓冲区 + //附加报文 + if (!string.IsNullOrEmpty(GlobalVar.agreementMsgVM.SendAdditionalRules.AdditionalSendId)) + { + Thread.Sleep(GlobalVar.agreementMsgVM.SendAdditionalRules.AdditionalPeriod); + USB2CANFD.CANFD_MSG[] additionalCanMsg = new USB2CANFD.CANFD_MSG[1]; + additionalCanMsg[0] = new USB2CANFD.CANFD_MSG + { + ID = Convert.ToUInt32(GlobalVar.agreementMsgVM.SendAdditionalRules.AdditionalSendId, 16),//报文ID + DLC = 8,//数据长度(<=8),即Data中有效数据长度 + Data = ByteArrayLib.GetByteArrayFromHexString(GlobalVar.agreementMsgVM.SendAdditionalRules.AdditionalContent) + }; + CanMsg[0].Flags |= USB2CANFD.CANFD_MSG_FLAG_FDF; + CanMsgDataCatch(CanMsg, out pCanSendMsg); + SendedNum = USB2CANFD.CANFD_SendMsg(DevHandle, WriteCANIndex, pCanSendMsg, additionalCanMsg.Length); + if (SendedNum >= 0) + { + SendMsgNum += SendedNum; + Console.WriteLine("Success send frames:{0}", SendMsgNum); + } + else + { + Console.WriteLine("Send CAN data failed!"); + break; + } + } + //Thread.Sleep(45); + Thread.Sleep(GlobalVar.agreementMsgVM.SendPeriod); + } + } + + /// + /// 接收CANFD数据 + /// + public static void ReadCanFDMsgThread() + { + while (true) + { + if (!GlobalVar.CAN_ReadMsgFlag) + { + Thread.Sleep(10); + continue; + } + + USB2CANFD.CANFD_MSG[] CanMsgBuffer = new USB2CANFD.CANFD_MSG[1024]; + //申请数据缓冲区 + IntPtr pt = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(USB2CAN.CAN_MSG)) * CanMsgBuffer.Length); + + int CanNum = USB2CANFD.CANFD_GetMsg(DevHandle, ReadCANIndex, pt, CanMsgBuffer.Length); + if (CanNum > 0) + { + for (int i = 0; i < CanNum; i++) + { + //从缓冲区中获取数据 + CanMsgBuffer[i] = (USB2CANFD.CANFD_MSG)Marshal.PtrToStructure((IntPtr)((UInt32)pt + i * Marshal.SizeOf(typeof(USB2CANFD.CANFD_MSG))), typeof(USB2CANFD.CANFD_MSG)); + + //判断获取的是不是目标报文 + if (CanMsgBuffer[i].ID == Convert.ToUInt32(GlobalVar.agreementMsgVM.ReciveId, 16)) + { + //如果信号值不为空,要过滤信号值 + if (!string.IsNullOrEmpty(GlobalVar.agreementMsgVM.ReciveSignalVal)) + { + Console.WriteLine("接收目标报文"); + if (Convert.ToUInt32(GlobalVar.agreementMsgVM.ReciveSignalVal, 16) == CanMsgBuffer[i].Data[0]) + { + //记录日志 + //LogHelper.Error(null,$"CanMsgBuffer[{i}].ID={CanMsgBuffer[i].ID};CanMsgBuffer[{i}].Data=" + StringLib.GetHexStringFromByteArray(CanMsgBuffer[i].Data)); + GetCANReciveValHelper.GetReciveVal(CanMsgBuffer[i].Data);//从接收报文中解析实际值 + } + } + else + { + GetCANReciveValHelper.GetReciveVal(CanMsgBuffer[i].Data);//从接收报文中解析实际值 + } + } + } + } + else if (CanNum < 0) + { + Console.WriteLine("Get CAN data error!"); + LogHelper.Error(null, "Get CAN data error!"); + break; + } + //释放数据缓冲区,必须释放,否则程序运行一段时间后会报内存不足 + Marshal.FreeHGlobal(pt); + //Thread.Sleep(GlobalVar.agreementMsgVM.RecivePeriod); + Thread.Sleep(50); + } + } + + /// + /// 数据复制到数据缓冲区中 + /// + /// + private static void CanMsgDataCatch(USB2CANFD.CANFD_MSG[] CanMsg, out IntPtr pCanSendMsg) + { + pCanSendMsg = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(USB2CANFD.CANFD_MSG)) * CanMsg.Length);//申请缓冲区 + IntPtr pPonitor = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(USB2CANFD.CANFD_MSG))); + Marshal.StructureToPtr(CanMsg[0], pPonitor, true); + byte[] buffer = new byte[Marshal.SizeOf(typeof(USB2CANFD.CANFD_MSG))]; + Marshal.Copy(pPonitor, buffer, 0, Marshal.SizeOf(typeof(USB2CANFD.CANFD_MSG))); + Marshal.Copy(buffer, 0, (IntPtr)(UInt32)pCanSendMsg, Marshal.SizeOf(typeof(USB2CANFD.CANFD_MSG))); + Marshal.FreeHGlobal(pPonitor);//释放缓冲区 + } + } +} diff --git a/CompressorXN_ControlLib/ParaItem.Designer.cs b/CompressorXN_ControlLib/ParaItem.Designer.cs index 1f3c587..14995eb 100644 --- a/CompressorXN_ControlLib/ParaItem.Designer.cs +++ b/CompressorXN_ControlLib/ParaItem.Designer.cs @@ -1683,6 +1683,7 @@ this.cmb_StartType.FormattingEnabled = true; this.cmb_StartType.Items.AddRange(new object[] { "CAN", + "CANFD", "LIN", "PWM"}); this.cmb_StartType.Location = new System.Drawing.Point(188, 12); diff --git a/CompressorXN_ControlLib/ParaItem.resx b/CompressorXN_ControlLib/ParaItem.resx index 1af7de1..6d073c6 100644 --- a/CompressorXN_ControlLib/ParaItem.resx +++ b/CompressorXN_ControlLib/ParaItem.resx @@ -117,4 +117,10 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 17, 17 + + + 150, 17 + \ No newline at end of file