How can I access a variable in a subprogram from my c++ application?

  • Hello,


    I've developed an application in VC++2005 that allow me to read and write variables in the robot controller.


    As an example, I have a function that is called CString GETVALUE(CString csVarName), that is called when I want to read one value.


    If I call it passing this string "$MODE_OP" I get the current mode op value as a CString.


    I would like to know how should I pass the Cstring parameter in order to read for example a variable inside the program TEST.SRC that is called TESTVAR.


    Thank you in advance.

  • Schritt für Schritt zum Roboterprofi!
  • I've declared this in the .DAT file of one selected program:


    BOOL m_bContinueWorking


    And I cannot access it...



    Thank you for your feedback!

  • Well! I've declared it as global and started working...


    GLOBAL BOOL b;


    And then I can read "b".


    Thank you! I've missed the fact that declaring in the .DAT makes it global for the entire .SRC file, but this don't mean that the variable would be global for the system.


    By the way, I must check if making all the variables global would have any drawback, do you know if there is any way of reading those values if the variable is not global?


    Thank you again.

  • Hello,


    acces to local variables should be possible after setting the datapath:
    e.g. $DATAPATH[]="/R1/TEST.DAT"


    I think in latest versions it is also possible to use the path inside the showvar command.
    e.g. "/R1/TEST.DAT/Testvar"


    Good luck
    DiDi

  • That would be great, but do this DATAPATH would affect anything into the robot behaviour or only affects the way Visual C++ will be able to communicate to the robot?


    THANK YOU!

  • Hi Joan,


    sorry for not answering, but instead bringing up some questions:


    Is your C++ program running on the robot controller?


    Where did you find documentation about the API you are using, or which headers did you include?


    Any information is welcome.


    Thanks a lot
    Dirk

  • Don't worry!


    My program is running on the robot controller.


    I've not found any documentation, I've had to make it all by myself, the people on kuka Spain did not know how to do it in VC++. they had done it in VB. And the people in kuka Germany told me that they don't give support for this kind of thing, that they could do it for me and then of course get a big amount of money for it. I did not wanted to go that way because then at my customer enterprise I would not be able to make any change and I would need to wait for KUKA guys to make any modification that could be needed.


    In fact, I've used the file cross3krc.cie and import it, it has generated for me automatically the files.tlh and .tli. It has been exact as importing a .TLB (#import "path+file.tlb").


    I'm using the intelligent COM pointers to the interface to get the service in order to be able to use the raw_showvar and raw_setvar methods.


    PS: opening that CIE file using the oleviewer from microsoft will help you to see the functions and methods available for taht interface.


    Hope this helps.

  • Hi Joan,


    thanks a lot for your information. That sounds like a lot of work you did! :grinser043:


    Of course now I have some more questions: Are you running VS 2005 on the robot controller? Does that make debugging possible? Or do you compile on another machine and transfer the program?


    Thanks again!


    Greetings from rainy germany,
    dirk

  • I don't know if I want to answer you... ;)


    I'm not running the Visual Studio on the robot controller, it would not run there due to the limited resources that the robot computer has.


    I'm working with VC++2005 and I compile it in another machine (not in the robot controller computer). I'm working on one machine with the OFFICE LITE installed, and in this way I can test everything. I could also make a remote debugging, but I preferred the first method, easier and for a simple application like mine in which I have had only to read and store 30-40 values it has not been a very big deal.


    Hope this helps.

  • I'm using the V5, but it should work also with the old one, at the beggining I used the V4 and the names of the routines available in the .CIE file where the same.


    Hope this helps.

  • Ouch!


    excuse me! I had installed the 4.x version there, but now I have also the 5.x version.


    You should be able to download that application from KUKA and install it, even if you don't register it you'll be able to find the file in the specified folder and use it without any problem.


    If you cannot find it in the kuka servers, or after speaking with your technical support, I can send it to you by mail.


    Another solution that you can try is to use the Cross.ocx control, it makes more or less the same.


    Hope this helps.

  • Morning, I'm not familiar with CIE or TLB file or COM service. sorry!
    I'm at the beginnig to write my own application in C++ to load an SRC file and read a variable.
    My question is:


    1. How use in C++ the cross3Krc.CIE? Have you got some code example? I try to make an Import but not work..
    I've no idea how to use it.


    2. After import how can I call for example a ShowVar?


    Thank you..


    Ulisse

Erstelle ein Benutzerkonto oder melde dich an um zu kommentieren

Du musst ein Benutzerkonto haben um einen Kommentar hinterlassen zu können

Benutzerkonto erstellen
Neues Benutzerkonto für unsere Community erstellen. Geht einfach!
Neues Benutzerkonto erstellen
Anmelden
Du hast bereits ein Benutzerkonto? Melde dich hier an.
Jetzt anmelden