354 lines
12 KiB
C#
354 lines
12 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;
|
|
using BRS.Common.PubSub;
|
|
using BRS.UI.Model.Winform;
|
|
using System;
|
|
using System.Collections.Concurrent;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Threading;
|
|
using static BRS.Common.Model.Helper.EnumHelper;
|
|
using static BRS.Process.A020.A020Process;
|
|
using BRS.Common.Base;
|
|
|
|
|
|
namespace BRS.Process.A020.UI
|
|
{
|
|
[MenuNode("ControlSet", "控制菜单", 3, "View2", true)]
|
|
//public partial class TriggerCountFrm : MenuFormBase
|
|
|
|
public partial class ControlSet : MenuFormBase
|
|
{
|
|
private bool is_btn_manual { get; set; } = false;
|
|
A020Process ProcessA020 => Process as A020Process;
|
|
A020Config Config => Process?.IConfig as A020Config;
|
|
|
|
private bool isSingleStepOperating = false;
|
|
|
|
public ControlSet()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void btn_start_Click(object sender, EventArgs e)
|
|
{
|
|
//流程正转启动按钮
|
|
|
|
}
|
|
|
|
|
|
private void ControlSet_Load(object sender, EventArgs e)
|
|
{
|
|
//cmb_sizechoose1_1.SelectedIndex = 0;
|
|
//cmb_sizechoose1_2.SelectedIndex = 0;
|
|
//cmb_sizechoose2_1.SelectedIndex = 0;
|
|
//cmb_sizechoose2_2.SelectedIndex = 0;
|
|
|
|
//如果尺寸选择为空,则设置该对应设备无法进行上下料
|
|
btn_load1_1.Enabled = false;
|
|
btn_down1_1.Enabled = false;
|
|
|
|
btn_load1_2.Enabled = false;
|
|
btn_down1_2.Enabled = false;
|
|
|
|
btn_load2_1.Enabled = false;
|
|
btn_down2_1.Enabled = false;
|
|
|
|
btn_load2_2.Enabled = false;
|
|
btn_down2_2.Enabled = false;
|
|
|
|
////初始化字典界面设置
|
|
//MachineInfo temp;
|
|
//temp.isReady = false;
|
|
//temp.location = -1;
|
|
//temp.tireSize = -1;
|
|
//MachineInfos.Add(0, temp); // 使用字典将顺序排好
|
|
//MachineInfos.Add(1, temp);
|
|
//MachineInfos.Add(2, temp);
|
|
//MachineInfos.Add(3, temp);
|
|
|
|
|
|
}
|
|
public void SetMachineInfo(int num,int location)
|
|
{
|
|
MachineInfo temp;
|
|
temp.isReady = false;
|
|
temp.location = -1;
|
|
temp.tyreSize = -1;
|
|
//根据选择设置按钮可用性
|
|
switch (num)
|
|
{
|
|
case 0: //如果选择为空,则对应区域内上下料按钮禁止使用
|
|
temp.isReady = false;
|
|
temp.location = location;
|
|
temp.tyreSize = 0;
|
|
break;
|
|
case 12:
|
|
temp.isReady = true;
|
|
temp.location = location;
|
|
temp.tyreSize = 12;
|
|
break;
|
|
case 13:
|
|
temp.isReady = true;
|
|
temp.location = location;
|
|
temp.tyreSize = 13;
|
|
break;
|
|
case 14:
|
|
temp.isReady = true;
|
|
temp.location = location;
|
|
temp.tyreSize = 14;
|
|
break;
|
|
case 15:
|
|
temp.isReady = true;
|
|
temp.location = location;
|
|
temp.tyreSize = 15;
|
|
break;
|
|
case 16:
|
|
temp.isReady = true;
|
|
temp.location = location;
|
|
temp.tyreSize = 16;
|
|
break;
|
|
case 17:
|
|
temp.isReady = true;
|
|
temp.location = location;
|
|
temp.tyreSize = 17;
|
|
break;
|
|
case 18:
|
|
temp.isReady = true;
|
|
temp.location = location;
|
|
temp.tyreSize = 18;
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
//bool location_exist = false;
|
|
//for (int i = 0; i < MachineInfos.Count(); i++) //遍历查找对应的location进行修改
|
|
//{
|
|
// if (MachineInfos[i].location == location)
|
|
// {
|
|
// MachineInfos[i] = temp;
|
|
// location_exist = true;
|
|
// break; //找到之后停止查询
|
|
// }
|
|
//}
|
|
//if (!location_exist) // 如果不存在则添加
|
|
//{
|
|
// MachineInfos.Add(temp);
|
|
//}
|
|
|
|
//使用字典存放界面的设置
|
|
if (!MachineInfos.ContainsKey(location)) // 如果该位置不存在,则添加进字典
|
|
MachineInfos.Add(location, temp);
|
|
else
|
|
MachineInfos[location] = temp;
|
|
}
|
|
private void cmb_sizechoose1_1_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
Sunny.UI.UIComboBox comboBox = (Sunny.UI.UIComboBox)sender;
|
|
string value = (string)comboBox.SelectedItem;
|
|
int num;
|
|
int.TryParse(value,out num);
|
|
if (0 < num)
|
|
{
|
|
btn_load1_1.Enabled = true;
|
|
btn_down1_1.Enabled = true;
|
|
}
|
|
else
|
|
{
|
|
btn_load1_1.Enabled = false;
|
|
btn_down1_1.Enabled = false;
|
|
}
|
|
SetMachineInfo(num, 0);
|
|
}
|
|
|
|
private void cmb_sizechoose2_1_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
Sunny.UI.UIComboBox comboBox = (Sunny.UI.UIComboBox)sender;
|
|
string value = (string)comboBox.SelectedItem;
|
|
int num;
|
|
int.TryParse(value, out num);
|
|
if (0 < num)
|
|
{
|
|
btn_load2_1.Enabled = true;
|
|
btn_down2_1.Enabled = true;
|
|
}
|
|
else
|
|
{
|
|
btn_load2_1.Enabled = false;
|
|
btn_down2_1.Enabled = false;
|
|
}
|
|
SetMachineInfo(num, 2);
|
|
}
|
|
|
|
private void cmb_sizechoose1_2_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
Sunny.UI.UIComboBox comboBox = (Sunny.UI.UIComboBox)sender;
|
|
string value = (string)comboBox.SelectedItem;
|
|
int num;
|
|
int.TryParse(value, out num);
|
|
if (0 < num)
|
|
{
|
|
btn_load1_2.Enabled = true;
|
|
btn_down1_2.Enabled = true;
|
|
}
|
|
else
|
|
{
|
|
btn_load1_2.Enabled = false;
|
|
btn_down1_2.Enabled = false;
|
|
}
|
|
SetMachineInfo(num, 1);
|
|
|
|
}
|
|
|
|
private void cmb_sizechoose2_2_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
Sunny.UI.UIComboBox comboBox = (Sunny.UI.UIComboBox)sender;
|
|
string value = (string)comboBox.SelectedItem;
|
|
int num;
|
|
int.TryParse(value, out num);
|
|
if (0 < num)
|
|
{
|
|
btn_load2_2.Enabled = true;
|
|
btn_down2_2.Enabled = true;
|
|
}
|
|
else
|
|
{
|
|
btn_load2_2.Enabled = false;
|
|
btn_down2_2.Enabled = false;
|
|
}
|
|
SetMachineInfo(num, 3);
|
|
}
|
|
|
|
private void btn_stop_Click(object sender, EventArgs e)
|
|
{
|
|
//var NbtRobot = A020Process.DeviceCollection.FirstOrDefault(u => u is RobotBase) as RobotBase;
|
|
//NbtRobot.power_off();
|
|
}
|
|
|
|
private void btn_load1_1_Click(object sender, EventArgs e)
|
|
{
|
|
if(!ProcessA020.IsSingleStepOperating)
|
|
{
|
|
ProcessA020.IsSingleStepOperating = true;
|
|
|
|
Dictionary<int, MachineInfo> machineInfos = MachineInfos;//拿到界面上的设置参数
|
|
int Machine1Entrance1TyreSize = 0;
|
|
|
|
foreach (var item in machineInfos)
|
|
{
|
|
if (item.Value.location == 0)
|
|
Machine1Entrance1TyreSize = item.Value.tyreSize;
|
|
}
|
|
//ProcessA020.Machine1Entrance1Up(Machine1Entrance1TyreSize);
|
|
}
|
|
else
|
|
LogAsync(DateTime.Now, LogLevel.Error, $"有未完成的操作。");
|
|
}
|
|
|
|
private void btn_down1_1_Click(object sender, EventArgs e)
|
|
{
|
|
if (!ProcessA020.IsSingleStepOperating)
|
|
{
|
|
ProcessA020.IsSingleStepOperating = true;
|
|
|
|
Dictionary<int, MachineInfo> machineInfos = MachineInfos;//拿到界面上的设置参数
|
|
int Machine1Entrance1TyreSize = 0;
|
|
foreach (var item in machineInfos)
|
|
{
|
|
if (item.Value.location == 0)
|
|
Machine1Entrance1TyreSize = item.Value.tyreSize;
|
|
}
|
|
//ProcessA020.Machine1Entrance1Down(Machine1Entrance1TyreSize);
|
|
}
|
|
else
|
|
LogAsync(DateTime.Now, LogLevel.Error, $"有未完成的操作。");
|
|
}
|
|
|
|
private void btn_down1_2_Click(object sender, EventArgs e)
|
|
{
|
|
if (!ProcessA020.IsSingleStepOperating)
|
|
{
|
|
ProcessA020.IsSingleStepOperating = true;
|
|
|
|
Dictionary<int, MachineInfo> machineInfos = MachineInfos;//拿到界面上的设置参数
|
|
int Machine1Entrance2TyreSize = 0;
|
|
foreach (var item in machineInfos)
|
|
{
|
|
if (item.Value.location == 1)
|
|
Machine1Entrance2TyreSize = item.Value.tyreSize;
|
|
}
|
|
//ProcessA020.Machine1Entrance2Down(Machine1Entrance2TyreSize);
|
|
}
|
|
else
|
|
LogAsync(DateTime.Now, LogLevel.Error, $"有未完成的操作。");
|
|
}
|
|
|
|
private void btn_load1_2_Click(object sender, EventArgs e)
|
|
{
|
|
if (!ProcessA020.IsSingleStepOperating)
|
|
{
|
|
ProcessA020.IsSingleStepOperating = true;
|
|
|
|
Dictionary<int, MachineInfo> machineInfos = MachineInfos;//拿到界面上的设置参数
|
|
int Machine1Entrance2TyreSize = 0;
|
|
|
|
foreach (var item in machineInfos)
|
|
{
|
|
if (item.Value.location == 1)
|
|
Machine1Entrance2TyreSize = item.Value.tyreSize;
|
|
}
|
|
//ProcessA020.Machine1Entrance2Up(Machine1Entrance2TyreSize);
|
|
}
|
|
else
|
|
LogAsync(DateTime.Now, LogLevel.Error, $"有未完成的操作。");
|
|
}
|
|
|
|
private void btn_manual_Click(object sender, EventArgs e)
|
|
{
|
|
btn_manual.FillColor = Color.FromArgb(41, 255, 156);
|
|
btn_manual.FillHoverColor = Color.FromArgb(41, 255, 156);
|
|
|
|
btn_auto.FillColor = Color.FromArgb(80, 160, 255);
|
|
btn_auto.FillHoverColor = Color.FromArgb(80, 160, 255);
|
|
|
|
ProcessA020.Machine1SwitchAutoManual(false);
|
|
}
|
|
private void btn_auto_Click(object sender, EventArgs e)
|
|
{
|
|
btn_auto.FillColor = Color.FromArgb(41, 255, 156);
|
|
btn_auto.FillHoverColor = Color.FromArgb(41, 255, 156);
|
|
|
|
btn_manual.FillColor = Color.FromArgb(80, 160, 255);
|
|
btn_manual.FillHoverColor = Color.FromArgb(80, 160, 255);
|
|
|
|
ProcessA020.Machine1SwitchAutoManual(true);
|
|
}
|
|
|
|
private void uiTableLayoutPanel1_Paint(object sender, PaintEventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void btn_start_MouseDown(object sender, MouseEventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void btn_start_MouseUp(object sender, MouseEventArgs e)
|
|
{
|
|
|
|
}
|
|
}
|
|
}
|
|
|