02.05.2014 Views

Ocean* Application Development Framework - Ocean - Schlumberger

Ocean* Application Development Framework - Ocean - Schlumberger

Ocean* Application Development Framework - 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 />

Shown below is an example setting up and using a converter:<br />

...<br />

// Find the unit service and catalog<br />

IUnitService us;<br />

us = CoreSystem.GetService() as IUnitService;<br />

IUnitCatalog catalog = us.GetCatalog(null);<br />

// units for degrees in fahrenheit and celcius<br />

IUnit f = catalog.GetUnit(“Deg F”);<br />

IUnit c = catalog.GetUnit(“Deg C”);<br />

// Create the converter<br />

IUnitConverter f2c = catalog.GetConverter(f, c);<br />

...<br />

The IUnitConverter.Convert method is overloaded to perform the conversion<br />

of double or float values. Individual values, arrays, or portions of arrays can be<br />

converted.<br />

...<br />

// Create the converter<br />

IUnitConverter f2c = catalog.GetConverter(f, c);<br />

// Define arrays of values to convert.<br />

float[ ] fa;<br />

double[ ] da;<br />

// Use your favorite code to populate the array<br />

...<br />

// Convert single values<br />

float a = f2c.Convert(32.0f);<br />

double b = f2c.Convert(32.0);<br />

// Convert the arrays<br />

float[ ] c = f2c.Convert(fa);<br />

double[ ] d = f2c.Convert(da);<br />

// Convert part of the arrays in place.<br />

f2c.Convert(fa, 0, 5);<br />

f2c.Convert(da, 0, 5);<br />

...<br />

Unit Conversion for<br />

Domain Objects<br />

Object data is often stored with units that are not the desired units for presentation<br />

to the user in an application. For example, time might be stored in seconds while<br />

milliseconds are the common units for presentation. It is therefore necessary to<br />

convert the data and units from the storage representation to the user interface<br />

representation (Fig. 4-14 on page 4-172). The data received by the <strong>Ocean</strong> API is<br />

<strong>Schlumberger</strong> Private - Customer Use<br />

<strong>Ocean</strong> Services 4-171

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

Saved successfully!

Ooh no, something went wrong!