PDA

View Full Version : How to: get the state of a network adapter



martins
4th April 2013, 14:58
hi,

as this question appears from time to time, I created a small sample how to get the network information from the available network interfaces into zenon.

I used the NetworkChange class from the .NET Framework (in namespace System.Net.NetworkInformation) and took the NetworkAddressChanged event to get notified about changes in the IP address. Alternativly, the NetworkAvailabilityChanged event could also be used - but there, I get no events if the IP changed (as the name already suggests ;) )

The sample does the following:

Everytime the IP address of an adapter changes (can be because of a different allocation of an IP address or because we lost the connection or because the adapter was disabled), we get the information from all interfaces in the network. In this demo, I then write this information onto a zenon variable of type string and display that string in the runtime. In reality, you could e.g. execute a zenon function (by calling this.RtFunctions().Item("myFunction").Start()) or writing some values onto a zenon variable on which you can react with a limit violation or a reaction matrix.

Note that I tried my best to eliminate any possible errors, but: I cannot guarantee that the source code is without any mistakes.

It is a zenon 7.0 project optimized for 1280x1024. Feel free to try it out, improve it, add a comment or something else ;)

best regards,
Martin

stolyarov_as
29th May 2013, 12:59
Hello, Martin!

I have some offtopic question for your project.
I changed main screen type to CEL and insert CEL table into it. By default such table has some columns set (without Value column). Typically columns are configured in screen switch function call for CEL type screen, but in case of CEL screen as startup screen there is no such ability.

Question is what it get this set from and how to change this set in case of using CEL screen as startup screen?

bernhardf
29th May 2013, 13:33
Hi,

why don't remove the "Start screen" in the project settings, and put a screen switch function to the CEL with the designated paramaters into the AUTOSTART script?

Regards,
Bernhard