FORUM CTRLX AUTOMATION
ctrlX World Partner Apps for ctrlX AUTOMATION
Dear Community User! We are updating our platform to a new
system.
Read more: Important
information on the platform change.
10-21-2020 12:22 PM - last edited on 02-16-2021 09:09 AM by CodeShepherd
Hello, colleague;
I am very intereasting in python with ctrlX. I have already installed the python app in my virtual controller.
some guys show me a example write by python,
the first line is " import Datalayer"
when I try to import Datalayer, it will throw out "ModuleNotFoundError".
Is this module have already installed in the Virtal control? Or should I do something special seeting?
Thank you very much!
Solved! Go to Solution.
02-16-2021 08:26 AM - last edited on 02-16-2021 09:09 AM by CodeShepherd
02-16-2021 08:52 AM - edited 02-16-2021 09:10 AM
Actually it is only possible to have access to the ctrlX Data Layer and the ctrlX MOTION via using the our integrated python interpreter. The interface to the firmware is fix connected to this app so there is no shared library that can be used via import.
You have to handle over complete .py files to it at start them. Other possibility would be to use the REST API out of your code to interact with our system. There all data and motion functions can be used.
When I get it right you set up your own app with your own python interpreter. There is at the moment no wheel or or other extensions for this case. This is planned to be provided with the March release RM21.03 (version 1.8) of the SDK.
04-16-2021 12:13 PM
Good morning,
I am using a script that writes a value, via datalayer, it works correctly if I load and start it via REST API, following this instructions.
Now, I'm trying to use Tiger IDE, but I can't import datalayer script. I guess it is due to the python interpreter, what is the interpreter path? can I change it?
I am working with the following versions:
Thanks in advance.
04-19-2021 09:29 AM - edited 04-19-2021 09:34 AM
Please first of all update your system to the release RM21.03 version (1.8) and also use the first official release 1.8 of the IDE app (former known as TIGER). The older version are prototypes including some known issues.
Further more there are two ways of running a script in the textual coding editor in the IDE app:
1) Run the script directly in the browser:
But the functions that should be called by the signatures are not available so this cannot run at the moment.
2) Run the script on the ctrlX CORE:
P.S.: The link in your post isn't working.
08-09-2022 07:34 PM
Hi, I am getting the same error "ModuleNotFoundError: No module named 'ctrlxpy'". I am trying to read the status of input on Channel 1 of my input module. Please tell me what I am doing wrong. Attaching some screenshots for reference:
Thanks for your help 🙂
08-10-2022 08:14 AM
Please check post above. This library is for auto completion only at the moment and the function cannot be used. Please execute the script on the control and comment this line to get it to work.
08-10-2022 10:36 AM
Thanks for the answer, but I already tried that I get the following error:
datalayer is not defined.
Can you please help me here?
08-10-2022 02:18 PM
This error is only shown in your browser because the local linter cannot find the files. We are working on that. But it has no influence on the function. So feel free to run the script on the ctrlX CORE.
I can try to test your code in the next days.
08-11-2022 02:03 PM - edited 08-11-2022 03:19 PM
I used your code to create my own example of reading an input and writing an output via python and writing something to the logbook of the ctrlX CORE.
If you need further support feel free to write me a direct message with your contact data so we can have a virtual meeting.
Thee also see this post for information about the print function into the logbook of the ctrlX CORE.
#from ctrlxpy import datalayer
import functools
print = functools.partial(print, flush=True) # flush all prints
Channel1 = datalayer.read("fieldbuses/ethercat/master/instances/ethercatmaster/realtime_data/input/data/S20_EC_BK/S20_DI_16_4/Digital_Input_Channels.DI_Channel_01_Terminal_Point_00_")
log = str(Channel1)
print("read: ")
print(log)
Channel1 = datalayer.write("fieldbuses/ethercat/master/instances/ethercatmaster/realtime_data/output/data/S20_EC_BK/S20_DO_16_3/Digital_Output_Channels.DO_Channel_01_Terminal_Point_00_",Channel1)
print("write: ")
print(log)