C
cmdolcet69
I have these two subs that are being called on two different timers
threads. It seems that when I get to the DoDualDSIWorkCOM2 that it
keeps passing in the sender and the e as the first serial com and not
the second serial com? How can I fix this?
Public Sub StartWorkerThreadDualDSI1(ByVal gageType As String, ByVal
comPort As Integer)
Dim expectedBaudRate As String = "57600"
Select Case gageType
Case "Mux"
AddHandler dataBackgroundWorker.DoWork, AddressOf
DoMuxWork
AddHandler dataBackgroundWorker.RunWorkerCompleted,
AddressOf MuxWorkComplete
expectedBaudRate = "57600"
Case "DAI"
AddHandler dataBackgroundWorker.DoWork, AddressOf
DoMuxWork
AddHandler dataBackgroundWorker.RunWorkerCompleted,
AddressOf DAIWorkComplete
expectedBaudRate = "57600"
Case "DSI"
AddHandler dataBackgroundWorker.DoWork, AddressOf
DoDualDSIWorkCOM1
AddHandler dataBackgroundWorker.RunWorkerCompleted,
AddressOf DualDSIWorkComplete
expectedBaudRate = "9600"
Case "501"
AddHandler dataBackgroundWorker.DoWork, AddressOf
Do501Work
AddHandler dataBackgroundWorker.RunWorkerCompleted,
AddressOf ASIWorkComplete
expectedBaudRate = "115200"
Case "Sony"
AddHandler dataBackgroundWorker.DoWork, AddressOf
DoSonyWork
AddHandler dataBackgroundWorker.RunWorkerCompleted,
AddressOf SonyWorkComplete
expectedBaudRate = "9600"
End Select
currentSerial = GetSerialPortUsed(comPort)
ChangeCOMBaudRateIfNecessary(expectedBaudRate)
dataBackgroundWorker.RunWorkerAsync(New Object()
{currentSerial})
Me.tmrBackgroundWorker.Enabled = True
End Sub
Public Sub StartWorkerThreadDualDSI2(ByVal gageType As String,
ByVal comPort As Integer)
Dim expectedBaudRate As String = "57600"
Select Case gageType
Case "Mux"
AddHandler dataBackgroundWorker.DoWork, AddressOf
DoMuxWork
AddHandler dataBackgroundWorker.RunWorkerCompleted,
AddressOf MuxWorkComplete
expectedBaudRate = "57600"
Case "DAI"
AddHandler dataBackgroundWorker.DoWork, AddressOf
DoMuxWork
AddHandler dataBackgroundWorker.RunWorkerCompleted,
AddressOf DAIWorkComplete
expectedBaudRate = "57600"
Case "DSI"
AddHandler dataBackgroundWorker2.DoWork, AddressOf
DoDualDSIWorkCOM2
AddHandler dataBackgroundWorker2.RunWorkerCompleted,
AddressOf DualDSIWorkComplete
expectedBaudRate = "9600"
Case "501"
AddHandler dataBackgroundWorker.DoWork, AddressOf
Do501Work
AddHandler dataBackgroundWorker.RunWorkerCompleted,
AddressOf ASIWorkComplete
expectedBaudRate = "115200"
Case "Sony"
AddHandler dataBackgroundWorker.DoWork, AddressOf
DoSonyWork
AddHandler dataBackgroundWorker.RunWorkerCompleted,
AddressOf SonyWorkComplete
expectedBaudRate = "9600"
End Select
currentSerial2 = GetSerialPortUsed(comPort)
ChangeCOMBaudRateIfNecessary(expectedBaudRate)
dataBackgroundWorker2.RunWorkerAsync(New Object()
{currentSerial2})
Me.tmrBackgroundWorker2.Enabled = True
End Sub
Private Sub DoDualDSIWorkCOM1(ByVal sender As Object, ByVal e As
DoWorkEventArgs)
Try
Dim args() As Object = e.Argument
Dim intloop As Integer
CType(args(0), IO.Ports.SerialPort).DiscardInBuffer()
muxClass.GetDualDSIInputCOM1(CType(args(0),
IO.Ports.SerialPort))
Catch ex As Exception
tListener.AddMethodError(ex)
End Try
End Sub
Private Sub DoDualDSIWorkCOM2(ByVal sender As Object, ByVal e As
DoWorkEventArgs)
Try
Dim args() As Object = e.Argument
Dim intloop As Integer
CType(args(0), IO.Ports.SerialPort).DiscardInBuffer()
muxClass.GetDualDSIInputCOM2(CType(args(0),
IO.Ports.SerialPort))
Catch ex As Exception
tListener.AddMethodError(ex)
End Try
End Sub
threads. It seems that when I get to the DoDualDSIWorkCOM2 that it
keeps passing in the sender and the e as the first serial com and not
the second serial com? How can I fix this?
Public Sub StartWorkerThreadDualDSI1(ByVal gageType As String, ByVal
comPort As Integer)
Dim expectedBaudRate As String = "57600"
Select Case gageType
Case "Mux"
AddHandler dataBackgroundWorker.DoWork, AddressOf
DoMuxWork
AddHandler dataBackgroundWorker.RunWorkerCompleted,
AddressOf MuxWorkComplete
expectedBaudRate = "57600"
Case "DAI"
AddHandler dataBackgroundWorker.DoWork, AddressOf
DoMuxWork
AddHandler dataBackgroundWorker.RunWorkerCompleted,
AddressOf DAIWorkComplete
expectedBaudRate = "57600"
Case "DSI"
AddHandler dataBackgroundWorker.DoWork, AddressOf
DoDualDSIWorkCOM1
AddHandler dataBackgroundWorker.RunWorkerCompleted,
AddressOf DualDSIWorkComplete
expectedBaudRate = "9600"
Case "501"
AddHandler dataBackgroundWorker.DoWork, AddressOf
Do501Work
AddHandler dataBackgroundWorker.RunWorkerCompleted,
AddressOf ASIWorkComplete
expectedBaudRate = "115200"
Case "Sony"
AddHandler dataBackgroundWorker.DoWork, AddressOf
DoSonyWork
AddHandler dataBackgroundWorker.RunWorkerCompleted,
AddressOf SonyWorkComplete
expectedBaudRate = "9600"
End Select
currentSerial = GetSerialPortUsed(comPort)
ChangeCOMBaudRateIfNecessary(expectedBaudRate)
dataBackgroundWorker.RunWorkerAsync(New Object()
{currentSerial})
Me.tmrBackgroundWorker.Enabled = True
End Sub
Public Sub StartWorkerThreadDualDSI2(ByVal gageType As String,
ByVal comPort As Integer)
Dim expectedBaudRate As String = "57600"
Select Case gageType
Case "Mux"
AddHandler dataBackgroundWorker.DoWork, AddressOf
DoMuxWork
AddHandler dataBackgroundWorker.RunWorkerCompleted,
AddressOf MuxWorkComplete
expectedBaudRate = "57600"
Case "DAI"
AddHandler dataBackgroundWorker.DoWork, AddressOf
DoMuxWork
AddHandler dataBackgroundWorker.RunWorkerCompleted,
AddressOf DAIWorkComplete
expectedBaudRate = "57600"
Case "DSI"
AddHandler dataBackgroundWorker2.DoWork, AddressOf
DoDualDSIWorkCOM2
AddHandler dataBackgroundWorker2.RunWorkerCompleted,
AddressOf DualDSIWorkComplete
expectedBaudRate = "9600"
Case "501"
AddHandler dataBackgroundWorker.DoWork, AddressOf
Do501Work
AddHandler dataBackgroundWorker.RunWorkerCompleted,
AddressOf ASIWorkComplete
expectedBaudRate = "115200"
Case "Sony"
AddHandler dataBackgroundWorker.DoWork, AddressOf
DoSonyWork
AddHandler dataBackgroundWorker.RunWorkerCompleted,
AddressOf SonyWorkComplete
expectedBaudRate = "9600"
End Select
currentSerial2 = GetSerialPortUsed(comPort)
ChangeCOMBaudRateIfNecessary(expectedBaudRate)
dataBackgroundWorker2.RunWorkerAsync(New Object()
{currentSerial2})
Me.tmrBackgroundWorker2.Enabled = True
End Sub
Private Sub DoDualDSIWorkCOM1(ByVal sender As Object, ByVal e As
DoWorkEventArgs)
Try
Dim args() As Object = e.Argument
Dim intloop As Integer
CType(args(0), IO.Ports.SerialPort).DiscardInBuffer()
muxClass.GetDualDSIInputCOM1(CType(args(0),
IO.Ports.SerialPort))
Catch ex As Exception
tListener.AddMethodError(ex)
End Try
End Sub
Private Sub DoDualDSIWorkCOM2(ByVal sender As Object, ByVal e As
DoWorkEventArgs)
Try
Dim args() As Object = e.Argument
Dim intloop As Integer
CType(args(0), IO.Ports.SerialPort).DiscardInBuffer()
muxClass.GetDualDSIInputCOM2(CType(args(0),
IO.Ports.SerialPort))
Catch ex As Exception
tListener.AddMethodError(ex)
End Try
End Sub