Commit 787a5e24 LN

增加负载率获取

1 个父辈 7c3ec452
......@@ -39,6 +39,9 @@
this.axStsMonitor_timer = new System.Windows.Forms.Timer(this.components);
this.tabControl1 = new System.Windows.Forms.TabControl();
this.tabPage1 = new System.Windows.Forms.TabPage();
this.groupBox11 = new System.Windows.Forms.GroupBox();
this.btnSearch = new System.Windows.Forms.Button();
this.txtFuzai = new System.Windows.Forms.TextBox();
this.groupBox8 = new System.Windows.Forms.GroupBox();
this.btnSetValue = new System.Windows.Forms.Button();
this.label77 = new System.Windows.Forms.Label();
......@@ -185,6 +188,7 @@
this.lblDI1 = new System.Windows.Forms.Label();
this.tabPage3 = new System.Windows.Forms.TabPage();
this.groupBox5 = new System.Windows.Forms.GroupBox();
this.chbAuto = new System.Windows.Forms.CheckBox();
this.lblAdSts = new System.Windows.Forms.Label();
this.txtAdSts4 = new System.Windows.Forms.TextBox();
this.label11 = new System.Windows.Forms.Label();
......@@ -212,9 +216,13 @@
this.richTextBox1 = new System.Windows.Forms.RichTextBox();
this.timerIO = new System.Windows.Forms.Timer(this.components);
this.timerMain = new System.Windows.Forms.Timer(this.components);
this.chbAuto = new System.Windows.Forms.CheckBox();
this.label13 = new System.Windows.Forms.Label();
this.label14 = new System.Windows.Forms.Label();
this.btnSearchNj = new System.Windows.Forms.Button();
this.txtNuiju = new System.Windows.Forms.TextBox();
this.tabControl1.SuspendLayout();
this.tabPage1.SuspendLayout();
this.groupBox11.SuspendLayout();
this.groupBox8.SuspendLayout();
this.groupBox7.SuspendLayout();
this.groupBox6.SuspendLayout();
......@@ -326,6 +334,7 @@
// tabPage1
//
this.tabPage1.BackColor = System.Drawing.Color.White;
this.tabPage1.Controls.Add(this.groupBox11);
this.tabPage1.Controls.Add(this.groupBox8);
this.tabPage1.Controls.Add(this.groupBox7);
this.tabPage1.Controls.Add(this.groupBox6);
......@@ -340,6 +349,42 @@
this.tabPage1.TabIndex = 0;
this.tabPage1.Text = " 单轴运动测试 ";
//
// groupBox11
//
this.groupBox11.Controls.Add(this.label14);
this.groupBox11.Controls.Add(this.btnSearchNj);
this.groupBox11.Controls.Add(this.txtNuiju);
this.groupBox11.Controls.Add(this.label13);
this.groupBox11.Controls.Add(this.btnSearch);
this.groupBox11.Controls.Add(this.txtFuzai);
this.groupBox11.Location = new System.Drawing.Point(249, 438);
this.groupBox11.Name = "groupBox11";
this.groupBox11.Size = new System.Drawing.Size(496, 100);
this.groupBox11.TabIndex = 16;
this.groupBox11.TabStop = false;
this.groupBox11.Text = "监控参数";
//
// btnSearch
//
this.btnSearch.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnSearch.Location = new System.Drawing.Point(197, 17);
this.btnSearch.Margin = new System.Windows.Forms.Padding(2);
this.btnSearch.Name = "btnSearch";
this.btnSearch.Size = new System.Drawing.Size(100, 35);
this.btnSearch.TabIndex = 18;
this.btnSearch.Text = "查询负载率";
this.btnSearch.UseVisualStyleBackColor = true;
this.btnSearch.Click += new System.EventHandler(this.btnSearch_Click);
//
// txtFuzai
//
this.txtFuzai.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txtFuzai.Location = new System.Drawing.Point(76, 21);
this.txtFuzai.Margin = new System.Windows.Forms.Padding(2);
this.txtFuzai.Name = "txtFuzai";
this.txtFuzai.Size = new System.Drawing.Size(109, 26);
this.txtFuzai.TabIndex = 14;
//
// groupBox8
//
this.groupBox8.Controls.Add(this.btnSetValue);
......@@ -1323,11 +1368,11 @@
this.tabPage2.Controls.Add(this.groupBox9);
this.tabPage2.Controls.Add(this.groupBox10);
this.tabPage2.Controls.Add(this.groupBox1);
this.tabPage2.Location = new System.Drawing.Point(4, 26);
this.tabPage2.Location = new System.Drawing.Point(4, 22);
this.tabPage2.Margin = new System.Windows.Forms.Padding(2);
this.tabPage2.Name = "tabPage2";
this.tabPage2.Padding = new System.Windows.Forms.Padding(2);
this.tabPage2.Size = new System.Drawing.Size(750, 558);
this.tabPage2.Size = new System.Drawing.Size(750, 562);
this.tabPage2.TabIndex = 1;
this.tabPage2.Text = " 数字量IO ";
//
......@@ -2041,9 +2086,9 @@
// tabPage3
//
this.tabPage3.Controls.Add(this.groupBox5);
this.tabPage3.Location = new System.Drawing.Point(4, 26);
this.tabPage3.Location = new System.Drawing.Point(4, 22);
this.tabPage3.Name = "tabPage3";
this.tabPage3.Size = new System.Drawing.Size(750, 558);
this.tabPage3.Size = new System.Drawing.Size(750, 562);
this.tabPage3.TabIndex = 2;
this.tabPage3.Text = " 模拟量AIO ";
this.tabPage3.UseVisualStyleBackColor = true;
......@@ -2076,6 +2121,17 @@
this.groupBox5.TabStop = false;
this.groupBox5.Text = "读取测试";
//
// chbAuto
//
this.chbAuto.AutoSize = true;
this.chbAuto.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.chbAuto.Location = new System.Drawing.Point(193, 217);
this.chbAuto.Name = "chbAuto";
this.chbAuto.Size = new System.Drawing.Size(84, 24);
this.chbAuto.TabIndex = 32;
this.chbAuto.Text = "自动读取";
this.chbAuto.UseVisualStyleBackColor = true;
//
// lblAdSts
//
this.lblAdSts.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
......@@ -2356,16 +2412,46 @@
this.timerMain.Interval = 1000;
this.timerMain.Tick += new System.EventHandler(this.timerMain_Tick);
//
// chbAuto
//
this.chbAuto.AutoSize = true;
this.chbAuto.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.chbAuto.Location = new System.Drawing.Point(193, 217);
this.chbAuto.Name = "chbAuto";
this.chbAuto.Size = new System.Drawing.Size(84, 24);
this.chbAuto.TabIndex = 32;
this.chbAuto.Text = "自动读取";
this.chbAuto.UseVisualStyleBackColor = true;
// label13
//
this.label13.AutoSize = true;
this.label13.Location = new System.Drawing.Point(17, 26);
this.label13.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.label13.Name = "label13";
this.label13.Size = new System.Drawing.Size(47, 17);
this.label13.TabIndex = 19;
this.label13.Text = "负载率:";
//
// label14
//
this.label14.AutoSize = true;
this.label14.Location = new System.Drawing.Point(17, 65);
this.label14.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.label14.Name = "label14";
this.label14.Size = new System.Drawing.Size(56, 17);
this.label14.TabIndex = 22;
this.label14.Text = "扭矩值:";
//
// btnSearchNj
//
this.btnSearchNj.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnSearchNj.Location = new System.Drawing.Point(197, 56);
this.btnSearchNj.Margin = new System.Windows.Forms.Padding(2);
this.btnSearchNj.Name = "btnSearchNj";
this.btnSearchNj.Size = new System.Drawing.Size(100, 35);
this.btnSearchNj.TabIndex = 21;
this.btnSearchNj.Text = "查询扭矩";
this.btnSearchNj.UseVisualStyleBackColor = true;
this.btnSearchNj.Click += new System.EventHandler(this.btnSearchNj_Click);
//
// txtNuiju
//
this.txtNuiju.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txtNuiju.Location = new System.Drawing.Point(76, 60);
this.txtNuiju.Margin = new System.Windows.Forms.Padding(2);
this.txtNuiju.Name = "txtNuiju";
this.txtNuiju.Size = new System.Drawing.Size(109, 26);
this.txtNuiju.TabIndex = 20;
//
// FrmHuiChuanTest
//
......@@ -2384,6 +2470,8 @@
this.Load += new System.EventHandler(this.FrmHuiChuanTest_Load);
this.tabControl1.ResumeLayout(false);
this.tabPage1.ResumeLayout(false);
this.groupBox11.ResumeLayout(false);
this.groupBox11.PerformLayout();
this.groupBox8.ResumeLayout(false);
this.groupBox8.PerformLayout();
this.groupBox7.ResumeLayout(false);
......@@ -2598,5 +2686,12 @@
private System.Windows.Forms.Label label6;
private System.Windows.Forms.Label lblAdSts;
private System.Windows.Forms.CheckBox chbAuto;
private System.Windows.Forms.GroupBox groupBox11;
private System.Windows.Forms.Button btnSearch;
private System.Windows.Forms.TextBox txtFuzai;
private System.Windows.Forms.Label label13;
private System.Windows.Forms.Label label14;
private System.Windows.Forms.Button btnSearchNj;
private System.Windows.Forms.TextBox txtNuiju;
}
}
\ No newline at end of file
......@@ -218,13 +218,17 @@ namespace HuichuanLibrary
MessageBox.Show("轴号为空!");
return;
}
axStsMonitor_timer.Enabled = true;
StsTimeStatus(true);
}
private void btnStopTimer_Click(object sender, EventArgs e)
private void StsTimeStatus(bool enable)
{
axStsMonitor_timer.Enabled = false;
btnStopTimer.Enabled = false;
btnStartTimer.Enabled = !enable;
}
private void btnStopTimer_Click(object sender, EventArgs e)
{
StsTimeStatus(false);
}
private void btnPtpMove_Click(object sender, EventArgs e)
......@@ -364,6 +368,10 @@ namespace HuichuanLibrary
short value = HCBoardManager.GetHomeStatus(GetAxisNo());
string homesstr = HCBoardManager.AxisHomeSts(value);
lblhomeSts.Text = homesstr;
//txtFuzai.Text = HCBoardManager.GetAxisLoadRate(axisNo);
btnSearch_Click(null,null);
btnSearchNj_Click(null, null);
}
private void btnSetBitDO_Click(object sender, EventArgs e)
......@@ -621,7 +629,7 @@ namespace HuichuanLibrary
groupBox8.Enabled = isOk;
groupBox9.Enabled = isOk;
groupBox10.Enabled = isOk;
groupBox11.Enabled = isOk;
btnSuddenStop.Enabled = isOk;
btnCancelStop.Enabled = isOk;
......@@ -662,5 +670,17 @@ namespace HuichuanLibrary
string output = Convert.ToString(input, 2).ToString().PadLeft(8, '0');
return output;
}
private void btnSearch_Click(object sender, EventArgs e)
{
short axisNo = GetAxisNo();
//txtFuzai.Text = HCBoardManager.GetAxisLoadRate(axisNo).ToString();
}
private void btnSearchNj_Click(object sender, EventArgs e)
{
short axisNo = GetAxisNo();
txtNuiju.Text = HCBoardManager.GetAxActTorq(axisNo).ToString();
}
}
}
......@@ -874,6 +874,64 @@ namespace HuichuanLibrary
return sStr;
}
#endregion
/// <summary>
/// 获取轴的负载率
/// </summary>
/// <param name="axisNo"></param>
/// <returns></returns>
public static string GetAxisLoadRate(short axisNo)
{
short pPhyStation_Id = 0;
short pPhySlot_id = 0;
UInt32 ret1 = ImcApi.IMC_GetAxEcatStation(nCardHandle, (ushort)axisNo, ref pPhyStation_Id, ref pPhySlot_id);
ushort index = 0x200b;
ushort subindex = 13;
uint targetsize = 2;
int datasize = 2;
uint resultSize = 0;
uint abortCode = 0;
Byte[] targetData = new Byte[targetsize];
UInt32 ret = ImcApi.IMC_GetEcatSdo(nCardHandle, pPhyStation_Id, index, subindex, targetData, targetsize, ref resultSize, ref abortCode);
if (resultSize > 0)
{
string strFromat = "{0:X2}";
string str = "";
foreach (byte b in targetData)
{
str += string.Format(strFromat, b);
}
int value = Convert.ToInt32(str.Trim().Replace(" ", ""), 16);
HCLogUtil.info($"axisNo={axisNo},pPhyStation_Id={pPhyStation_Id},index={index},subindex= {subindex},abortCode ={abortCode},resultSize={resultSize}, str={str},value={value}" );
return value.ToString();
}
else
{
HCLogUtil.info($"axisNo={axisNo},pPhyStation_Id={pPhyStation_Id},index={index},subindex= {subindex},abortCode ={abortCode},resultSize={resultSize},");
}
return "";
}
/// <summary>
/// 获取轴的扭矩
/// </summary>
/// <param name="axisNo"></param>
/// <returns></returns>
public static short GetAxActTorq(short axisNo)
{
short pActTrq = 0;
UInt32 ret = ImcApi.IMC_GetAxActTorq(nCardHandle, axisNo, ref pActTrq);
HCLogUtil.info($"axisNo={axisNo},pActTrq={pActTrq},");
return pActTrq;
}
/// <summary>
/// 回原点状态:0=正在回零中
/// </summary>
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!