1
Support Questions / Re: How to change PLCAddressItems of the ChartBySamplin by code and display series()
« on: June 05, 2019, 04:32:17 AM »I just noticed that this line has an optional parameter which is not really used (it was left there as I was experimenting and just forgot to remove it before posting the code here):
Public Sub SubscribeToComDriver(Optional ByVal indx As Integer = -1, Optional ByVal plcAddress As String = "")
plcAddress is not really required but the code will still work as it is.
If removed then the code will have to look like this:Code: [Select]Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged
If ComboBox1.SelectedItem = "Iген. (А)" Then
ChartBySampling1.PLCAddressItems.Item(9).PLCAddress = ("F428731")
ChartBySampling1.SubscribeToComDriver(9)
BasicLabel44.PLCAddressValue = ("F428731")
End If
If ComboBox1.SelectedItem = "out FCR" Then
ChartBySampling1.PLCAddressItems.Item(9).PLCAddress = ("F429285") 'df307
ChartBySampling1.SubscribeToComDriver(9)
BasicLabel44.PLCAddressValue = ("F429285")
End If
If ComboBox1.SelectedItem = "out AVR" Then
ChartBySampling1.PLCAddressItems.Item(9).PLCAddress = ("F429325") 'df327
ChartBySampling1.SubscribeToComDriver(9)
BasicLabel44.PLCAddressValue = ("F429325")
End If
Label69.Text = ChartBySampling1.PLCAddressItems.Item(9).PLCAddress
End Sub
and this:Code: [Select]Private SubscriptionsCreated As Boolean
Private additionalSubscriptionsCreated As Boolean
Public Sub SubscribeToComDriver(Optional ByVal indx As Integer = -1)
If Not DesignMode And IsHandleCreated Then
If indx <> -1 AndAlso SubscriptionsCreated Then
If additionalSubscriptionsCreated Then
SubScriptions.SubscriptionList.RemoveAt(SubScriptions.SubscriptionList.Count - 1)
SubScriptions.SubscribeTo(m_PLCAddressItems(indx).PLCAddress, m_PLCAddressItems(indx).NumberOfElements, AddressOf PolledDataReturned, m_PLCAddressItems(indx).PLCAddress, 1, 0)
Else
SubScriptions.SubscribeTo(m_PLCAddressItems(indx).PLCAddress, m_PLCAddressItems(indx).NumberOfElements, AddressOf PolledDataReturned, m_PLCAddressItems(indx).PLCAddress, 1, 0)
additionalSubscriptionsCreated = True
End If
Exit Sub
End If
If Not SubscriptionsCreated Then
'* Create a subscription handler object
If SubScriptions Is Nothing Then
SubScriptions = New SubscriptionHandler
SubScriptions.Parent = Me
AddHandler SubScriptions.DisplayError, AddressOf DisplaySubscribeError
End If
SubScriptions.ComComponent = m_ComComponent
Dim index As Integer
While index < m_PLCAddressItems.Count
If Not String.IsNullOrEmpty(m_PLCAddressItems(index).PLCAddress) Then
SubScriptions.SubscribeTo(m_PLCAddressItems(index).PLCAddress, m_PLCAddressItems(index).NumberOfElements, AddressOf PolledDataReturned, m_PLCAddressItems(index).PLCAddress, 1, 0)
End If
index += 1
End While
SubscriptionsCreated = True
End If
SubScriptions.SubscribeAutoProperties()
End If
End Sub
Everything is working.
Wonderful.
Thank you again!