Thanks for the quick reply.
I've tried your suggestions without success. The first input on both cards does not attach. I tried again with just one Phidget, but this had no effect.
Code: Select all
Public Class phidgetInterfaceClass
Dim WithEvents kit As Phidget22.DigitalInput
'WithEvents kit As Phidgets.InterfaceKit
Dim serialNumber As Integer
'Public inputs As Phidgets.InterfaceKitDigitalInputCollection
'Public outputs As Phidgets.InterfaceKitDigitalOutputCollection
Public numInputs As Integer
Public numOutputs As Integer
Public inputs As New List(Of DigitalInput)
Public outputs As New List(Of DigitalOutput)
Public connected As Boolean = False
Public txtStatus As String = ""
Public changes As New Queue(Of Integer)
Public Sub New()
open(0)
End Sub
Public Sub New(ByVal SN As Integer)
open(SN)
End Sub
Private Sub open(ByVal SN As Integer)
Phidget22.Phidget.InvokeEventCallbacks = True
kit = New Phidget22.DigitalInput()
'kit = New Phidgets.InterfaceKit
If SN <> 0 Then
serialNumber = SN
kit.open(serialNumber)
Else
kit.open()
End If
connected = False
txtStatus = "Not Connected"
End Sub
Private Sub attachEvent(ByVal sender As Object, ByVal e As Phidget22.Events.AttachEventArgs) Handles kit.Attach
'When the Phidget attaches
Dim retries As Integer = 10
'While retries > 0
' Try
'Dim attachedDevice As Phidget22.DigitalInput = CType(sender, Phidget22.DigitalInput)
Thread.Sleep(3000)
numOutputs = kit.GetDeviceChannelCount(ChannelClass.DigitalInput)
For i As Integer = 0 To numOutputs - 1
Dim output As New DigitalOutput
output.Channel = i
output.Open(500)
outputs.Add(output)
Next
numInputs = kit.GetDeviceChannelCount(ChannelClass.DigitalInput)
For i As Integer = 0 To numInputs - 1
Dim input As New DigitalInput()
input.Channel = i
Try
input.Open(500)
Catch ex As Exception
Console.WriteLine("Error for phidgetSN:" + kit.DeviceSerialNumber.ToString() + " input #" + i.ToString() + ":" + ex.Message)
End Try
inputs.Add(input)
Next
connected = True
txtStatus = "Connected" ' must be last
retries = 0
' Catch ex As Exception
'retries -= 1
' Trace.WriteLine("Error - Retires to go " & retries.ToString())
' End Try
'End While
End Sub
I'd think it was a base zero issue except the outputs all attach correctly.
I've included the initialisation code this time, so hopefully someone can see what I am doing wrong.
Thanks in advance.
P.S. Could the administrator extend the timeout on the POST A REPLY page. I got called away for half an hour and lost my previous message.