Commit 4eb33448 LN

负载率功能修改

1 个父辈 11c81d5d
......@@ -40,6 +40,10 @@
this.tabControl1 = new System.Windows.Forms.TabControl();
this.tabPage1 = new System.Windows.Forms.TabPage();
this.groupBox11 = new System.Windows.Forms.GroupBox();
this.label14 = new System.Windows.Forms.Label();
this.btnSearchNj = new System.Windows.Forms.Button();
this.txtNuiju = new System.Windows.Forms.TextBox();
this.label13 = new System.Windows.Forms.Label();
this.btnSearch = new System.Windows.Forms.Button();
this.txtFuzai = new System.Windows.Forms.TextBox();
this.groupBox8 = new System.Windows.Forms.GroupBox();
......@@ -216,10 +220,9 @@
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.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.groupBox12 = new System.Windows.Forms.GroupBox();
this.btnSaveMaxFuzai = new System.Windows.Forms.Button();
this.txtMaxFuzai = new System.Windows.Forms.TextBox();
this.tabControl1.SuspendLayout();
this.tabPage1.SuspendLayout();
this.groupBox11.SuspendLayout();
......@@ -238,6 +241,7 @@
this.tabPage3.SuspendLayout();
this.groupBox5.SuspendLayout();
this.groupBoard.SuspendLayout();
this.groupBox12.SuspendLayout();
this.SuspendLayout();
//
// btnGetBitDI
......@@ -324,16 +328,17 @@
this.tabControl1.Controls.Add(this.tabPage1);
this.tabControl1.Controls.Add(this.tabPage2);
this.tabControl1.Controls.Add(this.tabPage3);
this.tabControl1.Location = new System.Drawing.Point(4, 113);
this.tabControl1.Location = new System.Drawing.Point(4, 111);
this.tabControl1.Margin = new System.Windows.Forms.Padding(2);
this.tabControl1.Name = "tabControl1";
this.tabControl1.SelectedIndex = 0;
this.tabControl1.Size = new System.Drawing.Size(758, 588);
this.tabControl1.Size = new System.Drawing.Size(758, 626);
this.tabControl1.TabIndex = 34;
//
// tabPage1
//
this.tabPage1.BackColor = System.Drawing.Color.White;
this.tabPage1.Controls.Add(this.groupBox12);
this.tabPage1.Controls.Add(this.groupBox11);
this.tabPage1.Controls.Add(this.groupBox8);
this.tabPage1.Controls.Add(this.groupBox7);
......@@ -345,7 +350,7 @@
this.tabPage1.Margin = new System.Windows.Forms.Padding(2);
this.tabPage1.Name = "tabPage1";
this.tabPage1.Padding = new System.Windows.Forms.Padding(2);
this.tabPage1.Size = new System.Drawing.Size(750, 558);
this.tabPage1.Size = new System.Drawing.Size(750, 596);
this.tabPage1.TabIndex = 0;
this.tabPage1.Text = " 单轴运动测试 ";
//
......@@ -357,13 +362,54 @@
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.Location = new System.Drawing.Point(249, 434);
this.groupBox11.Name = "groupBox11";
this.groupBox11.Size = new System.Drawing.Size(496, 100);
this.groupBox11.Size = new System.Drawing.Size(313, 100);
this.groupBox11.TabIndex = 16;
this.groupBox11.TabStop = false;
this.groupBox11.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;
//
// 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 = "负载率:";
//
// btnSearch
//
this.btnSearch.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
......@@ -2396,9 +2442,9 @@
this.richTextBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.richTextBox1.Location = new System.Drawing.Point(766, 4);
this.richTextBox1.Location = new System.Drawing.Point(766, 12);
this.richTextBox1.Name = "richTextBox1";
this.richTextBox1.Size = new System.Drawing.Size(405, 697);
this.richTextBox1.Size = new System.Drawing.Size(405, 727);
this.richTextBox1.TabIndex = 36;
this.richTextBox1.Text = "";
//
......@@ -2412,52 +2458,44 @@
this.timerMain.Interval = 1000;
this.timerMain.Tick += new System.EventHandler(this.timerMain_Tick);
//
// 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;
// groupBox12
//
this.groupBox12.Controls.Add(this.btnSaveMaxFuzai);
this.groupBox12.Controls.Add(this.txtMaxFuzai);
this.groupBox12.Location = new System.Drawing.Point(578, 434);
this.groupBox12.Name = "groupBox12";
this.groupBox12.Size = new System.Drawing.Size(167, 100);
this.groupBox12.TabIndex = 17;
this.groupBox12.TabStop = false;
this.groupBox12.Text = "最大负载率";
//
// btnSaveMaxFuzai
//
this.btnSaveMaxFuzai.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnSaveMaxFuzai.Location = new System.Drawing.Point(21, 52);
this.btnSaveMaxFuzai.Margin = new System.Windows.Forms.Padding(2);
this.btnSaveMaxFuzai.Name = "btnSaveMaxFuzai";
this.btnSaveMaxFuzai.Size = new System.Drawing.Size(100, 35);
this.btnSaveMaxFuzai.TabIndex = 21;
this.btnSaveMaxFuzai.Text = "保存";
this.btnSaveMaxFuzai.UseVisualStyleBackColor = true;
this.btnSaveMaxFuzai.Click += new System.EventHandler(this.btnSaveMaxFuzai_Click);
//
// txtMaxFuzai
//
this.txtMaxFuzai.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txtMaxFuzai.Location = new System.Drawing.Point(16, 22);
this.txtMaxFuzai.Margin = new System.Windows.Forms.Padding(2);
this.txtMaxFuzai.Name = "txtMaxFuzai";
this.txtMaxFuzai.Size = new System.Drawing.Size(109, 26);
this.txtMaxFuzai.TabIndex = 20;
this.txtMaxFuzai.Text = "10";
//
// FrmHuiChuanTest
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.BackColor = System.Drawing.Color.White;
this.ClientSize = new System.Drawing.Size(1175, 711);
this.ClientSize = new System.Drawing.Size(1175, 749);
this.Controls.Add(this.richTextBox1);
this.Controls.Add(this.tabControl1);
this.Controls.Add(this.groupBoard);
......@@ -2498,6 +2536,8 @@
this.groupBox5.PerformLayout();
this.groupBoard.ResumeLayout(false);
this.groupBoard.PerformLayout();
this.groupBox12.ResumeLayout(false);
this.groupBox12.PerformLayout();
this.ResumeLayout(false);
}
......@@ -2693,5 +2733,8 @@
private System.Windows.Forms.Label label14;
private System.Windows.Forms.Button btnSearchNj;
private System.Windows.Forms.TextBox txtNuiju;
private System.Windows.Forms.GroupBox groupBox12;
private System.Windows.Forms.Button btnSaveMaxFuzai;
private System.Windows.Forms.TextBox txtMaxFuzai;
}
}
\ No newline at end of file
......@@ -38,7 +38,7 @@ namespace HuichuanLibrary
DILabelList.Add(lblDI13);
DILabelList.Add(lblDI14);
DILabelList.Add(lblDI15);
for(int i = 0; i < DILabelList.Count; i++)
for (int i = 0; i < DILabelList.Count; i++)
{
DILabelList[i].Text = "DI_" + i;
}
......@@ -87,9 +87,9 @@ namespace HuichuanLibrary
FormStatus(false);
timerIO.Start();
timerMain.Start();
lblAdSts.Text ="状态说明:\r\n"+
"Bit0 ,负载电压故障,0:正常,1:未接入外部电源\r\n" +
"Bit1 ,模拟芯片连接错误,0:正常,1:数字版与模拟板通讯错误\r\n" +
lblAdSts.Text = "状态说明:\r\n" +
"Bit0 ,负载电压故障,0:正常,1:未接入外部电源\r\n" +
"Bit1 ,模拟芯片连接错误,0:正常,1:数字版与模拟板通讯错误\r\n" +
"Bit2:通道故障\r\n" +
"Bit3:通道上溢\r\n" +
"Bit4:通道下溢\r\n" +
......@@ -98,8 +98,78 @@ namespace HuichuanLibrary
"Bit7:通道断线\r\n";
HCLogUtil.logBox = richTextBox1;
HCLogUtil.logBox = richTextBox1;
axisTimer = new System.Timers.Timer();
axisTimer.Interval = 200;
axisTimer.AutoReset = true;
axisTimer.Enabled = false;
axisTimer.Elapsed += AxisTimer_Elapsed;
txtMaxFuzai.Text = MaxFuZai.ToString();
groupBox12.Text = "最大负载率=" + MaxFuZai;
}
private void AxisTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
//200毫秒检测一次运动轴,如果负载率超过指定值,直接停止
//如果停止运动,从集合移除;
List<short> axiss = new List<short>(moveAxisNoList);
foreach (short axisNo in axiss)
{
AxisSts sts = HCBoardManager.GetAxisSts(axisNo);
if (sts.ServoOn <= 0)
{
HCLogUtil.error($"AxisTimer_Elapsed 轴号{axisNo} 伺服已关闭,removeMoveAxis");
removeMoveAxis(axisNo);
}
//判断是否再运动中
if (sts.BUSY <= 0)
{
HCLogUtil.error($"AxisTimer_Elapsed 轴号{axisNo} 已停止运动,removeMoveAxis");
removeMoveAxis(axisNo);
}
float currFuzai = HCBoardManager.GetAxisLoadRate(axisNo);
if (currFuzai > MaxFuZai)
{
HCLogUtil.error($"AxisTimer_Elapsed 轴号{axisNo} 当前负载率{currFuzai}大于最大负载率{MaxFuZai},停止运动,removeMoveAxis");
HCBoardManager.AxisStop(axisNo);
removeMoveAxis(axisNo);
}
}
}
private void removeMoveAxis(short axisNo)
{
try
{
HCLogUtil.info($"removeMoveAxis{axisNo}");
moveAxisNoList.Remove(axisNo);
}
catch(Exception ex)
{
}
}
private void addMoveAxis(short axisNo)
{
try
{
if (!moveAxisNoList.Contains(axisNo))
{
HCLogUtil.info($"addMoveAxis{axisNo}");
moveAxisNoList.Add(axisNo);
}
}
catch (Exception ex)
{
}
}
private List<short> moveAxisNoList = new List<short>();
private System.Timers.Timer axisTimer;
private float MaxFuZai = 10;
private void btnInitBoard_Click(object sender, EventArgs e)
{
bool result = HCBoardManager.OpenCard(1);
......@@ -242,6 +312,12 @@ namespace HuichuanLibrary
double ptpPos = Convert.ToDouble(txtPtpPos.Text);
HCBoardManager.AbsMove(axisNo, ptpPos, ptpVel, ptpAcc, ptpDec);
addMoveAxis(axisNo);
if (!axisTimer.Enabled)
{
HCLogUtil.info("启动axisTimer");
axisTimer.Start();
}
}
private void btnRelMove_Click(object sender, EventArgs e)
......@@ -255,6 +331,12 @@ namespace HuichuanLibrary
double ptpPos = Convert.ToDouble(txtPtpPos.Text);
HCBoardManager.RelMove(axisNo, ptpPos, ptpVel, ptpAcc, ptpDec);
addMoveAxis(axisNo);
if (!axisTimer.Enabled)
{
HCLogUtil.info("启动axisTimer");
axisTimer.Start();
}
}
private void btnAxisStop_Click(object sender, EventArgs e)
{
......@@ -298,7 +380,14 @@ namespace HuichuanLibrary
{
if (value.Equals(1))
{
lbl.BackColor = Color.Lime;
if (lbl.Text.Equals("ALM"))
{
lbl.BackColor = Color.Red;
}
else
{
lbl.BackColor = Color.Lime;
}
}
else if (value.Equals(0))
{
......@@ -674,7 +763,7 @@ namespace HuichuanLibrary
private void btnSearch_Click(object sender, EventArgs e)
{
short axisNo = GetAxisNo();
//txtFuzai.Text = HCBoardManager.GetAxisLoadRate(axisNo).ToString();
txtFuzai.Text = HCBoardManager.GetAxisLoadRate(axisNo).ToString();
}
private void btnSearchNj_Click(object sender, EventArgs e)
......@@ -682,5 +771,30 @@ namespace HuichuanLibrary
short axisNo = GetAxisNo();
txtNuiju.Text = HCBoardManager.GetAxActTorq(axisNo).ToString();
}
private void btnSaveMaxFuzai_Click(object sender, EventArgs e)
{
float v = 0;
try
{
v = (float)Convert.ToDecimal(txtMaxFuzai.Text);
}
catch (Exception ex)
{
}
if (v > 0)
{
MaxFuZai = v;
MessageBox.Show("已设置最大负载率=" + MaxFuZai);
}
else
{
MessageBox.Show("设置失败");
}
groupBox12.Text = "最大负载率=" + MaxFuZai;
}
}
}
......@@ -905,7 +905,7 @@ namespace HuichuanLibrary
/// </summary>
/// <param name="axisNo"></param>
/// <returns></returns>
public static string GetAxisLoadRate(short axisNo)
public static float GetAxisLoadRate(short axisNo)
{
short pPhyStation_Id = 0;
short pPhySlot_id = 0;
......@@ -913,6 +913,7 @@ namespace HuichuanLibrary
ushort index = 0x200b;
ushort subindex = 13;
//扭矩 3;
uint targetsize = 2;
int datasize = 2;
uint resultSize = 0;
......@@ -931,14 +932,15 @@ namespace HuichuanLibrary
}
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();
float v = (float)value / 2560;
HCLogUtil.info($"axisNo={axisNo},pPhyStation_Id={pPhyStation_Id},index={index},subindex= {subindex},abortCode ={abortCode},resultSize={resultSize}, str={str},value={value},v={v}" );
return v;
}
else
{
HCLogUtil.info($"axisNo={axisNo},pPhyStation_Id={pPhyStation_Id},index={index},subindex= {subindex},abortCode ={abortCode},resultSize={resultSize},");
}
return "";
return 0;
}
/// <summary>
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!