Aviation gauge
James Sentman
james at sentman.com
Sat Jan 19 09:07:22 EST 2019
You can more or less do this now :) Create 2 dimmable pseudos to hold the thousands and hundreds values and then in the on script of the unit that receives the actual usage data do something like this:
In the on script:
set newValue to (future value)
set thousands to floor( newValue / 1000)
set hundreds to newValue - (thousands * 1000)
-- just for better scaling make the thousands into hundreds so they aren't at the bottom of the gauge all the time
-- you can remove this if you prefer
set thousands to thousands * 100
-- put the values into the pseudos
set value of "thousands pseudo" to thousands
set value of "hundreds pseudo" to hundreds
on floor(TheValue)
if TheValue as integer = TheValue then
return TheValue -- already no decimal
end if
set AppleScript's text item delimiters to {"."}
set theFloor to text item 1 of (TheValue as text)
set AppleScript's text item delimiters to {}
return theFloor as integer
end floor
Applescript doesn’t seem to have a floor() function so I hacked that together. It seems just forcing it to an integer actually rounds the value which I don’t think is what you want here. So that floor function just checks to see if the value coerced to an integer is the same as the original value, if so then there is no decimal and it just returns the existing value. If there is one then the values will be different and it changes the number into a string and just takes the first value after splitting on the decimal point. Not the most efficient way to do it but apart from linking in some cocoa framework stuff or using a scripting extension I don’t see a better way to do it. I’ll add floor and ceil verbs to XTension for the next version ;)
That will give you 2 pseudos with the different values in them, then you can create a gauge in XTdb and put those 2 pseudos into it as arrows rather than the real value of the usage. Some tweaking of the gauge start and end points and you should have something almost as good as what you wanted I think. Let me know how that works.
> On Jan 19, 2019, at 3:33 AM, ard jonker <ard.jonker at xs4all.nl> wrote:
>
> Can the aviation gauge graph format get on the wish list please?
Thanks,
James
James Sentman http://www.PlanetaryGear.org http://MacHomeAutomation.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.machomeautomation.com/pipermail/xtensionlist/attachments/20190119/19579d1d/attachment.html>
More information about the XTensionList
mailing list