SlideShare une entreprise Scribd logo
1  sur  41
Eclipse UOMo Units of Measurement Support for Java and OSGi
Our Goal Avoiding Interface and Arithmetic Errors
Emphasis Most of today’s technologies including the current Java Language Releases lack support for common non-trivial Arithmetic problems like Unit Conversions.
Present Situation Historic IT Errors and Bugs Cause of Conversion Errors  Proposed Changes Type Safety Unit Frameworks History Features, Pros and Cons UOMo Overview UCUM Business Demo Q&A Summary
Patriot MissileThe cause was an inaccurate calculation of the time since boot due to a computer arithmetic error. Ariane 5 ExplosionThe floating point number which a value was converted from had a value greater than what would be represented by a 16 bit signed integer. What do these disasters have in common?
Gimli Glider (near disaster)Fuel loading was miscalculated through misunderstanding of the recently adopted Metric System, replacing the Imperial System Mars Orbiter Preliminary findings indicate that one team used English units (e.g. inches, feet and pounds) while the other used metric units for a key spacecraft operation. NASA lost a $125 million Mars orbiter because a Lockheed Martin engineering team used English units of measurement while the agency's team used the more conventional metric system for a key spacecraft operation This also underlines the added risk when 3rd party contractors are involved or projects are developed Offshore What do these disasters have in common?
NASA “Star Wars” Experiment, 1983 23rd March 1983. Ronald Reagan announces SDI (or “Star Wars”): ground-based and space-based systems to protect the US from attack by strategic nuclear ballistic missiles.
1985 Mirror on underside of shuttle SDI Experiment: The Plan Big mountain in Hawaii
1985 SDI Experiment: What really happened
1985: What happened?
NASA Mars Climate Orbiter, 1999
All previous example illustrate three categories of errors difficult to find through Unit Testing: Interface Errors (e.g. millisecond/second, radian/degree, meters/feet). Arithmetic Errors (e.g. overflow). Conversion Errors. Unit Tests did not find these Errors Despite their name
Ambiguity on the unit Gallon Dry / Gallon Liquid Gallon US / Gallon UK Day Sidereal / Day Calendar ... Wrong conversion factors: static final double PIXEL_TO_INCH = 1 / 72; double pixels = inches * PIXEL_TO_INCH Causes of Conversion Errors
Java does not have strongly typed primitive types (like e.g. Ada language). For performance reasons most developer prefer primitive types over objects in their interface. Primitives type arguments often lead to name clashes (methods with the same signature)‏ Present Situation
Base Classes and Packages Namespace: javax.measure.* Only one interface and one abstract class Measurable<Q extends Quantity> (interface)‏ Measure<V, Q extends Quantity> (abstract class)‏ Three sub-packages unit (holds the SI and NonSI units)‏ quantity (holds dimensions mass, length)‏ converter (holds unit converters)‏ JSR-275
Units of Measurement API Namespace: org.unitsofmeasurement.* Only interfaces (and exception classes) public interface Quantity<Q extends Quantity<Q>> public interface Unit<Q extends Quantity<Q>> Three sub-packages quantity (holds dimensions mass, length) unit(holds units) service (OSGi services) The King is Dead…
Unit-API | Operations Results with Same Dimension		Different Dimension Binary OperationsBinary Operations add(double) or (long)		root(int) multiply(double) or (long)	power(int) divide(double) or (long)		multiply(Unit) compound(Unit)			divide(Unit) Unary Operations 	inverse()
Mobile Sensor API Namespace: javax.microediton.sensor* Focusing on Sensors, but it got a minimalistic Unit API “in the closet” Unit	Essentially an SI singleton holding relevant unit constants, too. ChannelInfoHolding name, accuracy, data type,measurement ranges, scale and unit MeasurementRangeRange of possible values from minimum to maximum JSR-256
Sensor States JSR-256
Sensor Groups Context types categorize sensors into three groups:  ambient, sensors measuring some ambient property of the environment  device, sensors measuring properties related to the device  user, sensors measuring some function of the user  By using context types, it is possible to find, for example, user-related sensors for fitness, or ambient sensors for smart home controlling. Although the granularity of this level does not qualify the sensors very precisely, still in some cases it provides the way to make the distinction, for example, cf. air thermometer (ambient) / clinical thermometer (user).  JSR-256
Quantity The quantity provides a more precise qualifier. The unit and the quantity has a close relation. Some quantities are listed in tables of Unit class. When the quantity and context type is known, it is often easy to guess the full purpose of the sensor. Some examples are given here:  Quantity: electric_current + context type: ambient = sensor measuring electric current, amperemeter Quantity: catalytic_activity + contex type: ambient = sensor measuring catalytic activity JSR-256
Measurement Package Namespace: org.osgi.util.measurement SI only Unit API “in the closet” Unit	Essentially an SI singleton holding relevant unit constants, too. MeasurementRepresents a value with an error, a unit and a time-stamp.  StateGroups a state name, value and timestamp. OSGi
DEMO Unit Frameworks
Eclipse UOMo One Small Step…
One Unit Framework to Measure them All Namespace: org.eclipse.uomo.* Two main areas Static Type Safe Units of Measure Support Based on Units of Measurement API On top of ICU4J, the Globalization standard at Eclipse and others (Android, GWT, Google Financial, etc.) Prime UCUM Implementation Successor to Eclipse OHF UCUM Bundle Eclipse UOMo
Bundles UOMo currently consists of UOMo Core General parts of the framework, reusable components UOMo Util Utility classes, Formatting, Date/Time and other ICU4J or Unicode related items UOMo XML XMLPull and support for Markup Languages like UnitsML or MathML Eclipse UOMo
Bundles (2) UOMo Units Based on Units of Measurement API UOMo UCUM Unified Code for Units of Measure support UOMo Business Business Types and Monetary System Eclipse UOMo
UOMo Units | System of Units
Unified  Code for Units of Measure The Unified Code for Units of Measure is a code system intended to include all units of measures being contemporarily used in international science, engineering, and business. The purpose is to facilitate unambiguous electronic communication of quantities together with their units. The focus is on electronic communication, as opposed to communication between humans. A typical application of The Unified Code for Units of Measure are electronic data interchange (EDI) protocols, but there is nothing that prevents it from being used in other types of machine communication. How does it relate? UOMo UCUM
Unified  Code for Units of Measure The Unified Code for Units of Measure is inspired by and heavily based on ISO 2955-1983 ANSI X3.50-1986 HL7's extensions called ISO+ UOMo UCUM
DEMO Eclipse UOMo
Monetary systems are part of UOMo Business. This illustrates, how easily the Units bundle and underlying Unit-API can be extended beyondphysical or scientific quantities. Such extension can be valuable by leveraging the framework’s capabilities (formatting, conversion,…)  and applying its usefulness beyond what e.g. java.util.Currency now has to offer. UOMo Business | Monetary System
UOMo Business | Monetary Types
We’ll extend MoneyDemo to show fuel costs in Indian Rupees. First by adding a new currency to MonetarySystem. // Use currency not defined as constant (Indian Rupee). public static final DerivedUnit<Money> INR= monetary(new Currency(„INR„)); Then add this line to MoneyDemo.(also change static import to MonetarySystem.*; ) UnitFormat.getInstance().label(INR, „Rp"); UOMo Business | Money Demo (1)
Next set the Exchange Rate for Rp. ((Currency) INR).setExchangeRate(0.022);   // 1.0Rp = ~0.022 $ Note, the explicit cast is required here, because getUnits() in SystemOfUnits currently requires a neutral <?> generic collection type. UOMo Business | Money Demo (2)
Then we add the following line to the “Display cost.” section of MoneyDemo System.out.println("Trip cost = " + tripCost + " (" + tripCost.to(INR) + ")"); Resulting in the additional output: Trip cost = 87.50 $ (3977.26 Rp) UOMo Business | Money Demo (3)
What happens, if we use built in java.util.Currency and Standard JSP formats UOMo Business | Trading Example
DEMO UOMo Business
Links Eclipse – Project UOMo http://www.eclipse.org/uomo/ Units of Measurement API http://www.unitsofmeasurement.org UCUM http://www.unitsofmeasure.org
Q&A Questions ?
Contact werner@emergn.com or  uomo@catmedia.us Twitter: @wernerkeil

