上位机自动获取ABB机器人日志与报警
声明:本媒体部分图片、文章来源于网络,
版权归原作者所有,如有侵权,请与我联系删除。
1.ABB机器人PCSDK提供了丰富的日志接口,比如可以方便的实现如下的自动读取机器人日志功能(即机器人有新日志产生,上位机即可自动获取并更新日志显示)
private void button8_Click(object sender, EventArgs e)
{
EventLog log = controller.EventLog;
EventLogCategory cat;
cat = log.GetCategory(0);
//0表示读取所有日志,具体见CategoryType
this.textBox4.Text = "";
{
foreach (EventLogMessage emsg in cat.Messages)
{
this.textBox4.Text = this.textBox4.Text+emsg.Timestamp+" "+emsg.Title+" "+"\r\n";
//讲每一条日志的时间戳和日志标题写入并显示
}
}
}
private void subscribe_msg()
{
log = controller.EventLog;
log.MessageWritten += new EventHandler<MessageWrittenEventArgs>(msg_WritenChanged);
//添加日志事件触发
}
private void msg_WritenChanged(object sender, MessageWrittenEventArgs e)
{
this.Invoke(new EventHandler(UpdateGUI5), sender, e);
//为了避免界面线程和主线程冲突,采用委托方式
}
private void UpdateGUI5(object sender, System.EventArgs e)
{
this.textBox4.Text = "";
{
cat = log.GetCategory(0);
foreach (EventLogMessage emsg in cat.Messages)
{
this.textBox4.Text = this.textBox4.Text + emsg.Timestamp + " " + emsg.Number+emsg.SequenceNumber+" "+emsg.Title + " " + "\r\n";
//将日志的时间戳,日志代码和日志标题写入
}
}
}
更多资讯:ABB机器人