Difference between revisions of "IComComponent"
(→IComComponent Interface) |
|||
(13 intermediate revisions by 2 users not shown) | |||
Line 5: | Line 5: | ||
<font size="4"><u>'''Properties'''</u></font> | <font size="4"><u>'''Properties'''</u></font> | ||
− | <b>''DisableSubscriptions''</b> - | + | <b>''DisableSubscriptions''</b> - Pauses updating of subscriptions. This is useful in cases such as when hiding a form and there is no longer a need to refresh the values. Or when used with a Trend Chart, it can pause the charting.<br> |
<font size="4"><u>'''Methods'''</u></font> | <font size="4"><u>'''Methods'''</u></font> | ||
− | Function Subscribe(ByVal plcAddress As String, ByVal numberOfElements As Int16, ByVal pollRate As Integer, ByVal callback As EventHandler(Of Common.PlcComEventArgs)) As Integer<br> | + | <b>''Function Subscribe(ByVal plcAddress As String, ByVal numberOfElements As Int16, ByVal pollRate As Integer, ByVal callback As EventHandler(Of Common.PlcComEventArgs)) As Integer''</b><br> |
− | Function Unsubscribe(ByVal id As Integer) As Integer<br> | + | Subscriptions are used by the majority of the AdvancedHMI controls to receive their data from the PLC. Once a subscription is created, the driver will read the value at a r ate defined by the PollRateOverride property and return it to the subscriber. Most drivers optimize their subscription list in as few reads as possible. For values that need continuous updates, subscriptions will be the most efficient method. |
− | Function BeginRead(ByVal startAddress As String, ByVal numberOfElements As Integer) As Integer<br> | + | |
− | Function Read(ByVal startAddress As String, ByVal numberOfElements As Integer) As String()<br> | + | When using this function, it is important to store the SubscriptionID result for unsubscribing when no longer needed. |
− | Function BeginWrite(ByVal startAddress As String, ByVal numberOfElements As Integer, ByVal dataToWrite() As String) As Integer<br> | + | |
− | Function Write(ByVal startAddress As String, ByVal dataToWrite As String) As String<br> | + | |
+ | <b>''Function Unsubscribe(ByVal id As Integer) As Integer''</b><br> | ||
+ | Calling this method and passing the SubscriptionID that was return from the subscribe call will remove the item from the subscription list and the driver will stop updating the value. | ||
+ | |||
+ | <b>''Function BeginRead(ByVal startAddress As String, ByVal numberOfElements As Integer) As Integer''</b><br> | ||
+ | <b>''Function Read(ByVal startAddress As String, ByVal numberOfElements As Integer) As String()''</b><br> | ||
+ | <b>''Function BeginWrite(ByVal startAddress As String, ByVal numberOfElements As Integer, ByVal dataToWrite() As String) As Integer''</b><br> | ||
+ | <b>''Function Write(ByVal startAddress As String, ByVal dataToWrite As String) As String''</b><br> | ||
+ | |||
+ | |||
+ | <br>,<br> | ||
+ | <font size="4"><u>'''Pro and Cons of the Different Read Methods'''</u></font><br> | ||
+ | <b>Read (Synchronous reading)</b><br> | ||
+ | Pro - Minimal code required making it very easy to implement. <br> | ||
+ | Con - It is a blocking operation. If called from the UI thread, the UI will be unresponsive until data is returned from the PLC | ||
+ | |||
+ | |||
+ | <b>BeginRead (Asynchronous reading)</b><br> | ||
+ | Pro - Non-blocking operation that returns immediately after queueing the request, therefore will not freeze the UI thread<br> | ||
+ | Con - Requires more code to implement. Since requests are queued, it is the developer's responsibility to throttle the rate of calling, otherwise a "send que full" exception can occur if requests are sent too fast | ||
+ | |||
+ | <b>Subscription (Continuous refresh at a rate set by PollRateOverride)</b><br> | ||
+ | Pro - Simplifies the code needed to receive values at a regular interval. The driver will optimize communications by grouping multiple subscriptions into a single packet when possible.<br> | ||
+ | Con - Code can be complex to implement. A large number of subscriptions can put excessive load on the communication link. It is the developers responsibilty to maintain subscription IDs in order to unsubscribe when finished. |
Latest revision as of 08:52, 5 January 2019
IComComponent Interface
AdvancedHMI's controls work by requesting or sending data to a driver. In order for a single control to work with any driver, the driver's must implement a common interface. This interface is defined as the IComComponent. All AdvancedHMI drivers implement the methods and properties defined by this interface.
Properties
DisableSubscriptions - Pauses updating of subscriptions. This is useful in cases such as when hiding a form and there is no longer a need to refresh the values. Or when used with a Trend Chart, it can pause the charting.
Methods
Function Subscribe(ByVal plcAddress As String, ByVal numberOfElements As Int16, ByVal pollRate As Integer, ByVal callback As EventHandler(Of Common.PlcComEventArgs)) As Integer
Subscriptions are used by the majority of the AdvancedHMI controls to receive their data from the PLC. Once a subscription is created, the driver will read the value at a r ate defined by the PollRateOverride property and return it to the subscriber. Most drivers optimize their subscription list in as few reads as possible. For values that need continuous updates, subscriptions will be the most efficient method.
When using this function, it is important to store the SubscriptionID result for unsubscribing when no longer needed.
Function Unsubscribe(ByVal id As Integer) As Integer
Calling this method and passing the SubscriptionID that was return from the subscribe call will remove the item from the subscription list and the driver will stop updating the value.
Function BeginRead(ByVal startAddress As String, ByVal numberOfElements As Integer) As Integer
Function Read(ByVal startAddress As String, ByVal numberOfElements As Integer) As String()
Function BeginWrite(ByVal startAddress As String, ByVal numberOfElements As Integer, ByVal dataToWrite() As String) As Integer
Function Write(ByVal startAddress As String, ByVal dataToWrite As String) As String
,
Pro and Cons of the Different Read Methods
Read (Synchronous reading)
Pro - Minimal code required making it very easy to implement.
Con - It is a blocking operation. If called from the UI thread, the UI will be unresponsive until data is returned from the PLC
BeginRead (Asynchronous reading)
Pro - Non-blocking operation that returns immediately after queueing the request, therefore will not freeze the UI thread
Con - Requires more code to implement. Since requests are queued, it is the developer's responsibility to throttle the rate of calling, otherwise a "send que full" exception can occur if requests are sent too fast
Subscription (Continuous refresh at a rate set by PollRateOverride)
Pro - Simplifies the code needed to receive values at a regular interval. The driver will optimize communications by grouping multiple subscriptions into a single packet when possible.
Con - Code can be complex to implement. A large number of subscriptions can put excessive load on the communication link. It is the developers responsibilty to maintain subscription IDs in order to unsubscribe when finished.