Contenu connexe

Similaire à Mr. Keil Werner - UOMO 2011

Automatic Test Generation for Space
Automatic Test Generation for SpaceAutomatic Test Generation for Space
Automatic Test Generation for SpaceUlisses Costa
 
Fault Tolerance System
Fault Tolerance SystemFault Tolerance System
Fault Tolerance Systemprakashjjaya
 
Software Requirements and Design Process in the Aerospace Industry
Software Requirements and Design Process in the Aerospace IndustrySoftware Requirements and Design Process in the Aerospace Industry
Software Requirements and Design Process in the Aerospace IndustryLeif Bloomquist
 
Error Isolation and Management in Agile Multi-Tenant Cloud Based Applications
Error Isolation and Management in Agile Multi-Tenant Cloud Based Applications Error Isolation and Management in Agile Multi-Tenant Cloud Based Applications
Error Isolation and Management in Agile Multi-Tenant Cloud Based Applications neirew J
 
Error isolation and management in agile
Error isolation and management in agileError isolation and management in agile
Error isolation and management in agileijccsa
 
A WORKSPACE SIMULATION FOR TAL TR-2 ARTICULATED ROBOT
A WORKSPACE SIMULATION FOR TAL TR-2 ARTICULATED ROBOT A WORKSPACE SIMULATION FOR TAL TR-2 ARTICULATED ROBOT
A WORKSPACE SIMULATION FOR TAL TR-2 ARTICULATED ROBOT IAEME Publication
 
