You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
1013 B
35 lines
1013 B
Public Class ErrorStopper
|
|
|
|
Private nb_events As Integer = 0
|
|
Private nb_seconds As Integer = 0
|
|
|
|
Private myStack As ArrayList
|
|
|
|
Public Function insert() As Boolean
|
|
Dim result As Boolean = True
|
|
'Neues Element rein
|
|
Dim new_el As New DateTime
|
|
new_el = Now()
|
|
myStack.Add(new_el)
|
|
'Alte löschen
|
|
Dim check_el As DateTime
|
|
Dim i As Integer = myStack.Count
|
|
Do While i > 0
|
|
check_el = myStack.Item(0)
|
|
If DateAdd(DateInterval.Second, nb_seconds, check_el) < Now() Then
|
|
myStack.RemoveAt(0)
|
|
End If
|
|
i = i - 1
|
|
Loop
|
|
'Check ob Menge überschritten
|
|
If myStack.Count >= nb_events Then result = False
|
|
Return result
|
|
End Function
|
|
|
|
Public Sub init(ByVal numberOfEvents As Integer, ByVal periodInSeconds As Integer)
|
|
Me.nb_events = numberOfEvents
|
|
Me.nb_seconds = periodInSeconds
|
|
Me.myStack = New ArrayList
|
|
End Sub
|
|
End Class
|