Forum Home › Forums › Understanding the Software › Using Formulas › Dynamic text change to "error" if chanel value greater than specified value
- This topic has 10 replies, 3 voices, and was last updated 4 years, 8 months ago by ns.fariz.
-
AuthorPosts
-
August 5, 2019 at 9:32 pm #5792ns.farizParticipant
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,
August 6, 2019 at 12:05 pm #5796MikhailModeratorHi,
If channels is displayed as number, you can’t display “Error”. You can display error on a separate text component.August 6, 2019 at 12:05 pm #5797MikhailModeratorHi,
If channels is displayed as number, you can’t display “Error”. You can display error on a separate text component.August 6, 2019 at 8:53 pm #5801ns.farizParticipantHi Mikhail,
What’s your suggestion, I just need it it to pass the value to dynamic text when it read <150.August 7, 2019 at 11:45 am #5803manjey73ParticipantCan 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.
August 7, 2019 at 12:57 pm #5804manjey73Participantpublic 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.
August 7, 2019 at 1:07 pm #5805manjey73Participantpublic 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 ASCII353 – The channel, which we will display as Dinamic text and two values for minimum and maximum
- This reply was modified 4 years, 8 months ago by manjey73.
August 7, 2019 at 2:39 pm #5809ns.farizParticipantHi 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,
August 7, 2019 at 2:42 pm #5810MikhailModeratorIf 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 4 years, 8 months ago by Mikhail.
August 7, 2019 at 2:49 pm #5812manjey73Participantns.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
August 11, 2019 at 9:31 pm #5831ns.farizParticipantHi Manjey,
Your formula is too complicated to me, for now I stick with Mikhail solution. Thank you for your help everyone.
-
AuthorPosts
- You must be logged in to reply to this topic.