Author Topic: EthernetIPforCLX example in C#  (Read 4459 times)

JRYork

  • Newbie
  • *
  • Posts: 5
    • View Profile
EthernetIPforCLX example in C#
« on: December 16, 2016, 06:51:02 PM »
Hello, I am having problems getting my program to build and run correctly.  Is there a sample app in C# that uses EthernetIPforCLX available anywhere?  Also - is there documentation available for the class?  I ask because I haven't been able to find any.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: EthernetIPforCLX example in C#
« Reply #1 on: December 16, 2016, 06:56:39 PM »
The latest version of 3.99s has a C# project in it that is ready to use. Here is how to make it work:

- Open the MainForm in the AdvancedHMIcs project
- Add an EthernetIPforCLXCom driver from the Toolbox onto the form
- Set the IPAddress property
- Add a BasicLabel form the Toolbox
- Set PLCAddressValue to a valid tag in the PLC
- Run the application

The central location for documentation is a wiki that is still very much in the works:

http://advancedhmi.com/documentation/index.php?title=Main_Page

JRYork

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: EthernetIPforCLX example in C#
« Reply #2 on: December 19, 2016, 10:51:40 AM »
Thank you for your reply Archie.  I'll see what I can do with that.

JRYork

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: EthernetIPforCLX example in C#
« Reply #3 on: December 19, 2016, 12:29:24 PM »
I have now have the app building and running but it doesn't seem to work correctly.  I see continuous exceptions and see no data.

The way this started is I got a little app from a co-worker.  He said it would build and it runs.  I can't get it to build.  I download the v3.99s package from SourceForge and with a couple of tweaks it will build but, as I wrote, it doesn't run right.

The main change I made was going from EthernetIPforCLXCom to EthernetIPforCLX.  After that change, the program throws an exception in a call to (( System.ComponentModel.ISupportInitialize )( this.ABcomm )).BeginInit();

My questions are - what is the version that uses EthernetIPforCLXCom?  Is that available anywhere?  What can I do to make BeginInit work or is it even necessary?


Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: EthernetIPforCLX example in C#
« Reply #4 on: December 19, 2016, 12:44:52 PM »
The main change I made was going from EthernetIPforCLXCom to EthernetIPforCLX.  After that change, the program throws an exception in a call to (( System.ComponentModel.ISupportInitialize )( this.ABcomm )).BeginInit();
Exactly where did you make that change?

JRYork

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: EthernetIPforCLX example in C#
« Reply #5 on: December 19, 2016, 01:17:14 PM »
It was changed at the bottom of MainForm.Designer.cs where the member was declared for the MainForm class.  Then in the call to the constructor in InitializeComponent() and, lastly, there is a class with a PLC communication thread that has a ref to the object as a member.

I also had to comment this line out :

   (( System.ComponentModel.ISupportInitialize )( this.m_ControlLogix )).BeginInit();

and a corresponding EndInit() call because of exceptions.

Now, when the program runs it gets continual exceptions and no communication happens.

I am very inexperienced in C#.  I have a LOT of experience with C++ though.




JRYork

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: EthernetIPforCLX example in C#
« Reply #6 on: December 19, 2016, 01:20:23 PM »
Do you have a sample WinForm  app in C# that uses EthernetIPforCLX ?  I looked at the sample C# and it does not appear to have any communication in it.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: EthernetIPforCLX example in C#
« Reply #7 on: December 19, 2016, 01:32:58 PM »
You would want to use EthernetIPforCLXCom because it has the extensions for a UI application such as UI thread synchronization. It also adds the features to allow initialization through an INI file.

The designer files should never be changed because they are auto generated by Visual Studio.

If you want to read data via code, then it would simply be:

Dim MyValue as string
MyValue=EthernetIPforCLXCom1.Read("MyTag")

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: EthernetIPforCLX example in C#
« Reply #8 on: December 19, 2016, 01:55:19 PM »
Since you are coming from a C++ background, you may be over thinking this. Visual Studio and AdvancedHMI are designed to do the code writing for you. By doing a drag and drop from the Toolbox and setting properties, you can create your basic HMIs without writing a single line of code. Code writing is only necessary for more advanced things such as database interaction or modifying existing controls to add the features you need.