Private Sub Receiver_Receive (FirstTime As Boolean, StartingIntent As Intent)
imageFiles = Array As String("alarm1.png", "alarm1_cut.png")
timerInterval=5
If FirstTime Then
rv = ConfigureHomeWidget("wid", "rv", 31, "TankMonitor Widget")
End If
rv.HandleWidgetEvents(StartingIntent)
tmr.Initialize("tmr",2000)
tmr.Enabled=True
timerToSetAlarmOn= TIMER_DEFAULT_ALARM_ON
StartService(Socket_Service)
setDefaults
readSettings
End Sub
private Sub rv_Disabled
StopService(Socket_Service)
End Sub
Private Sub rv_RequestUpdate
SetTime
rv.UpdateWidget
End Sub
Sub tmr_Tick
If timerToSetAlarmOn>0 Then timerToSetAlarmOn = timerToSetAlarmOn - 1
tmr.Enabled= False
tmr.Interval= timerInterval * 1000
tmr.Enabled= True
updateViews
rv_RequestUpdate
End Sub
Sub updateViews
If IsPaused(Socket_Service) Then
StartService(Socket_Service)
tmr.Enabled= False
tmr.Interval= 1000
tmr.Enabled= True
rv.SetText("lblStatus","Service Starting...")
rv.UpdateWidget
End If
If Socket_Service.running Then
If Socket_Service.connectedIP<>"" Then
rv.SetText("lblStatus",Socket_Service.connectedIP)
End If
End If
End Sub
Private Sub SetTime
rv.SetText("lblUpTime", DateTime.Time(DateTime.Now))
End Sub
private Sub setDefaults
Socket_Service.myTanks(0).Capacity =20000
Socket_Service.myTanks(1).Capacity =20000
Socket_Service.myTanks(2).Capacity =20000
Socket_Service.myTanks(3).Capacity =20000
Socket_Service.myTanks(4).Capacity =20000
Socket_Service.myTanks(5).Capacity =20000
Socket_Service.TankNumbers= 2
Socket_Service.directConnect = True
IP = "192.168.1.34"
End Sub