Announcement

Collapse
No announcement yet.

How do I get device string with ScaleText for current value?

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

    How do I get device string with ScaleText for current value?

    I have features with ScaleText, how can I get the current device string?

    Both EProperty.Status and hsDevice.Status return empty string. Do I have to manually convert current device value to string?

    #2
    spud ?

    I do this, but it's so ugly - I hope there's better way?

    Code:
    double v = (double)ValueCached;
    StatusGraphic sg = GetStatusGraphic(v);
    StatusControl sc = GetStatusControl(v);
    var ad = AdditionalStatusData?.ToArray();
    s = sg?.GetLabelForValue(v, ad) ?? sc?.GetLabelForValue(v, ad);

    Comment


      #3
      Basically what you want is a replacement for CAPIGetStatus() that we had in the HS3 API, correct?
      If so, I don't think it exists in the HS4 Plugin SDK yet

      Comment


        #4
        Originally posted by spud View Post
        Basically what you want is a replacement for CAPIGetStatus() that we had in the HS3 API, correct?
        If so, I don't think it exists in the HS4 Plugin SDK yet
        I just want to read current device string (EProperty.Status) which was not set directly, but via the device value with ScaleText, i.e. if the device displays "-33.794702°" - but EProperty.Status returns empty string.

        Possibly it's a bug? Is it supposed to return "-33.794702°"?

        [EDIT]

        Yes, this workaround works:

        Code:
        var capi = HS3.CAPIGetStatus(RefId);
        return capi?.Status;

        Comment


          #5
          Status Eproperty in HS4 is the HS3 DeviceString. Intentional, not a bug.

          Comment


            #6
            The question I think is given a DeviceRef, how do you get a lable, how to use GetLableForValue?
            tenholde

            Comment


              #7
              Originally posted by alexbk66 View Post
              spud ?

              I do this, but it's so ugly - I hope there's better way?

              Code:
              double v = (double)ValueCached;
              StatusGraphic sg = GetStatusGraphic(v);
              StatusControl sc = GetStatusControl(v);
              var ad = AdditionalStatusData?.ToArray();
              s = sg?.GetLabelForValue(v, ad) ?? sc?.GetLabelForValue(v, ad);
              Where do I find GetStatusGraphic and GetStatusControl?
              tenholde

              Comment


                #8
                In the general case label and status are different. Status text is formed from DeviceValue based upon the other device properties that have been set. Label is the text associated with a control. HS3 DeviceString is now HS4 EProperty.Status. The displayed text on a HS browser page is a function of DeviceValue+properties. DeviceString/Eproperty.Status are independent and take precedence in the rendering of text vs. DeviceValue+properties.

                Comment


                  #9
                  Originally posted by tenholde View Post

                  Where do I find GetStatusGraphic and GetStatusControl?
                  hs.GetStatusGraphicForValue(RefId, value);
                  hs.GetStatusControlForValue(RefId, value);

                  Comment


                    #10
                    Am I missing something? This seems wierd.

                    AddStatusData =hs4.GetPropertyByRef(DevRef, EProperty.AdditionalStatusData) returns a List(of String)

                    While aStatusControl.GetLabelForValue(d, AddStatusData) requires String() for an argument? Makes me think I am doing something wrong?

                    tenholde

                    Comment


                      #11
                      That's what I do:

                      Click image for larger version

Name:	Screenshot 2021-06-15 012422.jpg
Views:	205
Size:	64.0 KB
ID:	1479521

                      Comment


                        #12
                        Code:
                        public string GetLabelForValue(double value, string[] additionalData = null)

                        Comment


                          #13
                          Thanks for your code. Essentially what I am doing. Just mystified why AdditionalData is List(of String) but the functions require it as String()

                          Thought I might be doing it the hard way.
                          tenholde

                          Comment


                            #14
                            Often suffix is AdditionalData[0]

                            Comment

                            Working...
                            X