« Units management » : différence entre les versions

De GENIUS
Aller à la navigation Aller à la recherche
Aucun résumé des modifications
 
(11 versions intermédiaires par le même utilisateur non affichées)
Ligne 1 : Ligne 1 :
Units are managed with the [{{PathCurrentJavaDoc}}/fr/cnes/genius/unit/GUnit.html|GUnit]] class or more directly with [{{PathCurrentJavaDoc}}/fr/cnes/genius/unit/GMetricUnit.html|GMetricUnit]].
Units are managed with the [{{PathCurrentJavaDoc}}/fr/cnes/genius/unit/GUnit.html GUnit] class or more directly with [{{PathCurrentJavaDoc}}/fr/cnes/genius/unit/GMetricUnit.html GMetricUnit].


<syntaxhighlight lang="java">
<syntaxhighlight lang="java">
Ligne 6 : Ligne 6 :
</syntaxhighlight>
</syntaxhighlight>


In case of using [{{PathCurrentJavaDoc}}/fr/cnes/genius/unit/GMetricUnit.html|GMetricUnit]], when we define a unit for a real value, it is stored automatically in the computer memory in '''International System (IS)''' (m, kg, rad …).
Since V1.7, a static factory method is available to simplify the creation of such tabel. We may write:
<syntaxhighlight lang="java">
GUnit[] unitDis = GUnitFactory.getGUnitArray("km", "nmi");
</syntaxhighlight>


<syntaxhighlight lang="java">                  
In case of using [{{PathCurrentJavaDoc}}/fr/cnes/genius/unit/GMetricUnit.html GMetricUnit], when we define a unit for a real value, it is stored automatically in the computer memory in '''International System (IS)''' (m, kg, rad …).
 
<syntaxhighlight lang="java">
dist  = new GEntryReal("Distance", 1000., unitDis); // Initialization with 1000 meters.
dist  = new GEntryReal("Distance", 1000., unitDis); // Initialization with 1000 meters.
</syntaxhighlight>
</syntaxhighlight>
Ligne 14 : Ligne 19 :
Thus, in that case, we may have a difference between what it is displayed (for example 1.0 km) and what it is actually stored in the memory (1000.).
Thus, in that case, we may have a difference between what it is displayed (for example 1.0 km) and what it is actually stored in the memory (1000.).


[[File:Units.jpg]]
[[File:Units.png]]


To get the value stored in memory (same for an integer even if there is no units for it), we will use the <font color=#4169E1>getValue()</font> method:
To get the value stored in memory (same for an integer even if there is no units for it), we will use the <font color=#4169E1>getValue()</font> method:
Ligne 22 : Ligne 27 :
</syntaxhighlight>
</syntaxhighlight>


The basic '''IS''' units given by default by <font color=#556B2F>**GENIUS**</font> are the following:
== Available units ==


* kilogram (**kg**)
The basic '''IS''' units given by default by <font color=#556B2F>'''GENIUS'''</font> are the following:
* meter (**m**)
* second (**s**)
* Amper (**A**)


Of course, <font color=#556B2F>**GENIUS**</font> proposes also angular units with **radian** (rad) for IS to be convertible in **degree** (deg).
* kilogram ('''kg''')
* meter ('''m''')
* second ('''s''')
* Amper ('''A''')


Then, it is possible to get composed units using "**.**" for multiplication, "**/**" for division or "**^**" for power (a negative power is enabled). Thus, we may have **kg.m/s^2** (or **kg.m.s^-2**) as a composed unit.
Of course, <font color=#556B2F>'''GENIUS'''</font> proposes also angular units with '''radian''' (rad) for IS to be convertible in '''degree''' (deg).


Allways about composed units, <font color=#556B2F>**GENIUS**</font> proposes the following ones:
Then, it is possible to get composed units using "'''.'''" for multiplication, "'''/'''" for division or "'''^''''" for power (a negative power is enabled). Thus, we may have '''kg.m/s^2''' (or '''kg.m.s^-2''') as a composed unit.


* Steradians (m<sup>2</sup>.m<sup>-2</sup>) => **sr**
Allways about composed units, <font color=#556B2F>'''GENIUS'''</font> proposes the following ones:
* Hertz (s<sup>-1</sup>) => **Hz**
 
