Commit 03aa9174 LN

增加升降轴调试

1 个父辈 e2f26200
...@@ -113,6 +113,12 @@ ...@@ -113,6 +113,12 @@
<DependentUpon>FrmStoreBox.cs</DependentUpon> <DependentUpon>FrmStoreBox.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="ManagerUtil.cs" /> <Compile Include="ManagerUtil.cs" />
<Compile Include="positionTool\FrmPositionTool.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="positionTool\FrmPositionTool.Designer.cs">
<DependentUpon>FrmPositionTool.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" /> <Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="useControl\AxisMoveControl.cs"> <Compile Include="useControl\AxisMoveControl.cs">
...@@ -139,6 +145,9 @@ ...@@ -139,6 +145,9 @@
<EmbeddedResource Include="FrmStoreBox.resx"> <EmbeddedResource Include="FrmStoreBox.resx">
<DependentUpon>FrmStoreBox.cs</DependentUpon> <DependentUpon>FrmStoreBox.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="positionTool\FrmPositionTool.resx">
<DependentUpon>FrmPositionTool.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx"> <EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator> <Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput> <LastGenOutput>Resources.Designer.cs</LastGenOutput>
......
...@@ -59,6 +59,7 @@ ...@@ -59,6 +59,7 @@
this.btnOpenDoor = new System.Windows.Forms.Button(); this.btnOpenDoor = new System.Windows.Forms.Button();
this.richTextBox1 = new System.Windows.Forms.RichTextBox(); this.richTextBox1 = new System.Windows.Forms.RichTextBox();
this.tabPage1 = new System.Windows.Forms.TabPage(); this.tabPage1 = new System.Windows.Forms.TabPage();
this.axisMoveControl1 = new OnlineStore.ACPackingStore.AxisMoveControl();
this.tabPage2 = new System.Windows.Forms.TabPage(); this.tabPage2 = new System.Windows.Forms.TabPage();
this.groupCode = new System.Windows.Forms.GroupBox(); this.groupCode = new System.Windows.Forms.GroupBox();
this.txtCode = new System.Windows.Forms.TextBox(); this.txtCode = new System.Windows.Forms.TextBox();
...@@ -168,7 +169,7 @@ ...@@ -168,7 +169,7 @@
this.开启DEBUGToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.开启DEBUGToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator12 = new System.Windows.Forms.ToolStripSeparator(); this.toolStripSeparator12 = new System.Windows.Forms.ToolStripSeparator();
this.清理日志ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.清理日志ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.axisMoveControl1 = new OnlineStore.ACPackingStore.AxisMoveControl(); this.btnUpdown = new System.Windows.Forms.Button();
this.contextMenuStrip1.SuspendLayout(); this.contextMenuStrip1.SuspendLayout();
this.tabControl2.SuspendLayout(); this.tabControl2.SuspendLayout();
this.tabPage4.SuspendLayout(); this.tabPage4.SuspendLayout();
...@@ -256,7 +257,7 @@ ...@@ -256,7 +257,7 @@
this.chbBuzzer.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.chbBuzzer.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.chbBuzzer.AutoSize = true; this.chbBuzzer.AutoSize = true;
this.chbBuzzer.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.chbBuzzer.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.chbBuzzer.Location = new System.Drawing.Point(773, 13); this.chbBuzzer.Location = new System.Drawing.Point(683, 13);
this.chbBuzzer.Name = "chbBuzzer"; this.chbBuzzer.Name = "chbBuzzer";
this.chbBuzzer.Size = new System.Drawing.Size(109, 25); this.chbBuzzer.Size = new System.Drawing.Size(109, 25);
this.chbBuzzer.TabIndex = 271; this.chbBuzzer.TabIndex = 271;
...@@ -267,7 +268,7 @@ ...@@ -267,7 +268,7 @@
// btnStoreExit // btnStoreExit
// //
this.btnStoreExit.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.btnStoreExit.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnStoreExit.Location = new System.Drawing.Point(539, 4); this.btnStoreExit.Location = new System.Drawing.Point(541, 4);
this.btnStoreExit.Name = "btnStoreExit"; this.btnStoreExit.Name = "btnStoreExit";
this.btnStoreExit.Size = new System.Drawing.Size(132, 39); this.btnStoreExit.Size = new System.Drawing.Size(132, 39);
this.btnStoreExit.TabIndex = 4; this.btnStoreExit.TabIndex = 4;
...@@ -291,7 +292,7 @@ ...@@ -291,7 +292,7 @@
this.chbAuto.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.chbAuto.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.chbAuto.AutoSize = true; this.chbAuto.AutoSize = true;
this.chbAuto.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.chbAuto.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.chbAuto.Location = new System.Drawing.Point(939, 13); this.chbAuto.Location = new System.Drawing.Point(804, 13);
this.chbAuto.Name = "chbAuto"; this.chbAuto.Name = "chbAuto";
this.chbAuto.Size = new System.Drawing.Size(125, 25); this.chbAuto.Size = new System.Drawing.Size(125, 25);
this.chbAuto.TabIndex = 270; this.chbAuto.TabIndex = 270;
...@@ -334,6 +335,7 @@ ...@@ -334,6 +335,7 @@
// //
// tabPage5 // tabPage5
// //
this.tabPage5.Controls.Add(this.btnUpdown);
this.tabPage5.Controls.Add(this.btnDebug); this.tabPage5.Controls.Add(this.btnDebug);
this.tabPage5.Controls.Add(this.btnAxisOff); this.tabPage5.Controls.Add(this.btnAxisOff);
this.tabPage5.Controls.Add(this.btnAxisOn); this.tabPage5.Controls.Add(this.btnAxisOn);
...@@ -344,7 +346,7 @@ ...@@ -344,7 +346,7 @@
this.tabPage5.Location = new System.Drawing.Point(4, 30); this.tabPage5.Location = new System.Drawing.Point(4, 30);
this.tabPage5.Name = "tabPage5"; this.tabPage5.Name = "tabPage5";
this.tabPage5.Padding = new System.Windows.Forms.Padding(3); this.tabPage5.Padding = new System.Windows.Forms.Padding(3);
this.tabPage5.Size = new System.Drawing.Size(1060, 46); this.tabPage5.Size = new System.Drawing.Size(1072, 46);
this.tabPage5.TabIndex = 1; this.tabPage5.TabIndex = 1;
this.tabPage5.Text = " 设备调试 "; this.tabPage5.Text = " 设备调试 ";
this.tabPage5.UseVisualStyleBackColor = true; this.tabPage5.UseVisualStyleBackColor = true;
...@@ -352,7 +354,7 @@ ...@@ -352,7 +354,7 @@
// btnDebug // btnDebug
// //
this.btnDebug.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.btnDebug.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnDebug.Location = new System.Drawing.Point(806, 4); this.btnDebug.Location = new System.Drawing.Point(939, 4);
this.btnDebug.Name = "btnDebug"; this.btnDebug.Name = "btnDebug";
this.btnDebug.Size = new System.Drawing.Size(132, 39); this.btnDebug.Size = new System.Drawing.Size(132, 39);
this.btnDebug.TabIndex = 12; this.btnDebug.TabIndex = 12;
...@@ -433,7 +435,7 @@ ...@@ -433,7 +435,7 @@
this.tabPage6.Controls.Add(this.btnLogDebug); this.tabPage6.Controls.Add(this.btnLogDebug);
this.tabPage6.Location = new System.Drawing.Point(4, 30); this.tabPage6.Location = new System.Drawing.Point(4, 30);
this.tabPage6.Name = "tabPage6"; this.tabPage6.Name = "tabPage6";
this.tabPage6.Size = new System.Drawing.Size(1060, 46); this.tabPage6.Size = new System.Drawing.Size(1072, 46);
this.tabPage6.TabIndex = 2; this.tabPage6.TabIndex = 2;
this.tabPage6.Text = " 其他 "; this.tabPage6.Text = " 其他 ";
this.tabPage6.UseVisualStyleBackColor = true; this.tabPage6.UseVisualStyleBackColor = true;
...@@ -495,7 +497,7 @@ ...@@ -495,7 +497,7 @@
this.tabPage3.Controls.Add(this.richTextBox1); this.tabPage3.Controls.Add(this.richTextBox1);
this.tabPage3.Location = new System.Drawing.Point(4, 29); this.tabPage3.Location = new System.Drawing.Point(4, 29);
this.tabPage3.Name = "tabPage3"; this.tabPage3.Name = "tabPage3";
this.tabPage3.Size = new System.Drawing.Size(560, 616); this.tabPage3.Size = new System.Drawing.Size(572, 616);
this.tabPage3.TabIndex = 2; this.tabPage3.TabIndex = 2;
this.tabPage3.Text = " 操作日志 "; this.tabPage3.Text = " 操作日志 ";
this.tabPage3.UseVisualStyleBackColor = true; this.tabPage3.UseVisualStyleBackColor = true;
...@@ -583,6 +585,13 @@ ...@@ -583,6 +585,13 @@
this.tabPage1.Text = " 伺服调试 "; this.tabPage1.Text = " 伺服调试 ";
this.tabPage1.UseVisualStyleBackColor = true; this.tabPage1.UseVisualStyleBackColor = true;
// //
// axisMoveControl1
//
this.axisMoveControl1.Location = new System.Drawing.Point(7, 8);
this.axisMoveControl1.Name = "axisMoveControl1";
this.axisMoveControl1.Size = new System.Drawing.Size(564, 529);
this.axisMoveControl1.TabIndex = 0;
//
// tabPage2 // tabPage2
// //
this.tabPage2.Controls.Add(this.groupCode); this.tabPage2.Controls.Add(this.groupCode);
...@@ -590,7 +599,7 @@ ...@@ -590,7 +599,7 @@
this.tabPage2.Location = new System.Drawing.Point(4, 29); this.tabPage2.Location = new System.Drawing.Point(4, 29);
this.tabPage2.Name = "tabPage2"; this.tabPage2.Name = "tabPage2";
this.tabPage2.Padding = new System.Windows.Forms.Padding(3); this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
this.tabPage2.Size = new System.Drawing.Size(560, 616); this.tabPage2.Size = new System.Drawing.Size(572, 616);
this.tabPage2.TabIndex = 1; this.tabPage2.TabIndex = 1;
this.tabPage2.Text = " 压紧轴/温湿度 "; this.tabPage2.Text = " 压紧轴/温湿度 ";
this.tabPage2.UseVisualStyleBackColor = true; this.tabPage2.UseVisualStyleBackColor = true;
...@@ -1914,12 +1923,16 @@ ...@@ -1914,12 +1923,16 @@
this.清理日志ToolStripMenuItem.Text = "清理日志"; this.清理日志ToolStripMenuItem.Text = "清理日志";
this.清理日志ToolStripMenuItem.Click += new System.EventHandler(this.清理日志ToolStripMenuItem_Click); this.清理日志ToolStripMenuItem.Click += new System.EventHandler(this.清理日志ToolStripMenuItem_Click);
// //
// axisMoveControl1 // btnUpdown
// //
this.axisMoveControl1.Location = new System.Drawing.Point(7, 8); this.btnUpdown.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.axisMoveControl1.Name = "axisMoveControl1"; this.btnUpdown.Location = new System.Drawing.Point(805, 4);
this.axisMoveControl1.Size = new System.Drawing.Size(564, 529); this.btnUpdown.Name = "btnUpdown";
this.axisMoveControl1.TabIndex = 0; this.btnUpdown.Size = new System.Drawing.Size(132, 39);
this.btnUpdown.TabIndex = 272;
this.btnUpdown.Text = "升降轴位置调试";
this.btnUpdown.UseVisualStyleBackColor = true;
this.btnUpdown.Click += new System.EventHandler(this.btnUpdown_Click);
// //
// FrmStoreBox // FrmStoreBox
// //
...@@ -2115,6 +2128,7 @@ ...@@ -2115,6 +2128,7 @@
private System.Windows.Forms.Label label32; private System.Windows.Forms.Label label32;
private System.Windows.Forms.CheckBox chbBuzzer; private System.Windows.Forms.CheckBox chbBuzzer;
private ACPackingStore.AxisMoveControl axisMoveControl1; private ACPackingStore.AxisMoveControl axisMoveControl1;
private System.Windows.Forms.Button btnUpdown;
} }
} }
...@@ -1166,6 +1166,24 @@ namespace OnlineStore.ACSingleStore ...@@ -1166,6 +1166,24 @@ namespace OnlineStore.ACSingleStore
} }
} }
private void btnUpdown_Click(object sender, EventArgs e)
{
string PortName = store.Config.UpDown_Axis.DeviceName;
int slvAddr = store.Config.UpDown_Axis.GetAxisValue();
string ioIP = "192.168.200.13";
int ioIndex = 0;
// if (store.Config.StoreDIList.ContainsKey(IO_Type.UpdownPositionSingal))
if (store.Config.StoreDIList.ContainsKey(IO_Type.TrayCheck_Fixture))
{
ioIP = store.Config.StoreDIList[IO_Type.TrayCheck_Fixture].IO_IP;
ioIndex = store.Config.StoreDIList[IO_Type.TrayCheck_Fixture].GetIOAddr();
}
FrmPositionTool frm = new FrmPositionTool(PortName, slvAddr, ioIP, ioIndex);
frm.ShowDialog();
LogUtil.logBox = this.richTextBox1;
}
//private void btnOpenFile_Click(object sender, EventArgs e) //private void btnOpenFile_Click(object sender, EventArgs e)
//{ //{
// System.Windows.Forms.OpenFileDialog openDialog = new System.Windows.Forms.OpenFileDialog(); // System.Windows.Forms.OpenFileDialog openDialog = new System.Windows.Forms.OpenFileDialog();
......
namespace OnlineStore.ACSingleStore
{
partial class FrmPositionTool
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.groupBox6 = new System.Windows.Forms.GroupBox();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.txtP4Offset = new System.Windows.Forms.TextBox();
this.label10 = new System.Windows.Forms.Label();
this.txtP3Offset = new System.Windows.Forms.TextBox();
this.label9 = new System.Windows.Forms.Label();
this.txtP6Offset = new System.Windows.Forms.TextBox();
this.label5 = new System.Windows.Forms.Label();
this.txtP5Offset = new System.Windows.Forms.TextBox();
this.label4 = new System.Windows.Forms.Label();
this.btnOpenFolder = new System.Windows.Forms.Button();
this.btnGetActualPosition = new System.Windows.Forms.Button();
this.txtSpeed = new System.Windows.Forms.TextBox();
this.label8 = new System.Windows.Forms.Label();
this.txtFileName = new System.Windows.Forms.TextBox();
this.ioStatusControl1 = new UserFromControl.IOStatusControl();
this.btnAbsMove = new System.Windows.Forms.Button();
this.label3 = new System.Windows.Forms.Label();
this.label7 = new System.Windows.Forms.Label();
this.txtPosition = new System.Windows.Forms.TextBox();
this.txtActualPosition = new System.Windows.Forms.TextBox();
this.label13 = new System.Windows.Forms.Label();
this.btnSdStop = new System.Windows.Forms.Button();
this.label6 = new System.Windows.Forms.Label();
this.txtTargetPosition = new System.Windows.Forms.TextBox();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.label12 = new System.Windows.Forms.Label();
this.label18 = new System.Windows.Forms.Label();
this.txtAddr = new System.Windows.Forms.TextBox();
this.btnHomeMove = new System.Windows.Forms.Button();
this.btnServoOn = new System.Windows.Forms.Button();
this.txtPortName = new System.Windows.Forms.TextBox();
this.btnServoOff = new System.Windows.Forms.Button();
this.txtIOIndex = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.txtIoIp = new System.Windows.Forms.TextBox();
this.btnExit = new System.Windows.Forms.Button();
this.btnClear = new System.Windows.Forms.Button();
this.richTextBox1 = new System.Windows.Forms.RichTextBox();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.groupBox6.SuspendLayout();
this.groupBox2.SuspendLayout();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// groupBox6
//
this.groupBox6.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.groupBox6.Controls.Add(this.groupBox2);
this.groupBox6.Controls.Add(this.groupBox1);
this.groupBox6.Controls.Add(this.btnExit);
this.groupBox6.Controls.Add(this.btnClear);
this.groupBox6.Controls.Add(this.richTextBox1);
this.groupBox6.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.groupBox6.Location = new System.Drawing.Point(6, 5);
this.groupBox6.Name = "groupBox6";
this.groupBox6.Size = new System.Drawing.Size(1008, 707);
this.groupBox6.TabIndex = 250;
this.groupBox6.TabStop = false;
//
// groupBox2
//
this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
this.groupBox2.Controls.Add(this.txtP4Offset);
this.groupBox2.Controls.Add(this.label10);
this.groupBox2.Controls.Add(this.txtP3Offset);
this.groupBox2.Controls.Add(this.label9);
this.groupBox2.Controls.Add(this.txtP6Offset);
this.groupBox2.Controls.Add(this.label5);
this.groupBox2.Controls.Add(this.txtP5Offset);
this.groupBox2.Controls.Add(this.label4);
this.groupBox2.Controls.Add(this.btnOpenFolder);
this.groupBox2.Controls.Add(this.btnGetActualPosition);
this.groupBox2.Controls.Add(this.txtSpeed);
this.groupBox2.Controls.Add(this.label8);
this.groupBox2.Controls.Add(this.txtFileName);
this.groupBox2.Controls.Add(this.ioStatusControl1);
this.groupBox2.Controls.Add(this.btnAbsMove);
this.groupBox2.Controls.Add(this.label3);
this.groupBox2.Controls.Add(this.label7);
this.groupBox2.Controls.Add(this.txtPosition);
this.groupBox2.Controls.Add(this.txtActualPosition);
this.groupBox2.Controls.Add(this.label13);
this.groupBox2.Controls.Add(this.btnSdStop);
this.groupBox2.Controls.Add(this.label6);
this.groupBox2.Controls.Add(this.txtTargetPosition);
this.groupBox2.Location = new System.Drawing.Point(9, 192);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(458, 504);
this.groupBox2.TabIndex = 283;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "位置信息";
//
// txtP4Offset
//
this.txtP4Offset.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txtP4Offset.Location = new System.Drawing.Point(184, 174);
this.txtP4Offset.MaxLength = 30;
this.txtP4Offset.Name = "txtP4Offset";
this.txtP4Offset.Size = new System.Drawing.Size(121, 26);
this.txtP4Offset.TabIndex = 287;
this.txtP4Offset.Text = "-6000";
//
// label10
//
this.label10.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label10.Location = new System.Drawing.Point(6, 177);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(173, 20);
this.label10.TabIndex = 288;
this.label10.Text = "入料缓冲点P4偏移量:";
this.label10.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// txtP3Offset
//
this.txtP3Offset.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txtP3Offset.Location = new System.Drawing.Point(184, 142);
this.txtP3Offset.MaxLength = 30;
this.txtP3Offset.Name = "txtP3Offset";
this.txtP3Offset.Size = new System.Drawing.Size(121, 26);
this.txtP3Offset.TabIndex = 285;
this.txtP3Offset.Text = "6000";
//
// label9
//
this.label9.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label9.Location = new System.Drawing.Point(6, 145);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(173, 20);
this.label9.TabIndex = 286;
this.label9.Text = "入料前点P3偏移量:";
this.label9.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// txtP6Offset
//
this.txtP6Offset.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txtP6Offset.Location = new System.Drawing.Point(184, 110);
this.txtP6Offset.MaxLength = 30;
this.txtP6Offset.Name = "txtP6Offset";
this.txtP6Offset.Size = new System.Drawing.Size(121, 26);
this.txtP6Offset.TabIndex = 283;
this.txtP6Offset.Text = "6000";
//
// label5
//
this.label5.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label5.Location = new System.Drawing.Point(6, 113);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(173, 20);
this.label5.TabIndex = 284;
this.label5.Text = "出料缓冲点P6偏移量:";
this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// txtP5Offset
//
this.txtP5Offset.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txtP5Offset.Location = new System.Drawing.Point(184, 78);
this.txtP5Offset.MaxLength = 30;
this.txtP5Offset.Name = "txtP5Offset";
this.txtP5Offset.Size = new System.Drawing.Size(121, 26);
this.txtP5Offset.TabIndex = 281;
this.txtP5Offset.Text = "-6000";
//
// label4
//
this.label4.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label4.Location = new System.Drawing.Point(6, 81);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(173, 20);
this.label4.TabIndex = 282;
this.label4.Text = "出料前点P5偏移值:";
this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// btnOpenFolder
//
this.btnOpenFolder.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnOpenFolder.Location = new System.Drawing.Point(312, 22);
this.btnOpenFolder.Name = "btnOpenFolder";
this.btnOpenFolder.Size = new System.Drawing.Size(132, 36);
this.btnOpenFolder.TabIndex = 280;
this.btnOpenFolder.Text = "打开文件夹";
this.btnOpenFolder.UseVisualStyleBackColor = true;
this.btnOpenFolder.Click += new System.EventHandler(this.btnOpenFolder_Click);
//
// btnGetActualPosition
//
this.btnGetActualPosition.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnGetActualPosition.Location = new System.Drawing.Point(312, 342);
this.btnGetActualPosition.Name = "btnGetActualPosition";
this.btnGetActualPosition.Size = new System.Drawing.Size(132, 36);
this.btnGetActualPosition.TabIndex = 269;
this.btnGetActualPosition.Text = "读取位置";
this.btnGetActualPosition.UseVisualStyleBackColor = true;
this.btnGetActualPosition.Click += new System.EventHandler(this.btnGetActualPosition_Click);
//
// txtSpeed
//
this.txtSpeed.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txtSpeed.Location = new System.Drawing.Point(184, 227);
this.txtSpeed.MaxLength = 30;
this.txtSpeed.Name = "txtSpeed";
this.txtSpeed.Size = new System.Drawing.Size(121, 26);
this.txtSpeed.TabIndex = 83;
this.txtSpeed.Text = "20";
//
// label8
//
this.label8.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label8.Location = new System.Drawing.Point(6, 230);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(173, 20);
this.label8.TabIndex = 84;
this.label8.Text = "移动速度:";
this.label8.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// txtFileName
//
this.txtFileName.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txtFileName.Location = new System.Drawing.Point(141, 27);
this.txtFileName.MaxLength = 30;
this.txtFileName.Name = "txtFileName";
this.txtFileName.Size = new System.Drawing.Size(164, 26);
this.txtFileName.TabIndex = 278;
this.txtFileName.Text = "position.csv";
//
// ioStatusControl1
//
this.ioStatusControl1.IOName = "检测信号";
this.ioStatusControl1.IOValue = 0;
this.ioStatusControl1.isCanClick = false;
this.ioStatusControl1.Location = new System.Drawing.Point(38, 401);
this.ioStatusControl1.Name = "ioStatusControl1";
this.ioStatusControl1.Size = new System.Drawing.Size(267, 69);
this.ioStatusControl1.TabIndex = 279;
//
// btnAbsMove
//
this.btnAbsMove.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnAbsMove.Location = new System.Drawing.Point(312, 222);
this.btnAbsMove.Name = "btnAbsMove";
this.btnAbsMove.Size = new System.Drawing.Size(132, 36);
this.btnAbsMove.TabIndex = 88;
this.btnAbsMove.Text = "开始运动";
this.btnAbsMove.UseVisualStyleBackColor = true;
this.btnAbsMove.Click += new System.EventHandler(this.btnAbsMove_Click);
//
// label3
//
this.label3.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label3.Location = new System.Drawing.Point(13, 30);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(122, 20);
this.label3.TabIndex = 277;
this.label3.Text = "保存文件名称:";
this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// label7
//
this.label7.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label7.Location = new System.Drawing.Point(6, 355);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(173, 20);
this.label7.TabIndex = 271;
this.label7.Text = "实际位置:";
this.label7.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// txtPosition
//
this.txtPosition.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txtPosition.Location = new System.Drawing.Point(184, 265);
this.txtPosition.MaxLength = 30;
this.txtPosition.Name = "txtPosition";
this.txtPosition.Size = new System.Drawing.Size(121, 26);
this.txtPosition.TabIndex = 89;
this.txtPosition.Text = "5000";
//
// txtActualPosition
//
this.txtActualPosition.Enabled = false;
this.txtActualPosition.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txtActualPosition.Location = new System.Drawing.Point(184, 352);
this.txtActualPosition.MaxLength = 30;
this.txtActualPosition.Name = "txtActualPosition";
this.txtActualPosition.Size = new System.Drawing.Size(121, 26);
this.txtActualPosition.TabIndex = 270;
//
// label13
//
this.label13.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label13.Location = new System.Drawing.Point(6, 268);
this.label13.Name = "label13";
this.label13.Size = new System.Drawing.Size(173, 20);
this.label13.TabIndex = 90;
this.label13.Text = "目标位置:";
this.label13.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// btnSdStop
//
this.btnSdStop.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnSdStop.Location = new System.Drawing.Point(312, 260);
this.btnSdStop.Name = "btnSdStop";
this.btnSdStop.Size = new System.Drawing.Size(132, 36);
this.btnSdStop.TabIndex = 257;
this.btnSdStop.Text = "停止";
this.btnSdStop.UseVisualStyleBackColor = true;
this.btnSdStop.Click += new System.EventHandler(this.btnSdStop_Click);
//
// label6
//
this.label6.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label6.Location = new System.Drawing.Point(6, 321);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(173, 20);
this.label6.TabIndex = 268;
this.label6.Text = "目标位置:";
this.label6.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// txtTargetPosition
//
this.txtTargetPosition.Enabled = false;
this.txtTargetPosition.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txtTargetPosition.Location = new System.Drawing.Point(184, 318);
this.txtTargetPosition.MaxLength = 30;
this.txtTargetPosition.Name = "txtTargetPosition";
this.txtTargetPosition.Size = new System.Drawing.Size(121, 26);
this.txtTargetPosition.TabIndex = 267;
//
// groupBox1
//
this.groupBox1.Controls.Add(this.label12);
this.groupBox1.Controls.Add(this.label18);
this.groupBox1.Controls.Add(this.txtAddr);
this.groupBox1.Controls.Add(this.btnHomeMove);
this.groupBox1.Controls.Add(this.btnServoOn);
this.groupBox1.Controls.Add(this.txtPortName);
this.groupBox1.Controls.Add(this.btnServoOff);
this.groupBox1.Controls.Add(this.txtIOIndex);
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.Controls.Add(this.label2);
this.groupBox1.Controls.Add(this.txtIoIp);
this.groupBox1.Location = new System.Drawing.Point(9, 13);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(458, 173);
this.groupBox1.TabIndex = 282;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "设备信息";
//
// label12
//
this.label12.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label12.Location = new System.Drawing.Point(8, 28);
this.label12.Name = "label12";
this.label12.Size = new System.Drawing.Size(122, 20);
this.label12.TabIndex = 1;
this.label12.Text = "端口号:";
this.label12.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// label18
//
this.label18.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label18.Location = new System.Drawing.Point(8, 64);
this.label18.Name = "label18";
this.label18.Size = new System.Drawing.Size(122, 20);
this.label18.TabIndex = 94;
this.label18.Text = "地址:";
this.label18.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// txtAddr
//
this.txtAddr.Enabled = false;
this.txtAddr.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txtAddr.Location = new System.Drawing.Point(136, 61);
this.txtAddr.MaxLength = 30;
this.txtAddr.Name = "txtAddr";
this.txtAddr.Size = new System.Drawing.Size(164, 26);
this.txtAddr.TabIndex = 95;
this.txtAddr.Text = "1";
//
// btnHomeMove
//
this.btnHomeMove.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnHomeMove.Location = new System.Drawing.Point(307, 113);
this.btnHomeMove.Name = "btnHomeMove";
this.btnHomeMove.Size = new System.Drawing.Size(132, 36);
this.btnHomeMove.TabIndex = 110;
this.btnHomeMove.Text = "原点返回";
this.btnHomeMove.UseVisualStyleBackColor = true;
this.btnHomeMove.Click += new System.EventHandler(this.btnHomeMove_Click);
//
// btnServoOn
//
this.btnServoOn.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnServoOn.Location = new System.Drawing.Point(307, 25);
this.btnServoOn.Name = "btnServoOn";
this.btnServoOn.Size = new System.Drawing.Size(132, 36);
this.btnServoOn.TabIndex = 258;
this.btnServoOn.Text = "打开伺服";
this.btnServoOn.UseVisualStyleBackColor = true;
this.btnServoOn.Click += new System.EventHandler(this.btnServoOn_Click);
//
// txtPortName
//
this.txtPortName.Enabled = false;
this.txtPortName.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txtPortName.Location = new System.Drawing.Point(136, 25);
this.txtPortName.MaxLength = 30;
this.txtPortName.Name = "txtPortName";
this.txtPortName.Size = new System.Drawing.Size(164, 26);
this.txtPortName.TabIndex = 276;
this.txtPortName.Text = "COM1";
//
// btnServoOff
//
this.btnServoOff.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnServoOff.Location = new System.Drawing.Point(307, 64);
this.btnServoOff.Name = "btnServoOff";
this.btnServoOff.Size = new System.Drawing.Size(132, 36);
this.btnServoOff.TabIndex = 259;
this.btnServoOff.Text = "关闭伺服";
this.btnServoOff.UseVisualStyleBackColor = true;
this.btnServoOff.Click += new System.EventHandler(this.btnServoOff_Click);
//
// txtIOIndex
//
this.txtIOIndex.Enabled = false;
this.txtIOIndex.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txtIOIndex.Location = new System.Drawing.Point(136, 133);
this.txtIOIndex.MaxLength = 30;
this.txtIOIndex.Name = "txtIOIndex";
this.txtIOIndex.Size = new System.Drawing.Size(164, 26);
this.txtIOIndex.TabIndex = 275;
this.txtIOIndex.Text = "1";
//
// label1
//
this.label1.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label1.Location = new System.Drawing.Point(8, 100);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(122, 20);
this.label1.TabIndex = 272;
this.label1.Text = "IO模块IP:";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// label2
//
this.label2.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label2.Location = new System.Drawing.Point(8, 136);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(122, 20);
this.label2.TabIndex = 274;
this.label2.Text = "检测信号地址:";
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// txtIoIp
//
this.txtIoIp.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txtIoIp.Location = new System.Drawing.Point(136, 97);
this.txtIoIp.MaxLength = 30;
this.txtIoIp.Name = "txtIoIp";
this.txtIoIp.Size = new System.Drawing.Size(164, 26);
this.txtIoIp.TabIndex = 273;
this.txtIoIp.Text = "192.168.201.11";
//
// btnExit
//
this.btnExit.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btnExit.Location = new System.Drawing.Point(838, 665);
this.btnExit.Name = "btnExit";
this.btnExit.Size = new System.Drawing.Size(132, 36);
this.btnExit.TabIndex = 281;
this.btnExit.Text = "退出";
this.btnExit.UseVisualStyleBackColor = true;
this.btnExit.Click += new System.EventHandler(this.btnExit_Click);
//
// btnClear
//
this.btnClear.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btnClear.Location = new System.Drawing.Point(691, 665);
this.btnClear.Name = "btnClear";
this.btnClear.Size = new System.Drawing.Size(132, 36);
this.btnClear.TabIndex = 106;
this.btnClear.Text = "清理";
this.btnClear.UseVisualStyleBackColor = true;
this.btnClear.Click += new System.EventHandler(this.btnClear_Click);
//
// richTextBox1
//
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.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.richTextBox1.Location = new System.Drawing.Point(473, 20);
this.richTextBox1.Name = "richTextBox1";
this.richTextBox1.Size = new System.Drawing.Size(526, 642);
this.richTextBox1.TabIndex = 105;
this.richTextBox1.Text = "";
//
// timer1
//
this.timer1.Interval = 1000;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// FrmPositionTool
//
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.ClientSize = new System.Drawing.Size(1020, 719);
this.Controls.Add(this.groupBox6);
this.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.Name = "FrmPositionTool";
this.Text = "升降轴位置测试";
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmPositionTool_FormClosing);
this.Load += new System.EventHandler(this.Form1_Load);
this.groupBox6.ResumeLayout(false);
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.GroupBox groupBox6;
private System.Windows.Forms.TextBox txtAddr;
private System.Windows.Forms.Label label18;
private System.Windows.Forms.Label label13;
private System.Windows.Forms.TextBox txtPosition;
private System.Windows.Forms.Button btnAbsMove;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.TextBox txtSpeed;
private System.Windows.Forms.Label label12;
private System.Windows.Forms.RichTextBox richTextBox1;
private System.Windows.Forms.Button btnClear;
private System.Windows.Forms.Button btnHomeMove;
private System.Windows.Forms.Button btnSdStop;
private System.Windows.Forms.Button btnServoOff;
private System.Windows.Forms.Button btnServoOn;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.TextBox txtTargetPosition;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.TextBox txtActualPosition;
private System.Windows.Forms.Button btnGetActualPosition;
private System.Windows.Forms.Timer timer1;
private System.Windows.Forms.TextBox txtIOIndex;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox txtIoIp;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox txtPortName;
private System.Windows.Forms.TextBox txtFileName;
private System.Windows.Forms.Label label3;
private UserFromControl.IOStatusControl ioStatusControl1;
private System.Windows.Forms.Button btnOpenFolder;
private System.Windows.Forms.Button btnExit;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.TextBox txtP4Offset;
private System.Windows.Forms.Label label10;
private System.Windows.Forms.TextBox txtP3Offset;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.TextBox txtP6Offset;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.TextBox txtP5Offset;
private System.Windows.Forms.Label label4;
}
}

