Records and Arrays Fault PCSDK
Dear All,
Some questions around accessing Arrays and RECORDS under PCSDK,
Using this piece of code returns errors both for arrays
And on records as Value is <undefined value>.
Note that the same way to access the data works fine on GTPU and that access is made to Virtual IRC5 from RS5.
Thanks for comments,
Best Regards,
Laurent Businaro
The code used
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using ABB.Robotics;
using ABB.Robotics.Controllers;
using ABB.Robotics.Controllers.Discovery;
using ABB.Robotics.Controllers.RapidDomain;
using TestPCSDK.DataClass;
namespace TestPCSDK
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.ListView listView1;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.ColumnHeader Avail;
private System.Windows.Forms.ColumnHeader Host;
private System.Windows.Forms.ColumnHeader Id;
private System.Windows.Forms.ColumnHeader Ip;
private System.Windows.Forms.ColumnHeader Virtual;
private System.Windows.Forms.ColumnHeader _Name;
private System.Windows.Forms.ColumnHeader Version;
private NetworkScanner ns;
private Controller ctrl;
private System.Windows.Forms.TextBox textBox1;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
if (this.ctrl != null)
{
this.ctrl.Logoff();
this.ctrl.Dispose();
this.ctrl = null;
}
if (this.ns !=null)
this.ns=null;
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.listView1 = new System.Windows.Forms.ListView();
this.Avail = new System.Windows.Forms.ColumnHeader();
this.Host = new System.Windows.Forms.ColumnHeader();
this.Id = new System.Windows.Forms.ColumnHeader();
this.Ip = new System.Windows.Forms.ColumnHeader();
this.Virtual = new System.Windows.Forms.ColumnHeader();
this._Name = new System.Windows.Forms.ColumnHeader();
this.Version = new System.Windows.Forms.ColumnHeader();
this.panel1 = new System.Windows.Forms.Panel();
this.textBox1 = new System.Windows.Forms.TextBox();
this.panel1.SuspendLayout();
this.SuspendLayout();
//
// listView1
//
this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.Avail,
this.Host,
this.Id,
this.Ip,
this.Virtual,
this._Name,
this.Version});
this.listView1.FullRowSelect = true;
this.listView1.GridLines = true;
this.listView1.Location = new System.Drawing.Point(0, 8);
this.listView1.Name = "listView1";
this.listView1.Size = new System.Drawing.Size(640, 64);
this.listView1.TabIndex = 0;
this.listView1.View = System.Windows.Forms.View.Details;
this.listView1.DoubleClick += new System.EventHandler(this.Lv_DblClick);
//
// Avail
//
this.Avail.Text = "Avail";
this.Avail.Width = 95;
//
// Host
//
this.Host.Text = "Host";
this.Host.Width = 73;
//
// Id
//
this.Id.Text = "Id";
this.Id.Width = 69;
//
// Ip
//
this.Ip.Text = "Ip";
//
// Virtual
//
this.Virtual.Text = "Virtual";
//
// _Name
//
this._Name.Text = "Name";
//
// Version
//
this.Version.Text = "Version";
this.Version.Width = 218;
//
// panel1
//
this.panel1.BackColor = System.Drawing.Color.PaleGoldenrod;
this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.panel1.Controls.Add(this.textBox1);
this.panel1.Location = new System.Drawing.Point(0, 80);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(640, 176);
this.panel1.TabIndex = 1;
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(80, 40);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(400, 20);
this.textBox1.TabIndex = 0;
this.textBox1.Text = "textBox1";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(642, 263);
this.Controls.Add(this.panel1);
this.Controls.Add(this.listView1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.Name = "Form1";
this.Text = "NetWork Scanning Window";
this.Load += new System.EventHandler(this.load);
this.panel1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void load(object sender, System.EventArgs e)
{
ns = new NetworkScanner();
this.ns.Scan();
ControllerInfoCollection controllers = ns.Controllers;
foreach( ControllerInfo controller in controllers )
{
ListViewItem item = new ListViewItem( controller.Availability.ToString() );
item.SubItems.Add(controller.HostName);
item.SubItems.Add(controller.Id);
item.SubItems.Add(controller.IPAddress.ToString());
item.SubItems.Add(controller.IsVirtual.ToString());
item.SubItems.Add(controller.SystemName);
item.SubItems.Add(controller.Version.ToString());
this.listView1.Items.Add(item);
item.Tag = controller;
}
}
private void Lv_DblClick(object sender, System.EventArgs e)
{
ListViewItem item = this.listView1.SelectedItems[0];
if (item.Tag != null)
{
ControllerInfo controllerInfo = (ControllerInfo) item.Tag;
if (controllerInfo.Availability != Availability.Available)
{
return;
}
if (this.ctrl != null)
{
this.ctrl.Logoff();
this.ctrl.Dispose();
this.ctrl = null;
}
this.ctrl = ControllerFactory.CreateFrom(controllerInfo);
this.ctrl.Logon(ABB.Robotics.Controllers.UserInfo.DefaultUser);
CallSampleCode();
}
}
private void CallSampleCode()
{
//using (Mastership m = Mastership.Request(ctrl.Rapid))
//{
RapidData rd = ctrl.Rapid.GetRapidData("T_ROB1", "MYMOD", "TESTDATA");
if (rd != null)
{
try
{
this.textBox1.Text=rd.Value.ToString();
}
catch (GeneralException gex)
{
throw new ApplicationException("Get value from controller not successful", gex);
}
catch (Exception ex)
{
throw new ApplicationException("Other general exception", ex);
}
finally
{
rd.Dispose();
}
}
//}
}
}
}
Comments
-
Laurent,
I noticed 2 things with the code.
1. You use a STAThread attribute instead of MTAThread. This affects how well the RobAPI objects work with .NET Framework.
2. Observe that the array elements are separated using the comma sign: Decimal Symbol on your computer has to be point. This depends on your local language, so maybe you have to change this on your PC.
Best regards,
Urban Vikblom
CONTAB0 -
Hi Urban,
Thanks for the suggestion, unfortunately no success. I have changed to MTAThread and checked I was using . as a Decimal symbol.
I have even changed my region to English UK or English US without success.
If the situation is in relation with the regional settings, I do not see what is more to be changed.
In addition, the decimal symbol is OK as if I read reg1 with a decimal value like 0.225, everything works fine.
Further help?
Best Regards,
Laurent
0 -
Oops, forgot to inform that non atomic standard data are correctly reported like robtargets.
BR
Laurent
0
Categories
- All Categories
- 5.5K RobotStudio
- 394 UpFeed
- 18 Tutorials
- 13 RobotApps
- 297 PowerPacs
- 405 RobotStudio S4
- 1.8K Developer Tools
- 249 ScreenMaker
- 2.7K Robot Controller
- 309 IRC5
- 59 OmniCore
- 7 RCS (Realistic Controller Simulation)
- 785 RAPID Programming
- AppStudio
- 3 RobotStudio AR Viewer
- 18 Wizard Easy Programming
- 105 Collaborative Robots
- 4 Job listings