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 - thug_

Pages: [1] 2
1
Support Questions / Re: High CPU usage ?
« on: March 10, 2017, 08:30:32 PM »
Ok Archie thanks for advice I will try wireshark as well sometimes during next week and I will post results.

Thanks so much for your support.

2
Support Questions / Re: High CPU usage ?
« on: March 10, 2017, 09:20:26 AM »
Thanks Archie it is working, my CPU usage is now around 7-12%, is that too high by your opinion ?

3
Support Questions / Re: High CPU usage ?
« on: March 04, 2017, 11:58:07 AM »
Thanks Archie, I suppose I will just replace MfgControl.AdvancedHMI.Drivers.dll in my project with this from the patch ?

Unfortunately I won't be able to test it before Wednesday next week, so I will get back with results next week.

Cheers.

4
Support Questions / Re: High CPU usage ?
« on: March 03, 2017, 10:53:38 PM »
Yes Archie it is only 1 element in e.Values, when DataRecived event fires.

5
Support Questions / Re: High CPU usage ?
« on: March 03, 2017, 08:41:37 PM »
I tried N7:0 as well but I just get a value for N7:0 others I am not getting. I didn't understand the part with bool bit to trigger subscribe, can you just give an example with code it will be easier for me to understand.

Thanks.

6
Support Questions / Re: High CPU usage ?
« on: March 03, 2017, 04:33:51 AM »
As I said I tried with subscription but I couldn't make to work

   //subscriptionTime = m_plc.Subscribe("N7:", 17, 100, plc_GigeOneDataRecieved);

This the line of code how I was trying to do, later in plc_GigeOneDataRecieved I was just assigning values to my variables. But I could get this work only when I read 1 element, so instead of 17 if I give 1 as numOfElements, it was working but 17 no. I am using 3.9.9.17 version of AdvancedHMI, later today I will try to get newset version and try again with subscribtions.

7
Support Questions / Re: High CPU usage ?
« on: March 02, 2017, 10:16:36 AM »
No I am just calling once when btnRead is pressed, that is the part of code when is happening :

  private void btnReadPlc_Click(object sender, RoutedEventArgs e)
        {
            _wp = new WriteReadPlc();
            //_draw.DrawDynamicGraph();
            _wp.ResultsAvailable+=wp_ResultsAvailable;
            try
            {
                Task.Factory.StartNew(() => {
                    _wp.Read();                 
                });
            }
            catch (Exception ex)
            {
                MessageBox.Show(String.Format("Error reading from PLC"));     
            }
}

I tried to use subscriptions but I don't how to read 17 registries, with subscription, do I need to create for every registry one subscription, or there is some way to read all of them with one subscription ?


8
Support Questions / Re: High CPU usage ?
« on: March 02, 2017, 09:26:06 AM »
It decreased but it is still around 7- 10..

