Skip to content

Commit

Permalink
Fixed some demos
Browse files Browse the repository at this point in the history
  • Loading branch information
keilw committed Feb 7, 2025
1 parent 22f0ed6 commit 924404a
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 137 deletions.
Original file line number Diff line number Diff line change
@@ -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.
*
Expand Down Expand Up @@ -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;
Expand All @@ -41,9 +42,8 @@ public static void main(String[] args) {
// Conversion between units.
final Quantity<Length> 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).
Expand Down
8 changes: 8 additions & 0 deletions console/systems/historical/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,17 @@
<groupId>tech.uom.lib</groupId>
<artifactId>uom-lib-common</artifactId>
</dependency>
<dependency>
<groupId>si.uom</groupId>
<artifactId>si-quantity</artifactId>
</dependency>
<dependency>
<groupId>systems.uom</groupId>
<artifactId>systems-quantity</artifactId>
</dependency>
<dependency>
<groupId>systems.uom</groupId>
<artifactId>systems-ucum</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -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 <a href="mailto:[email protected]">Werner Keil</a>
*
* @see <a
* href="http://www.nema.ne.gov/technological/dose-limits.html">NEMA:
* Radiological Emergency Preparedness</a>
* @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 <Quantity<IonizingRadiation>, String> repMap = new HashMap<>();
Quantity<IonizingRadiation> 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<IonizingRadiation> 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 <a href="mailto:[email protected]">Werner Keil</a>
*
* @see <a
* href="http://www.nema.ne.gov/technological/dose-limits.html">NEMA:
* Radiological Emergency Preparedness</a>
* @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 <Quantity<IonizingRadiation>, String> repMap = new HashMap<>();
Quantity<IonizingRadiation> 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<IonizingRadiation> dosimeterLimit : repMap.keySet()) {
System.out.println(dosimeterLimit + " :: " + repMap.get(dosimeterLimit));
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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.
*
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
*
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
<maven.compile.targetLevel>${jdkVersion}</maven.compile.targetLevel>
<maven.compile.sourceLevel>${jdkVersion}</maven.compile.sourceLevel>
<jsr.version>2.2</jsr.version><!-- for overloading parent -->
<ri.version>2.2.1-SNAPSHOT</ri.version>
<ri.version>2.2.3-SNAPSHOT</ri.version>
<lib.version>2.2</lib.version>
<si.version>2.2-SNAPSHOT</si.version>
<si.version>2.2</si.version>
<systems.version>2.2-SNAPSHOT</systems.version>
</properties>

Expand Down

0 comments on commit 924404a

Please sign in to comment.