Files
6150-HMI/CowainHmi/ucPressCtrl.cs
2026-01-15 15:06:36 +08:00

171 lines
5.9 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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 ucPressCtrl : UserControl
{
private string pressDBOut = "DB3401";
[Category("PCHMI"), Description("输出DB地址")]
public string PressDBOut
{
get
{
return pressDBOut;
}
set
{
pressDBOut = value;
}
}
private string pressDBIn = "DB3400";
[Category("PCHMI"), Description("输入DB地址")]
public string PressDBIn
{
get
{
return pressDBIn;
}
set
{
pressDBIn = value;
}
}
public ucPressCtrl()
{
InitializeComponent();
}
private void ProgramAdds()
{
this.btnEnable..[0] = $"{PressDBIn}.0.2";
this.btnEnable. = $"{PressDBIn}.0.2";
this.btnRef. = $"{PressDBIn}.4";
this.btnTareForce. = $"{PressDBIn}.4";
this.btnGoHome. = $"{PressDBIn}.4";
this.btnJogDec. = $"{PressDBIn}.4";
this.btnJogAdd. = $"{PressDBIn}.4";
this.btnJogAddSafe. = $"{PressDBIn}.0.6";
this.btnJogDecSafe. = $"{PressDBIn}.0.7";
this.btnRelease..[0] = $"{PressDBIn}.0.0";
this.btnRelease. = $"{PressDBIn}.0.0";
this.. = $"{PressDBOut}.4.2";
this.btnJogSafe..[0] = $"{PressDBIn}.1.0";
this.btnJogSafe. = $"{PressDBIn}.1.0";
this.lblEnable. = $"{PressDBOut}.0.0";
this.lblRef. = $"{PressDBOut}.0.6";
this.. = $"{PressDBOut}.0.7";
this.lblErr. = $"{PressDBOut}.1.1";
this.. = $"{PressDBIn}.8";
this.btnProgChange. = $"{PressDBIn}.4";
this.txtActPrognum. = $"{PressDBOut}.26";
this...[0] = $"{PressDBIn}.0.4";
this.. = $"{PressDBIn}.0.4";
this.btnGoSafe..[0] = $"{PressDBIn}.1.2";
this.btnGoSafe. = $"{PressDBIn}.1.2";
this.btnGoto. = $"{PressDBIn}.4";
this...[0] = $"{PressDBIn}.0.5";
this.. = $"{PressDBIn}.0.5";
this.lblGoSafe. = $"{PressDBIn}.1.1";
}
private void btnJogSafe_MouseDown(object sender, MouseEventArgs e)
{
if (this.btnJogSafe.Value == 0)
{
PCHMI.OPTLOG.WLOG($"手动解除了励星压机1Jog保护可能发生安全事故");
}
}
private void btnJogAdd_MouseDown(object sender, MouseEventArgs e)
{
PCHMI.OPTLOG.WLOG($"手动按下了励星压机1Jog Add");
PCHMI.RT.SET_INT16(0, $"{PressDBIn}.4", 10);
}
private void btnJogAdd_MouseUp(object sender, MouseEventArgs e)
{
PCHMI.RT.SET_INT16(0, $"{PressDBIn}.4", 0);
}
private void btnJogDec_MouseDown(object sender, MouseEventArgs e)
{
PCHMI.OPTLOG.WLOG($"手动解除了励星压机1Jog Dec");
PCHMI.RT.SET_INT16(0, $"{PressDBIn}.4", 11);
}
private void btnJogDec_MouseUp(object sender, MouseEventArgs e)
{
PCHMI.RT.SET_INT16(0, $"{PressDBIn}.4", 0);
}
private void btnRelease_MouseDown(object sender, MouseEventArgs e)
{
if (this.btnRelease.Value == 0)
{
PCHMI.OPTLOG.WLOG($"手动解除了励星压机1控制权");
}
}
private async void btnProgChange_MouseDown(object sender, MouseEventArgs e)
{
PCHMI.OPTLOG.WLOG($"手动按下励星压机1切换程序");
PCHMI.RT.SET_INT16(0, $"{PressDBIn}.4", 0);
await Task.Delay(500);
PCHMI.RT.SET_INT16(0, $"{PressDBIn}.4", 20);
}
private async void btnTareForce_MouseDown(object sender, MouseEventArgs e)
{
PCHMI.OPTLOG.WLOG($"手动按下励星压机1去皮");
PCHMI.RT.SET_INT16(0, $"{PressDBIn}.4", 0);
await Task.Delay(500);
PCHMI.RT.SET_INT16(0, $"{PressDBIn}.4", 40);
}
private async void btnRef_MouseDown(object sender, MouseEventArgs e)
{
PCHMI.OPTLOG.WLOG($"手动按下励星压机1回机械原点");
PCHMI.RT.SET_INT16(0, $"{PressDBIn}.4", 0);
await Task.Delay(500);
PCHMI.RT.SET_INT16(0, $"{PressDBIn}.4", 1);
}
private async void btnGoHome_MouseDown(object sender, MouseEventArgs e)
{
PCHMI.OPTLOG.WLOG($"手动按下励星压机1回程序原点");
PCHMI.RT.SET_INT16(0, $"{PressDBIn}.4", 0);
await Task.Delay(500);
PCHMI.RT.SET_INT16(0, $"{PressDBIn}.4", 2);
}
private async void btnGoto_MouseDown(object sender, MouseEventArgs e)
{
PCHMI.OPTLOG.WLOG($"手动按下励星压机1执行压装按钮程序号{this.txtActPrognum.Value}");
PCHMI.RT.SET_INT16(0, $"{PressDBIn}.4", 0);
await Task.Delay(500);
PCHMI.RT.SET_INT16(0, $"{PressDBIn}.4", 30);
}
private void ucPressCtrl_Load(object sender, EventArgs e)
{
ProgramAdds();
}
}
}