An example of using software management to work with KPM «RITM»
RITM is a hardware solution for running models in real time. It allows you to integrate work scenarios with physical equipment and manage it directly from Engee.
To get started with the target platform «RITM»:
-
Install the Engee subsystem.Integration, as shown in article.
-
After that, a module for working with external equipment becomes available, which provides software management of the KPM. «RITM». To connect the module, enter the following command:
using Main.EngeeDeviceManager.Targets: RITM_API -
Add A RITM machine to Engee through the app RITM.Manager
or through RITM_API.addMachine. -
Install support RITM BLOCKS:
engee.package.install("RITM-Engee-Blocks")
Basic methods of working with RITM
The following methods are available for working with the equipment on the RITM:
-
RITM_API.buildModel— builds a model based on the RITM. -
RITM_API.runModel— starts the model on the RITM. -
RITM_API.stopModel— stops the model on the RITM. -
RITM_API.isConnected— checks the availability of the RITM. -
RITM_API.isRunning— checks whether the RITM model is running. -
RITM_API.listFiles— retrieves the list of files in the specified directory. -
RITM_API.readFile— returns the contents of the specified file from the specified directory. -
RITM_API.downloadFile— retrieves the specified file from the specified directory. -
RITM_API.memInfo— returns information about the memory consumed by the model. -
RITM_API.getLog— returns the specified number of lines of model execution logs on the RITM. -
RITM_API.getScreenshot— creates a screenshot on the RITM and returns the path to the image file. -
RITM_API.getProfileData— returns the result of profiling the model based on the RITM.
| A detailed description of each method is provided in the article. Software control of RITM. |
Step-by-step example of working with the RITM model
-
Connecting modules and adding a machine — import the module and add the RITM machine:
using Main.EngeeDeviceManager.Targets: RITM_API if !RITM_API.isMachineExists("RITM 1") RITM_API.addMachine("RITM 1", "192.168.56.3") end -
Check the availability of RITM — check whether the connection is established with the RITM device:
RITM_API.isConnected("RITM 1")If the method returns
falsethen check the machine name and make sure that the client program is running on RITM. -
Firmware and support package version — find out the firmware and support package versions.:
RITM_API.version("RITM 1") -
The assembly is open in Engee models based on the RITM in independent mode:
engee.open("/user/Engee-Device-Manager-demos/example_RITM/example_ritm_extmodel.engee") model = engee.gcm() RITM_API.buildModel("RITM 1", model) -
Launching the model — launch the model on the RITM machine:
RITM_API.runModel("RITM 1", model; is_interactive_mode=false)After launch, the model will start executing in the previously set mode (in our case, in an independent mode).
-
Stopping the model — we will stop the execution of all running models on the RITM:
RITM_API.stopModel("RITM 1") -
Output the contents of the directory to the RITM — we get a list of files in the specified directory (
/home/ritm/):RITM_API.listFiles("RITM 1", "/home/ritm/build/example_ritm_extmodel") -
Reading the contents of the file — output the contents of the file
example_ritm_extmodel_profile.txtfrom the directory/home/ritm/build/example_ritm_extmodel/:RITM_API.readFile("RITM 1", "example_ritm_extmodel_profile.txt"; path="/home/ritm/build/example_ritm_extmodel/") -
Getting the file to the current directory — download the specified file (
example_ritm_extmodel_profile.txt) from the directory/home/ritm/build/example_ritm_extmodel/to the current directory Engee:RITM_API.downloadFile("RITM 1", "example_ritm_extmodel_profile.txt"; from="/home/ritm/build/example_ritm_extmodel/", to="") -
Getting information about memory — we will request data on memory consumption by the model:
engee.open("/user/Engee-Device-Manager-demos/example_RITM/example_ritm_extmodel.engee") model = engee.gcm() RITM_API.buildModel("RITM 1", model) RITM_API.runModel("RITM 1", model) memInfoBytes = RITM_API.memInfo("RITM 1", "example_ritm_extmodel") memInfoMb = memInfoBytes / 1024 println("Used memory: $(memInfoMb) MB") -
View the last 10 lines of logs — get the last 10 lines of the model execution log:
ritm_log = RITM_API.getLog("RITM 1", 10); print(ritm_log)They can be used to debug and diagnose the model.
-
Create a screenshot and get the path to it — take a screenshot of the car.:
screenshot_path = RITM_API.getScreenshot("RITM 2", "example.png")The file is uploaded to Engee, and the function returns the local path to it.
using FileIO using Images load("example.png") -
Check the status of the model — make sure that the model is running at a RITM:
RITM_API.isRunning("RITM 1", "example_ritm_extmodel")If the function returns
true, then the model is executed. -
Getting profiling data — we will get the profiling data of the model from the RITM in the form of a file or string:
RITM_API.getProfileData("RITM 1", "example_ritm_extmodel") -
File Upload — download the file
example_ritm_data.jld2from the directory Engee/user/Engee-Device-Manager-demos/example_RITM/to the RITM directory/home/ritm/data:RITM_API.uploadFile("RITM 1", "example_ritm_data.jld2"; from="/user/Engee-Device-Manager-demos/example_RITM/", to="/home/ritm/data") -
File deletion — delete the uploaded file
example_ritm_data.jld2On the beat:RITM_API.removeFile("RITM 1", "/home/ritm/data/example_ritm_data.jld2") -
Receiving diagnostics — we will receive diagnostics of the RITM machine:
RITM_API.getDiagnostic("RITM 1")File
ritm_diagnostic.zipit will be written to the current directory. -
* Reboot* — restart the machine.:
RITM_API.reboot("RITM 1") -
Shutdown — turn off the RITM machine:
RITM_API.poweroff("RITM 1") -
Configuring the Ethernet interface - configure the Ethernet interface of the RITM machine:
RITM_API.setupEthernet("RITM 1", ethernetNumber, "192.168.0.10", 24) -
Working with autorun
Putting the model in autorun:
RITM_API.setAutostart("RITM 1", model.name)Getting the list of models in autorun (empty if autorun is not configured):
RITM_API.getAutostart("RITM 1")Removing the model from autorun:
RITM_API.disableAutostart("RITM 1")
An example of managing machines in Engee
-
List of cars — we will display a list of known cars in Engee:
RITM_API.getMachines() -
Machine name and IP address — get the machine’s IP address by its name or the machine’s name by its IP address:
RITM_API.getIPByName("RITM 1") RITM_API.getNameByIP("192.168.56.3") -
Adding a car — add a car to the list of known cars in Engee if it has not been added yet:
if !RITM_API.isMachineExists("RITM 2") RITM_API.addMachine("RITM 2", "192.168.56.4") end -
Deleting a car — we will delete the car by its exact name if it is in the list of known cars. Engee:
if RITM_API.isMachineExists("RITM 2") RITM_API.removeMachine("RITM 2") end