Commit 065d6590 LN

增加位置验证

1 个父辈 5f3160f1
......@@ -14,10 +14,11 @@ namespace ABBRobotTest
internal class ABBRobotManager
{
internal static string DI_Start = "di_start";
internal static string DI_Stop = "di_stop";
internal static string DO_ES = "do_ES";
internal static string DO_IsRun= "do_IsRun";
internal static string DI_Start = "di_start";//启动程序
internal static string DI_Stop = "di_stop";//停止程序
internal static string DO_ES = "do_ES";//急停状态
internal static string DO_IsRun= "do_IsRun";//机器人程序运行状态
internal static string Do_AutoOn = "do_AutoOn";//是否自动状态
private static NetworkScanner scanner = null;
// private Controller controller = null;
......
......@@ -22,6 +22,7 @@ namespace ABBRobotTest
internal static string Cmd_movep = "movep";
internal static string Cmd_moveget = "moveget";
internal static string Cmd_moveput = "moveput";
internal static string Cmd_validateP = "validateP";
public static Dictionary<string, Client> ClientMap = new Dictionary<string, Client>();
......@@ -29,7 +30,7 @@ namespace ABBRobotTest
public static string LastSendPoint = "";
public delegate void OpEnd(string result);
private static event OpEnd OnMoveEnd;
private static event OpEnd OnCmdEnd;
private static object LockObj = new object();
......@@ -125,43 +126,50 @@ namespace ABBRobotTest
}
else if(msg.Contains(Cmd_movep)&& msg.Contains("OK"))
{
OnMoveEnd?.Invoke(msg);
OnCmdEnd?.Invoke(msg);
}
else if (msg.Contains(Cmd_moveput) && msg.Contains("OK"))
{
OnMoveEnd?.Invoke(msg);
OnCmdEnd?.Invoke(msg);
} else if (msg.Contains(Cmd_moveget) && msg.Contains("ok"))
{
OnMoveEnd?.Invoke(msg);
OnCmdEnd?.Invoke(msg);
}
return false;
}
public static void MoveToP(string robotIp, string PointName, string moveType="L" , double targetSpeed = 100, OpEnd AfterMove = null)
public static void MoveToP(string robotIp, string PointName, string moveType="L" , double targetSpeed = 100, OpEnd AfterCmd = null)
{
ABBRobotServer.OnMoveEnd = AfterMove;
ABBRobotServer.OnCmdEnd = AfterCmd;
SendMovePoint(robotIp, Cmd_movep, PointName,moveType,targetSpeed.ToString());
}
public static void MoveToPut(string robotIp, string PointName, string moveType = "L", double targetSpeed = 100, OpEnd AfterMove = null)
public static void MoveToPut(string robotIp, string PointName, string moveType = "L", double targetSpeed = 100, OpEnd AfterCmd = null)
{
ABBRobotServer.OnMoveEnd = AfterMove;
ABBRobotServer.OnCmdEnd = AfterCmd;
SendMovePoint(robotIp, Cmd_moveput, PointName, moveType, targetSpeed.ToString());
}
public static void MoveToGet(string robotIp, string PointName, string moveType = "L", double targetSpeed = 100, OpEnd AfterMove = null)
public static void MoveToGet(string robotIp, string PointName, string moveType = "L", double targetSpeed = 100, OpEnd AfterCmd = null)
{
ABBRobotServer.OnMoveEnd = AfterMove;
ABBRobotServer.OnCmdEnd = AfterCmd;
SendMovePoint(robotIp, Cmd_moveget, PointName, moveType, targetSpeed.ToString());
}
public static void Move(string robotIp, string moveCmd,string PointName, string moveType = "L", double targetSpeed = 100, OpEnd AfterMove = null)
public static void SendCmd(string robotIp, string moveCmd,string PointName, string moveType = "L", double targetSpeed = 100, OpEnd AfterCmd = null)
{
ABBRobotServer.OnMoveEnd = AfterMove;
if (moveCmd.Equals(Cmd_moveget) || moveCmd.Equals(Cmd_movep) || moveCmd.Equals(Cmd_moveput))
ABBRobotServer.OnCmdEnd = AfterCmd;
if (moveCmd.Equals(Cmd_moveget) || moveCmd.Equals(Cmd_movep) || moveCmd.Equals(Cmd_moveput)||moveCmd.Equals(Cmd_validateP))
{
SendMovePoint(robotIp, moveCmd, PointName, moveType, targetSpeed.ToString());
}
}
private static void SendMovePoint(string robotIp, string param1,string param2,string param3,string param4)
public static void ValidateP(string robotIp, string pointName, OpEnd AfterCmd = null)
{
ABBRobotServer.OnCmdEnd = AfterCmd;
SendMovePoint(robotIp, Cmd_validateP, pointName);
}
private static void SendMovePoint(string robotIp, string param1,string param2,string param3="L",string param4="10")
{
lock (LockObj)
{
......
......@@ -209,6 +209,7 @@
//
// comMoveP
//
this.comMoveP.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comMoveP.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.comMoveP.FormattingEnabled = true;
this.comMoveP.Location = new System.Drawing.Point(136, 130);
......@@ -227,6 +228,7 @@
//
// comMoveCmd
//
this.comMoveCmd.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comMoveCmd.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.comMoveCmd.FormattingEnabled = true;
this.comMoveCmd.Location = new System.Drawing.Point(136, 75);
......
......@@ -36,14 +36,15 @@ namespace ABBRobotTest
comMoveCmd.Items.Add(ABBRobotServer.Cmd_movep);
comMoveCmd.Items.Add(ABBRobotServer.Cmd_moveget);
comMoveCmd.Items.Add(ABBRobotServer.Cmd_moveput);
comMoveCmd.Items.Add(ABBRobotServer.Cmd_validateP);
comMoveP.Items.Clear();
for(int i = 0; i < 30; i++)
for(int i = 1; i <= 30; i++)
{
comMoveP.Items.Add("p" + i);
}
comMoveP.SelectedIndex = 0;
comMoveCmd.SelectedIndex = 1;
comMoveCmd.SelectedIndex = 0;
radioButton1.Checked = true;
......@@ -76,13 +77,13 @@ namespace ABBRobotTest
private void LoadListView()
{
this.listView1.Columns.Clear();
AddHealder("IPAddress", 100);
AddHealder("ID", 80);
AddHealder("IPAddress", 150);
AddHealder("ID", 180);
// AddHealder("设备状态", 100);
AddHealder("Availability", 100);
AddHealder("IsVirtual", 100);
AddHealder("SystemName", 100);
AddHealder("Version", 100);
AddHealder("Availability", 150);
AddHealder("IsVirtual", 150);
AddHealder("SystemName", 150);
AddHealder("Version", 150);
AddHealder("ControllerName", 180);
AddHealder("Statue", 180);
}
......@@ -118,8 +119,7 @@ namespace ABBRobotTest
int esValue = ABBRobotManager.GetSingalState(SelConIp);
if (esValue.Equals(1))
{
lblState.Text = "机器人["+SelConIp+"]急停中";
lblState.ForeColor = Color.Red;
SetMsg("机器人[" + SelConIp + "]急停中", Color.Red);
}
else
{
......@@ -128,11 +128,19 @@ namespace ABBRobotTest
int isRun = ABBRobotManager.GetSingalState(SelConIp, ABBRobotManager.DO_IsRun);
if (isRun.Equals(1))
{
lblState.Text = "机器人程序正常运行中";
lblState.ForeColor = Color.Green;
SetMsg("机器人程序正常运行中", Color.Green);
}
else
{
SetMsg("机器人[" + SelConIp + "]程序未运行", Color.Red);
}
}
}
private void SetMsg(string msg,Color foreColor)
{
lblState.Text = msg;
lblState.ForeColor = foreColor;
}
private void btnStart_Click(object sender, EventArgs e)
{
......@@ -199,7 +207,7 @@ namespace ABBRobotTest
{
speed = 100;
}
ABBRobotServer.Move(SelConIp, moveCmd, PPoint, MType, speed, MoveEnd);
ABBRobotServer.SendCmd(SelConIp, moveCmd, PPoint, MType, speed, MoveEnd);
}
private void MoveEnd(string msg)
{
......
......@@ -121,7 +121,7 @@ namespace OnlineStore.Common
}
private StringBuilder sb = new StringBuilder(); //这个是用来保存:接收到了的,但是还没有结束的消息
private int receiveBufferSize = 1024;
private string terminateString = "\r";
private string terminateString = ";";
public void ReceiveMessages(Client client) //这个函数会被以线程方式运行
{
try
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!