#Region Project Attributes
#ApplicationLabel: Control Home
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: portrait
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: true
#IncludeTitle: false
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim GeneralTimer As Timer
End Sub
Sub Globals
Private boton As ImageView
Private puerta1 As Boolean
Private time1 As Long
Dim realtime As FirebaseDatabase
Dim ref As DatabaseReference
End Sub
Sub Activity_Create(FirstTime As Boolean)
realtime.Initialize("Realtime")
realtime.PersistenceEnabled = True
realtime.goOnline
ref.Initialize("Reference",realtime.getReferencefromUrl("https://controlhome-xxxxx.firebaseio.com/"))
ref.addChildEventListener
ref.addListenerForSingleValueEvent
ref.addValueEventListener
GeneralTimer.Initialize("GeneralTimer",300)
GeneralTimer.Enabled=True
boton.Initialize("boton")
Activity.AddView(boton,10%x,10%y,40%x,20%y)
boton.Bitmap=LoadBitmap(File.DirAssets,"llave.png")
boton.Gravity=Gravity.FILL
puerta1=False
End Sub
Sub boton_click
Dim childUpdates As Map' ++++++++++++++++++++++++++++++++++++++++++++++++++++++
childUpdates.Initialize
childUpdates.Put("puerta1","abrir")
ref.updateChildren(childUpdates) ' +++++++++++++++++++++++++++++++++++++++++
time1=DateTime.now
puerta1=True
End Sub
Sub GeneralTimer_Tick
If puerta1=True Then
If time1+3000<DateTime.Now Then
Dim childUpdates As Map' ++++++++++++++++++++++++++++++++++++++++++++++
childUpdates.Initialize
childUpdates.Put("puerta1","cerrar")
ref.updateChildren(childUpdates) ' +++++++++++++++++++++++++++++++++
puerta1=False
End If
End If
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub