Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - bobobo

Pages: [1] 2
1
Support Questions / Twincat write performance
« on: December 07, 2023, 12:41:30 PM »
Hi
Is there an elegant way to group writes to Twincat?

I have an old advancedhmi application (Not sure how old, but maybe based on a 5 year old version or so) that I'm looking at improving the performance.
I noticed that each Twincatcomm1.write operation takes about 100-150ms. At some occations I do a handful writes to different avariables when a button is clicked.
A few places could be easily replaced by array-writes but when it's a bunch of different types it's not that easy.
Any suggestions? I'm thinking if there is any functionality to add variables in a sending list and then write it all?

Is the new 3.99y version that uses AMSrouter generally faster?

2
Open Discussion / Re: HTTP protocol or web interface
« on: January 13, 2016, 09:38:58 AM »
For the read-only web presentation:
I have an AdvHMI application that has been running for a year now with web-presentation.
On the same computer as AdvHMI I have installed a program called SCWebCam (google it)
That program takes a snapshot of the screen every 2 minute and uploads the image via ftp to an webserver. The webserver present this to anybody who wants to see :)

PS
screensaver must be turned of.

3
Support Questions / Re: Write two-dimensional array with twincat driver
« on: October 30, 2015, 06:54:37 PM »
Thank you!

With the index it's working for me too now.

TwinCATCom1.Write(".controlcurve[0,0]", cc, 200)

4
Support Questions / Write two-dimensional array with twincat driver
« on: October 30, 2015, 02:28:50 PM »
Hi
In past versions (at least v3.02) of Adv.HMI it was working to write to 2-dimensional arrays in Twincat plc by treating them as 1-dimensional in AdvancedHMI.
Like this:
Code: [Select]
Plc declaration:
  controlcurve: ARRAY [0..99,0..1] OF REAL:= 200(0);

vb.net declaration:
  Dim cc(200) As String
 
TwinCATCom1.Write(".controlcurve", cc, 200)


But now in version 3.99a application breaks with error "WriteData2b, not possible to convert the string 99,0..1 to type integer" (error message translated from Swedish so it's not the literally exact message)

 
Code: [Select]
   Public Function Write(ByVal startAddress As String, ByVal dataToWrite() As String, ByVal numberOfElements As UInt16) As Integer
        If Not DLL.ContainsKey(MyDLLInstance) OrElse DLL(MyDLLInstance) Is Nothing Then CreateDLLInstance()
        Try
            Dim Sym As MfgControl.AdvancedHMI.Drivers.TcAdsSymbolInfo
            'Dim SymIndex As Integer
            Try
                Sym = GetSymbolInfo(startAddress)
            Catch ex2 As Exception
                System.Windows.Forms.MessageBox.Show("WriteData2b. " & ex2.Message)
                Throw
            End Try

With v3.99a the following is still working, but I don't like to rewrite the plc program.
Code: [Select]
Plc declaration:
  controlcurve: ARRAY [0..199] OF REAL:= 200(0);

vb.net declaration:
  Dim cc(200) As String
 
TwinCATCom1.Write(".controlcurve", cc, 200)




Can this be solved?

I could do it by looping through the array and write one element at time, but it's not elegant...

Best Regards
Mattias

5
Support Questions / Re: Datasubscriber2 bug? (TwinCAT)
« on: October 16, 2015, 07:56:49 AM »
Now i receive the correct number of datareturned-events in my main application!
112 events per second instead of a couple of thousands...
:)

Thanks for help

6
Support Questions / Re: Datasubscriber2 bug? (TwinCAT)
« on: October 16, 2015, 07:19:18 AM »
I found that above changes makes the subscriptionlist in TwincatCom1 to be correct, but the subscriptionlist in subscriptionhandler is still populated with lots of duplicates.

Code: [Select]
   Public Sub SubscribeTo(ByVal PLCAddress As String, ByVal callBack As EventHandler(Of SubscriptionHandlerEventArgs), ByVal propertyName As String)
        '* Check to see if the subscription has already been created
        Dim index As Integer
        While index < m_SubscriptionList.Count AndAlso (m_SubscriptionList(index).CallBack <> callBack Or m_SubscriptionList(index).PropertyNameToSet <> propertyName)
            index += 1
        End While

        '* Already subscribed and PLCAddress was changed, so unsubscribe
        If (index < m_SubscriptionList.Count) AndAlso m_SubscriptionList(index).PLCAddress <> PLCAddress Then
            m_CommComponent.Unsubscribe(m_SubscriptionList(index).NotificationID)
            m_SubscriptionList.RemoveAt(index)
        End If

        '* Is there an address to subscribe to?
        If (PLCAddress IsNot Nothing) AndAlso (String.Compare(PLCAddress, "") <> 0) Then
            Try
                If m_CommComponent IsNot Nothing Then
                    '* If subscription succeedded, save the subscription details
                    Dim temp As New SubscriptionDetail(PLCAddress, callBack)
                    temp.PropertyNameToSet = propertyName
                    If PLCAddress.ToUpper.IndexOf("NOT ") = 0 Then
                        temp.Invert = True
                    End If
                    m_SubscriptionList.Add(temp)
                    InitializeTryTimer(500)
                Else
                    OnDisplayError("CommComponent Property not set")
                End If
            Catch ex As MfgControl.AdvancedHMI.Drivers.Common.PLCDriverException
                '* If subscribe fails, set up for retry
                InitializeSubscribeTry(ex, PLCAddress)
            End Try
        End If
    End Sub