M4M 2 the Rescue of M2M - Eclipse DemoCamps Kepler 2013
M4M 2 the Rescue of M2M - Eclipse DemoCamps Kepler 2013M4M 2 the Rescue of M2M - Eclipse DemoCamps Kepler 2013
M4M 2 the Rescue of M2M - Eclipse DemoCamps Kepler 2013Werner Keil
 
Model Based System Random Test For Smart OS
Model Based System Random Test For Smart OSModel Based System Random Test For Smart OS
Model Based System Random Test For Smart OSLex Yu
 
University course on aerospace projects management and se complete 2017
University course on aerospace projects management and se complete 2017University course on aerospace projects management and se complete 2017
University course on aerospace projects management and se complete 2017Panagiotis (Panos) Xefteris
 
201201 ureason introduction to use
201201 ureason introduction to use201201 ureason introduction to use
201201 ureason introduction to useUReasonChannel
 
Exploring the capabilities of the tight integration of HyperWorks and ESAComp
Exploring the capabilities of the tight integration of HyperWorks and ESACompExploring the capabilities of the tight integration of HyperWorks and ESAComp
Exploring the capabilities of the tight integration of HyperWorks and ESACompAltair
 
Running Head WINDOWS AND LINUX 1WINDOWS AND LINUX12.docx
Running Head WINDOWS AND LINUX     1WINDOWS AND LINUX12.docxRunning Head WINDOWS AND LINUX     1WINDOWS AND LINUX12.docx
Running Head WINDOWS AND LINUX 1WINDOWS AND LINUX12.docxjeffsrosalyn
 
Applying Drools in Assistive Technology
Applying Drools in Assistive TechnologyApplying Drools in Assistive Technology
Applying Drools in Assistive Technologytsurdilovic
 
Data Exchange Standards & STEP, EXPRESS & EXPRESS-G
Data Exchange Standards & STEP, EXPRESS & EXPRESS-GData Exchange Standards & STEP, EXPRESS & EXPRESS-G
Data Exchange Standards & STEP, EXPRESS & EXPRESS-Gmetalalp
 
M4M 2 the Rescue of M2M (Eclipse DemoCamp Trondheim)
M4M 2 the Rescue of M2M (Eclipse DemoCamp Trondheim)M4M 2 the Rescue of M2M (Eclipse DemoCamp Trondheim)
M4M 2 the Rescue of M2M (Eclipse DemoCamp Trondheim)Werner Keil
 
Chapter 1 Data structure.pptx
Chapter 1 Data structure.pptxChapter 1 Data structure.pptx
Chapter 1 Data structure.pptxwondmhunegn
 
