public static SlaveInfo RescanDevices(EcSettings settings, SlaveInfo referenceRootSlave) { var referenceSlaves = default(IEnumerable <SlaveInfo>); if (referenceRootSlave != null) { referenceSlaves = referenceRootSlave.Descendants().ToList(); } var newRootSlave = EcUtilities.ScanDevices(settings.InterfaceName, referenceRootSlave); newRootSlave.Descendants().ToList().ForEach(slave => { var referenceSlave = slave.Csa == slave.OldCsa ? referenceSlaves?.FirstOrDefault(x => x.Csa == slave.Csa) : null; if (referenceSlave != null) { slave.Extensions = referenceSlave.Extensions; } EcUtilities.CreateDynamicData(settings.EsiDirectoryPath, slave); }); return(newRootSlave); }
public void Configure(SlaveInfo rootSlaveInfo = null) { SlaveInfo actualSlaveInfo; IList <SlaveInfo> slaveInfoSet; IList <SlaveInfo> actualSlaveInfoSet; NetworkInterface networkInterface; networkInterface = NetworkInterface.GetAllNetworkInterfaces().Where(nic => nic.Name == _settings.InterfaceName).FirstOrDefault(); if (networkInterface?.OperationalStatus != OperationalStatus.Up) { throw new Exception($"Network interface '{_settings.InterfaceName}' is not linked. Aborting action."); } #region "PreOp" actualSlaveInfo = EcUtilities.ScanDevices(this.Context, _settings.InterfaceName, null); if (rootSlaveInfo == null) { rootSlaveInfo = actualSlaveInfo; rootSlaveInfo.Descendants().ToList().ForEach(current => { ExtensibilityHelper.CreateDynamicData(_settings.EsiDirectoryPath, _extensionFactory, current); }); } slaveInfoSet = rootSlaveInfo.Descendants().ToList(); actualSlaveInfoSet = actualSlaveInfo.Descendants().ToList(); this.ValidateSlaves(slaveInfoSet, actualSlaveInfoSet); this.ConfigureSlaves(slaveInfoSet); this.ConfigureIoMap(slaveInfoSet); this.ConfigureDc(); this.ConfigureSync01(slaveInfoSet); #endregion #region "SafeOp" EcUtilities.CheckErrorCode(this.Context, EcHL.CheckSafeOpState(this.Context), nameof(EcHL.CheckSafeOpState)); #endregion #region "Op" EcUtilities.CheckErrorCode(this.Context, EcHL.RequestOpState(this.Context), nameof(EcHL.RequestOpState)); #endregion if (_watchdogTask == null) { _watchdogTask = Task.Run(() => this.WatchdogRoutine(), _cts.Token); } }
public void Configure(SlaveInfo rootSlave = null) { var networkInterface = NetworkInterface .GetAllNetworkInterfaces() .Where(nic => nic.Name == _settings.InterfaceName) .FirstOrDefault(); if (networkInterface?.OperationalStatus != OperationalStatus.Up) { throw new Exception($"Network interface '{_settings.InterfaceName}' is not linked. Aborting action."); } #region "PreOp" var actualSlave = EcUtilities.ScanDevices(this.Context, _settings.InterfaceName, null); if (rootSlave == null) { rootSlave = actualSlave; rootSlave.Descendants().ToList().ForEach(current => { EcUtilities.CreateDynamicData(_settings.EsiDirectoryPath, current); }); } var slaves = rootSlave.Descendants().ToList(); var actualSlaves = actualSlave.Descendants().ToList(); this.ValidateSlaves(slaves, actualSlaves); this.ConfigureSlaves(slaves); this.ConfigureIoMap(slaves); this.ConfigureDc(); this.ConfigureSync01(slaves); #endregion #region "SafeOp" EcUtilities.CheckErrorCode(this.Context, EcHL.CheckSafeOpState(this.Context), nameof(EcHL.CheckSafeOpState)); #endregion #region "Op" EcUtilities.CheckErrorCode(this.Context, EcHL.RequestCommonState(this.Context, (UInt16)SlaveState.Operational), nameof(EcHL.RequestCommonState)); #endregion if (_watchdogTask == null) { _watchdogTask = Task.Run(() => this.WatchdogRoutine(), _cts.Token); } }
public static SlaveInfo ScanDevices(string interfaceName, SlaveInfo referenceSlaveInfo = null) { IntPtr context; SlaveInfo slaveInfo; context = EcHL.CreateContext(); slaveInfo = EcUtilities.ScanDevices(context, interfaceName, referenceSlaveInfo); EcHL.FreeContext(context); return(slaveInfo); }
public static SlaveInfo ScanDevices(string interfaceName, SlaveInfo referenceRootSlave = null) { if (NetworkInterface.GetAllNetworkInterfaces().Where(x => x.Name == interfaceName).FirstOrDefault()?.OperationalStatus != OperationalStatus.Up) { throw new Exception($"The network interface '{interfaceName}' is not linked. Aborting action."); } var context = EcHL.CreateContext(); var rootSlave = EcUtilities.ScanDevices(context, interfaceName, referenceRootSlave); EcHL.FreeContext(context); return(rootSlave); }