mirror of
https://github.com/9ParsonsB/Pulsar.git
synced 2025-07-01 08:23:42 -04:00
Add event-based LogMonitor state changes to better handle batch reads (#59)
* Add event-based LogMonitor state changes to better handle batch reads Pre-reading hackily used read-all to suppress notifications. But that broke some assumptions about what read-all meant. Furthermore, the Core UI told plugins about read-all rather than the log monitor telling them -- which is really what should be telling them. To address these concerns, LogMonitor now provides an event that both the PluginCore and PluginEventHandler listens to or tracking logging state allowing more granular information about the activities of LogMonitor, including distinguishing between ReadAll and Pre-read batches. Plugins no longer need to track if LogMonitor is in batch-read mode or not -- PluginCore now provides it. I've also converted all built-in plugins to use the new event-based system. The old system is marked deprecated and will go away once other known contributed plugins have converted to the new system. * Change LogMonitorState enum to [Flags], drop 'None' state As requested, and did associated simplifications and cleanup that followed.
This commit is contained in:
@ -34,8 +34,7 @@ namespace Observatory.Explorer
|
||||
private ObservableCollection<object> resultsGrid;
|
||||
private IObservatoryCore Core;
|
||||
|
||||
private bool readAllStarting = false;
|
||||
private bool readAllInProgress = false;
|
||||
private bool recordProcessedSinceBatchStart = false;
|
||||
|
||||
public string Name => "Observatory Explorer";
|
||||
|
||||
@ -57,12 +56,12 @@ namespace Observatory.Explorer
|
||||
|
||||
public void JournalEvent<TJournal>(TJournal journal) where TJournal : JournalBase
|
||||
{
|
||||
bool recordProcessed = false;
|
||||
switch (journal)
|
||||
{
|
||||
case Scan scan:
|
||||
explorer.ProcessScan(scan, readAllInProgress);
|
||||
recordProcessed = true;
|
||||
explorer.ProcessScan(scan, Core.IsLogMonitorBatchReading && recordProcessedSinceBatchStart);
|
||||
// Set this *after* the first scan processes so that we get the current custom criteria file.
|
||||
if (Core.IsLogMonitorBatchReading) recordProcessedSinceBatchStart = true;
|
||||
break;
|
||||
case FSSBodySignals signals:
|
||||
explorer.RecordSignal(signals);
|
||||
@ -84,24 +83,20 @@ namespace Observatory.Explorer
|
||||
break;
|
||||
}
|
||||
|
||||
//Set this *after* the first scan processes so that we get the current custom criteria file.
|
||||
if (readAllStarting && recordProcessed)
|
||||
readAllInProgress = true;
|
||||
}
|
||||
|
||||
public void ReadAllStarted()
|
||||
public void LogMonitorStateChanged(LogMonitorStateChangedEventArgs args)
|
||||
{
|
||||
readAllStarting = true;
|
||||
Core.ClearGrid(this, new ExplorerUIResults());
|
||||
explorer.Clear();
|
||||
}
|
||||
|
||||
public void ReadAllFinished()
|
||||
{
|
||||
readAllStarting = false;
|
||||
readAllInProgress = false;
|
||||
if (LogMonitorStateChangedEventArgs.IsBatchRead(args.NewState))
|
||||
{
|
||||
// Beginning a batch read. Clear grid.
|
||||
recordProcessedSinceBatchStart = false;
|
||||
Core.ClearGrid(this, new ExplorerUIResults());
|
||||
explorer.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public object Settings
|
||||
{
|
||||
get => settings;
|
||||
|
Reference in New Issue
Block a user