Author Topic: Basic Indicator On wiith decimal value  (Read 138 times)

Nikola Tesla

  • Newbie
  • *
  • Posts: 6
    • View Profile
Basic Indicator On wiith decimal value
« on: March 14, 2024, 06:25:26 AM »
Good morning friends, I have been trying all day to turn on a BasicIndicator in red colour for example when the modbus register is at a decimal value of 101 and when it is at any other value the indicator is off. But something escapes me because as much as I try I don't get it. How could I do this?

 Thank you very much!

 

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: Basic Indicator On wiith decimal value
« Reply #1 on: March 14, 2024, 08:53:31 AM »
The PLCAddressSelectColor2 works on a boolean value, so you can program the comparison in your PLC to set a boolean value.

The other option is to use some code:

- Add a DataSubscriber to the form
- Set PLCAddressValue to the register you want to use
- Double click the DataSubscriber to get back to code
- Enter this code:
Code: [Select]
if e.Values(0)=101 then
  BasicIndicator1.ForColor=Color.Red
else
  BasicIndicator1.ForColor=Color.White
end if


Nikola Tesla

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Basic Indicator On wiith decimal value
« Reply #2 on: March 14, 2024, 03:23:10 PM »
The PLCAddressSelectColor2 works on a boolean value, so you can program the comparison in your PLC to set a boolean value.

The other option is to use some code:

- Add a DataSubscriber to the form
- Set PLCAddressValue to the register you want to use
- Double click the DataSubscriber to get back to code
- Enter this code:
Code: [Select]
if e.Values(0)=101 then
  BasicIndicator1.ForColor=Color.Red
else
  BasicIndicator1.ForColor=Color.White
end if

Oh!! Thank you very much Archie for introducing me to the wonderful world of DataSubscriber!!!