public static async Task RestartAsync(AmsNetId target, CancellationToken cancel) { using (AdsClient client = new AdsClient()) { client.Connect(new AmsAddress(target, AmsPort.SystemService)); await client.WriteControlAsync(AdsState.Reset, 0, cancel); } }
public static async Task RebootAsync(AmsNetId target, TimeSpan delay, CancellationToken cancel) { var data = BitConverter.GetBytes((int)delay.TotalSeconds); var buffer = new ReadOnlyMemory <byte>(data); using (AdsClient client = new AdsClient()) { client.Connect(new AmsAddress(target, AmsPort.SystemService)); await client.WriteControlAsync(AdsState.Shutdown, 1, buffer, cancel); } }