SlideShare a Scribd company logo
1 of 20
@UnitAPI#JSR363
The First IoT JSR: Units of Measurement
JSR-363
Werner Keil | Otávio Santana
@wernerkeil | @otaviojava
@UnitAPI
https://www.jcp.org/en/jsr/detail?id=363
http://unitsofmeasurement.github.io
@UnitAPI#JSR363
What is JSR-363?
6,370.98 miles
A Quantity
A Unit
@UnitAPI#JSR363
Why do we need JSR-363?
There are no specifications or standards for handling units in Java.
The current solution is to use primitives, that don’t provide any Type
Safety.
The errors are difficult to find using unit testing:
Interface and Internationalization (e.g. radian/degree, meters/feet);
Arithmetic operations (e.g. overflow);
Conversion between units (e.g. from same domain);
@UnitAPI#JSR363
What is JSR-363?
Interfaces and abstract classes supporting unit operations including:
Checking of unit compatibility;
Expression of measurement in various units; and
Arithmetic operations on units.
Concrete classes implementing standard unit types (base, derived), unit
conversion and representation.
A framework supporting robust representation and correct handling of
quantities.
JSR 363 establishes safe and useful methods for modeling physical
quantities.
@UnitAPI#JSR363
System of Units
System International d’Unites (SI)
The accepted basis for most scientific and engineering
activities.
Standard units for key physical quantities
(length, time, power etc.)
Standard prefixes
(kilo/micro etc.)
Standard dimensions…
@UnitAPI#JSR363
Dimension
Allows analysis of a quantity by the rational powers of the 7 fundamental
dimensions (quantities are compatible when they have the same
dimensions):
length (L), mass (M), time (T), electric charge (I), absolute temperature
(Θ), amount of substance (N) and luminous intensity (J)
Examples:
Speed = length/time - it’s dimensions are L=1,T=-1 (rest 0) (e.g. metre/second - ms-1)
Acceleration is speed/time (m/s/s or ms-2) L=1, T=-2
Force is mass x acceleration M x ((length/time)/time) or M=1, L=1, T=-2
Molar Entropy: M=1 L=2 T=−2 Θ=−1 N=−1 (trust me!)
@UnitAPI#JSR363
Quantity
A physical attribute of a thing. Something that can be measured and has
units. Compatible quantities have the same dimension…
Examples:
• Time
• Length
• Speed
• Amount of Substance
• Luminous Intensity
• Volume
• Mass
• Force
• Power
• Electrical Current
• Magnetic Flux Density
• Volumetric Flow Rate
• Fuel Economy*
• Percentage
• Eggs per carton
• Sheep per hour
• Bits and bytes …
… ∞
@UnitAPI#JSR363
Unit Conversion
The process of conversion depends on the specific situation and the
intended purpose. This may be governed by regulation, contract,
technical specifications or other published standards.
Wikipedia
@UnitAPI#JSR363
1983: The Gimli “Glider”
Photo: Wayne Glowacki
Maintenance workers performed a test that estimated that 7,682 litres of
fuel were in the tank. They knew they needed 22,300 kilograms of fuel
for the remaining flight, so the question was, How much fuel, in litres,
should be pumped from the fuel truck into the aircraft? They were
forced to resort to a manual calculation:
They multiplied 7,682 L by 1.77, the density of the fuel provided by the
refuelling company on their documentation: The aircraft, according to
their calculations, currently had 13,597 kg of fuel.
Subtracting from 22,300 kg, they decided they needed to add 8,703 kg of
fuel.
Dividing by 1.77 — the same density used in the previous calculation —
yields 4,916 L, which was pumped into the aircraft.
However, 1.77 was the density of the fuel in pounds per litre (lb/L), not
kilograms per litre (kg/L); the correct figure for kg/L would have been
0.80. As a result, they ended up with less than half of the required
amount of fuel on board. (The fuel's density depends on
characteristics of the fuel, so it's not a constant, and the value must
be taken from documentation accompanying the fuel.)
@UnitAPI#JSR363
Some real-life mishaps…
[Cost $125M]
“Preliminary findings indicate that one team used US/English units (e.g.
inches, feet and pounds) while the other used metric units for a key
spacecraft operation.”
NASA Mars Climate Orbiter, 1999
@UnitAPI#JSR363
Conversion problems
These are examples of confusion on the units in application.
But there is also ambiguity on the unit itself:
10 Gallons … Gallon Dry / Gallon Liquid - Gallon US / Gallon UK
28 Days … Day Sidereal / Day Calendar
38 Degrees … Degree Celsius / Degree Fahrenheit / Degree Angle
And the wrong conversion factors:
static final double PIXEL_TO_INCH = 1 / 72;
double pixels = inches * PIXEL_TO_INCH;
@UnitAPI#JSR363
What is the problem, in code?
float distance = 6370.98; //in miles
float speed = airplane.getSpeed(); //in km/h
System.out.println(“TTD: “ + (distance/speed) + “ h”);
6,370.98 miles
A Quantity
A Unit
@UnitAPI#JSR363
What is JSR-363, in code?
Quantity<Length> distance =
Quantities.getQuantity(6370.98, USCustomary.MILE);
Quantity<Speed> airplaneSpeed = getAirplaneSpeed();
Quantity<Time> timeToDest =
(Quantity<Time>)distance.divide(airplaneSpeed);
System.out.println(“TTD: “ + timeToDest.to(Units.HOUR));
TTD: 10.84983093613525 h
@UnitAPI#JSR363
Who is going to use JSR-363?
Java developers who work with physical quantities need to handle
measurements in their programs.
Inadequate models of physical measurements can lead to significant
programmatic errors.
Platform providers and developers can provide and use a more
well-defined API.
Embedded developers can have less error-prone, more self-
documented code.
@UnitAPI#JSR363
JSR-363: Internal Structure
JSR-363 is broken down into the following packages:
Package Description
javax.measure Core API interfaces (e.g. Dimension, Quantity, Unit)
javax.measure.format [optional] Interfaces for quantity/unit formatting and parsing
javax.measure.quantity [optional] Interfaces for quantity types (e.g. Mass, Length)
javax.measure.spi [optional] Service Provider Interface (implementation discovery)
Reason: We target very small devices running Java ME (CLDC 8) for IoT
applications (e.g. sensors, wearables, gateways etc.)
@UnitAPI#JSR363
JSR-363: Systems and
ExtensionsOn top of JSR-363 we offer support
for various unit systems:
• Reusable Quantities
• SI System
• Common Systems (US, Imperial)
• ISO 80000
• UCUM
Reason: By providing small, modular
libraries, we live and sometimes forestall
the ideas behind Java ME 8 or Jigsaw and
offer great flexibility to IoT solutions
@UnitAPI#JSR363
JSR-363 timeline
March 11, 2014: Submitted
April 7, 2014: Creation approved
Dec 2014 – January 2015: Early Draft (done)
Q3/2015 – Q4/2015: Public Review (approved)
Q2/2016 : Final Draft
Q3/2016 : Final Release
@YourTwitterHandle#DVXFR14{session hashtag} @UnitAPI#JSR363 Images: Showtime / Fox 21
@UnitAPI#JSR363
Links to JSR-363
Public mailing list(s) and/or forum(s)
Units-Dev on Google Groups
Units-Users on Google Groups
EG only mailing list on java.net, archive fully visible (while java.net
exists)
JSR detail page on JCP.org: https://www.jcp.org/en/jsr/detail?id=363
Project website on GitHub: unitsofmeasurement.github.io
@YourTwitterHandle#DVXFR14{session hashtag} @UnitAPI#JSR363

