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.

112 lines
3.4 KiB
C#

2 years ago
using Rs.Framework;
using Rs.Motion;
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
{
public DebugMove()
{
InitializeComponent();
}
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);
}
Point startPoint;
Point endPoint;
Point curPoint;
bool pressed = false;
private void Move_MouseDown(object sender, MouseEventArgs e)
{
Button btn = (Button)sender;
if (e.Button == MouseButtons.Left)
{
if(chkMoveStep.Checked)
{
//走步长运动
double.TryParse(txtMoveDist.Text, out double moveStep);
ErrorCode errCode = AxisControl.GetAxis(btn.Text.SubLastChar()).MoveOffset(moveStep);
if(errCode> ErrorCode.Ok)
{
MessageQueue.Instance.Warn(errCode.ToString());
}
}
else
{
int dir = btn.Text.GetLastChar() == "+" ? 1 : 0;
ErrorCode errCode = AxisControl.GetAxis(btn.Text.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.Text.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}%";
}
}
}