I don't see where this code stops duplicates except for the comment?

7
Support Questions / Re: Datasubscriber2 bug? (TwinCAT)
« on: October 15, 2015, 06:16:47 PM »
Argh. Copy paste error by me.
I changed first IF to check subscriptionlist.count instead of usedsymbols.count
Several copies of each plcaddress were added to the subscriptionlist before usedsymbols got above 0.

(sent from Phone)

8
Support Questions / Re: Datasubscriber2 bug? (TwinCAT)
« on: October 15, 2015, 05:29:50 PM »
What do you think about my change to the IF statement? Does it make sense with regards to your intended use for each variables?

9
Support Questions / Re: Datasubscriber2 bug? (TwinCAT)
« on: October 15, 2015, 11:55:34 AM »
It was not enough to change this row:
                    If String.Compare(SubscriptionList(k).Symbol.Name, plcAddress, True) = 0 And SubscriptionList(k).dlgCallBack = callback Then

But I tried to change also the first if-statement to this:
Code: [Select]
            If UsedSymbols.Count > 0 Then
                For k = 0 To SubscriptionList.Count - 1
                    If String.Compare(SubscriptionList(k).Symbol.Name, plcAddress, True) = 0 And SubscriptionList(k).dlgCallBack = callback Then
                        SubExists = True
                        Exit For
                    End If
                Next
            End If

Then there is no duplicates made in the subscription list.

I still have too many calls to DataReturned in my main application (test application seems to be ok now). But I ssupect my own written AlarmSubsctiption routine, so I have to dig more into it.


Another issue:
After working a while in the application (Happened in both my main app and my test app) I get following "Object does not match target type" in the Collection editor for plcadress in DataSubscriber2. I have got it working again in a few different ways, but the most effective and so far permanent solution has been to comment this row out:
'<System.ComponentModel.TypeConverter(GetType(PLCAddressItemTypeConverter))> _
from PLCAddressItem.vb

In the test app I have not made any new controls or changes to Adv.HMI code besides what have been discussed above in this forum-thread, but anyway I got the "Object does not match target type"

10
Support Questions / Re: Datasubscriber2 bug?
« on: October 11, 2015, 02:09:24 PM »
After your suggested change it seems to work as long as I only enter addresses to subscribe from in the designer property manager.

I would like to add variables from my code (since number of elements is not working it would be handy to subscribe to arrays by for-loops)
but then it starts making trouble again.

If I add ".var1" and ".var2" in the property manager and then add this code:
Code: [Select]
    Private Sub MainForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        DataSubscriber21.PLCAddressValueItems.Add(New AdvancedHMIDrivers.PLCAddressItem(".var3"))
        DataSubscriber21.PLCAddressValueItems.Add(New AdvancedHMIDrivers.PLCAddressItem(".var4"))
        sw.Start()
    End Sub


I set a breakpoint and Watch TwinCATCom1.SubscriptionList it looks like this:
(0): ".var1"
(1): ".var1"
(2): ".var1"
(3): ".var2"
(4): ".var2"
(5): ".var2"
(6): ".var3"
(7): ".var3"
(8): ".var4"

The list seems to grow exponantially the more variables I add from code.

In above example I also get 45 insted of 8 or 16 datareturned-events per second with pollrateoverride 500.





This code has the same behaviour:
Code: [Select]
    Public Sub New()

        ' This call is required by the designer.
        InitializeComponent()

        Dim PlcAddressItem3 As AdvancedHMIDrivers.PLCAddressItem = New AdvancedHMIDrivers.PLCAddressItem()
        Dim PlcAddressItem4 As AdvancedHMIDrivers.PLCAddressItem = New AdvancedHMIDrivers.PLCAddressItem()
        PlcAddressItem3.LastValue = Nothing
        PlcAddressItem3.NumberOfElements = 1
        PlcAddressItem3.PLCAddress = ".var3"
        PlcAddressItem3.ScaleFactor = 1.0R
        PlcAddressItem3.ScaleOffset = 0.0R
        PlcAddressItem3.SubscriptionID = 0
        PlcAddressItem4.LastValue = Nothing
        PlcAddressItem4.NumberOfElements = 1
        PlcAddressItem4.PLCAddress = ".var4"
        PlcAddressItem4.ScaleFactor = 1.0R
        PlcAddressItem4.ScaleOffset = 0.0R
        PlcAddressItem4.SubscriptionID = 0
        DataSubscriber21.PLCAddressValueItems.Add(PlcAddressItem3)
        DataSubscriber21.PLCAddressValueItems.Add(PlcAddressItem4)

        ' Add any initialization after the InitializeComponent() call.

    End Sub

    Private Sub MainForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        sw.Start()
    End Sub



