Commit eb2722ae LN

增加升降轴对位置功能

1 个父辈 ace18d91
...@@ -2604,7 +2604,6 @@ ...@@ -2604,7 +2604,6 @@
this.升降轴位置调试ToolStripMenuItem.Name = "升降轴位置调试ToolStripMenuItem"; this.升降轴位置调试ToolStripMenuItem.Name = "升降轴位置调试ToolStripMenuItem";
this.升降轴位置调试ToolStripMenuItem.Size = new System.Drawing.Size(192, 26); this.升降轴位置调试ToolStripMenuItem.Size = new System.Drawing.Size(192, 26);
this.升降轴位置调试ToolStripMenuItem.Text = "升降轴位置调试"; this.升降轴位置调试ToolStripMenuItem.Text = "升降轴位置调试";
this.升降轴位置调试ToolStripMenuItem.Visible = false;
this.升降轴位置调试ToolStripMenuItem.Click += new System.EventHandler(this.升降轴位置调试ToolStripMenuItem_Click); this.升降轴位置调试ToolStripMenuItem.Click += new System.EventHandler(this.升降轴位置调试ToolStripMenuItem_Click);
// //
// toolStripSeparator11 // toolStripSeparator11
......
...@@ -1799,8 +1799,8 @@ namespace OnlineStore.AutoInOutStore ...@@ -1799,8 +1799,8 @@ namespace OnlineStore.AutoInOutStore
int ioIndex = 0; int ioIndex = 0;
if (store.Config.StoreDIList.ContainsKey(IO_Type.UpdownPositionSingal)) if (store.Config.StoreDIList.ContainsKey(IO_Type.UpdownPositionSingal))
{ {
ioIP = store.Config.StoreDIList[IO_Type.UpdownPositionSingal].DeviceName; ioIP = store.Config.StoreDIList[IO_Type.TrayCheck_Fixture].DeviceName;
ioIndex = store.Config.StoreDIList[IO_Type.UpdownPositionSingal].GetIOAddr(); ioIndex = store.Config.StoreDIList[IO_Type.TrayCheck_Fixture].GetIOAddr();
} }
FrmPositionTool frm = new FrmPositionTool(PortName, slvAddr, ioIP, ioIndex); FrmPositionTool frm = new FrmPositionTool(PortName, slvAddr, ioIP, ioIndex);
frm.ShowDialog(); frm.ShowDialog();
......
...@@ -47,7 +47,7 @@ namespace OnlineStore.AutoInOutStore ...@@ -47,7 +47,7 @@ namespace OnlineStore.AutoInOutStore
ACServerManager.IsShowMsg = false; ACServerManager.IsShowMsg = false;
LogUtil.logBox = this.richTextBox1; LogUtil.logBox = this.richTextBox1;
//ACServerManager.richeBox = this.richTextBox1; //ACServerManager.richeBox = this.richTextBox1;
formStatus(false);
CheckForIllegalCrossThreadCalls = false; CheckForIllegalCrossThreadCalls = false;
txtPortName.Text = PortName; txtPortName.Text = PortName;
txtAddr.Text = SlvAddr.ToString(); txtAddr.Text = SlvAddr.ToString();
...@@ -57,12 +57,26 @@ namespace OnlineStore.AutoInOutStore ...@@ -57,12 +57,26 @@ namespace OnlineStore.AutoInOutStore
if (IOManager.instance == null) if (IOManager.instance == null)
{ {
IOManager.Init(); IOManager.Init();
IOManager.instance.ConnectionIOList(new List<string> { IoIp }); IOManager.instance.ConnectionIOList(new List<string> { /*IoIp*/ });
} }
//判断伺服是否已经打开
bool isOn = ACServerManager.ServerOnStatus(PortName, SlvAddr);
formStatus(isOn);
timer1.Start(); timer1.Start();
ioStatusControl1.IOName = "检测信号";
} }
private void btnServoOn_Click(object sender, EventArgs e) private void btnServoOn_Click(object sender, EventArgs e)
{ {
//PositionList.Add(32000);
//PositionList.Add(38000);
//PositionList.Add(44000);
//PositionList.Add(50000);
//PositionList.Add(56000);
//P3Offset = FormUtil.GetIntValue(txtP3Offset);
//P4Offset = FormUtil.GetIntValue(txtP4Offset);
//P5Offset = FormUtil.GetIntValue(txtP5Offset);
//P6Offset = FormUtil.GetIntValue(txtP6Offset);
//StopTimer();
this.PortName = txtPortName.Text; this.PortName = txtPortName.Text;
this.SlvAddr = FormUtil.GetIntValue(txtAddr); this.SlvAddr = FormUtil.GetIntValue(txtAddr);
bool result = ACServerManager.OpenPort(PortName); bool result = ACServerManager.OpenPort(PortName);
...@@ -85,6 +99,7 @@ namespace OnlineStore.AutoInOutStore ...@@ -85,6 +99,7 @@ namespace OnlineStore.AutoInOutStore
{ {
} }
} }
private void btnServoOff_Click(object sender, EventArgs e) private void btnServoOff_Click(object sender, EventArgs e)
...@@ -102,9 +117,7 @@ namespace OnlineStore.AutoInOutStore ...@@ -102,9 +117,7 @@ namespace OnlineStore.AutoInOutStore
} }
ACServerManager.ServoOff(PortName, SlvAddr); ACServerManager.ServoOff(PortName, SlvAddr);
formStatus(false ); formStatus(false);
} }
private void formStatus(bool p) private void formStatus(bool p)
...@@ -163,9 +176,13 @@ namespace OnlineStore.AutoInOutStore ...@@ -163,9 +176,13 @@ namespace OnlineStore.AutoInOutStore
txtSpeed.Focus(); txtSpeed.Focus();
return; return;
} }
P3Offset = FormUtil.GetIntValue(txtP3Offset);
P4Offset = FormUtil.GetIntValue(txtP4Offset);
P5Offset = FormUtil.GetIntValue(txtP5Offset);
P6Offset = FormUtil.GetIntValue(txtP6Offset);
LastValue = IO_VALUE.LOW; LastValue = IO_VALUE.LOW;
string fileName = txtFileName.Text; string fileName = txtFileName.Text;
string filePath = Application.StartupPath + @"\" + fileName; string filePath = Application.StartupPath + @"\logs\" + fileName;
if (File.Exists(filePath)) if (File.Exists(filePath))
{ {
DialogResult result = MessageBox.Show("文件【"+filePath+"】已存在,是否确定覆盖?","", MessageBoxButtons.OKCancel,MessageBoxIcon.Question); DialogResult result = MessageBox.Show("文件【"+filePath+"】已存在,是否确定覆盖?","", MessageBoxButtons.OKCancel,MessageBoxIcon.Question);
...@@ -176,10 +193,25 @@ namespace OnlineStore.AutoInOutStore ...@@ -176,10 +193,25 @@ namespace OnlineStore.AutoInOutStore
} }
PositionList = new List<int>(); PositionList = new List<int>();
LogUtil.info(LogName + "伺服开始运动,速度【"+speed+"】位置【"+position+"】启动定时器 "); LogUtil.info(LogName + "伺服开始运动,速度【"+speed+"】位置【"+position+"】启动定时器 ");
formMoveStatus(false);
ACServerManager.AbsMove(PortName, SlvAddr, position,speed); ACServerManager.AbsMove(PortName, SlvAddr, position,speed);
toolTimer.Start(); 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) private void btnSdStop_Click(object sender, EventArgs e)
{ {
toolTimer.Stop(); toolTimer.Stop();
...@@ -190,9 +222,6 @@ namespace OnlineStore.AutoInOutStore ...@@ -190,9 +222,6 @@ namespace OnlineStore.AutoInOutStore
{ {
return IOManager.instance.GetDIValue(IoIp, 0, (ushort)IoIndex); return IOManager.instance.GetDIValue(IoIp, 0, (ushort)IoIndex);
} }
private int TargetPostion = 0; private int TargetPostion = 0;
private bool isInProcesss = false; private bool isInProcesss = false;
private DateTime LastTime = DateTime.Now; private DateTime LastTime = DateTime.Now;
...@@ -249,20 +278,27 @@ namespace OnlineStore.AutoInOutStore ...@@ -249,20 +278,27 @@ namespace OnlineStore.AutoInOutStore
return; return;
} }
LogUtil.info(LogName + "伺服已停止运动,停止定时器,记录数据"); LogUtil.info(LogName + "伺服已停止运动,停止定时器,记录数据");
string resultstr = ""; List<string> strList = new List<string>();
strList.Add("编号,标准位置,升降轴库位出料前点P5,升降轴库位出料缓冲点P6,升降轴库位入料前点P3,升降轴库位入料缓冲点P4");
int index = 1; int index = 1;
foreach (int p in PositionList) foreach (int p in PositionList)
{ {
resultstr += index + "," + p + "\r\n"; 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++; index++;
} }
string fileName = txtFileName.Text; string fileName = txtFileName.Text;
string filePath = Application.StartupPath + @"\" + fileName; string filePath = Application.StartupPath + @"\logs\" + fileName;
try try
{ {
// Clipboard.SetDataObject(resultstr); // Clipboard.SetDataObject(resultstr);
File.WriteAllText(filePath, resultstr); File.WriteAllLines(filePath, strList.ToArray());
LogUtil.error(LogName + "保存位置到文件【" + filePath + "】成功"); LogUtil.error(LogName + "保存位置到文件【" + filePath + "】成功");
} }
...@@ -270,10 +306,10 @@ namespace OnlineStore.AutoInOutStore ...@@ -270,10 +306,10 @@ namespace OnlineStore.AutoInOutStore
{ {
LogUtil.error(LogName + "保存位置到文件【" + filePath + "】出错:" + ex.ToString()); LogUtil.error(LogName + "保存位置到文件【" + filePath + "】出错:" + ex.ToString());
} }
formMoveStatus(true );
} }
private void timer1_Tick(object sender, EventArgs e) private void timer1_Tick(object sender, EventArgs e)
{ {
try try
{ {
ioStatusControl1.IOValue = (int)GetSingleValue(); ioStatusControl1.IOValue = (int)GetSingleValue();
...@@ -281,9 +317,7 @@ namespace OnlineStore.AutoInOutStore ...@@ -281,9 +317,7 @@ namespace OnlineStore.AutoInOutStore
} }
catch (Exception ex) catch (Exception ex)
{ {
} }
} }
private void FrmPositionTool_FormClosing(object sender, FormClosingEventArgs e) private void FrmPositionTool_FormClosing(object sender, FormClosingEventArgs e)
...@@ -295,12 +329,11 @@ namespace OnlineStore.AutoInOutStore ...@@ -295,12 +329,11 @@ namespace OnlineStore.AutoInOutStore
} }
//ACServerManager.CloseAllPort(); //ACServerManager.CloseAllPort();
IOManager.instance.CloseAllConnection(); IOManager.instance.CloseAllConnection();
} }
private void btnOpenFolder_Click(object sender, EventArgs e) private void btnOpenFolder_Click(object sender, EventArgs e)
{ {
System.Diagnostics.Process.Start("Explorer.exe", Application.StartupPath); System.Diagnostics.Process.Start("Explorer.exe", Application.StartupPath + @"\logs\");
} }
private void btnExit_Click(object sender, EventArgs e) private void btnExit_Click(object sender, EventArgs e)
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!