You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
298 lines
8.8 KiB
C#
298 lines
8.8 KiB
C#
using Rs.Framework;
|
|
using Rs.Motion;
|
|
using Rs.Motion.Base;
|
|
using Rs.MotionPlat.Commom;
|
|
using Rs.MotionPlat.Flow;
|
|
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 Rs.MotionPlat
|
|
{
|
|
public partial class DebugMove : BaseFormHeader
|
|
{
|
|
private static DebugMove instance;
|
|
public static DebugMove Instance
|
|
{
|
|
get
|
|
{
|
|
if (instance == null)
|
|
instance = new DebugMove(null);
|
|
return instance;
|
|
}
|
|
}
|
|
public event Action<string> FormCloseEven;
|
|
public DebugMove(Action<string> act)
|
|
{
|
|
InitializeComponent();
|
|
FormCloseEven=act;
|
|
}
|
|
|
|
private void DebugMove_Load(object sender, EventArgs e)
|
|
{
|
|
//获取屏幕的宽度
|
|
int tWidth = Screen.PrimaryScreen.WorkingArea.Width;
|
|
int tHeight = Screen.PrimaryScreen.WorkingArea.Height;
|
|
this.Opacity = 1;
|
|
this.Location = new Point(tWidth - Width, tHeight - Height);
|
|
timer1.Enabled = true;
|
|
HeaderBackgroundColor = Color.FromArgb(192, 0, 192);
|
|
}
|
|
|
|
private void Move_MouseDown(object sender, MouseEventArgs e)
|
|
{
|
|
Button btn = (Button)sender;
|
|
if (e.Button == MouseButtons.Left)
|
|
{
|
|
int dir = btn.Tag.ToString().GetLastChar() == "+" ? 1 : 0;
|
|
if (chkMoveStep.Checked)
|
|
{
|
|
//走步长运动
|
|
double.TryParse(txtMoveDist.Text, out double moveStep);
|
|
ErrorCode errCode = AxisControl.GetAxis(btn.Tag.ToString().SubLastChar()).MoveOffset(dir==1?moveStep:moveStep*-1, tbarSpeed.Value);
|
|
if(errCode> ErrorCode.Ok)
|
|
{
|
|
MessageQueue.Instance.Warn(errCode.ToString());
|
|
}
|
|
}
|
|
else
|
|
{
|
|
ErrorCode errCode = AxisControl.GetAxis(btn.Tag.ToString().SubLastChar()).MoveJog((short)dir, tbarSpeed.Value);
|
|
if (errCode > ErrorCode.Ok)
|
|
{
|
|
MessageQueue.Instance.Warn(errCode.ToString());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private void Move_MouseUp(object sender, MouseEventArgs e)
|
|
{
|
|
Button btn = (Button)sender;
|
|
if (!chkMoveStep.Checked)
|
|
{
|
|
ErrorCode errCode = AxisControl.GetAxis(btn.Tag.ToString().SubLastChar()).Stop();
|
|
if (errCode > ErrorCode.Ok)
|
|
{
|
|
MessageQueue.Instance.Warn(errCode.ToString());
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
protected void CommonMoveDist_Click(object sender, EventArgs e)
|
|
{
|
|
Label lblNum = (Label)sender;
|
|
txtMoveDist.Text = lblNum.Text;
|
|
chkMoveStep.Checked = true;
|
|
}
|
|
|
|
protected void Calc_Click(object sender, EventArgs e)
|
|
{
|
|
chkMoveStep.Checked = true;
|
|
Label lblNum = (Label)sender;
|
|
if (lblNum.Text.ToLower() == "c")
|
|
{
|
|
txtMoveDist.Text = "";
|
|
}
|
|
else
|
|
{
|
|
if (lblNum.Text == ".")
|
|
{
|
|
if (txtMoveDist.Text.IndexOf(".") == -1 && txtMoveDist.Text.Length > 0)
|
|
txtMoveDist.Text += ".";
|
|
}
|
|
else
|
|
{
|
|
txtMoveDist.Text += lblNum.Text;
|
|
}
|
|
}
|
|
}
|
|
|
|
private void tbarSpeed_ValueChanged(object sender, EventArgs e)
|
|
{
|
|
lblSpeed.Text = $"{tbarSpeed.Value}%";
|
|
}
|
|
|
|
double axisCurPotion = 0.0;
|
|
|
|
ErrorCode errcode = ErrorCode.Ok;
|
|
Dictionary<string, TextBox> dicPosText = new Dictionary<string, TextBox>();
|
|
private void timer1_Tick(object sender, EventArgs e)
|
|
{
|
|
List<IAxis> axises = AxisControl.GetAllAxis();
|
|
foreach (IAxis axis in axises)
|
|
{
|
|
if (axis.Config.EnableEncoder == 1)
|
|
{
|
|
errcode = axis.GetPrfPosition(out axisCurPotion);
|
|
|
|
if (errcode > ErrorCode.Ok) return;
|
|
}
|
|
else
|
|
{
|
|
errcode = axis.GetPrfPosition(out axisCurPotion);
|
|
if (errcode > ErrorCode.Ok) return;
|
|
}
|
|
if (dicPosText.ContainsKey(axis.Config.AxisName))
|
|
{
|
|
dicPosText[axis.Config.AxisName].Text = axisCurPotion.ToString("0.000");
|
|
}
|
|
else
|
|
{
|
|
Control txtControl = ControlManager.FindControl(this,$"txt{axis.Config.AxisName}");
|
|
if (txtControl != null && txtControl is TextBox)
|
|
{
|
|
dicPosText.Add(txtControl.Tag.ToString(), (TextBox)txtControl);
|
|
((TextBox)txtControl).Text = axisCurPotion.ToString("0.000");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private void DebugMove_FormClosed(object sender, FormClosedEventArgs e)
|
|
{
|
|
FormCloseEven?.Invoke("DebugMove");
|
|
}
|
|
|
|
private void button59_Click(object sender, EventArgs e)
|
|
{
|
|
for(int i=1;i<=16;i++)
|
|
{
|
|
Ops.On($"测试{i}号穴位真空吸");
|
|
}
|
|
}
|
|
|
|
private void button60_Click(object sender, EventArgs e)
|
|
{
|
|
for (int i = 1; i <= 16; i++)
|
|
{
|
|
Ops.Off($"测试{i}号穴位真空吸");
|
|
}
|
|
}
|
|
|
|
private void btnNozzleXOpen_Click(object sender, EventArgs e)
|
|
{
|
|
for(int i=1;i<=9;i++)
|
|
{
|
|
Ops.On($"{i}号吸嘴真空吸电磁阀");
|
|
}
|
|
}
|
|
|
|
private void btnNozzleXClose_Click(object sender, EventArgs e)
|
|
{
|
|
for (int i = 1; i <= 9; i++)
|
|
{
|
|
Ops.Off($"{i}号吸嘴真空吸电磁阀");
|
|
}
|
|
}
|
|
|
|
private void btnTurnoverVacOpen_Click(object sender, EventArgs e)
|
|
{
|
|
for (int i = 1; i <= 32; i++)
|
|
{
|
|
Ops.On($"周转盘{i}号穴位真空吸");
|
|
}
|
|
}
|
|
|
|
private void btnTurnoverVacClose_Click(object sender, EventArgs e)
|
|
{
|
|
for (int i = 1; i <= 32; i++)
|
|
{
|
|
Ops.Off($"周转盘{i}号穴位真空吸");
|
|
}
|
|
}
|
|
|
|
private void btnNozzlePoOpen_Click(object sender, EventArgs e)
|
|
{
|
|
for (int i = 1; i <= 9; i++)
|
|
{
|
|
Ops.On($"{i}号吸嘴真空破电磁阀");
|
|
}
|
|
}
|
|
|
|
private void btnNozzlePoClose_Click(object sender, EventArgs e)
|
|
{
|
|
for (int i = 1; i <= 9; i++)
|
|
{
|
|
Ops.Off($"{i}号吸嘴真空破电磁阀");
|
|
}
|
|
}
|
|
|
|
private void button64_Click(object sender, EventArgs e)
|
|
{
|
|
for (int i = 1; i <= 32; i++)
|
|
{
|
|
Ops.On($"周转盘{i}号穴位真空破");
|
|
}
|
|
}
|
|
|
|
private void button63_Click(object sender, EventArgs e)
|
|
{
|
|
for (int i = 1; i <= 32; i++)
|
|
{
|
|
Ops.Off($"周转盘{i}号穴位真空破");
|
|
}
|
|
}
|
|
|
|
private void button65_Click(object sender, EventArgs e)
|
|
{
|
|
for (int i = 1; i <= 16; i++)
|
|
{
|
|
Ops.On($"周转{i}号吸嘴真空吸");
|
|
}
|
|
}
|
|
|
|
private void button66_Click(object sender, EventArgs e)
|
|
{
|
|
for (int i = 1; i <= 16; i++)
|
|
{
|
|
Ops.Off($"周转{i}号吸嘴真空吸");
|
|
}
|
|
}
|
|
|
|
private void button67_Click(object sender, EventArgs e)
|
|
{
|
|
for (int i = 1; i <= 16; i++)
|
|
{
|
|
Ops.On($"周转{i}号吸嘴真空破");
|
|
}
|
|
}
|
|
|
|
private void button68_Click(object sender, EventArgs e)
|
|
{
|
|
for (int i = 1; i <= 16; i++)
|
|
{
|
|
Ops.Off($"周转{i}号吸嘴真空破");
|
|
}
|
|
}
|
|
|
|
private void button61_Click(object sender, EventArgs e)
|
|
{
|
|
for (int i = 1; i <= 16; i++)
|
|
{
|
|
Ops.On($"测试{i}号穴位真空破");
|
|
}
|
|
}
|
|
|
|
private void button62_Click(object sender, EventArgs e)
|
|
{
|
|
for (int i = 1; i <= 16; i++)
|
|
{
|
|
Ops.Off($"测试{i}号穴位真空破");
|
|
}
|
|
}
|
|
|
|
public override bool WindowsClose()
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
}
|