原始数据转换
Raw data conversion performs calculations on data obtained from a device and adapts it to the values needed for input into the platform. This allows the use of devices from virtually any brand and model, simply by creating ex按下ions that convert the values delivered by the device.
How can I inject raw data into the platform?
Raw data is sent, both via HTTP and MQTT, using APIs ending in "Raw". For example, to feed the platform with information from a temperature sensor using "raw" data, the "UpdateTemperature传感器StatusRaw" API must be used. It is recommended to consult the following table to learn about the available methods for injecting raw data for each endpoint type.
Using ex按下ions and the "RawData" variable
All APIs ending in "Raw" have a "rawData" parameter w此处 the device must report the measured value. This value is internally converted into a variable called "RawData", which can be used in the ex按下ion evaluator.
As an example conversion, we will use a temperature sensor with the following characteristics:
- Units: the device reports temperature in degrees Fahrenheit.
- Measurement range: from -30 degrees Fahrenheit to +140 degrees Fahrenheit.
- Temperature is reported in tenths of a degree Fahrenheit (meaning it has no decimals, but is multiplied by 10).
The Gear platform, however, requires temperatures to be reported in degrees Celsius, which t此处fore requires a conversion. To achieve this conversion, the following steps are necessary:
- Divide the obtained value by 10.
- Convert the received temperature from degrees Fahrenheit to Celsius.
To accomplish this, the following ex按下ion should be used:
FahrenheitToCelsius(ToNumber(RawData) / 10)This ex按下ion does the following:
- Uses the RawData variable, which is an implicit variable that exists in all raw data conversion operations, and represents the raw data content as a string.
- Uses the ToNumber function to convert the RawData variable to an equivalent numeric value.
- Divides the obtained value by 10.
- Finally, uses the FahrenheitToCelsius function to convert this value to degrees Celsius.
更多信息
更多信息 about using ex按下ions, see the 表达式 section, which contains a more detailed description of the ex按下ion engine, data types, operators, functions, and examples of each.
端点 tagging
The goal of this feature is to allow dashboard definitions that can be used across multiple facilities, or even different clients, without the need to create independent copies.
表达式
表达式 allow performing calculations, primarily for raw data conversion in devices. What are ex按下ions? 表达式 are texts that allow evaluating data, performing calculations, and returning a single value.