Back to contents pageHow to get spatial events using the API

How to get spatial events using the API

Summary

This article shows how to get spatial events using the API Ubisense .NET API. Spatial events are concerned with how objects interact with regions. For example, a person entering a defined region such as an 'Alarm Zone'.





Prerequisites

You should know the information in the following article:



Example material

Save this link to get a zip file of the example material


Guide

Before you start, remember:

This guide shows you how to react to spatial events, the example here being that a person enters or leaves an 'Alarm Zone'.

The event client in this example is called monitor_schema:


    // Create an example event client for a USpatial::Cell
    Ubisense.USpatial.Monitor.Schema monitor_schema = new
        Ubisense.USpatial.Monitor.Schema(true);

Add event handlers to react to people entering and leaving the 'Alarm Zone':


    // Add the insert/delete handlers for the monitor_schema.
    // These will be called when rows are inserted/deleted into/from
    // the Ubisense.USpatial.Monitor.Contains relation.
    Ubisense.USpatial.Monitor.Contains.AddInsertHandler(
        monitor_schema, OnInsert);
    Ubisense.USpatial.Monitor.Contains.AddDeleteHandler(
        monitor_schema, OnDelete);

    // Insert handler for the Ubisense.USpatial.Monitor.Contains relation
    static void OnInsert(Ubisense.USpatial.Interaction _i)
    {
        // This code will execute whenever a person enters the 'Alarm Zone'.
        // More precisely, it will execute whenever a row is inserted into the
        // Ubisense.USpatial.Monitor.Contains relation. Its row type is
        // Ubisense.USpatial.Interaction, and _i is the row that has been inserted.
    }

    // Delete handler for the Ubisense.USpatial.Monitor.Contains relation
    static void OnDelete(Ubisense.USpatial.Interaction _i)
    {
        // This code will execute whenever a person leaves the 'Alarm Zone'.
        // More precisely, it will execute whenever a row is deleted from the
        // Ubisense.USpatial.Monitor.Contains relation. Its row type is
        // Ubisense.USpatial.Interaction, and _i is the row that has been deleted.
    }



Back to top