How can I read from running robot with the C#? From RobotStudion/controller.

How can I read from running robot with the C#? From RobotStudion/controller. I can connect to it but I can not read from it. I would like to read some information with C# when it’s running - which program is running, logs, errors.

Hi,
you have to use the PC-SDK.

Detailed information and tutorials could be found on the following web site:
http://developercenter.robotstudio.com/pcsdk/gettingstarted

BR
Micky

The things which you are wanting to see are available from robotstudio if you connect it to the controller.

Thanks Micky.
How can I read logs? Can you help me out with this? Which class/methods I should use?
I’m an entry level with the C#, I’ll apritiate

Hello Eugene

you will find detailed description in the API reference at the follwoing link:
http://developercenter.robotstudio.com/pcsdk/api_reference

Follow the menu on the left side → Manual / using the PC SDK / Event log domain

The event log is descibed in the API reference in the following namespace “ABB.Robotics.Controllers.EventLogDomain

On this website you will fond source code examples and tutorials and small Visual Studio projects

Regards
Micky

Thanks Micky.
How can I read logs? Can you help me out with this? Which class/methods I should use?
I’m an entry level with the C#, I’ll apritiate

Thanks Micky.
How can I read logs? Can you help me out with this? Which class/methods I should use?
I’m an entry level with the C#, I’ll appreciate any help.

Mike,
How can I use EventLog class from ABB.Robotics.Controllers.EventLogDomain namespace to print all or some events from the controller which was found on the network with the NetworkScanner?

Hi,

enclosed you will find an example how to read all elogs from a connected controller and shows the error number and the title in a list view.

You have to connect and login to the connected controller (_ctrl) before you could read the elogs.
It is also possible to read only one category instead of all. In this case you have to user the methode “.GetCategory(CategoryType.Common);” to read only the commen elogs

private void ReadELogAll()
{
EventLog log = _ctrl.EventLog;

lsvELog.Items.Clear();

var categories = log.GetCategories();
foreach (var cat in categories)
{
foreach (EventLogMessage emsg in cat.Messages)
{
var item = new ListViewItem((emsg.CategoryId * 10000 + emsg.Number).ToString());
item.SubItems.Add(emsg.Title);

lsvELog.Items.Add(item);
}
cat.Dispose();
}
}

Mike,
Thank you for your response.
Questions.
In your code isvELog.Items.Clea(); - What is a isvELog? Is it an object of the class? I have an error on it.

var item = new ListViewItem((emsg.CategoryId * 10000 + emsg.Number).ToString()); - What is ListViewItem? I have an error on it. Is it an object of the class? I have an error on it.

Thank you so much for your help.

Eugene

Hi,

lsvELog is an instance of a listview for windows forms
this.lsvELog = new System.Windows.Forms.ListView();

See documentation: https://msdn.microsoft.com/en-us/library/system.windows.forms.listview(v=vs.110).aspx

ListViewItem is an item element of the list view and an instance of the folliwng class System.Windows.Forms.ListViewItem

See documentation
https://msdn.microsoft.com/en-us/library/system.windows.forms.listviewitem(v=vs.110).aspx

You could remove the listview related stuff and show the data from the elog collection where ever you want.

Br
Micky

Micky,

You know how can I pull info from the controller about which module is started running and when it started and stopped?

Micky,

At this point, I’m trying to print everything on the console, not using windows form. So I can see how it’s working, and after that, I will start exploring further.
How can I print on the console app?

I really appreciate your help Micky.

Eugene

Micky,
I think I figured it out.
I have another question.
How can I pull info from the controller about which module is started running and when it started?

Thank you very much,

Hello Eugene,

here is a program example which give you all the requested answers:

private static void RobotTest(ControllerInfo ctrlinfo)
{
_ctrl = ControllerFactory.CreateFrom(ctrlinfo);

//Login to the controller
_ctrl.Logon(UserInfo.DefaultUser);
System.Console.WriteLine(“Login as ‘Default User’”);

Console.WriteLine(“Operating mode: \t” + _ctrl.OperatingMode.ToString());
Console.WriteLine(“State:\t\t\t” + _ctrl.State.ToString());
Console.WriteLine(“Execution status:\t” + _ctrl.Rapid.ExecutionStatus.ToString());

Console.WriteLine(“”);
if (_ctrl.Rapid.ExecutionStatus == ExecutionStatus.Running)
Console.WriteLine(“Program is running”);

if (_ctrl.Rapid.ExecutionStatus == ExecutionStatus.Stopped)
Console.WriteLine(“Program is stopped”);

Console.WriteLine(“”);
//Book events to get info if an status changes
_ctrl.OperatingModeChanged += _ctrl_OperatingModeChanged;
_ctrl.StateChanged += _ctrl_StateChanged;
_ctrl.Rapid.ExecutionStatusChanged += Rapid_ExecutionStatusChanged;

using (ABB.Robotics.Controllers.RapidDomain.Task tsk = _ctrl.Rapid.GetTask(“T_ROB1”))
{
//Use event for program pointer changed to get the information which routine is executed
tsk.ProgramPointerChanged += Tsk_ProgramPointerChanged;

//Position of the program pointer
var pp = tsk.ProgramPointer;
Console.WriteLine(“Program pointer: \t\tModule: {0}, Routine: {1}”, pp.Module, pp.Routine);
Console.WriteLine(“”);

Console.ReadLine();
}
}

