Author Topic: AppleScript way to do "STATS" tag?  (Read 4610 times)

elagache

  • Global Moderator
  • Storm
  • *****
  • Posts: 6494
    • DW3835
    • KCAORIND10
    • Canebas Weather
  • Station Details: Davis Vantage Pro-2, Mac mini (2018), macOS 10.14.3, WeatherCat 3
AppleScript way to do "STATS" tag?
« on: February 27, 2012, 10:19:46 PM »
Howdy Stu and WeatherCat AppleScript fans,

This maybe already on the list or perhaps painfully difficult to do - or both!  :o  But here it goes. . . . .

It sure would be nice to be able to look up values like high and low temperature from AppleScript like the way the STATS tag can be used for web templates.  Right now my ET Reporter script runs all day because it needs the high and low temperature to compute the Blaney?Criddle estimate of evapotranspiration.  It isn't exactly the most efficient use of computer resources.

So far that's the only time I've run into the problem, so this may be another WeatherCat 2.0 item, but thought I would toss it out as one of those - "got to eventually get to it" sort of things.

Cheers, Edouard  [cheers1]

WCDev

  • WeatherCat Developer
  • Administrator
  • Storm
  • *****
  • Posts: 2911
    • CW9739
    • ISCOTLAN25
    • Trixology
  • Station Details: Main Station: Vantage Pro-2, 24hr fars, solar, soil/leaf station, extra temp stations, no U.V. WeatherLink IP.
Re: AppleScript way to do "STATS" tag?
« Reply #1 on: February 27, 2012, 10:39:46 PM »
Hi Edouard,
 
I can confirm we will see that in the future; it's tied into the WeatherCat SDK a little bit, which isn't available yet but will be in the near future - it's my next big job after 1.00 ships so we may well see this in a 1.x version.

It's actually pretty much all done, all I have to do is publish the internal query type WeatherCat uses - it's all ready (it's what custom web or a manual query from the stats window creates and sends to the stats manager), just needs wrapping up and publishing - I plan to make it available both to plug-ins and AppleScript.

The only slightly gotcha there may be is that there can be a delay between sending a query and getting a reply as these queries are processed on a separate thread whereas all AppleScript accesses come in on the main thread (I do wish they'd get rid of that restriction - maybe they have - last time I checked was 10.5 ish) - maybe a couple of milliseconds unless data needs to come in off disk where it can run to a few seconds.

Basically a query is exactly the same as the STAT$ tag operands  (i.e. data type, query type and date range) - those operands go directly into the fields in a query. The only difficulty you may face is creating time ranges - the query needs  a start date and an end date  - this is very flexible as you can do stats across any time range, but a bit of a pain, so I'll probably lay on top higher level date ranges as per the STAT$ tag (TODAY, YESTERDAY and so forth).

Hope this answers your question,
Stu.

elagache

  • Global Moderator
  • Storm
  • *****
  • Posts: 6494
    • DW3835
    • KCAORIND10
    • Canebas Weather
  • Station Details: Davis Vantage Pro-2, Mac mini (2018), macOS 10.14.3, WeatherCat 3
Sounds good to me!! (Re: AppleScript "STATS" tag?)
« Reply #2 on: February 28, 2012, 03:31:53 AM »
Howdy Stu and WeatherCat fans,

I can confirm we will see that in the future; it's tied into the WeatherCat SDK a little bit, which isn't available yet but will be in the near future - it's my next big job after 1.00 ships so we may well see this in a 1.x version.

Bummer dude!  I wanted to play with the LWC SDK but never got around to it.  I hadn't noticed that the SDK was broken in da' Cat.  Perhaps hopelessly naive on my part, but I still hope to write some plug-ins for WeatherCat.  The uploading to UK Met Office, PWS Weather and WeatherBug looked like good candidates for "experiments" in learnin' myself the SDK.  Oh well, I had hoped for a long winter of gentle soaking rains so I would have plenty of time to explore this sort of stuff.  With spring already evident around here . . . . time to play with the SDK won't be showing up anytime soon!  ::)


The only slightly gotcha there may be is that there can be a delay between sending a query and getting a reply as these queries are processed on a separate thread whereas all AppleScript accesses come in on the main thread (I do wish they'd get rid of that restriction - maybe they have - last time I checked was 10.5 ish) - maybe a couple of milliseconds unless data needs to come in off disk where it can run to a few seconds.

Uh Stu, have you looked recently at how slow AppleScript actually is!?!   If the only issue was being too slow for AppleScript - no problem!!  :)  Now it could be a problem for the SDK, that can run along at Objective-C so it has a right to demand speedy service!!


Basically a query is exactly the same as the STAT$ tag operands  (i.e. data type, query type and date range) - those operands go directly into the fields in a query. The only difficulty you may face is creating time ranges - the query needs  a start date and an end date  - this is very flexible as you can do stats across any time range, but a bit of a pain, so I'll probably lay on top higher level date ranges as per the STAT$ tag (TODAY, YESTERDAY and so forth).

Sounds good to me!  [tup]

Hope this answers your question,

 ;) Well golly, that's such a complete answer maybe I should lay on ya' that other question . . . . ya' know - about the meaning of life!!  [lol2]

Does that fall under: grin and bear it!  :D

Cheers, Edouard  [cheers1]