Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

help find my way in uom and related libs #426

Open
reeg33 opened this issue Aug 22, 2024 · 7 comments
Open

help find my way in uom and related libs #426

reeg33 opened this issue Aug 22, 2024 · 7 comments

Comments

@reeg33
Copy link

reeg33 commented Aug 22, 2024

Hello,

i'm not convinced that's the correct place to post, but maybe someone can redirect me if that's the case.

I need to implement in my code a system that allows unit conversions. Until now, seems the correct place. But, I don't really know how to begin with. I read JSR 385 Specification, i added uom-api to maven, but I found it was only "core code" and I needed to add implemented version. Then I found this RI, but still I have some units that are not present in "Unit.class". How do I code them ? Duplicate all project and modify ? seems I can't extend most of them indroya files (and when I can, methods are private so I can't really go further)
Things like
public static final Unit<ThermalConductivity> BTU_PER_HOUR_FAHRENHEIT_FOOT = addUnit(new ProductUnit<>(BTU_PER_HOUR_FAHRENHEIT.divide(FOOT)).asType(ThermalConductivity.class)); public static final Unit<MolarMass> GRAMME_PAR_MOL = addUnit(new ProductUnit<>(GRAM.divide(MOLE)).asType(MolarMass.class));

Is there a "getting started" or "how do i implement my own units" documentation somewhere ? Do I need some more libraries to do the job ?

Sorry if it's a lot of questions, but I find this lib very close to what I want, but seems I dont know how to make it work for me :(

@reeg33 reeg33 changed the title help find my way in uom and relaetd libs help find my way in uom and related libs Aug 22, 2024
@desruisseaux
Copy link
Contributor

Note: there is at least two implementations available. The RI is one of them. Seshat is another. They may provide different set of pre-defined units. In both case (I think in RI too), new units can be created by starting with existing units, then invoke methods such as multiply or divide. The Seshat page gives an example. The result may not have the desired label, but parsing and formatting with custom labels can be done by creating a UnitFormat and invoking the label(Unit, String) method on it.

@reeg33
Copy link
Author

reeg33 commented Aug 22, 2024

I feel that framework is too complicated for me unfortunately, i feel lost among all different libraries (api, implementations, demo, doc...). That is a shame because it seems it would fit perfectly for my app where I need to have my custom derivated units and go from Imperial to SI to custom prefered units system, but unfortunately I can't figure out what I actually need to code from what sources.

If anyone has a real full example of a use of that framework, feel free to give me a link so I can have a look.

@desruisseaux do you mind if I get in your DM, in french if possible ? maybe it'll be easier for me to explain my problem ^^
Cheers
Renaud

@desruisseaux
Copy link
Contributor

Hello Renaud. No problem.

@keilw
Copy link
Member

keilw commented Aug 22, 2024

@reeg33 Please see the repository uom-demos. It includes various modules such as Console Demos, Desktop Demos, Device Specific Demos, and Web Demos, among others.

There is some point that Seshat may be a bit more compact, but the RI was created to be modular and (in the "core" profile) ultra-compact, fitting eve into the once existing Java ME Embedded devices.
While Java ME Embedded may not exist anymore, it allows Edge Devices with sensors to run on a very small profile with little dependencies and add more where unit conversion and visual representation is necessary.

@reeg33
Copy link
Author

reeg33 commented Aug 23, 2024

Thank you all for your answers. I think that I was too optimistic with the use of that framework. Those demos are quite useful, unfortunately i couldnt find what i'm looking for. If there's a public project out there using uom, i'm curious to have look.
As a background context, on my side, for an engeneering app (heat exchangers) I basically need to :

  • have separate unit systems (SI, Imperial, custom1, custom2...) from which I can switch easily
  • add quite a few simple units that I didnt find in any implementation out there (curious "bar" is not there for pressure btw, maybe i didnt look at the right place) and also quite some more quantities (composed from other quantities like thermal conductivity, heat transfert coefficient or fouling factor...)
  • last but not least find what to implement concretely to get everything to work. That's where i failed until now unfortunately.

Let's hope that I'll find nice examples out there soon that can get me where I want to go (feel free to share some links :) )
Cheers,

@fref
Copy link

fref commented Sep 25, 2024

@reeg33 if you find examples, could you share them here?

@keilw
Copy link
Member

keilw commented Oct 12, 2024

@fref Please see uom-demos as mentioned, and if @reeg33 or anyone else has additional demos and examples, feel free to provide a PR there.

For separate unit systems (SI, Imperial, or others like UCUM) please see the Systems console demos.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants