Announcement

Collapse
No announcement yet.

BKM for Polling (location, methods, setup...)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    BKM for Polling (location, methods, setup...)

    Hi guys,

    Might be a stupid question but trying to figure out below...

    Trying to find what the best way to handle auto "polling interval" for a plugin. I see on Alex's Weather Plugin he has polling setup on the "Settings page with drop down select time interval. That would be something that would work for me.

    1. I can add to settings page but where is the BKM to store that setting? (not settings.ini)
    2. Is there a HS SDK class/method prebuilt for polling I haven't found?

    I can setup the programming, timer to poll at the interval and update devices. Just need a little help with where to store that poll interval. First pure HS4 plugin and as a Java guy it's been a VB challenge the past week. Now I have "Dim" in my works Java code....



    Thanks in advance.
    Attached Files

    #2
    Can’t answer your question, but as a Java guy, I suggest you learn to use C# for your plug-in instead of Visual Basic. VB is totally a legacy language, so although it can do things like multi threading (which you likely need), it will be very hard to find example code on how to write thread safe code in VB, but their are tons of examples on C#.

    Plus, C# is very similar syntactically to Java.

    FYI, a plug-in is simply a Windows “console” app that is started automatically by HS4 and has an inter process API. Unless the “work” your plug-in does during on each poll interval is very short, you will need to execute it in another thread or it could cause interaction problems with HS4. That will be far better supported in C#.

    Comment


      #3
      Originally posted by bradleyward View Post
      Can’t answer your question, but as a Java guy, I suggest you learn to use C# for your plug-in instead of Visual Basic. VB is totally a legacy language, so although it can do things like multi threading (which you likely need), it will be very hard to find example code on how to write thread safe code in VB, but their are tons of examples on C#.
      Thanks for the advice. This PI isn't too complex so I can convert once working. The next one I'll code in C#.

      Originally posted by bradleyward View Post
      Plus, C# is very similar syntactically to Java.
      I've been a Java programmer for years. That will help. )

      Originally posted by bradleyward View Post
      FYI, a plug-in is simply a Windows “console” app that is started automatically by HS4 and has an inter process API. Unless the “work” your plug-in does during on each poll interval is very short, you will need to execute it in another thread or it could cause interaction problems with HS4. That will be far better supported in C#.
      Yes, polling to the cloud a few times could be quick to lengthy. A separate thread is required. The companies API is not friendly and they haven't updated anything in years. Why develop a PI for it. The device, right now, is the only one available that will work in many scenarios.

      I think for my question, PlugExtraData might be my answer. Will wait for others to weigh in.
      Thanks

      Comment


        #4
        Originally posted by mattm55 View Post
        I see on Alex's Weather Plugin he has polling setup on the "Settings page with drop down select time interval. That would be something that would work for me.

        1. I can add to settings page but where is the BKM to store that setting? (not settings.ini)
        2. Is there a HS SDK class/method prebuilt for polling I haven't found?

        I can setup the programming, timer to poll at the interval and update devices. Just need a little help with where to store that poll interval
        There's no "class/method prebuilt for polling". All device settings I store in the device PED (Plugin Extra Data).

        And in my base device class (which I use in all my plugins) I have a function to start a timer - as I never need more than one timer.
        So in the derived class I just need to overwrite "TimerCallback" virtual function:

        Click image for larger version  Name:	image.png Views:	0 Size:	23.4 KB ID:	1591583

        Click image for larger version  Name:	image.png Views:	0 Size:	127.6 KB ID:	1591582

        Click image for larger version

Name:	image.png
Views:	39
Size:	45.8 KB
ID:	1591584

        Comment


          #5
          Thanks Alex.

          Easily understood and great explanation with examples.

          Comment

          Working...
          X