Closed ginseil closed 6 years ago
What you see here is partial conversion and it is a part of the MDF standard.
This is normally supported. However, converted channel might have been empty string because of bug #111 What channel do you get ?
What I mean is that the defined macro in the default value is applied before the simple range to text mapping is done.
Let me confirm: you expect that default value becomes a linear conversion, not a text ? Similar conversion is existing in mdf4. Possible but I am wondreing how to trigger it. With keyword 'LINEAR CONV' ? Maybe more examples of it would help a bit to get how CANape is doing...
Let me confirm: you expect that default value becomes a linear conversion, not a text ?
Yes.
Similar conversion is existing in mdf4. Possible but I am wondreing how to trigger it. With keyword 'LINEAR CONV' ?
I think a macro function is surrounded by curly braces, staring with the name of the formula: 'LINEAR_CONV'.
I am currently working on this:
npair = len(conv)
lower = [conv[pair]['lowerRange'] for pair in range(npair)]
upper = [conv[pair]['upperRange'] for pair in range(npair)]
text = {}
for pair in range(npair):
text[pair] = conv[pair]['Textrange']
if 'LINEAR CONV' in text[pair]: # linear conversion from CANape
from sympy import lambdify, symbols
X = symbols('X') # variable is X
left = text[pair].find('"')
right = text[pair].rfind('"')
text[pair] = text[pair][left + 1: right].replace('{', '').replace('}', '')
text[pair] = lambdify(X, text[pair], modules='numpy', dummify=False)
temp = []
for Lindex in range(len(data)):
value = text[0] # default value
for pair in range(1, npair):
if lower[pair] <= data[Lindex] <= upper[pair]:
value = text[pair]
break
if callable(value):
value = value(data[Lindex])
temp.append(value)
Can you check if it would be working for you ? unfortunately, the callable() is giving performance penalty
Hi, I'll test it in the next few days. Thanks for your work!
There is a bug in your code: if 'LINEAR CONV' in text[pair]: # linear conversion from CANape
I miss the underscore in LINEAR_CONV. However your solution works, once the underscore is added.
Good, I will correct and put in master
Part of last commit, you can check
Works like a charm, Thank you! :)
@ginseil
I'm trying to replicate this CANape specific feature, however MDFValidator doesn't raise this warning for my file:
The conversion block seems to me identical to what you had in your measurement. Is there something else that I don't see?
Edit: I'm using MDFValidator 2.4.4 and 2.3.0
I missed the underscore in _LINEARCONV.
Hi
do you plan to add support for CANape specific features like the following one?![image](https://user-images.githubusercontent.com/7522976/32779259-4b4ce36c-c93d-11e7-9dc5-19144a255bd1.png)