More Related Content

Similar to The First IoT JSR: Units of Measurement - JUG Berlin-Brandenburg

Proceedings
ProceedingsProceedings
Proceedings
butest
 
Mr. Keil Werner - UOMO 2011
Mr. Keil Werner - UOMO 2011Mr. Keil Werner - UOMO 2011
Mr. Keil Werner - UOMO 2011
beloslab
 
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
Werner Keil
 
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
 
Enhanced Skewed Load and Broadside Power Reduction in Transition Fault Testing
Enhanced Skewed Load and Broadside Power Reduction in Transition Fault TestingEnhanced Skewed Load and Broadside Power Reduction in Transition Fault Testing
Enhanced Skewed Load and Broadside Power Reduction in Transition Fault Testing
IJERA Editor
 

Similar to The First IoT JSR: Units of Measurement - JUG Berlin-Brandenburg (20)

JSR363 - Devoxx US
JSR363 - Devoxx USJSR363 - Devoxx US
JSR363 - Devoxx US
 
The First IoT JSR: Units of Measurement JSR-363 [BOF5981]
The First IoT JSR: Units of Measurement JSR-363 [BOF5981]The First IoT JSR: Units of Measurement JSR-363 [BOF5981]
The First IoT JSR: Units of Measurement JSR-363 [BOF5981]
 
