02.05.2014 Views

CoreandServices.book - Ocean - Schlumberger

CoreandServices.book - Ocean - Schlumberger

CoreandServices.book - Ocean - Schlumberger

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Units<br />

We get the measurement for the data from its property version. We then use the<br />

measurement to find the storage and user interface units. From the units, we build the<br />

converter and convert the data.<br />

...<br />

// Get the measurement for our data.<br />

IUnitMeasurement measurement;<br />

measurement = myObject.PropertyVersion.Measurement;<br />

// Get the unit settings<br />

IUnitServiceSettings uss;<br />

uss = CoreSystem.GetService();<br />

// Get the Invariant (storage) and UI unit system<br />

IUnitSystem uiSystem = uss.CurrentUISystem;<br />

IUnitSystem invariantSystem = uss.InvariantSystem;<br />

// Get the unit system for the stored data<br />

IUnitSystem storageSystem = catalog.GetSystem("English");<br />

// Get the units to use in the conversion from Storage to UI. IUnit<br />

unit_from = invariantSystem.GetUnit(measurement);<br />

IUnit unit_to = uiSystem.GetUnit(measurement);<br />

// Create the converter and convert the data<br />

IUnitConverter converter;<br />

converter = uss.CurrentCatalog.GetConverter(unit_from, unit_to);<br />

double converted = converter.Convert(myObject.Value);<br />

...<br />

4-214 <strong>Ocean</strong> Application Development Framework 2008.1<br />

<strong>Schlumberger</strong> Private

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!