Commit 34de589f LN

1

1 个父辈 065d6590
...@@ -51,7 +51,7 @@ namespace ABBRobotTest ...@@ -51,7 +51,7 @@ namespace ABBRobotTest
networkwatcher.Lost += new EventHandler<NetworkWatcherEventArgs>(HandleLostEvent); networkwatcher.Lost += new EventHandler<NetworkWatcherEventArgs>(HandleLostEvent);
networkwatcher.EnableRaisingEvents = true; networkwatcher.EnableRaisingEvents = true;
} }
private static void AddControllerInfo(ControllerInfo controllerInfo) private static bool AddControllerInfo(ControllerInfo controllerInfo)
{ {
try try
{ {
...@@ -64,10 +64,11 @@ namespace ABBRobotTest ...@@ -64,10 +64,11 @@ namespace ABBRobotTest
// controller = con; // controller = con;
controllerInfoMap.Add(ip, controllerInfo); controllerInfoMap.Add(ip, controllerInfo);
LogUtil.info("成功添加机器人【" + ip + "】"); LogUtil.info("成功添加机器人【" + ip + "】");
return true;
}catch(Exception ex) }catch(Exception ex)
{ {
LogUtil.error("添加机器人【" + controllerInfo.IPAddress.ToString() + "】失败:" + ex.ToString()); LogUtil.error("添加机器人【" + controllerInfo.IPAddress.ToString() + "】失败:" + ex.ToString());
} }return false;
} }
private static void RemoveController(string ip) private static void RemoveController(string ip)
{ {
...@@ -100,10 +101,12 @@ namespace ABBRobotTest ...@@ -100,10 +101,12 @@ namespace ABBRobotTest
{ {
ControllerInfo controllerInfo = e.Controller; ControllerInfo controllerInfo = e.Controller;
if (controllerInfo != null) if (controllerInfo != null)
{ {
AddControllerInfo(controllerInfo); if (AddControllerInfo(controllerInfo))
ControllerAddEvent?.Invoke(controllerInfo); {
} ControllerAddEvent?.Invoke(controllerInfo);
}
}
} }
private void StartRobotByTask(string ip) private void StartRobotByTask(string ip)
{ {
......
...@@ -13,8 +13,7 @@ namespace ABBRobotTest ...@@ -13,8 +13,7 @@ namespace ABBRobotTest
{ {
private static TcpServer tcpserver = null; private static TcpServer tcpserver = null;
public static bool IsStart = false; public static bool IsStart = false;
private static int ClientKeepSecond = 10;
private static int ABBServerPort = ConfigAppSettings.GetIntValue(Setting_Init.ABBServerPort ); private static int ABBServerPort = ConfigAppSettings.GetIntValue(Setting_Init.ABBServerPort );
public static string ErrorInfo = ""; public static string ErrorInfo = "";
...@@ -116,72 +115,80 @@ namespace ABBRobotTest ...@@ -116,72 +115,80 @@ namespace ABBRobotTest
IPEndPoint clientipe = (IPEndPoint)client.ClientSocket.RemoteEndPoint; IPEndPoint clientipe = (IPEndPoint)client.ClientSocket.RemoteEndPoint;
string add = clientipe.Address.ToString(); string add = clientipe.Address.ToString();
// string[] msgArray = msg.Split(cmd_spilt); // string[] msgArray = msg.Split(cmd_spilt);
msg = msg.Replace("\r", "").ToLower(); msg = msg.Replace("\r", "") ;
LogUtil.info("Revice[" + add + "]:[" + msg + "]"); LogUtil.info("Revice[" + add + "]:[" + msg + "]");
msg = msg.Replace(";", "");
string OkStr = "OK";
if (msg.ToLower().Contains("error")) if (msg.Contains("ERROR"))
{ {
ErrorInfo = msg; ErrorInfo = msg;
} }
else if(msg.Contains(Cmd_movep)&& msg.Contains("OK")) else if(msg.Contains(Cmd_movep)&& msg.Contains(OkStr))
{ {
OnCmdEnd?.Invoke(msg); OnCmdEnd?.Invoke(msg);
} }
else if (msg.Contains(Cmd_moveput) && msg.Contains("OK")) else if (msg.Contains(Cmd_moveput) && msg.Contains(OkStr))
{ {
OnCmdEnd?.Invoke(msg); OnCmdEnd?.Invoke(msg);
} else if (msg.Contains(Cmd_moveget) && msg.Contains("ok")) } else if (msg.Contains(Cmd_moveget) && msg.Contains(OkStr))
{
OnCmdEnd?.Invoke(msg);
}else if (msg.Contains(OkStr))
{ {
OnCmdEnd?.Invoke(msg); OnCmdEnd?.Invoke(msg);
} }
return false; return false;
} }
public static void MoveToP(string robotIp, string PointName, string moveType="L" , double targetSpeed = 100, OpEnd AfterCmd = null) public static bool MoveToP(string robotIp, string PointName, string moveType="L" , double targetSpeed = 100, OpEnd AfterCmd = null)
{ {
ABBRobotServer.OnCmdEnd = AfterCmd; ABBRobotServer.OnCmdEnd = AfterCmd;
SendMovePoint(robotIp, Cmd_movep, PointName,moveType,targetSpeed.ToString()); return SendMovePoint(robotIp, Cmd_movep, PointName,moveType,targetSpeed.ToString());
} }
public static void MoveToPut(string robotIp, string PointName, string moveType = "L", double targetSpeed = 100, OpEnd AfterCmd = null) public static bool MoveToPut(string robotIp, string PointName, string moveType = "L", double targetSpeed = 100, OpEnd AfterCmd = null)
{ {
ABBRobotServer.OnCmdEnd = AfterCmd; ABBRobotServer.OnCmdEnd = AfterCmd;
SendMovePoint(robotIp, Cmd_moveput, PointName, moveType, targetSpeed.ToString()); return SendMovePoint(robotIp, Cmd_moveput, PointName, moveType, targetSpeed.ToString());
} }
public static void MoveToGet(string robotIp, string PointName, string moveType = "L", double targetSpeed = 100, OpEnd AfterCmd = null) public static bool MoveToGet(string robotIp, string PointName, string moveType = "L", double targetSpeed = 100, OpEnd AfterCmd = null)
{ {
ABBRobotServer.OnCmdEnd = AfterCmd; ABBRobotServer.OnCmdEnd = AfterCmd;
SendMovePoint(robotIp, Cmd_moveget, PointName, moveType, targetSpeed.ToString()); return SendMovePoint(robotIp, Cmd_moveget, PointName, moveType, targetSpeed.ToString());
} }
public static void SendCmd(string robotIp, string moveCmd,string PointName, string moveType = "L", double targetSpeed = 100, OpEnd AfterCmd = null) public static bool SendCmd(string robotIp, string moveCmd,string PointName, string moveType = "L", double targetSpeed = 100, OpEnd AfterCmd = null)
{ {
ABBRobotServer.OnCmdEnd = AfterCmd; ABBRobotServer.OnCmdEnd = AfterCmd;
if (moveCmd.Equals(Cmd_moveget) || moveCmd.Equals(Cmd_movep) || moveCmd.Equals(Cmd_moveput)||moveCmd.Equals(Cmd_validateP)) if (moveCmd.Equals(Cmd_moveget) || moveCmd.Equals(Cmd_movep) || moveCmd.Equals(Cmd_moveput)||moveCmd.Equals(Cmd_validateP))
{ {
SendMovePoint(robotIp, moveCmd, PointName, moveType, targetSpeed.ToString()); return SendMovePoint(robotIp, moveCmd, PointName, moveType, targetSpeed.ToString());
} }
return false;
} }
public static void ValidateP(string robotIp, string pointName, OpEnd AfterCmd = null) public static bool ValidateP(string robotIp, string pointName, OpEnd AfterCmd = null)
{ {
ABBRobotServer.OnCmdEnd = AfterCmd; ABBRobotServer.OnCmdEnd = AfterCmd;
return SendMovePoint(robotIp, Cmd_validateP, pointName);
SendMovePoint(robotIp, Cmd_validateP, pointName);
} }
private static void SendMovePoint(string robotIp, string param1,string param2,string param3="L",string param4="10") private static bool SendMovePoint(string robotIp, string param1, string param2, string param3 = "L", string param4 = "10")
{ {
Client client = null;
lock (LockObj) lock (LockObj)
{ {
if (ClientMap.ContainsKey(robotIp)) if (ClientMap.ContainsKey(robotIp))
{ {
Client client = ClientMap[robotIp]; client = ClientMap[robotIp];
string str = param1 + "," + param2 + "," + param3 + "," + param4+"";
LastSendPoint = param2;
LogUtil.info("Send [" + robotIp + "] : [" + str + "]");
SendStrToClient(client, str);
} }
} }
if (client != null)
{
string str = param1 + "," + param2 + "," + param3 + "," + param4 + "";
LastSendPoint = param2;
LogUtil.info("Send [" + robotIp + "] : [" + str + "]");
SendStrToClient(client, str);
return true;
}
return false;
} }
private static bool SendStrToClient(Client client, string sendMsg) private static bool SendStrToClient(Client client, string sendMsg)
{ {
......
...@@ -35,6 +35,8 @@ ...@@ -35,6 +35,8 @@
this.btnStart = new System.Windows.Forms.Button(); this.btnStart = new System.Windows.Forms.Button();
this.richTextBox1 = new System.Windows.Forms.RichTextBox(); this.richTextBox1 = new System.Windows.Forms.RichTextBox();
this.groupMove = new System.Windows.Forms.GroupBox(); this.groupMove = new System.Windows.Forms.GroupBox();
this.btnClearLog = new System.Windows.Forms.Button();
this.lblState = new System.Windows.Forms.Label();
this.btnMove = new System.Windows.Forms.Button(); this.btnMove = new System.Windows.Forms.Button();
this.radioButton2 = new System.Windows.Forms.RadioButton(); this.radioButton2 = new System.Windows.Forms.RadioButton();
this.radioButton1 = new System.Windows.Forms.RadioButton(); this.radioButton1 = new System.Windows.Forms.RadioButton();
...@@ -45,8 +47,6 @@ ...@@ -45,8 +47,6 @@
this.label1 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label();
this.comMoveCmd = new System.Windows.Forms.ComboBox(); this.comMoveCmd = new System.Windows.Forms.ComboBox();
this.btnExit = new System.Windows.Forms.Button(); this.btnExit = new System.Windows.Forms.Button();
this.lblState = new System.Windows.Forms.Label();
this.btnClearLog = new System.Windows.Forms.Button();
this.groupMove.SuspendLayout(); this.groupMove.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numSpeed)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.numSpeed)).BeginInit();
this.SuspendLayout(); this.SuspendLayout();
...@@ -76,9 +76,9 @@ ...@@ -76,9 +76,9 @@
// btnStop // btnStop
// //
this.btnStop.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.btnStop.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnStop.Location = new System.Drawing.Point(171, 176); this.btnStop.Location = new System.Drawing.Point(171, 170);
this.btnStop.Name = "btnStop"; this.btnStop.Name = "btnStop";
this.btnStop.Size = new System.Drawing.Size(108, 46); this.btnStop.Size = new System.Drawing.Size(120, 45);
this.btnStop.TabIndex = 195; this.btnStop.TabIndex = 195;
this.btnStop.Text = "停止"; this.btnStop.Text = "停止";
this.btnStop.UseVisualStyleBackColor = true; this.btnStop.UseVisualStyleBackColor = true;
...@@ -87,9 +87,9 @@ ...@@ -87,9 +87,9 @@
// btnStart // btnStart
// //
this.btnStart.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.btnStart.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnStart.Location = new System.Drawing.Point(34, 176); this.btnStart.Location = new System.Drawing.Point(34, 170);
this.btnStart.Name = "btnStart"; this.btnStart.Name = "btnStart";
this.btnStart.Size = new System.Drawing.Size(108, 46); this.btnStart.Size = new System.Drawing.Size(120, 45);
this.btnStart.TabIndex = 194; this.btnStart.TabIndex = 194;
this.btnStart.Text = "启动"; this.btnStart.Text = "启动";
this.btnStart.UseVisualStyleBackColor = true; this.btnStart.UseVisualStyleBackColor = true;
...@@ -110,7 +110,6 @@ ...@@ -110,7 +110,6 @@
// //
this.groupMove.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) this.groupMove.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left))); | System.Windows.Forms.AnchorStyles.Left)));
this.groupMove.Controls.Add(this.btnClearLog);
this.groupMove.Controls.Add(this.lblState); this.groupMove.Controls.Add(this.lblState);
this.groupMove.Controls.Add(this.btnMove); this.groupMove.Controls.Add(this.btnMove);
this.groupMove.Controls.Add(this.radioButton2); this.groupMove.Controls.Add(this.radioButton2);
...@@ -121,20 +120,42 @@ ...@@ -121,20 +120,42 @@
this.groupMove.Controls.Add(this.comMoveP); this.groupMove.Controls.Add(this.comMoveP);
this.groupMove.Controls.Add(this.label1); this.groupMove.Controls.Add(this.label1);
this.groupMove.Controls.Add(this.comMoveCmd); this.groupMove.Controls.Add(this.comMoveCmd);
this.groupMove.Enabled = false;
this.groupMove.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.groupMove.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.groupMove.Location = new System.Drawing.Point(12, 243); this.groupMove.Location = new System.Drawing.Point(12, 227);
this.groupMove.Name = "groupMove"; this.groupMove.Name = "groupMove";
this.groupMove.Size = new System.Drawing.Size(426, 471); this.groupMove.Size = new System.Drawing.Size(426, 436);
this.groupMove.TabIndex = 197; this.groupMove.TabIndex = 197;
this.groupMove.TabStop = false; this.groupMove.TabStop = false;
this.groupMove.Text = "运动测试"; this.groupMove.Text = "运动测试";
// //
// btnClearLog
//
this.btnClearLog.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnClearLog.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnClearLog.Location = new System.Drawing.Point(309, 669);
this.btnClearLog.Name = "btnClearLog";
this.btnClearLog.Size = new System.Drawing.Size(120, 45);
this.btnClearLog.TabIndex = 199;
this.btnClearLog.Text = "清理日志";
this.btnClearLog.UseVisualStyleBackColor = true;
this.btnClearLog.Click += new System.EventHandler(this.btnClearLog_Click);
//
// lblState
//
this.lblState.AutoSize = true;
this.lblState.ForeColor = System.Drawing.Color.Red;
this.lblState.Location = new System.Drawing.Point(37, 36);
this.lblState.Name = "lblState";
this.lblState.Size = new System.Drawing.Size(0, 20);
this.lblState.TabIndex = 196;
//
// btnMove // btnMove
// //
this.btnMove.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.btnMove.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnMove.Location = new System.Drawing.Point(159, 317); this.btnMove.Location = new System.Drawing.Point(159, 317);
this.btnMove.Name = "btnMove"; this.btnMove.Name = "btnMove";
this.btnMove.Size = new System.Drawing.Size(108, 46); this.btnMove.Size = new System.Drawing.Size(120, 45);
this.btnMove.TabIndex = 195; this.btnMove.TabIndex = 195;
this.btnMove.Text = "运动测试"; this.btnMove.Text = "运动测试";
this.btnMove.UseVisualStyleBackColor = true; this.btnMove.UseVisualStyleBackColor = true;
...@@ -239,40 +260,20 @@ ...@@ -239,40 +260,20 @@
// btnExit // btnExit
// //
this.btnExit.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.btnExit.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnExit.Location = new System.Drawing.Point(309, 176); this.btnExit.Location = new System.Drawing.Point(309, 170);
this.btnExit.Name = "btnExit"; this.btnExit.Name = "btnExit";
this.btnExit.Size = new System.Drawing.Size(108, 46); this.btnExit.Size = new System.Drawing.Size(120, 45);
this.btnExit.TabIndex = 198; this.btnExit.TabIndex = 198;
this.btnExit.Text = "退出"; this.btnExit.Text = "退出";
this.btnExit.UseVisualStyleBackColor = true; this.btnExit.UseVisualStyleBackColor = true;
this.btnExit.Click += new System.EventHandler(this.btnExit_Click); this.btnExit.Click += new System.EventHandler(this.btnExit_Click);
// //
// lblState
//
this.lblState.AutoSize = true;
this.lblState.ForeColor = System.Drawing.Color.Red;
this.lblState.Location = new System.Drawing.Point(37, 36);
this.lblState.Name = "lblState";
this.lblState.Size = new System.Drawing.Size(51, 20);
this.lblState.TabIndex = 196;
this.lblState.Text = "急停中";
//
// btnClearLog
//
this.btnClearLog.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnClearLog.Location = new System.Drawing.Point(312, 419);
this.btnClearLog.Name = "btnClearLog";
this.btnClearLog.Size = new System.Drawing.Size(108, 46);
this.btnClearLog.TabIndex = 199;
this.btnClearLog.Text = "清理日志";
this.btnClearLog.UseVisualStyleBackColor = true;
this.btnClearLog.Click += new System.EventHandler(this.btnClearLog_Click);
//
// FrmRobotMain // FrmRobotMain
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1335, 726); this.ClientSize = new System.Drawing.Size(1335, 726);
this.Controls.Add(this.btnClearLog);
this.Controls.Add(this.btnExit); this.Controls.Add(this.btnExit);
this.Controls.Add(this.groupMove); this.Controls.Add(this.groupMove);
this.Controls.Add(this.richTextBox1); this.Controls.Add(this.richTextBox1);
...@@ -280,7 +281,9 @@ ...@@ -280,7 +281,9 @@
this.Controls.Add(this.btnStart); this.Controls.Add(this.btnStart);
this.Controls.Add(this.listView1); this.Controls.Add(this.listView1);
this.Name = "FrmRobotMain"; this.Name = "FrmRobotMain";
this.Text = "FrmRobotMain"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "ABB机器人测试";
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmRobotMain_FormClosing); this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmRobotMain_FormClosing);
this.Load += new System.EventHandler(this.FrmRobotMain_Load); this.Load += new System.EventHandler(this.FrmRobotMain_Load);
this.groupMove.ResumeLayout(false); this.groupMove.ResumeLayout(false);
......
...@@ -27,9 +27,16 @@ namespace ABBRobotTest ...@@ -27,9 +27,16 @@ namespace ABBRobotTest
LoadController(); LoadController();
timer1.Start(); timer1.Start();
ABBRobotServer.StartServer(); ABBRobotServer.StartServer();
ABBRobotManager.ControllerAddEvent += ABBRobotManager_ControllerAddEvent;
LogUtil.logBox = this.richTextBox1; LogUtil.logBox = this.richTextBox1;
} }
private void ABBRobotManager_ControllerAddEvent(ControllerInfo controller)
{
int index = listView1.Items.Count;
AddConInfo(controller, index);
}
private void LoadCom() private void LoadCom()
{ {
comMoveCmd.Items.Clear(); comMoveCmd.Items.Clear();
...@@ -56,24 +63,28 @@ namespace ABBRobotTest ...@@ -56,24 +63,28 @@ namespace ABBRobotTest
int i = 0; int i = 0;
foreach (ControllerInfo con in ABBRobotManager.controllerInfoMap.Values) foreach (ControllerInfo con in ABBRobotManager.controllerInfoMap.Values)
{ {
ListViewItem item = new ListViewItem(con.IPAddress.ToString()); AddConInfo(con,i);
item.SubItems.Add(con.Id.ToString()); i++;
item.SubItems.Add(con.Availability.ToString());
item.SubItems.Add(con.IsVirtual.ToString());
item.SubItems.Add(con.SystemName);
item.SubItems.Add(con.Version.ToString());
item.SubItems.Add(con.ControllerName);
item.Tag = con.IPAddress;
string state = ABBRobotManager.GetRobotState(con.IPAddress.ToString());
item.SubItems.Add(state);
this.listView1.Items.Add(item);
this.listView1.Items[i].Selected = true;
SelConIp = con.IPAddress.ToString();
i++;
} }
} }
private void AddConInfo(ControllerInfo con,int i)
{
ListViewItem item = new ListViewItem(con.IPAddress.ToString());
item.SubItems.Add(con.Id.ToString());
item.SubItems.Add(con.Availability.ToString());
item.SubItems.Add(con.IsVirtual.ToString());
item.SubItems.Add(con.SystemName);
item.SubItems.Add(con.Version.ToString());
item.SubItems.Add(con.ControllerName);
item.Tag = con.IPAddress;
string state = ABBRobotManager.GetRobotState(con.IPAddress.ToString());
item.SubItems.Add(state);
this.listView1.Items.Add(item);
this.listView1.Items[i].Selected = true;
SelConIp = con.IPAddress.ToString();
}
private void LoadListView() private void LoadListView()
{ {
this.listView1.Columns.Clear(); this.listView1.Columns.Clear();
...@@ -99,7 +110,7 @@ namespace ABBRobotTest ...@@ -99,7 +110,7 @@ namespace ABBRobotTest
} }
private void timer1_Tick(object sender, EventArgs e) private void timer1_Tick(object sender, EventArgs e)
{ {
int i = 0; int i = 0;
List<string> conList = new List<string>(ABBRobotManager.controllerMap.Keys); List<string> conList = new List<string>(ABBRobotManager.controllerMap.Keys);
foreach (string con in conList) foreach (string con in conList)
...@@ -116,26 +127,44 @@ namespace ABBRobotTest ...@@ -116,26 +127,44 @@ namespace ABBRobotTest
{ {
groupMove.Enabled = false; groupMove.Enabled = false;
} }
if (String.IsNullOrEmpty(SelConIp))
{
lblState.Text = "";
return;
}
bool isOk = false;
int esValue = ABBRobotManager.GetSingalState(SelConIp); int esValue = ABBRobotManager.GetSingalState(SelConIp);
if (esValue.Equals(1)) if (esValue.Equals(1))
{ {
SetMsg("机器人[" + SelConIp + "]急停中", Color.Red); SetMsg("机器人[" + SelConIp + "]急停中", Color.Red);
} }
else else
{ {
lblState.Text = ""; lblState.Text = "";
int isRun = ABBRobotManager.GetSingalState(SelConIp, ABBRobotManager.DO_IsRun); int isRun = ABBRobotManager.GetSingalState(SelConIp, ABBRobotManager.DO_IsRun);
if (isRun.Equals(1)) if (isRun.Equals(1))
{ {
SetMsg("机器人程序正常运行中", Color.Green); isOk = true;
SetMsg("机器人程序正常运行中", Color.Green);
} }
else else
{ {
SetMsg("机器人[" + SelConIp + "]程序未运行", Color.Red); SetMsg("机器人[" + SelConIp + "]程序未运行", Color.Red);
}
}
if (isOk && ABBRobotServer.RobotIsConnect(SelConIp))
{
if (!groupMove.Enabled)
{
groupMove.Enabled = true;
} }
} }
else if (groupMove.Enabled)
{
groupMove.Enabled = false;
}
} }
private void SetMsg(string msg,Color foreColor) private void SetMsg(string msg,Color foreColor)
{ {
lblState.Text = msg; lblState.Text = msg;
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!