9
Support Questions / Re: High CPU usage ?
« on: March 02, 2017, 08:57:54 AM »
          public SerialDF1forSLCMicroCom m_plc = new SerialDF1forSLCMicroCom();
          public event EventHandler<CameraResultsEventArgs> ResultsAvailable;
          System.Windows.Threading.DispatcherTimer plcPoll = new System.Windows.Threading.DispatcherTimer();
           public void Read()
           {
           
            m_plc.Write("N7:0", "100");
            m_plc.Write("N7:14", "100");
            m_plc.Write("N7:15", "100");
            m_plc.Write("N7:16", "100");
            plcPoll.Interval = TimeSpan.FromMilliseconds(100);
            plcPoll.IsEnabled = true;
            plcPoll.Tick += plcPoll_Tick;
            m_plc.DataReceived += m_plc_DataRecieved;
            plcPoll.Start();
        }

        void plcPoll_Tick(object sender, EventArgs e)
        {
            m_plc.BeginRead("N7:0", 17);
            //m_plc.BeginRead("C5:0.ACC", 7);
         
        }

        void m_plc_DataRecieved(object sender, MfgControl.AdvancedHMI.Drivers.Common.PlcComEventArgs e)
        {
            CamCollection values = new CamCollection();

            try
            {
                if (e.PlcAddress == "N7:0" && e.Values.Count == 17)
                {
                    values.Camera1.Trigger = e.Values[0];
                    values.Camera1.CurInspectionTime = e.Values[4];
                    values.Camera1.MaxInspectionTime = e.Values[3];

                    values.Camera2.Trigger = e.Values[14];
                    values.Camera2.MaxInspectionTime = e.Values[6];
                    values.Camera2.CurInspectionTime = e.Values[7];

                    values.Camera4.Trigger = e.Values[16];
                    values.Camera4.CurInspectionTime = e.Values[13];
                    values.Camera4.MaxInspectionTime = e.Values[12];

                    values.Camera3.Trigger = e.Values[15];
                    values.Camera3.CurInspectionTime = e.Values[10];
                    values.Camera3.MaxInspectionTime = e.Values[9];

                    if (ResultsAvailable != null)
                        ResultsAvailable(this, new CameraResultsEventArgs { Camera1 = values.Camera1, Camera2 = values.Camera2, Camera3 = values.Camera3, Camera4 = values.Camera4 });

                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(String.Format("Error reading nValues: {0}", ex.ToString()));
                plcPoll.Stop();
            }


That's the part of code where is reading done.

10
Support Questions / Re: High CPU usage ?
« on: March 02, 2017, 05:31:38 AM »
In that event handler I am assigning all values, which will later on be passed to UI, so basically nothing is happening if I comment out that part of code, I did and I run app, as it is expected CPU = 0, but I am not reading anything from PLC in that case.

11
Support Questions / High CPU usage ?
« on: March 02, 2017, 05:06:43 AM »
Hi All,

I am running application which is reading 17 registries from PLC every 100ms. PLC type is Allen Bradley MicroLogix 1200, and I am using Serial to USB connection with PLC. I am using SerialDF1forSLCMicroCom driver form AdvancedHMI, and BeginRead method for reading those registries.

When I run application my CPU usage is around 15- 20% which is little bit high for what I need. I ran performance profiler from red gate on it and it is showing that AdvancedHMIDrivers.S erialDF1forSLCMicroCom.OnDataReceived (PlcComEventArgs e) is "hot" and taking 34,5% time with children. It is everything running in WPF app.

Any suggestion how I could decrease usage of CPU?

Thanks



12
Code: [Select]
       private int SubscriptionID1;
        private void Button2_Click_1(object sender, EventArgs e)
        {
            SubscriptionID1 = ethernetIPforCLXCom1.Subscribe("MyTag", 1, 500, Subscription_DataReceived);
        }

        private void Subscription_DataReceived(object sender,MfgControl .AdvancedHMI . Drivers.Common.PlcComEventArgs e)
        {
            Label1.Text = e.Values[0];
        }

        private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            ethernetIPforCLXCom1.UnSubscribe(SubscriptionID1);
        }
Thanks Archie, it is working, I will need to updated a lot of code now, but at least there is a way to control polling time.

Just quick question about this number of elements, I am right now setting it to 1, that means I suppose it will read one element from plc and that is in this case N7:4 or whatever tag I provide. In the case this number of elements is higher let's say 10, is that mean that it will read elements from N7:0 until and including N7:9 ?

Cheers

13
I'm not sure how well this will work with WPF, but here is an example of how to use Subscribe via code:

Code: [Select]
    Private SubscriptionID1 As Integer
    Private Sub Button2_Click_1(sender As Object, e As EventArgs) Handles Button2.Click
        SubscriptionID1 = EthernetIPforCLXCom1.Subscribe("MyTag", 1, 500, AddressOf Subscription_DataReceived)
    End Sub

    Private Sub Subscription_DataReceived(sender As Object, e As Drivers.Common.PlcComEventArgs)
        Label1.Text = e.Values(0)
    End Sub

    Private Sub MainForm_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
        EthernetIPforCLXCom1.UnSubscribe(SubscriptionID1)
    End Sub
I would like to test it with C# code the code which I am trying to implement is

public int subscriptionID1;
public SerialDF1forSLCMicroCom plc = new SerialDF1forSLCMicroCom();

private void btnStartTriggers_Click(object sender, RoutedEventArgs e)
{
subscriptionID1 = plc.Subscribe ("N7:4", 1, 500, ???);
plc.SubscritionDataRecived += plc_SubscritpionDataRecieved;
}

 void plc_SubscriptionDataReceived(object sender, MfgControl.AdvancedHMI.Drivers.Common.SubscriptionEventArgs e)
        {
            lblDataSubcribe.Content = e.Values(0);
        }

What I should put as a AddressOf Subscription_DataReceived ?

Thanks Archie

14
Application should optimize trigger from 4 cameras. So I am giving parameters like trigger time, time interval, limits. Behind is running plc application which is recording date such as maximum inspection time, how many times inspection time went over given trigger time - and if it is over given limits in specific time interval, it is increasing/ decreasing trigger rate by the given value. So I would like to be able to set update time from plc.

It is WPF application which is using AdvancedHMI driver, SerialDF1forSLCMicroCom.

15
Yes, right now works like that, can you write simple example or point to me where I can find more info about using subscription instead of this timer.


Thanks

Pages: [1] 2