Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

RTMC numeric formatting - little known functions


aps Jun 21, 2010 10:42 AM

In another thread (about something else) MikeW said:

"RTMC (pro) needs a "WDQ" like function to properly show wind direction, if anything, allow 3 figure outputs ...ie 030 deg or 003 degrees instead of 30 or 3.....(just a dig to CSI)"

It turns out no other function is needed as there are functions built into RTMC to allow you to control how values are displayed (which are not commonly known). One of the most useful command is FormatFloat. You can achieve what you want above, by calling the variable to be displayed within a Formatfloat construct, e.g.

FormatFloat("Server:CR1000.Public.WD",$"%03.0f")

This will display the wind direction as a 3 digit number with leading zeroes and no decimal places.

Note: these functions were only added in Version 3 versions of RTMC (std and Pro)


MikeW Jul 11, 2010 05:47 AM

Thanks for the tip, I will try it shortly, its a big help.

The WDQ function is used in split to convert degrees to cardinal wind direction, this function should be included in the tools of RTMC Pro, that was my wish.

The only problem with the format float function for displaying a standard WMO wind direction is that when the direction is <0.5 degrees(because I only display whole degrees), the wind direction will display 000 which is okay as long as the speed is also zero (or greater than 0.5)......this is why I would prefer to show a cardinal wind direction (back to that dream of WDQ function for RTMC pro). The ultimate would be if I could use an if statement like this ...if WS=0 then WD="calm" and WS= NULL but....this is only because if wind speed is not zero then the direction cannot be 0, it must be 360

check out my display (current conditions)

http://tgs.gov.mb.ca/climate

Thanks again for the tip

Mike


IslandMan Jul 11, 2010 09:50 AM

Mike,
You could always generate the cardinal points and the word "calm" as a string variable using Case statements in the logger program and just display them as such in your RTMC.
IslandMan


MikeW Jul 12, 2010 03:25 AM

Thanks for the reply,

I have created multistate alarms in RTMC which would show a small .png of the cardinal direction (pain to create) although just on my current conditions page, I would have to do in excess of 35 which eventually causes issues when loading the project in run-time.

Your suggestion does work but I have 510's. I think if this request gets to the dev team in time it may come out in v3.2.

in the mean time, at least I can show WD publically, in the proper format.....thanks to Andrew

Mike


IslandMan Jul 12, 2010 10:33 AM

Not sure if you are using RTMC or RTMCPro. In RTMCPro 3.1 you can designated a data file to be used for data display.

Another workaround would be to run your "raw" data file through split with taskmaster when you receive a valid poll. Use the WDQ function to generate the cardinal points then read from that file into your display screens. This way you wouldn't have to re-write 35 programs :-)

Just another thought I had.
IslandMan


ChipsNSalsa Jul 15, 2010 06:16 PM

It would indeed be nice if there were a function in RTMC to return cardinal wind direction, but for now try out this monster expression with the WD alias modified to point to your wind direction:

Alias(WD,"Server:Logan.Public.WindDir");IIF((WD>=0 AND WD<22.5) OR (WD>=337.5 AND WD<370),$"N",IIF(WD>=22.5 AND WD<67.5,$"NE",IIF(WD>=67.5 AND WD<112.5,$"E",IIF(WD>=112.5 AND WD<157.5,$"SE",IIF(WD>=157.5 AND WD<202.5,$"S",IIF(WD>=202.5 AND WD<247.5,$"SW",IIF(WD>=247.5 AND WD<292.5,$"W",IIF(WD>=292.5 AND WD<337.5,$"NW",$"Error"))))))))

I should point out that the alias function wasn't available prior to version 3.0 so if you have an older version you'll have to specify the long data reference string over and over again.

* Last updated by: ChipsNSalsa on 7/15/2010 @ 12:23 PM *


ChipsNSalsa Jul 15, 2010 11:22 PM

Here's an 8 and a 16 segment expression without the constants:

