Advanced HMI, BeginReadMultiple, C# Script

Taylor Turner

Member
Join Date
Sep 2020
Location
Midwest
Posts
78
Having a hard time getting the data received when using BeginReadMultiple. Not the most familiar with the ClxDriver and EthernetIPforCLXCom() usage.
Code:
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);
        }

    }
}
 
I don't know C# very well, but is that "?" supposed to be there

private void TagDataReceived(object? sender, PlcComEventArgs e)


Also, if you put a breakpoint in on the plcCom.BeginReadMultiple(tags); line, do all of the properties of plcCom look correct?
 
Thanks for the replies. I'm realizing the method TagDataRecieved()isn't even being called. I'm not quite understanding how ".DataReceived" and that method works together. I found Advanced HMI's forum. We'll see if I get a response. Archie runs the show over there. He's on here too, but it looks like he hasn't been online in a year.
 
I deleted that previous post. I looked into it further and am not sure at all how AdvancedHMI fits into an event handler framework, so perhaps it's better if I do not add confusion to the mix.
 
Thanks for the replies. I'm realizing the method TagDataRecieved()isn't even being called. I'm not quite understanding how ".DataReceived" and that method works together. I found Advanced HMI's forum. We'll see if I get a response. Archie runs the show over there. He's on here too, but it looks like he hasn't been online in a year.

TagDataReceived() is an event handler. The event is being subscribed to in the above statement that contains the += operator. That event gets fired in another area of the code. If you put a breakpoint inside TagDataReceived() and it never hits it, then either the event isn't being fired or it isn't being subscribed to. Place a breakpoint at the line that contains the += operator to make sure it is being subscribed to. Also you can delete and re-enter the line.

Type in plcCom, then hit the dot char, Then let visual studio find DataReceived in the drop down intelesense. Then type += then hit the tab key twice. It will stub out the event handler for you ensuring the arguments are correct.

I'm not a user of advanced HMI but I have many years of C# experience including PLC drivers and middleware/database.

Hope that helps.
 

Similar Topics

I’m new to plc programming and very new to HMIs. So this is what I have done so far: I bought a micrologix 1100, I used bootP to set the up...
Replies
17
Views
1,681
So I installed advanced hmi and grabbed an ethernet cable. I have the click C0-12DRE-1-D PLC. I installed the advanced hmi and added the...
Replies
13
Views
2,064
Do I use the ethernet port on the click plc to connect it to my computer. Will advancedhmi work properly? Am I able to start data logging into a...
Replies
1
Views
941
I am in search of a non-PC based, non-SCADA based HMI and software that allows the ability to dynamically draw graphical objects on the screen to...
Replies
15
Views
5,047
Hi, I have developed a small PLC program of few motors, PB, and a tank. The communication between HMI and PLC is Modbus TCP. While I was trying...
Replies
9
Views
2,336
Back
Top Bottom