Get power on/off to work through Actions.

This commit is contained in:
Tim Young 2018-05-14 14:14:15 -05:00
parent 871f4132fe
commit 1d917fd097
4 changed files with 12 additions and 3 deletions

View File

@ -1475,7 +1475,7 @@ namespace EduNetworkBuilder
ActionClass AC = new ActionClass(); ActionClass AC = new ActionClass();
AC.Action = NBAction.changecomponent; AC.Action = NBAction.changecomponent;
AC.SourceID = HostID; AC.SourceID = HostID;
AC.ChangedComponent = Changed; AC.ChangedComponent = NetworkComponent.Clone(Changed);
RegisterAction(AC); RegisterAction(AC);

View File

@ -1167,6 +1167,8 @@ namespace EduNetworkBuilder
ItemClickedOn.IsBurned = true; ItemClickedOn.IsBurned = true;
ItemClickedOn.PowerOff = true; //It remains off. ItemClickedOn.PowerOff = true; //It remains off.
} }
NB.DoActionChangeComponent(ItemClickedOn);
UpdateLinks(); UpdateLinks();
UpdateVisuals(); UpdateVisuals();
} }
@ -1178,6 +1180,7 @@ namespace EduNetworkBuilder
{ {
ItemClickedOn.PowerOff = true; ItemClickedOn.PowerOff = true;
//Mark the replace test as "done" //Mark the replace test as "done"
NB.DoActionChangeComponent(ItemClickedOn);
myNetwork.RegisterDeviceReset(ItemClickedOn.hostname); myNetwork.RegisterDeviceReset(ItemClickedOn.hostname);
UpdateLinks(); UpdateLinks();
UpdateVisuals(); UpdateVisuals();
@ -1194,6 +1197,7 @@ namespace EduNetworkBuilder
ItemClickedOn.IsBurned = false; //If it had been burned before, it is no longer burned ItemClickedOn.IsBurned = false; //If it had been burned before, it is no longer burned
ItemClickedOn.PowerOff = true; ItemClickedOn.PowerOff = true;
ItemClickedOn.BadSprayCount = 0; ItemClickedOn.BadSprayCount = 0;
NB.DoActionChangeComponent(ItemClickedOn);
//Mark the replace test as "done" //Mark the replace test as "done"
myNetwork.RegisterDeviceReset(ItemClickedOn.hostname); //replacing something powers it off myNetwork.RegisterDeviceReset(ItemClickedOn.hostname); //replacing something powers it off

View File

@ -1511,6 +1511,7 @@ namespace EduNetworkBuilder
{ {
if (CopyFrom.GetType() != this.GetType()) return; //we cannot copy from it if it is different if (CopyFrom.GetType() != this.GetType()) return; //we cannot copy from it if it is different
NetworkDevice ndCopyFrom = (NetworkDevice)CopyFrom; NetworkDevice ndCopyFrom = (NetworkDevice)CopyFrom;
if (Object.ReferenceEquals(this, CopyFrom)) return; //No need to copy values to itself
hostname = ndCopyFrom.hostname; hostname = ndCopyFrom.hostname;
Size = ndCopyFrom.Size; Size = ndCopyFrom.Size;
DefaultGW = ndCopyFrom.DefaultGW; DefaultGW = ndCopyFrom.DefaultGW;
@ -1539,6 +1540,9 @@ namespace EduNetworkBuilder
DHCPRanges.AddRange(ndCopyFrom.DHCPRanges); DHCPRanges.AddRange(ndCopyFrom.DHCPRanges);
DHCPLeases.Clear(); DHCPLeases.Clear();
DHCPLeases.AddRange(ndCopyFrom.DHCPLeases); DHCPLeases.AddRange(ndCopyFrom.DHCPLeases);
PowerOff = ndCopyFrom.PowerOff;
IsBurned = ndCopyFrom.IsBurned;
} }
public void DHCPRequestFromHere() public void DHCPRequestFromHere()

View File

@ -267,8 +267,9 @@ namespace EduNetworkBuilder
deleteme = true; deleteme = true;
} }
} }
if (sNic.isWireless() != dNic.isWireless()) if (sNic != null && dNic != null)
deleteme = true; if (sNic.isWireless() != dNic.isWireless())
deleteme = true;
if(deleteme) if(deleteme)
{ {
sDev.RemoveLinkTo(dDev.hostname); //this removes this link sDev.RemoveLinkTo(dDev.hostname); //this removes this link