CODESYS - the IEC 61131-3 automation software

Welcome to the official CODESYS Forum by 3S-Smart Software Solutions GmbH | A member of the CODESYS Group
Deutsche Version English version russian version 
It is currently Mon Sep 16, 2019 4:17 pm

All times are UTC+01:00




Post new topic  Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Mon Apr 16, 2012 9:35 am 
Offline

Joined: Tue Oct 04, 2011 10:13 am
Posts: 80
Does CoDeSys provide the possibility to set the gateway (e.g. IP number) and scan the network for devices, by python script.

In the examples, I see no gateway IP number at all. While in the GUI, I have to select a gateway and set the active path.
e.g.
# set "Python.project" to active application
app = proj.active_application
onlineapp = online.create_online_application(app)
# login to device
onlineapp.login(OnlineChangeOption.Try, True)

The goal is to give a script two parameters (project name and gateway IP number). And that script would download the project to that device. (The project itself does not contain the gateway information.)


Top
   
PostPosted: Mon Apr 16, 2012 10:27 am 
Offline
Frequent User
Frequent User
User avatar

Joined: Fri Mar 18, 2011 4:12 pm
Posts: 266
Hi, Edwin,

Edwin wrote:
Does CoDeSys provide the possibility to set the gateway (e.g. IP number) and scan the network for devices, by python script.

In the examples, I see no gateway IP number at all. While in the GUI, I have to select a gateway and set the active path.
e.g.
# set "Python.project" to active application
app = proj.active_application
onlineapp = online.create_online_application(app)
# login to device
onlineapp.login(OnlineChangeOption.Try, True)

The goal is to give a script two parameters (project name and gateway IP number). And that script would download the project to that device. (The project itself does not contain the gateway information.)

For scripts, device Objects have the following methods:

Code:
get_gateway() # Returns the Guid of the Gateway
get_address() # Returns the device address as a string.
set_gateway_and_address(gateway, address) # Sets the gateway and address for this device. (gateway can be a Guid object or the string representation of a Guid.)

So you can set the gateway and address CoDeSys uses to connect to a specific device, the "active path". The adress here is the CoDeSys address (like "[011D.8001.9ED4]") and not an IP address, as it has to cover routing through several cascaded field busses.

Sadly, the Guid is not yet displayed anywhere in the UI. The easiest way to get the Guid for a Gateway currently is to set the active path of a device to that gateway, and then dump it via "print projects.primary.find("name_of_device", True)[0].get_gateway()" in a script.

It is not yet possible to configure the list of available Gateways itsself (like the "Add Gateway" button) from the script, however. If you need this functionality, please file it as a requirement via our support department.

_________________
Check out the CODESYS store: http://store.codesys.com/

CODESYS® a trademark of 3S-Smart Software Solutions GmbH
Inspiring Automation Solutions


Top
   
PostPosted: Tue Apr 17, 2012 9:24 am 
Offline

Joined: Tue Oct 04, 2011 10:13 am
Posts: 80
I used:
Code:
controller = projects.primary.find("CoDeSys_Control", True)[0]
pprint.pprint (controller)

deviceid      = controller.get_device_identification()
devicegateway = controller.get_gateway()
deviceaddress = controller.get_address()
pprint.pprint (devicegateway)

And that resulted in a 16 byte GUID.

Next I'll try to set the controller communication setting...

Also I detected that the Menu; Project; Export file contains the GatewayGuid.
Search for <Single Name="GatewayGuid" Type="System.Guid"> in the *.export file.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 3 posts ] 

All times are UTC+01:00


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited