179 lines
6.0 KiB
C#
179 lines
6.0 KiB
C#
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 SLC1_N
|
|
{
|
|
public partial class Form_PLCcontrol : Form
|
|
{
|
|
public delegate void MySignalHandler(int msg, bool mode); // 声明信号
|
|
public event MySignalHandler Signal_PLC_WriteCoil;
|
|
|
|
public Form_PLCcontrol()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void Form_PLCcontrol_Load(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
// CH1 滑轨伸出
|
|
private void bt_M1020_MouseDown(object sender, MouseEventArgs e)
|
|
{
|
|
bt_M1020.BackColor = Color.DodgerBlue;
|
|
bt_M1020.ForeColor = Color.White;
|
|
Signal_PLC_WriteCoil?.Invoke(1020, true);
|
|
}
|
|
private void bt_M1020_MouseUp(object sender, MouseEventArgs e)
|
|
{
|
|
bt_M1020.BackColor = Color.LightGray;
|
|
bt_M1020.ForeColor = Color.Black;
|
|
Signal_PLC_WriteCoil?.Invoke(1020, false);
|
|
}
|
|
// CH1 滑轨缩回
|
|
private void bt_M1021_MouseDown(object sender, MouseEventArgs e)
|
|
{
|
|
bt_M1021.BackColor = Color.DodgerBlue;
|
|
bt_M1021.ForeColor = Color.White;
|
|
Signal_PLC_WriteCoil?.Invoke(1021, true);
|
|
}
|
|
private void bt_M1021_MouseUp(object sender, MouseEventArgs e)
|
|
{
|
|
bt_M1021.BackColor = Color.LightGray;
|
|
bt_M1021.ForeColor = Color.Black;
|
|
Signal_PLC_WriteCoil?.Invoke(1021, false);
|
|
}
|
|
// CH1 气缸下压/上升
|
|
private void bt_M1022_down_Click(object sender, EventArgs e)
|
|
{
|
|
Signal_PLC_WriteCoil?.Invoke(1022, true);
|
|
}
|
|
private void bt_M1022_up_Click(object sender, EventArgs e)
|
|
{
|
|
Signal_PLC_WriteCoil?.Invoke(1022, false);
|
|
}
|
|
|
|
// CH2 滑轨伸出
|
|
private void bt_M1023_MouseDown(object sender, MouseEventArgs e)
|
|
{
|
|
bt_M1023.BackColor = Color.DodgerBlue;
|
|
bt_M1023.ForeColor = Color.White;
|
|
Signal_PLC_WriteCoil?.Invoke(1023, true);
|
|
}
|
|
private void bt_M1023_MouseUp(object sender, MouseEventArgs e)
|
|
{
|
|
bt_M1023.BackColor = Color.LightGray;
|
|
bt_M1023.ForeColor = Color.Black;
|
|
Signal_PLC_WriteCoil?.Invoke(1023, false);
|
|
}
|
|
// CH2 滑轨缩回
|
|
private void bt_M1024_MouseDown(object sender, MouseEventArgs e)
|
|
{
|
|
bt_M1024.BackColor = Color.DodgerBlue;
|
|
bt_M1024.ForeColor = Color.White;
|
|
Signal_PLC_WriteCoil?.Invoke(1024, true);
|
|
}
|
|
private void bt_M1024_MouseUp(object sender, MouseEventArgs e)
|
|
{
|
|
bt_M1024.BackColor = Color.LightGray;
|
|
bt_M1024.ForeColor = Color.Black;
|
|
Signal_PLC_WriteCoil?.Invoke(1024, false);
|
|
}
|
|
// CH2 气缸下压/上升
|
|
private void bt_M1025_down_Click(object sender, EventArgs e)
|
|
{
|
|
Signal_PLC_WriteCoil?.Invoke(1025, true);
|
|
}
|
|
private void bt_M1025_up_Click(object sender, EventArgs e)
|
|
{
|
|
Signal_PLC_WriteCoil?.Invoke(1025, false);
|
|
}
|
|
|
|
// CH3 滑轨伸出
|
|
private void bt_M1026_MouseDown(object sender, MouseEventArgs e)
|
|
{
|
|
bt_M1026.BackColor = Color.DodgerBlue;
|
|
bt_M1026.ForeColor = Color.White;
|
|
Signal_PLC_WriteCoil?.Invoke(1026, true);
|
|
}
|
|
private void bt_M1026_MouseUp(object sender, MouseEventArgs e)
|
|
{
|
|
bt_M1026.BackColor = Color.LightGray;
|
|
bt_M1026.ForeColor = Color.Black;
|
|
Signal_PLC_WriteCoil?.Invoke(1026, false);
|
|
}
|
|
// CH3 滑轨缩回
|
|
private void bt_M1027_MouseDown(object sender, MouseEventArgs e)
|
|
{
|
|
bt_M1027.BackColor = Color.DodgerBlue;
|
|
bt_M1027.ForeColor = Color.White;
|
|
Signal_PLC_WriteCoil?.Invoke(1027, true);
|
|
}
|
|
private void bt_M1027_MouseUp(object sender, MouseEventArgs e)
|
|
{
|
|
bt_M1027.BackColor = Color.LightGray;
|
|
bt_M1027.ForeColor = Color.Black;
|
|
Signal_PLC_WriteCoil?.Invoke(1027, false);
|
|
}
|
|
// CH3 气缸下压/上升
|
|
private void bt_M1028_down_Click(object sender, EventArgs e)
|
|
{
|
|
Signal_PLC_WriteCoil?.Invoke(1028, true);
|
|
}
|
|
private void bt_M1028_up_Click(object sender, EventArgs e)
|
|
{
|
|
Signal_PLC_WriteCoil?.Invoke(1028, false);
|
|
}
|
|
|
|
// CH4 滑轨伸出
|
|
private void bt_M1029_MouseDown(object sender, MouseEventArgs e)
|
|
{
|
|
bt_M1029.BackColor = Color.DodgerBlue;
|
|
bt_M1029.ForeColor = Color.White;
|
|
Signal_PLC_WriteCoil?.Invoke(1029, true);
|
|
}
|
|
private void bt_M1029_MouseUp(object sender, MouseEventArgs e)
|
|
{
|
|
bt_M1029.BackColor = Color.LightGray;
|
|
bt_M1029.ForeColor = Color.Black;
|
|
Signal_PLC_WriteCoil?.Invoke(1029, false);
|
|
}
|
|
// CH4 滑轨缩回
|
|
private void bt_M1030_MouseDown(object sender, MouseEventArgs e)
|
|
{
|
|
bt_M1030.BackColor = Color.DodgerBlue;
|
|
bt_M1030.ForeColor = Color.White;
|
|
Signal_PLC_WriteCoil?.Invoke(1030, true);
|
|
}
|
|
private void bt_M1030_MouseUp(object sender, MouseEventArgs e)
|
|
{
|
|
bt_M1030.BackColor = Color.LightGray;
|
|
bt_M1030.ForeColor = Color.Black;
|
|
Signal_PLC_WriteCoil?.Invoke(1030, false);
|
|
}
|
|
// CH4 气缸下压/上升
|
|
private void bt_M1031_down_Click(object sender, EventArgs e)
|
|
{
|
|
Signal_PLC_WriteCoil?.Invoke(1031, true);
|
|
}
|
|
private void bt_M1031_up_Click(object sender, EventArgs e)
|
|
{
|
|
Signal_PLC_WriteCoil?.Invoke(1031, false);
|
|
}
|
|
|
|
// 窗口关闭
|
|
private void Form_PLCcontrol_FormClosing(object sender, FormClosingEventArgs e)
|
|
{
|
|
Signal_PLC_WriteCoil = null;
|
|
}
|
|
}
|
|
}
|