Introduction to synchronous programming langauges
Introduction to synchronous programming langaugesIntroduction to synchronous programming langauges
Introduction to synchronous programming langaugesAkshar Desai
 
M4M 2 the Rescue of M2M - Eclipse DemoCamps Fall 2013
M4M 2 the Rescue of M2M - Eclipse DemoCamps Fall 2013M4M 2 the Rescue of M2M - Eclipse DemoCamps Fall 2013
M4M 2 the Rescue of M2M - Eclipse DemoCamps Fall 2013Werner Keil
 

Similaire à Mr. Keil Werner - UOMO 2011 (20)

Automatic Test Generation for Space
Automatic Test Generation for SpaceAutomatic Test Generation for Space
Automatic Test Generation for Space
 
Fault Tolerance System
Fault Tolerance SystemFault Tolerance System
Fault Tolerance System
 
Software Requirements and Design Process in the Aerospace Industry
Software Requirements and Design Process in the Aerospace IndustrySoftware Requirements and Design Process in the Aerospace Industry
Software Requirements and Design Process in the Aerospace Industry
 
Error Isolation and Management in Agile Multi-Tenant Cloud Based Applications
Error Isolation and Management in Agile Multi-Tenant Cloud Based Applications Error Isolation and Management in Agile Multi-Tenant Cloud Based Applications
Error Isolation and Management in Agile Multi-Tenant Cloud Based Applications
 
Error isolation and management in agile
Error isolation and management in agileError isolation and management in agile
Error isolation and management in agile
 
A WORKSPACE SIMULATION FOR TAL TR-2 ARTICULATED ROBOT
A WORKSPACE SIMULATION FOR TAL TR-2 ARTICULATED ROBOT A WORKSPACE SIMULATION FOR TAL TR-2 ARTICULATED ROBOT
A WORKSPACE SIMULATION FOR TAL TR-2 ARTICULATED ROBOT
 
M4M 2 the Rescue of M2M - Eclipse DemoCamps Kepler 2013
M4M 2 the Rescue of M2M - Eclipse DemoCamps Kepler 2013M4M 2 the Rescue of M2M - Eclipse DemoCamps Kepler 2013
M4M 2 the Rescue of M2M - Eclipse DemoCamps Kepler 2013
 
Model Based System Random Test For Smart OS
Model Based System Random Test For Smart OSModel Based System Random Test For Smart OS
Model Based System Random Test For Smart OS
 
The OHF Legacy
The OHF LegacyThe OHF Legacy
The OHF Legacy
 
University course on aerospace projects management and se complete 2017
University course on aerospace projects management and se complete 2017University course on aerospace projects management and se complete 2017
University course on aerospace projects management and se complete 2017
 
201201 ureason introduction to use
201201 ureason introduction to use201201 ureason introduction to use
201201 ureason introduction to use
 
Mini Project- ROM Based Sine Wave Generator
Mini Project- ROM Based Sine Wave GeneratorMini Project- ROM Based Sine Wave Generator
Mini Project- ROM Based Sine Wave Generator
 
Exploring the capabilities of the tight integration of HyperWorks and ESAComp
Exploring the capabilities of the tight integration of HyperWorks and ESACompExploring the capabilities of the tight integration of HyperWorks and ESAComp
Exploring the capabilities of the tight integration of HyperWorks and ESAComp
 
Running Head WINDOWS AND LINUX 1WINDOWS AND LINUX12.docx
Running Head WINDOWS AND LINUX     1WINDOWS AND LINUX12.docxRunning Head WINDOWS AND LINUX     1WINDOWS AND LINUX12.docx
Running Head WINDOWS AND LINUX 1WINDOWS AND LINUX12.docx
 
Applying Drools in Assistive Technology
Applying Drools in Assistive TechnologyApplying Drools in Assistive Technology
Applying Drools in Assistive Technology
 
Data Exchange Standards & STEP, EXPRESS & EXPRESS-G
Data Exchange Standards & STEP, EXPRESS & EXPRESS-GData Exchange Standards & STEP, EXPRESS & EXPRESS-G
Data Exchange Standards & STEP, EXPRESS & EXPRESS-G
 
