236 lines
6.6 KiB
Plaintext
236 lines
6.6 KiB
Plaintext
VERSION 5.00
|
|
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.1#0"; "mscomctl.ocx"
|
|
Begin VB.Form FrmWaagenRuhe
|
|
Caption = "Pruef2000: Warte auf Waagen Ruhe "
|
|
ClientHeight = 1590
|
|
ClientLeft = 60
|
|
ClientTop = 345
|
|
ClientWidth = 5415
|
|
LinkTopic = "Form2"
|
|
MaxButton = 0 'False
|
|
MinButton = 0 'False
|
|
ScaleHeight = 1590
|
|
ScaleWidth = 5415
|
|
StartUpPosition = 1 'Fenstermitte
|
|
Begin MSComctlLib.StatusBar StatusBar1
|
|
Align = 2 'Unten ausrichten
|
|
Height = 375
|
|
Left = 0
|
|
TabIndex = 5
|
|
Top = 1215
|
|
Width = 5415
|
|
_ExtentX = 9551
|
|
_ExtentY = 661
|
|
_Version = 393216
|
|
BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628}
|
|
NumPanels = 1
|
|
BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628}
|
|
EndProperty
|
|
EndProperty
|
|
End
|
|
Begin VB.CommandButton cmdAbbrechen
|
|
Caption = "Warten Abbrechen"
|
|
Height = 555
|
|
Left = 3690
|
|
TabIndex = 3
|
|
Top = 150
|
|
Width = 1395
|
|
End
|
|
Begin MSComctlLib.ProgressBar ProgressBar1
|
|
Height = 315
|
|
Left = 480
|
|
TabIndex = 2
|
|
Top = 780
|
|
Width = 4275
|
|
_ExtentX = 7541
|
|
_ExtentY = 556
|
|
_Version = 393216
|
|
Appearance = 1
|
|
End
|
|
Begin VB.Label lblWdh
|
|
Height = 285
|
|
Left = 4440
|
|
TabIndex = 4
|
|
Top = 810
|
|
Width = 675
|
|
End
|
|
Begin VB.Label Label2
|
|
Alignment = 1 'Rechts
|
|
Caption = "kg"
|
|
BeginProperty Font
|
|
Name = "MS Sans Serif"
|
|
Size = 13.5
|
|
Charset = 0
|
|
Weight = 400
|
|
Underline = 0 'False
|
|
Italic = 0 'False
|
|
Strikethrough = 0 'False
|
|
EndProperty
|
|
Height = 435
|
|
Left = 2100
|
|
TabIndex = 1
|
|
Top = 180
|
|
Width = 375
|
|
End
|
|
Begin VB.Label lblGewicht
|
|
Alignment = 1 'Rechts
|
|
BorderStyle = 1 'Fest Einfach
|
|
BeginProperty Font
|
|
Name = "MS Sans Serif"
|
|
Size = 13.5
|
|
Charset = 0
|
|
Weight = 400
|
|
Underline = 0 'False
|
|
Italic = 0 'False
|
|
Strikethrough = 0 'False
|
|
EndProperty
|
|
Height = 435
|
|
Left = 420
|
|
TabIndex = 0
|
|
Top = 180
|
|
Width = 1575
|
|
End
|
|
End
|
|
Attribute VB_Name = "FrmWaagenRuhe"
|
|
Attribute VB_GlobalNameSpace = False
|
|
Attribute VB_Creatable = False
|
|
Attribute VB_PredeclaredId = True
|
|
Attribute VB_Exposed = False
|
|
Public m_sFormat As String
|
|
Public m_RuheWdh As Integer
|
|
Private m_Activated As Boolean
|
|
|
|
Public m_RuheDifferenz As Double
|
|
|
|
Private Sub cmdAbbrechen_Click()
|
|
g_Abbruch = True
|
|
End Sub
|
|
|
|
Private Sub Form_Activate()
|
|
DebugMsg "Warte auf Waagen Ruhe"
|
|
|
|
Dim AltGewicht As Double
|
|
Dim NeuGewicht As Double
|
|
Dim Differenz As Double
|
|
|
|
Dim ZeitIntervall As Long
|
|
Dim DifferenzGrenzwert As Double
|
|
Dim Anzahl As Integer
|
|
Dim Zaehler As Integer
|
|
Dim versuchzaehler As Integer
|
|
|
|
Dim lngStartzeit As Long
|
|
Dim lngMaxzeit As Long
|
|
|
|
|
|
If m_Activated = True Then
|
|
Exit Sub
|
|
Else
|
|
m_Activated = True
|
|
End If
|
|
|
|
' Voreinstellungen
|
|
ZeitIntervall = 1000
|
|
|
|
DifferenzGrenzwert = m_RuheDifferenz
|
|
|
|
lngStartzeit = GetTickCount()
|
|
|
|
Select Case g_App.PruefstationNr
|
|
Case 2009, 2010
|
|
lngMaxzeit = 300000 ' 5 minuten = 5 * 60 * 1000 ms
|
|
Case Else
|
|
End Select
|
|
|
|
If m_RuheWdh > 0 Then
|
|
Anzahl = m_RuheWdh
|
|
Else
|
|
Anzahl = 10
|
|
End If
|
|
|
|
|
|
ProgressBar1.Max = Anzahl
|
|
' Initialisierung
|
|
WarteNeu:
|
|
|
|
Debug.Print Round(Differenz, 4)
|
|
|
|
Zaehler = 1
|
|
versuchzaehler = 0
|
|
Do
|
|
versuchzaehler = versuchzaehler + 1
|
|
If versuchzaehler > 5 Then
|
|
DebugMsg "Das Gewicht konnte nach mehrmaligen Versuchen nicht ermittelt werden." & vbCrLf & _
|
|
"Bitte überprüfen Sie die serielle Verbindung zur Waage!"
|
|
GoTo Ende
|
|
ElseIf versuchzaehler > 1 Then
|
|
Me.Caption = "Pruef2000: Waagenstörung ! Versuch: " & versuchzaehler
|
|
Sleep 200, True
|
|
End If
|
|
|
|
NeuGewicht = g_App.getWaage.GetGewicht()
|
|
FrmWaagenRuhe.lblGewicht.Caption = Format(NeuGewicht, "0.000")
|
|
Loop While NeuGewicht = -9999
|
|
|
|
ProgressBar1.value = 1
|
|
|
|
WarteWeiter:
|
|
ProgressBar1.value = Zaehler
|
|
lblWdh.Caption = Zaehler & "/" & Anzahl
|
|
Sleep ZeitIntervall, True
|
|
If g_Abbruch = True Then
|
|
g_Abbruch = False
|
|
GoTo Ende
|
|
End If
|
|
AltGewicht = NeuGewicht
|
|
versuchzaehler = 0
|
|
Do
|
|
versuchzaehler = versuchzaehler + 1
|
|
If versuchzaehler > 4 Then
|
|
DebugMsg "Das Gewicht konnte nach mehrmaligen Versuchen nicht ermittelt werden." & vbCrLf & _
|
|
"Bitte überprüfen Sie die serielle Verbindung zur Waage!"
|
|
GoTo Ende
|
|
ElseIf versuchzaehler > 1 Then
|
|
Me.Caption = "Pruef2000: Waagenstörung ! Versuch: " & versuchzaehler
|
|
Sleep 200, True
|
|
Else
|
|
Me.Caption = "Pruef2000"
|
|
End If
|
|
NeuGewicht = g_App.getWaage.GetGewicht()
|
|
FrmWaagenRuhe.lblGewicht.Caption = Format(NeuGewicht, "0.000")
|
|
Loop While NeuGewicht < -9999
|
|
|
|
If lngMaxzeit > 0 Then
|
|
If (lngStartzeit + lngMaxzeit) - GetTickCount > 0 Then
|
|
Debug.Print "Restzeit " & (lngStartzeit + lngMaxzeit) - GetTickCount
|
|
' Restzeit ist vorhanden
|
|
Else
|
|
' Abbruch nach lngMaxzeit ms
|
|
WriteToLog "Wartezeit für Waagenruhe " & lngMaxzeit / 1000 & "s abgelaufen. "
|
|
GoTo Ende
|
|
End If
|
|
End If
|
|
|
|
Differenz = Abs(NeuGewicht - AltGewicht)
|
|
Debug.Print Differenz & " > " & DifferenzGrenzwert & "?"
|
|
|
|
StatusBar1.SimpleText = "Abfluss = " & Differenz / ZeitIntervall
|
|
|
|
If Differenz > DifferenzGrenzwert Then GoTo WarteNeu
|
|
|
|
Zaehler = Zaehler + 1
|
|
If Zaehler <= Anzahl And Zaehler <= ProgressBar1.Max Then GoTo WarteWeiter
|
|
Ende:
|
|
Unload Me
|
|
End Sub
|
|
|
|
|
|
|
|
Private Sub Form_Load()
|
|
If m_sFormat = "" Then m_sFormat = "0.00"
|
|
m_Stop = False
|
|
m_Activated = False
|
|
End Sub
|
|
|
|
|