Commit 434f7f92 几米阳光

1

1 个父辈 005d9f15
...@@ -98,23 +98,14 @@ namespace URSoldering.DeviceLibrary ...@@ -98,23 +98,14 @@ namespace URSoldering.DeviceLibrary
/// 初始化 /// 初始化
/// </summary> /// </summary>
public static void Init() public static void Init()
{ {
//URRobotControl.InitEpson(); StartURRobot();
Task.Factory.StartNew(delegate ()
{
bool result = URRobotControl.StartRobot();
if (!result)
{
WarnMsg = "连接UR机器人失败";
}
});
SolderingManager.Init(RobotConfig.JBC_Soldering_Port, RobotConfig.JBC_Soldering_Num); SolderingManager.Init(RobotConfig.JBC_Soldering_Port, RobotConfig.JBC_Soldering_Num);
SendWireManager.Init(RobotConfig.JBC_SendWire_Port); SendWireManager.Init(RobotConfig.JBC_SendWire_Port);
isInit = true; isInit = true;
} }
private static void StartURRobot()
public static void ResetInit()
{ {
if (!URRobotControl.IsRun) if (!URRobotControl.IsRun)
{ {
...@@ -128,6 +119,10 @@ namespace URSoldering.DeviceLibrary ...@@ -128,6 +119,10 @@ namespace URSoldering.DeviceLibrary
} }
}); });
} }
}
public static void ResetInit()
{
StartURRobot();
SendWireManager.Init(RobotConfig.JBC_SendWire_Port); SendWireManager.Init(RobotConfig.JBC_SendWire_Port);
SolderingManager.Init(RobotConfig.JBC_Soldering_Port, RobotConfig.JBC_Soldering_Num); SolderingManager.Init(RobotConfig.JBC_Soldering_Port, RobotConfig.JBC_Soldering_Num);
} }
......
...@@ -116,6 +116,10 @@ namespace URSoldering.DeviceLibrary ...@@ -116,6 +116,10 @@ namespace URSoldering.DeviceLibrary
/// <returns></returns> /// <returns></returns>
public static bool StartRobot() public static bool StartRobot()
{ {
if (IsRun)
{
return true;
}
if (reconnectTimer == null) if (reconnectTimer == null)
{ {
reconnectTimer = new System.Timers.Timer(); reconnectTimer = new System.Timers.Timer();
...@@ -125,10 +129,6 @@ namespace URSoldering.DeviceLibrary ...@@ -125,10 +129,6 @@ namespace URSoldering.DeviceLibrary
reconnectTimer.Enabled = false; reconnectTimer.Enabled = false;
} }
IsStartConnect = true; IsStartConnect = true;
if (IsRun)
{
return true;
}
return StartConnect(); return StartConnect();
} }
...@@ -160,9 +160,10 @@ namespace URSoldering.DeviceLibrary ...@@ -160,9 +160,10 @@ namespace URSoldering.DeviceLibrary
PreStartTime = DateTime.Now; PreStartTime = DateTime.Now;
startCount++; startCount++;
//Reset(); LogUtil.info("" + LogName + "开始连接");
Reset();
controlTcp = new TcpClient(); controlTcp = new TcpClient();
controlTcp.TimeOutTime = 2000;
bool result = controlTcp.connect(RobotIp, ControlPort, new TcpClient.HandleMessage(OnControlRevice)); bool result = controlTcp.connect(RobotIp, ControlPort, new TcpClient.HandleMessage(OnControlRevice));
if (!result) if (!result)
{ {
......
...@@ -235,6 +235,7 @@ namespace URSoldering.Client ...@@ -235,6 +235,7 @@ namespace URSoldering.Client
} }
if (!URRobotControl.IsRun&&isRun.Equals(false)) if (!URRobotControl.IsRun&&isRun.Equals(false))
{ {
isRun = true;
Task.Factory.StartNew(delegate () Task.Factory.StartNew(delegate ()
{ {
bool result = URRobotControl.StartRobot(); bool result = URRobotControl.StartRobot();
...@@ -248,13 +249,10 @@ namespace URSoldering.Client ...@@ -248,13 +249,10 @@ namespace URSoldering.Client
} }
}); });
isRun = true;
} }
else else
{ {
RobotStatus(true); RobotStatus(true);
URRobotControl.FreeAxis();
UpdateRobotPosition(); UpdateRobotPosition();
} }
} }
...@@ -272,8 +270,7 @@ namespace URSoldering.Client ...@@ -272,8 +270,7 @@ namespace URSoldering.Client
} }
URRobotControl.LockAxis(); URRobotControl.LockAxis();
//timer2.Stop(); //timer2.Stop();
timer1.Stop(); timer1.Stop();
UsbCameraHDevelop.CloseAllCamera();
} }
private void btnSavePoint_Click(object sender, EventArgs e) private void btnSavePoint_Click(object sender, EventArgs e)
......
...@@ -22,25 +22,12 @@ namespace URSoldering.Client ...@@ -22,25 +22,12 @@ namespace URSoldering.Client
private void FrmBoardInfo_Load(object sender, EventArgs e) private void FrmBoardInfo_Load(object sender, EventArgs e)
{ {
CheckForIllegalCrossThreadCalls = false; //CheckForIllegalCrossThreadCalls = false;
//此界面打开时,不能打开自动焊接
if (WeldRobotBean.ISRun) if (WeldRobotBean.ISRun)
{ {
LogUtil.error("进入焊接界面,发现WeldRobotBean自动运行中,关闭自动运行"); LogUtil.error("进入焊接界面,发现WeldRobotBean自动运行中,关闭自动运行");
WeldRobotBean.StopRun(); WeldRobotBean.StopRun();
} }
if (URRobotControl.IsRun)
{
URRobotControl.FreeAxis();
URPointValue lastP = URRobotControl.GetLastPosition();
urRobotSControl1.ShowPoint(lastP);
}
else
{
}
isAuto = false; isAuto = false;
timer1.Interval = 1000; timer1.Interval = 1000;
...@@ -53,21 +40,11 @@ namespace URSoldering.Client ...@@ -53,21 +40,11 @@ namespace URSoldering.Client
{ {
if (!URRobotControl.IsRun && isRun.Equals(false)) if (!URRobotControl.IsRun && isRun.Equals(false))
{ {
isRun = true;
Task.Factory.StartNew(delegate () Task.Factory.StartNew(delegate ()
{ {
bool result = URRobotControl.StartRobot(); bool result = URRobotControl.StartRobot();
if (!result) });
{
LogUtil.info("连接失败:" + result);
}
else
{
URRobotControl.FreeAxis();
isAuto = false;
}
});
isRun = true;
} }
else else
{ {
...@@ -81,8 +58,7 @@ namespace URSoldering.Client ...@@ -81,8 +58,7 @@ namespace URSoldering.Client
private void FrmBoardInfo_FormClosing(object sender, FormClosingEventArgs e) private void FrmBoardInfo_FormClosing(object sender, FormClosingEventArgs e)
{ {
URRobotControl.LockAxis(); URRobotControl.LockAxis();
timer1.Stop(); timer1.Stop();
UsbCameraHDevelop.CloseAllCamera();
} }
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!