PC SDK How to get RAPID error line number from Controller
Comments
-
If you look on the controller under the RAPID Event log it has this information. I am not sure if you can pull the RAPID Event logs though. When I tried to set this up the RAPID Log files was not one of the enumerated selections. Does anybody know how to pull the RAPID Event logs from the controller?0
-
You use the EventLogMessage class. Here is a short snippet of some PCSDK C# that reads the event log and puts it in a listview.
private void button1_Click(object sender, EventArgs e)
{
EventLogCategory[] _cats = _controller.EventLog.GetCategories();
listView2.Items.Clear();
ListViewItem _item = null;
foreach (EventLogCategory _cat in _cats)
{
foreach (EventLogMessage _msg in _cat.Messages)
{
_item = new ListViewItem(_msg.SequenceNumber.ToString() );
_item.SubItems.Add(_msg.Number.ToString());
_item.SubItems.Add(_msg.Title);
this.listView2.Items.Add(_item);
}}
}Attached find a small non-finished sample that shows the principle and which sorts it correctly...
You need to click the GetErrors button to get whatever is in the controller at the moment, so if something happens you need to click it again. You can easily solve such by implementing the MessageWritten eventlog event:
http://developercenter.robotstudio.com:80/Index.aspx?DevCenter=RobotCommunication&OpenDocument&Url=../RobotCommunicationAppManual/doc38.html&OptTitle=Developing Controller applications
Dude said:does anybody know how to get from the controller the line number of the RAPID error using PC SDK? When I load my program in I want to know if the controller has a error and on what line number it is.
John
Developer Center0 -
John,
Thanks for the response. I am able to pull the event logs in now, the problem is that I don't see a way to get the RAPID event logs. When you look on the Teach Pendant under the event logs there is a category for RAPID and this event log gives you the line number of the problem with the program or module that you just loaded. So I am loading a program into the controller and I forgot to add a ";" after a call to a routine. I would like to be able to pull from the controller RAPID event log the error that is generated so I know what line in the program I forgot to add the ";". Unless you know a better way to get from the controller the errors you have with the program or module that you just loaded. Thanks again for your response.
�0 -
John,
Let me ask it another way. How can I get from the controller what Error it has in the RAPID program? Which Module has a error and what line number that error is on?
�0 -
Ah, that event. Like this right?
That is unfortunately impossible to get. It is not stored anywhere. Its hidden in RobotWare somewhere so even when RobotStudio handles a Virtual Controller we can't display it.
What you get instead is a generic "40160 Errors in RAPID Program", but it doesn't give you the module or line number or anything. But at least it lets you track when it happened.
If you have problems with unauthorized editing or somesuch I'd recommend looking into User Authentication System, this so that you can have a different login for the Edit rights.
I've also seen a solution where they put a system signal on when the controller goes into manual, you'd get a prompt to write in why and then it would take a copy of the program modules to the Home directory. But that has its own issues.
John
Developer Center0 -
John,
There must be a way to do this, RobotStudio is doing this somehow. It shows the message with this information in Output tab at the bottom. I am going to guess that it is part of the API that we as developers do not have access to?
�0 -
just to add to this...if you have a error in your program and you reboot the controller. When the controller starts up the error gets logged to the RAPID Event log. This error that gets logged does have the module line and col number in the body of the event log. The problem is that it would not be very good to reboot the controller every time you load a program to check if it has errors. So if the controller does this check at boot time, maybe there would be a way to trigger this check after you load a program? Which raises another question why does the controller log this error to the RAPID Event log on boot up, but not when the program is loaded?
�0 -
some more information for this topic! The event that gets logged to the RAPID Event log does not stay. What I mean is, If you fix the error and then reboot again the error is no longer in the RAPID Event Log? I would think that it would stay no matter what like the other event logs?
�0 -
I will ask R&D about why it behaves like that in RobotWare.
But I'm pretty sure RobotStudio doesn't handle this in any way different than the controller does, so anything RobotStudio can get out we should be able to get out as well using the SDKs. So exactly in which situation did you get that info in the Output tab which wasn't stored in the EventLog?
When I did it with the error in the screen above RobotStudio specificly didn't get any extra info to show - it was just the generic 40160.
John
Developer Center0 -
John,
I have Attached a picture of RobotStudio with the message in the Output tab after clicking on the Check Program button at the top.
�0 -
The RAPID syntax error and link error messages piggy backs on the "message format system" used by the EventLog. So it looks like an event log message. Maybe we can simplify things and say it is an event log message, but that is temporary to its nature.As the message says in the the FlexPendant screenshot: "This message will not be stored in any eventlog"... unfortunately that is correct, and that is the reason you cannot retrieve it from the PC SDK APIs to the the eventlog.What you have found in the RobotStudio output window is not really an eventlog line, but our presentation of the "build error list" from the RAPID subsystem in the controller.When you load a module in RobotStudio with an error, you get this message in the output window, which is a real eventlog message:40322: Load errorDescriptionTask T_ROB1: RAPID syntaxerror(s) in fileActionsThe source file to be loaded containsRAPID syntax errors. Correct the sourcefile.The FlexPendant behaves differently and displays the "temporary" eventlog message with type of error and line number.When you use the "Check Program" function in RobotStudio we makes a call to the controller and asks it to compile RAPID, and from that call we get a collection of errors (and those errors are formated as eventlog messages.What you would need is a way to make this check program call to the controller via PC SDK... I think.0
-
So do you know how to get the PC SDK to make the Check Program Call? I have been looking through the PC SDK documentation and cannot find anything that would do this, but that does not mean that it is not there.
�0 -
Hi again David, sorry if I answered a bit cryptic.There is no way to get the error collection in PC SDK. RobotStudio's implementation, as I referred to, uses a lower level API to the controller. Not everything is exposed in PC SDK.I agree this would be good to have.We have a category on the forum called UpFeed where you are welcome to make a post and suggest a new feature and describe how you would like it to work, and why it would be valuable.This may be a candidate.Would you it be good enough to get a collection of error lines as strings, that you can display in a listbox, or do you plan to programmatically access or parse details about the error, such as the name of an "unexpected identifier"?0
-
Hi Niklas thanks for the clarification. Yes a String array of the line number errors would be great. If not a array of strings then just the first error line number as a string that it found. But if I could get a string array of the Task, Module, Line number, Column and description of what was wrong that would be awesome!!!!! I will post to that forum my suggestion.
�0 -
Hmh... I think I was a bit too optimistic. As far as I now remember only the first error is returned by the controller. Sorry. So lets focus on the content in that item being returned. Then whether it is an array or not is an orthogonal question.0
Categories
- All Categories
- 5.5K RobotStudio
- 395 UpFeed
- 18 Tutorials
- 13 RobotApps
- 297 PowerPacs
- 405 RobotStudio S4
- 1.8K Developer Tools
- 249 ScreenMaker
- 2.7K Robot Controller
- 310 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