private static void Tsk_ProgramPointerChanged(object sender, ProgramPositionEventArgs e)
{
Console.WriteLine(“Tsk_ProgramPointerChanged: \tModule: {0}, Routine: {1}”, e.Position.Module, e.Position.Routine);
Console.WriteLine(“”);
}

private static void Rapid_ExecutionStatusChanged(object sender, ABB.Robotics.Controllers.RapidDomain.ExecutionStatusChangedEventArgs e)
{
Console.WriteLine(“Rapid_ExecutionStatusChanged: \t” + e.Status.ToString());
Console.WriteLine(“”);
}

private static void _ctrl_StateChanged(object sender, StateChangedEventArgs e)
{
Console.WriteLine(“_ctrl_StateChanged: \t\t” + e.NewState.ToString());
Console.WriteLine(“”);
}

private static void _ctrl_OperatingModeChanged(object sender, OperatingModeChangeEventArgs e)
{
Console.WriteLine(“_ctrl_OperatingModeChanged: \t” + e.NewMode.ToString());
Console.WriteLine(“”);
}

/BR
Micky

Micky,
Thank you so much for all your help.
Maybe you can help me with this too.
With pc sdk on the windows form - how can I give an operator option to select the program to run? I know it must be associated with PartData. How can I set up this?
And another one. How can I make TPReadFK or UIMsgBox with pc sdk on the windows form to inform operators about something, and give them the option to select from?

With your help, I start to understand/learn little by little pc sdk.
Thank you Micky.

Question 1: th pc sdk on the windows form - how can I give an operator option to select the program to run? I know it must be associated with PartData.

I assume you are http:// using the option “Production Manager” because its uses the partdata.
As you should know from the manual, you could define a plc interface in the PROC.CFG of the robot.
That means, you could use a group input for the program number and an input as start signal to select a partdata for executing.

  1. Define a virtual group input with Access level “ALL” in the EIO.CFG
  2. Defina a virtual digital input with Access level “ALL” in the EIO.CFG
  3. Assign the signal name of the group input as “PLC group in signal” in the PROC.CFG (Production Manager ApI Commands)of the “Production Manager” System parameter
  4. Assign digital input as start signal “RunPart in signal” in the PROC.CFG (Production Manager ApI Commands) of the “Production Manager” System parameter
  5. Define partdata mit valid program numbers in your program.

Pleaser refer the manual of the “Production Manager” (chapter 4.1.4, page 64) or the manual “Systemparameters” if you need additional help
http://isa.uniovi.es/~jalvarez/abb/en/3HAC024844-001_revG_en.pdf

  1. In your PC program you search all “partdata” declaration in the robot controller task (e.g. “T_ROB1”) by using the method “SearchRapidSymbol”
    You will find a example on the following website
    http://developercenter.robotstudio.com/blobproxy/devcenter/RobotCommunication/html/98dec265-6047-4e5c-932c-c9df1c903b10.htm

  2. You create a RapidData for each found rapid symbol in the array. Use the scope array to get the task, module and data name.

  3. Read the userdefined data (partdata) from the RapidData, see examples on following website:
    http://developercenter.robotstudio.com/blobproxy/devcenter/RobotCommunication/html/909ec106-fa38-4b26-b72e-e71af27fed25.htm

  4. Read the description of the partdata and the program code from the user defined data

  5. If you are use a listview to present your data to the customer add the text in the “item.Text” and the program number in the “item.tag” property

  6. If user selects an item in the list view, get the program number from the tag property of the selected item and cast it to an unsigned integer value (uint)

  7. Set the program number to previously created virtual group input signal
    See manual on the following website http://developercenter.robotstudio.com/blobproxy/devcenter/RobotCommunication/html/455b4712-8d1d-499b-90ef-72a2e4209563.htm

  8. Set the digital signal “RunPart” to 1.

  9. If program of the robot is not running you must start it

  10. Your selected partdata program on the robot should start running.

Do not forget to dispose all RapidSymbol, RapidData and Signal as you do not need it any longer.

Question: How can I make TPReadFK or UIMsgBox with pc sdk on the windows form to inform operators about something, and give them the option to select from?

Please read the following description on the
http://developercenter.robotstudio.com/blobproxy/devcenter/RobotCommunication/html/ae435101-731d-4fb3-be77-96e70b9aff19.htm

Thanks Micky
I will try this.

Micky,
Can I do all of those Production Manager ApI Commands inside RobotStudio?