Prediction of Critical Temperature of Superconductors using Tree Based Method...
Prediction of Critical Temperature of Superconductors using Tree Based Method...Prediction of Critical Temperature of Superconductors using Tree Based Method...
Prediction of Critical Temperature of Superconductors using Tree Based Method...
 
Werner Weil: UCUM - epicenter 2010
Werner Weil: UCUM - epicenter 2010Werner Weil: UCUM - epicenter 2010
Werner Weil: UCUM - epicenter 2010
 
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
 
COMAPARATIVE ANALYSIS VERILOG ADDERS
COMAPARATIVE ANALYSIS VERILOG ADDERSCOMAPARATIVE ANALYSIS VERILOG ADDERS
COMAPARATIVE ANALYSIS VERILOG ADDERS
 
Proceedings
ProceedingsProceedings
Proceedings
 
Accelerators at ORNL - Application Readiness, Early Science, and Industry Impact
Accelerators at ORNL - Application Readiness, Early Science, and Industry ImpactAccelerators at ORNL - Application Readiness, Early Science, and Industry Impact
Accelerators at ORNL - Application Readiness, Early Science, and Industry Impact
 
Designing a 2 d rz venture model for neutronic analysis of the nigeria resear...
Designing a 2 d rz venture model for neutronic analysis of the nigeria resear...Designing a 2 d rz venture model for neutronic analysis of the nigeria resear...
Designing a 2 d rz venture model for neutronic analysis of the nigeria resear...
 
Fv3610681072
Fv3610681072Fv3610681072
Fv3610681072
 
Slides for NSBE Oral Presentation.pptx
Slides for NSBE Oral Presentation.pptxSlides for NSBE Oral Presentation.pptx
Slides for NSBE Oral Presentation.pptx
 
Mr. Keil Werner - UOMO 2011
Mr. Keil Werner - UOMO 2011Mr. Keil Werner - UOMO 2011
Mr. Keil Werner - UOMO 2011
 
Towards a Quality Assessment of Web Corpora for Language Technology Applications
Towards a Quality Assessment of Web Corpora for Language Technology ApplicationsTowards a Quality Assessment of Web Corpora for Language Technology Applications
Towards a Quality Assessment of Web Corpora for Language Technology Applications
 
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
 
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)
 
How to achieve 95%+ Accurate power measurement during architecture exploration?
How to achieve 95%+ Accurate power measurement during architecture exploration? How to achieve 95%+ Accurate power measurement during architecture exploration?
How to achieve 95%+ Accurate power measurement during architecture exploration?
 
Design & Development of Articulated Inspection ARM for in House Inspection in...
Design & Development of Articulated Inspection ARM for in House Inspection in...Design & Development of Articulated Inspection ARM for in House Inspection in...
Design & Development of Articulated Inspection ARM for in House Inspection in...
 
Enhanced Skewed Load and Broadside Power Reduction in Transition Fault Testing
Enhanced Skewed Load and Broadside Power Reduction in Transition Fault TestingEnhanced Skewed Load and Broadside Power Reduction in Transition Fault Testing
Enhanced Skewed Load and Broadside Power Reduction in Transition Fault Testing
 
IRJET- Automobile Radiator Design and Validation
IRJET- Automobile Radiator Design and ValidationIRJET- Automobile Radiator Design and Validation
IRJET- Automobile Radiator Design and Validation
 
Eclipse UOMo
Eclipse UOMoEclipse UOMo
Eclipse UOMo
 

More from Werner Keil

More from Werner Keil (20)

Securing eHealth, eGovernment and eBanking with Java - DWX '21
Securing eHealth, eGovernment and eBanking with Java - DWX '21Securing eHealth, eGovernment and eBanking with Java - DWX '21
Securing eHealth, eGovernment and eBanking with Java - DWX '21
 
