Expression Attributes
  • 14 Oct 2024
  • 1 読む分

Expression Attributes


The content is currently unavailable in Ja - 日本語. You are viewing the default English version.
記事の要約

Expression Attributes allow the setting of state (active: true/false), based on the state of payload/data of one or more other Attributes. This can easily be added to a “24/4 Template Layer Template“ in code, but the logic can in a lot of situations instead be done by the Player itself. For example:

We have a camera-sensor measuring the number of cars in a traffic intersection:

{
  "name": "dyn.traffic",
  "data": "15"
}

This is updated by a template, a Player Plugin or some other mechanism. To trigger on this, we can add some Expression Attributes that can be used as Conditionals in the CMS:

{
  "name": "expr.lightTraffic",
  "data": "{dyn.traffic}.VALUE < 10"
}

{
  "name": "expr.mediumTraffic",
  "data": "{dyn.traffic}.VALUE >= 10 && {dyn.traffic}.VALUE < 20"
}

{
  "name": "expr.heavyTraffic",
  "data": "{dyn.traffic}.VALUE >= 20"
}

These will then change the active-state dynamically, based on the “dyn.traffic” data-value.

The data-field frequently contains an object serialized as JSON and this is supported in the syntax.

  • The expression is JS-eval()’ed after massaging of the string, so any JS-operators are valid.

  • “{dyn.ExampleAttr}” - boolean. The active state of “dyn.exampleAttr“.

  • “{dyn.ExampleAttr}.VALUE“ - string. The unparsed data-value.

  • “{dyn.ExampleAttr}.myValue“ - The type and value of JSON.parse(attr.data).myValue.

“expr.mediumTraffic“ from the example above can therefore be defined as:

{
  "name": "expr.mediumTraffic",
  "data": "!{expr.lightTraffic} && !{expr.heavyTraffic}"
}


この記事は役に立ちましたか?

Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.