AdvancedHMI Software
General Category => Open Discussion => Topic started by: FuzyDragon on December 07, 2015, 11:02:49 AM
-
I am trying to write code for a real time data chart for a large array of Thermocouples (120 to be exact). I want to show the temperatures that they are reading separately but the catch is that I don't want to show data for PLC Addresses that may not have a thermocouple input. For example, if there are only 25 thermocouples plugged in, I only want to show the first 25 as they will show real data, the rest will be some weird other number.
Is there a way to run an If loop or some form of logic to have something look at the value of all 120 PLC address and if it's in a certain range add it into the collection? I've tried using the ChartBySample1.PLCAddressItems.Add command but I don't think I'm entering the right arguments for it.
Thanks in advance for any help or advice you can give.
-
I'm not sure how to do the looping, but kind of figured out the add by just creating a chart and adding to the collection.
Below is code form the form.designer.vb
'Declare the addressItem
Dim PlcAddressItem1 As AdvancedHMIDrivers.PLCAddressItem = New AdvancedHMIDrivers.PLCAddressItem()
'Fill in the properties
PlcAddressItem1.LastValue = Nothing
PlcAddressItem1.NumberOfElements = 1
PlcAddressItem1.PLCAddress = "L0410"
PlcAddressItem1.ScaleFactor = 1.0R
PlcAddressItem1.ScaleOffset = 0.0R
PlcAddressItem1.SubscriptionID = 0
'Add it to the collection
Me.ChartBySampling1.PLCAddressItems.Add(PlcAddressItem1)
I was able to get to the form.designer.vb by searching for PLCAddressItems, can't figure out how to get there otherwise.
-
Thanks rbelknap for the quick response.
WIth what you've shown me, I definitely have some good starting points. I just have one question: Do you know if you can remove a PLC address from the collection based on the value inside of the PLC address? I see there is a .Remove function for removing an item from a collection, I just want to use it to remove Addresses that are not connected to thermocouples and are giving off gibberish
Thanks again for your help
-
A quick look shows that there are several ways to remove form the collection.
I haven't run anything to verify, but it looks like you can remove by specifying the PLCAddressItem name, ie PlcAddressItem1 or by specifying an index in the collection.
Me.ChartBySampling1.PLCAddressItems.Remove(PlcAddressItem1)
'or
Me.ChartBySampling1.PLCAddressItems.RemoveAt(index As integer)
That code could get interesting if you're looping through the items list as it'll be getting smaller when you remove items.
You may be better off only adding good values instead of trying to remove bad ones, if that makes sense.
Good luck.
-
That makes sense to me. I was thinking of adding a data subscriber and looking at the values of the PLC addresses that way. From what you've given me and my own experimentation, I should be able to find a way to add Addresses based on their values. Thanks for your help and I'll check in if I get stuck again.