Author Topic: Advanced HMI, BeginReadMultiple  (Read 730 times)

tturner

  • Newbie
  • *
  • Posts: 3
    • View Profile
Advanced HMI, BeginReadMultiple
« on: November 14, 2022, 08:37:32 AM »
Having a hard time with the BeginReadMultiple method when using on back end only, not coupled with winforms. I think I'm misunderstanding the use of BeginReadMultiple.

Code: [Select]
using ClxDriver.Common;
using cPLCAppCom;

namespace PLCTest
{
    class PLCinit
    {
        public EthernetIPforCLXCom plcCom = new EthernetIPforCLXCom();

        public void Config()
        {
            System.Diagnostics.Debug.WriteLine("Hello Config");
            plcCom.CIPConnectionSize = 508;
            plcCom.DisableMultiServiceRequest = false;
            plcCom.DisableSubscriptions = false;
            plcCom.IniFileName = "";
            plcCom.IniFileSection = null;
            plcCom.IPAddress = "x.x.x.x";
            plcCom.PollRateOverride = 500;
            plcCom.Port = 44818;
            plcCom.ProcessorSlot = 0;
            plcCom.RoutePath = null;
            plcCom.Timeout = 4000;
            plcCom.UseOmronRead = false;
            plcCom.DataReceived += new System.EventHandler<PlcComEventArgs>(TagDataReceived);
           
            string[] tags = new string[2];
            tags[0] = "test1";
            tags[1] = "test2";
            plcCom.BeginReadMultiple(tags);
        }

        private void TagDataReceived(object? sender, PlcComEventArgs e)
        {
            System.Diagnostics.Debug.WriteLine("Hello Data");
            string read_tags = e.Values[0];
            System.Diagnostics.Debug.WriteLine(read_tags);
        }

    }
}

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5269
    • View Profile
    • AdvancedHMI
Re: Advanced HMI, BeginReadMultiple
« Reply #1 on: November 14, 2022, 03:00:16 PM »
???
Code: [Select]
plcCom.IPAddress = "x.x.x.x";

tturner

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Advanced HMI, BeginReadMultiple
« Reply #2 on: November 14, 2022, 04:44:51 PM »
Good catch, but that was intentional ambiguity. I have tried it with the correct IP address. Should have clarified. 

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5269
    • View Profile
    • AdvancedHMI
Re: Advanced HMI, BeginReadMultiple
« Reply #3 on: November 14, 2022, 05:19:42 PM »
Are you not getting the event to fire with the data?

tturner

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Advanced HMI, BeginReadMultiple
« Reply #4 on: November 15, 2022, 08:11:02 AM »
That is correct, TagDataReceived is never called with the EventHandler method. Is the DataReceived method winForms dependent? I'd like to collect the tag data with the one back-end script.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5269
    • View Profile
    • AdvancedHMI
Re: Advanced HMI, BeginReadMultiple
« Reply #5 on: November 15, 2022, 09:10:53 AM »
Try handling the ComError event. Also you can do a Wireshark capture to see if the PLC returns any errors.