|
|
|
|
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 Mesnac.Action.ChemicalWeighing.ProjectDebug
|
|
|
|
|
{
|
|
|
|
|
public partial class FrmProjectDebug : Form
|
|
|
|
|
{
|
|
|
|
|
public string FormText = "";
|
|
|
|
|
public string PlcName = "";
|
|
|
|
|
public string PlcValue = "";
|
|
|
|
|
private string ReadGroupName = "DB101_ProjectDebug";
|
|
|
|
|
private string ReadGroupName2 = "DB111";
|
|
|
|
|
public FrmProjectDebug()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
this.StartPosition = FormStartPosition.CenterScreen;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void FrmProjectDebug_Load(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.Text = FormText;
|
|
|
|
|
if (PlcValue.Contains("Off"))
|
|
|
|
|
{
|
|
|
|
|
btn_Open.Enabled = true;
|
|
|
|
|
|
|
|
|
|
btn_Close.Enabled = false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
btn_Open.Enabled = false;
|
|
|
|
|
|
|
|
|
|
btn_Close.Enabled = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btn_Open_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
//获取工程调试器件列表
|
|
|
|
|
foreach (Mesnac.Equips.BaseEquip equip in Equips.Factory.Instance.AllEquips.Values)
|
|
|
|
|
{
|
|
|
|
|
if (equip.Group.ContainsKey(ReadGroupName))
|
|
|
|
|
{
|
|
|
|
|
foreach (Mesnac.Equips.BaseInfo.Data data in equip.Group[ReadGroupName].Data.Values)
|
|
|
|
|
{
|
|
|
|
|
if (data.KeyName.Contains(PlcName))
|
|
|
|
|
{
|
|
|
|
|
var writeResult16 = BasePlcHelper.Instance.PlcWriteByRunName(data.Name, new object[] { 1 });
|
|
|
|
|
if (writeResult16)
|
|
|
|
|
{
|
|
|
|
|
btn_Open.Enabled = false;
|
|
|
|
|
|
|
|
|
|
btn_Close.Enabled = true;
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (equip.Group.ContainsKey(ReadGroupName2))
|
|
|
|
|
{
|
|
|
|
|
foreach (Mesnac.Equips.BaseInfo.Data data in equip.Group[ReadGroupName2].Data.Values)
|
|
|
|
|
{
|
|
|
|
|
if (data.KeyName.Contains(PlcName))
|
|
|
|
|
{
|
|
|
|
|
var writeResult16 = BasePlcHelper.Instance.PlcWriteByRunName(data.Name, new object[] { 1 });
|
|
|
|
|
if (writeResult16)
|
|
|
|
|
{
|
|
|
|
|
btn_Open.Enabled = false;
|
|
|
|
|
|
|
|
|
|
btn_Close.Enabled = true;
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btn_Close_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
//获取工程调试器件列表
|
|
|
|
|
foreach (Mesnac.Equips.BaseEquip equip in Equips.Factory.Instance.AllEquips.Values)
|
|
|
|
|
{
|
|
|
|
|
if (equip.Group.ContainsKey(ReadGroupName))
|
|
|
|
|
{
|
|
|
|
|
foreach (Mesnac.Equips.BaseInfo.Data data in equip.Group[ReadGroupName].Data.Values)
|
|
|
|
|
{
|
|
|
|
|
if (data.KeyName.Contains(PlcName))
|
|
|
|
|
{
|
|
|
|
|
var writeResult16 = BasePlcHelper.Instance.PlcWriteByRunName(data.Name, new object[] { 0 });
|
|
|
|
|
if (writeResult16)
|
|
|
|
|
{
|
|
|
|
|
btn_Open.Enabled = true;
|
|
|
|
|
|
|
|
|
|
btn_Close.Enabled = false;
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (equip.Group.ContainsKey(ReadGroupName2))
|
|
|
|
|
{
|
|
|
|
|
foreach (Mesnac.Equips.BaseInfo.Data data in equip.Group[ReadGroupName2].Data.Values)
|
|
|
|
|
{
|
|
|
|
|
if (data.KeyName.Contains(PlcName))
|
|
|
|
|
{
|
|
|
|
|
var writeResult16 = BasePlcHelper.Instance.PlcWriteByRunName(data.Name, new object[] { 0 });
|
|
|
|
|
if (writeResult16)
|
|
|
|
|
{
|
|
|
|
|
btn_Open.Enabled = true;
|
|
|
|
|
|
|
|
|
|
btn_Close.Enabled = false;
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|