using OnlineStore.Common;
using OnlineStore.DeviceLibrary;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.IO.Ports;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace OnlineStore.ACSingleStore
{
public partial class FrmPositionTool : FrmBase
{
private string LogName = ResourceCulture.GetString("升降轴位置调试:");
private string PortName = "";
private int SlvAddr = 0;
private string IoIp = "";
private int IoIndex = 0;
public string Axis_Brake = IO_Type.Axis_Brake;
private System.Timers.Timer toolTimer = new System.Timers.Timer();
public FrmPositionTool(string protName, int slvAddr,string ioIp, int ioIndex)
{
InitializeComponent();
this.PortName = protName;
this.SlvAddr = slvAddr;
this.IoIp = ioIp;
this.IoIndex = ioIndex;
toolTimer.Enabled = false;
toolTimer.Interval = 50;
toolTimer.AutoReset = true;
toolTimer.Elapsed += ToolTimer_Elapsed;
FrmPositionTool.CheckForIllegalCrossThreadCalls = false;
}
private void Form1_Load(object sender, EventArgs e)
{
ACServerManager.IsShowMsg = false;
LogUtil.logBox = this.richTextBox1;
//ACServerManager.richeBox = this.richTextBox1;
CheckForIllegalCrossThreadCalls = false;
txtPortName.Text = PortName;
txtAddr.Text = SlvAddr.ToString();
txtIOIndex.Text = IoIndex.ToString();
txtIoIp.Text = IoIp.ToString();
if (IOManager.instance == null)
{
IOManager.Init();
IOManager.instance.ConnectionIOList(new List<string> { /*IoIp*/ });
}
P3Offset = ConfigAppSettings.GetIntValue(Setting_Init.Tool_P3_Offset);
P4Offset = ConfigAppSettings.GetIntValue(Setting_Init.Tool_P4_Offset);
P5Offset = ConfigAppSettings.GetIntValue(Setting_Init.Tool_P5_Offset);
P6Offset = ConfigAppSettings.GetIntValue(Setting_Init.Tool_P6_Offset);
int tSpeed = ConfigAppSettings.GetIntValue(Setting_Init.Tool_TargetSpeed);
int tPosition = ConfigAppSettings.GetIntValue(Setting_Init.Tool_TargetPosition);
if (P3Offset.Equals(0)) P3Offset = 6000;
if (P4Offset.Equals(0)) P4Offset = -6000;
if (P5Offset.Equals(0)) P5Offset = -6000;
if (P6Offset.Equals(0)) P6Offset = 6000;
if (tSpeed.Equals(0)) tSpeed = 20;
if (tPosition.Equals(0)) tPosition = 6000;
txtP3Offset.Text = P3Offset.ToString();
txtP4Offset.Text = P4Offset.ToString();
txtP5Offset.Text = P5Offset.ToString();
txtP6Offset.Text = P6Offset.ToString();
txtSpeed.Text = tSpeed.ToString();
txtPosition.Text = tPosition.ToString();
SaveConfig(tSpeed, tPosition);
//判断伺服是否已经打开
bool isOn = ACServerManager.ServerOnStatus(PortName, SlvAddr);
formStatus(isOn);
timer1.Start();
ioStatusControl1.IOName = ResourceCulture.GetString("检测信号");
}
private void btnServoOn_Click(object sender, EventArgs e)
{
this.PortName = txtPortName.Text;
this.SlvAddr = FormUtil.GetIntValue(txtAddr);
bool result = ACServerManager.OpenPort(PortName);
if (!result)
{
MessageBox.Show(ResourceCulture.GetString("打开串口失败"));
return;
}
formStatus(true);
ACServerManager.InitSlvAddr(PortName, SlvAddr);
Thread.Sleep(100);
ACServerManager.AlarmClear(PortName, SlvAddr);
ACServerManager.ServoOn(PortName, SlvAddr);
try
{
IOManager.IOMove(Axis_Brake, IO_VALUE.HIGH);
}catch(Exception ex)
{
}
}
private void btnServoOff_Click(object sender, EventArgs e)
{
StopTimer();
// toolTimer.Stop();
ACServerManager.SuddenStop(PortName, SlvAddr);
Thread.Sleep(100);
try
{
IOManager.IOMove(Axis_Brake, IO_VALUE.LOW);
}
catch (Exception ex)
{
}
ACServerManager.ServoOff(PortName, SlvAddr);
formStatus(false);
}
private void formStatus(bool p)
{
txtPortName.Enabled = !p;
txtAddr.Enabled = !p;
txtIOIndex.Enabled = !p;
// txtIoIp.Enabled = !p;
btnAbsMove.Enabled = p;
btnSdStop.Enabled = p;
btnHomeMove.Enabled = p;
timer1.Enabled = p;
btnServoOff.Enabled = p;
btnServoOn.Enabled = !p;
btnGetActualPosition.Enabled = p;
}
private void btnClear_Click(object sender, EventArgs e)
{
this.richTextBox1.Text = "";
}
private void btnRelMove_Click(object sender, EventArgs e)
{
int position = Convert.ToInt32(txtPosition.Text);
ACServerManager.RelMove(PortName, SlvAddr, position);
}
private void btnHomeMove_Click(object sender, EventArgs e)
{
int speed = Convert.ToInt32(txtSpeed.Text);
ACServerManager.HomeMove(PortName, SlvAddr, speed);
}
private void btnSpeedMove_Click(object sender, EventArgs e)
{
int speed = Convert.ToInt32(txtSpeed.Text);
ACServerManager.SpeedMove(PortName, SlvAddr, speed);
}
private void btnGetActualPosition_Click(object sender, EventArgs e)
{
int value = ACServerManager.GetTargetPosition(PortName, SlvAddr);
txtTargetPosition.Text = value.ToString();
value = ACServerManager.GetActualtPosition(PortName, SlvAddr);
txtActualPosition.Text = value.ToString();
}
private void SaveConfig(int speed,int position)
{
//保存配置
ConfigAppSettings.SaveValue(Setting_Init.Tool_P3_Offset, P3Offset);
ConfigAppSettings.SaveValue(Setting_Init.Tool_P4_Offset, P4Offset);
ConfigAppSettings.SaveValue(Setting_Init.Tool_P5_Offset, P5Offset);
ConfigAppSettings.SaveValue(Setting_Init.Tool_P6_Offset, P6Offset);
ConfigAppSettings.SaveValue(Setting_Init.Tool_TargetSpeed, speed);
ConfigAppSettings.SaveValue(Setting_Init.Tool_TargetPosition, position);
}
private void btnAbsMove_Click(object sender, EventArgs e)
{
int speed = Convert.ToInt32(txtSpeed.Text);
int position = Convert.ToInt32(txtPosition.Text.Trim(), 10);
TargetPostion = position;
if (speed <= (0))
{
MessageBox.Show(ResourceCulture.GetString("请输入正确的速度"));
txtSpeed.Focus();
return;
}
P3Offset = FormUtil.GetIntValue(txtP3Offset);
P4Offset = FormUtil.GetIntValue(txtP4Offset);
P5Offset = FormUtil.GetIntValue(txtP5Offset);
P6Offset = FormUtil.GetIntValue(txtP6Offset);
SaveConfig(speed, position);
LastValue = IO_VALUE.LOW;
string fileName = txtFileName.Text;
string filePath = Application.StartupPath + @"\logs\" + fileName;
if (File.Exists(filePath))
{
string msg = "文件【" + fileName + "】已存在,是否确定覆盖?";
DialogResult result = MessageBox.Show(msg, "", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
if (!result.Equals(DialogResult.OK))
{
return;
}
}
PositionList = new List<int>();
LogUtil.info(LogName + "伺服开始运动,速度【" + speed + "】位置【" + position + "】启动定时器 ");
formMoveStatus(false);
ACServerManager.AbsMove(PortName, SlvAddr, position, speed);
toolTimer.Start();
}
private int P3Offset = 0;
private int P4Offset = 0;
private int P5Offset = 0;
private int P6Offset = 0;
private void formMoveStatus(bool status)
{
txtFileName.Enabled = status;
txtP5Offset.Enabled = status;
txtP3Offset.Enabled = status;
txtP4Offset.Enabled = status;
txtP6Offset.Enabled = status;
txtSpeed.Enabled = status;
txtPosition.Enabled = status;
}
private void btnSdStop_Click(object sender, EventArgs e)
{
toolTimer.Stop();
ACServerManager.SuddenStop(PortName, SlvAddr);
}
private IO_VALUE GetSingleValue()
{
return IOManager.instance.GetDIValue(IoIp, 0, (ushort)IoIndex);
}
private int TargetPostion = 0;
private bool isInProcesss = false;
private DateTime LastTime = DateTime.Now;
private List<int> PositionList = new List<int>();
private IO_VALUE LastValue = IO_VALUE.LOW;
private DateTime LastGetPTime = DateTime.Now;
private void ToolTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
TimeSpan span = DateTime.Now - LastTime;
if (isInProcesss && span.TotalSeconds < 1)
{
return;
}
isInProcesss = true;
try
{
int moveS = ACServerManager.GetBusyStatus(PortName, SlvAddr);
if (moveS.Equals(1))
{
IO_VALUE currValue = GetSingleValue();
TimeSpan checkSpan = DateTime.Now - LastGetPTime;
if (LastValue.Equals(IO_VALUE.LOW) && currValue.Equals(IO_VALUE.HIGH)&&checkSpan.TotalSeconds>2)
{
int currPos = ACServerManager.GetActualtPosition(PortName, SlvAddr);
txtActualPosition.Text = currPos.ToString();
PositionList.Add(currPos);
int num = PositionList.Count;
int preValue = 0;
if (PositionList.Count > 1)
{
preValue = PositionList[num - 2];
}
LogUtil.info(LogName + "【"+ num + "】【" + currPos+"】【"+Math.Abs(currPos-preValue)+"】");
if (LogUtil.logBox == null)
{
this.richTextBox1.AppendText(LogName + "【" + num + "】【" + currPos + "】【" + Math.Abs(currPos - preValue) + "】"+Environment.NewLine);
}
LastValue = IO_VALUE.HIGH;
LastGetPTime = DateTime.Now;
}
LastValue = currValue;
}
else
{
StopTimer();
}
}catch(Exception ex)
{
LogUtil.error(LogName+"ToolTimer_Elapsed" + ex.ToString());
}
isInProcesss = false;
}
private void StopTimer()
{
toolTimer.Stop();
if (PositionList.Count <= 0)
{
return;
}
LogUtil.info(LogName + "伺服已停止运动,停止定时器,记录数据");
List<string> strList = new List<string>();
strList.Add("编号,标准位置,升降轴库位出料前点P5,升降轴库位出料缓冲点P6,升降轴库位入料前点P3,升降轴库位入料缓冲点P4");
int index = 1;
foreach (int p in PositionList)
{
int P3 = p + P3Offset;
int P4 = p + P4Offset;
int P5 = p + P5Offset;
int P6 = p + P6Offset;
string resultstr = index + "," + p + ","+P5+","+P6+","+P3+","+P4+"";
strList.Add(resultstr);
index++;
}
string fileName = txtFileName.Text;
string filePath = Application.StartupPath + @"\logs\" + fileName;
try
{
// Clipboard.SetDataObject(resultstr);
File.WriteAllLines(filePath, strList.ToArray());
LogUtil.error(LogName + "保存位置到文件【" + filePath + "】成功");
}
catch (Exception ex)
{
LogUtil.error(LogName + "保存位置到文件【" + filePath + "】出错:" + ex.ToString());
}
formMoveStatus(true );
}
private void timer1_Tick(object sender, EventArgs e)
{
try
{
ioStatusControl1.IOValue = (int)GetSingleValue();
ioStatusControl1.ShowData();
}
catch (Exception ex)
{
}
}
private void FrmPositionTool_FormClosing(object sender, FormClosingEventArgs e)
{
timer1.Stop();
if (btnServoOff.Enabled)
{
StopTimer();
// toolTimer.Stop();
ACServerManager.SuddenStop(PortName, SlvAddr);
Thread.Sleep(100);
}
LogUtil.logBox = null;
//ACServerManager.CloseAllPort();
//IOManager.instance.CloseAllConnection();
}
private void btnOpenFolder_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start("Explorer.exe", Application.StartupPath + @"\logs\");
}
private void btnExit_Click(object sender, EventArgs e)
{
this.Close();
}
}
public class ResourceCulture
{
internal static string GetString(string str)
{
return str;
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="timer1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>
\ No newline at end of file \ No newline at end of file
...@@ -91,5 +91,14 @@ namespace OnlineStore.Common ...@@ -91,5 +91,14 @@ namespace OnlineStore.Common
public static string UseBuzzer = "UseBuzzer"; public static string UseBuzzer = "UseBuzzer";
public static string ACBaudRate = "ACBaudRate"; public static string ACBaudRate = "ACBaudRate";
public static string Tool_P3_Offset = "Tool_P3_Offset";
public static string Tool_P4_Offset = "Tool_P4_Offset";
public static string Tool_P5_Offset = "Tool_P5_Offset";
public static string Tool_P6_Offset = "Tool_P6_Offset";
public static string Tool_TargetSpeed = "Tool_TargetSpeed";
public static string Tool_TargetPosition = "Tool_TargetPosition";
} }
} }
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!