Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

problems with create_online_application

dblessin
2015-07-20
2015-07-21
  • dblessin - 2015-07-20

    Hello,
    I use a script on different PC's. Since last week I've got an error on one of the PC's

    A Message box says line 173 object is no applicationobject. I checked the script on different PC's, only one has this error.

    codesys script protocol is:
    (172): app = proj.active_application
    (173): onlineapp = online.create_online_application(app)
    (173): Ausnahmefehler (<type 'exceptions.valueerror'="">, ValueError('Das angegebene Objekt ist kein Applikationsobjekt!',), <traceback object="" at="" 0x000000000000002c="">)
    (173): onlineapp = online.create_online_application(app)
    CoDeSysScript.py(173): Ausnahmefehler (<type 'exceptions.valueerror'="">, ValueError('Das angegebene Objekt ist kein Applikationsobjekt!',), <traceback 0x000000000000002d="" object="" at="">)
    (173): onlineapp = online.create_online_application(app)
    (173): Rückgabe von Skript
    (173): onlineapp = online.create_online_application(app)</traceback></type></traceback></type>

    In the script:
    Line
    172 app = proj.active_application
    173 onlineapp = online.create_online_application(app)
    like lots of examples here in the Forum...

    I checked the script that 'proj' is defined, that the path to the Codesys Project is the same, that all Options in codesys are identicall, but there must be a difference, but I've got now idea by now and I wasn't able to find something similar in the Forum.

    Has anyone had the same Problem or an idea how to solve it?

    best regards,
    daniel

     
  • Anonymous - 2015-07-20

    Originally created by: M.Schaber

    Hi,

    could you provide us with the typeguid of the object?

    app = proj.active_application
    print(app.type)
    print(repr(app.embedded_object_types)
    
     
  • dblessin - 2015-07-20

    I'm not quite sure what you mean, the next uses in the code are:

    \# setze Projekt als aktive Applikation
        app = proj.active_application
        onlineapp = online.create_online_application(app)
    \# Code in IEC importieren
        if (loadoption & PLCLOADOPTION_IMPORT) != 0:
            ImportCodeInIEC(proj, app);
    ...
    \# Einloggen
        if (loadoption & PLCLOADOPTION_ONLINECHANGE) != 0:
            onlineapp.login(OnlineChangeOption.Force, True)
        else:
            onlineapp.login(OnlineChangeOption.Never, True)
    
     
  • Anonymous - 2015-07-20

    Originally created by: M.Schaber

    I wanted you to share with us the output of the print statements, so we know the type guid (and possibly embedded object guids) of the object in question.

     
  • dblessin - 2015-07-20

    with the modified code

    171 # setze Projekt als aktive Applikation
    172    app = proj.active_application
    173    print(app.type)
    174    print(repr(app.embedded_object_types))
    175    onlineapp = online.create_online_application(app)
    

    I get the Output

    (172):     app = proj.active_application
    (173):     print(app.type)
                    225bfe47-7336-4dbc-9419-4105a7c831fa
    (174):     print(repr(app.embedded_object_types))
                    Array[Guid](())
    (175):     onlineapp = online.create_online_application(app)
    (175): Ausnahmefehler (<type 'exceptions.ValueError'>, ValueError('Das angegebene Objekt ist kein Applikationsobjekt!',), <traceback object at 0x000000000000002C>)
    (175):     onlineapp = online.create_online_application(app)
    (175): Ausnahmefehler (<type 'exceptions.ValueError'>, ValueError('Das angegebene Objekt ist kein Applikationsobjekt!',), <traceback object at 0x000000000000002D>)
    (175):     onlineapp = online.create_online_application(app)
    (175): Rückgabe von Skript
    (175):     onlineapp = online.create_online_application(app)
    

    is that what you Need?

     
  • Anonymous - 2015-07-20

    Originally created by: M.Schaber

    Hi, dblessin,

    yes, that's exactly what I need.

    it seems that the guid you give is the type guid of the device object (which clearly is no application object).

    However, I'm not sure how this could happen on a specific machine, as you wrote.

    At this place, the scripting API just uses the underlying Automation Platform API.

    Is this only happening on a specific project, or on all projects you process on the affected PC?

    Do the same projects work fine on other PCs?

    Which application is shown as the active one (it's displayed in bold)?

    What happens if you open the projects, set the active application to a valid application object via context menu, and save them - do the scripts work fine then?

     
  • dblessin - 2015-07-20

    Hi Mr. Schaber,

    that was the hint I needed, I don't know how this could happen, cause I use two PC's and on both I loaded the Project this morning from source safe. But on the machine with the Problem there was no active application defined (No Application found, Parametername: stApplication). After I set one of the devices to active application everything went quite well.
    That's the reason why it only happend on this PC. I haven't tested it with other Projects, but I'm sure it was the Problem of the not defined active application.
    Is ther an example for changing the active application or the used device in a Project using a python script?

     
  • Anonymous - 2015-07-20

    Originally created by: M.Schaber

    Hi,

    you can just set the active application by finding the application object in the script, and then assigning it to proj.active_application.

    app = proj.find('myapplication', true)[0]
    proj.active_application = app
    
     
  • dblessin - 2015-07-21

    Hi Mr. Schaber,

    it works, thank you.

     

Log in to post a comment.