OpenDDR and Jakarta MVC - JavaLand 2021
OpenDDR and Jakarta MVC - JavaLand 2021OpenDDR and Jakarta MVC - JavaLand 2021
OpenDDR and Jakarta MVC - JavaLand 2021
 
How JSR 385 could have Saved the Mars Climate Orbiter - Zurich IoT Day 2021
How JSR 385 could have Saved the Mars Climate Orbiter - Zurich IoT Day 2021How JSR 385 could have Saved the Mars Climate Orbiter - Zurich IoT Day 2021
How JSR 385 could have Saved the Mars Climate Orbiter - Zurich IoT Day 2021
 
OpenDDR and Jakarta MVC - Java2Days 2020 Virtual
OpenDDR and Jakarta MVC - Java2Days 2020 VirtualOpenDDR and Jakarta MVC - Java2Days 2020 Virtual
OpenDDR and Jakarta MVC - Java2Days 2020 Virtual
 
NoSQL Endgame - Java2Days 2020 Virtual
NoSQL Endgame - Java2Days 2020 VirtualNoSQL Endgame - Java2Days 2020 Virtual
NoSQL Endgame - Java2Days 2020 Virtual
 
JCON 2020: Mobile Java Web Applications with MVC and OpenDDR
JCON 2020: Mobile Java Web Applications with MVC and OpenDDRJCON 2020: Mobile Java Web Applications with MVC and OpenDDR
JCON 2020: Mobile Java Web Applications with MVC and OpenDDR
 
How JSR 385 could have Saved the Mars Climate Orbiter - JFokus 2020
How JSR 385 could have Saved the Mars Climate Orbiter - JFokus 2020How JSR 385 could have Saved the Mars Climate Orbiter - JFokus 2020
How JSR 385 could have Saved the Mars Climate Orbiter - JFokus 2020
 
Money, Money, Money, can be funny with JSR 354 (Devoxx BE)
Money, Money, Money, can be funny with JSR 354 (Devoxx BE)Money, Money, Money, can be funny with JSR 354 (Devoxx BE)
Money, Money, Money, can be funny with JSR 354 (Devoxx BE)
 
Money, Money, Money, can be funny with JSR 354 (DWX 2019)
Money, Money, Money, can be funny with JSR 354 (DWX 2019)Money, Money, Money, can be funny with JSR 354 (DWX 2019)
Money, Money, Money, can be funny with JSR 354 (DWX 2019)
 
NoSQL: The first New Jakarta EE Specification (DWX 2019)
NoSQL: The first New Jakarta EE Specification (DWX 2019)NoSQL: The first New Jakarta EE Specification (DWX 2019)
NoSQL: The first New Jakarta EE Specification (DWX 2019)
 
JNoSQL: The Definitive Solution for Java and NoSQL Databases
JNoSQL: The Definitive Solution for Java and NoSQL DatabasesJNoSQL: The Definitive Solution for Java and NoSQL Databases
JNoSQL: The Definitive Solution for Java and NoSQL Databases
 
Eclipse JNoSQL: The Definitive Solution for Java and NoSQL Databases
Eclipse JNoSQL: The Definitive Solution for Java and NoSQL DatabasesEclipse JNoSQL: The Definitive Solution for Java and NoSQL Databases
Eclipse JNoSQL: The Definitive Solution for Java and NoSQL Databases
 
Physikal - JSR 363 and Kotlin for Clean Energy - Java2Days 2017
Physikal - JSR 363 and Kotlin for Clean Energy - Java2Days 2017Physikal - JSR 363 and Kotlin for Clean Energy - Java2Days 2017
Physikal - JSR 363 and Kotlin for Clean Energy - Java2Days 2017
 
Performance Monitoring for the Cloud - Java2Days 2017
Performance Monitoring for the Cloud - Java2Days 2017Performance Monitoring for the Cloud - Java2Days 2017
Performance Monitoring for the Cloud - Java2Days 2017
 
Java2Days - Security for JavaEE and the Cloud
Java2Days - Security for JavaEE and the CloudJava2Days - Security for JavaEE and the Cloud
Java2Days - Security for JavaEE and the Cloud
 
Apache DeviceMap - Web-Dev-BBQ Stuttgart
Apache DeviceMap - Web-Dev-BBQ StuttgartApache DeviceMap - Web-Dev-BBQ Stuttgart
Apache DeviceMap - Web-Dev-BBQ Stuttgart
 
