You will learn how to set, get or remove an object's name and also, how to use the naming schema to get an object's ID.
None. You can use this article on its own.
Remember to:
Add the Ubisense references to your application.
Add a
Ubisense.UName.Naming.Schema object to your Form
class.
Instantiate the
Ubisense.UName.Naming.Schema.
Call
ConnectAsClient on your schema
object
Use the keyword 'using' to bring the Naming namespace into the scope of your WinForm class (or to create an alias), to save you some keystrokes.
For predictable scalability, it is preferable to create a schema cache client and query the local cache of schema data than to use remote procedure calls.
The Naming schema keeps the relation of an object with each of its names in the
ObjectName relation. There are two
available index methods for the
ObjectName relation;
name_ and
object_name_. The index methods return a cursor
to the elements of the relation that match the parameter given.
In this case we are not looking for a particular object or name, so there's no need to specify a parameter. The following code snippets can be used to get all the objects or names from the naming schema.
|
OR
using (Ubisense.UName.Naming.ReadTransaction xact = namingSchema.ReadTransaction()) |
We can query the naming schema to get only the rows that have a specific
objName and read the
object_ value from each of them.
Notice that more than one object can have the exact same name and if that were
the case with
objName, the code inside the
foreach statement would be executed more than once.
|
Same as before, but you need to know the object beforehand, retrieved from a different schema or maybe entered to the naming schema previously by your application.
|
In case you need to locate a specific name for an object, you can do so, like this:
|
All remote operations of any schema are executed at the server and might add latency if they communicate reliably (the client side waits for a response from the server). Remember to use a cached schema instead of using remote operations to query a schema whenever possible.
To get the objects that have a specific name from the server:
|
To get all the names for an object from the server:
|
You can use the following code to retrieve groups of objects from the server that share the same prefix.
|
The only way to modify the state of a schema in the server is using remote operations. Consider keeping a record of the changes within the scope of your program and only commit the necessary changes (e.g. the ones you want to remain persistent or need to communicate to other clients).
In Ubisense, an object exists only while it is in one of the relational schemas.
The
Naming schema provides the
easiest way to identify an object and find out its ID to look for that object
in other schemas. Removing an object from the
Naming schema does not remove
it from other schemas; modifying the
Naming schema could make identifying a
specific object more difficult.
An object can have many names, appearing many times in the names table; each row would contain the same object but different names. The following code creates an entry in the naming schema server:
|
Deletes all the entries in the server for the specified object and creates a new one with the specified name. If there are no entries it will still create the latter.
|
This will delete all the
entries at the server that have the specified object in their
object_ index
|
This will delete all the
entries at the server that have the specified name in their
name_ index
|
This will only remove the entry at the server that matches both object and name
|