* Newton (kg.m.s<sup>-2</sup>) => **N**
* Steradians (m<sup>2</sup>.m<sup>-2</sup>) => '''sr'''
* Pascal (N.m<sup>-2</sup>) => **Pa**
* Hertz (s<sup>-1</sup>) => '''Hz'''
* Joules (N.m) => **J**
* Newton (kg.m.s<sup>-2</sup>) => '''N'''
* Watt (J.s<sup>-1</sup>) => **W**
* Pascal (N.m<sup>-2</sup>) => '''Pa'''
* Coulomb (A.s) => **C**
* Joules (N.m) => '''J'''
* Volt (W.A<sup>-1</sup>) => **V**
* Watt (J.s<sup>-1</sup>) => '''W'''
* Farad (C.V<sup>-1</sup>) => **F**
* Coulomb (A.s) => '''C'''
* Ohm (V.A<sup>-1</sup>) => **R**
* Volt (W.A<sup>-1</sup>) => '''V'''
* Farad (C.V<sup>-1</sup>) => '''F'''
* Ohm (V.A<sup>-1</sup>) => '''R'''


For more facilities, these units have also been added:
For more facilities, these units have also been added:
* gramm = 0.001*kg => **g**
* gramm = 0.001*kg => '''g'''
* ton = 1000 kg => **t**
* ton = 1000 kg => '''t'''
* minutes = 60 s => **mn**
* minutes = 60 s => '''mn'''
* hour = 3600 s => **h**
* hour = 3600 s => '''h'''
* day = 86400 => **j**
* day = 86400 => '''j''' or '''d'''
* month = 1/12 year => '''mo'''
* year = 365.25 days => '''a''' or '''y'''


It is also possible to use coefficients:
It is also possible to use coefficients:


* **T** : Tera = 10<sup>12</sup>
* '''T''': Tera = 10<sup>12</sup>
* **G** : Giga = 10<sup>9</sup>
* '''G''' : Giga = 10<sup>9</sup>
* **M** : Mega = 10<sup>6</sup>
* '''M''': Mega = 10<sup>6</sup>
* **k** : kilo = 10<sup>3</sup>
* '''k''': kilo = 10<sup>3</sup>
* **h** : hecto = 10<sup>2</sup>
* '''h''': hecto = 10<sup>2</sup>
* **da** : deca = 10
* '''da''': deca = 10
* **d** : deci = 10<sup>-1</sup>
* '''d''': deci = 10<sup>-1</sup>
* **c** : centi = 10<sup>-2</sup>
* '''c''': centi = 10<sup>-2</sup>
* **m** : mili = 10<sup>-3</sup>
* '''m''': mili = 10<sup>-3</sup>
* **u** : micro = 10<sup>-6</sup>
* '''u''': micro = 10<sup>-6</sup>
* **n** : nano = 10<sup>-9</sup>
* '''n''': nano = 10<sup>-9</sup>
* **p** : pico = 10<sup>-12</sup>
* '''p''': pico = 10<sup>-12</sup>


Note that for mass values, these coefficient will be applied on "'''g'''" and not "'''kg'''".
Note that for mass values, these coefficient will be applied on "'''g'''" and not "'''kg'''".
Ligne 72 : Ligne 81 :
So, we could have something as '''mg.dam/mn^2''' ... for something equivalent as (1/36)10-6 Newtons !
So, we could have something as '''mg.dam/mn^2''' ... for something equivalent as (1/36)10-6 Newtons !


At last, for not proportional conversions, <font color=#556B2F>**GENIUS**</font> proposes anyway to convert:
At last, for not proportional conversions, <font color=#556B2F>'''GENIUS'''</font> proposes anyway to convert:
* Kelvin (**K**) to Celsius (**C**) or Fahrenheit (**F**) (using [{{PathCurrentJavaDoc}}/fr/cnes/genius/unit/GTemperatureUnit.html|GTemperatureUnit]])
* Kelvin ('''K''') to Celsius ('''C''') or Fahrenheit ('''F''') (using [{{PathCurrentJavaDoc}}/fr/cnes/genius/unit/GTemperatureUnit.html GTemperatureUnit])
* "**%**" to "****" (using [{{PathCurrentJavaDoc}}/fr/cnes/genius/unit/GPercentUnit.html|GPercentUnit]]).
* "'''%'''" to "''''''" (using [{{PathCurrentJavaDoc}}/fr/cnes/genius/unit/GPercentUnit.html GPercentUnit]).
 
