Commit 02f9b237 LN

io操作按钮调整

1 个父辈 351aea0a
...@@ -90,6 +90,12 @@ ...@@ -90,6 +90,12 @@
<Compile Include="FrmDischargeLine.Designer.cs"> <Compile Include="FrmDischargeLine.Designer.cs">
<DependentUpon>FrmDischargeLine.cs</DependentUpon> <DependentUpon>FrmDischargeLine.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="FrmEquipBase.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FrmEquipBase.Designer.cs">
<DependentUpon>FrmEquipBase.cs</DependentUpon>
</Compile>
<Compile Include="FrmProvidingEquip.cs"> <Compile Include="FrmProvidingEquip.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
......
...@@ -20,11 +20,9 @@ using OnlineStore.Common; ...@@ -20,11 +20,9 @@ using OnlineStore.Common;
namespace OnlineStore.AssemblyLine namespace OnlineStore.AssemblyLine
{ {
public partial class FrmDischargeLine : FrmBase public partial class FrmDischargeLine : FrmEquipBase
{ {
private bool IsLoad = false; private bool IsLoad = false;
private string portName = "";
private short SlvAddr = 0;
private DischargeLine dischargeLine; private DischargeLine dischargeLine;
public static readonly ILog LOGGER = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); public static readonly ILog LOGGER = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public FrmDischargeLine(DischargeLine moveEquip) public FrmDischargeLine(DischargeLine moveEquip)
...@@ -123,11 +121,19 @@ namespace OnlineStore.AssemblyLine ...@@ -123,11 +121,19 @@ namespace OnlineStore.AssemblyLine
LogUtil.error(LOGGER, ex.StackTrace); 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) private void btnWriteSingleDO_Click(object sender, EventArgs e)
{ {
WriteDO(IO_VALUE.LOW);
}
private void WriteDO(IO_VALUE value)
{
string deviceName = txtDoName.Text; string deviceName = txtDoName.Text;
int index = FormUtil.GetIntValue(txtDOIndex); 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 time = FormUtil.GetIntValue(txtWriteTime);
int slaveId = FormUtil.GetIntValue(txtSlaveId); int slaveId = FormUtil.GetIntValue(txtSlaveId);
if (time > 0) if (time > 0)
...@@ -140,6 +146,7 @@ namespace OnlineStore.AssemblyLine ...@@ -140,6 +146,7 @@ namespace OnlineStore.AssemblyLine
} }
} }
private ConfigIO GetSelectDO() private ConfigIO GetSelectDO()
{ {
string text = cmbWriteIO.SelectedValue.ToString(); string text = cmbWriteIO.SelectedValue.ToString();
...@@ -228,15 +235,6 @@ namespace OnlineStore.AssemblyLine ...@@ -228,15 +235,6 @@ 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) public void FormStatus(bool isStart)
{ {
btnStart.Enabled = !isStart; btnStart.Enabled = !isStart;
...@@ -246,15 +244,6 @@ namespace OnlineStore.AssemblyLine ...@@ -246,15 +244,6 @@ namespace OnlineStore.AssemblyLine
btnOutStore.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) private void FrmIOStatus_Shown(object sender, EventArgs e)
...@@ -348,98 +337,31 @@ namespace OnlineStore.AssemblyLine ...@@ -348,98 +337,31 @@ namespace OnlineStore.AssemblyLine
} }
private void btnStop1Up_Click(object sender, EventArgs e) private void btnStop1Up_Click(object sender, EventArgs e)
{ {
if (btnStop1Up.Text.Equals("阻挡气缸1下降")) LogUtil.info("点击【" + btnStop1Up.Text + "】 ");
if (btnStop1Up.Text.Equals("定位气缸上升"))
{ {
dischargeLine.IOMove(IO_Type.StopCylinder_Down1, IO_VALUE.HIGH); dischargeLine.CylinderMove(null, IO_Type.SeparateDevice_Down, IO_Type.SeparateDevice_Up);
btnStop1Up.Text = "阻挡气缸1上升"; btnStop1Up.Text = "定位气缸下降";
btnStop1Up.BackColor = Color.Aqua; btnStop1Up.BackColor = Color.Aqua;
} }
else else
{ {
dischargeLine.IOMove(IO_Type.StopCylinder_Down1, IO_VALUE.LOW); dischargeLine.CylinderMove(null, IO_Type.SeparateDevice_Up, IO_Type.SeparateDevice_Down);
btnStop1Up.Text = "阻挡气缸1下降"; btnStop1Up.Text = "定位气缸上升";
btnStop1Up.BackColor = Color.White; btnStop1Up.BackColor = Color.SkyBlue;
}
}
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;
}
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)
{
if (btnTopUp.Text.Equals("顶升气缸上升"))
{
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) private void btnCloseAll_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("夹料气缸夹紧")) IOManager.CloseDeviceDO(new List<ConfigIO>(dischargeLine.Config.DOList.Values));
foreach (Control con in groupBox5.Controls)
{ {
dischargeLine.CylinderMove(null, IO_Type.ClampCylinder_Tighten, IO_Type.ClampCylinder_Slack); if (con is Button)
btnClampSlack.Text = "夹料气缸放松";
btnClampSlack.BackColor = Color.Aqua;
}
else
{ {
dischargeLine.CylinderMove(null, IO_Type.ClampCylinder_Slack, IO_Type.ClampCylinder_Tighten); con.BackColor = BackColor = Color.White;
btnClampSlack.Text = "夹料气缸夹紧";
btnClampSlack.BackColor = Color.SkyBlue;
} }
} }
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 \ 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();
}
}
}
...@@ -20,7 +20,7 @@ using OnlineStore.Common; ...@@ -20,7 +20,7 @@ using OnlineStore.Common;
namespace OnlineStore.AssemblyLine namespace OnlineStore.AssemblyLine
{ {
public partial class FrmFeedingEquip : FrmBase public partial class FrmFeedingEquip : FrmEquipBase
{ {
private bool IsLoad = false; private bool IsLoad = false;
private string portName = ""; private string portName = "";
...@@ -148,11 +148,19 @@ namespace OnlineStore.AssemblyLine ...@@ -148,11 +148,19 @@ namespace OnlineStore.AssemblyLine
LogUtil.error(LOGGER, ex.StackTrace); 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) private void btnWriteSingleDO_Click(object sender, EventArgs e)
{ {
WriteDO(IO_VALUE.LOW);
}
private void WriteDO(IO_VALUE value)
{
string deviceName = txtDoName.Text; string deviceName = txtDoName.Text;
int index = FormUtil.GetIntValue(txtDOIndex); 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 time = FormUtil.GetIntValue(txtWriteTime);
int slaveId = FormUtil.GetIntValue(txtSlaveId); int slaveId = FormUtil.GetIntValue(txtSlaveId);
if (time > 0) if (time > 0)
...@@ -191,6 +199,7 @@ namespace OnlineStore.AssemblyLine ...@@ -191,6 +199,7 @@ namespace OnlineStore.AssemblyLine
if (selectControl != null) { selectControl.BackColor = Color.White; } if (selectControl != null) { selectControl.BackColor = Color.White; }
newControl.BackColor = Color.SkyBlue; newControl.BackColor = Color.SkyBlue;
selectControl = newControl; selectControl = newControl;
//txtIOInfo.Text = "IP:" + io.DeviceName + " /" + io.GetIOAddr().ToString();
} }
} }
} }
...@@ -271,15 +280,6 @@ namespace OnlineStore.AssemblyLine ...@@ -271,15 +280,6 @@ 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) public void FormStatus(bool isStart)
{ {
btnStart.Enabled = !isStart; btnStart.Enabled = !isStart;
...@@ -288,18 +288,6 @@ namespace OnlineStore.AssemblyLine ...@@ -288,18 +288,6 @@ namespace OnlineStore.AssemblyLine
btnInStore.Enabled = isStart; btnInStore.Enabled = isStart;
btnOutStore.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) private void FrmIOStatus_Shown(object sender, EventArgs e)
{ {
timer1.Start(); timer1.Start();
...@@ -399,96 +387,61 @@ namespace OnlineStore.AssemblyLine ...@@ -399,96 +387,61 @@ namespace OnlineStore.AssemblyLine
feedEquip.Reset(); feedEquip.Reset();
} }
} }
private void btnStop1Up_Click(object sender, EventArgs e)
private void BtnMove(Button btn,string defaultText,string targetText,string ioLowType,string ioHighType)
{ {
if (btnStop1Up.Text.Equals("阻挡气缸1下降")) LogUtil.info("点击【"+ btn.Text + "】 ");
if (btn.Text.Equals(defaultText))
{ {
feedEquip.IOMove(IO_Type.StopCylinder_Down1, IO_VALUE.HIGH); feedEquip.CylinderMove(null, ioLowType, ioHighType);
btnStop1Up.Text = "阻挡气缸1上升"; btn.Text = targetText;
btnStop1Up.BackColor = Color.Aqua; btn.BackColor = Color.Aqua;
} }
else else
{ {
feedEquip.IOMove(IO_Type.StopCylinder_Down1, IO_VALUE.LOW); feedEquip.CylinderMove(null, ioHighType, ioLowType);
btnStop1Up.Text = "阻挡气缸1下降"; btn.Text = defaultText;
btnStop1Up.BackColor = Color.White; btn.BackColor = Color.SkyBlue;
} }
} }
private void btnStop2Up_Click(object sender, EventArgs e) private void btnLocationCylinder_Click(object sender, EventArgs e)
{
if (btnStop2Up.Text.Equals("阻挡气缸2下降"))
{
feedEquip.IOMove(IO_Type.StopCylinder_Down2, IO_VALUE.HIGH);
btnStop2Up.Text = "阻挡气缸2上升";
btnStop2Up.BackColor = Color.Aqua;
}
else
{ {
feedEquip.IOMove(IO_Type.StopCylinder_Down2, IO_VALUE.LOW); BtnMove(btnLocationCylinder, "SL定位气缸上升", "SL定位气缸下降", IO_Type.SL_LocationCylinder_Down, IO_Type.SL_LocationCylinder_Up);
btnStop2Up.Text = "阻挡气缸2下降";
btnStop2Up.BackColor = Color.White;
}
} }
private void btnTopUp_Click(object sender, EventArgs e) private void btnOutTopCylinder_Click(object sender, EventArgs e)
{ {
if (btnTopUp.Text.Equals("顶升气缸上升")) BtnMove(btnOutTopCylinder, "SL出口顶升上升", "SL出口顶升下降", IO_Type.SL_OutTopCylinder_Down, IO_Type.SL_OutTopCylinder_Up);
{
feedEquip.CylinderMove(null, IO_Type.TopCylinder_Down, IO_Type.TopCylinder_UP);
btnTopUp.Text = "顶升气缸下降";
btnTopUp.BackColor = Color.Aqua;
} }
else private void btnFeedSideWay_Click(object sender, EventArgs e)
{ {
feedEquip.CylinderMove(null, IO_Type.TopCylinder_UP, IO_Type.TopCylinder_Down); BtnMove(btnFeedSideWay, "SL上料横移机构上升", "SL上料横移机构下降", IO_Type.SL_FeedSideWay_Down, IO_Type.SL_FeedSideWay_Up);
btnTopUp.Text = "顶升气缸上升";
btnTopUp.BackColor = Color.SkyBlue;
}
} }
private void btnBeforeAfterBefore_Click(object sender, EventArgs e) private void btnFeedCylinder_Click(object sender, EventArgs e)
{
if (btnBeforeAfterBefore.Text.Equals("前后气缸前进"))
{ {
feedEquip.CylinderMove(null, IO_Type.BeforeAfterCylinder_After, IO_Type.BeforeAfterCylinder_Before); BtnMove(btnFeedCylinder, "SL上料气缸放松", "SL上料气缸夹紧", IO_Type.SL_FeedCylinder_Tighten, IO_Type.SL_FeedCylinder_Slack);
btnBeforeAfterBefore.Text = "前后气缸后退";
btnBeforeAfterBefore.BackColor = Color.Aqua;
} }
else private void btnFeedSideWayCylinder_Click(object sender, EventArgs e)
{ {
feedEquip.CylinderMove(null, IO_Type.BeforeAfterCylinder_Before, IO_Type.BeforeAfterCylinder_After); BtnMove(btnFeedSideWayCylinder, "SL上料横移气缸取料", "SL上料横移气缸放料", IO_Type.SL_FeedSideWayCylinder_Emptying, IO_Type.SL_FeedSideWayCylinder_Take);
btnBeforeAfterBefore.Text = "前后气缸前进";
btnBeforeAfterBefore.BackColor = Color.SkyBlue;
} }
} private void btnTrayLocationCylinder_Click(object sender, EventArgs e)
private void btnUpDownUp_Click(object sender, EventArgs e)
{
if (btnUpDownUp.Text.Equals("上下气缸上升"))
{ {
feedEquip.CylinderMove(null, IO_Type.UpDownCylinder_Down, IO_Type.UpDownCylinder_Up); BtnMove(btnTrayLocationCylinder, "SL升降盘定位气缸前进", "SL升降盘定位气缸后退", IO_Type.SL_TrayLocationCylinder_Before, IO_Type.SL_TrayLocationCylinder_After);
btnUpDownUp.Text = "上下气缸下降";
btnUpDownUp.BackColor = Color.Aqua;
} }
else private void btnToroid_TopCylinder_Click(object sender, EventArgs e)
{ {
feedEquip.CylinderMove(null, IO_Type.UpDownCylinder_Up, IO_Type.UpDownCylinder_Down); BtnMove(btnToroid_TopCylinder, "环形线横移顶升上升", "环形线横移顶升下降", IO_Type.Toroid_TopCylinder_Down, IO_Type.Toroid_TopCylinder_Up);
btnUpDownUp.Text = "上下气缸上升";
btnUpDownUp.BackColor = Color.SkyBlue;
}
} }
private void btnClampSlack_Click(object sender, EventArgs e)
{ private void btnFL_TopCylinder_Click(object sender, EventArgs e)
if (btnClampSlack.Text.Equals("夹料气缸夹紧"))
{ {
feedEquip.CylinderMove(null, IO_Type.ClampCylinder_Tighten, IO_Type.ClampCylinder_Slack); BtnMove(btnFL_TopCylinder, "FL顶升上升", "FL顶升下降", IO_Type.FL_TopCylinder_Down, IO_Type.FL_TopCylinder_Up);
btnClampSlack.Text = "夹料气缸放松";
btnClampSlack.BackColor = Color.Aqua;
} }
else private void Toroid_LocationCylinder_Click(object sender, EventArgs e)
{ {
feedEquip.CylinderMove(null, IO_Type.ClampCylinder_Slack, IO_Type.ClampCylinder_Tighten); BtnMove(Toroid_LocationCylinder, "SL升降盘定位气缸前进", "SL升降盘定位气缸后退", IO_Type.Toroid_LocationCylinder_Down, IO_Type.Toroid_LocationCylinder_Up);
btnClampSlack.Text = "夹料气缸夹紧";
btnClampSlack.BackColor = Color.SkyBlue;
}
} }
private void btnOpenAxis_Click(object sender, EventArgs e) private void btnOpenAxis_Click(object sender, EventArgs e)
{ {
...@@ -632,7 +585,14 @@ namespace OnlineStore.AssemblyLine ...@@ -632,7 +585,14 @@ namespace OnlineStore.AssemblyLine
private void btnCloseAll_Click(object sender, EventArgs e) private void btnCloseAll_Click(object sender, EventArgs e)
{ {
IOManager.instance.CloseAllDO(); IOManager.CloseDeviceDO(new List<ConfigIO>(feedEquip.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) private void button3_Click(object sender, EventArgs e)
...@@ -691,6 +651,7 @@ namespace OnlineStore.AssemblyLine ...@@ -691,6 +651,7 @@ namespace OnlineStore.AssemblyLine
} }
} }
} }
} }
......
...@@ -212,6 +212,7 @@ namespace OnlineStore.AssemblyLine ...@@ -212,6 +212,7 @@ namespace OnlineStore.AssemblyLine
this.ShowInTaskbar = false; this.ShowInTaskbar = false;
this.notifyIcon1.Visible = true; this.notifyIcon1.Visible = true;
this.Hide(); this.Hide();
GC.Collect();
} }
private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e) private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
......
...@@ -20,7 +20,7 @@ using OnlineStore.Common; ...@@ -20,7 +20,7 @@ using OnlineStore.Common;
namespace OnlineStore.AssemblyLine namespace OnlineStore.AssemblyLine
{ {
public partial class FrmMoveEquip : FrmBase public partial class FrmMoveEquip : FrmEquipBase
{ {
private bool IsLoad = false; private bool IsLoad = false;
private string portName = ""; private string portName = "";
...@@ -135,11 +135,19 @@ namespace OnlineStore.AssemblyLine ...@@ -135,11 +135,19 @@ namespace OnlineStore.AssemblyLine
LogUtil.error(LOGGER, ex.StackTrace); 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) private void btnWriteSingleDO_Click(object sender, EventArgs e)
{ {
WriteDO(IO_VALUE.LOW);
}
private void WriteDO(IO_VALUE value)
{
string deviceName = txtDoName.Text; string deviceName = txtDoName.Text;
int index = FormUtil.GetIntValue(txtDOIndex); 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 time = FormUtil.GetIntValue(txtWriteTime);
int slaveId = FormUtil.GetIntValue(txtSlaveId); int slaveId = FormUtil.GetIntValue(txtSlaveId);
if (time > 0) if (time > 0)
...@@ -152,6 +160,7 @@ namespace OnlineStore.AssemblyLine ...@@ -152,6 +160,7 @@ namespace OnlineStore.AssemblyLine
} }
} }
private ConfigIO GetSelectDO() private ConfigIO GetSelectDO()
{ {
string text = cmbWriteIO.SelectedValue.ToString(); string text = cmbWriteIO.SelectedValue.ToString();
...@@ -197,10 +206,12 @@ namespace OnlineStore.AssemblyLine ...@@ -197,10 +206,12 @@ namespace OnlineStore.AssemblyLine
comboBox1.SelectedIndex = 0; comboBox1.SelectedIndex = 0;
txtAxisValue.Text = SlvAddr.ToString(); txtAxisValue.Text = SlvAddr.ToString();
btnUpDownUp.Visible = false;
} }
else else
{ {
tabControl1.TabPages.Remove(tabPage2); tabControl1.TabPages.Remove(tabPage2);
btnUpDownUp.Visible = true;
} }
cmbSizeList.Items.Clear(); cmbSizeList.Items.Clear();
...@@ -263,15 +274,6 @@ namespace OnlineStore.AssemblyLine ...@@ -263,15 +274,6 @@ 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) public void FormStatus(bool isStart)
{ {
btnStart.Enabled = !isStart; btnStart.Enabled = !isStart;
...@@ -281,16 +283,6 @@ namespace OnlineStore.AssemblyLine ...@@ -281,16 +283,6 @@ namespace OnlineStore.AssemblyLine
btnOutStore.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) private void FrmIOStatus_Shown(object sender, EventArgs e)
{ {
...@@ -393,94 +385,60 @@ namespace OnlineStore.AssemblyLine ...@@ -393,94 +385,60 @@ namespace OnlineStore.AssemblyLine
} }
private void btnStop1Up_Click(object sender, EventArgs e) private void btnStop1Up_Click(object sender, EventArgs e)
{ {
if (btnStop1Up.Text.Equals("阻挡气缸1下降")) BtnMove(btnStop1Up, "阻挡1下降", "阻挡1上升", IO_Type.StopCylinder_Down1);
{
moveEquip.IOMove(IO_Type.StopCylinder_Down1, IO_VALUE.HIGH);
btnStop1Up.Text = "阻挡气缸1上升";
btnStop1Up.BackColor = Color.Aqua;
} }
else private void btnStop2Up_Click(object sender, EventArgs e)
{ {
moveEquip.IOMove(IO_Type.StopCylinder_Down1, IO_VALUE.LOW); BtnMove(btnStop2Up, "阻挡2下降", "阻挡2上升", IO_Type.StopCylinder_Down2);
btnStop1Up.Text = "阻挡气缸1下降";
btnStop1Up.BackColor = Color.White;
} }
} private void BtnMove(Button btn, string defaultText, string targetText, string ioHighType )
private void btnStop2Up_Click(object sender, EventArgs e)
{ {
if (btnStop2Up.Text.Equals("阻挡气缸2下降")) LogUtil.info("点击【" + btn.Text + "】 ");
if (btn.Text.Equals(defaultText))
{ {
moveEquip.IOMove(IO_Type.StopCylinder_Down2, IO_VALUE.HIGH); moveEquip.IOMove(ioHighType, IO_VALUE.HIGH);
btnStop2Up.Text = "阻挡气缸2上升"; btn.Text = targetText;
btnStop2Up.BackColor = Color.Aqua; btn.BackColor = Color.Aqua;
} }
else else
{ {
moveEquip.IOMove(IO_Type.StopCylinder_Down2, IO_VALUE.LOW); moveEquip.IOMove(ioHighType, IO_VALUE.LOW);
btnStop2Up.Text = "阻挡气缸2下降"; btn.Text = defaultText;
btnStop2Up.BackColor = Color.White; btn.BackColor = Color.White;
} }
} }
private void btnTopUp_Click(object sender, EventArgs e) private void BtnMove(Button btn, string defaultText, string targetText, string ioLowType, string ioHighType)
{ {
if (btnTopUp.Text.Equals("顶升气缸上升")) LogUtil.info("点击【" + btn.Text + "】 ");
if (btn.Text.Equals(defaultText))
{ {
moveEquip.CylinderMove(null, IO_Type.TopCylinder_Down, IO_Type.TopCylinder_UP); moveEquip.CylinderMove(null, ioLowType, ioHighType);
btnTopUp.Text = "顶升气缸下降"; btn.Text = targetText;
btnTopUp.BackColor = Color.Aqua; btn.BackColor = Color.Aqua;
} }
else else
{ {
moveEquip.CylinderMove(null, IO_Type.TopCylinder_UP, IO_Type.TopCylinder_Down); moveEquip.CylinderMove(null, ioHighType, ioLowType);
btnTopUp.Text = "顶升气缸上升"; btn.Text = defaultText;
btnTopUp.BackColor = Color.SkyBlue; btn.BackColor = Color.SkyBlue;
} }
} }
private void btnTopUp_Click(object sender, EventArgs e)
private void btnBeforeAfterBefore_Click(object sender, EventArgs e)
{
if (btnBeforeAfterBefore.Text.Equals("前后气缸前进"))
{ {
moveEquip.CylinderMove(null, IO_Type.BeforeAfterCylinder_After, IO_Type.BeforeAfterCylinder_Before); BtnMove(btnTopUp, "顶升上升", "顶升下降", IO_Type.TopCylinder_Down, IO_Type.TopCylinder_UP);
btnBeforeAfterBefore.Text = "前后气缸后退";
btnBeforeAfterBefore.BackColor = Color.Aqua;
} }
else
private void btnBeforeAfterBefore_Click(object sender, EventArgs e)
{ {
moveEquip.CylinderMove(null, IO_Type.BeforeAfterCylinder_Before, IO_Type.BeforeAfterCylinder_After); BtnMove(btnBeforeAfterBefore, "横移前进", "横移后退", IO_Type.BeforeAfterCylinder_After, IO_Type.BeforeAfterCylinder_Before);
btnBeforeAfterBefore.Text = "前后气缸前进";
btnBeforeAfterBefore.BackColor = Color.SkyBlue;
}
} }
private void btnUpDownUp_Click(object sender, EventArgs e) private void btnUpDownUp_Click(object sender, EventArgs e)
{ {
if (btnUpDownUp.Text.Equals("上下气缸上升")) BtnMove(btnUpDownUp, "升降上升", "升降下降", IO_Type.UpDownCylinder_Down, IO_Type.UpDownCylinder_Up);
{
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;
}
} }
private void btnClampSlack_Click(object sender, EventArgs e) private void btnClampSlack_Click(object sender, EventArgs e)
{ {
if (btnClampSlack.Text.Equals("夹料气缸夹紧")) BtnMove(btnClampSlack, "夹料夹紧", "夹料放松", IO_Type.ClampCylinder_Tighten, IO_Type.ClampCylinder_Slack);
{
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;
}
} }
private void btnOpenAxis_Click(object sender, EventArgs e) private void btnOpenAxis_Click(object sender, EventArgs e)
{ {
...@@ -618,7 +576,14 @@ namespace OnlineStore.AssemblyLine ...@@ -618,7 +576,14 @@ namespace OnlineStore.AssemblyLine
private void btnCloseAll_Click(object sender, EventArgs e) 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) private void button3_Click(object sender, EventArgs e)
......
...@@ -20,11 +20,10 @@ using OnlineStore.Common; ...@@ -20,11 +20,10 @@ using OnlineStore.Common;
namespace OnlineStore.AssemblyLine namespace OnlineStore.AssemblyLine
{ {
public partial class FrmProvidingEquip : FrmBase public partial class FrmProvidingEquip : FrmEquipBase
{ {
private bool IsLoad = false; private bool IsLoad = false;
private string portName = "";
private short SlvAddr = 0;
private ProvidingEquip providingEquip; private ProvidingEquip providingEquip;
public static readonly ILog LOGGER = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); public static readonly ILog LOGGER = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public FrmProvidingEquip(ProvidingEquip moveEquip) public FrmProvidingEquip(ProvidingEquip moveEquip)
...@@ -123,11 +122,19 @@ namespace OnlineStore.AssemblyLine ...@@ -123,11 +122,19 @@ namespace OnlineStore.AssemblyLine
LogUtil.error(LOGGER, ex.StackTrace); 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) private void btnWriteSingleDO_Click(object sender, EventArgs e)
{ {
WriteDO(IO_VALUE.LOW);
}
private void WriteDO(IO_VALUE value)
{
string deviceName = txtDoName.Text; string deviceName = txtDoName.Text;
int index = FormUtil.GetIntValue(txtDOIndex); 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 time = FormUtil.GetIntValue(txtWriteTime);
int slaveId = FormUtil.GetIntValue(txtSlaveId); int slaveId = FormUtil.GetIntValue(txtSlaveId);
if (time > 0) if (time > 0)
...@@ -139,7 +146,6 @@ namespace OnlineStore.AssemblyLine ...@@ -139,7 +146,6 @@ namespace OnlineStore.AssemblyLine
IOManager.instance.WriteSingleDO(deviceName, (byte)slaveId, (ushort)index, (IO_VALUE)value); IOManager.instance.WriteSingleDO(deviceName, (byte)slaveId, (ushort)index, (IO_VALUE)value);
} }
} }
private ConfigIO GetSelectDO() private ConfigIO GetSelectDO()
{ {
string text = cmbWriteIO.SelectedValue.ToString(); string text = cmbWriteIO.SelectedValue.ToString();
...@@ -228,14 +234,6 @@ namespace OnlineStore.AssemblyLine ...@@ -228,14 +234,6 @@ 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) public void FormStatus(bool isStart)
{ {
...@@ -246,17 +244,6 @@ namespace OnlineStore.AssemblyLine ...@@ -246,17 +244,6 @@ namespace OnlineStore.AssemblyLine
btnOutStore.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) private void FrmIOStatus_Shown(object sender, EventArgs e)
{ {
timer1.Start(); timer1.Start();
...@@ -348,100 +335,74 @@ namespace OnlineStore.AssemblyLine ...@@ -348,100 +335,74 @@ namespace OnlineStore.AssemblyLine
} }
private void btnStop1Up_Click(object sender, EventArgs e) private void btnStop1Up_Click(object sender, EventArgs e)
{ {
if (btnStop1Up.Text.Equals("阻挡气缸1下降")) BtnMove(btnStop1Up, "阻挡1下降", "阻挡1上升", IO_Type.StopCylinder_Down1);
{
providingEquip.IOMove(IO_Type.StopCylinder_Down1, IO_VALUE.HIGH);
btnStop1Up.Text = "阻挡气缸1上升";
btnStop1Up.BackColor = Color.Aqua;
} }
else private void btnStop2Up_Click(object sender, EventArgs e)
{ {
providingEquip.IOMove(IO_Type.StopCylinder_Down1, IO_VALUE.LOW); BtnMove(btnStop2Up, "阻挡2下降", "阻挡2上升", IO_Type.StopCylinder_Down2);
btnStop1Up.Text = "阻挡气缸1下降";
btnStop1Up.BackColor = Color.White;
} }
} private void BtnMove(Button btn, string defaultText, string targetText, string ioHighType)
private void btnStop2Up_Click(object sender, EventArgs e)
{ {
if (btnStop2Up.Text.Equals("阻挡气缸2下降")) LogUtil.info("点击【" + btn.Text + "】 ");
if (btn.Text.Equals(defaultText))
{ {
providingEquip.IOMove(IO_Type.StopCylinder_Down2, IO_VALUE.HIGH); providingEquip.IOMove(ioHighType, IO_VALUE.HIGH);
btnStop2Up.Text = "阻挡气缸2上升"; btn.Text = targetText;
btnStop2Up.BackColor = Color.Aqua; btn.BackColor = Color.Aqua;
} }
else else
{ {
providingEquip.IOMove(IO_Type.StopCylinder_Down2, IO_VALUE.LOW); providingEquip.IOMove(ioHighType, IO_VALUE.LOW);
btnStop2Up.Text = "阻挡气缸2下降"; btn.Text = defaultText;
btnStop2Up.BackColor = Color.White; btn.BackColor = Color.White;
} }
} }
private void btnTopUp_Click(object sender, EventArgs e) private void BtnMove(Button btn, string defaultText, string targetText, string ioLowType, string ioHighType)
{ {
if (btnTopUp.Text.Equals("顶升气缸上升")) LogUtil.info("点击【" + btn.Text + "】 ");
if (btn.Text.Equals(defaultText))
{ {
providingEquip.CylinderMove(null, IO_Type.TopCylinder_Down, IO_Type.TopCylinder_UP); providingEquip.CylinderMove(null, ioLowType, ioHighType);
btnTopUp.Text = "顶升气缸下降"; btn.Text = targetText;
btnTopUp.BackColor = Color.Aqua; btn.BackColor = Color.Aqua;
} }
else else
{ {
providingEquip.CylinderMove(null, IO_Type.TopCylinder_UP, IO_Type.TopCylinder_Down); providingEquip.CylinderMove(null, ioHighType, ioLowType);
btnTopUp.Text = "顶升气缸上升"; btn.Text = defaultText;
btnTopUp.BackColor = Color.SkyBlue; btn.BackColor = Color.SkyBlue;
} }
} }
private void btnTopUp_Click(object sender, EventArgs e)
private void btnBeforeAfterBefore_Click(object sender, EventArgs e)
{
if (btnBeforeAfterBefore.Text.Equals("前后气缸前进"))
{ {
providingEquip.CylinderMove(null, IO_Type.BeforeAfterCylinder_After, IO_Type.BeforeAfterCylinder_Before); BtnMove(btnTopUp, "顶升上升", "顶升下降", IO_Type.TopCylinder_Down, IO_Type.TopCylinder_UP);
btnBeforeAfterBefore.Text = "前后气缸后退";
btnBeforeAfterBefore.BackColor = Color.Aqua;
} }
else
private void btnBeforeAfterBefore_Click(object sender, EventArgs e)
{ {
providingEquip.CylinderMove(null, IO_Type.BeforeAfterCylinder_Before, IO_Type.BeforeAfterCylinder_After); BtnMove(btnBeforeAfterBefore, "横移前进", "横移后退", IO_Type.BeforeAfterCylinder_After, IO_Type.BeforeAfterCylinder_Before);
btnBeforeAfterBefore.Text = "前后气缸前进";
btnBeforeAfterBefore.BackColor = Color.SkyBlue;
}
} }
private void btnUpDownUp_Click(object sender, EventArgs e) private void btnUpDownUp_Click(object sender, EventArgs e)
{ {
if (btnUpDownUp.Text.Equals("上下气缸上升")) BtnMove(btnUpDownUp, "升降上升", "升降下降", IO_Type.UpDownCylinder_Down, IO_Type.UpDownCylinder_Up);
{
providingEquip.CylinderMove(null, IO_Type.UpDownCylinder_Down, IO_Type.UpDownCylinder_Up);
btnUpDownUp.Text = "上下气缸下降";
btnUpDownUp.BackColor = Color.Aqua;
} }
else private void btnClampSlack_Click(object sender, EventArgs e)
{ {
providingEquip.CylinderMove(null, IO_Type.UpDownCylinder_Up, IO_Type.UpDownCylinder_Down); BtnMove(btnClampSlack, "夹料夹紧", "夹料放松", IO_Type.ClampCylinder_Tighten, IO_Type.ClampCylinder_Slack);
btnUpDownUp.Text = "上下气缸上升";
btnUpDownUp.BackColor = Color.SkyBlue;
} }
} private void btnCloseAll_Click(object sender, EventArgs e)
private void btnClampSlack_Click(object sender, EventArgs e)
{ {
if (btnClampSlack.Text.Equals("夹料气缸夹紧")) IOManager.CloseDeviceDO(new List<ConfigIO>( providingEquip.Config.DOList.Values));
foreach (Control con in groupBox5.Controls)
{ {
providingEquip.CylinderMove(null, IO_Type.ClampCylinder_Tighten, IO_Type.ClampCylinder_Slack); if (con is Button)
btnClampSlack.Text = "夹料气缸放松";
btnClampSlack.BackColor = Color.Aqua;
}
else
{ {
providingEquip.CylinderMove(null, IO_Type.ClampCylinder_Slack, IO_Type.ClampCylinder_Tighten); con.BackColor = BackColor = Color.White;
btnClampSlack.Text = "夹料气缸夹紧";
btnClampSlack.BackColor = Color.SkyBlue;
} }
} }
private void btnCloseAll_Click(object sender, EventArgs e)
{
IOManager.instance.CloseAllDO();
} }
} }
} }
......
...@@ -71,12 +71,12 @@ ...@@ -71,12 +71,12 @@
<Compile Include="deviceLibrary\IO\AIManager.cs" /> <Compile Include="deviceLibrary\IO\AIManager.cs" />
<Compile Include="deviceLibrary\IO\AIOBOX\AIOBOXManager.cs" /> <Compile Include="deviceLibrary\IO\AIOBOX\AIOBOXManager.cs" />
<Compile Include="deviceLibrary\IO\IOManager.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.cs" />
<Compile Include="assemblyLine\LineBean_Partial.cs" /> <Compile Include="assemblyLine\LineBean_Partial.cs" />
<Compile Include="assemblyLine\MoveEquip.cs" /> <Compile Include="assemblyLine\MoveEquip.cs" />
<Compile Include="assemblyLine\MoveEquip_Partial.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\ACCMDManager.cs" />
<Compile Include="deviceLibrary\PanasonicServo\ACServerManager.cs" /> <Compile Include="deviceLibrary\PanasonicServo\ACServerManager.cs" />
<Compile Include="deviceLibrary\PanasonicServo\ACServerManager_Partial.cs" /> <Compile Include="deviceLibrary\PanasonicServo\ACServerManager_Partial.cs" />
......
...@@ -22,10 +22,9 @@ namespace OnlineStore.DeviceLibrary ...@@ -22,10 +22,9 @@ namespace OnlineStore.DeviceLibrary
public static LineBean Line = null; public static LineBean Line = null;
public static Line_Config Config = 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, StoreConfig> allConfigMap = null;
public static Dictionary<int, DischargeLine_Config> disChargeLineMap = null;
public LineManager() public LineManager()
{ {
} }
...@@ -52,12 +51,18 @@ namespace OnlineStore.DeviceLibrary ...@@ -52,12 +51,18 @@ namespace OnlineStore.DeviceLibrary
{ {
if (!isInit) 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.SubDIList = new Dictionary<int, Dictionary<string, ConfigIO>>();
StoreConfig.SubDOList = new Dictionary<int, Dictionary<string, ConfigIO>>(); StoreConfig.SubDOList = new Dictionary<int, Dictionary<string, ConfigIO>>();
moveECMap = new Dictionary<int, MoveEquip_Config>(); moveECMap = new Dictionary<int, MoveEquip_Config>();
feedingECMap = new Dictionary<int, FeedingEquip_Config>(); feedingECMap = new Dictionary<int, FeedingEquip_Config>();
providingECMap = new Dictionary<int, ProvidingEquip_Config>(); providingECMap = new Dictionary<int, ProvidingEquip_Config>();
disChargeLineMap = new Dictionary<int, DischargeLine_Config>(); disChargeLineMap = new Dictionary<int, DischargeLine_Config>();
allConfigMap = new Dictionary<int, StoreConfig>();
string server = ConfigAppSettings.GetValue(Setting_Init.http_server); string server = ConfigAppSettings.GetValue(Setting_Init.http_server);
if (server.Equals("")) if (server.Equals(""))
{ {
...@@ -81,7 +86,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -81,7 +86,7 @@ namespace OnlineStore.DeviceLibrary
string linefilePath = appPath + ConfigAppSettings.GetValue(Setting_Init.ConfigPath_Line); string linefilePath = appPath + ConfigAppSettings.GetValue(Setting_Init.ConfigPath_Line);
Config = CSVConfigReader.LoadLineConfig(0, CID, StoreType.RC_LINE, linefilePath); Config = CSVConfigReader.LoadLineConfig(0, CID, StoreType.RC_LINE, linefilePath);
allConfigMap.Add(0, Config);
int moveEquipCount = ConfigAppSettings.GetIntValue(Setting_Init.Line_moveEquip_count); int moveEquipCount = ConfigAppSettings.GetIntValue(Setting_Init.Line_moveEquip_count);
string moveEquipConfig = ConfigAppSettings.GetValue(Setting_Init.ConfigPath_MoveEquip); string moveEquipConfig = ConfigAppSettings.GetValue(Setting_Init.ConfigPath_MoveEquip);
for (int i = 1; i <= moveEquipCount; i++) for (int i = 1; i <= moveEquipCount; i++)
...@@ -90,8 +95,9 @@ namespace OnlineStore.DeviceLibrary ...@@ -90,8 +95,9 @@ namespace OnlineStore.DeviceLibrary
string config = appPath + moveEquipConfig.Replace(".csv", "_" + nameStr + ".csv"); 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; int subType = i;
moveConfig.SetIO( subType); moveConfig.SetIO(subType);
moveECMap.Add(i, moveConfig); moveECMap.Add(i, moveConfig);
allConfigMap.Add(subType, moveConfig);
} }
int feedingEquipCount = ConfigAppSettings.GetIntValue(Setting_Init.Line_feedingEquip_count); int feedingEquipCount = ConfigAppSettings.GetIntValue(Setting_Init.Line_feedingEquip_count);
string feedingEquipConfig = ConfigAppSettings.GetValue(Setting_Init.ConfigPath_FeedingEquip); string feedingEquipConfig = ConfigAppSettings.GetValue(Setting_Init.ConfigPath_FeedingEquip);
...@@ -101,8 +107,9 @@ namespace OnlineStore.DeviceLibrary ...@@ -101,8 +107,9 @@ namespace OnlineStore.DeviceLibrary
string config = appPath + feedingEquipConfig.Replace(".csv", "_" + i + ".csv"); string config = appPath + feedingEquipConfig.Replace(".csv", "_" + i + ".csv");
FeedingEquip_Config moveConfig = CSVConfigReader.LoadFeedingConfig(subType, config); FeedingEquip_Config moveConfig = CSVConfigReader.LoadFeedingConfig(subType, config);
moveConfig.SetIO( subType); moveConfig.SetIO(subType);
feedingECMap.Add(i, moveConfig); feedingECMap.Add(subType, moveConfig);
allConfigMap.Add(subType, moveConfig);
} }
int providingEquipCount = ConfigAppSettings.GetIntValue(Setting_Init.Line_providingEquip_count); int providingEquipCount = ConfigAppSettings.GetIntValue(Setting_Init.Line_providingEquip_count);
...@@ -113,8 +120,9 @@ namespace OnlineStore.DeviceLibrary ...@@ -113,8 +120,9 @@ namespace OnlineStore.DeviceLibrary
string config = appPath + providingEquipConfig.Replace(".csv", "_" + i + ".csv"); string config = appPath + providingEquipConfig.Replace(".csv", "_" + i + ".csv");
ProvidingEquip_Config moveConfig = CSVConfigReader.LoadProvidingConfig(subType, config); ProvidingEquip_Config moveConfig = CSVConfigReader.LoadProvidingConfig(subType, config);
moveConfig.SetIO( subType); moveConfig.SetIO(subType);
providingECMap.Add(i, moveConfig); providingECMap.Add(subType, moveConfig);
allConfigMap.Add(subType, moveConfig);
} }
int dislineCount = ConfigAppSettings.GetIntValue(Setting_Init.Line_dischargeLine_count); int dislineCount = ConfigAppSettings.GetIntValue(Setting_Init.Line_dischargeLine_count);
...@@ -126,15 +134,17 @@ namespace OnlineStore.DeviceLibrary ...@@ -126,15 +134,17 @@ namespace OnlineStore.DeviceLibrary
DischargeLine_Config moveConfig = CSVConfigReader.LoadDischargeLineConfig(subType, config); DischargeLine_Config moveConfig = CSVConfigReader.LoadDischargeLineConfig(subType, config);
moveConfig.SetIO(subType); 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, "加载 完成!"); LogUtil.info(LOGGER, "加载 完成!");
return true; return true;
} }
} }
else if(Line != null){ else if (Line != null)
{
return true; return true;
} }
} }
...@@ -144,7 +154,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -144,7 +154,7 @@ namespace OnlineStore.DeviceLibrary
MessageBox.Show(ex.ToString(), "加载配置错误(请检查配置)"); MessageBox.Show(ex.ToString(), "加载配置错误(请检查配置)");
Application.Exit(); Application.Exit();
} }
return false ; return false;
} }
/// <summary> /// <summary>
...@@ -181,7 +191,8 @@ namespace OnlineStore.DeviceLibrary ...@@ -181,7 +191,8 @@ namespace OnlineStore.DeviceLibrary
string moveEquipConfig = ConfigAppSettings.GetValue(Setting_Init.ConfigPath_MoveEquip); string moveEquipConfig = ConfigAppSettings.GetValue(Setting_Init.ConfigPath_MoveEquip);
string configStr = appPath + moveEquipConfig.Replace(".csv", "_" + config.Id.ToString().PadLeft(2,'0') + ".csv"); 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)); bool result = CSVConfigReader.SaveConfig(configStr, config,typeof(MoveEquip_Config));
if (!result) if (!result)
{ {
...@@ -203,7 +214,8 @@ namespace OnlineStore.DeviceLibrary ...@@ -203,7 +214,8 @@ namespace OnlineStore.DeviceLibrary
int id = config.Id - 100; int id = config.Id - 100;
string configStr = appPath + moveEquipConfig.Replace(".csv", "_" + id+ ".csv"); 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)); bool result = CSVConfigReader.SaveConfig(configStr, config,typeof(FeedingEquip_Config));
if (!result) if (!result)
{ {
...@@ -224,7 +236,8 @@ namespace OnlineStore.DeviceLibrary ...@@ -224,7 +236,8 @@ namespace OnlineStore.DeviceLibrary
string moveEquipConfig = ConfigAppSettings.GetValue(Setting_Init.ConfigPath_ProvidingEquip); string moveEquipConfig = ConfigAppSettings.GetValue(Setting_Init.ConfigPath_ProvidingEquip);
int id = config.Id - 200; int id = config.Id - 200;
string configStr = appPath + moveEquipConfig.Replace(".csv", "_" + id + ".csv"); 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)); bool result = CSVConfigReader.SaveConfig(configStr, config,typeof(ProvidingEquip_Config));
if (!result) if (!result)
{ {
...@@ -246,7 +259,8 @@ namespace OnlineStore.DeviceLibrary ...@@ -246,7 +259,8 @@ namespace OnlineStore.DeviceLibrary
string moveEquipConfig = ConfigAppSettings.GetValue(Setting_Init.ConfigPath_DischargeLine); string moveEquipConfig = ConfigAppSettings.GetValue(Setting_Init.ConfigPath_DischargeLine);
int id = config.Id - 300; int id = config.Id - 300;
string configStr = appPath + moveEquipConfig.Replace(".csv", "_" + id + ".csv"); 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)); bool result = CSVConfigReader.SaveConfig(configStr, config, typeof(DischargeLine_Config));
if (!result) if (!result)
{ {
......
...@@ -25,7 +25,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -25,7 +25,7 @@ namespace OnlineStore.DeviceLibrary
this.Config = config; this.Config = config;
IsDebug = config.IsDebug.Equals(1); IsDebug = config.IsDebug.Equals(1);
baseConfig = config; baseConfig = config;
Name = (" " + "_出料皮带线_" + DeviceID % 30 + " ").ToUpper(); Name = (" " + "_出料皮带线_" + DeviceID % 100 + " ").ToUpper();
Init(); Init();
UseAxis = false; UseAxis = false;
MoveInfo = new LineMoveInfo(DeviceID, "出料皮带线-" + DeviceID + "-MoveInfo"); MoveInfo = new LineMoveInfo(DeviceID, "出料皮带线-" + DeviceID + "-MoveInfo");
......
...@@ -23,7 +23,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -23,7 +23,7 @@ namespace OnlineStore.DeviceLibrary
baseConfig = config; baseConfig = config;
this.Config = config; this.Config = config;
IsDebug = config.IsDebug.Equals(1); IsDebug = config.IsDebug.Equals(1);
Name = (" " + "_入料_" + DeviceID % 10 + " ").ToUpper(); Name = (" " + "_入料_" + DeviceID % 100 + " ").ToUpper();
Init(); Init();
MoveInfo = new LineMoveInfo(DeviceID, "入料-" + DeviceID + "-Move"); MoveInfo = new LineMoveInfo(DeviceID, "入料-" + DeviceID + "-Move");
SecondMoveInfo = new LineMoveInfo(DeviceID, "入料-" + DeviceID + "-SecondMove"); SecondMoveInfo = new LineMoveInfo(DeviceID, "入料-" + DeviceID + "-SecondMove");
......
...@@ -25,7 +25,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -25,7 +25,7 @@ namespace OnlineStore.DeviceLibrary
this.Config = config; this.Config = config;
IsDebug = config.IsDebug.Equals(1); IsDebug = config.IsDebug.Equals(1);
baseConfig = config; baseConfig = config;
Name = (" " + "_出料_" + DeviceID % 10 + " ").ToUpper(); Name = (" " + "_出料_" + DeviceID % 100 + " ").ToUpper();
Init(); Init();
UseAxis = false; UseAxis = false;
MoveInfo = new LineMoveInfo(DeviceID, "出料-" + DeviceID + "-MoveInfo"); MoveInfo = new LineMoveInfo(DeviceID, "出料-" + DeviceID + "-MoveInfo");
......
...@@ -293,17 +293,6 @@ namespace OnlineStore.DeviceLibrary ...@@ -293,17 +293,6 @@ namespace OnlineStore.DeviceLibrary
} }
} }
} }
//else
//{
// if (sta == null)
// {
// LogUtil.error("UpdateAllDO ip[" + ip + "], sta=null");
// }
// else
// {
// LogUtil.error(" UpdateAllDO ip[" + ip + "], sta.Length=" + sta.Length);
// }
//}
} }
...@@ -316,9 +305,6 @@ namespace OnlineStore.DeviceLibrary ...@@ -316,9 +305,6 @@ namespace OnlineStore.DeviceLibrary
ushort length = LineManager.Config.GetDOLength(aio.IP); ushort length = LineManager.Config.GetDOLength(aio.IP);
for (ushort i = 0; i < length; i++) 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); aio.WriteDO(i, Box_Sta.Off);
} }
} }
...@@ -347,7 +333,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -347,7 +333,7 @@ namespace OnlineStore.DeviceLibrary
bool result = aioBox.WriteDO(StartAddress, GetBox_Sta(onOff)); bool result = aioBox.WriteDO(StartAddress, GetBox_Sta(onOff));
if (!result) if (!result)
{ {
LogUtil.error("AIO WriteSingleDO [" + StartAddress + "] 第" + i + "次失败:" + aioBox.ErrInfo); LogUtil.error("AIO WriteSingleDO ["+ioIp+"] [" + StartAddress + "] 第" + i + "次失败:" + aioBox.ErrInfo);
} }
else else
{ {
...@@ -362,7 +348,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -362,7 +348,7 @@ namespace OnlineStore.DeviceLibrary
} }
catch (Exception ex) 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) public override void WriteSingleDO(string ioIp, byte slaveId, ushort StartAddress, IO_VALUE onOff, int mSeconds)
...@@ -384,7 +370,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -384,7 +370,7 @@ namespace OnlineStore.DeviceLibrary
try try
{ {
aioBox.WriteDO(StartAddress, aioBox.ReverseStatus(currBox_Sta)); 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) catch (Exception ex)
{ {
...@@ -396,12 +382,12 @@ namespace OnlineStore.DeviceLibrary ...@@ -396,12 +382,12 @@ namespace OnlineStore.DeviceLibrary
} }
else else
{ {
LogUtil.error(LOGGER, "WriteSingleDO出错 没有连接IO模块:" + ioIp); LogUtil.error(LOGGER, "AIO WriteSingleDO [" + ioIp + "] [" + StartAddress + "] 出错 没有连接IO模块:" + ioIp);
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
LogUtil.error("WriteSingleDO 出错:" + ioIp); LogUtil.error("AIO WriteSingleDO [" + ioIp + "] [" + StartAddress + "] 出错:" + ioIp);
} }
} }
public override void ReadAllDI(string ioIp, byte slaveId) public override void ReadAllDI(string ioIp, byte slaveId)
...@@ -417,7 +403,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -417,7 +403,7 @@ namespace OnlineStore.DeviceLibrary
} }
catch (Exception ex) catch (Exception ex)
{ {
LogUtil.error("ReadAllDI出错:" + ioIp); LogUtil.error("ReadAllDI [" + ioIp + "]出错:" + ioIp);
} }
} }
public override void ReadAllDO(string ioIp, byte slaveId) public override void ReadAllDO(string ioIp, byte slaveId)
...@@ -434,7 +420,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -434,7 +420,7 @@ namespace OnlineStore.DeviceLibrary
} }
catch (Exception ex) catch (Exception ex)
{ {
LogUtil.error("ReadAllDO出错:" + ioIp); LogUtil.error("ReadAllDO [" + ioIp + "]出错:" + ioIp);
} }
} }
public override IO_VALUE GetDOValue(string ioIP, byte slaveId, ushort StartAddress) public override IO_VALUE GetDOValue(string ioIP, byte slaveId, ushort StartAddress)
...@@ -463,7 +449,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -463,7 +449,7 @@ namespace OnlineStore.DeviceLibrary
} }
catch (Exception ex) catch (Exception ex)
{ {
LogUtil.error("GetDOValue 出错:" + ex.ToString()); LogUtil.error("GetDOValue [" + ioIP + "] [" + StartAddress + "] 出错:" + ex.ToString());
} }
return value; return value;
} }
...@@ -495,7 +481,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -495,7 +481,7 @@ namespace OnlineStore.DeviceLibrary
} }
catch (Exception ex) catch (Exception ex)
{ {
LogUtil.error("GetDIValue 出错:" + ex.ToString()); LogUtil.error("GetDIValue [" + ioIP + "] [" + StartAddress + "] 出错:" + ex.ToString());
} }
return value; return value;
} }
...@@ -515,15 +501,11 @@ namespace OnlineStore.DeviceLibrary ...@@ -515,15 +501,11 @@ namespace OnlineStore.DeviceLibrary
} }
catch (Exception ex) catch (Exception ex)
{ {
LogUtil.error(LOGGER, " GetIOValue 获取数据出错:" + ex.ToString()); LogUtil.error(LOGGER, " GetIOValue [" + configIO.DeviceName + "] [" + configIO.GetIOAddr() + "] 获取数据出错:" + ex.ToString());
} }
return value; return value;
} }
//private Box_Addr GetAddr(ushort StartAddress)
//{
// return (Box_Addr)(StartAddress);
//}
private Box_Sta GetBox_Sta(IO_VALUE onOff) private Box_Sta GetBox_Sta(IO_VALUE onOff)
{ {
if (onOff.Equals(IO_VALUE.HIGH)) if (onOff.Equals(IO_VALUE.HIGH))
......
...@@ -16,12 +16,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -16,12 +16,7 @@ namespace OnlineStore.DeviceLibrary
#region KNDIO #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) public static void IOMove(string ioType, IO_VALUE ioValue,int subType = 0)
{ {
ConfigIO configIo = GetDO(ioType, subType); ConfigIO configIo = GetDO(ioType, subType);
...@@ -91,27 +86,14 @@ namespace OnlineStore.DeviceLibrary ...@@ -91,27 +86,14 @@ namespace OnlineStore.DeviceLibrary
} }
else else
{ {
if (LineManager.moveECMap.ContainsKey(subType)) if (LineManager.allConfigMap.ContainsKey(subType))
{
if (LineManager.moveECMap[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.allConfigMap[subType].DIList.ContainsKey(ioType))
}
}
if (LineManager.providingECMap.ContainsKey(subType))
{ {
if (LineManager.providingECMap[subType].DIList.ContainsKey(ioType)) return LineManager.allConfigMap[subType].DIList[ioType];
{
return LineManager.providingECMap[subType].DIList[ioType];
} }
} }
} }
return configIo; return configIo;
} }
...@@ -127,29 +109,40 @@ namespace OnlineStore.DeviceLibrary ...@@ -127,29 +109,40 @@ namespace OnlineStore.DeviceLibrary
} }
else else
{ {
if (LineManager.moveECMap.ContainsKey(subType)) if (LineManager.allConfigMap.ContainsKey(subType))
{ {
if (LineManager.moveECMap[subType].DOList.ContainsKey(ioType)) if (LineManager.allConfigMap[subType].DOList.ContainsKey(ioType))
{ {
return LineManager.moveECMap[subType].DOList[ioType]; return LineManager.allConfigMap[subType].DOList[ioType];
} }
} }
if (LineManager.feedingECMap.ContainsKey(subType))
}
return configIo;
}
public static void CloseDeviceDO(List<ConfigIO> DoList)
{ {
if (LineManager.feedingECMap[subType].DOList.ContainsKey(ioType)) foreach (ConfigIO io in DoList)
{ {
return LineManager.feedingECMap[subType].DOList[ioType]; instance.WriteSingleDO(io.DeviceName, io.SlaveID, io.GetIOAddr(), IO_VALUE.LOW);
Thread.Sleep(60);
} }
} }
if (LineManager.providingECMap.ContainsKey(subType)) public static void CloseDeviceDO(int subType)
{ {
if (LineManager.providingECMap[subType].DOList.ContainsKey(ioType)) List<ConfigIO> DoList = new List<ConfigIO>();
if (subType <= 0)
{ {
return LineManager.providingECMap[subType].DOList[ioType]; DoList = new List<ConfigIO>(LineManager.Config.DOList.Values);
} }
else
{
if (LineManager.allConfigMap.ContainsKey(subType))
{
DoList = new List<ConfigIO>(LineManager.allConfigMap[subType].DOList.Values);
} }
} }
return configIo; CloseDeviceDO(DoList);
} }
#endregion #endregion
public static void Init() public static void Init()
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!