Commit 02f9b237 LN

io操作按钮调整

1 个父辈 351aea0a
......@@ -90,6 +90,12 @@
<Compile Include="FrmDischargeLine.Designer.cs">
<DependentUpon>FrmDischargeLine.cs</DependentUpon>
</Compile>
<Compile Include="FrmEquipBase.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FrmEquipBase.Designer.cs">
<DependentUpon>FrmEquipBase.cs</DependentUpon>
</Compile>
<Compile Include="FrmProvidingEquip.cs">
<SubType>Form</SubType>
</Compile>
......
......@@ -20,11 +20,9 @@ using OnlineStore.Common;
namespace OnlineStore.AssemblyLine
{
public partial class FrmDischargeLine : FrmBase
public partial class FrmDischargeLine : FrmEquipBase
{
private bool IsLoad = false;
private string portName = "";
private short SlvAddr = 0;
private bool IsLoad = false;
private DischargeLine dischargeLine;
public static readonly ILog LOGGER = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public FrmDischargeLine(DischargeLine moveEquip)
......@@ -123,11 +121,19 @@ namespace OnlineStore.AssemblyLine
LogUtil.error(LOGGER, ex.StackTrace);
}
}
private void btnOpenDo_Click(object sender, EventArgs e)
{
WriteDO(IO_VALUE.HIGH);
}
private void btnWriteSingleDO_Click(object sender, EventArgs e)
{
WriteDO(IO_VALUE.LOW);
}
private void WriteDO(IO_VALUE value)
{
string deviceName = txtDoName.Text;
int index = FormUtil.GetIntValue(txtDOIndex);
IO_VALUE value = checkBox1.Checked ? IO_VALUE.HIGH : IO_VALUE.LOW;
// IO_VALUE value = checkBox1.Checked ? IO_VALUE.HIGH : IO_VALUE.LOW;
int time = FormUtil.GetIntValue(txtWriteTime);
int slaveId = FormUtil.GetIntValue(txtSlaveId);
if (time > 0)
......@@ -140,6 +146,7 @@ namespace OnlineStore.AssemblyLine
}
}
private ConfigIO GetSelectDO()
{
string text = cmbWriteIO.SelectedValue.ToString();
......@@ -227,16 +234,7 @@ namespace OnlineStore.AssemblyLine
}
}
private void btnReadAllDi_Click(object sender, EventArgs e)
{
string deviceName = txtDoName.Text;
IO_VALUE value = checkBox1.Checked ? IO_VALUE.HIGH : IO_VALUE.LOW;
int time = FormUtil.GetIntValue(txtWriteTime);
int slaveId = FormUtil.GetIntValue(txtSlaveId);
IOManager.instance.ReadAllDI(deviceName, (byte)slaveId);
}
public void FormStatus(bool isStart)
{
btnStart.Enabled = !isStart;
......@@ -246,16 +244,7 @@ namespace OnlineStore.AssemblyLine
btnOutStore.Enabled = isStart;
}
private void btnReadAllDo_Click(object sender, EventArgs e)
{
string deviceName = txtDoName.Text;
IO_VALUE value = checkBox1.Checked ? IO_VALUE.HIGH : IO_VALUE.LOW;
int time = FormUtil.GetIntValue(txtWriteTime);
int slaveId = FormUtil.GetIntValue(txtSlaveId);
IOManager.instance.ReadAllDO(deviceName, (byte)slaveId );
}
private void FrmIOStatus_Shown(object sender, EventArgs e)
{
......@@ -348,99 +337,32 @@ namespace OnlineStore.AssemblyLine
}
private void btnStop1Up_Click(object sender, EventArgs e)
{
if (btnStop1Up.Text.Equals("阻挡气缸1下降"))
{
dischargeLine.IOMove(IO_Type.StopCylinder_Down1, IO_VALUE.HIGH);
btnStop1Up.Text = "阻挡气缸1上升";
LogUtil.info("点击【" + btnStop1Up.Text + "】 ");
if (btnStop1Up.Text.Equals("定位气缸上升"))
{
dischargeLine.CylinderMove(null, IO_Type.SeparateDevice_Down, IO_Type.SeparateDevice_Up);
btnStop1Up.Text = "定位气缸下降";
btnStop1Up.BackColor = Color.Aqua;
}
else
{
dischargeLine.IOMove(IO_Type.StopCylinder_Down1, IO_VALUE.LOW);
btnStop1Up.Text = "阻挡气缸1下降";
btnStop1Up.BackColor = Color.White;
}
}
private void btnStop2Up_Click(object sender, EventArgs e)
{
if (btnStop2Up.Text.Equals("阻挡气缸2下降"))
{
dischargeLine.IOMove(IO_Type.StopCylinder_Down2, IO_VALUE.HIGH);
btnStop2Up.Text = "阻挡气缸2上升";
btnStop2Up.BackColor = Color.Aqua;
dischargeLine.CylinderMove(null, IO_Type.SeparateDevice_Up, IO_Type.SeparateDevice_Down);
btnStop1Up.Text = "定位气缸上升";
btnStop1Up.BackColor = Color.SkyBlue;
}
else
{
dischargeLine.IOMove(IO_Type.StopCylinder_Down2, IO_VALUE.LOW);
btnStop2Up.Text = "阻挡气缸2下降";
btnStop2Up.BackColor = Color.White;
}
}
private void btnTopUp_Click(object sender, EventArgs e)
private void btnCloseAll_Click(object sender, EventArgs e)
{
if (btnTopUp.Text.Equals("顶升气缸上升"))
IOManager.CloseDeviceDO(new List<ConfigIO>(dischargeLine.Config.DOList.Values));
foreach (Control con in groupBox5.Controls)
{
dischargeLine.CylinderMove(null, IO_Type.TopCylinder_Down, IO_Type.TopCylinder_UP);
btnTopUp.Text = "顶升气缸下降";
btnTopUp.BackColor = Color.Aqua;
}
else
{
dischargeLine.CylinderMove(null, IO_Type.TopCylinder_UP, IO_Type.TopCylinder_Down);
btnTopUp.Text = "顶升气缸上升";
btnTopUp.BackColor = Color.SkyBlue;
}
}
private void btnBeforeAfterBefore_Click(object sender, EventArgs e)
{
if (btnBeforeAfterBefore.Text.Equals("前后气缸前进"))
{
dischargeLine.CylinderMove(null, IO_Type.BeforeAfterCylinder_After, IO_Type.BeforeAfterCylinder_Before);
btnBeforeAfterBefore.Text = "前后气缸后退";
btnBeforeAfterBefore.BackColor = Color.Aqua;
}
else
{
dischargeLine.CylinderMove(null, IO_Type.BeforeAfterCylinder_Before, IO_Type.BeforeAfterCylinder_After);
btnBeforeAfterBefore.Text = "前后气缸前进";
btnBeforeAfterBefore.BackColor = Color.SkyBlue;
}
}
private void btnUpDownUp_Click(object sender, EventArgs e)
{
if (btnUpDownUp.Text.Equals("上下气缸上升"))
{
dischargeLine.CylinderMove(null, IO_Type.UpDownCylinder_Down, IO_Type.UpDownCylinder_Up);
btnUpDownUp.Text = "上下气缸下降";
btnUpDownUp.BackColor = Color.Aqua;
}
else
{
dischargeLine.CylinderMove(null, IO_Type.UpDownCylinder_Up, IO_Type.UpDownCylinder_Down);
btnUpDownUp.Text = "上下气缸上升";
btnUpDownUp.BackColor = Color.SkyBlue;
}
}
private void btnClampSlack_Click(object sender, EventArgs e)
{
if (btnClampSlack.Text.Equals("夹料气缸夹紧"))
{
dischargeLine.CylinderMove(null, IO_Type.ClampCylinder_Tighten, IO_Type.ClampCylinder_Slack);
btnClampSlack.Text = "夹料气缸放松";
btnClampSlack.BackColor = Color.Aqua;
}
else
{
dischargeLine.CylinderMove(null, IO_Type.ClampCylinder_Slack, IO_Type.ClampCylinder_Tighten);
btnClampSlack.Text = "夹料气缸夹紧";
btnClampSlack.BackColor = Color.SkyBlue;
if (con is Button)
{
con.BackColor = BackColor = Color.White;
}
}
}
private void btnCloseAll_Click(object sender, EventArgs e)
{
IOManager.instance.CloseAllDO();
}
}
......
namespace OnlineStore.AssemblyLine
{
partial class FrmEquipBase
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Text = "FrmEquipBase";
}
#endregion
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace OnlineStore.AssemblyLine
{
public partial class FrmEquipBase : FrmBase
{
public FrmEquipBase()
{
InitializeComponent();
}
}
}
......@@ -212,6 +212,7 @@ namespace OnlineStore.AssemblyLine
this.ShowInTaskbar = false;
this.notifyIcon1.Visible = true;
this.Hide();
GC.Collect();
}
private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
......
......@@ -20,7 +20,7 @@ using OnlineStore.Common;
namespace OnlineStore.AssemblyLine
{
public partial class FrmMoveEquip : FrmBase
public partial class FrmMoveEquip : FrmEquipBase
{
private bool IsLoad = false;
private string portName = "";
......@@ -135,11 +135,19 @@ namespace OnlineStore.AssemblyLine
LogUtil.error(LOGGER, ex.StackTrace);
}
}
private void btnOpenDo_Click(object sender, EventArgs e)
{
WriteDO(IO_VALUE.HIGH);
}
private void btnWriteSingleDO_Click(object sender, EventArgs e)
{
WriteDO(IO_VALUE.LOW);
}
private void WriteDO(IO_VALUE value)
{
string deviceName = txtDoName.Text;
int index = FormUtil.GetIntValue(txtDOIndex);
IO_VALUE value = checkBox1.Checked ? IO_VALUE.HIGH : IO_VALUE.LOW;
// IO_VALUE value = checkBox1.Checked ? IO_VALUE.HIGH : IO_VALUE.LOW;
int time = FormUtil.GetIntValue(txtWriteTime);
int slaveId = FormUtil.GetIntValue(txtSlaveId);
if (time > 0)
......@@ -152,6 +160,7 @@ namespace OnlineStore.AssemblyLine
}
}
private ConfigIO GetSelectDO()
{
string text = cmbWriteIO.SelectedValue.ToString();
......@@ -197,10 +206,12 @@ namespace OnlineStore.AssemblyLine
comboBox1.SelectedIndex = 0;
txtAxisValue.Text = SlvAddr.ToString();
btnUpDownUp.Visible = false;
}
else
{
tabControl1.TabPages.Remove(tabPage2);
btnUpDownUp.Visible = true;
}
cmbSizeList.Items.Clear();
......@@ -262,16 +273,7 @@ namespace OnlineStore.AssemblyLine
}
}
private void btnReadAllDi_Click(object sender, EventArgs e)
{
string deviceName = txtDoName.Text;
IO_VALUE value = checkBox1.Checked ? IO_VALUE.HIGH : IO_VALUE.LOW;
int time = FormUtil.GetIntValue(txtWriteTime);
int slaveId = FormUtil.GetIntValue(txtSlaveId);
IOManager.instance.ReadAllDI(deviceName, (byte)slaveId);
}
public void FormStatus(bool isStart)
{
btnStart.Enabled = !isStart;
......@@ -281,17 +283,7 @@ namespace OnlineStore.AssemblyLine
btnOutStore.Enabled = isStart;
}
private void btnReadAllDo_Click(object sender, EventArgs e)
{
string deviceName = txtDoName.Text;
IO_VALUE value = checkBox1.Checked ? IO_VALUE.HIGH : IO_VALUE.LOW;
int time = FormUtil.GetIntValue(txtWriteTime);
int slaveId = FormUtil.GetIntValue(txtSlaveId);
IOManager.instance.ReadAllDO(deviceName, (byte)slaveId );
}
private void FrmIOStatus_Shown(object sender, EventArgs e)
{
timer1.Start();
......@@ -393,95 +385,61 @@ namespace OnlineStore.AssemblyLine
}
private void btnStop1Up_Click(object sender, EventArgs e)
{
if (btnStop1Up.Text.Equals("阻挡气缸1下降"))
{
moveEquip.IOMove(IO_Type.StopCylinder_Down1, IO_VALUE.HIGH);
btnStop1Up.Text = "阻挡气缸1上升";
btnStop1Up.BackColor = Color.Aqua;
}
else
{
moveEquip.IOMove(IO_Type.StopCylinder_Down1, IO_VALUE.LOW);
btnStop1Up.Text = "阻挡气缸1下降";
btnStop1Up.BackColor = Color.White;
}
BtnMove(btnStop1Up, "阻挡1下降", "阻挡1上升", IO_Type.StopCylinder_Down1);
}
private void btnStop2Up_Click(object sender, EventArgs e)
{
if (btnStop2Up.Text.Equals("阻挡气缸2下降"))
{
moveEquip.IOMove(IO_Type.StopCylinder_Down2, IO_VALUE.HIGH);
btnStop2Up.Text = "阻挡气缸2上升";
btnStop2Up.BackColor = Color.Aqua;
}
else
{
moveEquip.IOMove(IO_Type.StopCylinder_Down2, IO_VALUE.LOW);
btnStop2Up.Text = "阻挡气缸2下降";
btnStop2Up.BackColor = Color.White;
}
}
private void btnTopUp_Click(object sender, EventArgs e)
{
if (btnTopUp.Text.Equals("顶升气缸上升"))
BtnMove(btnStop2Up, "阻挡2下降", "阻挡2上升", IO_Type.StopCylinder_Down2);
}
private void BtnMove(Button btn, string defaultText, string targetText, string ioHighType )
{
LogUtil.info("点击【" + btn.Text + "】 ");
if (btn.Text.Equals(defaultText))
{
moveEquip.CylinderMove(null, IO_Type.TopCylinder_Down, IO_Type.TopCylinder_UP);
btnTopUp.Text = "顶升气缸下降";
btnTopUp.BackColor = Color.Aqua;
moveEquip.IOMove(ioHighType, IO_VALUE.HIGH);
btn.Text = targetText;
btn.BackColor = Color.Aqua;
}
else
{
moveEquip.CylinderMove(null, IO_Type.TopCylinder_UP, IO_Type.TopCylinder_Down);
btnTopUp.Text = "顶升气缸上升";
btnTopUp.BackColor = Color.SkyBlue;
moveEquip.IOMove(ioHighType, IO_VALUE.LOW);
btn.Text = defaultText;
btn.BackColor = Color.White;
}
}
private void btnBeforeAfterBefore_Click(object sender, EventArgs e)
private void BtnMove(Button btn, string defaultText, string targetText, string ioLowType, string ioHighType)
{
if (btnBeforeAfterBefore.Text.Equals("前后气缸前进"))
LogUtil.info("点击【" + btn.Text + "】 ");
if (btn.Text.Equals(defaultText))
{
moveEquip.CylinderMove(null, IO_Type.BeforeAfterCylinder_After, IO_Type.BeforeAfterCylinder_Before);
btnBeforeAfterBefore.Text = "前后气缸后退";
btnBeforeAfterBefore.BackColor = Color.Aqua;
moveEquip.CylinderMove(null, ioLowType, ioHighType);
btn.Text = targetText;
btn.BackColor = Color.Aqua;
}
else
{
moveEquip.CylinderMove(null, IO_Type.BeforeAfterCylinder_Before, IO_Type.BeforeAfterCylinder_After);
btnBeforeAfterBefore.Text = "前后气缸前进";
btnBeforeAfterBefore.BackColor = Color.SkyBlue;
moveEquip.CylinderMove(null, ioHighType, ioLowType);
btn.Text = defaultText;
btn.BackColor = Color.SkyBlue;
}
}
}
private void btnTopUp_Click(object sender, EventArgs e)
{
BtnMove(btnTopUp, "顶升上升", "顶升下降", IO_Type.TopCylinder_Down, IO_Type.TopCylinder_UP);
}
private void btnBeforeAfterBefore_Click(object sender, EventArgs e)
{
BtnMove(btnBeforeAfterBefore, "横移前进", "横移后退", IO_Type.BeforeAfterCylinder_After, IO_Type.BeforeAfterCylinder_Before);
}
private void btnUpDownUp_Click(object sender, EventArgs e)
{
if (btnUpDownUp.Text.Equals("上下气缸上升"))
{
moveEquip.CylinderMove(null, IO_Type.UpDownCylinder_Down, IO_Type.UpDownCylinder_Up);
btnUpDownUp.Text = "上下气缸下降";
btnUpDownUp.BackColor = Color.Aqua;
}
else
{
moveEquip.CylinderMove(null, IO_Type.UpDownCylinder_Up, IO_Type.UpDownCylinder_Down);
btnUpDownUp.Text = "上下气缸上升";
btnUpDownUp.BackColor = Color.SkyBlue;
}
}
BtnMove(btnUpDownUp, "升降上升", "升降下降", IO_Type.UpDownCylinder_Down, IO_Type.UpDownCylinder_Up);
}
private void btnClampSlack_Click(object sender, EventArgs e)
{
if (btnClampSlack.Text.Equals("夹料气缸夹紧"))
{
moveEquip.CylinderMove(null, IO_Type.ClampCylinder_Tighten, IO_Type.ClampCylinder_Slack);
btnClampSlack.Text = "夹料气缸放松";
btnClampSlack.BackColor = Color.Aqua;
}
else
{
moveEquip.CylinderMove(null, IO_Type.ClampCylinder_Slack, IO_Type.ClampCylinder_Tighten);
btnClampSlack.Text = "夹料气缸夹紧";
btnClampSlack.BackColor = Color.SkyBlue;
}
}
BtnMove(btnClampSlack, "夹料夹紧", "夹料放松", IO_Type.ClampCylinder_Tighten, IO_Type.ClampCylinder_Slack);
}
private void btnOpenAxis_Click(object sender, EventArgs e)
{
string portName = txtAxisDeviceName.Text;
......@@ -617,8 +575,15 @@ namespace OnlineStore.AssemblyLine
}
private void btnCloseAll_Click(object sender, EventArgs e)
{
IOManager.instance.CloseAllDO();
{
IOManager.CloseDeviceDO(new List<ConfigIO>( moveEquip.Config.DOList.Values));
foreach(Control con in groupBox5.Controls)
{
if(con is Button)
{
con.BackColor= BackColor = Color.White;
}
}
}
private void button3_Click(object sender, EventArgs e)
......
......@@ -20,11 +20,10 @@ using OnlineStore.Common;
namespace OnlineStore.AssemblyLine
{
public partial class FrmProvidingEquip : FrmBase
public partial class FrmProvidingEquip : FrmEquipBase
{
private bool IsLoad = false;
private string portName = "";
private short SlvAddr = 0;
private ProvidingEquip providingEquip;
public static readonly ILog LOGGER = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public FrmProvidingEquip(ProvidingEquip moveEquip)
......@@ -123,11 +122,19 @@ namespace OnlineStore.AssemblyLine
LogUtil.error(LOGGER, ex.StackTrace);
}
}
private void btnOpenDo_Click(object sender, EventArgs e)
{
WriteDO(IO_VALUE.HIGH);
}
private void btnWriteSingleDO_Click(object sender, EventArgs e)
{
WriteDO(IO_VALUE.LOW);
}
private void WriteDO(IO_VALUE value)
{
string deviceName = txtDoName.Text;
int index = FormUtil.GetIntValue(txtDOIndex);
IO_VALUE value = checkBox1.Checked ? IO_VALUE.HIGH : IO_VALUE.LOW;
// IO_VALUE value = checkBox1.Checked ? IO_VALUE.HIGH : IO_VALUE.LOW;
int time = FormUtil.GetIntValue(txtWriteTime);
int slaveId = FormUtil.GetIntValue(txtSlaveId);
if (time > 0)
......@@ -139,7 +146,6 @@ namespace OnlineStore.AssemblyLine
IOManager.instance.WriteSingleDO(deviceName, (byte)slaveId, (ushort)index, (IO_VALUE)value);
}
}
private ConfigIO GetSelectDO()
{
string text = cmbWriteIO.SelectedValue.ToString();
......@@ -227,15 +233,7 @@ namespace OnlineStore.AssemblyLine
}
}
private void btnReadAllDi_Click(object sender, EventArgs e)
{
string deviceName = txtDoName.Text;
IO_VALUE value = checkBox1.Checked ? IO_VALUE.HIGH : IO_VALUE.LOW;
int time = FormUtil.GetIntValue(txtWriteTime);
int slaveId = FormUtil.GetIntValue(txtSlaveId);
IOManager.instance.ReadAllDI(deviceName, (byte)slaveId);
}
public void FormStatus(bool isStart)
{
......@@ -245,18 +243,7 @@ namespace OnlineStore.AssemblyLine
//btnInStore.Enabled = isStart;
btnOutStore.Enabled = isStart;
}
private void btnReadAllDo_Click(object sender, EventArgs e)
{
string deviceName = txtDoName.Text;
IO_VALUE value = checkBox1.Checked ? IO_VALUE.HIGH : IO_VALUE.LOW;
int time = FormUtil.GetIntValue(txtWriteTime);
int slaveId = FormUtil.GetIntValue(txtSlaveId);
IOManager.instance.ReadAllDO(deviceName, (byte)slaveId );
}
private void FrmIOStatus_Shown(object sender, EventArgs e)
{
timer1.Start();
......@@ -348,100 +335,74 @@ namespace OnlineStore.AssemblyLine
}
private void btnStop1Up_Click(object sender, EventArgs e)
{
if (btnStop1Up.Text.Equals("阻挡气缸1下降"))
{
providingEquip.IOMove(IO_Type.StopCylinder_Down1, IO_VALUE.HIGH);
btnStop1Up.Text = "阻挡气缸1上升";
btnStop1Up.BackColor = Color.Aqua;
}
else
{
providingEquip.IOMove(IO_Type.StopCylinder_Down1, IO_VALUE.LOW);
btnStop1Up.Text = "阻挡气缸1下降";
btnStop1Up.BackColor = Color.White;
}
}
BtnMove(btnStop1Up, "阻挡1下降", "阻挡1上升", IO_Type.StopCylinder_Down1);
}
private void btnStop2Up_Click(object sender, EventArgs e)
{
if (btnStop2Up.Text.Equals("阻挡气缸2下降"))
{
providingEquip.IOMove(IO_Type.StopCylinder_Down2, IO_VALUE.HIGH);
btnStop2Up.Text = "阻挡气缸2上升";
btnStop2Up.BackColor = Color.Aqua;
}
else
{
providingEquip.IOMove(IO_Type.StopCylinder_Down2, IO_VALUE.LOW);
btnStop2Up.Text = "阻挡气缸2下降";
btnStop2Up.BackColor = Color.White;
}
}
private void btnTopUp_Click(object sender, EventArgs e)
{
if (btnTopUp.Text.Equals("顶升气缸上升"))
BtnMove(btnStop2Up, "阻挡2下降", "阻挡2上升", IO_Type.StopCylinder_Down2);
}
private void BtnMove(Button btn, string defaultText, string targetText, string ioHighType)
{
LogUtil.info("点击【" + btn.Text + "】 ");
if (btn.Text.Equals(defaultText))
{
providingEquip.CylinderMove(null, IO_Type.TopCylinder_Down, IO_Type.TopCylinder_UP);
btnTopUp.Text = "顶升气缸下降";
btnTopUp.BackColor = Color.Aqua;
providingEquip.IOMove(ioHighType, IO_VALUE.HIGH);
btn.Text = targetText;
btn.BackColor = Color.Aqua;
}
else
{
providingEquip.CylinderMove(null, IO_Type.TopCylinder_UP, IO_Type.TopCylinder_Down);
btnTopUp.Text = "顶升气缸上升";
btnTopUp.BackColor = Color.SkyBlue;
providingEquip.IOMove(ioHighType, IO_VALUE.LOW);
btn.Text = defaultText;
btn.BackColor = Color.White;
}
}
private void btnBeforeAfterBefore_Click(object sender, EventArgs e)
private void BtnMove(Button btn, string defaultText, string targetText, string ioLowType, string ioHighType)
{
if (btnBeforeAfterBefore.Text.Equals("前后气缸前进"))
LogUtil.info("点击【" + btn.Text + "】 ");
if (btn.Text.Equals(defaultText))
{
providingEquip.CylinderMove(null, IO_Type.BeforeAfterCylinder_After, IO_Type.BeforeAfterCylinder_Before);
btnBeforeAfterBefore.Text = "前后气缸后退";
btnBeforeAfterBefore.BackColor = Color.Aqua;
providingEquip.CylinderMove(null, ioLowType, ioHighType);
btn.Text = targetText;
btn.BackColor = Color.Aqua;
}
else
{
providingEquip.CylinderMove(null, IO_Type.BeforeAfterCylinder_Before, IO_Type.BeforeAfterCylinder_After);
btnBeforeAfterBefore.Text = "前后气缸前进";
btnBeforeAfterBefore.BackColor = Color.SkyBlue;
providingEquip.CylinderMove(null, ioHighType, ioLowType);
btn.Text = defaultText;
btn.BackColor = Color.SkyBlue;
}
}
}
private void btnTopUp_Click(object sender, EventArgs e)
{
BtnMove(btnTopUp, "顶升上升", "顶升下降", IO_Type.TopCylinder_Down, IO_Type.TopCylinder_UP);
}
private void btnBeforeAfterBefore_Click(object sender, EventArgs e)
{
BtnMove(btnBeforeAfterBefore, "横移前进", "横移后退", IO_Type.BeforeAfterCylinder_After, IO_Type.BeforeAfterCylinder_Before);
}
private void btnUpDownUp_Click(object sender, EventArgs e)
{
if (btnUpDownUp.Text.Equals("上下气缸上升"))
{
providingEquip.CylinderMove(null, IO_Type.UpDownCylinder_Down, IO_Type.UpDownCylinder_Up);
btnUpDownUp.Text = "上下气缸下降";
btnUpDownUp.BackColor = Color.Aqua;
}
else
{
providingEquip.CylinderMove(null, IO_Type.UpDownCylinder_Up, IO_Type.UpDownCylinder_Down);
btnUpDownUp.Text = "上下气缸上升";
btnUpDownUp.BackColor = Color.SkyBlue;
}
}
BtnMove(btnUpDownUp, "升降上升", "升降下降", IO_Type.UpDownCylinder_Down, IO_Type.UpDownCylinder_Up);
}
private void btnClampSlack_Click(object sender, EventArgs e)
{
if (btnClampSlack.Text.Equals("夹料气缸夹紧"))
{
providingEquip.CylinderMove(null, IO_Type.ClampCylinder_Tighten, IO_Type.ClampCylinder_Slack);
btnClampSlack.Text = "夹料气缸放松";
btnClampSlack.BackColor = Color.Aqua;
}
else
{
providingEquip.CylinderMove(null, IO_Type.ClampCylinder_Slack, IO_Type.ClampCylinder_Tighten);
btnClampSlack.Text = "夹料气缸夹紧";
btnClampSlack.BackColor = Color.SkyBlue;
}
BtnMove(btnClampSlack, "夹料夹紧", "夹料放松", IO_Type.ClampCylinder_Tighten, IO_Type.ClampCylinder_Slack);
}
private void btnCloseAll_Click(object sender, EventArgs e)
{
IOManager.instance.CloseAllDO();
{
IOManager.CloseDeviceDO(new List<ConfigIO>( providingEquip.Config.DOList.Values));
foreach (Control con in groupBox5.Controls)
{
if (con is Button)
{
con.BackColor = BackColor = Color.White;
}
}
}
}
}
......
......@@ -71,12 +71,12 @@
<Compile Include="deviceLibrary\IO\AIManager.cs" />
<Compile Include="deviceLibrary\IO\AIOBOX\AIOBOXManager.cs" />
<Compile Include="deviceLibrary\IO\IOManager.cs" />
<Compile Include="deviceLibrary\IO\KangNaiDe\KNDManager.cs" />
<Compile Include="deviceLibrary\IO\KangNaiDe\MasterTcpClient.cs" />
<Compile Include="assemblyLine\LineBean.cs" />
<Compile Include="assemblyLine\LineBean_Partial.cs" />
<Compile Include="assemblyLine\MoveEquip.cs" />
<Compile Include="assemblyLine\MoveEquip_Partial.cs" />
<Compile Include="deviceLibrary\IO\KangNaiDe\KNDManager.cs" />
<Compile Include="deviceLibrary\IO\KangNaiDe\MasterTcpClient.cs" />
<Compile Include="deviceLibrary\PanasonicServo\ACCMDManager.cs" />
<Compile Include="deviceLibrary\PanasonicServo\ACServerManager.cs" />
<Compile Include="deviceLibrary\PanasonicServo\ACServerManager_Partial.cs" />
......
......@@ -22,10 +22,9 @@ namespace OnlineStore.DeviceLibrary
public static LineBean Line = null;
public static Line_Config Config = null;
public static Dictionary<int, MoveEquip_Config> moveECMap = null;
public static Dictionary<int, FeedingEquip_Config> feedingECMap = null;
public static Dictionary<int, ProvidingEquip_Config> providingECMap = null;
public static Dictionary<int, DischargeLine_Config> disChargeLineMap = null;
public static Dictionary<int, StoreConfig> allConfigMap = null;
public LineManager()
{
}
......@@ -52,12 +51,18 @@ namespace OnlineStore.DeviceLibrary
{
if (!isInit)
{
Dictionary<int, MoveEquip_Config> moveECMap = null;
Dictionary<int, FeedingEquip_Config> feedingECMap = null;
Dictionary<int, ProvidingEquip_Config> providingECMap = null;
Dictionary<int, DischargeLine_Config> disChargeLineMap = null;
StoreConfig.SubDIList = new Dictionary<int, Dictionary<string, ConfigIO>>();
StoreConfig.SubDOList = new Dictionary<int, Dictionary<string, ConfigIO>>();
moveECMap = new Dictionary<int, MoveEquip_Config>();
feedingECMap = new Dictionary<int, FeedingEquip_Config>();
providingECMap = new Dictionary<int, ProvidingEquip_Config>();
disChargeLineMap = new Dictionary<int, DischargeLine_Config>();
allConfigMap = new Dictionary<int, StoreConfig>();
string server = ConfigAppSettings.GetValue(Setting_Init.http_server);
if (server.Equals(""))
{
......@@ -81,17 +86,18 @@ namespace OnlineStore.DeviceLibrary
string linefilePath = appPath + ConfigAppSettings.GetValue(Setting_Init.ConfigPath_Line);
Config = CSVConfigReader.LoadLineConfig(0, CID, StoreType.RC_LINE, linefilePath);
int moveEquipCount = ConfigAppSettings.GetIntValue(Setting_Init.Line_moveEquip_count);
allConfigMap.Add(0, Config);
int moveEquipCount = ConfigAppSettings.GetIntValue(Setting_Init.Line_moveEquip_count);
string moveEquipConfig = ConfigAppSettings.GetValue(Setting_Init.ConfigPath_MoveEquip);
for (int i = 1; i <= moveEquipCount; i++)
{
string nameStr = i.ToString().PadLeft(2, '0');
string config = appPath + moveEquipConfig.Replace(".csv", "_" + nameStr + ".csv");
MoveEquip_Config moveConfig = CSVConfigReader.LoadMoveConfig(i, config);
MoveEquip_Config moveConfig = CSVConfigReader.LoadMoveConfig(i, config);
int subType = i;
moveConfig.SetIO( subType);
moveConfig.SetIO(subType);
moveECMap.Add(i, moveConfig);
allConfigMap.Add(subType, moveConfig);
}
int feedingEquipCount = ConfigAppSettings.GetIntValue(Setting_Init.Line_feedingEquip_count);
string feedingEquipConfig = ConfigAppSettings.GetValue(Setting_Init.ConfigPath_FeedingEquip);
......@@ -100,9 +106,10 @@ namespace OnlineStore.DeviceLibrary
int subType = 100 + i;
string config = appPath + feedingEquipConfig.Replace(".csv", "_" + i + ".csv");
FeedingEquip_Config moveConfig = CSVConfigReader.LoadFeedingConfig(subType, config);
moveConfig.SetIO( subType);
feedingECMap.Add(i, moveConfig);
moveConfig.SetIO(subType);
feedingECMap.Add(subType, moveConfig);
allConfigMap.Add(subType, moveConfig);
}
int providingEquipCount = ConfigAppSettings.GetIntValue(Setting_Init.Line_providingEquip_count);
......@@ -112,9 +119,10 @@ namespace OnlineStore.DeviceLibrary
int subType = 200 + i;
string config = appPath + providingEquipConfig.Replace(".csv", "_" + i + ".csv");
ProvidingEquip_Config moveConfig = CSVConfigReader.LoadProvidingConfig(subType, config);
moveConfig.SetIO( subType);
providingECMap.Add(i, moveConfig);
moveConfig.SetIO(subType);
providingECMap.Add(subType, moveConfig);
allConfigMap.Add(subType, moveConfig);
}
int dislineCount = ConfigAppSettings.GetIntValue(Setting_Init.Line_dischargeLine_count);
......@@ -126,15 +134,17 @@ namespace OnlineStore.DeviceLibrary
DischargeLine_Config moveConfig = CSVConfigReader.LoadDischargeLineConfig(subType, config);
moveConfig.SetIO(subType);
disChargeLineMap.Add(i, moveConfig);
disChargeLineMap.Add(subType, moveConfig);
allConfigMap.Add(subType, moveConfig);
}
Line = new LineBean(Config, moveECMap,feedingECMap,providingECMap,disChargeLineMap);
Line = new LineBean(Config, moveECMap, feedingECMap, providingECMap, disChargeLineMap);
LogUtil.info(LOGGER, "加载 完成!");
return true;
}
}
else if(Line != null){
else if (Line != null)
{
return true;
}
}
......@@ -144,7 +154,7 @@ namespace OnlineStore.DeviceLibrary
MessageBox.Show(ex.ToString(), "加载配置错误(请检查配置)");
Application.Exit();
}
return false ;
return false;
}
/// <summary>
......@@ -181,7 +191,8 @@ namespace OnlineStore.DeviceLibrary
string moveEquipConfig = ConfigAppSettings.GetValue(Setting_Init.ConfigPath_MoveEquip);
string configStr = appPath + moveEquipConfig.Replace(".csv", "_" + config.Id.ToString().PadLeft(2,'0') + ".csv");
moveECMap[config.Id] = config;
// moveECMap[config.Id] = config;
allConfigMap[config.Id] = config;
bool result = CSVConfigReader.SaveConfig(configStr, config,typeof(MoveEquip_Config));
if (!result)
{
......@@ -203,7 +214,8 @@ namespace OnlineStore.DeviceLibrary
int id = config.Id - 100;
string configStr = appPath + moveEquipConfig.Replace(".csv", "_" + id+ ".csv");
feedingECMap[config.Id] = config;
// feedingECMap[config.Id] = config;
allConfigMap[config.Id] = config;
bool result = CSVConfigReader.SaveConfig(configStr, config,typeof(FeedingEquip_Config));
if (!result)
{
......@@ -224,7 +236,8 @@ namespace OnlineStore.DeviceLibrary
string moveEquipConfig = ConfigAppSettings.GetValue(Setting_Init.ConfigPath_ProvidingEquip);
int id = config.Id - 200;
string configStr = appPath + moveEquipConfig.Replace(".csv", "_" + id + ".csv");
providingECMap[config.Id] = config;
// providingECMap[config.Id] = config;
allConfigMap[config.Id] = config;
bool result = CSVConfigReader.SaveConfig(configStr, config,typeof(ProvidingEquip_Config));
if (!result)
{
......@@ -246,7 +259,8 @@ namespace OnlineStore.DeviceLibrary
string moveEquipConfig = ConfigAppSettings.GetValue(Setting_Init.ConfigPath_DischargeLine);
int id = config.Id - 300;
string configStr = appPath + moveEquipConfig.Replace(".csv", "_" + id + ".csv");
disChargeLineMap[config.Id] = config;
// disChargeLineMap[config.Id] = config;
allConfigMap[config.Id] = config;
bool result = CSVConfigReader.SaveConfig(configStr, config, typeof(DischargeLine_Config));
if (!result)
{
......
......@@ -25,7 +25,7 @@ namespace OnlineStore.DeviceLibrary
this.Config = config;
IsDebug = config.IsDebug.Equals(1);
baseConfig = config;
Name = (" " + "_出料皮带线_" + DeviceID % 30 + " ").ToUpper();
Name = (" " + "_出料皮带线_" + DeviceID % 100 + " ").ToUpper();
Init();
UseAxis = false;
MoveInfo = new LineMoveInfo(DeviceID, "出料皮带线-" + DeviceID + "-MoveInfo");
......
......@@ -23,7 +23,7 @@ namespace OnlineStore.DeviceLibrary
baseConfig = config;
this.Config = config;
IsDebug = config.IsDebug.Equals(1);
Name = (" " + "_入料_" + DeviceID % 10 + " ").ToUpper();
Name = (" " + "_入料_" + DeviceID % 100 + " ").ToUpper();
Init();
MoveInfo = new LineMoveInfo(DeviceID, "入料-" + DeviceID + "-Move");
SecondMoveInfo = new LineMoveInfo(DeviceID, "入料-" + DeviceID + "-SecondMove");
......
......@@ -25,7 +25,7 @@ namespace OnlineStore.DeviceLibrary
this.Config = config;
IsDebug = config.IsDebug.Equals(1);
baseConfig = config;
Name = (" " + "_出料_" + DeviceID % 10 + " ").ToUpper();
Name = (" " + "_出料_" + DeviceID % 100 + " ").ToUpper();
Init();
UseAxis = false;
MoveInfo = new LineMoveInfo(DeviceID, "出料-" + DeviceID + "-MoveInfo");
......
......@@ -292,18 +292,7 @@ namespace OnlineStore.DeviceLibrary
DOValueMap.Add(ip, newList);
}
}
}
//else
//{
// if (sta == null)
// {
// LogUtil.error("UpdateAllDO ip[" + ip + "], sta=null");
// }
// else
// {
// LogUtil.error(" UpdateAllDO ip[" + ip + "], sta.Length=" + sta.Length);
// }
//}
}
}
......@@ -315,10 +304,7 @@ namespace OnlineStore.DeviceLibrary
{
ushort length = LineManager.Config.GetDOLength(aio.IP);
for (ushort i = 0; i < length; i++)
{
// ushort u = (ushort)(i + length);
// ushort u = (ushort)(i );
// Box_Addr addr = GetAddr(u);
{
aio.WriteDO(i, Box_Sta.Off);
}
}
......@@ -347,7 +333,7 @@ namespace OnlineStore.DeviceLibrary
bool result = aioBox.WriteDO(StartAddress, GetBox_Sta(onOff));
if (!result)
{
LogUtil.error("AIO WriteSingleDO [" + StartAddress + "] 第" + i + "次失败:" + aioBox.ErrInfo);
LogUtil.error("AIO WriteSingleDO ["+ioIp+"] [" + StartAddress + "] 第" + i + "次失败:" + aioBox.ErrInfo);
}
else
{
......@@ -362,7 +348,7 @@ namespace OnlineStore.DeviceLibrary
}
catch (Exception ex)
{
LOGGER.Error("出错啦:" + ex.ToString());
LOGGER.Error("AIO WriteSingleDO [" + ioIp + "] [" + StartAddress + "] 出错啦:" + ex.ToString());
}
}
public override void WriteSingleDO(string ioIp, byte slaveId, ushort StartAddress, IO_VALUE onOff, int mSeconds)
......@@ -384,7 +370,7 @@ namespace OnlineStore.DeviceLibrary
try
{
aioBox.WriteDO(StartAddress, aioBox.ReverseStatus(currBox_Sta));
LogUtil.debug(LOGGER, "**********定时回写入 IO【" + ioIp + "," + StartAddress + ",值" + aioBox.ReverseStatus(currBox_Sta) + "】:");
LogUtil.debug(LOGGER, "**********定时回写入 IO [" + ioIp + "] [" + StartAddress + "]值" + aioBox.ReverseStatus(currBox_Sta) + "】:");
}
catch (Exception ex)
{
......@@ -396,12 +382,12 @@ namespace OnlineStore.DeviceLibrary
}
else
{
LogUtil.error(LOGGER, "WriteSingleDO出错 没有连接IO模块:" + ioIp);
LogUtil.error(LOGGER, "AIO WriteSingleDO [" + ioIp + "] [" + StartAddress + "] 出错 没有连接IO模块:" + ioIp);
}
}
catch (Exception ex)
{
LogUtil.error("WriteSingleDO 出错:" + ioIp);
LogUtil.error("AIO WriteSingleDO [" + ioIp + "] [" + StartAddress + "] 出错:" + ioIp);
}
}
public override void ReadAllDI(string ioIp, byte slaveId)
......@@ -417,7 +403,7 @@ namespace OnlineStore.DeviceLibrary
}
catch (Exception ex)
{
LogUtil.error("ReadAllDI出错:" + ioIp);
LogUtil.error("ReadAllDI [" + ioIp + "]出错:" + ioIp);
}
}
public override void ReadAllDO(string ioIp, byte slaveId)
......@@ -434,7 +420,7 @@ namespace OnlineStore.DeviceLibrary
}
catch (Exception ex)
{
LogUtil.error("ReadAllDO出错:" + ioIp);
LogUtil.error("ReadAllDO [" + ioIp + "]出错:" + ioIp);
}
}
public override IO_VALUE GetDOValue(string ioIP, byte slaveId, ushort StartAddress)
......@@ -463,7 +449,7 @@ namespace OnlineStore.DeviceLibrary
}
catch (Exception ex)
{
LogUtil.error("GetDOValue 出错:" + ex.ToString());
LogUtil.error("GetDOValue [" + ioIP + "] [" + StartAddress + "] 出错:" + ex.ToString());
}
return value;
}
......@@ -495,7 +481,7 @@ namespace OnlineStore.DeviceLibrary
}
catch (Exception ex)
{
LogUtil.error("GetDIValue 出错:" + ex.ToString());
LogUtil.error("GetDIValue [" + ioIP + "] [" + StartAddress + "] 出错:" + ex.ToString());
}
return value;
}
......@@ -515,15 +501,11 @@ namespace OnlineStore.DeviceLibrary
}
catch (Exception ex)
{
LogUtil.error(LOGGER, " GetIOValue 获取数据出错:" + ex.ToString());
LogUtil.error(LOGGER, " GetIOValue [" + configIO.DeviceName + "] [" + configIO.GetIOAddr() + "] 获取数据出错:" + ex.ToString());
}
return value;
}
//private Box_Addr GetAddr(ushort StartAddress)
//{
// return (Box_Addr)(StartAddress);
//}
private Box_Sta GetBox_Sta(IO_VALUE onOff)
{
if (onOff.Equals(IO_VALUE.HIGH))
......
......@@ -16,12 +16,7 @@ namespace OnlineStore.DeviceLibrary
#region KNDIO
/// <summary>
/// 写指定IO
/// </summary>
/// <param name="ioType">IO类型</param>
/// <param name="ioValue">IO值</param>
/// <param name="subType">=0表示流水线IO,>=1表示移栽IO</param>
public static void IOMove(string ioType, IO_VALUE ioValue,int subType = 0)
{
ConfigIO configIo = GetDO(ioType, subType);
......@@ -91,27 +86,14 @@ namespace OnlineStore.DeviceLibrary
}
else
{
if (LineManager.moveECMap.ContainsKey(subType))
if (LineManager.allConfigMap.ContainsKey(subType))
{
if (LineManager.moveECMap[subType].DIList.ContainsKey(ioType))
if (LineManager.allConfigMap[subType].DIList.ContainsKey(ioType))
{
return LineManager.moveECMap[subType].DIList[ioType];
}
}
if (LineManager.feedingECMap.ContainsKey(subType))
{
if (LineManager.feedingECMap[subType].DIList.ContainsKey(ioType))
{
return LineManager.feedingECMap[subType].DIList[ioType];
}
}
if (LineManager.providingECMap.ContainsKey(subType))
{
if (LineManager.providingECMap[subType].DIList.ContainsKey(ioType))
{
return LineManager.providingECMap[subType].DIList[ioType];
return LineManager.allConfigMap[subType].DIList[ioType];
}
}
}
return configIo;
}
......@@ -127,30 +109,41 @@ namespace OnlineStore.DeviceLibrary
}
else
{
if (LineManager.moveECMap.ContainsKey(subType))
{
if (LineManager.moveECMap[subType].DOList.ContainsKey(ioType))
{
return LineManager.moveECMap[subType].DOList[ioType];
}
}
if (LineManager.feedingECMap.ContainsKey(subType))
{
if (LineManager.feedingECMap[subType].DOList.ContainsKey(ioType))
{
return LineManager.feedingECMap[subType].DOList[ioType];
}
}
if (LineManager.providingECMap.ContainsKey(subType))
if (LineManager.allConfigMap.ContainsKey(subType))
{
if (LineManager.providingECMap[subType].DOList.ContainsKey(ioType))
if (LineManager.allConfigMap[subType].DOList.ContainsKey(ioType))
{
return LineManager.providingECMap[subType].DOList[ioType];
return LineManager.allConfigMap[subType].DOList[ioType];
}
}
}
return configIo;
}
public static void CloseDeviceDO(List<ConfigIO> DoList)
{
foreach (ConfigIO io in DoList)
{
instance.WriteSingleDO(io.DeviceName, io.SlaveID, io.GetIOAddr(), IO_VALUE.LOW);
Thread.Sleep(60);
}
}
public static void CloseDeviceDO(int subType)
{
List<ConfigIO> DoList = new List<ConfigIO>();
if (subType <= 0)
{
DoList = new List<ConfigIO>(LineManager.Config.DOList.Values);
}
else
{
if (LineManager.allConfigMap.ContainsKey(subType))
{
DoList = new List<ConfigIO>(LineManager.allConfigMap[subType].DOList.Values);
}
}
CloseDeviceDO(DoList);
}
#endregion
public static void Init()
{
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!