Hallo,
Habe eine I/O Usb Karte, Man kann laut Hersteller bis zu 4 Stück an einem Computer anschließen und ansteuern. Gibt also 4 Adressen. Wie ich die aber alle gleichzeitig in einem Programm unterbringe, dazu schreibt der Hersteller leider nix. Wenn ich Alle 4 Karten in unterschiedlichen Modulen nacheinander verbinde, kann er alle finden. aber wenn ich dann einen Ausgang an mache , über das jeweilige modul, reagiert nur die Letzte karte.
Da ich überhaupt keinen lösungsansatz habe Hier der Quellcode, ein wechseln zwischen den Karten geht nicht, da auch Daten von den Karten kommen und ich die nicht beeinflussen kann.
Habe eine I/O Usb Karte, Man kann laut Hersteller bis zu 4 Stück an einem Computer anschließen und ansteuern. Gibt also 4 Adressen. Wie ich die aber alle gleichzeitig in einem Programm unterbringe, dazu schreibt der Hersteller leider nix. Wenn ich Alle 4 Karten in unterschiedlichen Modulen nacheinander verbinde, kann er alle finden. aber wenn ich dann einen Ausgang an mache , über das jeweilige modul, reagiert nur die Letzte karte.
Da ich überhaupt keinen lösungsansatz habe Hier der Quellcode, ein wechseln zwischen den Karten geht nicht, da auch Daten von den Karten kommen und ich die nicht beeinflussen kann.
VB.NET-Quellcode
- Module Verbindungen_und_KomunikationKüche
- Private Declare Function OpenDevice Lib "k8055d.dll" (ByVal CardAddress As Integer) As Integer
- Private Declare Sub CloseDevice Lib "k8055d.dll" ()
- Private Declare Function Version Lib "k8055d.dll" () As Integer
- Private Declare Function SearchDevices Lib "k8055d.dll" () As Integer
- Private Declare Function SetCurrentDevice Lib "k8055d.dll" (ByVal CardAddress As Integer) As Integer
- Private Declare Function ReadAnalogChannel Lib "k8055d.dll" (ByVal Channel As Integer) As Integer
- Private Declare Sub ReadAllAnalog Lib "k8055d.dll" (ByRef Data1 As Integer, ByRef Data2 As Integer)
- Private Declare Sub OutputAnalogChannel Lib "k8055d.dll" (ByVal Channel As Integer, ByVal Data As Integer)
- Private Declare Sub OutputAllAnalog Lib "k8055d.dll" (ByVal Data1 As Integer, ByVal Data2 As Integer)
- Private Declare Sub ClearAnalogChannel Lib "k8055d.dll" (ByVal Channel As Integer)
- Private Declare Sub SetAllAnalog Lib "k8055d.dll" ()
- Private Declare Sub ClearAllAnalog Lib "k8055d.dll" ()
- Private Declare Sub SetAnalogChannel Lib "k8055d.dll" (ByVal Channel As Integer)
- Private Declare Sub WriteAllDigital Lib "k8055d.dll" (ByVal Data As Integer)
- Private Declare Sub ClearDigitalChannel Lib "k8055d.dll" (ByVal Channel As Integer)
- Private Declare Sub ClearAllDigital Lib "k8055d.dll" ()
- Private Declare Sub SetDigitalChannel Lib "k8055d.dll" (ByVal Channel As Integer)
- Private Declare Sub SetAllDigital Lib "k8055d.dll" ()
- Private Declare Function ReadDigitalChannel Lib "k8055d.dll" (ByVal Channel As Integer) As Boolean
- Private Declare Function ReadAllDigital Lib "k8055d.dll" () As Integer
- Private Declare Function ReadCounter Lib "k8055d.dll" (ByVal CounterNr As Integer) As Integer
- Private Declare Sub ResetCounter Lib "k8055d.dll" (ByVal CounterNr As Integer)
- Private Declare Sub SetCounterDebounceTime Lib "k8055d.dll" (ByVal CounterNr As Integer, ByVal DebounceTime As Integer)
- Public Sub VerbindenKüche()
- Dim CardAddress As Integer
- Dim h As Integer
- CardAddress = 2
- h = OpenDevice(CardAddress)
- Select Case h
- Case 0, 1, 2, 3
- Form1.VerbundenKüche = "1"
- Case -1
- Form1.VerbundenKüche = "0"
- End Select
- End Sub
- Public Sub test1()
- SetAllDigital()
- End Sub
- End Module
VB.NET-Quellcode
- Module Verbindungen_und_Komunikation
- Private Declare Function OpenDevice Lib "k8055d.dll" (ByVal CardAddress As Integer) As Integer
- Private Declare Sub CloseDevice Lib "k8055d.dll" ()
- Private Declare Function Version Lib "k8055d.dll" () As Integer
- Private Declare Function SearchDevices Lib "k8055d.dll" () As Integer
- Private Declare Function SetCurrentDevice Lib "k8055d.dll" (ByVal CardAddress As Integer) As Integer
- Private Declare Function ReadAnalogChannel Lib "k8055d.dll" (ByVal Channel As Integer) As Integer
- Private Declare Sub ReadAllAnalog Lib "k8055d.dll" (ByRef Data1 As Integer, ByRef Data2 As Integer)
- Private Declare Sub OutputAnalogChannel Lib "k8055d.dll" (ByVal Channel As Integer, ByVal Data As Integer)
- Private Declare Sub OutputAllAnalog Lib "k8055d.dll" (ByVal Data1 As Integer, ByVal Data2 As Integer)
- Private Declare Sub ClearAnalogChannel Lib "k8055d.dll" (ByVal Channel As Integer)
- Private Declare Sub SetAllAnalog Lib "k8055d.dll" ()
- Private Declare Sub ClearAllAnalog Lib "k8055d.dll" ()
- Private Declare Sub SetAnalogChannel Lib "k8055d.dll" (ByVal Channel As Integer)
- Private Declare Sub WriteAllDigital Lib "k8055d.dll" (ByVal Data As Integer)
- Private Declare Sub ClearDigitalChannel Lib "k8055d.dll" (ByVal Channel As Integer)
- Private Declare Sub ClearAllDigital Lib "k8055d.dll" ()
- Private Declare Sub SetDigitalChannel Lib "k8055d.dll" (ByVal Channel As Integer)
- Private Declare Sub SetAllDigital Lib "k8055d.dll" ()
- Private Declare Function ReadDigitalChannel Lib "k8055d.dll" (ByVal Channel As Integer) As Boolean
- Private Declare Function ReadAllDigital Lib "k8055d.dll" () As Integer
- Private Declare Function ReadCounter Lib "k8055d.dll" (ByVal CounterNr As Integer) As Integer
- Private Declare Sub ResetCounter Lib "k8055d.dll" (ByVal CounterNr As Integer)
- Private Declare Sub SetCounterDebounceTime Lib "k8055d.dll" (ByVal CounterNr As Integer, ByVal DebounceTime As Integer)
- Public Sub VerbindenBad()
- Dim CardAddress As Integer
- Dim h As Integer
- CardAddress = 0
- h = OpenDevice(CardAddress)
- Select Case h
- Case 0, 1, 2, 3
- Form1.VerbundenBad = "1"
- Case -1
- Form1.VerbundenBad = "0"
- End Select
- End Sub
- Public Sub Test()
- SetAllDigital()
- End Sub
- End Module
VB.NET-Quellcode
- Public Class Form1
- Public VerbundenBad As Integer 'Adresse 0
- Public VerbundenWohnzimmer As Integer 'Adresse 1
- Public VerbundenKüche As Integer ''Adresse 2
- Public VerbundenSchlafzimmer As Integer ' Adresse 3
- Public LichtBad0 As Integer
- Public LichtBad1 As Integer
- Public LichtBad2 As Integer
- Public RauchmelderBad As CheckBox
- Public BewegungsmelderBad As CheckBox
- Public LichtschalterBad0 As CheckBox
- Public LichtschalterBad1 As CheckBox
- Public LichtschalterBad2 As CheckBox
- Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
- VerbindenBad()
- VerbindenKüche()
- VerbindenSchlafzimmer()
- VerbindenWohnzimmer()
- MsgBox(VerbundenBad & VerbundenKüche & VerbundenSchlafzimmer & VerbundenWohnzimmer)
- End Sub
- Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
- Test()
- End Sub
- Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
- test1()
- End Sub
- End Class