VERSION 5.00
Begin VB.Form Test_InpOutt32 
   Caption         =   "Test Inpout32"
   ClientHeight    =   9180
   ClientLeft      =   915
   ClientTop       =   1410
   ClientWidth     =   12090
   LinkTopic       =   "Form1"
   PaletteMode     =   1  'UseZOrder
   ScaleHeight     =   9180
   ScaleWidth      =   12090
   Begin VB.CommandButton m4 
      Caption         =   "m4"
      Height          =   495
      Left            =   7800
      TabIndex        =   15
      Top             =   2880
      Width           =   495
   End
   Begin VB.CommandButton m3 
      Caption         =   "m3"
      Height          =   495
      Left            =   7800
      TabIndex        =   14
      Top             =   3840
      Width           =   495
   End
   Begin VB.CommandButton m2 
      Caption         =   "m2"
      Height          =   495
      Left            =   7800
      TabIndex        =   13
      Top             =   4800
      Width           =   495
   End
   Begin VB.CommandButton m1 
      Caption         =   "m1"
      Height          =   495
      Left            =   7800
      TabIndex        =   12
      Top             =   5880
      Width           =   495
   End
   Begin VB.Frame Frame2 
      Caption         =   "Valeur capteur"
      Height          =   255
      Left            =   120
      TabIndex        =   11
      Top             =   1080
      Width           =   1935
   End
   Begin VB.Frame Frame1 
      Caption         =   "Programmation de l'ascenseur sous VB"
      Height          =   495
      Left            =   2280
      TabIndex        =   10
      Top             =   120
      Width           =   5415
   End
   Begin VB.TextBox Text2 
      Height          =   375
      Left            =   5280
      TabIndex        =   9
      Text            =   "Text2"
      Top             =   1320
      Width           =   6015
   End
   Begin VB.CommandButton etage4 
      Caption         =   "etage4"
      Height          =   495
      Left            =   9720
      TabIndex        =   8
      Top             =   2880
      Width           =   1335
   End
   Begin VB.CommandButton etage3 
      Caption         =   "etage3"
      Height          =   495
      Left            =   9720
      TabIndex        =   7
      Top             =   3840
      Width           =   1335
   End
   Begin VB.CommandButton etage2 
      Caption         =   "etage2"
      Height          =   495
      Left            =   9720
      TabIndex        =   6
      Top             =   4800
      Width           =   1335
   End
   Begin VB.CommandButton etage1 
      Caption         =   "etage1"
      Height          =   495
      Left            =   9720
      TabIndex        =   5
      Top             =   5880
      Width           =   1335
   End
   Begin VB.Timer Timer1 
      Interval        =   10
      Left            =   2640
      Top             =   2280
   End
   Begin VB.CommandButton lire_port 
      Caption         =   "lire_port"
      Height          =   495
      Left            =   240
      TabIndex        =   4
      Top             =   2280
      Width           =   1215
   End
   Begin VB.CommandButton arreter 
      Caption         =   "Arreter"
      Height          =   735
      Left            =   4920
      TabIndex        =   3
      Top             =   3600
      Width           =   1815
   End
   Begin VB.CommandButton descendre 
      Caption         =   "Descendre"
      Height          =   735
      Left            =   2520
      TabIndex        =   2
      Top             =   3600
      Width           =   1815
   End
   Begin VB.TextBox Text1 
      Height          =   372
      Left            =   120
      TabIndex        =   1
      Text            =   "Text1"
      Top             =   1440
      Width           =   2052
   End
   Begin VB.CommandButton monter 
      Caption         =   "Monter"
      Height          =   732
      Left            =   120
      TabIndex        =   0
      Top             =   3600
      Width           =   1932
   End
End
Attribute VB_Name = "Test_InpOutt32"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim Value, i, etage_courant, c_etage1, c_etage2, c_etage3, c_etage4, ordre As Integer


Dim PortAddress1, PortAddress2, code As Integer

Private Sub Form_Load()

PortAddress1 = &H378
PortAddress2 = &H379

c_etage1 = 0
c_etage2 = 0
c_etage3 = 0
c_etage4 = 0


End Sub


Private Sub Command1_Click()


  
End Sub



Private Sub Command2_Click()


End Sub

Private Sub Command3_Click()


 

End Sub

Private Sub Command4_Click()





End Sub

Private Sub etage1_Click()
  etage_courant = Inp(&H379)
  If etage_courant = 0 Then
    Text2.Text = "Ascenseur entre 2 étages. Positionner le ŕ un étage précis"
  Else
    
  If etage_courant = bidon Or etage_courant = bidon Or etage_courant = bidon Then 'descend
    
    Do
      Out &H378, 2         ' commande pour descendre
      code = Inp(&H379)
    Loop Until code = c_etage1
    Out &H378, 0            ' stop
    
  End If
  
  
  Text2.Text = " Etage 1 atteint "
  End If
  
End Sub

Private Sub etage2_Click()

etage_courant = Inp(&H379)
  If etage_courant = 0 Then
    Text2.Text = "Ascenseur entre 2 étages. Positionner le ŕ un étage précis"
  Else
    
    If etage_courant = bidon Or etage_courant = bidon Then   ' on descend
    
      Do
        Out &H378, 2         ' commande pour descendre
        code = Inp(&H379)
      Loop Until code = c_etage2
      Out &H378, 0            ' stop
    
    
    Else                      ' sinon on monte
   
      Do
        Out &H378, 1         ' commande pour monter
        code = Inp(&H379)
     Loop Until code = c_etage2
      Out &H378, 0            ' stop
    
    End If
     
  Text2.Text = " Etage 2 atteint "
  End If
  











End Sub

Private Sub etage3_Click()
etage_courant = Inp(&H379)
  If etage_courant = 0 Then
    Text2.Text = "Ascenseur entre 2 étages. Positionner le ŕ un étage précis"
  Else
    
    If etage_courant = bidon Then    ' on descend
    
      Do
        Out &H378, 2         ' commande pour descendre
        code = Inp(&H379)
      Loop Until code = c_etage3
      Out &H378, 0            ' stop
    
    
    Else  '                         sinon on monte
   
      Do
        Out &H378, 1         ' commande pour monter
        code = Inp(&H379)
     Loop Until code = c_etage3
      Out &H378, 0            ' stop
    
    End If
     
  Text2.Text = " Etage 3 atteint "
  End If
End Sub

Private Sub etage4_Click()
etage_courant = Inp(&H379)
  If etage_courant = 0 Then
    Text2.Text = "Ascenseur entre 2 étages. Positionner le ŕ un étage précis"
  Else
          
      Do
        Out &H378, 1         ' commande pour monter
        code = Inp(&H379)
     Loop Until code = c_etage4
      Out &H378, 0            ' stop
    
     
  Text2.Text = " Etage 4 atteint "
  End If
End Sub




Private Sub lire_port_Click()
Text1.Text = Inp(PortAddress2)
End Sub

Private Sub Timer1_Timer()
  Text1.Text = Inp(PortAddress2)
End Sub
