Remote execution of Python script

Script execution outside CRI Atom Craft

CRI Atom Craft allows you to use the Robot function from an external executed Script (by an external process).
The TCP/IP protocol is used to communicate with external execution scripts during remote execution.

To start the Script Server

To execute the Script Server remotely, select "Server" > "Start Script Server" from the "Script" menu to start the Server for remote execution of the Robot function.

criatom_tools_atomcraft_api_connect_runserver.png

The server settings (IP address, port number) can be set from "Script Settings" in the "Script" menu.

criatom_tools_atomcraft_api_connect_server_settings.png

After starting the server, connect with a script from an external client.

Remote execution from the console version of CRI Atom Craft

Scripts created for Local execution of Python script can also be run from the console version of CRI Atom Craft .
For the console version of CRI Atom Craft , see Building Projects with the CRI Atom Craft command line version .

Execution image

(1) Start CriAtomCraftC.exe with the option -runrobotserver. You can also specify the IP address and port number.

CriAtomCraftC.exe -runrobotserver
CriAtomCraftC.exe -runrobotserver 127.0.0.1 9000

(2) The console tool will wait for the script.

(3) While the script is waiting, enter -serverexit and press Enter to exit the console tool.

Pending commands

While the script is waiting, only the commands below are accepted. Options specified for the executable file cannot be used.

Command Description
-serverexit Terminates the server's communication waiting process and terminates the application.
-serverreboot Restarts the server process. Use this if the remote API cannot be processed correctly for some reason.

Writing Scripts for Remote Execution

The Script uses the modules in the remote execution plugin package.
In this package, cri.atomcraft.criatomcraft_api_lib is provided.
By importing the Connection Module , you can initialize the function and connect with CRI Atom Craft to run the remote execution.
※ For the settings of this remote execution plugin package, refer to Preference settings for remote execution .

For example, if the script of the Display "Hello, World" in the Script log tutorial is made compatible with remote execution, it will be as follows:

import sys
import cri.atomcraft.criatomcraft_api_lib as acconnect
import cri.atomcraft.debug as acdebug
# Initialization
result = acconnect.initialize()
if result != 0:
print("initialize error")
sys.exit()
# Connecting
result = acconnect.connect("127.0.0.1", 9000)
if result != 0:
print("connection failed")
acconnect.finalize()
sys.exit()
# Send command
acdebug.log("Hello World!")
# Disconnect
acconnect.disconnect()
# Exit
acconnect.finalize()

Save this Script as " helloworld.py ", and run the following command from Terminal(command prompt), you can check the output character string in CRI Atom Craft.

python3 helloworld.py

※ The Python3 executable files may be shown as "python" instead of "python3" in some environments.