JSR 354: Money and Currency API - Short Overview
JSR 354: Money and Currency API - Short OverviewJSR 354: Money and Currency API - Short Overview
JSR 354: Money and Currency API - Short Overview
 
JavaLand: Quantified Social - Fitness-Geräte und -Portale mit Agorava
JavaLand: Quantified Social - Fitness-Geräte und -Portale mit AgoravaJavaLand: Quantified Social - Fitness-Geräte und -Portale mit Agorava
JavaLand: Quantified Social - Fitness-Geräte und -Portale mit Agorava
 
Enterprise 2.0 with Open Source Frameworks like Agorava
Enterprise 2.0 with Open Source Frameworks like AgoravaEnterprise 2.0 with Open Source Frameworks like Agorava
Enterprise 2.0 with Open Source Frameworks like Agorava
 
JSR 375 - Have you seen Java EE Security API lately? - codemotion Tel Aviv 2015
JSR 375 - Have you seen Java EE Security API lately? - codemotion Tel Aviv 2015JSR 375 - Have you seen Java EE Security API lately? - codemotion Tel Aviv 2015
JSR 375 - Have you seen Java EE Security API lately? - codemotion Tel Aviv 2015
 

Recently uploaded

+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 

Recently uploaded (20)

WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security Program
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 

The First IoT JSR: Units of Measurement - JUG Berlin-Brandenburg

  • 1. @UnitAPI#JSR363 The First IoT JSR: Units of Measurement JSR-363 Werner Keil | Otávio Santana @wernerkeil | @otaviojava @UnitAPI https://www.jcp.org/en/jsr/detail?id=363 http://unitsofmeasurement.github.io
  • 3. @UnitAPI#JSR363 Why do we need JSR-363? There are no specifications or standards for handling units in Java. The current solution is to use primitives, that don’t provide any Type Safety. The errors are difficult to find using unit testing: Interface and Internationalization (e.g. radian/degree, meters/feet); Arithmetic operations (e.g. overflow); Conversion between units (e.g. from same domain);
  • 4. @UnitAPI#JSR363 What is JSR-363? Interfaces and abstract classes supporting unit operations including: Checking of unit compatibility; Expression of measurement in various units; and Arithmetic operations on units. Concrete classes implementing standard unit types (base, derived), unit conversion and representation. A framework supporting robust representation and correct handling of quantities. JSR 363 establishes safe and useful methods for modeling physical quantities.
  • 5. @UnitAPI#JSR363 System of Units System International d’Unites (SI) The accepted basis for most scientific and engineering activities. Standard units for key physical quantities (length, time, power etc.) Standard prefixes (kilo/micro etc.) Standard dimensions…
  • 6. @UnitAPI#JSR363 Dimension Allows analysis of a quantity by the rational powers of the 7 fundamental dimensions (quantities are compatible when they have the same dimensions): length (L), mass (M), time (T), electric charge (I), absolute temperature (Θ), amount of substance (N) and luminous intensity (J) Examples: Speed = length/time - it’s dimensions are L=1,T=-1 (rest 0) (e.g. metre/second - ms-1) Acceleration is speed/time (m/s/s or ms-2) L=1, T=-2 Force is mass x acceleration M x ((length/time)/time) or M=1, L=1, T=-2 Molar Entropy: M=1 L=2 T=−2 Θ=−1 N=−1 (trust me!)
  • 7. @UnitAPI#JSR363 Quantity A physical attribute of a thing. Something that can be measured and has units. Compatible quantities have the same dimension… Examples: • Time • Length • Speed • Amount of Substance • Luminous Intensity • Volume • Mass • Force • Power • Electrical Current • Magnetic Flux Density • Volumetric Flow Rate • Fuel Economy* • Percentage • Eggs per carton • Sheep per hour • Bits and bytes … … ∞
  • 8. @UnitAPI#JSR363 Unit Conversion The process of conversion depends on the specific situation and the intended purpose. This may be governed by regulation, contract, technical specifications or other published standards. Wikipedia
  • 9. @UnitAPI#JSR363 1983: The Gimli “Glider” Photo: Wayne Glowacki Maintenance workers performed a test that estimated that 7,682 litres of fuel were in the tank. They knew they needed 22,300 kilograms of fuel for the remaining flight, so the question was, How much fuel, in litres, should be pumped from the fuel truck into the aircraft? They were forced to resort to a manual calculation: They multiplied 7,682 L by 1.77, the density of the fuel provided by the refuelling company on their documentation: The aircraft, according to their calculations, currently had 13,597 kg of fuel. Subtracting from 22,300 kg, they decided they needed to add 8,703 kg of fuel. Dividing by 1.77 — the same density used in the previous calculation — yields 4,916 L, which was pumped into the aircraft. However, 1.77 was the density of the fuel in pounds per litre (lb/L), not kilograms per litre (kg/L); the correct figure for kg/L would have been 0.80. As a result, they ended up with less than half of the required amount of fuel on board. (The fuel's density depends on characteristics of the fuel, so it's not a constant, and the value must be taken from documentation accompanying the fuel.)
  • 10. @UnitAPI#JSR363 Some real-life mishaps… [Cost $125M] “Preliminary findings indicate that one team used US/English units (e.g. inches, feet and pounds) while the other used metric units for a key spacecraft operation.” NASA Mars Climate Orbiter, 1999
  • 11. @UnitAPI#JSR363 Conversion problems These are examples of confusion on the units in application. But there is also ambiguity on the unit itself: 10 Gallons … Gallon Dry / Gallon Liquid - Gallon US / Gallon UK 28 Days … Day Sidereal / Day Calendar 38 Degrees … Degree Celsius / Degree Fahrenheit / Degree Angle And the wrong conversion factors: static final double PIXEL_TO_INCH = 1 / 72; double pixels = inches * PIXEL_TO_INCH;
  • 12. @UnitAPI#JSR363 What is the problem, in code? float distance = 6370.98; //in miles float speed = airplane.getSpeed(); //in km/h System.out.println(“TTD: “ + (distance/speed) + “ h”); 6,370.98 miles A Quantity A Unit
  • 13. @UnitAPI#JSR363 What is JSR-363, in code? Quantity<Length> distance = Quantities.getQuantity(6370.98, USCustomary.MILE); Quantity<Speed> airplaneSpeed = getAirplaneSpeed(); Quantity<Time> timeToDest = (Quantity<Time>)distance.divide(airplaneSpeed); System.out.println(“TTD: “ + timeToDest.to(Units.HOUR)); TTD: 10.84983093613525 h
  • 14. @UnitAPI#JSR363 Who is going to use JSR-363? Java developers who work with physical quantities need to handle measurements in their programs. Inadequate models of physical measurements can lead to significant programmatic errors. Platform providers and developers can provide and use a more well-defined API. Embedded developers can have less error-prone, more self- documented code.
  • 15. @UnitAPI#JSR363 JSR-363: Internal Structure JSR-363 is broken down into the following packages: Package Description javax.measure Core API interfaces (e.g. Dimension, Quantity, Unit) javax.measure.format [optional] Interfaces for quantity/unit formatting and parsing javax.measure.quantity [optional] Interfaces for quantity types (e.g. Mass, Length) javax.measure.spi [optional] Service Provider Interface (implementation discovery) Reason: We target very small devices running Java ME (CLDC 8) for IoT applications (e.g. sensors, wearables, gateways etc.)
  • 16. @UnitAPI#JSR363 JSR-363: Systems and ExtensionsOn top of JSR-363 we offer support for various unit systems: • Reusable Quantities • SI System • Common Systems (US, Imperial) • ISO 80000 • UCUM Reason: By providing small, modular libraries, we live and sometimes forestall the ideas behind Java ME 8 or Jigsaw and offer great flexibility to IoT solutions
  • 17. @UnitAPI#JSR363 JSR-363 timeline March 11, 2014: Submitted April 7, 2014: Creation approved Dec 2014 – January 2015: Early Draft (done) Q3/2015 – Q4/2015: Public Review (approved) Q2/2016 : Final Draft Q3/2016 : Final Release
  • 19. @UnitAPI#JSR363 Links to JSR-363 Public mailing list(s) and/or forum(s) Units-Dev on Google Groups Units-Users on Google Groups EG only mailing list on java.net, archive fully visible (while java.net exists) JSR detail page on JCP.org: https://www.jcp.org/en/jsr/detail?id=363 Project website on GitHub: unitsofmeasurement.github.io