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.
255 lines
9.1 KiB
C#
255 lines
9.1 KiB
C#
using Rs.Framework;
|
|
using Rs.Motion.Base.Config;
|
|
using Rs.MotionPlat.Commom;
|
|
using Rs.MotionPlat.Flow;
|
|
using Rs.MotionPlat.Flow.SafePosFlow;
|
|
using Rs.MotionPlat.Flow.SubFlow;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Button;
|
|
|
|
namespace Rs.MotionPlat.SysConfig
|
|
{
|
|
public partial class FixtureConfig : BaseForm
|
|
{
|
|
public FixtureConfig()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void Nozzle2Fixture_Click(object sender, EventArgs e)
|
|
{
|
|
TargetPosition targetPosition = new TargetPosition();
|
|
Button btn = (Button)sender;
|
|
if (int.TryParse(btn.Tag.ToString(), out int fixtureIndex))
|
|
{
|
|
if (int.TryParse(btn.Text, out int nozzleIndex))
|
|
{
|
|
targetPosition = NozzleManager.GetNozzleToFixturePos(fixtureIndex, nozzleIndex);
|
|
EButtonType btnType = Msgbox.ShowTipDialog(EButtonType.Ok | EButtonType.Cancel, $"Are you sure to move loadx:{targetPosition.X},loady1:{targetPosition.Y1},loady2:{targetPosition.Y2}");
|
|
//if (targetPosition.X - GlobalVar.FixtureSafePosX > 20)
|
|
//{
|
|
// DischargeModuleGoSafePosFlow.Instance.GoSafePostion(ESafePosSide.PlaceToFixture);
|
|
//}
|
|
if(btnType== EButtonType.Ok)
|
|
{
|
|
GroupAxisMove.XY1Y2MovePos(targetPosition, GlobalVar.WholeSpeed, EGoWhichSide.FixtureSide);
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
private void ReadOut()
|
|
{
|
|
foreach (Control ctol in groupBox15.Controls)
|
|
{
|
|
if (ctol.Tag == null || ctol.Tag.ToString() != "nocheck")
|
|
{
|
|
string ioname = string.Format(ctol.Tag.ToString(), ctol.Text);
|
|
if (Ops.IsOutOn(ioname))
|
|
{
|
|
ctol.BackColor = Color.Lime;
|
|
}
|
|
else
|
|
{
|
|
ctol.BackColor = Color.FromArgb(56, 56, 56);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public void txtSysParam_KeyUp(object sender, KeyEventArgs e)
|
|
{
|
|
if (e.KeyCode == Keys.Enter)
|
|
{
|
|
UpdateSysParam((TextBox)sender);
|
|
}
|
|
}
|
|
|
|
private void Teach_Click(object sender, EventArgs e)
|
|
{
|
|
PositionHelper.Teach(this, sender);
|
|
}
|
|
|
|
private void FixtureConfig_Load(object sender, EventArgs e)
|
|
{
|
|
CheckPermission();
|
|
PositionHelper.BindPosition(groupBox1,"int");
|
|
PositionHelper.BindPosition(groupBox23);
|
|
PositionHelper.BindPosition(groupBox24);
|
|
PositionHelper.BindPosition(groupBox25);
|
|
PositionHelper.BindPosition(groupBox26);
|
|
PositionHelper.BindPosition(groupBox27);
|
|
PositionHelper.BindPosition(groupBox28);
|
|
timer1.Enabled = true;
|
|
}
|
|
|
|
private void Move_Click(object sender, EventArgs e)
|
|
{
|
|
Button btn=(Button)sender;
|
|
string name = "txt" + btn.Name.Replace("btnMove", "");
|
|
Control control = ControlManager.FindControl(groupBox22, name);
|
|
if (control != null)
|
|
{
|
|
string axisname = ((TextBox)control).Tag.ToString();
|
|
double gotoPos = double.Parse(((TextBox)control).Text);
|
|
//DialogResult dr = Msg.ShowQuestion($"Are you sure to move {axisname} to postion at: {gotoPos}");
|
|
EButtonType btnType = Msgbox.ShowTipDialog(EButtonType.Ok | EButtonType.Cancel, $"Are you sure to move {axisname} to postion at: {gotoPos}");
|
|
//if (dr == DialogResult.OK)
|
|
if (btnType == EButtonType.Ok)
|
|
{
|
|
TargetPosition target = new TargetPosition();
|
|
if(axisname.ToLower()=="loadx")
|
|
{
|
|
target.X = gotoPos;
|
|
target.Y1 = GlobalVar.FixtureSideY1;
|
|
target.Y2 = Ops.GetCurPosition(AxisControl.LoadY2);
|
|
GroupAxisMove.XY1Y2MovePos(target, GlobalVar.WholeSpeed, EGoWhichSide.FixtureSide);
|
|
}
|
|
else if(axisname.ToLower()=="loady2")
|
|
{
|
|
target.X = Ops.GetCurPosition(AxisControl.LoadX);
|
|
target.Y1 = GlobalVar.FixtureSideY1;
|
|
target.Y2 = gotoPos;
|
|
GroupAxisMove.XY1Y2MovePos(target, GlobalVar.WholeSpeed, EGoWhichSide.FixtureSide);
|
|
}
|
|
//Motion.ErrorCode errCode = AxisControl.GetAxis(axisname).MovePos(gotoPos, speed);
|
|
//if (errCode > Motion.ErrorCode.Ok)
|
|
//{
|
|
// //Msg.ShowError($"axis {axisname} move fail {errCode}");
|
|
// Msgbox.ShowTipDialog(EButtonType.Ok, $"axis {axisname} move fail {errCode}", "move", true);
|
|
//}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
//PositionHelper.Move2This(this, sender, "", GlobalVar.WholeSpeed);
|
|
}
|
|
|
|
protected void btnIoOut_Click(object sender, EventArgs e)
|
|
{
|
|
Button btn = (Button)sender;
|
|
if (btn.Tag == null || btn.Tag.ToString() != "nocheck")
|
|
{
|
|
if (btn.BackColor == Color.Lime)
|
|
{
|
|
Ops.Off(string.Format(btn.Tag.ToString(), btn.Text));
|
|
}
|
|
else
|
|
{
|
|
Ops.On(string.Format(btn.Tag.ToString(), btn.Text));
|
|
}
|
|
}
|
|
}
|
|
|
|
private void button25_Click(object sender, EventArgs e)
|
|
{
|
|
for(int i=1;i<=6;i++)
|
|
{
|
|
Ops.On($"治具夹{i}");
|
|
}
|
|
}
|
|
|
|
private void button26_Click(object sender, EventArgs e)
|
|
{
|
|
for (int i = 1; i <= 6; i++)
|
|
{
|
|
Ops.Off($"治具夹{i}");
|
|
}
|
|
}
|
|
|
|
private void timer1_Tick(object sender, EventArgs e)
|
|
{
|
|
ReadOut();
|
|
}
|
|
|
|
|
|
protected void btnTake_Click(object sender, EventArgs e)
|
|
{
|
|
int nozzleIndex = 1;
|
|
if (rbtnNozzle1.Checked)
|
|
nozzleIndex = 1;
|
|
if (rbtnNozzle2.Checked)
|
|
nozzleIndex = 2;
|
|
if (rbtnNozzle3.Checked)
|
|
nozzleIndex =3;
|
|
if (rbtnNozzle4.Checked)
|
|
nozzleIndex = 4;
|
|
Task.Run(() => {
|
|
FixtureTakeFlow.Instance.Take(int.Parse(((Button)sender).Tag.ToString()), nozzleIndex,true,false);
|
|
//double curLoadX = Ops.GetCurPosition(AxisControl.LoadX);
|
|
//if (curLoadX - GlobalVar.FixtureSafePosX > 50)
|
|
//{
|
|
// DischargeModuleGoSafePosFlow.Instance.GoSafePostion(ESafePosSide.PlaceToStock);
|
|
//}
|
|
DischargeModuleGoSafePosFlow.Instance.GoSafePostion();
|
|
});
|
|
}
|
|
|
|
protected void btnPlace_Click(object sender, EventArgs e)
|
|
{
|
|
int nozzleIndex = 1;
|
|
if (rbtnNozzle1.Checked)
|
|
nozzleIndex = 1;
|
|
if (rbtnNozzle2.Checked)
|
|
nozzleIndex = 2;
|
|
if (rbtnNozzle3.Checked)
|
|
nozzleIndex = 3;
|
|
if (rbtnNozzle4.Checked)
|
|
nozzleIndex = 4;
|
|
Task.Run(() => {
|
|
FixturePlaceFlow.Instance.Place(int.Parse(((Button)sender).Tag.ToString()), nozzleIndex,true,false);
|
|
//double curLoadX = Ops.GetCurPosition(AxisControl.LoadX);
|
|
//if(curLoadX-GlobalVar.FixtureSafePosX>50)
|
|
//{
|
|
// DischargeModuleGoSafePosFlow.Instance.GoSafePostion(ESafePosSide.PlaceToStock);
|
|
//}
|
|
DischargeModuleGoSafePosFlow.Instance.GoSafePostion();
|
|
});
|
|
}
|
|
|
|
static bool stop = false;
|
|
private void btnStart_Click(object sender, EventArgs e)
|
|
{
|
|
stop = false;
|
|
if(int.TryParse(txtIntervalTime.Text, out int interval))
|
|
{
|
|
Task.Run(() => {
|
|
while (true)
|
|
{
|
|
if (stop)
|
|
break;
|
|
for (int i = 1; i <= 6; i++)
|
|
{
|
|
Ops.On($"治具夹{i}");
|
|
}
|
|
Thread.Sleep(interval);
|
|
for (int i = 1; i <= 6; i++)
|
|
{
|
|
Ops.Off($"治具夹{i}");
|
|
}
|
|
Thread.Sleep(interval);
|
|
}
|
|
});
|
|
}
|
|
|
|
}
|
|
|
|
private void btnEnd_Click(object sender, EventArgs e)
|
|
{
|
|
stop = true;
|
|
}
|
|
}
|
|
}
|