using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ocean;
using demo.ClassHelper.MsgBox;
namespace demo.UI
{
public partial class FormMove : Form
{
#region 全局变量
private bool _b2nd = false; //是否为二代机
//轴关联 一代机
public static int _upx = 51001; //上下料x轴
public static int _upy = 51003; //上下料Y2轴
public static int _upy1 = 51002; //上下料Y1轴
public static int _upz = 51004; //上下料Z轴
public static int _carryx = 51005; //搬运x轴
public static int _feedz1 = 51006; //OK仓顶升
public static int _feedz2 = 51007; //进料仓顶升
public static int _feedz3 = 51008; //空料仓顶升
//二代机增加
public static int _ccdx = 52001; //治具相机x轴
public static int _ccdz = 52002; //治具相机z轴
public static int _upz2 = 52004; //上下料Z2轴
public static int _upz3 = 52005; //上下料Z3轴
public static int _upz4 = 52006; //上下料Z4轴
public static int language = 0;//语言选择
//速度设置
private int _curvel = 0; //当前速度选择
private double[] _vel = { 4, 10, 30 };
private double[] _acc = { 2, 5, 20 };
private double[] _dec = { 10, 20, 30 };
#endregion 全局变量
public FormMove()
{
InitializeComponent();
}
private void set1st()
{//设置为一代机
if (!_b2nd) return;
_ccdx = 0;
_ccdz = 0;
_upz2 = 0;
_upz3 = 0;
_upz4 = 0;
_upx = 51001; //上下料x轴
_upy = 51003; //上下料Y2轴
_upy1 = 51002; //上下料Y1轴
_upz = 51004; //上下料Z1轴
_carryx = 51005; //搬运x轴
_feedz1 = 51006; //OK仓顶升
_feedz2 = 51007; //进料仓顶升
_feedz3 = 51008; //空料仓顶升
}
private void set2nd()
{//设置为二代机
if (_b2nd) return;
_upx = 51001; //上下料x轴
_upy = 51003; //上下料Y2轴
_upy1 = 51002; //上下料Y1轴
_upz = 52003; //上下料Z1轴
_upz2 = 52004; //上下料Z2轴
_upz3 = 52005; //上下料Z2轴
_upz4 = 52006; //上下料Z4轴
_carryx = 51004; //搬运x轴
_feedz1 = 51005; //OK仓顶升
_feedz2 = 51006; //进料仓顶升
_feedz3 = 51007; //空料仓顶升
_ccdx = 52001;
_ccdz = 52002;
}
public bool B2nd
{//是否为二代机
get { return _b2nd; }
set { if (value) set2nd(); else set1st(); _b2nd = value; }
}
#region 点位坐标
public string UpxPos
{
get { return labelx1Pos.Text; }
//set { labelx1Pos.Text = value; }
}
public string UpyPos
{
get { return labelyPos.Text; }
//set { labelyPos.Text = value; }
}
public string UpzPos
{
get { return labelzPos.Text; }
//set { labelzPos.Text = value; }
}
public string Upy1Pos
{
get { return labelx2Pos.Text; }
//set { labelx2Pos.Text = value; }
}
public string CarryPos
{
get { return labelhPos.Text; }
//set { labelhPos.Text = value; }
}
public string FeedOkPos
{
get { return labelf1Pos.Text; }
//set { labelf1Pos.Text = value; }
}
public string FeedInputPos
{
get { return labelf2Pos.Text; }
//set { labelf2Pos.Text = value; }
}
public string FeedNullPos
{
get { return labelf3Pos.Text; }
//set { labelf3Pos.Text = value; }
}
public string Upz2Pos
{
get { return labelzPos2.Text; }
//set { labelzPos2.Text = value; }
}
public string Upz3Pos
{
get { return labelzPos3.Text; }
//set { labelzPos3.Text = value; }
}
public string Upz4Pos
{
get { return labelzPos4.Text; }
//set { labelzPos4.Text = value; }
}
public string CxPos
{
get { return labelcxPos.Text; }
//set { labelcxPos.Text = value; }
}
public string CzPos
{
get { return labelczPos.Text; }
//set { labelczPos.Text = value; }
}
#endregion
#region 连动,寸动
///
/// 检测Z轴安全
///
/// true 安全,false 不安全
public bool check_in_pos(int axis, double pos)
{//检查某个轴在此位置
int status = control.get_dev_status(axis);
if ((int)ocean.EDevStatus.EMove_NOHOME == status)// 未回原
{
MsgBoxHelper.ShowTips("Z轴未回原,请先回原!");//Z轴未回原,请先回原!please return to the original position first!
return false;
}
if ((int)ocean.EDevStatus.EMove_ISMOVING == status || (int)ocean.EDevStatus.EMove_ISHOME == status)// 运动中 / 回原中
{
MsgBoxHelper.ShowTips("Z轴正在运动,请等待Z轴运动停止!");//Z轴正在运动,请等待Z轴运动停止!please wait for Z-axis to stop!
return false;
}
pos -= control.getAxisPos(axis);
return pos < 0.01 && pos > -0.01;
}
public bool check_up_pos(int axis, double pos)
{//检查某个轴位置是否大于等于预定值
int status = control.get_dev_status(axis);
if ((int)ocean.EDevStatus.EMove_NOHOME == status)// 未回原
{
MsgBoxHelper.ShowTips("Z轴未回原,请先回原!");//Z轴未回原,请先回原!please return to the original position first!
return false;
}
if ((int)ocean.EDevStatus.EMove_ISMOVING == status || (int)ocean.EDevStatus.EMove_ISHOME == status)// 运动中 / 回原中
{
MsgBoxHelper.ShowTips("Z轴正在运动,请等待Z轴运动停止!");//Z轴正在运动,请等待Z轴运动停止!please wait for Z-axis to stop!
return false;
}
pos -= control.getAxisPos(axis);
if (pos < -0.1)
{//no safe
MsgBoxHelper.ShowTips("Z轴不在安全位");//Z轴不在安全位 please take Z-axis to safe pos!
return false;
}
return true;
}
public bool check_z_safety2()//检测Z轴安全
{//检测是否在安全位
double v2z = var.getdouble("v2z");
double v3z = var.getdouble("v3z");
double v4z = var.getdouble("v4z");
double safez = var.getdouble("safez");
//z轴往下是增加
if (!check_up_pos(_upz, safez)) return false;
if (!check_up_pos(_upz2, safez + v2z)) return false;
if (!check_up_pos(_upz3, safez + v3z)) return false;
if (!check_up_pos(_upz4, safez + v4z)) return false;
return true;
}
public bool check_z_safety()//检测Z轴安全
{
double safez = 0;
if (_b2nd) return check_z_safety2();
safez = var.getdouble("safez");//Z轴安全高度
if (!check_up_pos(_upz, safez)) return false;
control.write("吸料上下气缸1", 0);
control.write("吸料上下气缸2", 0);
control.write("吸料上下气缸3", 0);
control.write("吸料上下气缸4", 0);
return true;
}
///
/// 检测X轴安全
///
/// true 安全,false 不安全
public bool chace_x_safety()//检测X轴安全
{
int ret = 0;
double m_bpos = 0;
int m_status = 0;
TPoint m_point = new TPoint();
//if (_b2nd) return true; //二代机暂时不检测
control.axis_get_pos(_upx, ref m_bpos);//X轴当前位置
m_status = control.get_dev_status(_upx);//对象状态
ret = control.get_point(1, "换料仓位", ref m_point);
if ((int)ocean.EDevStatus.EMove_ISMOVING == m_status || (int)ocean.EDevStatus.EMove_ISHOME == m_status)// 运动中 / 回原中
{
MsgBoxHelper.ShowTips("X轴正在运动,请等待X轴运动停止!");//X轴正在运动,请等待X轴运动停止!X-axis is moving, please wait for X-axis to stop!
return false;
}
if (0 != ret) //点位获取失败
{
MsgBoxHelper.ShowTips("X轴-上料工站-换料仓位,点位获取失败!");//上料工站-换料仓位,点位获取失败!X-axis point acquisition failed!
return false;
}
if (Math.Abs(m_point.x - m_bpos) > 1.1) //相差超过1mm
{
MsgBoxHelper.ShowTips("X轴不在安全区域(换料仓位),请运行到安全区域!");//X轴不在安全区域(换料仓位),请运行到安全区域!X-axis is not in the safe area (Avoidance point), please run to the safe area!
return false;
}
return true;
}
///
/// 检测H轴安全
///
/// true 安全,false 不安全
public bool chace_h_safety()//检测H轴安全
{
int m_status = 0;
if (_b2nd) return true; //二代机暂时不检测
m_status = control.get_dev_status(_carryx);//对象状态
if ((int)ocean.EDevStatus.EMove_ISMOVING == m_status || (int)ocean.EDevStatus.EMove_ISHOME == m_status)// 运动中 / 回原中
{
MsgBoxHelper.ShowTips("H-Axis is moving, please wait for H-axis to stop!");//H轴正在运动,请等待H轴运动停止!
return false;
}
if (0 == control.axis_read(_carryx, EIOType.IOT_HOME)) //不在原点
{
MsgBoxHelper.ShowTips("H-Axis is not in the origin area, please run to the origin area!");//H轴不在原点区域,请运行到安全区域!
return false;
}
return true;
}
public bool chace_in_tray()//检测在料盘侧 true 在,false 不在
{
string strmsg = "";
double m_bpos = 0;
if (_b2nd) return true; //二代机暂时不检测
if (1 == language) { strmsg = "把吸嘴移到料盘侧 Y1>10 ,当前 Y1 = "; }//中文
else { strmsg = "把吸嘴移到料盘侧-英语"; }//英语 或其他的
control.axis_get_pos(_upy1, ref m_bpos, 0);//Y1轴当前位置
if (m_bpos < 10)
{
MessageBox.Show(strmsg + m_bpos.ToString());
return false;
}
control.axis_get_pos(_upy, ref m_bpos, 0);//Y1轴当前位置
if (1 == language) { strmsg = "把吸嘴移到料盘侧 Y2>180 ,当前 Y2 = "; }//中文
else { strmsg = "把吸嘴移到料盘侧-英语"; }//英语 或其他的
if (m_bpos < 180)
{
MessageBox.Show(strmsg + m_bpos.ToString());
return false;
}
control.axis_get_pos(_upx, ref m_bpos, 0);//Y1轴当前位置
if (1 == language) { strmsg = "把吸嘴移到料盘侧 X<850 ,当前 X = "; }//中文
else { strmsg = "把吸嘴移到料盘侧-英语"; }//英语 或其他的
if (m_bpos > 850)
{
MessageBox.Show(strmsg + m_bpos.ToString());
return false;
}
return true;
}
private void checkBoxStep_CheckedChanged(object sender, EventArgs e)
{//寸动模式
nud_step.Enabled = checkBoxStep.Checked;
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{//当前速度
_curvel = combox_spd.SelectedIndex;
DownSpeed();
}
private void button5_MouseDown(object sender, MouseEventArgs e)
{
if (checkBoxStep.Checked == false) //连动
{
if (false == check_z_safety()) { return; }
DownSpeed();
control.axis_move_jog(_upx, 0);
}
else //寸动
{
control.axis_move_offset(_upx, -Convert.ToDouble(nud_step.Value));
}
}
private void button5_MouseUp(object sender, MouseEventArgs e)
{
if (checkBoxStep.Checked == false) //连动
{
control.axis_stop(_upx);
}
}
private void button8_MouseDown(object sender, MouseEventArgs e)
{
if (checkBoxStep.Checked == false) //连动
{
if (false == check_z_safety()) { return; }
if (false == chace_h_safety()) { return; }
DownSpeed();
control.axis_move_jog(_upx, 1);
}
else //寸动
{
control.axis_move_offset(_upx, Convert.ToDouble(nud_step.Value));
}
}
private void button6_MouseDown(object sender, MouseEventArgs e)
{
if (checkBoxStep.Checked == false) //连动
{
if (false == check_z_safety()) { return; }
if (false == chace_h_safety()) { return; }
DownSpeed();
control.axis_move_jog(_upy1, 1);
}
else //寸动
{
control.axis_move_offset(_upy1, Convert.ToDouble(nud_step.Value));
}
}
private void button6_MouseUp(object sender, MouseEventArgs e)
{
if (checkBoxStep.Checked == false) //连动
{
control.axis_stop(_upy1);
}
}
private void button7_MouseDown(object sender, MouseEventArgs e)
{
if (checkBoxStep.Checked == false) //连动
{
if (false == check_z_safety()) { return; }
DownSpeed();
control.axis_move_jog(_upy1, 0);
}
else //寸动
{
control.axis_move_offset(_upy1, -Convert.ToDouble(nud_step.Value));
}
}
private void button10_MouseDown(object sender, MouseEventArgs e)
{
if (checkBoxStep.Checked == false) //连动
{
if (false == check_z_safety()) { return; }
DownSpeed();
control.axis_move_jog(_upy, 1);
}
else //寸动
{
control.axis_move_offset(_upy, Convert.ToDouble(nud_step.Value));
}
}
private void button10_MouseUp(object sender, MouseEventArgs e)
{
if (checkBoxStep.Checked == false) //连动
{
control.axis_stop(_upy);
}
}
private void button9_MouseDown(object sender, MouseEventArgs e)
{
if (checkBoxStep.Checked == false) //连动
{
if (false == check_z_safety()) { return; }
DownSpeed();
control.axis_move_jog(_upy, 0);
}
else //寸动
{
control.axis_move_offset(_upy, -Convert.ToDouble(nud_step.Value));
}
}
private void button12_MouseDown(object sender, MouseEventArgs e)
{
if (checkBoxStep.Checked == false) //连动
{
DownSpeed();
control.axis_move_jog(_upz, 1);
}
else //寸动
{
control.axis_move_offset(_upz, Convert.ToDouble(nud_step.Value));
}
}
private void button12_MouseUp(object sender, MouseEventArgs e)
{
if (checkBoxStep.Checked == false) //连动
{
control.axis_stop(_upz);
}
}
private void button11_MouseDown(object sender, MouseEventArgs e)
{
if (checkBoxStep.Checked == false) //连动
{
DownSpeed();
control.axis_move_jog(_upz, 0);
}
else //寸动
{
control.axis_move_offset(_upz, -Convert.ToDouble(nud_step.Value));
}
}
private void button20_MouseDown(object sender, MouseEventArgs e)
{
if (checkBoxStep.Checked == false) //连动
{
if (0 == control.read("料盘搬运气缸-")) { MsgBoxHelper.ShowTips("The tray handling cylinder is not in the safe position"); return; }
DownSpeed();
control.axis_move_jog(_carryx, 1);
}
else //寸动
{
control.axis_move_offset(_carryx, Convert.ToDouble(nud_step.Value));
}
}
private void button20_MouseUp(object sender, MouseEventArgs e)
{
if (checkBoxStep.Checked == false) //连动
{
control.axis_stop(_carryx);
}
}
private void button18_MouseDown(object sender, MouseEventArgs e)
{
if (checkBoxStep.Checked == false) //连动
{
if (false == chace_x_safety()) { return; }//检测X轴安全
if (0 == control.read("料盘搬运气缸-")) { MsgBoxHelper.ShowTips("The tray handling cylinder is not in the safe position"); return; }
DownSpeed();
control.axis_move_jog(_carryx, 0);
}
else //寸动
{
control.axis_move_offset(_carryx, -Convert.ToDouble(nud_step.Value));
}
}
private void button22_MouseDown(object sender, MouseEventArgs e)
{
if (checkBoxStep.Checked == false) //连动
{
if (0 == control.read("料仓光电1")) { MsgBoxHelper.ShowTips("Please push the Pass Output Tray silo into position"); return; }
DownSpeed();
control.axis_move_jog(_feedz1, 1);
}
else //寸动
{
control.axis_move_offset(_feedz1, Convert.ToDouble(nud_step.Value));
}
}
private void button22_MouseUp(object sender, MouseEventArgs e)
{
if (checkBoxStep.Checked == false) //连动
{
control.axis_stop(_feedz1);
}
}
private void button16_MouseDown(object sender, MouseEventArgs e)
{
if (checkBoxStep.Checked == false) //连动
{
if (0 == control.read("料仓光电1")) { MsgBoxHelper.ShowTips("Please push the Pass Output Tray silo into position"); return; }
DownSpeed();
control.axis_move_jog(_feedz1, 0);
}
else //寸动
{
control.axis_move_offset(_feedz1, -Convert.ToDouble(nud_step.Value));
}
}
private void button19_MouseDown(object sender, MouseEventArgs e)
{
if (checkBoxStep.Checked == false) //连动
{
if (0 == control.read("料仓光电2")) { MsgBoxHelper.ShowTips("Please push the Input Tray silo into position"); return; }
DownSpeed();
control.axis_move_jog(_feedz2, 1);
}
else //寸动
{
control.axis_move_offset(_feedz2, Convert.ToDouble(nud_step.Value));
}
}
private void button19_MouseUp(object sender, MouseEventArgs e)
{
if (checkBoxStep.Checked == false) //连动
{
control.axis_stop(_feedz2);
}
}
private void button21_MouseDown(object sender, MouseEventArgs e)
{
if (checkBoxStep.Checked == false) //连动
{
if (0 == control.read("料仓光电2")) { MsgBoxHelper.ShowTips("Please push the Input Tray silo into position"); return; }
DownSpeed();
control.axis_move_jog(_feedz2, 0);
}
else //寸动
{
control.axis_move_offset(_feedz2, -Convert.ToDouble(nud_step.Value));
}
}
private void button28_MouseDown(object sender, MouseEventArgs e)
{
if (checkBoxStep.Checked == false) //连动
{
if (0 == control.read("料仓光电3")) { MsgBoxHelper.ShowTips("Please push the Empty Tray silo into position"); return; }
DownSpeed();
control.axis_move_jog(_feedz3, 1);
}
else //寸动
{
control.axis_move_offset(_feedz3, Convert.ToDouble(nud_step.Value));
}
}
private void button28_MouseUp(object sender, MouseEventArgs e)
{
if (checkBoxStep.Checked == false) //连动
{
control.axis_stop(_feedz3);
}
}
private void button27_MouseDown(object sender, MouseEventArgs e)
{
if (checkBoxStep.Checked == false) //连动
{
if (0 == control.read("料仓光电3")) { MsgBoxHelper.ShowTips("Please push the Empty Tray silo into position"); return; }
DownSpeed();
control.axis_move_jog(_feedz3, 0);
}
else //寸动
{
control.axis_move_offset(_feedz3, -Convert.ToDouble(nud_step.Value));
}
}
public void DownSpeed()
{//检查速度是否和界面设置一样
double vel = _vel[_curvel];
double acc = _acc[_curvel];
double dec = _dec[_curvel];
control.set_speed(1, vel, acc, dec);//设置指定工站接下来的运动速度
control.set_speed(2, vel, acc, dec);
control.set_speed(3, vel, acc, dec);
control.set_speed(4, vel, acc, dec);
control.set_speed(5, vel, acc, dec);
control.set_global_speed(1, vel * 2);//设置指定工站的全局速度
control.set_global_speed(2, vel * 2);
control.set_global_speed(3, vel * 2);
control.set_global_speed(4, vel * 2);
control.set_global_speed(5, vel * 2);
if (!_b2nd) return;
control.set_speed(6, vel, acc, dec);//设置指定工站接下来的运动速度
control.set_speed(7, vel, acc, dec);
control.set_speed(8, vel, acc, dec);
control.set_speed(9, vel, acc, dec);
control.set_speed(10, vel, acc, dec);
control.set_global_speed(6, vel * 2);//设置指定工站的全局速度
control.set_global_speed(7, vel * 2);
control.set_global_speed(8, vel * 2);
control.set_global_speed(9, vel * 2);
control.set_global_speed(10, vel * 2);
}
private void button17_Click(object sender, EventArgs e)
{
control.station_reset(1);
control.station_reset(2);
control.station_reset(3);
control.station_reset(4);
control.station_reset(5);
if (!_b2nd) return;
control.station_reset(6);
control.station_reset(7);
control.station_reset(8);
control.station_reset(9);
control.station_reset(10);
}
private void button13_Click(object sender, EventArgs e)
{
int val = 0;
if (btn_off.Text == "OFF")
{
btn_off.Text = "ON";
}
else
{
val = 1;
btn_off.Text = "OFF";
}
control.axis_write(_upx, EIOType.IOT_SEVON, val);
control.axis_write(_upy1, EIOType.IOT_SEVON, val);
control.axis_write(_upy, EIOType.IOT_SEVON, val);
control.axis_write(_upz, EIOType.IOT_SEVON, val);
control.axis_write(_carryx, EIOType.IOT_SEVON, val);
control.axis_write(_feedz1, EIOType.IOT_SEVON, val);
control.axis_write(_feedz2, EIOType.IOT_SEVON, val);
control.axis_write(_feedz3, EIOType.IOT_SEVON, val);
if (!_b2nd) return;
control.axis_write(_ccdx, EIOType.IOT_SEVON, val);
control.axis_write(_ccdz, EIOType.IOT_SEVON, val);
control.axis_write(_upz2, EIOType.IOT_SEVON, val);
control.axis_write(_upz3, EIOType.IOT_SEVON, val);
control.axis_write(_upz4, EIOType.IOT_SEVON, val);
}
private void btn_zsafe_Click(object sender, EventArgs e)
{
double v2z = var.getdouble("v2z");
double v3z = var.getdouble("v3z");
double v4z = var.getdouble("v4z");
double safez = var.getdouble("safez");
DownSpeed();
control.axis_move_pos(_upz, safez);//指定轴点位运动
if (!_b2nd) return;
control.axis_move_pos(_upz2, safez + v2z);
control.axis_move_pos(_upz3, safez + v3z);
control.axis_move_pos(_upz4, safez + v4z);
}
private void button14_Click(object sender, EventArgs e)
{
int ret = 0;
string smg = "";
double m_bpos = 0;
int m_status = 0;
TPoint m_point = new TPoint();
control.axis_get_pos(_upx, ref m_bpos, 0);//X轴当前位置
ret = control.get_point(1, "5号治具位置", ref m_point);
m_status = control.get_dev_status(_upx);//对象状态
if (false == check_z_safety()) { return; }
if (0 != ret) //点位获取失败
{
MsgBoxHelper.ShowTips("Point acquisition failed!");//点位获取失败!
return;
}
if ((int)ocean.EDevStatus.EDev_IDLE == m_status)//就绪
{
if (m_bpos > m_point.x)
{
//if (2 == language) { smg = "vi"; }//越南语
if (1 == language) { MessageBox.Show("Y1轴与H轴会出现干涉,请先把X轴移动到安全位置"); }
else { MessageBox.Show("The Y1-axis and the H-axis will interfere, please move the X-axis to the security location"); }
return;
}
}
//if (2 == language) { smg = "vi"; }//越南语
if (1 == language) { smg = "请注意取料工站与移栽工站是否干涉。\r\n点击是继续回原\r\n不确定点击否放弃回原。"; }
else { smg = "Please pay attention to whether the reclaimer station interferes with the transplanter station.\r\nclick Yes to continue returning to the original. \r\nclick No to give up returning to the original."; }
if (MsgBoxHelper.ConfirmYesNo(smg))
{
control.axis_home(_upx);
control.axis_home(_upy1);
control.axis_home(_upy);
}
}
private void button15_Click(object sender, EventArgs e)
{
control.axis_home(_upz);
}
private void button23_Click(object sender, EventArgs e)
{
if (0 == control.read("料盘搬运气缸-")) { MsgBoxHelper.ShowTips("The tray handling cylinder is not in the safe position"); return; }
control.station_home(2);
}
private void button25_Click(object sender, EventArgs e)
{
if (0 == control.read("抽屉拉伸气缸1-")) { MsgBoxHelper.ShowTips("Please push the Pass Output Tray silo into position"); return; }
control.write("抽屉锁1", (ushort)1);
control.station_home(3);
}
private void button24_Click(object sender, EventArgs e)
{
if (0 == control.read("抽屉拉伸气缸2-")) { MsgBoxHelper.ShowTips("Please push the Input Tray silo into position"); return; }
control.write("抽屉锁2", (ushort)1);
control.station_home(4);
}
private void button26_Click(object sender, EventArgs e)
{
if (0 == control.read("抽屉拉伸气缸3-")) { MsgBoxHelper.ShowTips("Please push the Empty Tray silo into position"); return; }
control.write("抽屉锁3", (ushort)1);
control.station_home(5);
}
private void btn_z2n_MouseDown(object sender, MouseEventArgs e)
{
if (_upz2 == 0) return;
if (checkBoxStep.Checked == false) //连动
{
control.axis_move_jog(_upz2, 0);
}
else //寸动
{
control.axis_move_offset(_upz2, -Convert.ToDouble(nud_step.Value));
}
}
private void btn_z2p_MouseDown(object sender, MouseEventArgs e)
{
if (_upz2 == 0) return;
if (checkBoxStep.Checked == false) //连动
{
control.axis_move_jog(_upz2, 1);
}
else //寸动
{
control.axis_move_offset(_upz2, Convert.ToDouble(nud_step.Value));
}
}
private void btn_z2n_MouseUp(object sender, MouseEventArgs e)
{
if (_upz2 == 0) return;
if (checkBoxStep.Checked == false) //连动
{
control.axis_stop(_upz2, 0);
}
}
private void btn_z2h_Click(object sender, EventArgs e)
{
if (_upz2 == 0) return;
control.axis_home(_upz2);
}
private void btn_z3n_MouseDown(object sender, MouseEventArgs e)
{
if (_upz3 == 0) return;
if (checkBoxStep.Checked == false) //连动
{
control.axis_move_jog(_upz3, 0);
}
else //寸动
{
control.axis_move_offset(_upz3, -Convert.ToDouble(nud_step.Value));
}
}
private void btn_z3p_MouseDown(object sender, MouseEventArgs e)
{
if (_upz3 == 0) return;
if (checkBoxStep.Checked == false) //连动
{
control.axis_move_jog(_upz3, 1);
}
else //寸动
{
control.axis_move_offset(_upz3, Convert.ToDouble(nud_step.Value));
}
}
private void btn_z3n_MouseUp(object sender, MouseEventArgs e)
{
if (_upz3 == 0) return;
if (checkBoxStep.Checked == false) //连动
{
control.axis_stop(_upz3, 0);
}
}
private void btn_z3h_Click(object sender, EventArgs e)
{
if (_upz3 == 0) return;
control.axis_home(_upz3);
}
private void btn_z4n_MouseDown(object sender, MouseEventArgs e)
{
if (_upz4 == 0) return;
if (checkBoxStep.Checked == false) //连动
{
control.axis_move_jog(_upz4, 0);
}
else //寸动
{
control.axis_move_offset(_upz4, -Convert.ToDouble(nud_step.Value));
}
}
private void btn_z4p_MouseDown(object sender, MouseEventArgs e)
{
if (_upz4 == 0) return;
if (checkBoxStep.Checked == false) //连动
{
control.axis_move_jog(_upz4, 1);
}
else //寸动
{
control.axis_move_offset(_upz4, Convert.ToDouble(nud_step.Value));
}
}
private void btn_z4n_MouseUp(object sender, MouseEventArgs e)
{
if (_upz4 == 0) return;
if (checkBoxStep.Checked == false) //连动
{
control.axis_stop(_upz4, 0);
}
}
private void btn_z4h_Click(object sender, EventArgs e)
{
if (_upz4 == 0) return;
control.axis_home(_upz4);
}
private void btn_cxn_MouseDown(object sender, MouseEventArgs e)
{
if (_ccdx == 0) return;
if (checkBoxStep.Checked == false) //连动
{
control.axis_move_jog(_ccdx, 0);
}
else //寸动
{
control.axis_move_offset(_ccdx, -Convert.ToDouble(nud_step.Value));
}
}
private void btn_cxp_KeyDown(object sender, KeyEventArgs e)
{
if (_ccdx == 0) return;
if (checkBoxStep.Checked == false) //连动
{
control.axis_move_jog(_ccdx, 1);
}
else //寸动
{
control.axis_move_offset(_ccdx, Convert.ToDouble(nud_step.Value));
}
}
private void btn_cxn_MouseUp(object sender, MouseEventArgs e)
{
if (_ccdx == 0) return;
if (checkBoxStep.Checked == false) //连动
{
control.axis_stop(_ccdx, 0);
}
}
private void btn_cxh_Click(object sender, EventArgs e)
{
if (_ccdx == 0) return;
control.axis_home(_ccdx);
}
private void btn_czn_MouseDown(object sender, MouseEventArgs e)
{
if (_ccdz == 0) return;
if (checkBoxStep.Checked == false) //连动
{
control.axis_move_jog(_ccdz, 0);
}
else //寸动
{
control.axis_move_offset(_ccdx, -Convert.ToDouble(nud_step.Value));
}
}
private void btn_czp_MouseDown(object sender, MouseEventArgs e)
{
if (_ccdz == 0) return;
if (checkBoxStep.Checked == false) //连动
{
control.axis_move_jog(_ccdz, 1);
}
else //寸动
{
control.axis_move_offset(_ccdz, Convert.ToDouble(nud_step.Value));
}
}
private void btn_czn_MouseUp(object sender, MouseEventArgs e)
{
if (_ccdz == 0) return;
if (checkBoxStep.Checked == false) //连动
{
control.axis_stop(_ccdz, 0);
}
}
private void btn_czh_Click(object sender, EventArgs e)
{
if (_ccdz == 0) return;
control.axis_home(_ccdz);
}
#endregion 连动,寸动
#region 刷新IO信号
public void Update_Pos()
{//刷新位置
double pos = 0;
pos = control.getAxisPos(_upx);
labelx1Pos.Text = pos.ToString("f3");
pos = control.getAxisPos(_upy1);
labelx2Pos.Text = pos.ToString("f3");
pos = control.getAxisPos(_upy);
labelyPos.Text = pos.ToString("f3");
pos = control.getAxisPos(_upz);
labelzPos.Text = pos.ToString("f3");
pos = control.getAxisPos(_carryx);
labelhPos.Text = pos.ToString("f3");
pos = control.getAxisPos(_feedz1);
labelf1Pos.Text = pos.ToString("f3");
pos = control.getAxisPos(_feedz2);
labelf2Pos.Text = pos.ToString("f3");
pos = control.getAxisPos(_feedz3);
labelf3Pos.Text = pos.ToString("f3");
pos = control.getAxisPos(_ccdx);
labelcxPos.Text = pos.ToString("f3");
pos = control.getAxisPos(_ccdz);
labelczPos.Text = pos.ToString("f3");
pos = control.getAxisPos(_upz2);
labelzPos2.Text = pos.ToString("f3");
pos = control.getAxisPos(_upz3);
labelzPos3.Text = pos.ToString("f3");
pos = control.getAxisPos(_upz4);
labelzPos4.Text = pos.ToString("f3");
}
public void Show_IO_pnh()//IO刷新显示 正、负限位、原点
{
pic_x1h.Image = control.axisIO(_upx, EIOType.IOT_HOME) ?
Properties.Resources.Green1 : Properties.Resources.white1;
pic_y1h.Image = control.axisIO(_upy1, EIOType.IOT_HOME) ?
Properties.Resources.Green1 : Properties.Resources.white1;
pic_y2h.Image = control.axisIO(_upy, EIOType.IOT_HOME) ?
Properties.Resources.Green1 : Properties.Resources.white1;
pic_z1h.Image = control.axisIO(_upz, EIOType.IOT_HOME) ?
Properties.Resources.Green1 : Properties.Resources.white1;
pic_hxh.Image = control.axisIO(_carryx, EIOType.IOT_HOME) ?
Properties.Resources.Green1 : Properties.Resources.white1;
pic_f1h.Image = control.axisIO(_feedz1, EIOType.IOT_HOME) ?
Properties.Resources.Green1 : Properties.Resources.white1;
pic_f2h.Image = control.axisIO(_feedz2, EIOType.IOT_HOME) ?
Properties.Resources.Green1 : Properties.Resources.white1;
pic_f3h.Image = control.axisIO(_feedz3, EIOType.IOT_HOME) ?
Properties.Resources.Green1 : Properties.Resources.white1;
pic_z2h.Image = control.axisIO(_upz2, EIOType.IOT_HOME) ?
Properties.Resources.Green1 : Properties.Resources.white1;
pic_z3h.Image = control.axisIO(_upz3, EIOType.IOT_HOME) ?
Properties.Resources.Green1 : Properties.Resources.white1;
pic_z4h.Image = control.axisIO(_upz4, EIOType.IOT_HOME) ?
Properties.Resources.Green1 : Properties.Resources.white1;
pic_cxh.Image = control.axisIO(_ccdx, EIOType.IOT_HOME) ?
Properties.Resources.Green1 : Properties.Resources.white1;
pic_czh.Image = control.axisIO(_ccdz, EIOType.IOT_HOME) ?
Properties.Resources.Green1 : Properties.Resources.white1;
btn_xp.Image = control.axisIO(_upx, EIOType.IOT_LIMITP) ?
Properties.Resources.ARW07RT1 : Properties.Resources.ARW07RT;
btn_y1p.Image = control.axisIO(_upy1, EIOType.IOT_LIMITP) ?
Properties.Resources.ARW07RT1 : Properties.Resources.ARW07RT;
btn_y2p.Image = control.axisIO(_upy, EIOType.IOT_LIMITP) ?
Properties.Resources.ARW07RT1 : Properties.Resources.ARW07RT;
btn_z1p.Image = control.axisIO(_upz, EIOType.IOT_LIMITP) ?
Properties.Resources.ARW07RT1 : Properties.Resources.ARW07RT;
btn_hxp.Image = control.axisIO(_carryx, EIOType.IOT_LIMITP) ?
Properties.Resources.ARW07RT1 : Properties.Resources.ARW07RT;
btn_f1p.Image = control.axisIO(_feedz1, EIOType.IOT_LIMITP) ?
Properties.Resources.ARW07RT1 : Properties.Resources.ARW07RT;
btn_f2p.Image = control.axisIO(_feedz2, EIOType.IOT_LIMITP) ?
Properties.Resources.ARW07RT1 : Properties.Resources.ARW07RT;
btn_f3p.Image = control.axisIO(_feedz3, EIOType.IOT_LIMITP) ?
Properties.Resources.ARW07RT1 : Properties.Resources.ARW07RT;
btn_z2p.Image = control.axisIO(_upz2, EIOType.IOT_LIMITP) ?
Properties.Resources.ARW07RT1 : Properties.Resources.ARW07RT;
btn_z3p.Image = control.axisIO(_upz3, EIOType.IOT_LIMITP) ?
Properties.Resources.ARW07RT1 : Properties.Resources.ARW07RT;
btn_z4p.Image = control.axisIO(_upz4, EIOType.IOT_LIMITP) ?
Properties.Resources.ARW07RT1 : Properties.Resources.ARW07RT;
btn_cxp.Image = control.axisIO(_ccdx, EIOType.IOT_LIMITP) ?
Properties.Resources.ARW07RT1 : Properties.Resources.ARW07RT;
btn_czp.Image = control.axisIO(_ccdz, EIOType.IOT_LIMITP) ?
Properties.Resources.ARW07RT1 : Properties.Resources.ARW07RT;
btn_xn.Image = control.axisIO(_upx, EIOType.IOT_LIMITN) ?
Properties.Resources.ARW07RT1 : Properties.Resources.ARW07RT;
btn_y1n.Image = control.axisIO(_upy1, EIOType.IOT_LIMITN) ?
Properties.Resources.ARW07RT1 : Properties.Resources.ARW07RT;
btn_y2n.Image = control.axisIO(_upy, EIOType.IOT_LIMITN) ?
Properties.Resources.ARW07RT1 : Properties.Resources.ARW07RT;
btn_z1n.Image = control.axisIO(_upz, EIOType.IOT_LIMITN) ?
Properties.Resources.ARW07RT1 : Properties.Resources.ARW07RT;
btn_hxn.Image = control.axisIO(_carryx, EIOType.IOT_LIMITN) ?
Properties.Resources.ARW07RT1 : Properties.Resources.ARW07RT;
btn_f1n.Image = control.axisIO(_feedz1, EIOType.IOT_LIMITN) ?
Properties.Resources.ARW07RT1 : Properties.Resources.ARW07RT;
btn_f2n.Image = control.axisIO(_feedz2, EIOType.IOT_LIMITN) ?
Properties.Resources.ARW07RT1 : Properties.Resources.ARW07RT;
btn_f3n.Image = control.axisIO(_feedz3, EIOType.IOT_LIMITN) ?
Properties.Resources.ARW07RT1 : Properties.Resources.ARW07RT;
btn_z2n.Image = control.axisIO(_upz2, EIOType.IOT_LIMITN) ?
Properties.Resources.ARW07RT1 : Properties.Resources.ARW07RT;
btn_z3n.Image = control.axisIO(_upz3, EIOType.IOT_LIMITN) ?
Properties.Resources.ARW07RT1 : Properties.Resources.ARW07RT;
btn_z4n.Image = control.axisIO(_upz4, EIOType.IOT_LIMITN) ?
Properties.Resources.ARW07RT1 : Properties.Resources.ARW07RT;
btn_cxn.Image = control.axisIO(_ccdx, EIOType.IOT_LIMITN) ?
Properties.Resources.ARW07RT1 : Properties.Resources.ARW07RT;
btn_czn.Image = control.axisIO(_ccdz, EIOType.IOT_LIMITN) ?
Properties.Resources.ARW07RT1 : Properties.Resources.ARW07RT;
}
#endregion 刷新IO信号
private void FormMove_Load(object sender, EventArgs e)
{
combox_spd.SelectedIndex = 0;
language = config.getint("ui", "language");//语言选择
if (!_b2nd)
{//一代机
labelcx.Visible = labelcxPos.Visible = false;
labelcz.Visible = labelczPos.Visible = false;
labelz2.Visible = labelzPos2.Visible = false;
labelz3.Visible = labelzPos3.Visible = false;
labelz4.Visible = labelzPos4.Visible = false;
btn_z2n.Visible = btn_z2h.Visible = pic_z2h.Visible = btn_z2p.Visible = false;
btn_z3n.Visible = btn_z3h.Visible = pic_z3h.Visible = btn_z3p.Visible = false;
btn_z4n.Visible = btn_z4h.Visible = pic_z4h.Visible = btn_z4p.Visible = false;
btn_cxn.Visible = btn_cxh.Visible = pic_cxh.Visible = btn_cxp.Visible = false;
btn_czn.Visible = btn_czh.Visible = pic_czh.Visible = btn_czp.Visible = false;
}
}
private void FormMove_FormClosing(object sender, FormClosingEventArgs e)
{
this.Hide();
e.Cancel = true;
}
private void FormMove_VisibleChanged(object sender, EventArgs e)
{
if (this.Visible == true)
{//显示
combox_spd.SelectedIndex = 0;
}
else
{//不显示
_curvel = 0;
}
}
}
}