nel mio programma sono comandi seriali
Ho finito adesso modificando con dei controlli timer inserendo un'array di timer e funziona tutto.
questi sono i timer:
codice:
#Region "TIMER TOGO"
Private Sub tmrTGo_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim tmrTGoTag As Integer = CInt(CType(sender, Timer).Tag)
'Debug.Print("timer togo " & tmrTGoTag & " " & CType(sender, Timer).Enabled)
GoNext(tmrTGoTag) = GoNext(tmrTGoTag) + 1
ToGo(tmrTGoTag) = memInterval(tmrTGoTag) - GoNext(tmrTGoTag)
FindControl("lblMem" & CStr(tmrTGoTag), Me).BackColor = Color.Khaki
If ToGo(tmrTGoTag) < 0 Then 'Se il tempo dell'intervallo a scalare è = 0
ToGo(tmrTGoTag) = memInterval(tmrTGoTag) 'Imposto il tempo dell'intervallo = all'intervallo delle memorie
GoNext(tmrTGoTag) = 0 ' e visualizzo zero nella lblMem
FindControl("lblMem" & CStr(tmrTGoTag), Me).Text = "C" & tmrTGoTag & " From " & CStr(memFrom(tmrTGoTag) + 1) & " To " & CStr(memTo(tmrTGoTag) + 1) & " Out:" & CStr(lastMem(tmrTGoTag) + 1) & " Int:" & memInterval(tmrTGoTag) & " Go: " & memInterval(tmrTGoTag)
Else
FindControl("lblMem" & CStr(tmrTGoTag), Me).Text = "C" & tmrTGoTag & " From " & CStr(memFrom(tmrTGoTag) + 1) & " To " & CStr(memTo(tmrTGoTag) + 1) & " Out:" & CStr(lastMem(tmrTGoTag) + 1) & " Int:" & memInterval(tmrTGoTag) & " Go: " & memInterval(tmrTGoTag) - GoNext(tmrTGoTag)
End If
End Sub
#End Region
#Region "TIMER MEMORIE"
Private Sub tmrMem_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim tmrMemTag As Integer = CInt(CType(sender, Timer).Tag)
Dim tmrMemInterval As Integer = CType(sender, Timer).Interval
'Debug.Print("timer mem " & tmrMemTag & " " & CType(sender, Timer).Enabled)
'sequenza in play ?
memPlay(tmrMemTag) = ini.IniRead(iniFile, "CAM" & tmrMemTag, "MEMPLAY")
If CurrentCamSelect = tmrMemTag Then
'Coloro di verde la mem precedente della cam corrente
BtnArray(lastMem(tmrMemTag)).BackColor = Color.PaleGreen
'Coloro di rosso la memoria in esecuzione della cam corrente
BtnArray(memOut(tmrMemTag)).BackColor = Color.Red
End If
FindControl("lblMem" & CStr(tmrMemTag), Me).BackColor = Color.DarkKhaki
tmrMemInterval = CInt(memInterval(tmrMemTag) * CLng(1000))
If memPlay(tmrMemTag) = "TRUE" Then
'Imposto play a vero
PlayOn(tmrMemTag) = CBool("TRUE")
'Invio al controller la selezione della camera
ComCamera.Write(Chr(2) & "XPT:" & tmrMemTag & Chr(13))
'Aggiungo uno zero al comando inviato se inferiore a 10
If memOut(tmrMemTag) < 10 Then
ComCamera.Write(Chr(13) & "#R0" & memOut(tmrMemTag) & Chr(13))
Else
ComCamera.Write(Chr(13) & "#R" & memOut(tmrMemTag) & Chr(13))
End If
ComCamera.Write(Chr(2) & "XPT:" & tmrMemTag & Chr(13))
'Imposto la variabile dell'ultima memoria uscita con la memoria fuori adesso
lastMem(tmrMemTag) = memOut(tmrMemTag)
'Se la memoria uscita è uguale alla memoria finale o minore della memoria di partenza
If memOut(tmrMemTag) >= memTo(tmrMemTag) Then 'Or memFrom(tmrMemTag) >= memTo(tmrMemTag) Then
memOut(tmrMemTag) = memFrom(tmrMemTag)
Else
'Incremento la memoria da mandare
memOut(tmrMemTag) += 1
End If
'Salvo la memoria che ho mandato. Se esco dal programma ripartirò da questa memoria al riavvio
ini.IniWrite(iniFile, "CAM" & tmrMemTag, "MEMOUT", CStr(memOut(tmrMemTag)))
End If
End Sub
#End Region
in TIMER MEMORIE mando i comandi al brandeggio
in TIMER TOGO visualizzo sulla form che intervallo di memorie sta uscendo su quel brandeggio, che memoria sta uscendo, l'interbvallo tra una mem e l'altra e tra quanto uscita la prossima memoria.
Più di così non saprei come spiegare
Grazie, Alberto