TDengine’s Stream Computing in IoT: Typical Applications in Connected Vehicles

Chait Diwadkar
Chait Diwadkar
/
Share on LinkedIn

In today’s Internet of Things (IoT) platforms, the volume and frequency of data generated by vehicles are immense. These include sensor data, driving behavior data, GPS trajectory data, and more. This demands the use of stream computing to process and analyze the data in real-time, generating value immediately as the data is created or received. For example, stream computing can enable real-time monitoring and analysis of vehicle health, predicting potential failures, providing timely maintenance advice, and tracking vehicle movement to ensure the safety and stability of both the vehicles and the business operations.

In stream computing, data arrives as an ongoing stream. Since the data is unbounded (in theory, it will continue to be generated indefinitely), the concept of “windows” is used to divide the stream into manageable chunks. Through different types of windows, stream computing can meet a variety of business requirements.

TDengine offers five unique window queries for stream computing, which help in handling real-time data efficiently. These are detailed in the TDengine documentation (https://docs.tdengine.com/tdengine-reference/sql-manual/time-series-extensions/). In simple terms, these windows are:

  • Interval: Divides the stream based on fixed time intervals.
  • State Window: Divides the stream based on boolean values.
  • Session Window: Divides the stream based on the duration of a specific state.
  • Count Window: Divides the stream based on the number of data rows.
  • Event Window: Divides the stream based on custom-defined expressions.

Each of these window types is tailored to meet different business needs and plays a crucial role in stream processing within the connected vehicle industry.

Example: State Window in Action

One of the most useful windows for the connected vehicle industry is the state_window, which allows users to segment data streams based on boolean values. For example, by tracking the moving or stationary status of a vehicle, businesses can calculate the duration of each vehicle’s movement and stopping times in real-time, as well as the corresponding locations.

Using the state_window, a user could track vehicle movement based on speed, detecting the exact time and place when a vehicle starts or stops. For instance, this logic could be used to issue alerts if a vehicle exceeds a certain threshold for idle time or stops in an unusual location. The query might look like this:

CREATE stream overtime_parking INTO overtime_parking_output_stb AS
SELECT
    _wstart,
    _wend,
    TIMEDIFF(_wstart, _wend, 1s) AS sparking_time,
    LAST(address) address,
    speed_status,
    COUNT(*) AS record_count,
    tbname
FROM
    stb_cold_gps PARTITION BY tbname state_window(speed_status); 

This query enables real-time tracking of a vehicle’s movement status. Through such an approach, businesses can efficiently monitor vehicles for issues like excessive idling, abnormal parking, or other anomalous behavior.

Customizing Window Logic for More Flexibility

Moreover, TDengine allows users to customize the window logic even further based on their unique business requirements. By leveraging the CASE WHEN logic, users can create custom states for their vehicles. For example, a user can define a state window where the condition for a vehicle to be considered “moving” or “stationary” depends on its speed. This flexibility is illustrated in the following query:

STATE_WINDOW( CASE WHEN speed >= xxx THEN true ELSE false END)

This logic ensures that the window can be fine-tuned to meet specific business needs, allowing for more granular insights into vehicle behavior.

Expanding Use Cases and Business Impact

Beyond just monitoring vehicle status, stream computing with TDengine can support a wide range of other business needs in the connected vehicle ecosystem. Some of these include:

  • Predictive Maintenance: Real-time analysis of vehicle health data can predict parts failure or system malfunctions before they occur. This enables companies to schedule maintenance efficiently and avoid costly repairs or downtimes.
  • Traffic Management: By analyzing real-time GPS data, authorities can track traffic conditions, optimize routes, and even identify areas of congestion or accidents in real-time, providing a better overall experience for drivers.
  • Fleet Management: For businesses with large fleets, stream computing helps with monitoring fleet health, tracking vehicles, and optimizing their utilization. The ability to react instantly to real-time data enables better decision-making and resource allocation.

TDengine’s windowing capabilities make it a powerful tool for managing the massive amounts of real-time data generated in the connected vehicle space. By dividing data into smaller, manageable chunks, businesses can perform real-time analytics and gain valuable insights that drive operational efficiency, improve customer experiences, and reduce costs.

  • Chait Diwadkar

    Chait Diwadkar is Director of Solution Engineering at TDengine. Prior to joining TDengine he was in the biotechnology industry in technical marketing, professional services, and product management roles and supported customers in pharma, medical devices and diagnostics on analytical chemistry, and genetic platforms.