Back to contents pageHow to set/remove ownerships using the API

How to set/remove ownerships using the API

Summary

This article shows you how to set and remove object ownerships using the API. Object ownerships are used when you want an object's position to be driven by another object's position.



Prerequisites

None. You can use this article on its own.



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 ensure an object's location depends on the location of a Ubisense tag. That is, you have attached a tag to a real-world object and you would like this to be reflected by your application. A driven object's location is dependent on the driver's location.



1) Create the schema client and connect to the schema


    // Create the ULocation.Driven event client
    Ubisense.ULocation.Driven.Schema driven_schema = new
        Ubisense.ULocation.Driven.Schema(true);

    // Connect to the schema
    driven_schema.ConnectAsClient();



2) Set a new object driver/driven relationship

The following code creates a new row for the Ubisense.ULocation.Driven.IsDrivenBy relation.


    // Create the new row for the database
    Ubisense.ULocation.Driven.IsDrivenBy.RowType r = new
        Ubisense.ULocation.Driven.IsDrivenBy.RowType();

    // Set the fields of the new row
    r.driven_ = // The object to which the tag is attached...
    r.driver_ = // The tag attached to the object...
    r.transform_ = // The Ubisense.ULocation.Transform to apply...

    // Call the remote operation to assert the new row
    driven_schema.set_driven_object(r);



3) Remove a relationship

The remove_driven_object() method is used to stop an object's location from being driven by another object.


    driven_schema.remove_driven_object(/* The object that no longer requires tracking */);

The remove_driver_object() method is used to stop an object's location driving another object's location.


    driven_schema.remove_driver_object(/* The object, normally a
        Ubisense.ULocationIntegration.Tag, that no longer drives
        any other object's location*/);



Back to top