Please consider adding a lookup function
that would be useful for current gear...
Lookup(Value:Ratio1,"ReturnValue1",Ratio2,"ReturnValue2"...,Ratiox,
"ReturnValuex")
Where...
Value is the gear ratio value/equation, i.e., ([0C]*60*1.830)/([0D]*2.813*1000)
If gear ratio is closest to this value (Ratio1) then return ReturnValue1
If gear ratio is closest to this value (Ratio2) then return ReturnValue2
etc.
Lookup(Value:4.552,"1",2.548,"2",1.659,"3",1.230,"4",1.000,"5",0.830,"6")
https://torque-bhp.com/forums/?wpforumaction=viewtopic&t=8721.0
This capability would also be useful with states if ReturnValue can
be an ascii value.
Fuel Status pid...
Lookup(A:1,"Open Loop",2,"Closed Loop")
Edited.
+1
OK, that's a fair one - key/value pairs. The example is good as I'll try to work towards that
Still doing the equation storage stuff, so I'll send out the next beta once that's done and in, then I'll try to get this function added ready for the one after that
Thank you Ian 🙂 .
This is nearly done - it will probably be in the next couple of betas before release, just a couple of things to tidy up.
The lookup will be something like:
LOOKUP({VALUE}:{DEFAULT}:{KEY1}{OPERATOR}{VALUE1}:{KEY2}{OPERATOR}{VALUE2}:...etc)
Caveat:
* String values will be set in the PID directly. The value will still be set on the PID that was used to match the string (if a string was used) otherwise the replacement value is used.
String, exact matching, returning a string
LOOKUP(A::1='moo':2='boo')
Numeric, exact, with a default of 0 for no match
LOOKUP(A:0:1=100:2=200:3=300)
Numeric, exact, with a default of the input value for no match
LOOKUP(A:A:1=100:2=200:3=300)
Numeric, range matching - 0 to 3 = 4 and 4 to 5 = 7
LOOKUP(A::0~3=4:4~5=7)
String, exact matching, returning a string, value is also returned into the PID. The value will be '5' when A is 2, and 4 when A is 1 (the display will show boo and moo however)
LOOKUP(A::1='moo':2='boo')+3
Mixed matching with strings and numbers (Strings are shown on the display with numbers being passed through to the equation) exact, with a default of the input value for no match
LOOKUP(A:A:1=100:2=200:3='this is a test')
What happens if the value (gear ratio in my
example) doesn't precisely match the key. I'm
guessing the floating point internal value will
have some fractional digits beyond the three
places in my example? Are you requiring an
exact match to the key?
Numeric Range Matching seems to be the answer to my
question but will require the user to determine
upper and lower ranges for each gear?
Will we have to use a certain display type for the
text displays?
I'm always impressed with how you take an
idea and make it better! 🙂
Thanks again Ian.
Any beta testers willing to give this a try...
closest(([0C]*60*1.830)/(([0D]+1)*2.813*1000)::28.000='P/N':4.552='1st':2.548='2nd':1.659='3rd':1.230='4th':1.000='5th':0.830='6th':0.0='OFF')
Edited.
Hi,
I have been trying for days to get the Lookup/closest equation to work, but always get various errors.
Which version of Torque is required to try these functions?
Beta Version 1.8.190.
192 hasn't been released to Beta yet.
Just a heads up... the single quote needs
to be exact. For me, Word was using a single
quote not recognized by Torque's parser by
default. Editing from Torque fixed my issues
at the time.
Hi Capp777,
Thanks for the speedy response.
I used notpad to write the formula, then copied to phone via wiFi, then copied text into Torque.
Running 1.8.178
That's probably part of the problem.
Where to get this "Beta Version 1.8.190." apk?
If enrolled as a Beta Tester it will present
as an update in google play.
This is how I enrolled. Not sure if it is still
open to new testers...
https://torque-bhp.com/forums/?wpforumaction=viewtopic&t=7993.0
So, I am enrolled as a "tester", but how long might "a while" be?
"Note: It can take a while for you to receive the update."
Where/how will I receive this update?
(I am new to this "game", so many questions may seem "dumb" ?)
Same way as regular updates. Goto
your apps in Google Play and look for
Torque Pro update.
Ok, so I got it without knowing.
Then I had to reset my Samsung S2, so i can't use that anymore, as it only has Android Gingerbread, which is too old.
Maybe Samsung can update it for me.
I tried the new Lookup function on my A5, and just by a brief test with the vehicle stationary, it does seem to work.
I'll check again tommorrow when I'm going for a 50km drive.
So I've done a bit of testing, and the lookup does work, but i need to do some refining og my "code".
I does not read ["internal pid"] by using the "name".
I does however read the internal pid if one uses the pid number assigned to that pid. This number however is temporary, once you go out of Torque, that number is lost.
How do i give my internal pid a number?
I also want to try the "closest function, as that may work better.