-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMainWindow.ClockSyncToggle.cs
More file actions
54 lines (44 loc) · 1.81 KB
/
Copy pathMainWindow.ClockSyncToggle.cs
File metadata and controls
54 lines (44 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using ArIED61850Tester.Models;
namespace ArIED61850Tester;
public partial class MainWindow
{
private bool _clockSyncEnabled = true;
internal bool IsClockSyncEnabled => _clockSyncEnabled;
internal async Task SetClockSyncEnabledAsync(bool enabled)
{
if (_clockSyncEnabled == enabled)
return;
_clockSyncEnabled = enabled;
if (!enabled)
{
Devices.CollectionChanged -= ClockSyncDevices_CollectionChanged;
foreach (var device in Devices)
device.PropertyChanged -= ClockSyncDevice_PropertyChanged;
await _clockSyncIntegrationGate.WaitAsync();
try
{
await _sntpClockService.StopAsync();
_clockSyncObservedClients.Clear();
_clockSyncRepliedClients.Clear();
AddLog("INFO", "Clock Sync",
"Clock Sync disabled from the FAT workspace. IEC 61850 monitoring remains active.");
}
catch (Exception ex)
{
AddLog("WARN", "Clock Sync",
$"Clock Sync disable requested, but the SNTP service reported: {ex.Message}");
}
finally
{
_clockSyncIntegrationGate.Release();
}
return;
}
Devices.CollectionChanged -= ClockSyncDevices_CollectionChanged;
Devices.CollectionChanged += ClockSyncDevices_CollectionChanged;
foreach (var device in Devices)
AttachClockSyncDevice(device);
AddLog("INFO", "Clock Sync",
"Clock Sync enabled from the FAT workspace. ARSAS will serve connected IPv4 IEDs using normal UDP/123 when available and an Npcap RAW fallback when Windows already owns that port. Windows Time is never stopped or reconfigured.");
}
}