Dynamic text change to "error" if chanel value greater than specified value

Forum Home Forums Understanding the Software Using Formulas Dynamic text change to "error" if chanel value greater than specified value

This topic contains 10 replies, has 3 voices, and was last updated by Avatar ns.fariz 1 week, 4 days ago.

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #5792
    Avatar
    ns.fariz
    Participant

    Hi Mikhail,

    I have device connected via modbus protocol. And I have connected to its sensor, but I want dynamic text to show “error” when sensor reading is greater than 150. Can it be achieved with formula?

    Thanks,

    #5796
    Mikhail
    Mikhail
    Moderator

    Hi,
    If channels is displayed as number, you can’t display “Error”. You can display error on a separate text component.

    #5797
    Mikhail
    Mikhail
    Moderator

    Hi,
    If channels is displayed as number, you can’t display “Error”. You can display error on a separate text component.

    #5801
    Avatar
    ns.fariz
    Participant

    Hi Mikhail,
    What’s your suggestion, I just need it it to pass the value to dynamic text when it read <150.

    #5803
    Avatar
    manjey73
    Participant

    Can try a formula that any number will translate to text and if the number is less than or greater than the desired range, to make an inscription Error ?

    That is, in fact, any correct number will be text and not the number itself.

    Never tried that.

    #5804
    Avatar
    manjey73
    Participant

    public double ToASCII(double can)
    {
    string test = String.Format(“{0:F2}”, can);
    if (can > 3.5) test = “Error”;
    return ScadaUtils.EncodeAscii(test);
    }

    Make an additional channel, put it in the Format – ASCII Text and use a similar formula. Specify the desired number of decimal places. It is better to add a couple of input variables for Min and Max to set in the formula… Output as Dynamic text.

    #5805
    Avatar
    manjey73
    Participant

    public double ToAscii(double channel, double min, double max)
    {
    string s = String.Format(“{0:F2}”, channel);
    if (channel < min || channel > max) s = “Error”;
    return ScadaUtils.EncodeAscii(s);
    }

    353 Extra Channel – use formula ToAscii(Val(532), -1, 3.45)
    Format – Text ASCII

    353 – The channel, which we will display as Dinamic text and two values for minimum and maximum

    • This reply was modified 2 weeks, 2 days ago by Avatar manjey73.
    #5809
    Avatar
    ns.fariz
    Participant

    Hi Manjey,

    That is, in fact, any correct number will be text and not the number itself.

    No that I want, can I make it display number? , and if it’s value greater than desired number, it will turn “error” or something else. Because when sensor get faulty, it will show value 65535,

    #5810
    Mikhail
    Mikhail
    Moderator

    If sensor returns 65535, set channel data to undefined. Try the formula:
    Cnl; Cnl >= 65535 ? 0 : CnlStat
    The right part of the formula defines channel status.

    • This reply was modified 2 weeks, 1 day ago by Mikhail Mikhail.
    #5812
    Avatar
    manjey73
    Participant

    ns.fariz Yes, the scheme will look like numbers, except for the conditions that you specify. It works, I checked 🙂 But the status can be changed color, but I did not check

    #5831
    Avatar
    ns.fariz
    Participant

    Hi Manjey,

    Your formula is too complicated to me, for now I stick with Mikhail solution. Thank you for your help everyone.

Viewing 11 posts - 1 through 11 (of 11 total)

You must be logged in to reply to this topic.