Author Topic: Message Display by Value question  (Read 7359 times)

leesxz

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Message Display by Value question
« Reply #15 on: April 03, 2018, 05:28:21 PM »
The MessageDisplayByValue is used to create a list of messages each with a unique integer value assigned to them. The PCLAddressValue is then pointed to an integer in the PLC that is used to select which message in the list to display.

If you are just looking to display a single message based on a Boolean value, then you can use any number of controls with the PLCAddressVisible property, such as the BasicLabel.

Thanks for your answer!

I just read your sample of message display by value. It helps a lot!

I created a control that is basically an analog display and multistate combined.  I added it to a base project, version 3.99x (I believe).  It will allow bool for states of 0 and 1.  You can download here:
https://drive.google.com/file/d/1_2H0OgWjSnOXPiKPDymz_vMITjE_Pi9m/view?usp=sharing
You can test with Modbus sim.

James

Excellent!

It is really a good example for me!

Thanks for your help, James!

Phrog30

  • Guest
Re: Message Display by Value question
« Reply #16 on: April 03, 2018, 06:08:15 PM »
Hope it helps. I wasn't quite sure how to handle the conversion from bool to integer (considering the value is a string) so I wimped out and butchered that part. So, if you see that part just understand that's not best practice. :)

Phrog30

  • Guest
Re: Message Display by Value question
« Reply #17 on: April 04, 2018, 09:24:40 AM »
Updated app:
https://drive.google.com/file/d/1GqH4FxCVq8GCQGnNjzITB7D-E_7L0I2W/view?usp=sharing
I made it a little easier to integrate if anyone wants to use.  Instead of my keypad, I went back to "stock".  On the main form I created some examples that shows what the control can do.  In my opinion it's pretty powerful since it allows embedded variables.

James

Edit: updated, added observable collections, INI sections
« Last Edit: April 09, 2018, 01:37:27 PM by Phrog30 »

leesxz

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Message Display by Value question
« Reply #18 on: April 04, 2018, 12:02:05 PM »
Hope it helps. I wasn't quite sure how to handle the conversion from bool to integer (considering the value is a string) so I wimped out and butchered that part. So, if you see that part just understand that's not best practice. :)

I use Convert.ToInt32(bool) to convert bool to integer. True returns -1 and False returns 0.

 

Phrog30

  • Guest
Re: Message Display by Value question
« Reply #19 on: April 04, 2018, 12:06:59 PM »
Hope it helps. I wasn't quite sure how to handle the conversion from bool to integer (considering the value is a string) so I wimped out and butchered that part. So, if you see that part just understand that's not best practice. :)

I use Convert.ToInt32(bool) to convert bool to integer. True returns -1 and False returns 0.

That will give an exception, plus true should be 1. After 30 minutes I didn't see spending any more time as worthwhile. I may come back to it later.

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: Message Display by Value question
« Reply #20 on: April 04, 2018, 12:14:28 PM »
As an example, this is what Archie has in the BasicLabel:

            If (String.Compare(m_Value, "True", True) = 0) Then
                If m_BooleanDisplay = BooleanDisplayOption.OnOff Then ResultText = "On"
                If m_BooleanDisplay = BooleanDisplayOption.YesNo Then ResultText = "Yes"
                If m_BooleanDisplay = BooleanDisplayOption.TrueFalse Then ResultText = "True"
                If m_BooleanDisplay = BooleanDisplayOption.OneZero Then ResultText = "1"
            ElseIf (String.Compare(m_Value, "False", True) = 0) Then
                If m_BooleanDisplay = BooleanDisplayOption.OnOff Then ResultText = "Off"
                If m_BooleanDisplay = BooleanDisplayOption.YesNo Then ResultText = "No"
                If m_BooleanDisplay = BooleanDisplayOption.TrueFalse Then ResultText = "False"
                If m_BooleanDisplay = BooleanDisplayOption.OneZero Then ResultText = "0"

Which is pretty much: if True then 1 else if False then 0.

Phrog30

  • Guest
Re: Message Display by Value question
« Reply #21 on: April 04, 2018, 12:18:44 PM »
Yeah, I'm just saying if true then 1, else 0. If the value is numeric then it is what it is. Pretty easy and straight forward, just not exactly elegant.