Alias(WD,"Server:Logan.Public.WindDir");IIF((WD>=0 AND WD<360/8/2) OR (WD>=7*360/8+360/8/2 AND WD<370),$"N",IIF(WD>=360/8/2 AND WD<360/8+360/8/2,$"NE",IIF(WD>=360/8+360/8/2 AND WD<2*360/8+360/8/2,$"E",IIF(WD>=2*360/8+360/8/2 AND WD<3*360/8+360/8/2,$"SE",IIF(WD>=3*360/8+360/8/2 AND WD<4*360/8+360/8/2,$"S",IIF(WD>=4*360/8+360/8/2 AND WD<5*360/8+360/8/2,$"SW",IIF(WD>=5*360/8+360/8/2 AND WD<6*360/8+360/8/2,$"W",IIF(WD>=6*360/8+360/8/2 AND WD<7*360/8+360/8/2,$"NW",$"Error"))))))))

Alias(WD,"Server:Logan.Public.WindDir");IIF((WD>=0 AND WD<360/16/2) OR (WD>=15*360/16+360/16/2 AND WD<370),$"N",IIF(WD>=360/16/2 AND WD<360/16+360/16/2,$"NNE",IIF(WD>=360/16+360/16/2 AND WD<2*360/16+360/16/2,$"NE",IIF(WD>=2*360/16+360/16/2 AND WD<3*360/16+360/16/2,$"ENE",IIF(WD>=3*360/16+360/16/2 AND WD<4*360/16+360/16/2,$"E",IIF(WD>=4*360/16+360/16/2 AND WD<5*360/16+360/16/2,$"ESE",IIF(WD>=5*360/16+360/16/2 AND WD<6*360/16+360/16/2,$"SE",IIF(WD>=6*360/16+360/16/2 AND WD<7*360/16+360/16/2,$"SSE",IIF(WD>=7*360/16+360/16/2 AND WD<8*360/16+360/16/2,$"S",IIF(WD>=8*360/16+360/16/2 AND WD<9*360/16+360/16/2,$"SSW",IIF(WD>=9*360/16+360/16/2 AND WD<10*360/16+360/16/2,$"SW",IIF(WD>=10*360/16+360/16/2 AND WD<11*360/16+360/16/2,$"WSW",IIF(WD>=11*360/16+360/16/2 AND WD<12*360/16+360/16/2,$"W",IIF(WD>=12*360/16+360/16/2 AND WD<13*360/16+360/16/2,$"WNW",IIF(WD>=13*360/16+360/16/2 AND WD<14*360/16+360/16/2,$"NW",IIF(WD>=14*360/16+360/16/2 AND WD<15*360/16+360/16/2,$"NNW",$"Error"))))))))))))))))

If calculations were allowed in Alias functions, much much shorter expressions could be used. Unfortunately they are not. Maybe some day they will be and we can do this:

Alias(WD,INT(1+("Server:Logan.Public.WindDir"+(360/16/2))/(360/16)));IIF(WD=1 OR WD=17,$"N",IIF(WD=2,$"NNE",IIF(WD=3,$"NE",IIF(WD=4,$"ENE",IIF(WD=5,$"E",IIF(WD=6,$"ESE",IIF(WD=7,$"SE",IIF(WD=8,$"SSE",IIF(WD=9,$"S",IIF(WD=10,$"SSW",IIF(WD=11,$"SW",IIF(WD=12,$"WSW",IIF(WD=13,$"W",IIF(WD=14,$"WNW",IIF(WD=15,$"NW",IIF(WD=16,$"NNW",$"Error"))))))))))))))))

* Last updated by: ChipsNSalsa on 7/15/2010 @ 6:14 PM *


MikeW Jul 16, 2010 06:02 PM

Thanks to Glen and IM for the input. I have a huge RTMC file as it is approaching 7MB's. On the bright side, 3.1 has never crashed on me so far!

I am going to start with my current conditions;

http://tgs.gov.mb.ca/climate/CurrentConditions2.aspx

