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

Scaling of min/max/default in signals #126

Closed
altendky opened this issue Dec 29, 2017 · 4 comments
Closed

Scaling of min/max/default in signals #126

altendky opened this issue Dec 29, 2017 · 4 comments
Labels

Comments

@altendky
Copy link
Collaborator

Are the in-memory min/max/defaults supposed to be comparable to the raw integers in a CAN message? or the human value they represent? With a factor of 0.1 and a default human value of 15.1, should signal.attributes['GenSigStartValue'] be '15.1' or '151'?

This is coming up because some of my defaults are not getting written to my .sym file because after the scaling (introduced at the beginning 95611b1#diff-2fda6f9ac5ab0214cac52642f17fc1f7R167) the value is not in the range of the min and max and so isn't output. I just thought it would be good to know the intended in-memory value before trying to review the code.

For reference, here is a sample signal from the symbol editor. Note that the max and default both have decimals so they are scaled values, not directly comparable to any raw integer value from a message.

Var=Var1 unsigned 0,8 /f:0.1 /min:11 /max:25.4 /d:15.1
@ebroecker
Copy link
Owner

I know some dbc's where the default is value for a signal is 'invalid value' which is often not in range between min and max.
So maybe the min/max-check for the default-value is arguable.

In my opinion the raw-default-value should be used, because scaling often leads to some arithmetical errors.

I think .dbc stores the raw-default value but .sym stores the scaled value?

@altendky
Copy link
Collaborator Author

altendky commented Jan 2, 2018

In addition to calculation errors, even just converting from a string to a float can induce error. That is why I added the float factory option and use decimal (a622e5e).

But, not calculating is only an option if all file formats store all values either scaled or not. Well, at least given the assumption that we want a consistent state in memory. Alternatively we could calculate losslessly using decimal and/or fractions as needed. If some formats store scaled values and others raw/unscaled values then we are stuck doing calculations since the in-memory value should be consistent.

@ebroecker
Copy link
Owner

... slowly but surely I understand this issue :-)
Well in my opinion fractions seem to be the best solution.

@ebroecker
Copy link
Owner

A long time later, I am working on this issue.
I now decided to use the scaled values and store them decimal

I have done this now for

Signal.initial_value

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

No branches or pull requests

2 participants