M4M 2 the Rescue of M2M (Eclipse DemoCamp Trondheim)
M4M 2 the Rescue of M2M (Eclipse DemoCamp Trondheim)M4M 2 the Rescue of M2M (Eclipse DemoCamp Trondheim)
M4M 2 the Rescue of M2M (Eclipse DemoCamp Trondheim)
 
Chapter 1 Data structure.pptx
Chapter 1 Data structure.pptxChapter 1 Data structure.pptx
Chapter 1 Data structure.pptx
 
Introduction to synchronous programming langauges
Introduction to synchronous programming langaugesIntroduction to synchronous programming langauges
Introduction to synchronous programming langauges
 
M4M 2 the Rescue of M2M - Eclipse DemoCamps Fall 2013
M4M 2 the Rescue of M2M - Eclipse DemoCamps Fall 2013M4M 2 the Rescue of M2M - Eclipse DemoCamps Fall 2013
M4M 2 the Rescue of M2M - Eclipse DemoCamps Fall 2013
 

Plus de beloslab

Mr. Keil Werner - Stem demo camp
Mr. Keil Werner - Stem demo campMr. Keil Werner - Stem demo camp
Mr. Keil Werner - Stem demo campbeloslab
 
Mr. Ankur Sharma - PDE good practices
Mr. Ankur Sharma - PDE good practicesMr. Ankur Sharma - PDE good practices
Mr. Ankur Sharma - PDE good practicesbeloslab
 
Konstantin Slisenko - OSGi, Equinox, Eclipse plug-in development, v 2.0
Konstantin Slisenko - OSGi, Equinox, Eclipse plug-in development, v 2.0Konstantin Slisenko - OSGi, Equinox, Eclipse plug-in development, v 2.0
Konstantin Slisenko - OSGi, Equinox, Eclipse plug-in development, v 2.0beloslab
 
Konstantin Slisenko - Belarus Open Source Lab
Konstantin Slisenko - Belarus Open Source LabKonstantin Slisenko - Belarus Open Source Lab
Konstantin Slisenko - Belarus Open Source Labbeloslab
 
Konstantin Slisenko - OSGi, Equinox, Eclipse plug-in developement
Konstantin Slisenko -  OSGi, Equinox, Eclipse plug-in developementKonstantin Slisenko -  OSGi, Equinox, Eclipse plug-in developement
Konstantin Slisenko - OSGi, Equinox, Eclipse plug-in developementbeloslab
 
Yuri Trukhin - IE9 Launch
Yuri Trukhin - IE9 LaunchYuri Trukhin - IE9 Launch
Yuri Trukhin - IE9 Launchbeloslab
 
Yuri Trukhin - Software developement best practices
Yuri Trukhin - Software developement best practicesYuri Trukhin - Software developement best practices
Yuri Trukhin - Software developement best practicesbeloslab
 
Yuri Trukhin - Microsoft4students
Yuri Trukhin - Microsoft4studentsYuri Trukhin - Microsoft4students
Yuri Trukhin - Microsoft4studentsbeloslab
 
Yuri Trukhin - Windows Phone 7
Yuri Trukhin - Windows Phone 7Yuri Trukhin - Windows Phone 7
Yuri Trukhin - Windows Phone 7beloslab
 
Pavel Rumantsev - Java Script
Pavel Rumantsev - Java ScriptPavel Rumantsev - Java Script
Pavel Rumantsev - Java Scriptbeloslab
 
Sergey Gavruk - Mix11
Sergey Gavruk - Mix11Sergey Gavruk - Mix11
Sergey Gavruk - Mix11beloslab
 
Konstantin slisenko - Spring Framework
Konstantin slisenko - Spring FrameworkKonstantin slisenko - Spring Framework
Konstantin slisenko - Spring Frameworkbeloslab
 
Aleksei Gomza - ASP.NET MVC3 data processing
Aleksei Gomza - ASP.NET MVC3 data processingAleksei Gomza - ASP.NET MVC3 data processing
Aleksei Gomza - ASP.NET MVC3 data processingbeloslab
 
Aleksei Gomza - Web-applications and ASP
Aleksei Gomza - Web-applications and ASPAleksei Gomza - Web-applications and ASP
Aleksei Gomza - Web-applications and ASPbeloslab
 
Sergey Gavruk - WebMatrix
Sergey Gavruk - WebMatrixSergey Gavruk - WebMatrix
Sergey Gavruk - WebMatrixbeloslab
 
Konstantin slisenko - Design patterns
Konstantin slisenko - Design patternsKonstantin slisenko - Design patterns
Konstantin slisenko - Design patternsbeloslab
 

Plus de beloslab (16)

Mr. Keil Werner - Stem demo camp
Mr. Keil Werner - Stem demo campMr. Keil Werner - Stem demo camp
Mr. Keil Werner - Stem demo camp
 
Mr. Ankur Sharma - PDE good practices
Mr. Ankur Sharma - PDE good practicesMr. Ankur Sharma - PDE good practices
Mr. Ankur Sharma - PDE good practices
 
Konstantin Slisenko - OSGi, Equinox, Eclipse plug-in development, v 2.0
Konstantin Slisenko - OSGi, Equinox, Eclipse plug-in development, v 2.0Konstantin Slisenko - OSGi, Equinox, Eclipse plug-in development, v 2.0
Konstantin Slisenko - OSGi, Equinox, Eclipse plug-in development, v 2.0
 
Konstantin Slisenko - Belarus Open Source Lab
Konstantin Slisenko - Belarus Open Source LabKonstantin Slisenko - Belarus Open Source Lab
Konstantin Slisenko - Belarus Open Source Lab
 
Konstantin Slisenko - OSGi, Equinox, Eclipse plug-in developement
Konstantin Slisenko -  OSGi, Equinox, Eclipse plug-in developementKonstantin Slisenko -  OSGi, Equinox, Eclipse plug-in developement
Konstantin Slisenko - OSGi, Equinox, Eclipse plug-in developement
 
Yuri Trukhin - IE9 Launch
Yuri Trukhin - IE9 LaunchYuri Trukhin - IE9 Launch
Yuri Trukhin - IE9 Launch
 
Yuri Trukhin - Software developement best practices
Yuri Trukhin - Software developement best practicesYuri Trukhin - Software developement best practices
Yuri Trukhin - Software developement best practices
 
Yuri Trukhin - Microsoft4students
Yuri Trukhin - Microsoft4studentsYuri Trukhin - Microsoft4students
Yuri Trukhin - Microsoft4students
 
Yuri Trukhin - Windows Phone 7
Yuri Trukhin - Windows Phone 7Yuri Trukhin - Windows Phone 7
Yuri Trukhin - Windows Phone 7
 
Pavel Rumantsev - Java Script
Pavel Rumantsev - Java ScriptPavel Rumantsev - Java Script
Pavel Rumantsev - Java Script
 
Sergey Gavruk - Mix11
Sergey Gavruk - Mix11Sergey Gavruk - Mix11
Sergey Gavruk - Mix11
 
Konstantin slisenko - Spring Framework
Konstantin slisenko - Spring FrameworkKonstantin slisenko - Spring Framework
Konstantin slisenko - Spring Framework
 
Aleksei Gomza - ASP.NET MVC3 data processing
Aleksei Gomza - ASP.NET MVC3 data processingAleksei Gomza - ASP.NET MVC3 data processing
Aleksei Gomza - ASP.NET MVC3 data processing
 
Aleksei Gomza - Web-applications and ASP
Aleksei Gomza - Web-applications and ASPAleksei Gomza - Web-applications and ASP
Aleksei Gomza - Web-applications and ASP
 
Sergey Gavruk - WebMatrix
Sergey Gavruk - WebMatrixSergey Gavruk - WebMatrix
Sergey Gavruk - WebMatrix
 
Konstantin slisenko - Design patterns
Konstantin slisenko - Design patternsKonstantin slisenko - Design patterns
Konstantin slisenko - Design patterns
 

