From 924404a54a34f14db3361a73de800f9b4df1b0f5 Mon Sep 17 00:00:00 2001 From: Werner Keil Date: Fri, 7 Feb 2025 20:54:26 +0100 Subject: [PATCH] Fixed some demos --- .../demo/systems/common/ConversionDemo.java | 6 +- console/systems/historical/pom.xml | 8 ++ .../RadiologicalEmergencyPreparedness.java | 134 +++++++++--------- .../si/RadiologicalEmergencyPreparedness.java | 62 -------- .../java/tech/uom/demo/systems/si/SIDemo.java | 4 +- .../java/tech/uom/demo/systems/si/SIDemo.java | 3 +- pom.xml | 4 +- 7 files changed, 84 insertions(+), 137 deletions(-) rename console/systems/{si/src/main/java/tech/uom/demo/systems/si => historical/src/main/java/tech/uom/demo/systems/historical}/RadiologicalEmergencyPreparedness.java (94%) delete mode 100644 console/systems/si-java17/src/main/java/tech/uom/demo/systems/si/RadiologicalEmergencyPreparedness.java diff --git a/console/systems/common/src/main/java/tech/uom/demo/systems/common/ConversionDemo.java b/console/systems/common/src/main/java/tech/uom/demo/systems/common/ConversionDemo.java index 40245a6a..36a9da07 100644 --- a/console/systems/common/src/main/java/tech/uom/demo/systems/common/ConversionDemo.java +++ b/console/systems/common/src/main/java/tech/uom/demo/systems/common/ConversionDemo.java @@ -1,6 +1,6 @@ /* * Units of Measurement Demos for Java - * Copyright (c) 2005-2020, Jean-Marie Dautelle, Werner Keil and others. + * Copyright (c) 2005-2025, Jean-Marie Dautelle, Werner Keil and others. * * All rights reserved. * @@ -31,6 +31,7 @@ import tech.units.indriya.quantity.Quantities; import static si.uom.SI.*; +import static si.uom.NonSI.*; import static systems.uom.common.USCustomary.METER; import static systems.uom.common.USCustomary.MILE; import static systems.uom.common.USCustomary.MILE_PER_HOUR; @@ -41,9 +42,8 @@ public static void main(String[] args) { // Conversion between units. final Quantity m = Quantities.getQuantity(10, MILE); System.out.println(m); - System.out.println(KILO(METER).getConverterTo(MILE).convert(10.0)); // Retrieval of the system unit (identifies the measurement type). - System.out.println(REVOLUTION.divide(MINUTE).getSystemUnit()); + System.out.println(KILO(METER).getConverterTo(MILE).convert(10.0)); // Dimension checking (allows/disallows conversions) System.out.println(ELECTRON_VOLT.isCompatible(WATT.multiply(HOUR))); // Retrieval of the unit dimension (depends upon the current model). diff --git a/console/systems/historical/pom.xml b/console/systems/historical/pom.xml index 3d30fe1c..62d26d87 100644 --- a/console/systems/historical/pom.xml +++ b/console/systems/historical/pom.xml @@ -17,9 +17,17 @@ tech.uom.lib uom-lib-common + + si.uom + si-quantity + systems.uom systems-quantity + + systems.uom + systems-ucum + \ No newline at end of file diff --git a/console/systems/si/src/main/java/tech/uom/demo/systems/si/RadiologicalEmergencyPreparedness.java b/console/systems/historical/src/main/java/tech/uom/demo/systems/historical/RadiologicalEmergencyPreparedness.java similarity index 94% rename from console/systems/si/src/main/java/tech/uom/demo/systems/si/RadiologicalEmergencyPreparedness.java rename to console/systems/historical/src/main/java/tech/uom/demo/systems/historical/RadiologicalEmergencyPreparedness.java index 8a73eb57..bc3261f3 100644 --- a/console/systems/si/src/main/java/tech/uom/demo/systems/si/RadiologicalEmergencyPreparedness.java +++ b/console/systems/historical/src/main/java/tech/uom/demo/systems/historical/RadiologicalEmergencyPreparedness.java @@ -1,67 +1,67 @@ -/* - * Units of Measurement Demos for Java - * Copyright (c) 2015-2020, Werner Keil and others. - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * - * 3. Neither the name of JSR-385, Unit-API nor the names of their contributors may be used to endorse or promote products derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package tech.uom.demo.systems.si; - -import static si.uom.NonSI.ROENTGEN; -import static javax.measure.MetricPrefix.MILLI; - -import java.util.HashMap; -import java.util.Map; - -import javax.measure.Quantity; - -import si.uom.quantity.IonizingRadiation; -import tech.units.indriya.quantity.Quantities; - -/** - * @author Werner Keil - * - * @see NEMA: - * Radiological Emergency Preparedness - * @version 0.9, Jul 17, 2020 - */ -//TODO consider moving this to Health demos -public class RadiologicalEmergencyPreparedness { - - /** - * @param args - */ - public static void main(String[] args) { - final Map , String> repMap = new HashMap<>(); - Quantity ira = Quantities.getQuantity(500, MILLI(ROENTGEN)); - - repMap.put(ira, String.format("Call supervisor for further instructions. Dosimeter reading up to and including %s allowed for emergency Worker assignments.", ira)); - ira = Quantities.getQuantity(1, ROENTGEN); - repMap.put(ira, "Turn-back dose for Emergency Workers with no means of communication with supervisor. Dose allowed for assignments involving protection of valuable property."); - ira = Quantities.getQuantity(2.5, ROENTGEN); - repMap.put(ira, "Dose allowed for assignments involving LIFESAVING protection of large populations."); - - for (Quantity dosimeterLimit : repMap.keySet()) { - System.out.println(dosimeterLimit + " :: " + repMap.get(dosimeterLimit)); - } - } -} +/* + * Units of Measurement Demos for Java + * Copyright (c) 2015-2020, Werner Keil and others. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * 3. Neither the name of JSR-385, Unit-API nor the names of their contributors may be used to endorse or promote products derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package tech.uom.demo.systems.historical; + +import static systems.uom.ucum.UCUM.ROENTGEN; +import static javax.measure.MetricPrefix.MILLI; + +import java.util.HashMap; +import java.util.Map; + +import javax.measure.Quantity; + +import si.uom.quantity.IonizingRadiation; +import tech.units.indriya.quantity.Quantities; + +/** + * @author Werner Keil + * + * @see NEMA: + * Radiological Emergency Preparedness + * @version 1.0, Feb 7, 2025 + */ +//TODO consider moving this to Health demos +public class RadiologicalEmergencyPreparedness { + + /** + * @param args + */ + public static void main(String[] args) { + final Map , String> repMap = new HashMap<>(); + Quantity ira = Quantities.getQuantity(500, MILLI(ROENTGEN)); + + repMap.put(ira, String.format("Call supervisor for further instructions. Dosimeter reading up to and including %s allowed for emergency Worker assignments.", ira)); + ira = Quantities.getQuantity(1, ROENTGEN); + repMap.put(ira, "Turn-back dose for Emergency Workers with no means of communication with supervisor. Dose allowed for assignments involving protection of valuable property."); + ira = Quantities.getQuantity(2.5, ROENTGEN); + repMap.put(ira, "Dose allowed for assignments involving LIFESAVING protection of large populations."); + + for (Quantity dosimeterLimit : repMap.keySet()) { + System.out.println(dosimeterLimit + " :: " + repMap.get(dosimeterLimit)); + } + } +} diff --git a/console/systems/si-java17/src/main/java/tech/uom/demo/systems/si/RadiologicalEmergencyPreparedness.java b/console/systems/si-java17/src/main/java/tech/uom/demo/systems/si/RadiologicalEmergencyPreparedness.java deleted file mode 100644 index 42f40710..00000000 --- a/console/systems/si-java17/src/main/java/tech/uom/demo/systems/si/RadiologicalEmergencyPreparedness.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Units of Measurement Demos for Java - * Copyright (c) 2015-2020, Werner Keil and others. - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * - * 3. Neither the name of JSR-385, Unit-API nor the names of their contributors may be used to endorse or promote products derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package tech.uom.demo.systems.si; - -import static si.uom.NonSI.ROENTGEN; -import static javax.measure.MetricPrefix.MILLI; - -import java.util.HashMap; -import tech.units.indriya.quantity.Quantities; - -/** - * @author Werner Keil - * - * @see NEMA: - * Radiological Emergency Preparedness - * @version 0.9, Jul 17, 2020 - */ -// TODO consider moving this to Health demos -public class RadiologicalEmergencyPreparedness { - - /** - * @param args - */ - public static void main(String[] args) { - final var repMap = new HashMap<>(); - var ira = Quantities.getQuantity(500, MILLI(ROENTGEN)); - - repMap.put(ira, String.format("Call supervisor for further instructions. Dosimeter reading up to and including %s allowed for emergency Worker assignments.", ira)); - ira = Quantities.getQuantity(1, ROENTGEN); - repMap.put(ira, "Turn-back dose for Emergency Workers with no means of communication with supervisor. Dose allowed for assignments involving protection of valuable property."); - ira = Quantities.getQuantity(2.5, ROENTGEN); - repMap.put(ira, "Dose allowed for assignments involving LIFESAVING protection of large populations."); - - for (var dosimeterLimit : repMap.keySet()) { - System.out.println(dosimeterLimit + " :: " + repMap.get(dosimeterLimit)); - } - } -} diff --git a/console/systems/si-java17/src/main/java/tech/uom/demo/systems/si/SIDemo.java b/console/systems/si-java17/src/main/java/tech/uom/demo/systems/si/SIDemo.java index d5b61d74..c07527b7 100644 --- a/console/systems/si-java17/src/main/java/tech/uom/demo/systems/si/SIDemo.java +++ b/console/systems/si-java17/src/main/java/tech/uom/demo/systems/si/SIDemo.java @@ -1,6 +1,6 @@ /* * Units of Measurement Demos for Java - * Copyright (c) 2015-2020, Werner Keil and others. + * Copyright (c) 2015-2025, Werner Keil and others. * * All rights reserved. * @@ -27,7 +27,7 @@ import static si.uom.SI.*; import static si.uom.NonSI.DEGREE_ANGLE; - +import static si.uom.NonSI.UNIFIED_ATOMIC_MASS; import tech.units.indriya.quantity.Quantities; public class SIDemo { diff --git a/console/systems/si/src/main/java/tech/uom/demo/systems/si/SIDemo.java b/console/systems/si/src/main/java/tech/uom/demo/systems/si/SIDemo.java index 21d8a12e..e42c6d59 100644 --- a/console/systems/si/src/main/java/tech/uom/demo/systems/si/SIDemo.java +++ b/console/systems/si/src/main/java/tech/uom/demo/systems/si/SIDemo.java @@ -1,6 +1,6 @@ /* * Units of Measurement Demos for Java - * Copyright (c) 2015-2020, Werner Keil and others. + * Copyright (c) 2015-2025, Werner Keil and others. * * All rights reserved. * @@ -27,6 +27,7 @@ import static si.uom.SI.*; import static si.uom.NonSI.DEGREE_ANGLE; +import static si.uom.NonSI.UNIFIED_ATOMIC_MASS; import javax.measure.Quantity; import javax.measure.Unit; diff --git a/pom.xml b/pom.xml index 74d97392..4a9195ce 100644 --- a/pom.xml +++ b/pom.xml @@ -34,9 +34,9 @@ ${jdkVersion} ${jdkVersion} 2.2 - 2.2.1-SNAPSHOT + 2.2.3-SNAPSHOT 2.2 - 2.2-SNAPSHOT + 2.2 2.2-SNAPSHOT