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

asammdf based signal.append functionality doesn't handle conversion type #1080

Open
parthipan-ganeshaperumal opened this issue Sep 16, 2024 · 13 comments

Comments

@parthipan-ganeshaperumal

asammdf based signal.append functionality doesn't handle conversion type:

Example :not possible to add this conversion as part of signal if conversion attribute of signal : {0:xx,1:yy,2:xxx}
output : it seeting defualt None or conversion_type=0 if pass above dict values
Kindly make fix on this?

@parthipan-ganeshaperumal
Copy link
Author

output always like this : conversion:<ChannelConversion (name: , unit: , comment: , formula: , referenced blocks: None, address: 0, fields: ['address:0', 'block_len:80', 'comment:', 'comment_addr:0', 'conversion_type:0', 'flags:0', 'formula:', "id:b'##CC'", 'inv_conv_addr:0', 'links_nr:4', 'max_phy_value:0', 'min_phy_value:0', 'name:', 'name_addr:0', 'precision:1', 'ref_param_nr:0', 'referenced_blocks:None', 'reserved0:0', 'unit:', 'unit_addr:0', 'val_param_nr:0'])>

but I expect convesion_type like that : {0:xx,1:yy,2:xxx} under conversion type attribute

@danielhrisca
Copy link
Owner

You probably need to setup the correct dict keys like the example shows

# value to text

@parthipan-ganeshaperumal
Copy link
Author

parthipan-ganeshaperumal commented Sep 16, 2024

For my case : input look like 'conversion_type': 'lookup_dict', 'lookup_dict': [[0, 'FALSE'], [1, 'TRUE']]}

     but received out like conversion=<ChannelConversion (name: , unit: , comment: , formula: , referenced blocks: None, address: 0, fields: ['address:0', 'block_len:80', 'comment:', 'comment_addr:0', 'conversion_type:0', 'flags:0', 'formula:', "id:b'##CC'", 'inv_conv_addr:0', 'links_nr:4', 'max_phy_value:0', 'min_phy_value:0', 'name:', 'name_addr:0', 'precision:1', 'ref_param_nr:0', 'referenced_blocks:None', 'reserved0:0', 'unit:', 'unit_addr:0', 'val_param_nr:0'])>

@danielhrisca
Copy link
Owner

Like I said, you need to follow the dict key naming. This will not work with any doct that you throw at it

@parthipan-ganeshaperumal
Copy link
Author

parthipan-ganeshaperumal commented Sep 17, 2024

Do you wanna align like this
{'val_0': 0, 'val_1': 1, 'text_0': 'FALSE', 'text_1': 'TRUE'}

@danielhrisca
Copy link
Owner

I would also add the default key for unmapped values

@parthipan-ganeshaperumal
Copy link
Author

Basically those approach worked but while extracting mdf4 files converstion automatically applied on values in array (np.array) values of concerned signal.. for example : {'val_0': 0, 'val_1': 1, 'text_0': 'FALSE', 'text_1': 'TRUE', 'default': b'default key'} after applied on mdf4 file ...then try to extract information conversion type automatically applied on 0 to False and 1 to True (in np.array).. how to make conversion type visible in attribute level instead of applied on data ???

@danielhrisca
Copy link
Owner

Call get or select with raw=True

1 similar comment
@danielhrisca
Copy link
Owner

Call get or select with raw=True

@parthipan-ganeshaperumal
Copy link
Author

Yes, it worked with proper data but converstion type based information missed and giving as attribute info like this : conversion:{"dict":{}m "type":7} instead of {'val_0': 0, 'val_1': 1, 'text_0': 'FALSE', 'text_1': 'TRUE'} or {0:True, 1:False} ... how to fix

@danielhrisca
Copy link
Owner

print(ch.conversion)

@parthipan-ganeshaperumal
Copy link
Author

before building below mdf file with converstion value :

enter conversion:{'val_0': 0, 'val_1': 1, 'val_2': 2, 'val_3': 3, 'val_4': 4, 'val_5': 5, 'val_6': 6, 'val_7': 7, 'val_8': 8, 'text_0': 'EmiCtrl', 'text_1': 'PartialFC', 'text_2': 'EmiOSC', 'text_3': 'EmiHeat', 'text_4': 'EmiGpf', 'text_5': 'Diagnostics (SwiftLamOffs)', 'text_6': 'ProtExh', 'text_7': 'ProtIgn', 'text_8': 'Debug', 'default': b'default key'}

after try to view the file via below:

1.mdf = asammdf.MDF('particular.mf4')
2.signals = mdf.select(["rVcLamTar_D_LamSrc"])

signal(as below):

[<Signal rVcLamTar_D_LamSrc:
samples=[b'EmiCtrl' b'EmiCtrl' b'EmiCtrl' ... b'EmiGpf' b'EmiGpf' b'EmiGpf']
timestamps=[ -5.05789961 -5.0478505 -5.03780139 ... 1384.68072007 1384.69071935
1384.70076962]
invalidation_bits=None
unit="-"
conversion=None
source=SignalSource(name='Python', path='Python', comment='', source_type=4, bus_type=0)
comment="Lambda source"
mastermeta="('time', 1)"
raw=False
display_name=
attachment=()>
]

conclusion : converstion type applied on samples but conversion comes as None so here my query : I don't wanna apply conversion_type on samples but i just wanna see the converstion information in conversion ... how to do this?

@danielhrisca
Copy link
Owner

Call get or select with raw=True

https://asammdf.readthedocs.io/en/latest/

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

2 participants