Examples
Runnable Python and TypeScript scripts that write, read, and stream data, run control sequences, and set up hardware tasks.
Each example is a script in the Synnax repository that you can run against your own Core.
Run an example
Python
TypeScript
Most Python examples connect with the login that sy login saves. Log in once, see
Log in once with sy login, then
run a script:
python basic_read_write.pyThe Arduino examples set their connection values in the script.
The control examples and the simulators import other example files. Run them as modules
from the client/py folder, with a simulator in a second terminal:
python -m examples.simulators.press
python -m examples.control.press.control_sequenceThe README in each folder gives the steps.
The TypeScript examples connect to localhost:9090 with the username synnax and the
password seldon. Change these values in the script to match your Core. From the
client/ts/examples/node folder, install the client and run a script:
npm install
node basicReadWrite.jsstreamRead.js streams the samples that streamWrite.js writes. Run streamWrite.js
first, in a second terminal.
Examples by topic
Python
TypeScript
Write, read, and work with data. See Write data and Read data.
Stream data. See Stream data. The scripts that read
live samples need stream_write.py to run in a second terminal.
Channels and ranges. See Channels and Ranges.
Control sequences. See Control.
Hardware tasks. See Hardware. These examples need the Driver and the device. The Modbus, OPC UA, and HTTP folders include a simulated device.
Write, read, and work with data. See Write data and Read data.
Stream data. See Stream data.