Visual Basic Sequenzer programmieren von SelMcKenzie
Selzer-McKenzie
Heute zeige ich Ihnen, wie Sie mit VB einen Sequenzer für
die Musikausgabe programmieren. Nachstehend der SourceCode.
Dim COUNTDOWN As Integer
Dim COUNTUP As Integer
Dim OXIDIZERON As Integer
Dim OXIDIZEROFF As Integer
Dim PUR
GEON As Integer
Dim PURGEOFF As Integer
Dim ERROR As Integer
Dim PURGE As Boolean
Dim SequenceCheck As Boolean
Dim COUNTDOWNACTIVE As Boolean
Private Sub cmdabort_Click()
EZX1.DOKstate = 0
EZX1.DOEstate = 0
EZX1.DONstate = 0
EZX1.DOSstate
= 0
txtcount.Text = txtcountdown.Text
lbltsign.Text = "T minus"
tmrhybrid1.Enabled = False
txtstatus.Text = "Sequence Aborted"
EZX1.UpdateCmd = True
End Sub
Private Sub cmdconnect_Click()
If EZX1.CommPort = 0 Then
EZX1.Comm
Port = 1
txtstatus.Text = "Connected"
EZX1.UpdateCmd = True
cmdstart.Enabled = True
ElseIf EZX1.CommPort = 1 Then
EZX1.CommPort = 0
txtstatus.Text = "Disconnected"
cmdstart.Enabled = True
End If
End S
ub
Private Sub cmdigniter_Click()
If EZX1.DOKstate = 0 Then
EZX1.DOKstate = 1
txtstatus.Text = "DOK Active"
ElseIf EZX1.DOKstate = 1 Then
EZX1.DOKstate = 0
txtstatus.Text = "DOK Inactive"
End If
EZX1.UpdateC
md = True
End Sub
Private Sub cmdoxidizeroff_Click()
If EZX1.DOEstate = 0 Then
EZX1.DOEstate = 1
txtstatus.Text = "DOE Active"
ElseIf EZX1.DOEstate = 1 Then
EZX1.DOEstate = 0
txtstatus.Text = "DOE Inactive"
End
If
EZX1.UpdateCmd = True
End Sub
Private Sub cmdoxidizeron_Click()
If EZX1.DOSstate = 0 Then
EZX1.DOSstate = 1
txtstatus.Text = "DOS Active"
ElseIf EZX1.DOSstate = 1 Then
EZX1.DOSstate = 0
txtstatus.Text = "DOS
Inactive"
End If
EZX1.UpdateCmd = True
End Sub
Private Sub cmdpurge_Click()
If EZX1.DONstate = 0 Then
EZX1.DONstate = 1
txtstatus.Text = "DON Active"
ElseIf EZX1.DONstate = 1 Then
EZX1.DONstate = 0
txtst
atus.Text = "DON Inactive"
End If
EZX1.UpdateCmd = True
End Sub
Private Sub cmdstart_Click()
COUNTDOWN = Val(txtcountdown.Text)
COUNTUP = Val(txtignition.Text)
COUNTDOWNACTIVE = True
OXIDIZERON = Val(txtoxidizeron.Text)
OXI
DIZEROFF = Val(txtoxidizeroff.Text)
PURGEON = Val(txtpurgeon.Text)
PURGEOFF = Val(txtpurgeoff.Text)
Call SequenceLogicCheck
If SequenceCheck = True Then
tmrhybrid1.Enabled = True
End If
End Sub
Private Sub SequenceLogicCheck()
If COUNTDOWN > 0 Then
If OXIDIZERON > 0 Then
If OXIDIZEROFF > OXIDIZERON Then
If PURGEON > OXIDIZEROFF Then
If PURGEOFF > PURGEON Then
PURGE = True
S
equenceCheck = True
Else
PURGE = False
SequenceCheck = True
urgeon.Text = "
---
"
txtpurgeoff.Text = "
---
"
End If
Else
PURGE = False
SequenceCheck = True
txtpurgeon.Text = "
---
"
txtpurgeoff.Text = "
---
"
End If
Else
txtstatus.Text = "O
xidizer Off must be > Oxidizer On"
SequenceCheck = False
End If
Else
txtstatus.Text = "Oxidizer On must occur at T+1 second
or later"
SequenceCheck = False
End If
Else
txtstatu
s.Text = "Countdown must be >= 1 second"
SequenceCheck = False
End If
End Sub
Private Sub Command1_Click()
If EZX1.Visible = False Then
EZX1.Visible = True
ElseIf EZX1.Visible = True Then
EZX1.Visible = False
End If
End Sub
Private Su
b Form_Load()
tmrhybrid1.Enabled = False
tmrhybrid2.Enabled = False
cmdstart.Enabled = False
txtcount.Text = txtcountdown.Text
frmFlexControl.Show
End Sub
Private Sub tmrhybrid1_Timer()
If COUNTDOWNACTIVE = True Then
COUNTDOWN = COUNTDOWN
-
1
txtcount.Text = COUNTDOWN
lbltsign.Text = "T minus"
txtpurgeoff.BackColor = &H80000005 'white
txtoxidizeroff.BackColor = &H80000005 'white
tx
tcountdown.BackColor = &HFF& 'red
Beep
If COUNTDOWN <= 1 Then
COUNTDOWNACTIVE = False
End If
ElseIf COUNTDOWNACTIVE = False Then
lbltsign.Text = "T plus"
txtcount.Text = COUNTUP
If COUNTUP < OXIDIZERON Then
EZX1.DOKstate = 1 'Igniter active
txtcountdown.BackColor = &H80000005 'white
txtignition.BackColor = &HF
F& 'red
txtignition.ForeColor = &H80000005
txtstatus.Text = "Ignition"
ElseIf COUNTUP >= OXIDIZERON And COUNTUP < OXIDIZEROFF
Then
EZX1.DOKstate = 0
txtignition.Bac
kColor = &H80000005 'white
txtignition.ForeColor = &HFF& 'black
EZX1.DOSstate = 1 'Oxidizer ON active
txtoxidizeron.BackColor = &HFF& 'red
txtstatus.Text = "Oxidizer ON"
ElseIf COUNTUP >= OXIDIZEROFF And COUNTUP < PURGEON
And PURGE = True Then
EZX1.DOSstate = 0
txtoxidizeron.BackColor = &H80000005 'white
txto
xidizeroff.BackColor = &HFF& 'red
1.DOEstate = 1 'Oxidizer OFF is active
txtstatus.Text = "Oxidizer OFF "
ElseIf COUNTUP >= PURGEON And COUNTUP < PURGEOFF And
PURGE = T
rue Then
EZX1.DOEstate = 0
EZX1.DONstate = 1 'Purge Active
txtoxidizeroff.BackColor = &H80000005 'white
txtpurgeon.BackColor = &HFF& 'red
txtstatus.Text = "Purge ON"
ElseIf COUNTUP >= PURGEOFF And PURGE = True Then
EZX1.DOSstate = 0
txtpurgeon.BackColor = &H80000005 'white
txtpurgeoff.BackColor = &HFF&
'red
txtstatus.Text = " Purge OFF"
tmrhybrid1.Enabled = False
Else
EZX1.DOSstate = 0
EZX1.DOEstate = 1
txtoxidizeron.BackColor = &H80000005 'w
hite
txtoxidizeroff.BackColor = &HFF& 'red
txtstatus.Text = "Oxidizer OFF"
tmrhybrid1.Enabled = False
tmrhybrid2.Enabled = True
End If
EZX1.UpdateCmd = Tru
e
COUNTUP = COUNTUP + 1
Beep
End If
End Sub
Private Sub tmrhybrid2_Timer()
txtoxidizeroff.BackColor = &H80000005 'white
EZX1.DOEstate = 0
EZX1.UpdateCmd = True
tmrhybrid2.Enabled = False
End Sub
Private Sub txtcountdown_Change()
txtcount.Text = txtcountdown.Text
End Sub
Private Sub txtpurgeoff_Change()
If txtpurgeoff.Text = "0" Then
txtpurgeoff.Text = "
---
"
End If
End Sub
Private Sub txtpurgeon_Change()
If txtpurgeon.Text = "0"
Then
txtpurgeon.Text = "
---
"
End If
End Sub
Keine Kommentare:
Kommentar veröffentlichen
Hinweis: Nur ein Mitglied dieses Blogs kann Kommentare posten.