Documentation:Tutorial:Using Data Versioning - MdsWiki
Navigation
Personal tools

From MdsWiki

Jump to: navigation, search

Data versioning is an optional feature in MDSplus trees. When "versioning" is enabled in a tree instance, data stored in a node does not overwrite any existing data in that node. Instead the previous data is retained. By default, accessing the data in the node will return the newest data stored in that node. To retrieve the older data you can use the TCL "SET VIEW datetime" command which will cause all data retrieved to reflect the values that were in place at that particular date and time. Versioning can be enable in the model, in the pulse, or both. The following example illustrates how one might use versioning in a tree:

TCL> EDIT/NEW MYTREE
TCL> SET VERSIONS/MODEL/SHOT
TCL> SHOW VERSIONS

  Versions are enabled in the model file and enabled in the shot file.

TCL> ADD NODE MYNUMBER/USAGE=NUMERIC
TCL> WRITE
TCL> CLOSE
TCL> SET TREE MYTREE
TCL> PUT MYNUMBER 1
TCL> DIR/FULL MYNUMBER
 
\MYTREE::TOP
 
 :MYNUMBER    
     Status: on,parent is on, usage numeric
     compress on put
     Data inserted: 22-MAY-2013 12:09:15.53    Owner: [1751,1750]
     Dtype: DTYPE_L               Class: CLASS_S             Length: 12 bytes
 
Total of 1 node.
TCL> PUT MYNUMBER 2
TCL> DIR/FULL MYNUMBER
 
\MYTREE::TOP
 
 :MYNUMBER    
     Status: on,parent is on, usage numeric
     compress on put
     Data inserted: 22-MAY-2013 12:10:37.78    Owner: [1751,1750]
     Dtype: DTYPE_L               Class: CLASS_S             Length: 12 bytes

     Data inserted: 22-MAY-2013 12:09:15.53    Owner: [1751,1750]
     Dtype: DTYPE_L               Class: CLASS_S             Length: 12 bytes
 
Total of 1 node.
TCL> PUT MYNUMBER 3
TCL> DIR/FULL MYNUMBER
 
\MYTREE::TOP
 
 :MYNUMBER    
     Status: on,parent is on, usage numeric
     compress on put
     Data inserted: 22-MAY-2013 12:11:52.20    Owner: [1751,1750]
     Dtype: DTYPE_L               Class: CLASS_S             Length: 12 bytes

     Data inserted: 22-MAY-2013 12:10:37.78    Owner: [1751,1750]
     Dtype: DTYPE_L               Class: CLASS_S             Length: 12 bytes

     Data inserted: 22-MAY-2013 12:09:15.53    Owner: [1751,1750]
     Dtype: DTYPE_L               Class: CLASS_S             Length: 12 bytes
 
Total of 1 node.
TCL> DECOMPILE MYNUMBER
3
TCL> SET VIEW "22-MAY-2013 12:11:00"
2

You need to use the TCL "SET VIEW" command in other languages to change the view datetime. For example:

IDL> MDSOPEN,'MYTREE',-1
IDL> print,MDSVALUE('MYNUMBER')
          3
IDL> mdstcl,'SET VIEW "22-MAY-2013 12:11:00"'
IDL> print,MDSVALUE('MYNUMBER')
          2