RobotStudio event

PCSDK - Eventlog

Hello all,

I have a PC application that among other things need to display the Flexpendant Eventlog. In the past i used the CategoryType method from the Evenlog class, but apparently that method is now Obsolete along with the entire CategoryType class.


The old way..
[Quote]
 private void FillEventList(CategoryType cat)
        {
            EventLog anEventLog = Controller.EventLog;
            EventLogCategory aCategory = anEventLog.GetCategory(cat);
            foreach (EventLogMessage colItem in aCategory.Messages)
            {
               // Take care of the message
            }
        }

[/Quote]

Does anyone have an idea how to do it the new way? Because i have tried using the new method GetCategories(). But this gives me an exception(One of the identified items was in an invalid format.)
[Quote]
 EventLogCategory[] elogcat = Controller.EventLog.GetCategories();
[/Quote]


Kind regards
Daniel

Comments

  • Hi Daniel,
     

    then enumeration of event log categories was made obsolete as part of an extension to RobotWare which made it possible for applications to add their own categories.

     

    However in FlexPendant SDK the enumeration is still there. Probably the "old built in" categories will never change their id number, and in this case the enum could actually be used anyway. And for the dynamic categorieis you have to use the id number.

     

    Currently the PC SDK and FlexPendant SDK handles this situation in a different way.

     

    I've been discussing this with one of our architechts, to decide if the "FP or PC SDK way" is the correct one.

     

    I've been using code like the following as a workaround:

     

    [CODE]

    EventLogCategory
    [] cats = c.EventLog.GetCategories();
    int idRapid;
    foreach (EventLogCategory cat in cats)
    {
    Console.WriteLine(string.Format("Category Id: {0} Localized Name: {1}", cat.Id, cat.LocalizedName));
    if (cat.Name == "RAPID")
    idRapid = idRapid;
    }

    EventLogCategory rapidCat = c.EventLog.GetCategory(idRapid);

    [/CODE]
     
    Do you get exception from EventLog.GetCategories()? Can you send me a code snippet? Which version of PC SDK do you use?

    Best Regards, Niklas Skoglund
    ABB Robotics

    Developer Center
    RobotStudio Blog

  • Hi Niklas,
    I made a small program just for trying the GetCategories(). PCSDK Version 5.13.255.0.

    The following code will cast an FormatException.
    [Quote]
    System.FormatException was unhandled
      Message="One of the identified items was in an invalid format."
      Source="ABB.Robotics.Controllers"
      StackTrace:
           at ABB.Robotics.Controllers.Internal.FileSystem.DemandExceptionFree(FileSystemCmd cmd)
           at ABB.Robotics.Controllers.Internal.FileSystem.PostProcessCmd(FileSystemCmd cmd)
           at ABB.Robotics.Controllers.Internal.FileSystem.EndDownloadFile(IAsyncResult ar)
           at ABB.Robotics.Controllers.Internal.FileSystem.Download(String source, String destination, Boolean overwrite)
           at ABB.Robotics.Controllers.Internal.FileSystem.DownloadToTemp(String source)
           at ABB.Robotics.Controllers.Internal.EventLog.Download(String path)
           at ABB.Robotics.Controllers.Internal.EventLog.DownloadAndParseCategories(String path)
           at ABB.Robotics.Controllers.Internal.EventLog.GetStaticCategories()
           at ABB.Robotics.Controllers.Internal.EventLog.LoadCategories()
           at ABB.Robotics.Controllers.Internal.EventLog.GetCategories()
           at ABB.Robotics.Controllers.EventLogDomain.EventLog.GetCategories()
           at main.Program.Main(String[] args) in C:UsersdacaDesktopmainmainProgram.cs:line 32
           at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
           at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
           at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
           at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
           at System.Threading.ThreadHelper.ThreadStart()

    [/Quote]


    [Quote]
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Text;

    using ABB.Robotics.Controllers;
    using ABB.Robotics.Controllers.Discovery;
    using ABB.Robotics.Controllers.IOSystemDomain;
    using ABB.Robotics.Controllers.FileSystemDomain;
    using ABB.Robotics.Controllers.RapidDomain;
    using ABB.Robotics.Controllers.EventLogDomain;

    namespace main
    {
        class Program
        {
            public static NetworkScanner netScan = null;
            public static ControllerInfo[] ctrlInfo = null;
            public static Controller aController = null;
            public static IOFilterTypes currentFilter = IOFilterTypes.All;
            public static Mastership _Mastership = null;
            public static Rapid rapid = null;
            public static Task task = null;


            static void Main(string[] args)
            {
               aController = RAB_ConnectToRob("AUI_Vaderstad");
               if (aController != null)
               {
                   EventLogCategory[] elogcat = aController.EventLog.GetCategories();

               }
              
            }


            private static Controller RAB_ConnectToRob(string systemnamn)
            {
                NetworkScanner netScan = new NetworkScanner();
                ctrlInfo = netScan.GetControllers();
                foreach (ControllerInfo Info in ctrlInfo){
                    if (Info.SystemName == systemnamn)
                        aController = new Controller(Info);
                }
                return aController;
            }
          
        }
    }

    [/Quote]


    King regards
    Daniel

    Daniel CarlAcn2010-08-25 07:54:57
  • Thank you Daniel, you have found a bug. This has been working fine for me before. Does your code execute on a 64-bit OS?  
    On order to find out which categories exists, PC SDK needs to read an XML file on the controller, and when doing this a exception is thrown. I can see that for example from this line in the callstack:

    [CODE]"at ABB.Robotics.Controllers.Internal.EventLog.Download(String path)"[/CODE]

     

    I recommend that you report this problem to the ABB Robotics support. In the mean time I'll try to reproduce it on my new Windows 7 64-bit machine.

    Best Regards, Niklas Skoglund
    ABB Robotics

    Developer Center
    RobotStudio Blog
  • Hi Niklas,

    Yes, I do have a x64 win7 OS, but the target platform under project properties is x86. I reckon using ANY CPU/x64 will generate even bigger problems. I'm installing VS 2008 on a xp 32bit machine beside me right now to see if the same problem occurs.

    Allright, I will report this to the robotic support. Please contact me if you find a temporary solution Niklas.

    Kind regards
    Daniel


  • Hi again Daniel,
     

    it is correct that the target platform shall be set to x86.

     

    We have found  a similar problems in PC-SDK/Virtual Controller where another method, which needed to "download a file to the FlexPendant" threw a similar exception.

     

    That is not related to the code you are building.

     

    Please go ahead and report all those related problems to support.

    Basically there are two issues, 1) The CategoryType property which is obsolete, throws an exception while being called. 2) When trying my workaround, using GetCategories() you get an exception from that method, probably related to 64-bit OS. 

     

    Besides trying on a 32-bit XP machine you can also try connecting your application to a real  controller if you have one available.

     

     

     

     

     
    Niklas Skoglund2010-08-25 15:48:57

    Best Regards, Niklas Skoglund
    ABB Robotics

    Developer Center
    RobotStudio Blog
  • Hello,

    I'll try and move the entire project to an xp machine, and try to connect to a real robot during next week. If I should get a different result I'll let you know : )

    //Daniel

  • I'm running 32-bit Windows 7 and it seems that EventLog.GetCategories() works, no exception. I will test on a real controller tomorrow.
    Lennart H
  • Hi Daniel,
     

    the problem causing the excpetion on 64-bit machines has been found and fixed. It will be available in PC SDK 5.13.02 which is released in a couple of weeks.

     

    The path to program files includes  "()" on 64 bit OS. --> Program Files (x86).

    The "(" and ")" caused the problem. But I guess renaming your "Program Files (x86)" to for example "Program Files x86", is not a tempting workaround, especially since you do not need to wait long for the fix. 

    Best Regards, Niklas Skoglund
    ABB Robotics

    Developer Center
    RobotStudio Blog