Announcement

Collapse
No announcement yet.

tenScripting4, the extensions, and C#

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

    #46
    That was based on the example on this HS doc page. But I'll play around a bit and see what I can figure out. Thanks!

    Comment


      #47
      Originally posted by dlmorgan999 View Post
      That was based on the example on this HS doc page. But I'll play around a bit and see what I can figure out. Thanks!
      Let me know if you get your construct to work. C# for HS4 is very poorly documented and not widely used for scripting. I'm hoping it will be more usable with the recent improvements
      tenholde

      Comment


        #48
        Will do! And agreed - the documentation is fairly sparse. But I so much prefer C# over VB that I'm willing to put in the effort to figure it out. And tenScripting is super nice to have for development. 😊

        Comment


          #49
          I'm thinking about documenting C# use for HS4. Would you be willing to contribute your experiences as you get things working?
          tenholde

          Comment


            #50
            Originally posted by tenholde View Post
            I'm thinking about documenting C# use for HS4. Would you be willing to contribute your experiences as you get things working?
            Sure - I'd be happy to help with that!

            Comment


              #51
              Ed; Thanks for this. I just ran into this thread and gave it a try. Makes life a lot easier.
              Don

              Comment


                #52
                I am writing all my code moving forward in C# instead of VB.Net for HS4. The more I read about Microsoft's waning support for VB, the more sense it makes for me to transition to C#. Thanks to you guys for making progress on ironing out issues with C# and HS4.
                ---------------------------------------------------
                Jean-Marie G. Vaneskahian
                jean@vaneskahian.com
                ---------------------------------------------------

                Comment


                  #53
                  Originally posted by jeanv View Post
                  I am writing all my code moving forward in C# instead of VB.Net for HS4. The more I read about Microsoft's waning support for VB, the more sense it makes for me to transition to C#. Thanks to you guys for making progress on ironing out issues with C# and HS4.
                  I'm working on documenting C# development and HomeSeer. Just starting. Any observations or things learned would be appreciated.
                  tenholde

                  Comment


                    #54
                    Will do! I am nowhere near the coder you are tenholde and I use your tools to help write my simple plug-ins and scripts. Most of my issues relate to understanding how to convert from VB.Net to C# and less about C# use in HS4. Here are some initial thoughts on items I have come across:
                    1. C# requires that the calls to HomeSeer names be case sensitive and do not always match what is in the various HomeSeer document repositories.
                    2. I can no longer declare a variable as just type "object" for use in HS4. I seem to have to cast that variable as a specific HomeSeer type.
                    3. I have to use a lot of casting to data types in the form of: (double)hs4.GetPropertyByRef((int)Custom_HomeSeer_Device_Enums.Attic_Temperature, HomeSeer.PluginSdk.Devices.EProperty.Value)
                    4. I have to convert data types in a way I do not recalling having to be explicit about in VB.Net: int Attic_Temperature = Convert.ToInt32((double)hs4.GetPropertyByRef((int)Custom_HomeSeer_Device_Enums.Attic _Temperature, HomeSeer.PluginSdk.Devices.EProperty.Value))
                    5. In VB.Net this used to work: Dim Pair As VSPair / Dim GPair As VGPair - But now I have to be explicit: HomeSeerAPI.VSVGPairs.VSPair Pair; / HomeSeerAPI.VSVGPairs.VGPair GPair;

                    I am sure these are terrible examples, but it is part of the difficulty I have come across. I spend some of my time using online code converters to move from VB.Net to C#. Usually it works, sometimes it does not.

                    I can't tell you how much I appreciate all that you do for this community! Please let me know how else I can help...

                    Thanks again!
                    ---------------------------------------------------
                    Jean-Marie G. Vaneskahian
                    jean@vaneskahian.com
                    ---------------------------------------------------

                    Comment


                      #55
                      Oh yes, I also figured out how to get a device name and change a device name using C#

                      Get Device Name
                      string Old_Device_Name = (Scheduler.Classes.DeviceClass)hs.GetDeviceByRef(Device_Reference)).get_Name(hs);

                      Set Device Name
                      ((Scheduler.Classes.DeviceClass)hs.GetDeviceByRef(Device_Reference)).set_Name(hs, New_Device_Name_Stirng);
                      ---------------------------------------------------
                      Jean-Marie G. Vaneskahian
                      jean@vaneskahian.com
                      ---------------------------------------------------

                      Comment


                        #56
                        Originally posted by dlmorgan999 View Post
                        Yup. I'm running it as a service, so I stopped the service, copied the latest tenGlobalMethods.dll file to the HS4 root folder, edited the settings file, and started the service.

                        This sounds like an HS4 issue and nothing to do with your code, but I figured I would ask if you've tried using the extensions with C# before. Also, unless the documentation is just a bit behind (always a distinct possibility), this page makes it sounds like you still only use settings.ini for VB scripts.
                        See: https://forums.homeseer.com/forum/homeseer-products-services/system-software-controllers/hs4-hs4pro-software/1511845-hs4-now-includes-option-to-run-as-a-windows-service?p=1529969#post1529969

                        This should be reported as a bug.
                        tenholde

                        Comment


                          #57
                          Thanks for the link - this sounds like exactly what I was seeing. I'll give it a try but probably not until the weekend. If that solves the issue, I'll submit a bug report.

                          Comment

                          Working...
                          X