Mr. Keil Werner - UOMO 2011

  • 1. Eclipse UOMo Units of Measurement Support for Java and OSGi
  • 2. Our Goal Avoiding Interface and Arithmetic Errors
  • 3. Emphasis Most of today’s technologies including the current Java Language Releases lack support for common non-trivial Arithmetic problems like Unit Conversions.
  • 4. Present Situation Historic IT Errors and Bugs Cause of Conversion Errors Proposed Changes Type Safety Unit Frameworks History Features, Pros and Cons UOMo Overview UCUM Business Demo Q&A Summary
  • 5. Patriot MissileThe cause was an inaccurate calculation of the time since boot due to a computer arithmetic error. Ariane 5 ExplosionThe floating point number which a value was converted from had a value greater than what would be represented by a 16 bit signed integer. What do these disasters have in common?
  • 6. Gimli Glider (near disaster)Fuel loading was miscalculated through misunderstanding of the recently adopted Metric System, replacing the Imperial System Mars Orbiter Preliminary findings indicate that one team used English units (e.g. inches, feet and pounds) while the other used metric units for a key spacecraft operation. NASA lost a $125 million Mars orbiter because a Lockheed Martin engineering team used English units of measurement while the agency's team used the more conventional metric system for a key spacecraft operation This also underlines the added risk when 3rd party contractors are involved or projects are developed Offshore What do these disasters have in common?
  • 7. NASA “Star Wars” Experiment, 1983 23rd March 1983. Ronald Reagan announces SDI (or “Star Wars”): ground-based and space-based systems to protect the US from attack by strategic nuclear ballistic missiles.
  • 8. 1985 Mirror on underside of shuttle SDI Experiment: The Plan Big mountain in Hawaii
  • 9. 1985 SDI Experiment: What really happened
  • 11. NASA Mars Climate Orbiter, 1999
  • 12. All previous example illustrate three categories of errors difficult to find through Unit Testing: Interface Errors (e.g. millisecond/second, radian/degree, meters/feet). Arithmetic Errors (e.g. overflow). Conversion Errors. Unit Tests did not find these Errors Despite their name
  • 13. Ambiguity on the unit Gallon Dry / Gallon Liquid Gallon US / Gallon UK Day Sidereal / Day Calendar ... Wrong conversion factors: static final double PIXEL_TO_INCH = 1 / 72; double pixels = inches * PIXEL_TO_INCH Causes of Conversion Errors
  • 14. Java does not have strongly typed primitive types (like e.g. Ada language). For performance reasons most developer prefer primitive types over objects in their interface. Primitives type arguments often lead to name clashes (methods with the same signature)‏ Present Situation
  • 15. Base Classes and Packages Namespace: javax.measure.* Only one interface and one abstract class Measurable<Q extends Quantity> (interface)‏ Measure<V, Q extends Quantity> (abstract class)‏ Three sub-packages unit (holds the SI and NonSI units)‏ quantity (holds dimensions mass, length)‏ converter (holds unit converters)‏ JSR-275
  • 16. Units of Measurement API Namespace: org.unitsofmeasurement.* Only interfaces (and exception classes) public interface Quantity<Q extends Quantity<Q>> public interface Unit<Q extends Quantity<Q>> Three sub-packages quantity (holds dimensions mass, length) unit(holds units) service (OSGi services) The King is Dead…
  • 17. Unit-API | Operations Results with Same Dimension Different Dimension Binary OperationsBinary Operations add(double) or (long) root(int) multiply(double) or (long) power(int) divide(double) or (long) multiply(Unit) compound(Unit) divide(Unit) Unary Operations inverse()
  • 18. Mobile Sensor API Namespace: javax.microediton.sensor* Focusing on Sensors, but it got a minimalistic Unit API “in the closet” Unit Essentially an SI singleton holding relevant unit constants, too. ChannelInfoHolding name, accuracy, data type,measurement ranges, scale and unit MeasurementRangeRange of possible values from minimum to maximum JSR-256
  • 20. Sensor Groups Context types categorize sensors into three groups: ambient, sensors measuring some ambient property of the environment device, sensors measuring properties related to the device user, sensors measuring some function of the user By using context types, it is possible to find, for example, user-related sensors for fitness, or ambient sensors for smart home controlling. Although the granularity of this level does not qualify the sensors very precisely, still in some cases it provides the way to make the distinction, for example, cf. air thermometer (ambient) / clinical thermometer (user). JSR-256
  • 21. Quantity The quantity provides a more precise qualifier. The unit and the quantity has a close relation. Some quantities are listed in tables of Unit class. When the quantity and context type is known, it is often easy to guess the full purpose of the sensor. Some examples are given here: Quantity: electric_current + context type: ambient = sensor measuring electric current, amperemeter Quantity: catalytic_activity + contex type: ambient = sensor measuring catalytic activity JSR-256
  • 22. Measurement Package Namespace: org.osgi.util.measurement SI only Unit API “in the closet” Unit Essentially an SI singleton holding relevant unit constants, too. MeasurementRepresents a value with an error, a unit and a time-stamp. StateGroups a state name, value and timestamp. OSGi
  • 24. Eclipse UOMo One Small Step…
  • 25. One Unit Framework to Measure them All Namespace: org.eclipse.uomo.* Two main areas Static Type Safe Units of Measure Support Based on Units of Measurement API On top of ICU4J, the Globalization standard at Eclipse and others (Android, GWT, Google Financial, etc.) Prime UCUM Implementation Successor to Eclipse OHF UCUM Bundle Eclipse UOMo
  • 26. Bundles UOMo currently consists of UOMo Core General parts of the framework, reusable components UOMo Util Utility classes, Formatting, Date/Time and other ICU4J or Unicode related items UOMo XML XMLPull and support for Markup Languages like UnitsML or MathML Eclipse UOMo
  • 27. Bundles (2) UOMo Units Based on Units of Measurement API UOMo UCUM Unified Code for Units of Measure support UOMo Business Business Types and Monetary System Eclipse UOMo
  • 28. UOMo Units | System of Units
  • 29. Unified Code for Units of Measure The Unified Code for Units of Measure is a code system intended to include all units of measures being contemporarily used in international science, engineering, and business. The purpose is to facilitate unambiguous electronic communication of quantities together with their units. The focus is on electronic communication, as opposed to communication between humans. A typical application of The Unified Code for Units of Measure are electronic data interchange (EDI) protocols, but there is nothing that prevents it from being used in other types of machine communication. How does it relate? UOMo UCUM
  • 30. Unified Code for Units of Measure The Unified Code for Units of Measure is inspired by and heavily based on ISO 2955-1983 ANSI X3.50-1986 HL7's extensions called ISO+ UOMo UCUM
  • 32. Monetary systems are part of UOMo Business. This illustrates, how easily the Units bundle and underlying Unit-API can be extended beyondphysical or scientific quantities. Such extension can be valuable by leveraging the framework’s capabilities (formatting, conversion,…) and applying its usefulness beyond what e.g. java.util.Currency now has to offer. UOMo Business | Monetary System
  • 33. UOMo Business | Monetary Types
  • 34. We’ll extend MoneyDemo to show fuel costs in Indian Rupees. First by adding a new currency to MonetarySystem. // Use currency not defined as constant (Indian Rupee). public static final DerivedUnit<Money> INR= monetary(new Currency(„INR„)); Then add this line to MoneyDemo.(also change static import to MonetarySystem.*; ) UnitFormat.getInstance().label(INR, „Rp"); UOMo Business | Money Demo (1)
  • 35. Next set the Exchange Rate for Rp. ((Currency) INR).setExchangeRate(0.022); // 1.0Rp = ~0.022 $ Note, the explicit cast is required here, because getUnits() in SystemOfUnits currently requires a neutral <?> generic collection type. UOMo Business | Money Demo (2)
  • 36. Then we add the following line to the “Display cost.” section of MoneyDemo System.out.println("Trip cost = " + tripCost + " (" + tripCost.to(INR) + ")"); Resulting in the additional output: Trip cost = 87.50 $ (3977.26 Rp) UOMo Business | Money Demo (3)
  • 37. What happens, if we use built in java.util.Currency and Standard JSP formats UOMo Business | Trading Example
  • 39. Links Eclipse – Project UOMo http://www.eclipse.org/uomo/ Units of Measurement API http://www.unitsofmeasurement.org UCUM http://www.unitsofmeasure.org
  • 41. Contact werner@emergn.com or uomo@catmedia.us Twitter: @wernerkeil