== How to enter directly a unit ==
 
Even if a unit is not proposed in the dedicated menu ("'''km'''" and "'''nmi'''" in the previous example), it is possible to enter a compatible unit with the following syntax:
 
[[File:Units2.png]]
 
Thus, it will take into account 0.01 meter in memory and will display the value with the current displayed unit.


[[File:Units3.png]]


[[WELCOME_TO_THE_GENIUS_WIKI|Return to the introduction ↑]]  
[[WELCOME_TO_THE_GENIUS_WIKI|Return to the introduction ↑]]  
[[GContainer|Go to the next page →]]
[[GContainer|Go to the next page →]]

Dernière version du 14 novembre 2019 à 08:58

Units are managed with the GUnit class or more directly with GMetricUnit.

// To display a menu allowing to display kilometers (km) or Nautic Miles (nmi)
GUnit[] unitDis = { new GMetricUnit ("km") , new GMetricUnit ("nmi") };

Since V1.7, a static factory method is available to simplify the creation of such tabel. We may write:

GUnit[] unitDis = GUnitFactory.getGUnitArray("km", "nmi");

In case of using GMetricUnit, when we define a unit for a real value, it is stored automatically in the computer memory in International System (IS) (m, kg, rad …).

dist  = new GEntryReal("Distance", 1000., unitDis); // Initialization with 1000 meters.

Thus, in that case, we may have a difference between what it is displayed (for example 1.0 km) and what it is actually stored in the memory (1000.).

Units.png

To get the value stored in memory (same for an integer even if there is no units for it), we will use the getValue() method:

double val = dist.getValue(); // Allways in IS

Available units

The basic IS units given by default by GENIUS are the following:

  • kilogram (kg)
  • meter (m)
  • second (s)
  • Amper (A)

Of course, GENIUS proposes also angular units with radian (rad) for IS to be convertible in degree (deg).

Then, it is possible to get composed units using "." for multiplication, "/" for division or "^'" for power (a negative power is enabled). Thus, we may have kg.m/s^2 (or kg.m.s^-2) as a composed unit.

Allways about composed units, GENIUS proposes the following ones:

  • Steradians (m2.m-2) => sr
  • Hertz (s-1) => Hz
  • Newton (kg.m.s-2) => N
  • Pascal (N.m-2) => Pa
  • Joules (N.m) => J
  • Watt (J.s-1) => W
  • Coulomb (A.s) => C
  • Volt (W.A-1) => V
  • Farad (C.V-1) => F
  • Ohm (V.A-1) => R

For more facilities, these units have also been added:

  • gramm = 0.001*kg => g
  • ton = 1000 kg => t
  • minutes = 60 s => mn
  • hour = 3600 s => h
  • day = 86400 => j or d
  • month = 1/12 year => mo
  • year = 365.25 days => a or y

It is also possible to use coefficients:

  • T: Tera = 1012
  • G : Giga = 109
  • M: Mega = 106
  • k: kilo = 103
  • h: hecto = 102
  • da: deca = 10
  • d: deci = 10-1
  • c: centi = 10-2
  • m: mili = 10-3
  • u: micro = 10-6
  • n: nano = 10-9
  • p: pico = 10-12

Note that for mass values, these coefficient will be applied on "g" and not "kg".

So, we could have something as mg.dam/mn^2 ... for something equivalent as (1/36)10-6 Newtons !

At last, for not proportional conversions, GENIUS proposes anyway to convert:

How to enter directly a unit

Even if a unit is not proposed in the dedicated menu ("km" and "nmi" in the previous example), it is possible to enter a compatible unit with the following syntax:

Units2.png

Thus, it will take into account 0.01 meter in memory and will display the value with the current displayed unit.

Units3.png

Return to the introduction ↑ Go to the next page →