Difference between revisions of "SHIP:Property:variable:context"

From Serious Documentation
Jump to: navigation, search
(Node: Variable)
(Node: Variable)
Line 1: Line 1:
 
=== Node: [[SHIP:Node|Variable]] ===
 
=== Node: [[SHIP:Node|Variable]] ===
 
{{PropTableStart|}}
 
{{PropTableStart|}}
|<onlyinclude>{{Prop|variable|context}}**||{{DataType|Byte}}|| Makes the variable persistent across reboots.</onlyinclude>
+
|<onlyinclude>{{Prop|variable|context}}**||{{DataType|Byte}}|| The name space for this {{Prop|variable|persistent}} variable on this SIM.</onlyinclude>
 
|}
 
|}
 
Variables marked {{Prop|variable|persistent}} must be stored in the registry in a specific name space, or {{Prop|variable|context}}.  A context is a simple 8 bit number, with 0x00 and 0xFF reserved for Serious use.  Typically, you'll use context 0x01.  If you have multiple GUIs loading on the same physical SIM, you may assign each GUI's variables a different context -- or you can share persistent variables selectively by having some variables share the same context.
 
Variables marked {{Prop|variable|persistent}} must be stored in the registry in a specific name space, or {{Prop|variable|context}}.  A context is a simple 8 bit number, with 0x00 and 0xFF reserved for Serious use.  Typically, you'll use context 0x01.  If you have multiple GUIs loading on the same physical SIM, you may assign each GUI's variables a different context -- or you can share persistent variables selectively by having some variables share the same context.
Line 8: Line 8:
  
 
See the related properties {{Prop|variable|persistent}}, {{Prop|variable|varid}}, and {{Prop|variable|varversion}}. In order to make a variable {{Prop|variable|persistent}}, you must set these 3 related properties as well.
 
See the related properties {{Prop|variable|persistent}}, {{Prop|variable|varid}}, and {{Prop|variable|varversion}}. In order to make a variable {{Prop|variable|persistent}}, you must set these 3 related properties as well.
 +
 +
Here's how to make a variable persistent:
 +
* go into the property sheet for the variable in SHIPTide
 +
* turn the persistent property to true
 +
* set the context to 0x02...0xFD (your choice) - this is the name space for your application. This way you can have 2 different apps on the unit or more and each has its own set of persistent variables that do not conflict as long as they use different context IDs
 +
* assign the variable a unique variable id (varid) (e.g. 0x0001, 0x0002, ...) within your context
 +
* assign a variable version (varversion) to the variable (eg. 0x01) -- this is used if you ever need to upgrade a variable to a different version)
 +
 +
Now, whenever you change the variable it will write-thru automatically to the registry in serial flash. Whenever you boot, it will retrieve the value from serial flash.
 +
 +
Here's an example in the attached screen shot:
 +
 +
{| class="wikitable" style="margin: 1em auto 1em auto;"
 +
|[[Image:SHIPPersistentVariable.png|200px|center|SHIP Persistent Variable Example]]
 +
|}
  
 
<nowiki>**</nowiki>The {{Prop|variable|context}} property can only be set in [[SHIPTide]].
 
<nowiki>**</nowiki>The {{Prop|variable|context}} property can only be set in [[SHIPTide]].

Revision as of 10:24, 6 August 2013

Node: Variable

Property Data Type Description
context** Byte The name space for this persistent variable on this SIM.

Variables marked persistent must be stored in the registry in a specific name space, or context. A context is a simple 8 bit number, with 0x00 and 0xFF reserved for Serious use. Typically, you'll use context 0x01. If you have multiple GUIs loading on the same physical SIM, you may assign each GUI's variables a different context -- or you can share persistent variables selectively by having some variables share the same context.

Variables are stored by a combined unique value of context + varid + varversion. A persistent variable in one GUI with context 0x01, varid 0x0001, varversion 0x01 is a completely different stored variable than one with a different (say, 0x02) context.

See the related properties persistent, varid, and varversion. In order to make a variable persistent, you must set these 3 related properties as well.

Here's how to make a variable persistent:

  • go into the property sheet for the variable in SHIPTide
  • turn the persistent property to true
  • set the context to 0x02...0xFD (your choice) - this is the name space for your application. This way you can have 2 different apps on the unit or more and each has its own set of persistent variables that do not conflict as long as they use different context IDs
  • assign the variable a unique variable id (varid) (e.g. 0x0001, 0x0002, ...) within your context
  • assign a variable version (varversion) to the variable (eg. 0x01) -- this is used if you ever need to upgrade a variable to a different version)

Now, whenever you change the variable it will write-thru automatically to the registry in serial flash. Whenever you boot, it will retrieve the value from serial flash.

Here's an example in the attached screen shot:

SHIP Persistent Variable Example

**The context property can only be set in SHIPTide.