Files
6150-HMI/CowainHmi/Cy/Cylinder.cs

207 lines
7.0 KiB
C#
Raw Normal View History

2026-01-15 15:06:36 +08:00
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 CowainHmi
{
public partial class Cylinder : UserControl
{
private string[] cyNameList;
[Category("PCHMI"), Description("气缸名称列表")]
public string[] CyNameList
{
get
{
return this.cyNameList;
}
set
{
this.cyNameList = value;
}
}
private string cyIdAddr = "";
[Category("PCHMI"), Description("气缸编号地址")]
public string CyIdAddr
{
get
{
return cyIdAddr;
}
set
{
cyIdAddr = value;
}
}
private string dataAddr = "";
[Category("PCHMI"), Description("气缸控制DB地址")]
public string DataAddr
{
get
{
return dataAddr;
}
set
{
dataAddr = value;
}
}
private string errAddr = "";
[Category("PCHMI"), Description("气缸错误DB地址")]
public string ErrAddr
{
get
{
return errAddr;
}
set
{
errAddr = value;
}
}
private string paramAddr = "";
[Category("PCHMI"), Description("气缸参数DB地址")]
public string ParamAddr
{
get
{
return paramAddr;
}
set
{
paramAddr = value;
}
}
private int id = 0;
public Cylinder()
{
InitializeComponent();
}
private void CbxCySelect_SelectedIndexChanged(object sender, EventArgs e)
{
//PCHMI.RT.SEND_UINT16(0, CyIdAddr, (ushort)(this.cbxCySelect.SelectedIndex + 1));
SetAddress();
}
private string cyName;
private void SetAddress()
{
id = this.cbxCySelect.SelectedIndex;
cyName = $"SV{(id + 1).ToString("D3")}-气缸{id}";
this.btnToWork..[0] = $"{DataAddr}.{id * 6}.0";
this.btnToWork. = $"{DataAddr}.{id * 6}.0";
this.btnToBase..[0] = $"{DataAddr}.{id * 6}.1";
this.btnToBase. = $"{DataAddr}.{id * 6}.1";
this.btnWorkSafe..[0] = $"{DataAddr}.{id * 6 + 1}.2";
this.btnWorkSafe. = $"{DataAddr}.{id * 6 + 1}.2";
this.btnBaseSafe..[0] = $"{DataAddr}.{id * 6 + 1}.1";
this.btnBaseSafe. = $"{DataAddr}.{id * 6 + 1}.1";
this.btnWorkSensor..[0] = $"{ParamAddr}.{id * 10 + 8}.1";
this.btnWorkSensor. = $"{ParamAddr}.{id * 10 + 8}.1";
this.btnBaseSensor..[0] = $"{ParamAddr}.{id * 10 + 8}.0";
this.btnBaseSensor. = $"{ParamAddr}.{id * 10 + 8}.0";
this.btnWorkUnlock..[0] = $"{DataAddr}.{id * 6}.4";
this.btnWorkUnlock. = $"{DataAddr}.{id * 6}.4";
this.btnBaseUnlock..[0] = $"{DataAddr}.{id * 6}.4";
this.btnBaseUnlock. = $"{DataAddr}.{id * 6}.4";
this.txtWorkDoneTime. = $"{ParamAddr}.{id * 10}";
this.txtBaseDoneTime. = $"{ParamAddr}.{id * 10 + 2}";
this.txtWorkErrTime. = $"{ParamAddr}.{id * 10 + 4}";
this.txtBaseErrTime. = $"{ParamAddr}.{id * 10 + 6}";
this.lblToWork. = $"{DataAddr}.{id * 6 + 4}.0";
this.lblToBase. = $"{DataAddr}.{id * 6 + 4}.1";
this.lblInWork. = $"{DataAddr}.{id * 6 + 4}.2";
this.lblInBase. = $"{DataAddr}.{id * 6 + 4}.3";
this.lblWorkSafe. = $"{DataAddr}.{id * 6 + 1}.0";
this.lblBaseSafe. = $"{DataAddr}.{id * 6 + 0}.7";
this.lblNotWork. = $"{ErrAddr}.{id * 2 + 0}.2";
this.lblNotBase. = $"{ErrAddr}.{id * 2 + 0}.3";
this.lblManWork. = $"{ErrAddr}.{id * 2 + 0}.0";
this.lblManBase. = $"{ErrAddr}.{id * 2 + 0}.1";
}
private void Cylinder_Load(object sender, EventArgs e)
{
id = PCHMI.VL.GET_UINT16(0, CyIdAddr) - 1;//读气缸编号
if (id < 0)
{
PCHMI.RT.SEND_UINT16(0, CyIdAddr, 1);
id = 0;
}
this.cbxCySelect.DataSource = CyNameList;
this.cbxCySelect.SelectedIndex = id;
this.cbxCySelect.SelectedIndexChanged += CbxCySelect_SelectedIndexChanged;
SetAddress();
}
private void btnWorkSafe_MouseDown(object sender, MouseEventArgs e)
{
if (this.btnWorkSafe.Value == 0)
{
PCHMI.OPTLOG.WLOG($"手动解除了气缸去工作位安全保护,气缸名称:{cyName}");
}
}
private void btnBaseSafe_MouseDown(object sender, MouseEventArgs e)
{
if (this.btnBaseSafe.Value == 0)
{
PCHMI.OPTLOG.WLOG($"手动解除了气缸去原位安全保护,气缸名称:{cyName}");
}
}
private void btnBaseSensor_MouseDown(object sender, MouseEventArgs e)
{
if (this.btnBaseSensor.Value == 0)
{
PCHMI.OPTLOG.WLOG($"手动按下了气缸原位屏蔽按钮,气缸名称:{cyName}");
}
else
{
PCHMI.OPTLOG.WLOG($"手动解除了气缸原位屏蔽按钮,气缸名称:{cyName}");
}
}
private void btnWorkSensor_MouseDown(object sender, MouseEventArgs e)
{
if (this.btnWorkSensor.Value == 0)
{
PCHMI.OPTLOG.WLOG($"手动按下了气缸工作位屏蔽按钮,气缸名称:{cyName}");
}
else
{
PCHMI.OPTLOG.WLOG($"手动解除了气缸工作位屏蔽按钮,气缸名称:{cyName}");
}
}
private void btnBaseUnlock_MouseDown(object sender, MouseEventArgs e)
{
if (this.btnBaseUnlock.Value == 0)
{
PCHMI.OPTLOG.WLOG($"清除了气缸去原位手动记忆,气缸名称:{cyName}");
}
}
private void btnWorkUnlock_MouseDown(object sender, MouseEventArgs e)
{
if (this.btnWorkUnlock.Value == 0)
{
PCHMI.OPTLOG.WLOG($"清除了气缸去工作位手动记忆,气缸名称:{cyName}");
}
}
}
}