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.


Topics - PJonHar

Pages: [1]
1
Support Questions / Subscribe - EIPTransport.SendData Error, No Callback
« on: February 18, 2020, 11:36:42 AM »
Hi,

Version:3.99y Beta 34

I have the following program that subscribes to tags via code (ignore the IPAddress).

Code: [Select]
        private EthernetIPforCLXCom PLCComms = null;
        private List<int> SubscriptionIDs = new List<int>();
        public K_AutoExternal AEX { get; set; } = new K_AutoExternal();
        private string AEXParentTag = "Robot1";
       
        public MainWindow()
        {
            InitializeComponent();

            DataContext = this;

            PLCComms = new EthernetIPforCLXCom();

            PLCComms.BeginInit();
            PLCComms.IniFileName = "CLX.ini";
            PLCComms.IniFileSection = "PLCComms";
            PLCComms.EndInit();

            PLCComms.ComError += this.PLCComms_ComError;

            SubscribeAEXTags();

            PLCComms.ReadClock();
        }

        private void UnsubscribeAEXTags()
        {
            foreach (int i in SubscriptionIDs)
                PLCComms.Unsubscribe(i);
            SubscriptionIDs.Clear();
        }

        private void SubscribeAEXTags()
        {
            try
            {
                UnsubscribeAEXTags();

                PropertyInfo[] properties = typeof(K_AutoExternal).GetProperties();
                foreach (PropertyInfo property in properties)
                    SubscriptionIDs.Add(PLCComms.Subscribe(String.Format("{0}.{1}", AEXParentTag, property.Name), 1, 5000, SubscriptionCallback));
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, ex.TargetSite.Name);
            }
        }

        private void SubscriptionCallback(object sender, PlcComEventArgs e)
        {
            if (e.ErrorId == 0 && e.Values != null && e.Values.Count > 0)
                ParseData(e.PlcAddress, e.Values[0]);
        }
       
        private void ParseData(string tag, string value)
        {
            try
            {
                PropertyInfo[] properties = typeof(K_AutoExternal).GetProperties();
                foreach (PropertyInfo property in properties)
                {
                    if (String.Format("{0}.{1}", AEXParentTag, property.Name) == tag)
                    {
                        TypeConverter typeConverter = TypeDescriptor.GetConverter(AEX.GetType().GetProperty(property.Name).PropertyType);
                        object propValue = typeConverter.ConvertFromString(value);

                        AEX.GetType().GetProperty(property.Name).SetValue(AEX, propValue, null);
                        AEX.UpdateProperties();
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, ex.TargetSite.Name);
            }
        }

        private void PLCComms_ComError(object sender, PlcComEventArgs e)
        {
            Console.WriteLine(e.ErrorId + " - " + e.ErrorMessage);
        }

The tags get updated, but only on the initial execution of the program.

The following error messages appear at each poll:
Code: [Select]
0 - EIPTransport.SendData-No Response
-22 - No Response from PLC(22)

The pollrate is quite high (5000ms), so i think this is okay.

Any ideas what it could be?

2
Support Questions / Subscribe Method
« on: May 23, 2017, 08:04:50 AM »
Hi,

I am using the Subscribe on certain tags that a user can define via XML, which is then read in and the subscriptions made.
Code: [Select]
Private Sub QCompositeButtonPLCMessages_ItemActivated(sender As System.Object, e As Qios.DevSuite.Components.QCompositeEventArgs) Handles QCompositeButtonPLCMessages.ItemActivated
        Try
            Dim frmPLCMessages As New frmPLCMessages()
            If frmPLCMessages.ShowDialog(Me) = DialogResult.OK Then
                ApplicationPLCMessages = New PLCMessages().Load
                SubscribePLCMessages()
            End If
            frmPLCMessages = Nothing
        Catch ex As Exception
            Log.ErrorMessage(ex.TargetSite.Name, ex.Message, "1410")
        End Try
    End Sub

    Private Sub UnsubscribePLCMessages()
        For Each i As Integer In SubscriptionIDs
            PLC.UnSubscribe(i)
        Next
        SubscriptionIDs.Clear()
    End Sub

    Private Sub SubscribePLCMessages()
        UnsubscribePLCMessages()

        For Each pm As PLCMessage In ApplicationPLCMessages
            If pm.Message.Length > 0 Then
                SubscriptionIDs.Add(PLC.Subscribe(pm.Tag, 1, AddressOf SubscriptionCallback))
            End If
        Next

    End Sub

Upon initial loading of the main form the method SubscribePLCMessages is ran and the subscription works.
If i open the form frmPLCMessages and then click OK to the form the SubscribePLCMessages is re-ran to ensure any changes made to the XML file take place. However, upon this second call to SubscribePLCMessages my program hangs on the line 'PLC.Subscribe(pm.Tag, 1, AddressOf SubscriptionCallback)'.

Any Ideas?

Thanks.

3
Support Questions / Cannot Separate components
« on: March 15, 2017, 12:39:20 PM »
Hi,

I have being using the AdvancedHMI CLX Driver for testing in a Visual Studio app.
My normal procedure is download the latest AdvancedHMI project, Extract to a folder, Build the solution.

I then start a new Visual Studio project and reference the Driver dll's. THis has being working until just now? I referenced the new drivers i downloaded and i get the message:

Cannot Separate components from AdvancedHMI Solution. C:\Users\user\Projects\weld\LinearWelder\Linear Welder\bin\Debug\ - Please refer to the licensing agreement.

Any Ideas?

Thanks.

4
Support Questions / EthernetIPforCLXCom Reading 5000+ array of REAL
« on: April 18, 2016, 07:17:17 AM »
Hi All,

I am using a PLC to log data (5000+ points of REAL values).

Currently I am reading in the data like below, a For Loop for each index in the array. This stops my application from being used as the GUI can't be updated.

Code: [Select]
            Dim NewWeldData As New WeldData

            For i = 0 To 2
                Dim NewChannelData As New ChannelData
                NewChannelData.Name = PLCConnection.Read("WeldData.ChannelData[" & i & "].Name")
                NewChannelData.Unit = PLCConnection.Read("WeldData.ChannelData[" & i & "].Unit")
                For j = 0 To NewWeld.Samples
                    StatusUpdate("Retrieving Weld Information [" & i & "],[" & j & "]")
                    Dim value As Double = 0.0
                    Try
                        value = Convert.ToDouble(PLCConnection.Read("WeldData.ChannelData[" & i & "].Data[" & j & "]"))
                    Catch ex As Exception
                        StatusUpdate("Retrieving Weld Information Error, Trying Again...")
                        value = Convert.ToDouble(PLCConnection.Read("WeldData.ChannelData[" & i & "].Data[" & j & "]"))
                    End Try
                    NewChannelData.Data.Add(value)
                    'Sleep(20)
                Next
                NewWeldData.Data.Add(NewChannelData)
            Next

Is there a better way to read in an array of 5000+ REAL values?
Should I perform the same code in a separate thread that I could start in the background?

Thanks,

Paul

5
Support Questions / DataSubscriber - Heavy CPU Load??
« on: April 15, 2016, 08:11:45 PM »
Hi,

First of all thanks for the great library!

I have started a project and I am using the DataSubscriber in order to get notified of when a Tag changes value:
Code: [Select]
  Private ds As New AdvancedHMIControls.DataSubscriber

With ds
                .CommComponent = PLCConnection

                AddHandler .DataChanged, AddressOf DataChangedCallback
                .PLCAddressValue = "Value1"
                .PLCAddressValue = "Value2"
                .PLCAddressValue = "Value3"
                .PLCAddressValue = "Value4"

End With

However, When i run the project, all of my cpu cores pretty much max out and if i profile the application running there seems to be a thread for each of the subscriptions on the data subscriber, but they don't seem to be taking a great percentage of processing (see picture 1). The profile application also notices that 30+ other threads (see picture 2) have been created and running?

I am doing this the wrong way or is something not right?

Thanks,

Paul

Pages: [1]