From 1d917fd0972eb680afa25664244511c4940aebdb Mon Sep 17 00:00:00 2001 From: Tim Young Date: Mon, 14 May 2018 14:14:15 -0500 Subject: [PATCH] Get power on/off to work through Actions. --- EduNetworkBuilder/NB.cs | 2 +- EduNetworkBuilder/NetworkBuilder.cs | 4 ++++ EduNetworkBuilder/NetworkDevice.cs | 4 ++++ EduNetworkBuilder/NetworkLink.cs | 5 +++-- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/EduNetworkBuilder/NB.cs b/EduNetworkBuilder/NB.cs index 3cf2aa6..a283fa1 100644 --- a/EduNetworkBuilder/NB.cs +++ b/EduNetworkBuilder/NB.cs @@ -1475,7 +1475,7 @@ namespace EduNetworkBuilder ActionClass AC = new ActionClass(); AC.Action = NBAction.changecomponent; AC.SourceID = HostID; - AC.ChangedComponent = Changed; + AC.ChangedComponent = NetworkComponent.Clone(Changed); RegisterAction(AC); diff --git a/EduNetworkBuilder/NetworkBuilder.cs b/EduNetworkBuilder/NetworkBuilder.cs index c634129..98bacbc 100644 --- a/EduNetworkBuilder/NetworkBuilder.cs +++ b/EduNetworkBuilder/NetworkBuilder.cs @@ -1167,6 +1167,8 @@ namespace EduNetworkBuilder ItemClickedOn.IsBurned = true; ItemClickedOn.PowerOff = true; //It remains off. } + NB.DoActionChangeComponent(ItemClickedOn); + UpdateLinks(); UpdateVisuals(); } @@ -1178,6 +1180,7 @@ namespace EduNetworkBuilder { ItemClickedOn.PowerOff = true; //Mark the replace test as "done" + NB.DoActionChangeComponent(ItemClickedOn); myNetwork.RegisterDeviceReset(ItemClickedOn.hostname); UpdateLinks(); UpdateVisuals(); @@ -1194,6 +1197,7 @@ namespace EduNetworkBuilder ItemClickedOn.IsBurned = false; //If it had been burned before, it is no longer burned ItemClickedOn.PowerOff = true; ItemClickedOn.BadSprayCount = 0; + NB.DoActionChangeComponent(ItemClickedOn); //Mark the replace test as "done" myNetwork.RegisterDeviceReset(ItemClickedOn.hostname); //replacing something powers it off diff --git a/EduNetworkBuilder/NetworkDevice.cs b/EduNetworkBuilder/NetworkDevice.cs index d8cbf4f..62f8a67 100644 --- a/EduNetworkBuilder/NetworkDevice.cs +++ b/EduNetworkBuilder/NetworkDevice.cs @@ -1511,6 +1511,7 @@ namespace EduNetworkBuilder { if (CopyFrom.GetType() != this.GetType()) return; //we cannot copy from it if it is different NetworkDevice ndCopyFrom = (NetworkDevice)CopyFrom; + if (Object.ReferenceEquals(this, CopyFrom)) return; //No need to copy values to itself hostname = ndCopyFrom.hostname; Size = ndCopyFrom.Size; DefaultGW = ndCopyFrom.DefaultGW; @@ -1539,6 +1540,9 @@ namespace EduNetworkBuilder DHCPRanges.AddRange(ndCopyFrom.DHCPRanges); DHCPLeases.Clear(); DHCPLeases.AddRange(ndCopyFrom.DHCPLeases); + + PowerOff = ndCopyFrom.PowerOff; + IsBurned = ndCopyFrom.IsBurned; } public void DHCPRequestFromHere() diff --git a/EduNetworkBuilder/NetworkLink.cs b/EduNetworkBuilder/NetworkLink.cs index f0e3228..e148c1a 100644 --- a/EduNetworkBuilder/NetworkLink.cs +++ b/EduNetworkBuilder/NetworkLink.cs @@ -267,8 +267,9 @@ namespace EduNetworkBuilder deleteme = true; } } - if (sNic.isWireless() != dNic.isWireless()) - deleteme = true; + if (sNic != null && dNic != null) + if (sNic.isWireless() != dNic.isWireless()) + deleteme = true; if(deleteme) { sDev.RemoveLinkTo(dDev.hostname); //this removes this link