(note my 3 digit winds thx Richard..hope when you look I'll have some winds <100deg)

I will figure out something for calm conditions as I still have that problem.....I don't like seeing winds of dir 000 with a valid speed and vice a valid direction with no speed (or 0.499999km/h's).
I need to display "calm" for dir and speed if that is the case
I'll clarify; presently I do not have cardinal dir's(hope to though)

-I show whole degrees for direction (3 digits now)
-I convert m/s to km/h and round whole.
-The logger resolves calm with 000 for dir and 0 for speed IF the speed is abs 0 (m/s).....(member,...x35 510's so no "in logger" soln's(our dozen )

The problem is when the resolved speed(on my RTMC pro project) is >0 and <0.5 (km/h) the direction is valid but the speed shown will be 0, ie 354 @ 0 km/h(0.49 km/h) or 000 @ 0 km/h (000.49deg @ 0.49 km/h).......see why I need cardinals...I prefer deg's as a Met person but the pub doesn't like it or at least comp with both formats.

Thanks again all, I'm going to play with this new ammo you've given me....(I've read the ? twice on the new f's and its still set'lin in my noggin with the possibilities for me...I can now show a conditional humidex...)

I will reply whether or not I can load the proj after 5 or so stations with the new code....with the calm thing fixed though.

okay, time to dive....Mike


MikeW Jul 16, 2010 06:20 PM

To IM: Split is so essential to our op., we use it for tons of things in the last 5 years, here's the problem though..I love the GUI for the server NW and hate creating 5 instances(sources) per station for 50 stations, this is just one reason and a small one.......the big problem is this; we have a mixed NW of 510's/10x and 1K,800's and decided years ago to go Table Based on the 510's....which I think is where our prob is (10xTD/PB O/S)...we use cell modems which are prone to telemetry issues which results in this brutal and unfortunate problem called "cannot find sync byte".....its seems inherent to the 510/10x-TD O/S....I can live with it though BUT, sometimes LN never recovers from this an resets everything and downloads the table def's and shoots the output (sans T0A5....which I hate) to the default dest and everything (but run-time...its a cache thing)in our data stream stops until I cut out the data, paste it back into the proper dir and change the dest in setup for the station......if I split up the source, run-time wouldn't work when my little "sync byte" issue happens...which is 1 or two stations every couple of weeks,....plus I would have to create over 150 source files(5 tables per stn)..almost as fun as setting up VDV!

Anyways thanks IM, it is a viable solution and it works, if I had a couple of stn's it would be the best soln.

Mike


MikeW Jul 16, 2010 06:38 PM

One last note on my "cannot find sync byte" problem....I have 25 ravens on the airlink dns server, sometimes the resolution messes up (25 modems turning on within min's of each other) and obviously when LN makes a call to a modem that hasn't resolved yet, it may (and sometimes does)connect to another station and after the handshake happens and the "sync byte" cannot be found, luckily, LN will take down the new stn's table def's and write them to a discernable place.....ie station1.station2.dat....and run-time STILL WORKS PROPERLY with the correct stations viewing on the run-time snapshots....beautiful. I can live with this problem as due to location and telemetry, I will never achieve perfect comms (no landlines......siting in middle of nowwhere, but good Met siting). I fix this quick enough and split would pick up the correction on the next hour, but remember, run-time does not miss a beat upon my "sync-byte" issue (of which the pub see)if I split the source, runtime would would not eat if "syncy" jumps in our LN. Sorry for the tangent.Mike


MikeW Jul 16, 2010 10:46 PM

Wow, the file compiles and it works great....its time to play with these string functions....it seems all of a sudden with the new K loggers combined with the cap's in LN and RTMC pro that its openned a whole new door on a huge wharehouse of possibilities for me to automate the disemination of our weather data. Although I haven't solved the calm thing completely, I'm now leaps ahead of where I was yesterday......Thanks to IM, and all of you CSI guys/girls who are addicted to this stuff as I am.....see the results....ticket closed....MW

http://tgs.gov.mb.ca/climate/CurrentConditions2.aspx

Log in or register to post/reply in the forum.