Create ICDs
Create an ICD and its messages in the Console, Python, or TypeScript.
Create an ICD to describe the messages that a device sends. Then a read task can use it to turn each message into samples on channels.
When to create an ICD
Create an ICD
Console
Python
TypeScript
-
Open the ICD:
- Click in the ICDs toolbar.
- Run the “Create ICD” command from the command palette.
The Console creates an ICD named “ICD”, with no messages, and opens it in a tab.
-
Click the name at the top of the tab, and enter a new name.
-
Click Add message. The new message is named “Message 1”, in the binary format.
-
In the message details, enter a Name and select the Format: Binary, Text, or JSON.
-
Click Add field for each value in the message, and fill in its properties.
Each edit saves at once. There is no save button.
import synnax as sy
client = sy.Synnax()
telemetry = sy.icd.Message(
name="Telemetry",
payload=sy.icd.JSONPayload(
fields=[
sy.icd.TimestampJSONField(
name="time", pointer="/ts", time_format="unix_ms"
),
sy.icd.FloatJSONField(
name="temperature", pointer="/temperature", units="degC"
),
sy.icd.FloatJSONField(name="pressure", pointer="/pressure", units="kPa"),
],
),
)
oven = client.icds.create(name="Oven", messages=[telemetry])create also takes an ICD, or a list of them to create many at once.
const oven = await client.icds.create({
name: "Oven",
messages: [
{
name: "Telemetry",
payload: {
format: "json",
fields: [
{ name: "time", pointer: "/ts", type: "timestamp", timeFormat: "unix_ms" },
{
name: "temperature",
pointer: "/temperature",
type: "float",
units: "degC",
},
{ name: "pressure", pointer: "/pressure", type: "float", units: "kPa" },
],
},
},
],
});create also takes an array of ICDs to create many at once.
Each message and field gets a key when you create it. Tasks refer to messages and fields by key, so you can rename them later. The ICD reference gives the properties of each format.
Check an ICD
A check finds the problems in an ICD, such as two messages with one name. Most problems do not stop a save. A value that breaks a rule of the ICD’s schema, such as a field with no name, does stop the save.
Console
Python
TypeScript
The editor checks the ICD shortly after each edit, and marks each problem on its property.
for problem in client.icds.check(oven):
print(problem.path, problem.message)for (const { path, message } of await client.icds.check(oven))
console.log(path, message);path is the place of the problem, such as messages.0.name. It is empty for a problem
with the whole ICD. The problems in the
reference say how to fix each one.
Use the ICD in a task
A task selects the messages that it reads and binds their fields to channels. To bind fields, see the MQTT read task.