I have a screen with a button for each possible installation. I intend to attach complex code to each button. This screen will be triggered on power up if the machine name has not yet been chosen. Once chosen, the user can access that screen by touching the machine name which appears on all pages (and then security will be checked before the page is accessed).
I have not had success yet. The HMI retains the IP address as set on the communications page after a power cycle. I have tried waiting up to several minutes both before and after setting the IP address.
I am not sure if this is done with DevCtrl, or if I have made a mistake in one of its parameters or syntax.
There are probably other ways to do this, but here is what I did (and I know it could be simplified a little)
I created logic to provide the operator with feedback as to what was happening but I left it our to simplify this post.
1. Create Internal Retentive Tags for IP Address (called G310_IP_ADDRESS), Mask, and Gateway (my mask and gateway could change). These are integer tags. Place these tags in the Network Settings Boxes.
2. Create sets of string tags with called IP_ADDR1, IP_ADDR2, etc. (and for the masks and gateways too). In them, put the values (like "192.168.1.100") in quotes.
3. Create a tag G310_IP ( source is GetNetIP(1) ).
4. Create an integer tag called MachineName and give it Multitext with the machine names configured for the integer values to represent which machine is selected.
If it is machine 1 it will contain 1 and the multitext will say "Machine 1256", if machine 2 it will contain 2 and the multitext will say "Machine 1958" , etc.
5. Behind the button you use to set the IP use logic like this (the only thing that will change is the MachineName and the suffix for G310_IPx):
MachineName := 1;
if (G310_IP == G310_IP1) {
GotoPage(OVERVIEW);
}
else {
IP_Change_Logic();
}
5. The following is IP_CHANGE_Logic()
switch (MachineName){
case 1:
if (G310_IP != G310_IP1) {
G310_IP_ADDRESS := TextToAddr(G310_IP1);
G310_MASK := TextToAddr(G310_MASK1);
G310_GATEWAY := TextToAddr(G310_GATEWAY1);
CommitAndReset();
}
break;
case 2:
if (G310_IP != G310_IP2) {
G310_IP_ADDRESS := TextToAddr(G310_IP2);
G310_MASK := TextToAddr(G310_MASK2);
G310_GATEWAY := TextToAddr(G310_GATEWAY2);
CommitAndReset();
}
break;
default:
break;
}
6. Here is the Startup Program, too...
MachineName := 1;
if (G310_IP_ADDRESS == 0) {
G310_IP_ADDRESS := TextToAddr(G310_IP1);
G310_MASK := TextToAddr(G310_MASK1);
G310_GATEWAY := TextToAddr(G310_GATEWAY1);
CommitAndReset();
}
int Start = GetNow() + 8;
while(GetNow() < Start) Sleep(1000);
if (G315_IP_ADDRESS == TextToAddr(G315_IP1)) {
DevCtrl(MACHINE,1,MACHINE1_IP);
}
else {
DevCtrl(MACHINE,1,MACHINE2_IP);
}
The startup program should be where you set your DevCtrl IP address. You need the delay after starting before running this logic. My logic only had two locations, but you can use switch logic based on the MachineName rather than the If, then, else logic.
I know this may be confusing, but after you have played with it, let me know if you have any questions. (Not responsible for typos)