Create a GUI
4 minute read
Motorcortex Grid builds a dashboard for your application: switches, buttons, lights and plots, each linked to a parameter in the parameter tree. On this page you make a small one: a switch that sets the gripper parameter you used in Desk, and a light that shows its value. You test it live, then deploy it to the controller.
A dashboard is a grid fileA grid file (.grid) describes one dashboard: its screens, the components on them, and the parameter path each component is linked to. It lives in a grid package in your motorcortex.io project.
in a grid package of your motorcortex.io project. You edit it in the Grid editor, and deploy the package to the controller like the packages in Deploy an application.
Create a grid package and a grid file
A package of its own keeps your dashboard apart from the one that came with the application.
- Log in to
motorcortex.io, click
Projectsin the menu on the left, and open the project you deployed. - Open the actions menu, the
…button at the top of the page, and chooseNew. UnderPackage, choosegrid. - Give the package a
Nameand clickCreate. - Open the new package. In its actions menu, choose
New, thengrid file. - Give the file a
Nameand clickCreate. motorcortex.io adds the.gridextension. - Click the file name to open it in the Grid editor. The new dashboard has one empty screenA screen is one page of a dashboard, with its own components. A dashboard can have several screens; a new grid file starts with one, called
screen 1. ,screen 1.
Connect the editor to the controller
The editor reads the parameter tree from the controller, so you can pick parameters from it and see live values while you build.
-
In the top bar of the editor, click
Connection. -
In
machine IP, typecontroller_ip_addressThe IP address of your controller. In most cases 192.168.2.100., or the address of your cloud machine. -
Keep
Secureticked. -
Click
connect.
Add a switch and a light
-
Click
libraryat the top left. The Library opens on the left with every component you can add.
-
Drag a
switchonto the screen. -
Drag a
lightonto the screen, next to it.
Link each component to a parameter
A component does nothing until it has a parameter pathA parameter path is the full name of a parameter: the folders from root down to the parameter, separated by /. For example root/Logic/state.
. The switch writes to its parameter; the light shows the value of its parameter.
-
Click the switch on the screen. Its Properties open on the right.
-
Under
PATH, click thepathfield. The Parameters panel opens on the left with the parameter tree of the controller. -
Open
root,UserParametersandIO, and clickgripper. Its path,root/UserParameters/IO/gripper, fills in thepathfield.
-
Under
VALUE, leavevalue onat1andvalue offat0. These are the values the switch writes. -
Click the light, and link its
pathtogripperin the same way.
Test it in the preview
The preview runs your dashboard against the live controller, so you can try it before you deploy.
Note
The preview writes to the live controller, just as the deployed dashboard will. In simulation that is harmless; on a real machine, make sure that whatever a component writes to is safe to change.
-
Click
previewin the top bar. The dashboard opens in preview mode.
-
Flip the switch. The light turns on and off with it, because both are linked to
gripper. -
If Desk is still open, the
gripperplot there steps along.
Deploy the dashboard
Until you deploy it, the dashboard exists only in motorcortex.io. Deploying copies the grid package to the controller. Each grid package gets its own folder there, so the application’s own dashboard stays as it is.
- Go back to motorcortex.io and open your grid package.
- Click
Deployat the top of the page. - In
Controller IP address or domain, typecontroller_ip_addressThe IP address of your controller. In most cases 192.168.2.100., or the address of your cloud machine. - Keep
Also upgrade the controller’s grid runtime if it is out of dateticked, so the controller can run a dashboard made with the current editor. - Click
Deploy.
The transfer runs in the background, straight from your browser to the controller, so you can keep working. It needs the browser certificate from Install a browser certificate, like Desk does.
You have now used your application from Desk and from a dashboard of your own. More components, screens and settings are in the Motorcortex Grid guide.
Next: Configure your application, to adapt the application to your own drives, axes and mechanism.