Author Topic: Checking the returned tag value against a preset  (Read 1314 times)

ScottyP

  • Newbie
  • *
  • Posts: 15
    • View Profile
Checking the returned tag value against a preset
« on: April 15, 2021, 07:50:48 AM »
Hi all - I'm using AHMI for a great dashboard reading our CLX PLC's along with other things, and hit a problem I can't seem to solve yet (experienced in VB6, new to .NET)

I pull a string tag into a BevelButtonDisplay to show a production run code, so when the machine is running the production ID is entered by them on the local HMI at the console, and appears in my AHMI dashboard as it should.

When the machine is not running, no code is entered so I want to change the text in the BBD to "PLANNED DOWNTIME" lets say, however I seem to have issues finding the right property to check if the PLC is returning a blank string tag. I have tried the TextChanged property of the BBD so that as it changes to blank, I try to check if the .text = "" and initially that is true when no string is displayed (the PLC returned an empty string from that tag) - so I set the .text value of the BBD to "PLANNED DOWNTIME" but it gets over-written a second later as the tag refreshes - this time the TextChanged property never fires again??

I need a straightforward way to detect the PLC tag returning a blank string and then substitute my string into the control. I tried the DataSubscriber control but double clicking it does not take me to its events.

I have AHMI V3.99 and VS 2019. The data I am reading from the PLC works flawlessly, just need a method or property that is only true when the returned tag data matches a value. Seems like it should be easy, maybe I'm not seeing the solution.


EDIT I had to reboot VS as it had stopped letting me double click into a controls' code - weird. Anyway, I am using a timer to check the .text values and that works, so of course the EthernetIPforCLX overwrites the .text with the blank tag value every 500ms, and the timer puts the string back, so I guess I will have to read the tag value into an intermediate variable, check if it's blank and then write the default string to the DBB control if it is, and the proper data if not. I think the timer will be best for that function. This is instead of using the direct tag link in the DBB properties.

I think I answered my own question........!

Is there a standard VB style label control in VS? I can only seem to find ones that can't be resized at design time...
« Last Edit: April 15, 2021, 08:07:04 AM by ScottyP »

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: Checking the returned tag value against a preset
« Reply #1 on: April 16, 2021, 02:09:40 AM »
In the Toolbox you can find standard WinForms Label control in "All Windows Forms" category as well as AdvancedHMI BasicLabel control in "AdvancedHMIControls Components" category.

Both controls have the AutoSize property, which when set to False will allow you to resize the control manually.

Your MainForm, or any other form, should be open in order for the Toolbox to populate available controls/components.

See the attached picture.

ScottyP

  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: Checking the returned tag value against a preset
« Reply #2 on: April 16, 2021, 04:14:04 AM »
Thanks, I never knew about the autosize property, that threw me. Old VB6 just let you resize it from the start as default. Many thanks.