11
Support Questions / Re: Datasubscriber2 bug?
« on: October 10, 2015, 12:29:47 PM »
When I removed the first basiclabel from the form, so that I only have the Datasubscriber21, Label1, Label2 and TwinCatCom1 the number dropped from 23 to 17-17.3 with 3 valid addresses.

So it seems that also addresses not in the Datasubscriber trigger the DataSubscriber.Datareturned ...?

12
Support Questions / Re: Datasubscriber2 bug?
« on: October 10, 2015, 12:12:28 PM »
Sorry, I wrote it in the first post, but then edited the text and accidently removed that info...
Twincat driver.

13
Support Questions / Re: Datasubscriber2 bug?
« on: October 10, 2015, 12:01:37 PM »
As most of the time, really impressive quick answers!

Results with the code from your first test:
With 3 valid tags: 23.0

With 2 valid and one invalid: 334

...

14
Support Questions / Datasubscriber2 bug? (TwinCAT)
« on: October 10, 2015, 11:10:15 AM »
Hi
My application gets unresponsive and for error tracking I made an experiment and got a result that I think indicates a bug in the component or driver...

I started a new Adv.HMI 3.99a project. I added only a basiclabel to see that plc communication is working.
Then I added a Datasubscriber2, a standard Timer (interval 1000) and a textbox.

Code: [Select]
    Dim rate As Integer

    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
        TextBox1.Text = rate
        rate = 0
    End Sub

    Private Sub DataSubscriber21_DataReturned(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles DataSubscriber21.DataReturned
        rate = rate + 1
    End Sub

The displayed rate indicates (approx) how many calls DataReturned gets per second:
1 valid PLCaddress in DataSubscriber: 4 events/s
2 valid PLCaddresses : 12 events/s
3 valid PLCaddresses : 24 events/s
2 valid PLCaddresses and 1 invalid PLCaddress : increasing slowly over 40sec to rate of 300-330events/s
13 valid PLCaddresses: 360 events/s
13 valid PLCaddresses and 1 invalid : increasing to about 2000 events/s

All above numbers with PollRateOverride (driver) at 500, and PollRate in DataSubscriber at 0.

(With one PLCaddress in DataSubscriber and a PollrateOverride at 100 I get 20 events/s (correctly 5 times above test)
With PollrateOverride 1000 I get 2 events/s.
Equal result if I change PollrateOverride to 0 and set 100/500 and 1000 at DataSubscriber PollRate.)


What do you think?

15
Support Questions / Re: Datasubscriber2 and NumberOfElements
« on: October 08, 2015, 05:59:40 AM »
I made an attemt to add the function in a ugly work-around way...
In Datasubscriber2:
Code: [Select]
                    '* We must pass the address as a property name so the subscriptionHandler doesn't confuse the next address as a change for the same property
                    If m_PLCAddressValueItems(index).NumberOfElements <= 1 Then
                        SubScriptions.SubscribeTo(m_PLCAddressValueItems(index).PLCAddress, AddressOf PolledDataReturned, m_PLCAddressValueItems(index).PLCAddress)
                    Else
                        For element = 1 To m_PLCAddressValueItems(index).NumberOfElements
                            SubScriptions.SubscribeTo(m_PLCAddressValueItems(index).PLCAddress & "[" & element & "]", AddressOf PolledDataReturned, m_PLCAddressValueItems(index).PLCAddress & "[" & element & "]")
                        Next
                    End If

But it doesn't work.

However, if I manually add all elements of the variable (Alarm.Temperr[1], Alarm.TempErr[2], etc] in the datasubscriber, I can use this in the datachanged event:
Code: [Select]
        Select Case e.PlcAddress.Split("[")(0)
            Case "ALARM.TEMPERR"
                AlarmNum = e.PlcAddress.Split("[")(1).Trim(New Char() {"[", "]"}) - 1)
                State = e.Values(0)
                     ...
        End Select

Would have been nice if the NumberOfElements were implemented....

Do you have suggestions of better ways to imlement this outside the closed dll? in subscription handler?
The subscription handler looked too advanced for me, that's why i tried to put it in DataSubscriber2

Pages: [1] 2