Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/DBMDataRef/DBMDataRef.vb
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ Namespace Vitens.DynamicBandwidthMonitor

Private _lock As New Object ' Object for exclusive lock on critical section.
Private _annotations As New SortedDictionary(Of AFTime, Object)
Private Shared _dbm As New DBM(New DBMLoggerAFTrace)
Private _dbm As New DBM(New DBMLoggerAFTrace)


Public Shared Function CreateDataPipe As Object
Expand Down
15 changes: 13 additions & 2 deletions src/dbm/DBMDataStore.vb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
' Dynamic Bandwidth Monitor
' Leak detection method implemented in a real-time data historian
' Copyright (C) 2014-2022 J.H. Fitié, Vitens N.V.
' Copyright (C) 2014-2025 J.H. Fitié, Vitens N.V.
'
' This file is part of DBM.
'
Expand All @@ -22,6 +22,7 @@ Imports System
Imports System.Collections.Generic
Imports System.Double
Imports System.Threading
Imports Vitens.DynamicBandwidthMonitor.DBMParameters


Namespace Vitens.DynamicBandwidthMonitor
Expand All @@ -30,8 +31,12 @@ Namespace Vitens.DynamicBandwidthMonitor
Public Class DBMDataStore


Private Shared ReadOnly MaxDataStoreSize As Integer =
(365+ComparePatterns*7)*24*60*60\CalculationInterval+EMAPreviousPeriods


Private _lock As New Object ' Object for exclusive lock on critical section.
Private _dataStore As New Dictionary(Of DateTime, Double) ' In-memory data
Private _dataStore As New SortedDictionary(Of DateTime, Double) ' In-mem


Public Sub AddData(timestamp As DateTime, data As Object)
Expand All @@ -46,7 +51,13 @@ Namespace Vitens.DynamicBandwidthMonitor
Try

If Not _dataStore.ContainsKey(timestamp) Then

While _dataStore.Count >= MaxDataStoreSize ' Limit size
_dataStore.Remove(_dataStore.Keys.First()) ' Remove oldest
End While

_dataStore.Add(timestamp, DirectCast(data, Double))

End If

Finally
Expand Down
Loading