Author Topic: If Tag Exists  (Read 1553 times)

Phrog30

  • Guest
If Tag Exists
« on: August 07, 2019, 08:21:31 PM »
Archie, or whoever  :)

I'm creating very dynamic screens.  Part of this will need to check if tags exist.  So, the plan is to do a read before doing other steps, however, curious if there is a better way and to get around clobbering the UI if the tag doesn't exist.  Is this something to do in a background thread/worker?  If it exists I'll just see if there is a value, if not look for an error?

Any advice is much appreciated as always.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5270
    • View Profile
    • AdvancedHMI
Re: If Tag Exists
« Reply #1 on: August 07, 2019, 09:09:36 PM »
What about using GetTagList on FormLoad then checking the list?

Phrog30

  • Guest
Re: If Tag Exists
« Reply #2 on: August 07, 2019, 09:45:32 PM »
I'm not familiar with that, I'll look into though, here's a little more info...

I have a motor popup.  This motor may have interlocks, digital inputs, analog inputs, etc.  Each motor is different.  So, one motor may have an analog input for amps/current.  I'll show a display for the current on the popup, but only if the tag exists.  There is one generic motor popup.  In other SCADA platforms (that are tag based), I can check if the tag exists.  If it is, I display it, if not, I don't.  I pass in a basetag, so there is really no list.  I've done parameterized popups before in AHMI, but not quite to this level. 

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5270
    • View Profile
    • AdvancedHMI
Re: If Tag Exists
« Reply #3 on: August 08, 2019, 07:21:23 AM »
Would the base tag be like a prefix to the other tags? For example you would pass a base tag of "Motor1" and the tags to be check would be "Motor1Amps", "Motor1Speed", etc

I am thinking the GetTagList on startup and storing it in a Public variable would probably be the best option. The disadvantage would be the slowing down of the startup especially if there are a lot of tags to read.

Code: [Select]
Public tags() As MfgControl.AdvancedHMI.Drivers.CLXTag

Private Sub MainForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
 tags = EthernetIPforCLXCom1.GetTagList
End Sub

When the pop opens, it can check the tags to see which ones exist.

You could also do a Read within a Try-Catch on each tag before the form pops up. You figure each read would take about 10ms. So if you had 10 tags, it would only delay the form pop up for 100ms

Phrog30

  • Guest
Re: If Tag Exists
« Reply #4 on: August 08, 2019, 09:37:04 AM »
Thanks Archie, on a read, is there a way to speed up the time it takes to "error" out?  Basically, if a read should take 20ms, then in 50ms if I don't have a response assume it's in error??

And yes, the basetag would be the tagname for the UDT, so motor.auto, motor.running, valve.open, etc.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5270
    • View Profile
    • AdvancedHMI
Re: If Tag Exists
« Reply #5 on: August 08, 2019, 10:49:24 AM »
If a read is done on a tag that does not exist, it should throw an exception as fast as the processor replies because it will come back as a Path Destination Unknown. A timeout should only occur if there is no communication or the rare occasion the processor does not response, then it will take a few seconds to throw an exception.

If the tag count is less than 30, then you could use the BeginRead and use the DataReceived and ComError events.

Another option is to use the BeginReadMultiple with the DataReceived and ComError events. This would be the fastest.

Phrog30

  • Guest
Re: If Tag Exists
« Reply #6 on: August 08, 2019, 08:45:10 PM »
Thanks Archie!!

Justinb94

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: If Tag Exists
« Reply #7 on: November 11, 2020, 03:12:03 AM »
Would the base tag be like a prefix to the other tags? For example you would pass a base tag of "Motor1" and the tags to be check would be "Motor1Amps", "Motor1Speed", etc

How hard is it to create a group of controls e.g(motor, buttons, values) into one group that passes a base tag and uses that base as a prefix to reference other tags, similar to your example above?

I can see this function extremely helpful allowing me to build screen very quickly and to standardize all my controls. 

MajorFault

  • Guest
Re: If Tag Exists
« Reply #8 on: November 11, 2020, 10:01:36 AM »
Would the base tag be like a prefix to the other tags? For example you would pass a base tag of "Motor1" and the tags to be check would be "Motor1Amps", "Motor1Speed", etc

How hard is it to create a group of controls e.g(motor, buttons, values) into one group that passes a base tag and uses that base as a prefix to reference other tags, similar to your example above? 

That depends on several things.  What you consider hard.  Your experience level.  Etc.

If you need help I recommend getting very specific.  Passing in a tag is very common.  With the exception of low end platforms like C-More, most SCADA/HMIs can do it, and with ease.  AHMI will approach it with similarities and differences.