Commit ad32f0da LN

1

1 个父辈 0fbc88eb
...@@ -14,6 +14,11 @@ namespace ABBRobotTest ...@@ -14,6 +14,11 @@ namespace ABBRobotTest
internal class ABBRobotManager 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";
private static NetworkScanner scanner = null; private static NetworkScanner scanner = null;
// private Controller controller = null; // private Controller controller = null;
private static Task[] tasks = null; private static Task[] tasks = null;
...@@ -24,6 +29,8 @@ namespace ABBRobotTest ...@@ -24,6 +29,8 @@ namespace ABBRobotTest
internal delegate void ControllerAddDelegate(ControllerInfo controller); internal delegate void ControllerAddDelegate(ControllerInfo controller);
internal static event ControllerAddDelegate ControllerAddEvent; internal static event ControllerAddDelegate ControllerAddEvent;
internal static void LoadController() internal static void LoadController()
{ {
controllerMap = new Dictionary<string, Controller>(); controllerMap = new Dictionary<string, Controller>();
...@@ -45,12 +52,31 @@ namespace ABBRobotTest ...@@ -45,12 +52,31 @@ namespace ABBRobotTest
} }
private static void AddControllerInfo(ControllerInfo controllerInfo) private static void AddControllerInfo(ControllerInfo controllerInfo)
{ {
Controller con = ControllerFactory.CreateFrom(controllerInfo); try
con.Logon(UserInfo.DefaultUser); {
ControllerState state = con.State; Controller con = ControllerFactory.CreateFrom(controllerInfo);
controllerMap.Add(con.IPAddress.ToString(), con); con.Logon(UserInfo.DefaultUser);
// controller = con; ControllerState state = con.State;
controllerInfoMap.Add(controllerInfo.IPAddress.ToString(), controllerInfo); string ip = con.IPAddress.ToString();
RemoveController(ip);
controllerMap.Add(ip, con);
// controller = con;
controllerInfoMap.Add(ip, controllerInfo);
}catch(Exception ex)
{
LogUtil.error("添加机器人【" + controllerInfo.IPAddress.ToString() + "】失败:" + ex.ToString());
}
}
private static void RemoveController(string ip)
{
if (controllerInfoMap.ContainsKey(ip))
{
controllerInfoMap.Remove(ip);
}
if (controllerMap.ContainsKey(ip))
{
controllerMap.Remove(ip);
}
} }
private static void HandleLostEvent(object sender, NetworkWatcherEventArgs e) private static void HandleLostEvent(object sender, NetworkWatcherEventArgs e)
{ {
...@@ -58,14 +84,14 @@ namespace ABBRobotTest ...@@ -58,14 +84,14 @@ namespace ABBRobotTest
private static void HandleFoundEvent(object sender, NetworkWatcherEventArgs e) private static void HandleFoundEvent(object sender, NetworkWatcherEventArgs e)
{ {
Invoke(new //Invoke(new
EventHandler<NetworkWatcherEventArgs>(AddControllerToListView), //EventHandler<NetworkWatcherEventArgs>(AddControllerToListView),
new Object[] { null, e }); //new Object[] { null, e });
AddControllerToListView(null, e);
} }
private static void Invoke(EventHandler<NetworkWatcherEventArgs> eventHandler, object[] v) private static void Invoke(EventHandler<NetworkWatcherEventArgs> eventHandler, object[] v)
{ {
throw new NotImplementedException();
} }
private static void AddControllerToListView(object sender, NetworkWatcherEventArgs e) private static void AddControllerToListView(object sender, NetworkWatcherEventArgs e)
...@@ -217,7 +243,33 @@ namespace ABBRobotTest ...@@ -217,7 +243,33 @@ namespace ABBRobotTest
LogUtil.error("ABBRobot[" + ip + "] ResetRobotSignal [" + name + "] Error:" + ex.ToString()); LogUtil.error("ABBRobot[" + ip + "] ResetRobotSignal [" + name + "] Error:" + ex.ToString());
} }
} }
internal static int GetSingalState(string ip, string name = "do_ES")
{
try
{
Controller controller = GetControllerByIP(ip);
if (controller != null)
{
//string name = comboBox1.Text;
Signal singalValue = controller.IOSystem.GetSignal(name);
if (singalValue == null)
{
LogUtil.error("ABBRobot[" + ip + "] GetSingal [" + name + "]= null");
}
else
{
DigitalSignal digitalSig = (DigitalSignal)singalValue;
return (int)digitalSig.Value;
}
}
}
catch (Exception ex)
{
LogUtil.error("ABBRobot[" + ip + "] GetSingalState [" + name + "] Error:" + ex.ToString());
}
return 0;
}
internal static string GetRobotState(string ip) internal static string GetRobotState(string ip)
{ {
try try
......
...@@ -35,16 +35,18 @@ ...@@ -35,16 +35,18 @@
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.btnExit = new System.Windows.Forms.Button(); this.btnMove = new System.Windows.Forms.Button();
this.comMoveCmd = new System.Windows.Forms.ComboBox(); this.radioButton2 = new System.Windows.Forms.RadioButton();
this.label1 = new System.Windows.Forms.Label(); this.radioButton1 = new System.Windows.Forms.RadioButton();
this.numSpeed = new System.Windows.Forms.NumericUpDown();
this.label3 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label();
this.comMoveP = new System.Windows.Forms.ComboBox(); this.comMoveP = new System.Windows.Forms.ComboBox();
this.label3 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label();
this.numSpeed = new System.Windows.Forms.NumericUpDown(); this.comMoveCmd = new System.Windows.Forms.ComboBox();
this.radioButton1 = new System.Windows.Forms.RadioButton(); this.btnExit = new System.Windows.Forms.Button();
this.radioButton2 = new System.Windows.Forms.RadioButton(); this.lblState = new System.Windows.Forms.Label();
this.btnMove = new System.Windows.Forms.Button(); 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();
...@@ -108,6 +110,8 @@ ...@@ -108,6 +110,8 @@
// //
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.btnMove); this.groupMove.Controls.Add(this.btnMove);
this.groupMove.Controls.Add(this.radioButton2); this.groupMove.Controls.Add(this.radioButton2);
this.groupMove.Controls.Add(this.radioButton1); this.groupMove.Controls.Add(this.radioButton1);
...@@ -125,61 +129,38 @@ ...@@ -125,61 +129,38 @@
this.groupMove.TabStop = false; this.groupMove.TabStop = false;
this.groupMove.Text = "运动测试"; this.groupMove.Text = "运动测试";
// //
// btnExit // btnMove
//
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.Name = "btnExit";
this.btnExit.Size = new System.Drawing.Size(108, 46);
this.btnExit.TabIndex = 198;
this.btnExit.Text = "退出";
this.btnExit.UseVisualStyleBackColor = true;
this.btnExit.Click += new System.EventHandler(this.btnExit_Click);
//
// comMoveCmd
//
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, 41);
this.comMoveCmd.Name = "comMoveCmd";
this.comMoveCmd.Size = new System.Drawing.Size(171, 29);
this.comMoveCmd.TabIndex = 0;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(37, 45);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(79, 20);
this.label1.TabIndex = 2;
this.label1.Text = "运动方式:";
//
// label2
// //
this.label2.AutoSize = true; this.btnMove.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label2.Location = new System.Drawing.Point(37, 100); this.btnMove.Location = new System.Drawing.Point(159, 317);
this.label2.Name = "label2"; this.btnMove.Name = "btnMove";
this.label2.Size = new System.Drawing.Size(93, 20); this.btnMove.Size = new System.Drawing.Size(108, 46);
this.label2.TabIndex = 4; this.btnMove.TabIndex = 195;
this.label2.Text = "坐标点名称:"; this.btnMove.Text = "运动测试";
this.btnMove.UseVisualStyleBackColor = true;
this.btnMove.Click += new System.EventHandler(this.btnMove_Click);
// //
// comMoveP // radioButton2
// //
this.comMoveP.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.radioButton2.AutoSize = true;
this.comMoveP.FormattingEnabled = true; this.radioButton2.Location = new System.Drawing.Point(200, 250);
this.comMoveP.Location = new System.Drawing.Point(136, 96); this.radioButton2.Name = "radioButton2";
this.comMoveP.Name = "comMoveP"; this.radioButton2.Size = new System.Drawing.Size(83, 24);
this.comMoveP.Size = new System.Drawing.Size(171, 29); this.radioButton2.TabIndex = 9;
this.comMoveP.TabIndex = 3; this.radioButton2.TabStop = true;
this.radioButton2.Text = "圆弧运动";
this.radioButton2.UseVisualStyleBackColor = true;
// //
// label3 // radioButton1
// //
this.label3.AutoSize = true; this.radioButton1.AutoSize = true;
this.label3.Location = new System.Drawing.Point(37, 155); this.radioButton1.Location = new System.Drawing.Point(63, 250);
this.label3.Name = "label3"; this.radioButton1.Name = "radioButton1";
this.label3.Size = new System.Drawing.Size(51, 20); this.radioButton1.Size = new System.Drawing.Size(83, 24);
this.label3.TabIndex = 6; this.radioButton1.TabIndex = 8;
this.label3.Text = "速度:"; this.radioButton1.TabStop = true;
this.radioButton1.Text = "直线运动";
this.radioButton1.UseVisualStyleBackColor = true;
// //
// numSpeed // numSpeed
// //
...@@ -188,7 +169,7 @@ ...@@ -188,7 +169,7 @@
0, 0,
0, 0,
0}); 0});
this.numSpeed.Location = new System.Drawing.Point(137, 153); this.numSpeed.Location = new System.Drawing.Point(137, 187);
this.numSpeed.Maximum = new decimal(new int[] { this.numSpeed.Maximum = new decimal(new int[] {
500, 500,
0, 0,
...@@ -208,38 +189,82 @@ ...@@ -208,38 +189,82 @@
0, 0,
0}); 0});
// //
// radioButton1 // label3
// //
this.radioButton1.AutoSize = true; this.label3.AutoSize = true;
this.radioButton1.Location = new System.Drawing.Point(63, 216); this.label3.Location = new System.Drawing.Point(37, 189);
this.radioButton1.Name = "radioButton1"; this.label3.Name = "label3";
this.radioButton1.Size = new System.Drawing.Size(83, 24); this.label3.Size = new System.Drawing.Size(51, 20);
this.radioButton1.TabIndex = 8; this.label3.TabIndex = 6;
this.radioButton1.TabStop = true; this.label3.Text = "速度:";
this.radioButton1.Text = "直线运动";
this.radioButton1.UseVisualStyleBackColor = true;
// //
// radioButton2 // label2
// //
this.radioButton2.AutoSize = true; this.label2.AutoSize = true;
this.radioButton2.Location = new System.Drawing.Point(200, 216); this.label2.Location = new System.Drawing.Point(37, 134);
this.radioButton2.Name = "radioButton2"; this.label2.Name = "label2";
this.radioButton2.Size = new System.Drawing.Size(83, 24); this.label2.Size = new System.Drawing.Size(93, 20);
this.radioButton2.TabIndex = 9; this.label2.TabIndex = 4;
this.radioButton2.TabStop = true; this.label2.Text = "坐标点名称:";
this.radioButton2.Text = "圆弧运动";
this.radioButton2.UseVisualStyleBackColor = true;
// //
// btnMove // comMoveP
// //
this.btnMove.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.comMoveP.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnMove.Location = new System.Drawing.Point(159, 283); this.comMoveP.FormattingEnabled = true;
this.btnMove.Name = "btnMove"; this.comMoveP.Location = new System.Drawing.Point(136, 130);
this.btnMove.Size = new System.Drawing.Size(108, 46); this.comMoveP.Name = "comMoveP";
this.btnMove.TabIndex = 195; this.comMoveP.Size = new System.Drawing.Size(171, 29);
this.btnMove.Text = "运动测试"; this.comMoveP.TabIndex = 3;
this.btnMove.UseVisualStyleBackColor = true; //
this.btnMove.Click += new System.EventHandler(this.btnMove_Click); // label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(37, 79);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(79, 20);
this.label1.TabIndex = 2;
this.label1.Text = "运动方式:";
//
// comMoveCmd
//
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);
this.comMoveCmd.Name = "comMoveCmd";
this.comMoveCmd.Size = new System.Drawing.Size(171, 29);
this.comMoveCmd.TabIndex = 0;
//
// btnExit
//
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.Name = "btnExit";
this.btnExit.Size = new System.Drawing.Size(108, 46);
this.btnExit.TabIndex = 198;
this.btnExit.Text = "退出";
this.btnExit.UseVisualStyleBackColor = true;
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
// //
...@@ -281,5 +306,7 @@ ...@@ -281,5 +306,7 @@
private System.Windows.Forms.RadioButton radioButton1; private System.Windows.Forms.RadioButton radioButton1;
private System.Windows.Forms.NumericUpDown numSpeed; private System.Windows.Forms.NumericUpDown numSpeed;
private System.Windows.Forms.Button btnMove; private System.Windows.Forms.Button btnMove;
private System.Windows.Forms.Label lblState;
private System.Windows.Forms.Button btnClearLog;
} }
} }
\ No newline at end of file \ No newline at end of file
...@@ -84,7 +84,7 @@ namespace ABBRobotTest ...@@ -84,7 +84,7 @@ namespace ABBRobotTest
AddHealder("SystemName", 100); AddHealder("SystemName", 100);
AddHealder("Version", 100); AddHealder("Version", 100);
AddHealder("ControllerName", 180); AddHealder("ControllerName", 180);
AddHealder("Statue", 100); AddHealder("Statue", 180);
} }
...@@ -115,6 +115,23 @@ namespace ABBRobotTest ...@@ -115,6 +115,23 @@ namespace ABBRobotTest
{ {
groupMove.Enabled = false; groupMove.Enabled = false;
} }
int esValue = ABBRobotManager.GetSingalState(SelConIp);
if (esValue.Equals(1))
{
lblState.Text = "机器人["+SelConIp+"]急停中";
lblState.ForeColor = Color.Red;
}
else
{
lblState.Text = "";
int isRun = ABBRobotManager.GetSingalState(SelConIp, ABBRobotManager.DO_IsRun);
if (isRun.Equals(1))
{
lblState.Text = "机器人程序正常运行中";
lblState.ForeColor = Color.Green;
}
}
} }
private void btnStart_Click(object sender, EventArgs e) private void btnStart_Click(object sender, EventArgs e)
...@@ -140,7 +157,7 @@ namespace ABBRobotTest ...@@ -140,7 +157,7 @@ namespace ABBRobotTest
if (listView1.SelectedItems != null && listView1.SelectedItems.Count > 0) if (listView1.SelectedItems != null && listView1.SelectedItems.Count > 0)
{ {
int index = listView1.SelectedItems[0].Index; int index = listView1.SelectedItems[0].Index;
string ip = listView1.Items[index].SubItems[0].ToString(); string ip = listView1.Items[index].SubItems[0].Text.ToString();
if (!String.IsNullOrEmpty(ip)) if (!String.IsNullOrEmpty(ip))
{ {
SelConIp = ip; SelConIp = ip;
...@@ -188,5 +205,11 @@ namespace ABBRobotTest ...@@ -188,5 +205,11 @@ namespace ABBRobotTest
{ {
LogUtil.info("机器人运动完成:" + msg); LogUtil.info("机器人运动完成:" + msg);
} }
private void btnClearLog_Click(object sender, EventArgs e)
{
this.richTextBox1.Clear();
LogUtil.ClearLog();
}
} }
} }
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!