Initial commit
This commit is contained in:
34
Archiv/edkb04op - Kopie/EDKB04OP/ErrorStopper.vb
Normal file
34
Archiv/edkb04op - Kopie/EDKB04OP/ErrorStopper.vb
Normal file
@@ -0,0 +1,34 @@
|
||||
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
|
||||
Reference in New Issue
Block a user