Folge dem Video um zu sehen, wie unsere Website als Web-App auf dem Startbildschirm installiert werden kann.
Anmerkung: Diese Funktion ist in einigen Browsern möglicherweise nicht verfügbar.
Und genauso solls beim Testen auch gewesen sein.können bis zu 8 verschiedene Geräte zu unterschiedlichen Zeiten ein- oder ausgeschaltet werden.
Public Declare Function OPENCOM Lib "Port" (ByVal A As String) As Integer
Public Declare Function READBYTE Lib "Port" () As Integer
Public Declare Function CTS Lib "Port" () As Integer
Public Declare Function DSR Lib "Port" () As Integer
Public Declare Function RI Lib "Port" () As Integer
Public Declare Function DCD Lib "Port" () As Integer
Public Declare Function TIMEREAD Lib "Port" () As Long
Public Declare Function TIMEREADUS Lib "Port" () As Long
Public Declare Function INPORT Lib "Port" (ByVal p As Integer) As Integer
'Public Declare Function JOYX Lib "Port" () As Long
'Public Declare Function JOYY Lib "Port" () As Long
'Public Declare Function JOYZ Lib "Port" () As Long
'Public Declare Function JOYW Lib "Port" () As Long
'Public Declare Function JOYBUTTON Lib "Port" () As Integer
'Public Declare Function SOUNDSETRATE Lib "Port" (ByVal Rate As Integer) As Integer
'Public Declare Function SOUNDGETRATE Lib "Port" () As Integer
'Public Declare Function SOUNDBUSY Lib "Port" () As Boolean
'Public Declare Function SOUNDIS Lib "Port" () As Boolean
'Public Declare Function SOUNDGETBYTES Lib "Port" () As Integer
'Public Declare Function SOUNDSETBYTES Lib "Port" (ByVal b As Integer) As Integer
Public Declare Sub CLOSECOM Lib "Port" ()
Public Declare Sub SENDBYTE Lib "Port" (ByVal B As Integer)
Public Declare Sub DTR Lib "Port" (ByVal B As Integer)
Public Declare Sub RTS Lib "Port" (ByVal B As Integer)
Public Declare Sub TXD Lib "Port" (ByVal B As Integer)
Public Declare Sub DELAY Lib "Port" (ByVal B As Integer)
Public Declare Sub DELAYUS Lib "Port" (ByVal L As Long)
Public Declare Sub TIMEINIT Lib "Port" ()
Public Declare Sub TIMEINITUS Lib "Port" ()
Public Declare Sub REALTIME Lib "Port" (ByVal i As Boolean)
Public Declare Sub OUTPORT Lib "Port" (ByVal A As Integer, ByVal B As Integer)
'Public Declare Sub SOUNDIN Lib "Port" (ByVal Puffer As String, ByVal Size As Integer)
'Public Declare Sub SOUNDOUT Lib "Port" (ByVal Puffer As String, ByVal Size As Integer)
'Public Declare Sub SOUNDCAPIN Lib "Port" ()
'Public Declare Sub SOUNDCAPOUT Lib "Port" ()
Public Function BinOfDec(ByVal Number As String, Optional length As Integer) As String
Dim D, B, L, wk, C
D = Number
L = 0
If length = Empty Then
Do
If D Mod 2 Then B = "1" & B Else B = "0" & B
D = D \ 2
Loop Until D = 0
Else
Do
If D Mod 2 Then B = "1" & B Else B = "0" & B
D = D \ 2
L = L + 1
Loop Until L = length
End If
If Number < 0 And length = 8 Then GoTo TwosCompliment
GoTo BinAns
TwosCompliment:
L = Len(B)
D = 0
C = 1
For D = L To 1 Step -1
wk = Mid(B, D, 1)
If wk = 1 Then wk = 0 Else wk = 1
If wk = 1 And C = 1 Then
wk = 0
C = 1
ElseIf wk = 0 And C = 1 Then
wk = 1
C = 0
ElseIf wk = 1 And C = 0 Then
wk = 1
C = 0
ElseIf wk = 0 And C = 0 Then
wk = 0
C = 0
End If
BinOfDec = BinOfDec & wk
Next D
Exit Function
BinAns:
BinOfDec = B
End Function
Dim ADR As Integer
Dim WADR As Integer
Dim AD0 As Boolean
Dim AD1 As Boolean
Dim AD2 As Boolean
Dim AD3 As Boolean
Dim AD4 As Boolean
Dim AD5 As Boolean
Dim AD6 As Boolean
Dim AD7 As Boolean
Dim DD(8) As Boolean
Dim Opened As Boolean
Private Sub UserControl_Resize()
On Error Resume Next
On Error Resume Next
UserControl.Width = Label1.Width
UserControl.Height = Label1.Height
End Sub
Public Function Open_Port(Parameter As String) As Boolean
On Error Resume Next
Dim X As Integer
If Opened = False Then
X = OPENCOM(Parameter)
If X = 0 Then
Open_Port = False
Else
'Com1=1016
'Com2=760
'Com3=1000
'LPT1=888
ADR = 0
If InStrRev(Parameter, ":") > 0 Then
Select Case UCase(Mid(Parameter, 1, InStr(1, Parameter, ":") - 1))
Case "COM1": ADR = 1016
Case "COM2": ADR = 760
Case "COM3": ADR = 1000
End Select
Else
Select Case UCase(Parameter)
Case "LPT1"
ADR = 888
WADR = 889
End Select
End If
Opened = True
Open_Port = True
End If
Else
Open_Port = False
End If
End Function
Public Function Close_Port() As Boolean
On Error Resume Next
If Opened = True Then
CLOSECOM
Opened = False
Close_Port = True
Else
Close_Port = False
End If
End Function
Public Function Seriel_IN_CTS() As Boolean
On Error Resume Next
If CTS = 0 Then
Seriel_IN_CTS = False
Else
Seriel_IN_CTS = True
End If
End Function
Public Function Seriel_IN_DSR() As Boolean
On Error Resume Next
If DSR = 0 Then
Seriel_IN_DSR = False
Else
Seriel_IN_DSR = True
End If
End Function
Public Function Seriel_IN_RI() As Boolean
On Error Resume Next
If RI = 0 Then
Seriel_IN_RI = False
Else
Seriel_IN_RI = True
End If
End Function
Public Function Seriel_IN_DCD() As Boolean
On Error Resume Next
If DCD = 0 Then
Seriel_IN_DCD = False
Else
Seriel_IN_DCD = True
End If
End Function
Public Function Seriel_OUT_DTR(Value As Boolean)
On Error Resume Next
If Value = False Then
DTR 0
Else
DTR 1
End If
End Function
Public Function Seriel_OUT_RTS(Value As Boolean)
On Error Resume Next
If Value = False Then
RTS 0
Else
RTS 1
End If
End Function
Public Function Seriel_OUT_TXD(Value As Boolean)
On Error Resume Next
If Value = False Then
TXD 0
Else
TXD 1
End If
End Function
Public Function Port_OUT_Data(Adresse As Integer, Data As Integer)
On Error Resume Next
OUTPORT Adresse, Data
End Function
Public Function Port_IN_Data(Adresse As Integer) As Integer
On Error Resume Next
Port_IN_Data = INPORT(Adresse)
End Function
Public Function Set_RealTime(Value As Boolean)
On Error Resume Next
REALTIME Value
End Function
Public Function Port_ReadByte() As Integer
On Error Resume Next
Port_ReadByte = READBYTE
End Function
Public Function Port_SendByte(Data As Integer)
On Error Resume Next
SENDBYTE Data
End Function
Public Function Delay_Sek(Time As Integer)
On Error Resume Next
DELAY Time
End Function
Public Function Delay_USek(Time As Long)
On Error Resume Next
DELAYUS Time
End Function
Public Function Time_Init_Sek()
On Error Resume Next
TIMEINIT
End Function
Public Function Time_Init_USek()
On Error Resume Next
TIMEINITUS
End Function
Public Function Time_Read_Sek() As Integer
On Error Resume Next
Time_Read_Sek = TIMEREAD
End Function
Public Function Time_Read_USek() As Integer
On Error Resume Next
Time_Read_USek = TIMEREADUS
End Function
Public Function Set_Adresse(Adresse As Integer)
On Error Resume Next
ADR = Adresse
End Function
Public Function Set_WriteAdresse(Adresse As Integer)
On Error Resume Next
WADR = Adresse
End Function
Public Function Parallel_IN_SELECT() As Boolean
On Error Resume Next
If Mid(BinOfDec(INPORT(ADR + 1), 8), 4, 1) = 1 Then
Parallel_IN_SELECT = True
Else
Parallel_IN_SELECT = False
End If
End Function
Public Function Parallel_IN_PE() As Boolean
On Error Resume Next
If Mid(BinOfDec(INPORT(ADR + 1), 8), 3, 1) = 1 Then
Parallel_IN_PE = True
Else
Parallel_IN_PE = False
End If
End Function
Public Function Parallel_IN_BUSY() As Boolean
On Error Resume Next
If Mid(BinOfDec(INPORT(ADR + 1), 8), 1, 1) = 1 Then
Parallel_IN_BUSY = True
Else
Parallel_IN_BUSY = False
End If
End Function
Public Function Parallel_IN_ACK() As Boolean
On Error Resume Next
If Mid(BinOfDec(INPORT(ADR + 1), 8), 2, 1) = 1 Then
Parallel_IN_ACK = True
Else
Parallel_IN_ACK = False
End If
End Function
Public Function Parallel_IN_ERROR() As Boolean
On Error Resume Next
If Mid(BinOfDec(INPORT(ADR + 1), 8), 5, 1) = 1 Then
Parallel_IN_ERROR = True
Else
Parallel_IN_ERROR = False
End If
End Function
Public Function Parallel_IN_D(Bit As Integer) As Boolean
On Error Resume Next
If Mid(BinOfDec(INPORT(ADR + 6), 8), 8 - (Bit - 1), 1) = 1 Then
Parallel_IN_D = True
Else
Parallel_IN_D = False
End If
End Function
Public Function Parallel_IN_STROBE() As Boolean
On Error Resume Next
If Mid(BinOfDec(INPORT(ADR + 2), 8), 8, 1) = 0 Then
Parallel_IN_STROBE = True
Else
Parallel_IN_STROBE = False
End If
End Function
Public Function Parallel_IN_AUTOFEED() As Boolean
On Error Resume Next
If Mid(BinOfDec(INPORT(ADR + 2), 8), 7, 1) = 0 Then
Parallel_IN_AUTOFEED = True
Else
Parallel_IN_AUTOFEED = False
End If
End Function
Public Function Parallel_IN_INIT() As Boolean
On Error Resume Next
If Mid(BinOfDec(INPORT(ADR + 2), 8), 6, 1) = 1 Then
Parallel_IN_INIT = True
Else
Parallel_IN_INIT = False
End If
End Function
Public Function Parallel_IN_SLCT() As Boolean
On Error Resume Next
If Mid(BinOfDec(INPORT(ADR + 2), 8), 5, 1) = 0 Then
Parallel_IN_SLCT = True
Else
Parallel_IN_SLCT = False
End If
End Function
Public Function Parallel_OUT_STROBE(Value As Boolean)
On Error Resume Next
Dim B As String
B = BinOfDec(INPORT(ADR + 2))
If Value = True Then
Else
End If
End Function
Public Function Parallel_OUT_AUTOFEED(Value As Boolean)
On Error Resume Next
End Function
Public Function Parallel_OUT_INIT(Value As Boolean)
On Error Resume Next
End Function
Public Function Parallel_OUT_SLCT(Value As Boolean)
On Error Resume Next
End Function
Public Function Parallel_OUT_D(Value As Integer)
On Error Resume Next
OUTPORT ADR, Value
End Function
Public Function Parallel_OUT_DD(Bit As Integer, Value As Boolean)
On Error Resume Next
Dim X As Integer
Dim OD As Integer
DD(Bit) = Value
OD = 0
For X = 1 To 8
If DD(X) = True Then
OD = OD + (2 ^ (X - 1))
End If
Next
OUTPORT ADR, OD
End Function
Private Sub UserControl_Terminate()
On Error Resume Next
If Opened = True Then
CLOSECOM
End If
End Sub
Public Function CheckPortOpen() As Boolean
On Error Resume Next
CheckPortOpen = Opened
End Function
Dim LV As Boolean
Private Sub Check1_Click(Index As Integer)
Port1.Parallel_OUT_DD Index + 1, CBool(Check1(Index).Value)
End Sub
Private Sub Form_Load()
Dim NV As Boolean
NV = Port1.Open_Port("LPT1")
Port1.Parallel_OUT_D 0
MsgBox NV
End Sub
Private Sub Form_Unload(Cancel As Integer)
Port1.Close_Port
End Sub
Private Sub Timer1_Timer()
If Port1.CheckPortOpen = True Then
Dim TV As Boolean
TV = Port1.Parallel_IN_ACK
If TV = False Then
Shape1.BackColor = vbGreen
Else
Shape1.BackColor = vbRed
End If
If LV <> TV Then
ChangeV TV
End If
LV = TV
End If
End Sub
Public Function ChangeV(NewValue As Boolean)
Dim X As Long
If NewValue = False Then
For X = 0 To 7
Check1(X).Value = Check1(X + 8).Value
Next
Else
For X = 0 To 7
Check1(X).Value = 0
Next
End If
End Function