package b4a.smarthomeapp;

import anywheresoftware.b4a.B4AMenuItem;
import android.app.Activity;
import android.os.Bundle;
import anywheresoftware.b4a.BA;
import anywheresoftware.b4a.BALayout;
import anywheresoftware.b4a.B4AActivity;
import anywheresoftware.b4a.ObjectWrapper;
import anywheresoftware.b4a.objects.ActivityWrapper;
import java.lang.reflect.InvocationTargetException;
import anywheresoftware.b4a.B4AUncaughtException;
import anywheresoftware.b4a.debug.*;
import java.lang.ref.WeakReference;

public class main extends Activity implements B4AActivity{
	static main mostCurrent;
	static boolean afterFirstLayout;
	static boolean isFirst = true;
    private static boolean processGlobalsRun = false;
	BALayout layout;
	public static BA processBA;
	BA activityBA;
    ActivityWrapper _activity;
    java.util.ArrayList<B4AMenuItem> menuItems;
	private static final boolean fullScreen = true;
	private static final boolean includeTitle = false;
    public static WeakReference<Activity> previousOne;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		if (isFirst) {
			processBA = new BA(this.getApplicationContext(), null, null, "b4a.smarthomeapp", "main");
			processBA.loadHtSubs(this.getClass());
	        float deviceScale = getApplicationContext().getResources().getDisplayMetrics().density;
	        BALayout.setDeviceScale(deviceScale);
		}
		else if (previousOne != null) {
			Activity p = previousOne.get();
			if (p != null && p != this) {
                anywheresoftware.b4a.keywords.Common.Log("Killing previous instance (main).");
				p.finish();
			}
		}
		if (!includeTitle) {
        	this.getWindow().requestFeature(android.view.Window.FEATURE_NO_TITLE);
        }
        if (fullScreen) {
        	getWindow().setFlags(android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN,   
        			android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN);
        }
		mostCurrent = this;
        processBA.activityBA = null;
		layout = new BALayout(this);
		setContentView(layout);
		afterFirstLayout = false;
		BA.handler.postDelayed(new WaitForLayout(), 5);

	}
	private static class WaitForLayout implements Runnable {
		public void run() {
			if (afterFirstLayout)
				return;
			if (mostCurrent.layout.getWidth() == 0) {
				BA.handler.postDelayed(this, 5);
				return;
			}
			mostCurrent.layout.getLayoutParams().height = mostCurrent.layout.getHeight();
			mostCurrent.layout.getLayoutParams().width = mostCurrent.layout.getWidth();
			afterFirstLayout = true;
			mostCurrent.afterFirstLayout();
		}
	}
	private void afterFirstLayout() {
		activityBA = new BA(this, layout, processBA, "b4a.smarthomeapp", "main");
        processBA.activityBA = new java.lang.ref.WeakReference<BA>(activityBA);
        _activity = new ActivityWrapper(activityBA, "activity");
        anywheresoftware.b4a.Msgbox.isDismissing = false;
        initializeProcessGlobals();		
        initializeGlobals();
        anywheresoftware.b4a.objects.ViewWrapper.lastId = 0;
        anywheresoftware.b4a.keywords.Common.Log("** Activity (main) Create, isFirst = " + isFirst + " **");
        processBA.raiseEvent2(null, true, "activity_create", false, isFirst);
		isFirst = false;
		if (mostCurrent == null || mostCurrent != this)
			return;
        processBA.setActivityPaused(false);
        anywheresoftware.b4a.keywords.Common.Log("** Activity (main) Resume **");
        processBA.raiseEvent(null, "activity_resume");

	}
	public void addMenuItem(B4AMenuItem item) {
		if (menuItems == null)
			menuItems = new java.util.ArrayList<B4AMenuItem>();
		menuItems.add(item);
	}
	@Override
	public boolean onCreateOptionsMenu(android.view.Menu menu) {
		super.onCreateOptionsMenu(menu);
		if (menuItems == null)
			return false;
		for (B4AMenuItem bmi : menuItems) {
			android.view.MenuItem mi = menu.add(bmi.title);
			if (bmi.drawable != null)
				mi.setIcon(bmi.drawable);
			mi.setOnMenuItemClickListener(new B4AMenuItemsClickListener(bmi.eventName.toLowerCase(BA.cul)));
		}
		return true;
	}
	private class B4AMenuItemsClickListener implements android.view.MenuItem.OnMenuItemClickListener {
		private final String eventName;
		public B4AMenuItemsClickListener(String eventName) {
			this.eventName = eventName;
		}
		public boolean onMenuItemClick(android.view.MenuItem item) {
			processBA.raiseEvent(item.getTitle(), eventName + "_click");
			return true;
		}
	}
    public static Class<?> getObject() {
		return main.class;
	}
    private Boolean onKeySubExist = null;
    private Boolean onKeyUpSubExist = null;
	@Override
	public boolean onKeyDown(int keyCode, android.view.KeyEvent event) {
		if (onKeySubExist == null)
			onKeySubExist = processBA.subExists("activity_keypress");
		if (onKeySubExist) {
			Boolean res =  (Boolean)processBA.raiseEvent2(_activity, false, "activity_keypress", false, keyCode);
			if (res == null || res == true)
				return true;
		}
		return super.onKeyDown(keyCode, event);
	}
    @Override
	public boolean onKeyUp(int keyCode, android.view.KeyEvent event) {
		if (onKeyUpSubExist == null)
			onKeyUpSubExist = processBA.subExists("activity_keyup");
		if (onKeyUpSubExist) {
			Boolean res =  (Boolean)processBA.raiseEvent2(_activity, false, "activity_keyup", false, keyCode);
			if (res == null || res == true)
				return true;
		}
		return super.onKeyUp(keyCode, event);
	}
	@Override
	public void onNewIntent(android.content.Intent intent) {
		this.setIntent(intent);
	}
    @Override 
	public void onPause() {
		super.onPause();
        if (_activity == null) //workaround for emulator bug (Issue 2423)
            return;
		anywheresoftware.b4a.Msgbox.dismiss(true);
        anywheresoftware.b4a.keywords.Common.Log("** Activity (main) Pause, UserClosed = " + activityBA.activity.isFinishing() + " **");
        processBA.raiseEvent2(_activity, true, "activity_pause", false, activityBA.activity.isFinishing());		
        processBA.setActivityPaused(true);
        mostCurrent = null;
        if (!activityBA.activity.isFinishing())
			previousOne = new WeakReference<Activity>(this);
        anywheresoftware.b4a.Msgbox.isDismissing = false;
	}

	@Override
	public void onDestroy() {
        super.onDestroy();
		previousOne = null;
	}
    @Override 
	public void onResume() {
		super.onResume();
        mostCurrent = this;
        anywheresoftware.b4a.Msgbox.isDismissing = false;
        if (activityBA != null) { //will be null during activity create (which waits for AfterLayout).
        	ResumeMessage rm = new ResumeMessage(mostCurrent);
        	BA.handler.post(rm);
        }
	}
    private static class ResumeMessage implements Runnable {
    	private final WeakReference<Activity> activity;
    	public ResumeMessage(Activity activity) {
    		this.activity = new WeakReference<Activity>(activity);
    	}
		public void run() {
			if (mostCurrent == null || mostCurrent != activity.get())
				return;
			processBA.setActivityPaused(false);
            anywheresoftware.b4a.keywords.Common.Log("** Activity (main) Resume **");
		    processBA.raiseEvent(mostCurrent._activity, "activity_resume", (Object[])null);
		}
    }
	@Override
	protected void onActivityResult(int requestCode, int resultCode,
	      android.content.Intent data) {
		processBA.onActivityResult(requestCode, resultCode, data);
	}
	private static void initializeGlobals() {
		processBA.raiseEvent2(null, true, "globals", false, (Object[])null);
	}

public anywheresoftware.b4a.keywords.Common __c = null;
public static anywheresoftware.b4a.objects.MediaPlayerWrapper _mp = null;
public static anywheresoftware.b4a.objects.Serial _serial1 = null;
public static anywheresoftware.b4a.randomaccessfile.AsyncStreams _astreams = null;
public static anywheresoftware.b4a.objects.Serial.BluetoothAdmin _badmin = null;
public static boolean _connected = false;
public static String _sensors = "";
public static String _s = "";
public static String _sb = "";
public static boolean _fullrx = false;
public anywheresoftware.b4a.agraham.dialogs.InputDialog.NumberDialog _numdial = null;
public anywheresoftware.b4a.agraham.dialogs.InputDialog _inpbox = null;
public anywheresoftware.b4a.objects.Timer _t1 = null;
public anywheresoftware.b4a.objects.Timer _t2 = null;
public static int _i = 0;
public anywheresoftware.b4a.objects.AnimationWrapper _animate1 = null;
public anywheresoftware.b4a.objects.AnimationWrapper _animate2 = null;
public anywheresoftware.b4a.objects.AnimationWrapper _panimate1 = null;
public anywheresoftware.b4a.objects.ImageViewWrapper _imageview1 = null;
public anywheresoftware.b4a.objects.ImageViewWrapper _imageview2 = null;
public anywheresoftware.b4a.objects.LabelWrapper _label1 = null;
public anywheresoftware.b4a.objects.LabelWrapper _label2 = null;
public anywheresoftware.b4a.objects.LabelWrapper _label3 = null;
public anywheresoftware.b4a.objects.LabelWrapper _label4 = null;
public anywheresoftware.b4a.objects.LabelWrapper _label5 = null;
public anywheresoftware.b4a.objects.LabelWrapper _label6 = null;
public anywheresoftware.b4a.objects.LabelWrapper _labelfan = null;
public anywheresoftware.b4a.objects.LabelWrapper _labellight1 = null;
public anywheresoftware.b4a.objects.LabelWrapper _labellight2 = null;
public anywheresoftware.b4a.objects.LabelWrapper _labeltelevision = null;
public anywheresoftware.b4a.objects.PanelWrapper _panelappliances = null;
public anywheresoftware.b4a.objects.ButtonWrapper _buttondoor = null;
public anywheresoftware.b4a.objects.ButtonWrapper _buttonsenfan = null;
public anywheresoftware.b4a.objects.ButtonWrapper _buttonsenlight1 = null;
public anywheresoftware.b4a.objects.ButtonWrapper _buttonsenlight2 = null;
public anywheresoftware.b4a.objects.ImageViewWrapper _imageappliance = null;
public anywheresoftware.b4a.objects.ImageViewWrapper _imagedoor = null;
public anywheresoftware.b4a.objects.ImageViewWrapper _imagedoorstatus = null;
public anywheresoftware.b4a.objects.ImageViewWrapper _imagesensomate = null;
public anywheresoftware.b4a.objects.ImageViewWrapper _imagesensors = null;
public anywheresoftware.b4a.objects.ImageViewWrapper _imagesettings = null;
public anywheresoftware.b4a.objects.LabelWrapper _label10 = null;
public anywheresoftware.b4a.objects.LabelWrapper _label11 = null;
public anywheresoftware.b4a.objects.LabelWrapper _label12 = null;
public anywheresoftware.b4a.objects.LabelWrapper _label13 = null;
public anywheresoftware.b4a.objects.LabelWrapper _label14 = null;
public anywheresoftware.b4a.objects.LabelWrapper _label15 = null;
public anywheresoftware.b4a.objects.LabelWrapper _label16 = null;
public anywheresoftware.b4a.objects.LabelWrapper _label17 = null;
public anywheresoftware.b4a.objects.LabelWrapper _label18 = null;
public anywheresoftware.b4a.objects.LabelWrapper _label7 = null;
public anywheresoftware.b4a.objects.LabelWrapper _label8 = null;
public anywheresoftware.b4a.objects.LabelWrapper _label9 = null;
public anywheresoftware.b4a.objects.LabelWrapper _labeldoorstatus = null;
public anywheresoftware.b4a.objects.LabelWrapper _labellightin = null;
public anywheresoftware.b4a.objects.LabelWrapper _labellightout = null;
public anywheresoftware.b4a.objects.LabelWrapper _labelmotion = null;
public anywheresoftware.b4a.objects.LabelWrapper _labeltempin = null;
public anywheresoftware.b4a.objects.LabelWrapper _labeltempout = null;
public anywheresoftware.b4a.objects.PanelWrapper _paneldoor = null;
public anywheresoftware.b4a.objects.PanelWrapper _panelsensomate = null;
public anywheresoftware.b4a.objects.PanelWrapper _panelsensors = null;
public anywheresoftware.b4a.objects.PanelWrapper _panelsettings = null;
public anywheresoftware.b4a.objects.ButtonWrapper _buttonsavelog = null;
public anywheresoftware.b4a.objects.ButtonWrapper _buttonbluetoothswitch = null;
public anywheresoftware.b4a.objects.ImageViewWrapper _imageview3 = null;
public anywheresoftware.b4a.objects.LabelWrapper _label19 = null;
public anywheresoftware.b4a.objects.LabelWrapper _labelbluetoothstatus = null;
public anywheresoftware.b4a.objects.ButtonWrapper _buttonconnect = null;
public anywheresoftware.b4a.objects.ButtonWrapper _buttonsenmotion = null;
public anywheresoftware.b4a.objects.LabelWrapper _label20 = null;
public anywheresoftware.b4a.objects.ButtonWrapper _buttonpassword = null;
public anywheresoftware.b4a.objects.ButtonWrapper _buttonalloff = null;
public anywheresoftware.b4a.objects.ButtonWrapper _buttonallon = null;
public anywheresoftware.b4a.objects.ButtonWrapper _buttonsleepmode = null;
public anywheresoftware.b4a.objects.PanelWrapper _panelabout = null;
public anywheresoftware.b4a.objects.LabelWrapper _labellpg = null;
public anywheresoftware.b4a.objects.ButtonWrapper _buttonfanoff = null;
public anywheresoftware.b4a.objects.ButtonWrapper _buttonfanon = null;
public anywheresoftware.b4a.objects.ButtonWrapper _buttonlight1off = null;
public anywheresoftware.b4a.objects.ButtonWrapper _buttonlight1on = null;
public anywheresoftware.b4a.objects.ButtonWrapper _buttonlight2off = null;
public anywheresoftware.b4a.objects.ButtonWrapper _buttonlight2on = null;
public anywheresoftware.b4a.objects.ButtonWrapper _buttontvoff = null;
public anywheresoftware.b4a.objects.ButtonWrapper _buttontvon = null;
public anywheresoftware.b4a.objects.ButtonWrapper _buttonresetautoconnect = null;
public anywheresoftware.b4a.objects.ButtonWrapper _buttonsleepmodeoff = null;
public anywheresoftware.b4a.objects.ImageViewWrapper _imageview4 = null;
public anywheresoftware.b4a.objects.ImageViewWrapper _imageview5 = null;
public anywheresoftware.b4a.objects.ImageViewWrapper _imageview6 = null;
public anywheresoftware.b4a.objects.ImageViewWrapper _imageview7 = null;
public anywheresoftware.b4a.objects.LabelWrapper _label21 = null;
public anywheresoftware.b4a.objects.LabelWrapper _label22 = null;
public anywheresoftware.b4a.objects.LabelWrapper _label23 = null;
public anywheresoftware.b4a.objects.ButtonWrapper _buttonprogfire = null;
public static String  _activity_create(boolean _firsttime) throws Exception{
 //BA.debugLineNum = 103;BA.debugLine="Sub Activity_Create(FirstTime As Boolean)";
 //BA.debugLineNum = 104;BA.debugLine="Activity.LoadLayout(\"frontintro\")	'load the layout file onto activity";
mostCurrent._activity.LoadLayout("frontintro",mostCurrent.activityBA);
 //BA.debugLineNum = 105;BA.debugLine="If FirstTime Then'process starts";
if (_firsttime) { 
 //BA.debugLineNum = 106;BA.debugLine="mp.Initialize	'initialize the media player";
_mp.Initialize();
 //BA.debugLineNum = 107;BA.debugLine="badmin.Initialize(\"badmin\")";
_badmin.Initialize(processBA,"badmin");
 //BA.debugLineNum = 108;BA.debugLine="serial1.Initialize(\"Serial1\")";
_serial1.Initialize("Serial1");
 };
 //BA.debugLineNum = 111;BA.debugLine="connected=False";
_connected = anywheresoftware.b4a.keywords.Common.False;
 //BA.debugLineNum = 114;BA.debugLine="Panelappliances.Visible=False";
mostCurrent._panelappliances.setVisible(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 115;BA.debugLine="Panelsensors.Visible=False";
mostCurrent._panelsensors.setVisible(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 116;BA.debugLine="Panelsensomate.Visible=False";
mostCurrent._panelsensomate.setVisible(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 117;BA.debugLine="Paneldoor.Visible=False";
mostCurrent._paneldoor.setVisible(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 118;BA.debugLine="Panelsettings.Visible=False";
mostCurrent._panelsettings.setVisible(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 119;BA.debugLine="Panelabout.Visible=False";
mostCurrent._panelabout.setVisible(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 121;BA.debugLine="ImageView1.Visible=True	'enable the \"HOME\" image";
mostCurrent._imageview1.setVisible(anywheresoftware.b4a.keywords.Common.True);
 //BA.debugLineNum = 122;BA.debugLine="ImageView2.Visible=False	'disable the \"MOBILE\" image";
mostCurrent._imageview2.setVisible(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 123;BA.debugLine="Label1.Visible=False";
mostCurrent._label1.setVisible(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 124;BA.debugLine="Label2.Visible=False";
mostCurrent._label2.setVisible(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 125;BA.debugLine="Label3.Visible=False";
mostCurrent._label3.setVisible(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 126;BA.debugLine="Label4.Visible=False";
mostCurrent._label4.setVisible(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 127;BA.debugLine="Label5.Visible=False";
mostCurrent._label5.setVisible(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 128;BA.debugLine="i=0";
_i = (int)(0);
 //BA.debugLineNum = 129;BA.debugLine="t1.Initialize(\"t1\",700)";
mostCurrent._t1.Initialize(processBA,"t1",(long)(700));
 //BA.debugLineNum = 130;BA.debugLine="t2.Initialize(\"t2\",1500)	'delay between main animation and actual control panel";
mostCurrent._t2.Initialize(processBA,"t2",(long)(1500));
 //BA.debugLineNum = 131;BA.debugLine="t2.Enabled=False";
mostCurrent._t2.setEnabled(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 132;BA.debugLine="animate1.InitializeAlpha(\"animate1\",0,1)'used in animating the main animation label";
mostCurrent._animate1.InitializeAlpha(mostCurrent.activityBA,"animate1",(float)(0),(float)(1));
 //BA.debugLineNum = 133;BA.debugLine="animate1.Duration=1000";
mostCurrent._animate1.setDuration((long)(1000));
 //BA.debugLineNum = 134;BA.debugLine="animate2.InitializeAlpha(\"animate2\",0,1)'used in animating the main animation label";
mostCurrent._animate2.InitializeAlpha(mostCurrent.activityBA,"animate2",(float)(0),(float)(1));
 //BA.debugLineNum = 135;BA.debugLine="animate2.Duration=1000";
mostCurrent._animate2.setDuration((long)(1000));
 //BA.debugLineNum = 136;BA.debugLine="panimate1.InitializeAlpha(\"panimate1\",0,1)'used in animating the different panels";
mostCurrent._panimate1.InitializeAlpha(mostCurrent.activityBA,"panimate1",(float)(0),(float)(1));
 //BA.debugLineNum = 137;BA.debugLine="panimate1.Duration=1000";
mostCurrent._panimate1.setDuration((long)(1000));
 //BA.debugLineNum = 140;BA.debugLine="Activity.AddMenuItem(\"Appliances\",\"mnuappliances\")";
mostCurrent._activity.AddMenuItem("Appliances","mnuappliances");
 //BA.debugLineNum = 141;BA.debugLine="Activity.AddMenuItem(\"Sensors\",\"mnusensors\")";
mostCurrent._activity.AddMenuItem("Sensors","mnusensors");
 //BA.debugLineNum = 142;BA.debugLine="Activity.AddMenuItem(\"Door control\",\"mnudoor\")";
mostCurrent._activity.AddMenuItem("Door control","mnudoor");
 //BA.debugLineNum = 143;BA.debugLine="Activity.AddMenuItem(\"Sensomate\",\"mnusensomate\")";
mostCurrent._activity.AddMenuItem("Sensomate","mnusensomate");
 //BA.debugLineNum = 144;BA.debugLine="Activity.AddMenuItem(\"Settings\",\"mnusettings\")";
mostCurrent._activity.AddMenuItem("Settings","mnusettings");
 //BA.debugLineNum = 145;BA.debugLine="Activity.AddMenuItem(\"About\",\"mnuabout\")";
mostCurrent._activity.AddMenuItem("About","mnuabout");
 //BA.debugLineNum = 148;BA.debugLine="If File.IsDirectory(File.DirRootExternal,\"smarthome\")=False Then'check whether this folder already exists in the root directory";
if (anywheresoftware.b4a.keywords.Common.File.IsDirectory(anywheresoftware.b4a.keywords.Common.File.getDirRootExternal(),"smarthome")==anywheresoftware.b4a.keywords.Common.False) { 
 //BA.debugLineNum = 149;BA.debugLine="File.MakeDir(File.DirRootExternal,\"smarthome\")'if not make a folder in the root directory of SD card for storing sensor readings";
anywheresoftware.b4a.keywords.Common.File.MakeDir(anywheresoftware.b4a.keywords.Common.File.getDirRootExternal(),"smarthome");
 };
 //BA.debugLineNum = 153;BA.debugLine="If File.Exists(File.DirInternal,\"password.txt\")=False Then	'if the text file \"password.txt\" containing password does not exists";
if (anywheresoftware.b4a.keywords.Common.File.Exists(anywheresoftware.b4a.keywords.Common.File.getDirInternal(),"password.txt")==anywheresoftware.b4a.keywords.Common.False) { 
 //BA.debugLineNum = 154;BA.debugLine="File.WriteString(File.DirInternal,\"password.txt\",\"45206734\")	'the create it,with password=\"45206734\"";
anywheresoftware.b4a.keywords.Common.File.WriteString(anywheresoftware.b4a.keywords.Common.File.getDirInternal(),"password.txt","45206734");
 };
 //BA.debugLineNum = 157;BA.debugLine="If File.ReadString(File.DirInternal,\"password.txt\")<>\"\" Then 'password is enabled,something in the file";
if ((anywheresoftware.b4a.keywords.Common.File.ReadString(anywheresoftware.b4a.keywords.Common.File.getDirInternal(),"password.txt")).equals("") == false) { 
 //BA.debugLineNum = 158;BA.debugLine="inpbox.InputType=inpbox.INPUT_TYPE_TEXT";
mostCurrent._inpbox.setInputType(mostCurrent._inpbox.INPUT_TYPE_TEXT);
 //BA.debugLineNum = 159;BA.debugLine="inpbox.PasswordMode=True";
mostCurrent._inpbox.setPasswordMode(anywheresoftware.b4a.keywords.Common.True);
 //BA.debugLineNum = 160;BA.debugLine="If inpbox.Show(\"\",\"Enter login password :\",\"OK\",\"Cancel\",\"\",Null)=DialogResponse.POSITIVE Then 'request login password from user";
if (mostCurrent._inpbox.Show("","Enter login password :","OK","Cancel","",mostCurrent.activityBA,(android.graphics.Bitmap)(anywheresoftware.b4a.keywords.Common.Null))==anywheresoftware.b4a.keywords.Common.DialogResponse.POSITIVE) { 
 //BA.debugLineNum = 161;BA.debugLine="If inpbox.Input<>File.ReadString(File.DirInternal,\"password.txt\") Then'if password incorrect";
if ((mostCurrent._inpbox.getInput()).equals(anywheresoftware.b4a.keywords.Common.File.ReadString(anywheresoftware.b4a.keywords.Common.File.getDirInternal(),"password.txt")) == false) { 
 //BA.debugLineNum = 162;BA.debugLine="Msgbox(\"Incorrect password,try again!\",\"Error\")";
anywheresoftware.b4a.keywords.Common.Msgbox("Incorrect password,try again!","Error",mostCurrent.activityBA);
 //BA.debugLineNum = 163;BA.debugLine="ExitApplication";
anywheresoftware.b4a.keywords.Common.ExitApplication();
 };
 }else {
 //BA.debugLineNum = 166;BA.debugLine="ExitApplication";
anywheresoftware.b4a.keywords.Common.ExitApplication();
 };
 };
 //BA.debugLineNum = 171;BA.debugLine="If File.Exists(File.DirInternal,\"mac.txt\")=False Then	'if the text file \"mac.txt\" containing host default MAC address does not exists";
if (anywheresoftware.b4a.keywords.Common.File.Exists(anywheresoftware.b4a.keywords.Common.File.getDirInternal(),"mac.txt")==anywheresoftware.b4a.keywords.Common.False) { 
 //BA.debugLineNum = 172;BA.debugLine="File.WriteString(File.DirInternal,\"mac.txt\",\"\")	'the create it,with null data";
anywheresoftware.b4a.keywords.Common.File.WriteString(anywheresoftware.b4a.keywords.Common.File.getDirInternal(),"mac.txt","");
 };
 //BA.debugLineNum = 175;BA.debugLine="disable_main_views			'disable all main buttons initially";
_disable_main_views();
 //BA.debugLineNum = 176;BA.debugLine="t1.Enabled=True				'start the animation";
mostCurrent._t1.setEnabled(anywheresoftware.b4a.keywords.Common.True);
 //BA.debugLineNum = 177;BA.debugLine="End Sub";
return "";
}
public static boolean  _activity_keypress(int _keycode) throws Exception{
 //BA.debugLineNum = 1012;BA.debugLine="Sub Activity_KeyPress (KeyCode As Int) As Boolean 'Return True to consume the event";
 //BA.debugLineNum = 1013;BA.debugLine="If KeyCode=KeyCodes.KEYCODE_BACK Then'if user pressed the back key";
if (_keycode==anywheresoftware.b4a.keywords.Common.KeyCodes.KEYCODE_BACK) { 
 //BA.debugLineNum = 1014;BA.debugLine="If connected=False Then'if the application was previously disconnected";
if (_connected==anywheresoftware.b4a.keywords.Common.False) { 
 //BA.debugLineNum = 1015;BA.debugLine="Return False'means now this activity keypress event is not consumed and transmitted to the system for further actions which is supposed to be performed by the respective (BACK)key pressed";
if (true) return anywheresoftware.b4a.keywords.Common.False;
 }else {
 //BA.debugLineNum = 1017;BA.debugLine="ToastMessageShow(\"Current connection disconnected!\" & Chr(10) & \"Press back again to exit!\",False)";
anywheresoftware.b4a.keywords.Common.ToastMessageShow("Current connection disconnected!"+String.valueOf(anywheresoftware.b4a.keywords.Common.Chr((int)(10)))+"Press back again to exit!",anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 1018;BA.debugLine="disable_main_views";
_disable_main_views();
 //BA.debugLineNum = 1019;BA.debugLine="astreams.Close";
_astreams.Close();
 //BA.debugLineNum = 1020;BA.debugLine="serial1.Disconnect";
_serial1.Disconnect();
 //BA.debugLineNum = 1021;BA.debugLine="connected=False";
_connected = anywheresoftware.b4a.keywords.Common.False;
 //BA.debugLineNum = 1022;BA.debugLine="Buttonconnect.Enabled=True";
mostCurrent._buttonconnect.setEnabled(anywheresoftware.b4a.keywords.Common.True);
 //BA.debugLineNum = 1023;BA.debugLine="Buttonconnect.Text=\"CONNECT\"";
mostCurrent._buttonconnect.setText((Object)("CONNECT"));
 //BA.debugLineNum = 1024;BA.debugLine="Return True'this event is consumed and no further action is taken";
if (true) return anywheresoftware.b4a.keywords.Common.True;
 };
 };
 //BA.debugLineNum = 1027;BA.debugLine="End Sub";
return false;
}
public static String  _activity_pause(boolean _userclosed) throws Exception{
 //BA.debugLineNum = 194;BA.debugLine="Sub Activity_Pause (UserClosed As Boolean)";
 //BA.debugLineNum = 196;BA.debugLine="End Sub";
return "";
}
public static String  _activity_resume() throws Exception{
 //BA.debugLineNum = 178;BA.debugLine="Sub Activity_Resume";
 //BA.debugLineNum = 179;BA.debugLine="If badmin.IsEnabled=False Then'if bluetooth is OFF";
if (_badmin.IsEnabled()==anywheresoftware.b4a.keywords.Common.False) { 
 //BA.debugLineNum = 180;BA.debugLine="If Msgbox2(\"This application requires bluetooth to be turned ON\" & CRLF & \"Turn it ON?\",\"Error\",\"Yes\",\"NO\",\"\",Null)=DialogResponse.POSITIVE Then 'yes,turn it ON";
if (anywheresoftware.b4a.keywords.Common.Msgbox2("This application requires bluetooth to be turned ON"+anywheresoftware.b4a.keywords.Common.CRLF+"Turn it ON?","Error","Yes","NO","",(android.graphics.Bitmap)(anywheresoftware.b4a.keywords.Common.Null),mostCurrent.activityBA)==anywheresoftware.b4a.keywords.Common.DialogResponse.POSITIVE) { 
 //BA.debugLineNum = 181;BA.debugLine="badmin.enable'turn ON bluetooth";
_badmin.Enable();
 }else {
 //BA.debugLineNum = 183;BA.debugLine="Labelbluetoothstatus.Text=\"OFF\"";
mostCurrent._labelbluetoothstatus.setText((Object)("OFF"));
 //BA.debugLineNum = 184;BA.debugLine="Buttonbluetoothswitch.Text=\"TURN ON\"";
mostCurrent._buttonbluetoothswitch.setText((Object)("TURN ON"));
 //BA.debugLineNum = 185;BA.debugLine="disable_main_views";
_disable_main_views();
 };
 //BA.debugLineNum = 187;BA.debugLine="connected=False	'may be if previously connected and user has turned off bluetooth manually off the application pausing it";
_connected = anywheresoftware.b4a.keywords.Common.False;
 }else {
 //BA.debugLineNum = 189;BA.debugLine="Buttonconnect.Enabled=True";
mostCurrent._buttonconnect.setEnabled(anywheresoftware.b4a.keywords.Common.True);
 //BA.debugLineNum = 190;BA.debugLine="Labelbluetoothstatus.Text=\"ON\"";
mostCurrent._labelbluetoothstatus.setText((Object)("ON"));
 //BA.debugLineNum = 191;BA.debugLine="Buttonbluetoothswitch.Text=\"TURN OFF\"";
mostCurrent._buttonbluetoothswitch.setText((Object)("TURN OFF"));
 };
 //BA.debugLineNum = 193;BA.debugLine="End Sub";
return "";
}
public static String  _animate2_animationend() throws Exception{
 //BA.debugLineNum = 200;BA.debugLine="Sub animate2_AnimationEnd	'main animation is over now";
 //BA.debugLineNum = 201;BA.debugLine="t2.Enabled=True	'wait for 1.5 second now";
mostCurrent._t2.setEnabled(anywheresoftware.b4a.keywords.Common.True);
 //BA.debugLineNum = 202;BA.debugLine="End Sub";
return "";
}
public static String  _astreams_newdata(byte[] _buffer) throws Exception{
String _msg = "";
byte _start = 0;
byte _finish = 0;
String _x = "";
 //BA.debugLineNum = 682;BA.debugLine="Sub AStreams_NewData (Buffer() As Byte)'serial data will be received here";
 //BA.debugLineNum = 685;BA.debugLine="Dim msg As String";
_msg = "";
 //BA.debugLineNum = 686;BA.debugLine="msg = BytesToString(Buffer, 0,Buffer.length, \"UTF8\")";
_msg = anywheresoftware.b4a.keywords.Common.BytesToString(_buffer,(int)(0),_buffer.length,"UTF8");
 //BA.debugLineNum = 687;BA.debugLine="msg = msg.trim";
_msg = _msg.trim();
 //BA.debugLineNum = 689;BA.debugLine="If msg.StartsWith(\"@\")=True AND msg.EndsWith(\"#\")=True Then'complete string is received";
if (_msg.startsWith("@")==anywheresoftware.b4a.keywords.Common.True && _msg.endsWith("#")==anywheresoftware.b4a.keywords.Common.True) { 
 //BA.debugLineNum = 690;BA.debugLine="sb = msg";
_sb = _msg;
 //BA.debugLineNum = 691;BA.debugLine="fullrx = True";
_fullrx = anywheresoftware.b4a.keywords.Common.True;
 }else if(_msg.startsWith("@")==anywheresoftware.b4a.keywords.Common.True && _msg.endsWith("#")==anywheresoftware.b4a.keywords.Common.False) { 
 //BA.debugLineNum = 693;BA.debugLine="sb = msg";
_sb = _msg;
 //BA.debugLineNum = 694;BA.debugLine="fullrx = False";
_fullrx = anywheresoftware.b4a.keywords.Common.False;
 }else if(_msg.startsWith("@")==anywheresoftware.b4a.keywords.Common.False && _msg.endsWith("#")==anywheresoftware.b4a.keywords.Common.True) { 
 //BA.debugLineNum = 696;BA.debugLine="sb = sb & msg	'concatinate it and make it full";
_sb = _sb+_msg;
 //BA.debugLineNum = 697;BA.debugLine="fullrx = True";
_fullrx = anywheresoftware.b4a.keywords.Common.True;
 }else {
 //BA.debugLineNum = 699;BA.debugLine="fullrx = False";
_fullrx = anywheresoftware.b4a.keywords.Common.False;
 };
 //BA.debugLineNum = 702;BA.debugLine="If fullrx = True Then		'now if we got the complete data string";
if (_fullrx==anywheresoftware.b4a.keywords.Common.True) { 
 //BA.debugLineNum = 703;BA.debugLine="If sb.Length >= 44 AND sb.Length < = 49 Then'if valid string is received,its length cannot go beyond this limit";
if (_sb.length()>=44 && _sb.length()<=49) { 
 //BA.debugLineNum = 704;BA.debugLine="Try";
try { //BA.debugLineNum = 705;BA.debugLine="If sb.charat(1)=Chr(90)Then		'Z ligh1 turned ON by host";
if (_sb.charAt((int)(1))==anywheresoftware.b4a.keywords.Common.Chr((int)(90))) { 
 //BA.debugLineNum = 706;BA.debugLine="Buttonlight1on.TextColor=Colors.green";
mostCurrent._buttonlight1on.setTextColor(anywheresoftware.b4a.keywords.Common.Colors.Green);
 //BA.debugLineNum = 707;BA.debugLine="Buttonlight1off.TextColor=Colors.black";
mostCurrent._buttonlight1off.setTextColor(anywheresoftware.b4a.keywords.Common.Colors.Black);
 }else if(_sb.charAt((int)(1))==anywheresoftware.b4a.keywords.Common.Chr((int)(122))) { 
 //BA.debugLineNum = 709;BA.debugLine="Buttonlight1on.TextColor=Colors.black";
mostCurrent._buttonlight1on.setTextColor(anywheresoftware.b4a.keywords.Common.Colors.Black);
 //BA.debugLineNum = 710;BA.debugLine="Buttonlight1off.TextColor=Colors.green";
mostCurrent._buttonlight1off.setTextColor(anywheresoftware.b4a.keywords.Common.Colors.Green);
 };
 //BA.debugLineNum = 713;BA.debugLine="If sb.charat(2)= Chr(89)Then		'Y ligh2 turned ON by host";
if (_sb.charAt((int)(2))==anywheresoftware.b4a.keywords.Common.Chr((int)(89))) { 
 //BA.debugLineNum = 714;BA.debugLine="Buttonlight2on.TextColor=Colors.green";
mostCurrent._buttonlight2on.setTextColor(anywheresoftware.b4a.keywords.Common.Colors.Green);
 //BA.debugLineNum = 715;BA.debugLine="Buttonlight2off.TextColor=Colors.black";
mostCurrent._buttonlight2off.setTextColor(anywheresoftware.b4a.keywords.Common.Colors.Black);
 }else if(_sb.charAt((int)(2))==anywheresoftware.b4a.keywords.Common.Chr((int)(121))) { 
 //BA.debugLineNum = 717;BA.debugLine="Buttonlight2on.TextColor=Colors.black";
mostCurrent._buttonlight2on.setTextColor(anywheresoftware.b4a.keywords.Common.Colors.Black);
 //BA.debugLineNum = 718;BA.debugLine="Buttonlight2off.TextColor=Colors.green";
mostCurrent._buttonlight2off.setTextColor(anywheresoftware.b4a.keywords.Common.Colors.Green);
 };
 //BA.debugLineNum = 721;BA.debugLine="If sb.charat(3)= Chr(88)Then'X";
if (_sb.charAt((int)(3))==anywheresoftware.b4a.keywords.Common.Chr((int)(88))) { 
 //BA.debugLineNum = 722;BA.debugLine="Buttontvon.TextColor=Colors.green";
mostCurrent._buttontvon.setTextColor(anywheresoftware.b4a.keywords.Common.Colors.Green);
 //BA.debugLineNum = 723;BA.debugLine="Buttontvoff.TextColor=Colors.black";
mostCurrent._buttontvoff.setTextColor(anywheresoftware.b4a.keywords.Common.Colors.Black);
 }else if(_sb.charAt((int)(3))==anywheresoftware.b4a.keywords.Common.Chr((int)(120))) { 
 //BA.debugLineNum = 725;BA.debugLine="Buttontvon.TextColor=Colors.black";
mostCurrent._buttontvon.setTextColor(anywheresoftware.b4a.keywords.Common.Colors.Black);
 //BA.debugLineNum = 726;BA.debugLine="Buttontvoff.TextColor=Colors.green";
mostCurrent._buttontvoff.setTextColor(anywheresoftware.b4a.keywords.Common.Colors.Green);
 };
 //BA.debugLineNum = 729;BA.debugLine="If sb.charat(4)= Chr(87)Then'W";
if (_sb.charAt((int)(4))==anywheresoftware.b4a.keywords.Common.Chr((int)(87))) { 
 //BA.debugLineNum = 730;BA.debugLine="Buttonfanon.TextColor=Colors.green";
mostCurrent._buttonfanon.setTextColor(anywheresoftware.b4a.keywords.Common.Colors.Green);
 //BA.debugLineNum = 731;BA.debugLine="Buttonfanoff.TextColor=Colors.black";
mostCurrent._buttonfanoff.setTextColor(anywheresoftware.b4a.keywords.Common.Colors.Black);
 }else if(_sb.charAt((int)(4))==anywheresoftware.b4a.keywords.Common.Chr((int)(119))) { 
 //BA.debugLineNum = 733;BA.debugLine="Buttonfanon.TextColor=Colors.black";
mostCurrent._buttonfanon.setTextColor(anywheresoftware.b4a.keywords.Common.Colors.Black);
 //BA.debugLineNum = 734;BA.debugLine="Buttonfanoff.TextColor=Colors.green";
mostCurrent._buttonfanoff.setTextColor(anywheresoftware.b4a.keywords.Common.Colors.Green);
 };
 //BA.debugLineNum = 737;BA.debugLine="If sb.charat(5)= Chr(70)Then'F";
if (_sb.charAt((int)(5))==anywheresoftware.b4a.keywords.Common.Chr((int)(70))) { 
 //BA.debugLineNum = 738;BA.debugLine="Labelmotion.Text=\"YES\"";
mostCurrent._labelmotion.setText((Object)("YES"));
 }else if(_sb.charAt((int)(5))==anywheresoftware.b4a.keywords.Common.Chr((int)(102))) { 
 //BA.debugLineNum = 740;BA.debugLine="Labelmotion.Text=\"NO\"";
mostCurrent._labelmotion.setText((Object)("NO"));
 };
 //BA.debugLineNum = 743;BA.debugLine="If sb.charat(6)= Chr(71)Then'G";
if (_sb.charAt((int)(6))==anywheresoftware.b4a.keywords.Common.Chr((int)(71))) { 
 //BA.debugLineNum = 744;BA.debugLine="Labellpg.Text=\"LEAK\"";
mostCurrent._labellpg.setText((Object)("LEAK"));
 }else if(_sb.charAt((int)(6))==anywheresoftware.b4a.keywords.Common.Chr((int)(103))) { 
 //BA.debugLineNum = 746;BA.debugLine="Labellpg.Text=\"NO LEAK\"";
mostCurrent._labellpg.setText((Object)("NO LEAK"));
 };
 //BA.debugLineNum = 749;BA.debugLine="If sb.charat(7)= Chr(85)Then'U door is opened now";
if (_sb.charAt((int)(7))==anywheresoftware.b4a.keywords.Common.Chr((int)(85))) { 
 //BA.debugLineNum = 750;BA.debugLine="Buttondoor.Text=\"CLOSE\"";
mostCurrent._buttondoor.setText((Object)("CLOSE"));
 //BA.debugLineNum = 751;BA.debugLine="Imagedoorstatus.Bitmap=LoadBitmap(File.DirAssets,\"open_door.png\")'opened gate graphic loading";
mostCurrent._imagedoorstatus.setBitmap((android.graphics.Bitmap)(anywheresoftware.b4a.keywords.Common.LoadBitmap(anywheresoftware.b4a.keywords.Common.File.getDirAssets(),"open_door.png").getObject()));
 //BA.debugLineNum = 752;BA.debugLine="Labeldoorstatus.Text=\"DOOR OPENED\"";
mostCurrent._labeldoorstatus.setText((Object)("DOOR OPENED"));
 }else if(_sb.charAt((int)(7))==anywheresoftware.b4a.keywords.Common.Chr((int)(117))) { 
 //BA.debugLineNum = 754;BA.debugLine="Buttondoor.Text=\"OPEN\"";
mostCurrent._buttondoor.setText((Object)("OPEN"));
 //BA.debugLineNum = 755;BA.debugLine="Imagedoorstatus.Bitmap=LoadBitmap(File.DirAssets,\"close_door.png\")'closed gate graphic loading";
mostCurrent._imagedoorstatus.setBitmap((android.graphics.Bitmap)(anywheresoftware.b4a.keywords.Common.LoadBitmap(anywheresoftware.b4a.keywords.Common.File.getDirAssets(),"close_door.png").getObject()));
 //BA.debugLineNum = 756;BA.debugLine="Labeldoorstatus.Text=\"DOOR CLOSED\"";
mostCurrent._labeldoorstatus.setText((Object)("DOOR CLOSED"));
 };
 //BA.debugLineNum = 759;BA.debugLine="If sb.charat(8)= Chr(84)Then'T sleep mode activated";
if (_sb.charAt((int)(8))==anywheresoftware.b4a.keywords.Common.Chr((int)(84))) { 
 //BA.debugLineNum = 760;BA.debugLine="Buttonsleepmode.Textcolor=Colors.green";
mostCurrent._buttonsleepmode.setTextColor(anywheresoftware.b4a.keywords.Common.Colors.Green);
 //BA.debugLineNum = 761;BA.debugLine="Buttonsleepmodeoff.Textcolor=Colors.black";
mostCurrent._buttonsleepmodeoff.setTextColor(anywheresoftware.b4a.keywords.Common.Colors.Black);
 }else if(_sb.charAt((int)(8))==anywheresoftware.b4a.keywords.Common.Chr((int)(116))) { 
 //BA.debugLineNum = 763;BA.debugLine="Buttonsleepmode.Textcolor=Colors.black";
mostCurrent._buttonsleepmode.setTextColor(anywheresoftware.b4a.keywords.Common.Colors.Black);
 //BA.debugLineNum = 764;BA.debugLine="Buttonsleepmodeoff.Textcolor=Colors.green";
mostCurrent._buttonsleepmodeoff.setTextColor(anywheresoftware.b4a.keywords.Common.Colors.Green);
 };
 //BA.debugLineNum = 767;BA.debugLine="If sb.charat(9)= Chr(83)Then'S motion sensor alarm programmed";
if (_sb.charAt((int)(9))==anywheresoftware.b4a.keywords.Common.Chr((int)(83))) { 
 //BA.debugLineNum = 768;BA.debugLine="Buttonsenmotion.Text=\"Programmed\"";
mostCurrent._buttonsenmotion.setText((Object)("Programmed"));
 }else if(_sb.charAt((int)(9))==anywheresoftware.b4a.keywords.Common.Chr((int)(115))) { 
 //BA.debugLineNum = 770;BA.debugLine="Buttonsenmotion.Text=\"Unprogrammed\"";
mostCurrent._buttonsenmotion.setText((Object)("Unprogrammed"));
 };
 //BA.debugLineNum = 773;BA.debugLine="Dim start As Byte";
_start = 0;
 //BA.debugLineNum = 774;BA.debugLine="Dim finish As Byte";
_finish = 0;
 //BA.debugLineNum = 777;BA.debugLine="start = sb.IndexOf(\"K\")";
_start = (byte)(_sb.indexOf("K"));
 //BA.debugLineNum = 778;BA.debugLine="finish = sb.IndexOf(\"k\")";
_finish = (byte)(_sb.indexOf("k"));
 //BA.debugLineNum = 779;BA.debugLine="If (start>=0 AND start<=sb.Length) AND (finish>=0 AND finish<=sb.Length) Then'if the both are in limits";
if ((_start>=0 && _start<=_sb.length()) && (_finish>=0 && _finish<=_sb.length())) { 
 //BA.debugLineNum = 780;BA.debugLine="Labeltempin.text = sb.SubString2(start+1,finish)";
mostCurrent._labeltempin.setText((Object)(_sb.substring((int)(_start+1),(int)(_finish))));
 };
 //BA.debugLineNum = 784;BA.debugLine="start = sb.IndexOf(\"J\")";
_start = (byte)(_sb.indexOf("J"));
 //BA.debugLineNum = 785;BA.debugLine="finish = sb.IndexOf(\"j\")";
_finish = (byte)(_sb.indexOf("j"));
 //BA.debugLineNum = 786;BA.debugLine="If (start>=0 AND start<=sb.Length) AND (finish>=0 AND finish<=sb.Length) Then'if the both are in limits";
if ((_start>=0 && _start<=_sb.length()) && (_finish>=0 && _finish<=_sb.length())) { 
 //BA.debugLineNum = 787;BA.debugLine="Labeltempout.text = sb.SubString2(start+1,finish)";
mostCurrent._labeltempout.setText((Object)(_sb.substring((int)(_start+1),(int)(_finish))));
 };
 //BA.debugLineNum = 791;BA.debugLine="start = sb.IndexOf(\"I\")";
_start = (byte)(_sb.indexOf("I"));
 //BA.debugLineNum = 792;BA.debugLine="finish = sb.IndexOf(\"i\")";
_finish = (byte)(_sb.indexOf("i"));
 //BA.debugLineNum = 793;BA.debugLine="If (start>=0 AND start<=sb.Length) AND (finish>=0 AND finish<=sb.Length) Then'if the both are in limits";
if ((_start>=0 && _start<=_sb.length()) && (_finish>=0 && _finish<=_sb.length())) { 
 //BA.debugLineNum = 794;BA.debugLine="Labellightin.text = sb.SubString2(start+1,finish)";
mostCurrent._labellightin.setText((Object)(_sb.substring((int)(_start+1),(int)(_finish))));
 };
 //BA.debugLineNum = 798;BA.debugLine="start = sb.IndexOf(\"H\")";
_start = (byte)(_sb.indexOf("H"));
 //BA.debugLineNum = 799;BA.debugLine="finish = sb.IndexOf(\"h\")";
_finish = (byte)(_sb.indexOf("h"));
 //BA.debugLineNum = 800;BA.debugLine="If (start>=0 AND start<=sb.Length) AND (finish>=0 AND finish<=sb.Length) Then'if the both are in limits";
if ((_start>=0 && _start<=_sb.length()) && (_finish>=0 && _finish<=_sb.length())) { 
 //BA.debugLineNum = 801;BA.debugLine="Labellightout.text = sb.SubString2(start+1,finish)";
mostCurrent._labellightout.setText((Object)(_sb.substring((int)(_start+1),(int)(_finish))));
 };
 //BA.debugLineNum = 804;BA.debugLine="Dim x As String";
_x = "";
 //BA.debugLineNum = 807;BA.debugLine="start = sb.IndexOf(\"R\")";
_start = (byte)(_sb.indexOf("R"));
 //BA.debugLineNum = 808;BA.debugLine="finish = sb.IndexOf(\"r\")";
_finish = (byte)(_sb.indexOf("r"));
 //BA.debugLineNum = 809;BA.debugLine="If (start>=0 AND start<=sb.Length) AND (finish>=0 AND finish<=sb.Length) Then'if the both are in limits";
if ((_start>=0 && _start<=_sb.length()) && (_finish>=0 && _finish<=_sb.length())) { 
 //BA.debugLineNum = 810;BA.debugLine="x = sb.SubString2(start+1,finish)";
_x = _sb.substring((int)(_start+1),(int)(_finish));
 //BA.debugLineNum = 811;BA.debugLine="If x=\"0\" Then";
if ((_x).equals("0")) { 
 //BA.debugLineNum = 812;BA.debugLine="Buttonsenlight1.text =\"Unprogrammed\"";
mostCurrent._buttonsenlight1.setText((Object)("Unprogrammed"));
 }else {
 //BA.debugLineNum = 814;BA.debugLine="Buttonsenlight1.Text=\"Programmed = \" & x";
mostCurrent._buttonsenlight1.setText((Object)("Programmed = "+_x));
 };
 };
 //BA.debugLineNum = 819;BA.debugLine="start = sb.IndexOf(\"P\")";
_start = (byte)(_sb.indexOf("P"));
 //BA.debugLineNum = 820;BA.debugLine="finish = sb.IndexOf(\"p\")";
_finish = (byte)(_sb.indexOf("p"));
 //BA.debugLineNum = 821;BA.debugLine="If (start>=0 AND start<=sb.Length) AND (finish>=0 AND finish<=sb.Length) Then'if the both are in limits";
if ((_start>=0 && _start<=_sb.length()) && (_finish>=0 && _finish<=_sb.length())) { 
 //BA.debugLineNum = 822;BA.debugLine="x = sb.SubString2(start+1,finish)";
_x = _sb.substring((int)(_start+1),(int)(_finish));
 //BA.debugLineNum = 823;BA.debugLine="If x=\"0\" Then";
if ((_x).equals("0")) { 
 //BA.debugLineNum = 824;BA.debugLine="Buttonsenlight2.text =\"Unprogrammed\"";
mostCurrent._buttonsenlight2.setText((Object)("Unprogrammed"));
 }else {
 //BA.debugLineNum = 826;BA.debugLine="Buttonsenlight2.Text=\"Programmed = \" & x";
mostCurrent._buttonsenlight2.setText((Object)("Programmed = "+_x));
 };
 };
 //BA.debugLineNum = 831;BA.debugLine="start = sb.IndexOf(\"N\")";
_start = (byte)(_sb.indexOf("N"));
 //BA.debugLineNum = 832;BA.debugLine="finish = sb.IndexOf(\"n\")";
_finish = (byte)(_sb.indexOf("n"));
 //BA.debugLineNum = 833;BA.debugLine="If (start>=0 AND start<=sb.Length) AND (finish>=0 AND finish<=sb.Length) Then'if the both are in limits";
if ((_start>=0 && _start<=_sb.length()) && (_finish>=0 && _finish<=_sb.length())) { 
 //BA.debugLineNum = 834;BA.debugLine="x = sb.SubString2(start+1,finish)";
_x = _sb.substring((int)(_start+1),(int)(_finish));
 //BA.debugLineNum = 835;BA.debugLine="If x=\"0\" Then";
if ((_x).equals("0")) { 
 //BA.debugLineNum = 836;BA.debugLine="Buttonsenfan.text =\"Unprogrammed\"";
mostCurrent._buttonsenfan.setText((Object)("Unprogrammed"));
 }else {
 //BA.debugLineNum = 838;BA.debugLine="Buttonsenfan.Text=\"Programmed = \" & x";
mostCurrent._buttonsenfan.setText((Object)("Programmed = "+_x));
 };
 };
 } 
       catch (Exception e) {
			processBA.setLastException(e); };
 };
 };
 //BA.debugLineNum = 846;BA.debugLine="End Sub";
return "";
}
public static String  _badmin_statechanged(int _newstate,int _oldstate) throws Exception{
 //BA.debugLineNum = 333;BA.debugLine="Sub badmin_statechanged(newstate As Int,oldstate As Int)'state change event of bluetooth adaptor";
 //BA.debugLineNum = 335;BA.debugLine="If newstate=badmin.STATE_ON Then'if bluetooth switched ON successfuly";
if (_newstate==_badmin.STATE_ON) { 
 //BA.debugLineNum = 336;BA.debugLine="ToastMessageShow(\"Bluetooth is switched ON!\",False)";
anywheresoftware.b4a.keywords.Common.ToastMessageShow("Bluetooth is switched ON!",anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 337;BA.debugLine="Labelbluetoothstatus.Text=\"ON\"";
mostCurrent._labelbluetoothstatus.setText((Object)("ON"));
 //BA.debugLineNum = 338;BA.debugLine="Buttonbluetoothswitch.Text=\"TURN OFF\"";
mostCurrent._buttonbluetoothswitch.setText((Object)("TURN OFF"));
 //BA.debugLineNum = 339;BA.debugLine="Buttonconnect.Enabled=True";
mostCurrent._buttonconnect.setEnabled(anywheresoftware.b4a.keywords.Common.True);
 //BA.debugLineNum = 340;BA.debugLine="Buttonconnect.Text=\"CONNECT\"";
mostCurrent._buttonconnect.setText((Object)("CONNECT"));
 };
 //BA.debugLineNum = 343;BA.debugLine="If newstate=badmin.STATE_OFF Then'if bluetooth switched OFF successfuly";
if (_newstate==_badmin.STATE_OFF) { 
 //BA.debugLineNum = 344;BA.debugLine="ToastMessageShow(\"Bluetooth is switched OFF!\",False)";
anywheresoftware.b4a.keywords.Common.ToastMessageShow("Bluetooth is switched OFF!",anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 345;BA.debugLine="Labelbluetoothstatus.Text=\"OFF\"";
mostCurrent._labelbluetoothstatus.setText((Object)("OFF"));
 //BA.debugLineNum = 346;BA.debugLine="Buttonbluetoothswitch.Text=\"TURN ON\"";
mostCurrent._buttonbluetoothswitch.setText((Object)("TURN ON"));
 //BA.debugLineNum = 347;BA.debugLine="Buttonconnect.Enabled=False";
mostCurrent._buttonconnect.setEnabled(anywheresoftware.b4a.keywords.Common.False);
 };
 //BA.debugLineNum = 350;BA.debugLine="If newstate=badmin.STATE_TURNING_OFF Then'if bluetooth is turning OFF";
if (_newstate==_badmin.STATE_TURNING_OFF) { 
 //BA.debugLineNum = 351;BA.debugLine="ToastMessageShow(\"Turning OFF bluetooth!\",False)";
anywheresoftware.b4a.keywords.Common.ToastMessageShow("Turning OFF bluetooth!",anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 352;BA.debugLine="Labelbluetoothstatus.Text=\"-----\"";
mostCurrent._labelbluetoothstatus.setText((Object)("-----"));
 //BA.debugLineNum = 353;BA.debugLine="disable_main_views";
_disable_main_views();
 };
 //BA.debugLineNum = 356;BA.debugLine="If newstate=badmin.STATE_TURNING_ON Then'if bluetooth is turning ON";
if (_newstate==_badmin.STATE_TURNING_ON) { 
 //BA.debugLineNum = 357;BA.debugLine="ToastMessageShow(\"Turning ON bluetooth!\",False)";
anywheresoftware.b4a.keywords.Common.ToastMessageShow("Turning ON bluetooth!",anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 358;BA.debugLine="Labelbluetoothstatus.Text=\"-----\"";
mostCurrent._labelbluetoothstatus.setText((Object)("-----"));
 };
 //BA.debugLineNum = 360;BA.debugLine="End Sub";
return "";
}
public static String  _buttonalloff_click() throws Exception{
 //BA.debugLineNum = 489;BA.debugLine="Sub Buttonalloff_Click";
 //BA.debugLineNum = 490;BA.debugLine="s=\"e\"";
_s = "e";
 //BA.debugLineNum = 491;BA.debugLine="astreams.Write(s.GetBytes(\"UTF8\"))";
_astreams.Write(_s.getBytes("UTF8"));
 //BA.debugLineNum = 492;BA.debugLine="End Sub";
return "";
}
public static String  _buttonalloff_longclick() throws Exception{
 //BA.debugLineNum = 983;BA.debugLine="Sub Buttonalloff_LongClick";
 //BA.debugLineNum = 984;BA.debugLine="Msgbox(\"With this,you can turn OFF all your home appliances in a single click!\",\"Help\")";
anywheresoftware.b4a.keywords.Common.Msgbox("With this,you can turn OFF all your home appliances in a single click!","Help",mostCurrent.activityBA);
 //BA.debugLineNum = 985;BA.debugLine="End Sub";
return "";
}
public static String  _buttonallon_click() throws Exception{
 //BA.debugLineNum = 485;BA.debugLine="Sub Buttonallon_Click'";
 //BA.debugLineNum = 486;BA.debugLine="s=\"E\"";
_s = "E";
 //BA.debugLineNum = 487;BA.debugLine="astreams.Write(s.GetBytes(\"UTF8\"))";
_astreams.Write(_s.getBytes("UTF8"));
 //BA.debugLineNum = 488;BA.debugLine="End Sub";
return "";
}
public static String  _buttonallon_longclick() throws Exception{
 //BA.debugLineNum = 980;BA.debugLine="Sub Buttonallon_LongClick";
 //BA.debugLineNum = 981;BA.debugLine="Msgbox(\"With this,you can turn ON all your home appliances in a single click!\",\"Help\")";
anywheresoftware.b4a.keywords.Common.Msgbox("With this,you can turn ON all your home appliances in a single click!","Help",mostCurrent.activityBA);
 //BA.debugLineNum = 982;BA.debugLine="End Sub";
return "";
}
public static String  _buttonbluetoothswitch_click() throws Exception{
 //BA.debugLineNum = 318;BA.debugLine="Sub Buttonbluetoothswitch_Click";
 //BA.debugLineNum = 319;BA.debugLine="If Buttonbluetoothswitch.Text=\"TURN ON\" Then 'bluettoth is previously OFF";
if ((mostCurrent._buttonbluetoothswitch.getText()).equals("TURN ON")) { 
 //BA.debugLineNum = 320;BA.debugLine="Buttonbluetoothswitch.Text=\"TURN OFF\"";
mostCurrent._buttonbluetoothswitch.setText((Object)("TURN OFF"));
 //BA.debugLineNum = 321;BA.debugLine="badmin.enable	'turn bluetooth ON";
_badmin.Enable();
 }else {
 //BA.debugLineNum = 323;BA.debugLine="If connected=True Then'if previously connected";
if (_connected==anywheresoftware.b4a.keywords.Common.True) { 
 //BA.debugLineNum = 324;BA.debugLine="astreams.Close";
_astreams.Close();
 //BA.debugLineNum = 325;BA.debugLine="serial1.Disconnect";
_serial1.Disconnect();
 //BA.debugLineNum = 326;BA.debugLine="connected = False";
_connected = anywheresoftware.b4a.keywords.Common.False;
 //BA.debugLineNum = 327;BA.debugLine="disable_main_views";
_disable_main_views();
 };
 //BA.debugLineNum = 329;BA.debugLine="Buttonbluetoothswitch.Text=\"TURN ON\"";
mostCurrent._buttonbluetoothswitch.setText((Object)("TURN ON"));
 //BA.debugLineNum = 330;BA.debugLine="badmin.disable	'turn bluetooth OFF";
_badmin.Disable();
 };
 //BA.debugLineNum = 332;BA.debugLine="End Sub";
return "";
}
public static String  _buttonbluetoothswitch_longclick() throws Exception{
 //BA.debugLineNum = 977;BA.debugLine="Sub Buttonbluetoothswitch_LongClick";
 //BA.debugLineNum = 978;BA.debugLine="Msgbox(\"With this,you can manually turn ON/OFF the phones's bluetooth adaptor!\",\"Help\")";
anywheresoftware.b4a.keywords.Common.Msgbox("With this,you can manually turn ON/OFF the phones's bluetooth adaptor!","Help",mostCurrent.activityBA);
 //BA.debugLineNum = 979;BA.debugLine="End Sub";
return "";
}
public static String  _buttonconnect_click() throws Exception{
anywheresoftware.b4a.objects.collections.Map _paireddevices = null;
anywheresoftware.b4a.objects.collections.List _l = null;
int _res = 0;
 //BA.debugLineNum = 634;BA.debugLine="Sub Buttonconnect_Click";
 //BA.debugLineNum = 635;BA.debugLine="If Buttonconnect.Text=\"CONNECT\" Then'if disconnected previously";
if ((mostCurrent._buttonconnect.getText()).equals("CONNECT")) { 
 //BA.debugLineNum = 636;BA.debugLine="If connected=False Then'if you are disconnected";
if (_connected==anywheresoftware.b4a.keywords.Common.False) { 
 //BA.debugLineNum = 637;BA.debugLine="Dim PairedDevices As Map";
_paireddevices = new anywheresoftware.b4a.objects.collections.Map();
 //BA.debugLineNum = 638;BA.debugLine="PairedDevices = serial1.GetPairedDevices";
_paireddevices = _serial1.GetPairedDevices();
 //BA.debugLineNum = 640;BA.debugLine="Dim l As List  'create a list";
_l = new anywheresoftware.b4a.objects.collections.List();
 //BA.debugLineNum = 641;BA.debugLine="l.Initialize 'iniitialize the list";
_l.Initialize();
 //BA.debugLineNum = 643;BA.debugLine="For i = 0 To PairedDevices.Size - 1";
{
final double step563 = 1;
final double limit563 = (int)(_paireddevices.getSize()-1);
for (_i = (int)(0); (step563 > 0 && _i <= limit563) || (step563 < 0 && _i >= limit563); _i += step563) {
 //BA.debugLineNum = 644;BA.debugLine="l.Add(PairedDevices.GetKeyAt(i)) 'add the friendly name to the list";
_l.Add(_paireddevices.GetKeyAt(_i));
 }
};
 //BA.debugLineNum = 647;BA.debugLine="Dim res As Int";
_res = 0;
 //BA.debugLineNum = 648;BA.debugLine="res = InputList(l, \"Choose device\",-1) 'show list with paired devices";
_res = anywheresoftware.b4a.keywords.Common.InputList(_l,"Choose device",(int)(-1),mostCurrent.activityBA);
 //BA.debugLineNum = 649;BA.debugLine="If res <> DialogResponse.CANCEL Then'if user has not pressed the back key";
if (_res!=anywheresoftware.b4a.keywords.Common.DialogResponse.CANCEL) { 
 //BA.debugLineNum = 650;BA.debugLine="serial1.Connect(PairedDevices.Get(l.Get(res))) 'convert the name to mac address";
_serial1.Connect(processBA,String.valueOf(_paireddevices.Get(_l.Get(_res))));
 //BA.debugLineNum = 651;BA.debugLine="File.WriteString(File.DirInternal,\"mac.txt\",PairedDevices.Get(l.Get(res)))'store the file with currently chosen paired host's MAC address";
anywheresoftware.b4a.keywords.Common.File.WriteString(anywheresoftware.b4a.keywords.Common.File.getDirInternal(),"mac.txt",String.valueOf(_paireddevices.Get(_l.Get(_res))));
 };
 };
 }else {
 //BA.debugLineNum = 655;BA.debugLine="disable_main_views";
_disable_main_views();
 //BA.debugLineNum = 656;BA.debugLine="Buttonconnect.Enabled=True";
mostCurrent._buttonconnect.setEnabled(anywheresoftware.b4a.keywords.Common.True);
 //BA.debugLineNum = 657;BA.debugLine="Buttonconnect.Text=\"CONNECT\"";
mostCurrent._buttonconnect.setText((Object)("CONNECT"));
 //BA.debugLineNum = 658;BA.debugLine="astreams.Close";
_astreams.Close();
 //BA.debugLineNum = 659;BA.debugLine="serial1.Disconnect";
_serial1.Disconnect();
 //BA.debugLineNum = 660;BA.debugLine="connected = False";
_connected = anywheresoftware.b4a.keywords.Common.False;
 //BA.debugLineNum = 661;BA.debugLine="ToastMessageShow(\"Disconnected successfully!\",False)";
anywheresoftware.b4a.keywords.Common.ToastMessageShow("Disconnected successfully!",anywheresoftware.b4a.keywords.Common.False);
 };
 //BA.debugLineNum = 663;BA.debugLine="End Sub";
return "";
}
public static String  _buttonconnect_longclick() throws Exception{
 //BA.debugLineNum = 974;BA.debugLine="Sub Buttonconnect_LongClick";
 //BA.debugLineNum = 975;BA.debugLine="Msgbox(\"With this,you can manually connect/disconnect with your host device!\",\"Help\")";
anywheresoftware.b4a.keywords.Common.Msgbox("With this,you can manually connect/disconnect with your host device!","Help",mostCurrent.activityBA);
 //BA.debugLineNum = 976;BA.debugLine="End Sub";
return "";
}
public static String  _buttondoor_click() throws Exception{
 //BA.debugLineNum = 916;BA.debugLine="Sub Buttondoor_Click'door OPEN/CLOSE button";
 //BA.debugLineNum = 917;BA.debugLine="If Buttondoor.Text=\"OPEN\" Then 'gate is previously closed,button is dislaying \"OPEN\"";
if ((mostCurrent._buttondoor.getText()).equals("OPEN")) { 
 //BA.debugLineNum = 918;BA.debugLine="s=\"F\"'open the door command";
_s = "F";
 //BA.debugLineNum = 919;BA.debugLine="astreams.Write(s.GetBytes(\"UTF8\"))";
_astreams.Write(_s.getBytes("UTF8"));
 }else {
 //BA.debugLineNum = 921;BA.debugLine="s=\"N\"'close the door command";
_s = "N";
 //BA.debugLineNum = 922;BA.debugLine="astreams.Write(s.GetBytes(\"UTF8\"))";
_astreams.Write(_s.getBytes("UTF8"));
 };
 //BA.debugLineNum = 924;BA.debugLine="End Sub";
return "";
}
public static String  _buttondoor_longclick() throws Exception{
 //BA.debugLineNum = 971;BA.debugLine="Sub Buttondoor_LongClick";
 //BA.debugLineNum = 972;BA.debugLine="Msgbox(\"With this,you can manually open/close your main entrance door!\",\"Help\")";
anywheresoftware.b4a.keywords.Common.Msgbox("With this,you can manually open/close your main entrance door!","Help",mostCurrent.activityBA);
 //BA.debugLineNum = 973;BA.debugLine="End Sub";
return "";
}
public static String  _buttonfanoff_click() throws Exception{
 //BA.debugLineNum = 479;BA.debugLine="Sub Buttonfanoff_Click";
 //BA.debugLineNum = 480;BA.debugLine="s=\"d\"";
_s = "d";
 //BA.debugLineNum = 481;BA.debugLine="astreams.Write(s.GetBytes(\"UTF8\"))";
_astreams.Write(_s.getBytes("UTF8"));
 //BA.debugLineNum = 482;BA.debugLine="End Sub";
return "";
}
public static String  _buttonfanon_click() throws Exception{
 //BA.debugLineNum = 475;BA.debugLine="Sub Buttonfanon_Click";
 //BA.debugLineNum = 476;BA.debugLine="s=\"D\"";
_s = "D";
 //BA.debugLineNum = 477;BA.debugLine="astreams.Write(s.GetBytes(\"UTF8\"))";
_astreams.Write(_s.getBytes("UTF8"));
 //BA.debugLineNum = 478;BA.debugLine="End Sub";
return "";
}
public static String  _buttonlight1off_click() throws Exception{
 //BA.debugLineNum = 469;BA.debugLine="Sub Buttonlight1off_Click";
 //BA.debugLineNum = 470;BA.debugLine="s=\"a\"";
_s = "a";
 //BA.debugLineNum = 471;BA.debugLine="astreams.Write(s.GetBytes(\"UTF8\"))";
_astreams.Write(_s.getBytes("UTF8"));
 //BA.debugLineNum = 472;BA.debugLine="End Sub";
return "";
}
public static String  _buttonlight1on_click() throws Exception{
 //BA.debugLineNum = 465;BA.debugLine="Sub Buttonlight1on_Click";
 //BA.debugLineNum = 466;BA.debugLine="s=\"A\"";
_s = "A";
 //BA.debugLineNum = 467;BA.debugLine="astreams.Write(s.GetBytes(\"UTF8\"))";
_astreams.Write(_s.getBytes("UTF8"));
 //BA.debugLineNum = 468;BA.debugLine="End Sub";
return "";
}
public static String  _buttonlight2off_click() throws Exception{
 //BA.debugLineNum = 459;BA.debugLine="Sub Buttonlight2off_Click";
 //BA.debugLineNum = 460;BA.debugLine="s=\"b\"";
_s = "b";
 //BA.debugLineNum = 461;BA.debugLine="astreams.Write(s.GetBytes(\"UTF8\"))";
_astreams.Write(_s.getBytes("UTF8"));
 //BA.debugLineNum = 462;BA.debugLine="End Sub";
return "";
}
public static String  _buttonlight2on_click() throws Exception{
 //BA.debugLineNum = 455;BA.debugLine="Sub Buttonlight2on_Click";
 //BA.debugLineNum = 456;BA.debugLine="s=\"B\"";
_s = "B";
 //BA.debugLineNum = 457;BA.debugLine="astreams.Write(s.GetBytes(\"UTF8\"))";
_astreams.Write(_s.getBytes("UTF8"));
 //BA.debugLineNum = 458;BA.debugLine="End Sub";
return "";
}
public static String  _buttonpassword_click() throws Exception{
byte _a = 0;
 //BA.debugLineNum = 851;BA.debugLine="Sub Buttonpassword_Click";
 //BA.debugLineNum = 852;BA.debugLine="If File.ReadString(File.DirInternal,\"password.txt\")<>\"\" Then 'if some password exists";
if ((anywheresoftware.b4a.keywords.Common.File.ReadString(anywheresoftware.b4a.keywords.Common.File.getDirInternal(),"password.txt")).equals("") == false) { 
 //BA.debugLineNum = 853;BA.debugLine="inpbox.InputType=inpbox.INPUT_TYPE_TEXT";
mostCurrent._inpbox.setInputType(mostCurrent._inpbox.INPUT_TYPE_TEXT);
 //BA.debugLineNum = 854;BA.debugLine="inpbox.PasswordMode=True";
mostCurrent._inpbox.setPasswordMode(anywheresoftware.b4a.keywords.Common.True);
 //BA.debugLineNum = 855;BA.debugLine="inpbox.Input=\"\"";
mostCurrent._inpbox.setInput("");
 //BA.debugLineNum = 856;BA.debugLine="If inpbox.Show(\"\",\"Enter current password :\",\"OK\",\"Cancel\",\"\",Null)=DialogResponse.POSITIVE Then'if user entered something and hit OK";
if (mostCurrent._inpbox.Show("","Enter current password :","OK","Cancel","",mostCurrent.activityBA,(android.graphics.Bitmap)(anywheresoftware.b4a.keywords.Common.Null))==anywheresoftware.b4a.keywords.Common.DialogResponse.POSITIVE) { 
 //BA.debugLineNum = 857;BA.debugLine="If inpbox.Input<>File.ReadString(File.DirInternal,\"password.txt\") Then 'current password not matched";
if ((mostCurrent._inpbox.getInput()).equals(anywheresoftware.b4a.keywords.Common.File.ReadString(anywheresoftware.b4a.keywords.Common.File.getDirInternal(),"password.txt")) == false) { 
 //BA.debugLineNum = 858;BA.debugLine="Msgbox(\"Incorrect password,try again!\",\"Error\")";
anywheresoftware.b4a.keywords.Common.Msgbox("Incorrect password,try again!","Error",mostCurrent.activityBA);
 //BA.debugLineNum = 859;BA.debugLine="Return";
if (true) return "";
 };
 }else {
 //BA.debugLineNum = 862;BA.debugLine="Return	'return from here only";
if (true) return "";
 };
 };
 //BA.debugLineNum = 866;BA.debugLine="Dim a As Byte";
_a = 0;
 //BA.debugLineNum = 867;BA.debugLine="a=Msgbox2(\"Do you want to change the password?\",\"Password Manager\",\"Yes\",\"No\",\"Disable\",Null)";
_a = (byte)(anywheresoftware.b4a.keywords.Common.Msgbox2("Do you want to change the password?","Password Manager","Yes","No","Disable",(android.graphics.Bitmap)(anywheresoftware.b4a.keywords.Common.Null),mostCurrent.activityBA));
 //BA.debugLineNum = 868;BA.debugLine="If a=DialogResponse.NEGATIVE Then'disable the password";
if (_a==anywheresoftware.b4a.keywords.Common.DialogResponse.NEGATIVE) { 
 //BA.debugLineNum = 869;BA.debugLine="File.WriteString(File.DirInternal,\"password.txt\",\"\")'file stored with no text means password is disabled";
anywheresoftware.b4a.keywords.Common.File.WriteString(anywheresoftware.b4a.keywords.Common.File.getDirInternal(),"password.txt","");
 //BA.debugLineNum = 870;BA.debugLine="ToastMessageShow(\"Password disabled successfully!\",False)";
anywheresoftware.b4a.keywords.Common.ToastMessageShow("Password disabled successfully!",anywheresoftware.b4a.keywords.Common.False);
 }else if(_a==anywheresoftware.b4a.keywords.Common.DialogResponse.POSITIVE) { 
 //BA.debugLineNum = 872;BA.debugLine="inpbox.InputType=inpbox.INPUT_TYPE_TEXT";
mostCurrent._inpbox.setInputType(mostCurrent._inpbox.INPUT_TYPE_TEXT);
 //BA.debugLineNum = 873;BA.debugLine="inpbox.PasswordMode=True";
mostCurrent._inpbox.setPasswordMode(anywheresoftware.b4a.keywords.Common.True);
 //BA.debugLineNum = 874;BA.debugLine="inpbox.Input=\"\"";
mostCurrent._inpbox.setInput("");
 //BA.debugLineNum = 875;BA.debugLine="If inpbox.Show(\"\",\"Enter new password :\",\"OK\",\"Cancel\",\"\",Null)=DialogResponse.POSITIVE Then";
if (mostCurrent._inpbox.Show("","Enter new password :","OK","Cancel","",mostCurrent.activityBA,(android.graphics.Bitmap)(anywheresoftware.b4a.keywords.Common.Null))==anywheresoftware.b4a.keywords.Common.DialogResponse.POSITIVE) { 
 //BA.debugLineNum = 876;BA.debugLine="File.WriteString(File.DirInternal,\"password.txt\",inpbox.Input)";
anywheresoftware.b4a.keywords.Common.File.WriteString(anywheresoftware.b4a.keywords.Common.File.getDirInternal(),"password.txt",mostCurrent._inpbox.getInput());
 //BA.debugLineNum = 877;BA.debugLine="ToastMessageShow(\"Password changed successfully!\",False)";
anywheresoftware.b4a.keywords.Common.ToastMessageShow("Password changed successfully!",anywheresoftware.b4a.keywords.Common.False);
 };
 };
 //BA.debugLineNum = 880;BA.debugLine="End Sub";
return "";
}
public static String  _buttonpassword_longclick() throws Exception{
 //BA.debugLineNum = 968;BA.debugLine="Sub Buttonpassword_LongClick";
 //BA.debugLineNum = 969;BA.debugLine="Msgbox(\"With this,you can set and change you login password!\",\"Help\")";
anywheresoftware.b4a.keywords.Common.Msgbox("With this,you can set and change you login password!","Help",mostCurrent.activityBA);
 //BA.debugLineNum = 970;BA.debugLine="End Sub";
return "";
}
public static String  _buttonprogfire_click() throws Exception{
byte _one = 0;
byte _two = 0;
 //BA.debugLineNum = 881;BA.debugLine="Sub Buttonprogfire_Click";
 //BA.debugLineNum = 882;BA.debugLine="numdial.Decimal=0";
mostCurrent._numdial.setDecimal((int)(0));
 //BA.debugLineNum = 883;BA.debugLine="numdial.Digits=2";
mostCurrent._numdial.setDigits((int)(2));
 //BA.debugLineNum = 884;BA.debugLine="numdial.Number=48";
mostCurrent._numdial.setNumber((int)(48));
 //BA.debugLineNum = 885;BA.debugLine="numdial.ShowSign=False";
mostCurrent._numdial.setShowSign(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 886;BA.debugLine="If numdial.Show(\"Fire alarm threshold ('C) min :\",\"OK\",\"Cancel\",\"\",Null)=DialogResponse.POSITIVE Then";
if (mostCurrent._numdial.Show("Fire alarm threshold ('C) min :","OK","Cancel","",mostCurrent.activityBA,(android.graphics.Bitmap)(anywheresoftware.b4a.keywords.Common.Null))==anywheresoftware.b4a.keywords.Common.DialogResponse.POSITIVE) { 
 //BA.debugLineNum = 887;BA.debugLine="If numdial.Number>=30 AND numdial.Number<=80 Then'if user entered between 30-80'C";
if (mostCurrent._numdial.getNumber()>=30 && mostCurrent._numdial.getNumber()<=80) { 
 //BA.debugLineNum = 889;BA.debugLine="Dim one As Byte,two As Byte,i As Int";
_one = 0;
_two = 0;
_i = 0;
 //BA.debugLineNum = 890;BA.debugLine="one =numdial.Number Mod 10'fetch ones place number";
_one = (byte)(mostCurrent._numdial.getNumber()%10);
 //BA.debugLineNum = 891;BA.debugLine="two =numdial.Number / 10'fetch tens place number";
_two = (byte)(mostCurrent._numdial.getNumber()/(double)10);
 //BA.debugLineNum = 894;BA.debugLine="s=\"P\"";
_s = "P";
 //BA.debugLineNum = 895;BA.debugLine="astreams.Write(s.GetBytes(\"UTF8\"))";
_astreams.Write(_s.getBytes("UTF8"));
 //BA.debugLineNum = 896;BA.debugLine="For i=1 To 20000'wait some time";
{
final double step781 = 1;
final double limit781 = (int)(20000);
for (_i = (int)(1); (step781 > 0 && _i <= limit781) || (step781 < 0 && _i >= limit781); _i += step781) {
 }
};
 //BA.debugLineNum = 898;BA.debugLine="s=two";
_s = BA.NumberToString(_two);
 //BA.debugLineNum = 899;BA.debugLine="astreams.Write(s.GetBytes(\"UTF8\"))";
_astreams.Write(_s.getBytes("UTF8"));
 //BA.debugLineNum = 900;BA.debugLine="For i=1 To 20000";
{
final double step785 = 1;
final double limit785 = (int)(20000);
for (_i = (int)(1); (step785 > 0 && _i <= limit785) || (step785 < 0 && _i >= limit785); _i += step785) {
 }
};
 //BA.debugLineNum = 902;BA.debugLine="s=one";
_s = BA.NumberToString(_one);
 //BA.debugLineNum = 903;BA.debugLine="astreams.Write(s.GetBytes(\"UTF8\"))";
_astreams.Write(_s.getBytes("UTF8"));
 //BA.debugLineNum = 904;BA.debugLine="For i=1 To 20000";
{
final double step789 = 1;
final double limit789 = (int)(20000);
for (_i = (int)(1); (step789 > 0 && _i <= limit789) || (step789 < 0 && _i >= limit789); _i += step789) {
 }
};
 //BA.debugLineNum = 906;BA.debugLine="s=\"p\"";
_s = "p";
 //BA.debugLineNum = 907;BA.debugLine="astreams.Write(s.GetBytes(\"UTF8\"))";
_astreams.Write(_s.getBytes("UTF8"));
 }else {
 //BA.debugLineNum = 910;BA.debugLine="Msgbox(\"You can programme the fire sensor threshold only between 30'C-80'C!\",\"Error\")";
anywheresoftware.b4a.keywords.Common.Msgbox("You can programme the fire sensor threshold only between 30'C-80'C!","Error",mostCurrent.activityBA);
 };
 };
 //BA.debugLineNum = 913;BA.debugLine="End Sub";
return "";
}
public static String  _buttonprogfire_longclick() throws Exception{
 //BA.debugLineNum = 995;BA.debugLine="Sub Buttonprogfire_LongClick";
 //BA.debugLineNum = 996;BA.debugLine="Msgbox(\"With this,you can programme the host to raise fire alarm if the temperature inside home exceeds this threshold limit!\",\"Help\")";
anywheresoftware.b4a.keywords.Common.Msgbox("With this,you can programme the host to raise fire alarm if the temperature inside home exceeds this threshold limit!","Help",mostCurrent.activityBA);
 //BA.debugLineNum = 997;BA.debugLine="End Sub";
return "";
}
public static String  _buttonresetautoconnect_click() throws Exception{
 //BA.debugLineNum = 847;BA.debugLine="Sub Buttonresetautoconnect_Click";
 //BA.debugLineNum = 848;BA.debugLine="File.WriteString(File.DirInternal,\"mac.txt\",\"\")'store the file with null,means no autoconnection will be done at startup";
anywheresoftware.b4a.keywords.Common.File.WriteString(anywheresoftware.b4a.keywords.Common.File.getDirInternal(),"mac.txt","");
 //BA.debugLineNum = 849;BA.debugLine="ToastMessageShow(\"Autoconnection disabled successfully!\",False)";
anywheresoftware.b4a.keywords.Common.ToastMessageShow("Autoconnection disabled successfully!",anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 850;BA.debugLine="End Sub";
return "";
}
public static String  _buttonresetautoconnect_longclick() throws Exception{
 //BA.debugLineNum = 986;BA.debugLine="Sub Buttonresetautoconnect_LongClick";
 //BA.debugLineNum = 987;BA.debugLine="Msgbox(\"With this,you can disable the autoconnection at startup of your app to the previously registered host!\",\"Help\")";
anywheresoftware.b4a.keywords.Common.Msgbox("With this,you can disable the autoconnection at startup of your app to the previously registered host!","Help",mostCurrent.activityBA);
 //BA.debugLineNum = 988;BA.debugLine="End Sub";
return "";
}
public static String  _buttonsavelog_click() throws Exception{
String _filename = "";
 //BA.debugLineNum = 1000;BA.debugLine="Sub Buttonsavelog_Click";
 //BA.debugLineNum = 1001;BA.debugLine="Dim s As String,filename As String";
_s = "";
_filename = "";
 //BA.debugLineNum = 1003;BA.debugLine="DateTime.TimeFormat=\"HH,mm,ss\"";
anywheresoftware.b4a.keywords.Common.DateTime.setTimeFormat("HH,mm,ss");
 //BA.debugLineNum = 1004;BA.debugLine="DateTime.DateFormat=\"MM.dd.yyyy\"";
anywheresoftware.b4a.keywords.Common.DateTime.setDateFormat("MM.dd.yyyy");
 //BA.debugLineNum = 1005;BA.debugLine="filename=DateTime.Time(DateTime.Now) & \"_\" & DateTime.date(DateTime.Now) & \".txt\"";
_filename = anywheresoftware.b4a.keywords.Common.DateTime.Time(anywheresoftware.b4a.keywords.Common.DateTime.getNow())+"_"+anywheresoftware.b4a.keywords.Common.DateTime.Date(anywheresoftware.b4a.keywords.Common.DateTime.getNow())+".txt";
 //BA.debugLineNum = 1007;BA.debugLine="s=\"Temperature outside : \" & Labeltempout.Text & CRLF & \"Temperature inside : \" & Labeltempin.Text & CRLF & \"Light outside : \" & Labellightout.Text & CRLF & \"Light inside : \" & Labellightin.Text & CRLF &  \"Motion : \" & Labelmotion.Text & CRLF & \"LPG : \" & Labellpg.text & CRLF & CRLF & \"Time : \" & DateTime.Time(DateTime.Now) & CRLF & \"Date : \" & DateTime.date(DateTime.Now)";
_s = "Temperature outside : "+mostCurrent._labeltempout.getText()+anywheresoftware.b4a.keywords.Common.CRLF+"Temperature inside : "+mostCurrent._labeltempin.getText()+anywheresoftware.b4a.keywords.Common.CRLF+"Light outside : "+mostCurrent._labellightout.getText()+anywheresoftware.b4a.keywords.Common.CRLF+"Light inside : "+mostCurrent._labellightin.getText()+anywheresoftware.b4a.keywords.Common.CRLF+"Motion : "+mostCurrent._labelmotion.getText()+anywheresoftware.b4a.keywords.Common.CRLF+"LPG : "+mostCurrent._labellpg.getText()+anywheresoftware.b4a.keywords.Common.CRLF+anywheresoftware.b4a.keywords.Common.CRLF+"Time : "+anywheresoftware.b4a.keywords.Common.DateTime.Time(anywheresoftware.b4a.keywords.Common.DateTime.getNow())+anywheresoftware.b4a.keywords.Common.CRLF+"Date : "+anywheresoftware.b4a.keywords.Common.DateTime.Date(anywheresoftware.b4a.keywords.Common.DateTime.getNow());
 //BA.debugLineNum = 1009;BA.debugLine="File.WriteString(\"/mnt/sdcard/smarthome\",filename,s)";
anywheresoftware.b4a.keywords.Common.File.WriteString("/mnt/sdcard/smarthome",_filename,_s);
 //BA.debugLineNum = 1010;BA.debugLine="ToastMessageShow(\"Sensor readings logged successfully!\",False)";
anywheresoftware.b4a.keywords.Common.ToastMessageShow("Sensor readings logged successfully!",anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 1011;BA.debugLine="End Sub";
return "";
}
public static String  _buttonsavelog_longclick() throws Exception{
 //BA.debugLineNum = 965;BA.debugLine="Sub Buttonsavelog_LongClick";
 //BA.debugLineNum = 966;BA.debugLine="Msgbox(\"With this,you can save your current sensor readings to your SD card!\",\"Help\")";
anywheresoftware.b4a.keywords.Common.Msgbox("With this,you can save your current sensor readings to your SD card!","Help",mostCurrent.activityBA);
 //BA.debugLineNum = 967;BA.debugLine="End Sub";
return "";
}
public static String  _buttonsenfan_click() throws Exception{
byte _r = 0;
byte _one = 0;
byte _two = 0;
 //BA.debugLineNum = 574;BA.debugLine="Sub Buttonsenfan_Click";
 //BA.debugLineNum = 575;BA.debugLine="numdial.Decimal=0";
mostCurrent._numdial.setDecimal((int)(0));
 //BA.debugLineNum = 576;BA.debugLine="numdial.Digits=2";
mostCurrent._numdial.setDigits((int)(2));
 //BA.debugLineNum = 577;BA.debugLine="numdial.Number=32";
mostCurrent._numdial.setNumber((int)(32));
 //BA.debugLineNum = 578;BA.debugLine="numdial.ShowSign=False";
mostCurrent._numdial.setShowSign(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 579;BA.debugLine="Dim r As Byte";
_r = 0;
 //BA.debugLineNum = 580;BA.debugLine="r=numdial.Show(\"Fan/AC lower limit('C) :\",\"Prog\",\"Cancel\",\"Unprog\",Null)";
_r = (byte)(mostCurrent._numdial.Show("Fan/AC lower limit('C) :","Prog","Cancel","Unprog",mostCurrent.activityBA,(android.graphics.Bitmap)(anywheresoftware.b4a.keywords.Common.Null)));
 //BA.debugLineNum = 581;BA.debugLine="If r=DialogResponse.POSITIVE Then'programme the threshold value";
if (_r==anywheresoftware.b4a.keywords.Common.DialogResponse.POSITIVE) { 
 //BA.debugLineNum = 582;BA.debugLine="If numdial.Number<10 Then 'if user wrongly enters value greater less then 10'c";
if (mostCurrent._numdial.getNumber()<10) { 
 //BA.debugLineNum = 583;BA.debugLine="Msgbox(\"Please enter the limit less between 10'C - 99'C !\",\"Error\")";
anywheresoftware.b4a.keywords.Common.Msgbox("Please enter the limit less between 10'C - 99'C !","Error",mostCurrent.activityBA);
 //BA.debugLineNum = 584;BA.debugLine="Return";
if (true) return "";
 };
 //BA.debugLineNum = 587;BA.debugLine="Dim one As Byte,two As Byte,i As Int";
_one = 0;
_two = 0;
_i = 0;
 //BA.debugLineNum = 588;BA.debugLine="one =numdial.Number Mod 10'fetch ones place number";
_one = (byte)(mostCurrent._numdial.getNumber()%10);
 //BA.debugLineNum = 589;BA.debugLine="two =numdial.Number / 10'fetch tens place number";
_two = (byte)(mostCurrent._numdial.getNumber()/(double)10);
 //BA.debugLineNum = 592;BA.debugLine="s=\"L\"";
_s = "L";
 //BA.debugLineNum = 593;BA.debugLine="astreams.Write(s.GetBytes(\"UTF8\"))";
_astreams.Write(_s.getBytes("UTF8"));
 //BA.debugLineNum = 594;BA.debugLine="For i=1 To 20000'wait some time";
{
final double step520 = 1;
final double limit520 = (int)(20000);
for (_i = (int)(1); (step520 > 0 && _i <= limit520) || (step520 < 0 && _i >= limit520); _i += step520) {
 }
};
 //BA.debugLineNum = 596;BA.debugLine="s=two";
_s = BA.NumberToString(_two);
 //BA.debugLineNum = 597;BA.debugLine="astreams.Write(s.GetBytes(\"UTF8\"))";
_astreams.Write(_s.getBytes("UTF8"));
 //BA.debugLineNum = 598;BA.debugLine="For i=1 To 20000";
{
final double step524 = 1;
final double limit524 = (int)(20000);
for (_i = (int)(1); (step524 > 0 && _i <= limit524) || (step524 < 0 && _i >= limit524); _i += step524) {
 }
};
 //BA.debugLineNum = 600;BA.debugLine="s=one";
_s = BA.NumberToString(_one);
 //BA.debugLineNum = 601;BA.debugLine="astreams.Write(s.GetBytes(\"UTF8\"))";
_astreams.Write(_s.getBytes("UTF8"));
 //BA.debugLineNum = 602;BA.debugLine="For i=1 To 20000";
{
final double step528 = 1;
final double limit528 = (int)(20000);
for (_i = (int)(1); (step528 > 0 && _i <= limit528) || (step528 < 0 && _i >= limit528); _i += step528) {
 }
};
 //BA.debugLineNum = 604;BA.debugLine="s=\"l\"";
_s = "l";
 //BA.debugLineNum = 605;BA.debugLine="astreams.Write(s.GetBytes(\"UTF8\"))";
_astreams.Write(_s.getBytes("UTF8"));
 }else if(_r==anywheresoftware.b4a.keywords.Common.DialogResponse.NEGATIVE) { 
 //BA.debugLineNum = 608;BA.debugLine="s=\"M\"";
_s = "M";
 //BA.debugLineNum = 609;BA.debugLine="astreams.Write(s.GetBytes(\"UTF8\"))";
_astreams.Write(_s.getBytes("UTF8"));
 };
 //BA.debugLineNum = 611;BA.debugLine="End Sub";
return "";
}
public static String  _buttonsenfan_longclick() throws Exception{
 //BA.debugLineNum = 962;BA.debugLine="Sub Buttonsenfan_LongClick";
 //BA.debugLineNum = 963;BA.debugLine="Msgbox(\"With this,you can program Fan/AC to switch ON/OFF automatically when the internal temperature sensor exceeds the programmed threshold value!\",\"Help\")";
anywheresoftware.b4a.keywords.Common.Msgbox("With this,you can program Fan/AC to switch ON/OFF automatically when the internal temperature sensor exceeds the programmed threshold value!","Help",mostCurrent.activityBA);
 //BA.debugLineNum = 964;BA.debugLine="End Sub";
return "";
}
public static String  _buttonsenlight1_click() throws Exception{
byte _r = 0;
byte _one = 0;
byte _two = 0;
 //BA.debugLineNum = 496;BA.debugLine="Sub Buttonsenlight1_Click";
 //BA.debugLineNum = 497;BA.debugLine="numdial.Decimal=0";
mostCurrent._numdial.setDecimal((int)(0));
 //BA.debugLineNum = 498;BA.debugLine="numdial.Digits=2";
mostCurrent._numdial.setDigits((int)(2));
 //BA.debugLineNum = 499;BA.debugLine="numdial.Number=15";
mostCurrent._numdial.setNumber((int)(15));
 //BA.debugLineNum = 500;BA.debugLine="numdial.ShowSign=False";
mostCurrent._numdial.setShowSign(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 501;BA.debugLine="Dim r As Byte";
_r = 0;
 //BA.debugLineNum = 502;BA.debugLine="r=numdial.Show(\"Light1 lower limit(%) :\",\"Prog\",\"Cancel\",\"Unprog\",Null)";
_r = (byte)(mostCurrent._numdial.Show("Light1 lower limit(%) :","Prog","Cancel","Unprog",mostCurrent.activityBA,(android.graphics.Bitmap)(anywheresoftware.b4a.keywords.Common.Null)));
 //BA.debugLineNum = 503;BA.debugLine="If r=DialogResponse.POSITIVE Then'programme the threshold value";
if (_r==anywheresoftware.b4a.keywords.Common.DialogResponse.POSITIVE) { 
 //BA.debugLineNum = 504;BA.debugLine="If numdial.Number<5 Then 'if user wrongly enters value greater less then 5%";
if (mostCurrent._numdial.getNumber()<5) { 
 //BA.debugLineNum = 505;BA.debugLine="Msgbox(\"Please enter the limit greater than 5% !\",\"Error\")";
anywheresoftware.b4a.keywords.Common.Msgbox("Please enter the limit greater than 5% !","Error",mostCurrent.activityBA);
 //BA.debugLineNum = 506;BA.debugLine="Return";
if (true) return "";
 };
 //BA.debugLineNum = 509;BA.debugLine="Dim one As Byte,two As Byte,i As Int";
_one = 0;
_two = 0;
_i = 0;
 //BA.debugLineNum = 510;BA.debugLine="one =numdial.Number Mod 10'fetch ones place number";
_one = (byte)(mostCurrent._numdial.getNumber()%10);
 //BA.debugLineNum = 511;BA.debugLine="two =numdial.Number / 10'fetch tens place number";
_two = (byte)(mostCurrent._numdial.getNumber()/(double)10);
 //BA.debugLineNum = 514;BA.debugLine="s=\"H\"";
_s = "H";
 //BA.debugLineNum = 515;BA.debugLine="astreams.Write(s.GetBytes(\"UTF8\"))";
_astreams.Write(_s.getBytes("UTF8"));
 //BA.debugLineNum = 516;BA.debugLine="For i=1 To 20000'wait some time";
{
final double step452 = 1;
final double limit452 = (int)(20000);
for (_i = (int)(1); (step452 > 0 && _i <= limit452) || (step452 < 0 && _i >= limit452); _i += step452) {
 }
};
 //BA.debugLineNum = 518;BA.debugLine="s=two";
_s = BA.NumberToString(_two);
 //BA.debugLineNum = 519;BA.debugLine="astreams.Write(s.GetBytes(\"UTF8\"))";
_astreams.Write(_s.getBytes("UTF8"));
 //BA.debugLineNum = 520;BA.debugLine="For i=1 To 20000";
{
final double step456 = 1;
final double limit456 = (int)(20000);
for (_i = (int)(1); (step456 > 0 && _i <= limit456) || (step456 < 0 && _i >= limit456); _i += step456) {
 }
};
 //BA.debugLineNum = 522;BA.debugLine="s=one";
_s = BA.NumberToString(_one);
 //BA.debugLineNum = 523;BA.debugLine="astreams.Write(s.GetBytes(\"UTF8\"))";
_astreams.Write(_s.getBytes("UTF8"));
 //BA.debugLineNum = 524;BA.debugLine="For i=1 To 20000";
{
final double step460 = 1;
final double limit460 = (int)(20000);
for (_i = (int)(1); (step460 > 0 && _i <= limit460) || (step460 < 0 && _i >= limit460); _i += step460) {
 }
};
 //BA.debugLineNum = 526;BA.debugLine="s=\"h\"";
_s = "h";
 //BA.debugLineNum = 527;BA.debugLine="astreams.Write(s.GetBytes(\"UTF8\"))";
_astreams.Write(_s.getBytes("UTF8"));
 }else if(_r==anywheresoftware.b4a.keywords.Common.DialogResponse.NEGATIVE) { 
 //BA.debugLineNum = 530;BA.debugLine="s=\"I\"";
_s = "I";
 //BA.debugLineNum = 531;BA.debugLine="astreams.Write(s.GetBytes(\"UTF8\"))";
_astreams.Write(_s.getBytes("UTF8"));
 };
 //BA.debugLineNum = 533;BA.debugLine="End Sub";
return "";
}
public static String  _buttonsenlight1_longclick() throws Exception{
 //BA.debugLineNum = 959;BA.debugLine="Sub Buttonsenlight1_LongClick";
 //BA.debugLineNum = 960;BA.debugLine="Msgbox(\"With this,you can program LIGHT1 to switch ON/OFF automatically when the external light sensor exceeds the programmed threshold value!\",\"Help\")";
anywheresoftware.b4a.keywords.Common.Msgbox("With this,you can program LIGHT1 to switch ON/OFF automatically when the external light sensor exceeds the programmed threshold value!","Help",mostCurrent.activityBA);
 //BA.debugLineNum = 961;BA.debugLine="End Sub";
return "";
}
public static String  _buttonsenlight2_click() throws Exception{
byte _r = 0;
byte _one = 0;
byte _two = 0;
 //BA.debugLineNum = 535;BA.debugLine="Sub Buttonsenlight2_Click";
 //BA.debugLineNum = 536;BA.debugLine="numdial.Decimal=0";
mostCurrent._numdial.setDecimal((int)(0));
 //BA.debugLineNum = 537;BA.debugLine="numdial.Digits=2";
mostCurrent._numdial.setDigits((int)(2));
 //BA.debugLineNum = 538;BA.debugLine="numdial.Number=15";
mostCurrent._numdial.setNumber((int)(15));
 //BA.debugLineNum = 539;BA.debugLine="numdial.ShowSign=False";
mostCurrent._numdial.setShowSign(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 540;BA.debugLine="Dim r As Byte";
_r = 0;
 //BA.debugLineNum = 541;BA.debugLine="r=numdial.Show(\"Light2 lower limit(%) :\",\"Prog\",\"Cancel\",\"Unprog\",Null)";
_r = (byte)(mostCurrent._numdial.Show("Light2 lower limit(%) :","Prog","Cancel","Unprog",mostCurrent.activityBA,(android.graphics.Bitmap)(anywheresoftware.b4a.keywords.Common.Null)));
 //BA.debugLineNum = 542;BA.debugLine="If r=DialogResponse.POSITIVE Then'programme the threshold value";
if (_r==anywheresoftware.b4a.keywords.Common.DialogResponse.POSITIVE) { 
 //BA.debugLineNum = 543;BA.debugLine="If numdial.Number<5 Then 'if user wrongly enters value greater less then 5%";
if (mostCurrent._numdial.getNumber()<5) { 
 //BA.debugLineNum = 544;BA.debugLine="Msgbox(\"Please enter the limit greater than 5% !\",\"Error\")";
anywheresoftware.b4a.keywords.Common.Msgbox("Please enter the limit greater than 5% !","Error",mostCurrent.activityBA);
 //BA.debugLineNum = 545;BA.debugLine="Return";
if (true) return "";
 };
 //BA.debugLineNum = 548;BA.debugLine="Dim one As Byte,two As Byte,i As Int";
_one = 0;
_two = 0;
_i = 0;
 //BA.debugLineNum = 549;BA.debugLine="one =numdial.Number Mod 10'fetch ones place number";
_one = (byte)(mostCurrent._numdial.getNumber()%10);
 //BA.debugLineNum = 550;BA.debugLine="two =numdial.Number / 10'fetch tens place number";
_two = (byte)(mostCurrent._numdial.getNumber()/(double)10);
 //BA.debugLineNum = 553;BA.debugLine="s=\"J\"";
_s = "J";
 //BA.debugLineNum = 554;BA.debugLine="astreams.Write(s.GetBytes(\"UTF8\"))";
_astreams.Write(_s.getBytes("UTF8"));
 //BA.debugLineNum = 555;BA.debugLine="For i=1 To 20000'wait some time";
{
final double step486 = 1;
final double limit486 = (int)(20000);
for (_i = (int)(1); (step486 > 0 && _i <= limit486) || (step486 < 0 && _i >= limit486); _i += step486) {
 }
};
 //BA.debugLineNum = 557;BA.debugLine="s=two";
_s = BA.NumberToString(_two);
 //BA.debugLineNum = 558;BA.debugLine="astreams.Write(s.GetBytes(\"UTF8\"))";
_astreams.Write(_s.getBytes("UTF8"));
 //BA.debugLineNum = 559;BA.debugLine="For i=1 To 20000";
{
final double step490 = 1;
final double limit490 = (int)(20000);
for (_i = (int)(1); (step490 > 0 && _i <= limit490) || (step490 < 0 && _i >= limit490); _i += step490) {
 }
};
 //BA.debugLineNum = 561;BA.debugLine="s=one";
_s = BA.NumberToString(_one);
 //BA.debugLineNum = 562;BA.debugLine="astreams.Write(s.GetBytes(\"UTF8\"))";
_astreams.Write(_s.getBytes("UTF8"));
 //BA.debugLineNum = 563;BA.debugLine="For i=1 To 20000";
{
final double step494 = 1;
final double limit494 = (int)(20000);
for (_i = (int)(1); (step494 > 0 && _i <= limit494) || (step494 < 0 && _i >= limit494); _i += step494) {
 }
};
 //BA.debugLineNum = 565;BA.debugLine="s=\"j\"";
_s = "j";
 //BA.debugLineNum = 566;BA.debugLine="astreams.Write(s.GetBytes(\"UTF8\"))";
_astreams.Write(_s.getBytes("UTF8"));
 }else if(_r==anywheresoftware.b4a.keywords.Common.DialogResponse.NEGATIVE) { 
 //BA.debugLineNum = 569;BA.debugLine="s=\"K\"";
_s = "K";
 //BA.debugLineNum = 570;BA.debugLine="astreams.Write(s.GetBytes(\"UTF8\"))";
_astreams.Write(_s.getBytes("UTF8"));
 };
 //BA.debugLineNum = 572;BA.debugLine="End Sub";
return "";
}
public static String  _buttonsenlight2_longclick() throws Exception{
 //BA.debugLineNum = 956;BA.debugLine="Sub Buttonsenlight2_LongClick";
 //BA.debugLineNum = 957;BA.debugLine="Msgbox(\"With this,you can program LIGHT2 to switch ON/OFF automatically when the external light sensor exceeds the programmed threshold value!\",\"Help\")";
anywheresoftware.b4a.keywords.Common.Msgbox("With this,you can program LIGHT2 to switch ON/OFF automatically when the external light sensor exceeds the programmed threshold value!","Help",mostCurrent.activityBA);
 //BA.debugLineNum = 958;BA.debugLine="End Sub";
return "";
}
public static String  _buttonsenmotion_click() throws Exception{
byte _r = 0;
 //BA.debugLineNum = 612;BA.debugLine="Sub Buttonsenmotion_Click";
 //BA.debugLineNum = 613;BA.debugLine="Dim r As Byte";
_r = 0;
 //BA.debugLineNum = 614;BA.debugLine="r=Msgbox2(\"Do you want to program the motion sensor to switch ON Light2(outside) if motion is detected on the entrance?\",\"Motion sensor alarm\",\"Prog\",\"Cancel\",\"Unprog\",Null)";
_r = (byte)(anywheresoftware.b4a.keywords.Common.Msgbox2("Do you want to program the motion sensor to switch ON Light2(outside) if motion is detected on the entrance?","Motion sensor alarm","Prog","Cancel","Unprog",(android.graphics.Bitmap)(anywheresoftware.b4a.keywords.Common.Null),mostCurrent.activityBA));
 //BA.debugLineNum = 615;BA.debugLine="If r=DialogResponse.POSITIVE Then'programme the alarm";
if (_r==anywheresoftware.b4a.keywords.Common.DialogResponse.POSITIVE) { 
 //BA.debugLineNum = 616;BA.debugLine="s=\"G\"";
_s = "G";
 //BA.debugLineNum = 617;BA.debugLine="astreams.Write(s.GetBytes(\"UTF8\"))";
_astreams.Write(_s.getBytes("UTF8"));
 }else if(_r==anywheresoftware.b4a.keywords.Common.DialogResponse.NEGATIVE) { 
 //BA.debugLineNum = 619;BA.debugLine="s=\"g\"";
_s = "g";
 //BA.debugLineNum = 620;BA.debugLine="astreams.Write(s.GetBytes(\"UTF8\"))";
_astreams.Write(_s.getBytes("UTF8"));
 };
 //BA.debugLineNum = 622;BA.debugLine="End Sub";
return "";
}
public static String  _buttonsenmotion_longclick() throws Exception{
 //BA.debugLineNum = 953;BA.debugLine="Sub Buttonsenmotion_LongClick";
 //BA.debugLineNum = 954;BA.debugLine="Msgbox(\"With this,you can program the motion sensor to switch ON Light2(outside)when motion is detected at the entrance door\",\"Help\")";
anywheresoftware.b4a.keywords.Common.Msgbox("With this,you can program the motion sensor to switch ON Light2(outside)when motion is detected at the entrance door","Help",mostCurrent.activityBA);
 //BA.debugLineNum = 955;BA.debugLine="End Sub";
return "";
}
public static String  _buttonsleepmode_click() throws Exception{
 //BA.debugLineNum = 623;BA.debugLine="Sub Buttonsleepmode_Click'turn ON sleep mode";
 //BA.debugLineNum = 624;BA.debugLine="s=\"S\"";
_s = "S";
 //BA.debugLineNum = 625;BA.debugLine="astreams.Write(s.GetBytes(\"UTF8\"))";
_astreams.Write(_s.getBytes("UTF8"));
 //BA.debugLineNum = 626;BA.debugLine="End Sub";
return "";
}
public static String  _buttonsleepmode_longclick() throws Exception{
 //BA.debugLineNum = 989;BA.debugLine="Sub Buttonsleepmode_LongClick";
 //BA.debugLineNum = 990;BA.debugLine="Msgbox(\"With this,you can activate the sleep mode which will turn off all devices and, activate the door and motion alarm so that you can sleep with no worries!\",\"Help\")";
anywheresoftware.b4a.keywords.Common.Msgbox("With this,you can activate the sleep mode which will turn off all devices and, activate the door and motion alarm so that you can sleep with no worries!","Help",mostCurrent.activityBA);
 //BA.debugLineNum = 991;BA.debugLine="End Sub";
return "";
}
public static String  _buttonsleepmodeoff_click() throws Exception{
 //BA.debugLineNum = 627;BA.debugLine="Sub Buttonsleepmodeoff_Click'turn OFF sleep mode";
 //BA.debugLineNum = 628;BA.debugLine="s=\"T\"";
_s = "T";
 //BA.debugLineNum = 629;BA.debugLine="astreams.Write(s.GetBytes(\"UTF8\"))";
_astreams.Write(_s.getBytes("UTF8"));
 //BA.debugLineNum = 630;BA.debugLine="End Sub";
return "";
}
public static String  _buttonsleepmodeoff_longclick() throws Exception{
 //BA.debugLineNum = 992;BA.debugLine="Sub Buttonsleepmodeoff_LongClick";
 //BA.debugLineNum = 993;BA.debugLine="Msgbox(\"With this,you can deactivate the sleep mode!\",\"Help\")";
anywheresoftware.b4a.keywords.Common.Msgbox("With this,you can deactivate the sleep mode!","Help",mostCurrent.activityBA);
 //BA.debugLineNum = 994;BA.debugLine="End Sub";
return "";
}
public static String  _buttontvoff_click() throws Exception{
 //BA.debugLineNum = 449;BA.debugLine="Sub Buttontvoff_Click";
 //BA.debugLineNum = 450;BA.debugLine="s=\"c\"";
_s = "c";
 //BA.debugLineNum = 451;BA.debugLine="astreams.Write(s.GetBytes(\"UTF8\"))";
_astreams.Write(_s.getBytes("UTF8"));
 //BA.debugLineNum = 452;BA.debugLine="End Sub";
return "";
}
public static String  _buttontvon_click() throws Exception{
 //BA.debugLineNum = 445;BA.debugLine="Sub Buttontvon_Click";
 //BA.debugLineNum = 446;BA.debugLine="s=\"C\"";
_s = "C";
 //BA.debugLineNum = 447;BA.debugLine="astreams.Write(s.GetBytes(\"UTF8\"))";
_astreams.Write(_s.getBytes("UTF8"));
 //BA.debugLineNum = 448;BA.debugLine="End Sub";
return "";
}
public static String  _disable_main_views() throws Exception{
 //BA.debugLineNum = 391;BA.debugLine="Sub disable_main_views";
 //BA.debugLineNum = 392;BA.debugLine="Buttonfanoff.Enabled=False";
mostCurrent._buttonfanoff.setEnabled(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 393;BA.debugLine="Buttonfanon.Enabled=False";
mostCurrent._buttonfanon.setEnabled(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 394;BA.debugLine="Buttonlight1off.Enabled=False";
mostCurrent._buttonlight1off.setEnabled(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 395;BA.debugLine="Buttonlight1on.Enabled=False";
mostCurrent._buttonlight1on.setEnabled(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 396;BA.debugLine="Buttonlight2off.Enabled=False";
mostCurrent._buttonlight2off.setEnabled(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 397;BA.debugLine="Buttonlight2on.Enabled=False";
mostCurrent._buttonlight2on.setEnabled(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 398;BA.debugLine="Buttontvoff.Enabled=False";
mostCurrent._buttontvoff.setEnabled(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 399;BA.debugLine="Buttontvon.Enabled=False";
mostCurrent._buttontvon.setEnabled(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 400;BA.debugLine="Buttonallon.Enabled=False";
mostCurrent._buttonallon.setEnabled(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 401;BA.debugLine="Buttonalloff.Enabled=False";
mostCurrent._buttonalloff.setEnabled(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 402;BA.debugLine="Buttondoor.Enabled=False";
mostCurrent._buttondoor.setEnabled(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 403;BA.debugLine="Buttonsenlight1.Enabled=False";
mostCurrent._buttonsenlight1.setEnabled(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 404;BA.debugLine="Buttonsleepmode.Enabled=False";
mostCurrent._buttonsleepmode.setEnabled(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 405;BA.debugLine="Buttonsenlight2.Enabled=False";
mostCurrent._buttonsenlight2.setEnabled(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 406;BA.debugLine="Buttonsenfan.Enabled=False";
mostCurrent._buttonsenfan.setEnabled(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 407;BA.debugLine="Buttonsenmotion.Enabled=False";
mostCurrent._buttonsenmotion.setEnabled(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 408;BA.debugLine="Buttonsavelog.Enabled=False";
mostCurrent._buttonsavelog.setEnabled(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 409;BA.debugLine="Buttonconnect.Enabled=False";
mostCurrent._buttonconnect.setEnabled(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 410;BA.debugLine="Buttonsleepmodeoff.Enabled=False";
mostCurrent._buttonsleepmodeoff.setEnabled(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 411;BA.debugLine="Buttonprogfire.Enabled=False";
mostCurrent._buttonprogfire.setEnabled(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 413;BA.debugLine="Labeltempout.Text=\"000\"";
mostCurrent._labeltempout.setText((Object)("000"));
 //BA.debugLineNum = 414;BA.debugLine="Labeltempin.Text=\"000\"";
mostCurrent._labeltempin.setText((Object)("000"));
 //BA.debugLineNum = 415;BA.debugLine="Labellightout.Text=\"000\"";
mostCurrent._labellightout.setText((Object)("000"));
 //BA.debugLineNum = 416;BA.debugLine="Labellightin.Text=\"000\"";
mostCurrent._labellightin.setText((Object)("000"));
 //BA.debugLineNum = 417;BA.debugLine="Labelmotion.Text=\"NO MOTION\"";
mostCurrent._labelmotion.setText((Object)("NO MOTION"));
 //BA.debugLineNum = 418;BA.debugLine="Labellpg.Text=\"NO LEAK\"";
mostCurrent._labellpg.setText((Object)("NO LEAK"));
 //BA.debugLineNum = 421;BA.debugLine="Buttonlight1on.TextColor=Colors.Black";
mostCurrent._buttonlight1on.setTextColor(anywheresoftware.b4a.keywords.Common.Colors.Black);
 //BA.debugLineNum = 422;BA.debugLine="Buttonlight1off.TextColor=Colors.black";
mostCurrent._buttonlight1off.setTextColor(anywheresoftware.b4a.keywords.Common.Colors.Black);
 //BA.debugLineNum = 423;BA.debugLine="Buttonlight2on.TextColor=Colors.black";
mostCurrent._buttonlight2on.setTextColor(anywheresoftware.b4a.keywords.Common.Colors.Black);
 //BA.debugLineNum = 424;BA.debugLine="Buttonlight2off.TextColor=Colors.black";
mostCurrent._buttonlight2off.setTextColor(anywheresoftware.b4a.keywords.Common.Colors.Black);
 //BA.debugLineNum = 425;BA.debugLine="Buttontvon.TextColor=Colors.black";
mostCurrent._buttontvon.setTextColor(anywheresoftware.b4a.keywords.Common.Colors.Black);
 //BA.debugLineNum = 426;BA.debugLine="Buttontvoff.TextColor=Colors.black";
mostCurrent._buttontvoff.setTextColor(anywheresoftware.b4a.keywords.Common.Colors.Black);
 //BA.debugLineNum = 427;BA.debugLine="Buttonfanon.TextColor=Colors.black";
mostCurrent._buttonfanon.setTextColor(anywheresoftware.b4a.keywords.Common.Colors.Black);
 //BA.debugLineNum = 428;BA.debugLine="Buttonfanoff.TextColor=Colors.black";
mostCurrent._buttonfanoff.setTextColor(anywheresoftware.b4a.keywords.Common.Colors.Black);
 //BA.debugLineNum = 429;BA.debugLine="Buttonsleepmode.Textcolor=Colors.black";
mostCurrent._buttonsleepmode.setTextColor(anywheresoftware.b4a.keywords.Common.Colors.Black);
 //BA.debugLineNum = 430;BA.debugLine="Buttonsleepmodeoff.Textcolor=Colors.black";
mostCurrent._buttonsleepmodeoff.setTextColor(anywheresoftware.b4a.keywords.Common.Colors.Black);
 //BA.debugLineNum = 432;BA.debugLine="Buttondoor.Text=\"OPEN\"";
mostCurrent._buttondoor.setText((Object)("OPEN"));
 //BA.debugLineNum = 433;BA.debugLine="Imagedoorstatus.Bitmap=LoadBitmap(File.DirAssets,\"close_door.png\")'closed gate graphic loading";
mostCurrent._imagedoorstatus.setBitmap((android.graphics.Bitmap)(anywheresoftware.b4a.keywords.Common.LoadBitmap(anywheresoftware.b4a.keywords.Common.File.getDirAssets(),"close_door.png").getObject()));
 //BA.debugLineNum = 434;BA.debugLine="Labeldoorstatus.Text=\"DOOR CLOSED\"";
mostCurrent._labeldoorstatus.setText((Object)("DOOR CLOSED"));
 //BA.debugLineNum = 436;BA.debugLine="Buttonsenmotion.Text=\"Unprogrammed\"";
mostCurrent._buttonsenmotion.setText((Object)("Unprogrammed"));
 //BA.debugLineNum = 437;BA.debugLine="Buttonsenlight1.Text=\"Unprogrammed\"";
mostCurrent._buttonsenlight1.setText((Object)("Unprogrammed"));
 //BA.debugLineNum = 438;BA.debugLine="Buttonsenlight2.Text=\"Unprogrammed\"";
mostCurrent._buttonsenlight2.setText((Object)("Unprogrammed"));
 //BA.debugLineNum = 439;BA.debugLine="Buttonsenfan.Text=\"Unprogrammed\"";
mostCurrent._buttonsenfan.setText((Object)("Unprogrammed"));
 //BA.debugLineNum = 440;BA.debugLine="End Sub";
return "";
}
public static String  _enable_main_views() throws Exception{
 //BA.debugLineNum = 362;BA.debugLine="Sub enable_main_views";
 //BA.debugLineNum = 363;BA.debugLine="Buttonfanoff.Enabled=True";
mostCurrent._buttonfanoff.setEnabled(anywheresoftware.b4a.keywords.Common.True);
 //BA.debugLineNum = 364;BA.debugLine="Buttonfanon.Enabled=True";
mostCurrent._buttonfanon.setEnabled(anywheresoftware.b4a.keywords.Common.True);
 //BA.debugLineNum = 365;BA.debugLine="Buttonlight1off.Enabled=True";
mostCurrent._buttonlight1off.setEnabled(anywheresoftware.b4a.keywords.Common.True);
 //BA.debugLineNum = 366;BA.debugLine="Buttonlight1on.Enabled=True";
mostCurrent._buttonlight1on.setEnabled(anywheresoftware.b4a.keywords.Common.True);
 //BA.debugLineNum = 367;BA.debugLine="Buttonlight2off.Enabled=True";
mostCurrent._buttonlight2off.setEnabled(anywheresoftware.b4a.keywords.Common.True);
 //BA.debugLineNum = 368;BA.debugLine="Buttonlight2on.Enabled=True";
mostCurrent._buttonlight2on.setEnabled(anywheresoftware.b4a.keywords.Common.True);
 //BA.debugLineNum = 369;BA.debugLine="Buttontvoff.Enabled=True";
mostCurrent._buttontvoff.setEnabled(anywheresoftware.b4a.keywords.Common.True);
 //BA.debugLineNum = 370;BA.debugLine="Buttontvon.Enabled=True";
mostCurrent._buttontvon.setEnabled(anywheresoftware.b4a.keywords.Common.True);
 //BA.debugLineNum = 371;BA.debugLine="Buttonallon.Enabled=True";
mostCurrent._buttonallon.setEnabled(anywheresoftware.b4a.keywords.Common.True);
 //BA.debugLineNum = 372;BA.debugLine="Buttonalloff.Enabled=True";
mostCurrent._buttonalloff.setEnabled(anywheresoftware.b4a.keywords.Common.True);
 //BA.debugLineNum = 373;BA.debugLine="Buttondoor.Enabled=True";
mostCurrent._buttondoor.setEnabled(anywheresoftware.b4a.keywords.Common.True);
 //BA.debugLineNum = 374;BA.debugLine="Buttonsenlight1.Enabled=True";
mostCurrent._buttonsenlight1.setEnabled(anywheresoftware.b4a.keywords.Common.True);
 //BA.debugLineNum = 375;BA.debugLine="Buttonsenlight2.Enabled=True";
mostCurrent._buttonsenlight2.setEnabled(anywheresoftware.b4a.keywords.Common.True);
 //BA.debugLineNum = 376;BA.debugLine="Buttonsenfan.Enabled=True";
mostCurrent._buttonsenfan.setEnabled(anywheresoftware.b4a.keywords.Common.True);
 //BA.debugLineNum = 377;BA.debugLine="Buttonsenmotion.Enabled=True";
mostCurrent._buttonsenmotion.setEnabled(anywheresoftware.b4a.keywords.Common.True);
 //BA.debugLineNum = 378;BA.debugLine="Buttonsavelog.Enabled=True";
mostCurrent._buttonsavelog.setEnabled(anywheresoftware.b4a.keywords.Common.True);
 //BA.debugLineNum = 379;BA.debugLine="Buttonconnect.Enabled=True";
mostCurrent._buttonconnect.setEnabled(anywheresoftware.b4a.keywords.Common.True);
 //BA.debugLineNum = 380;BA.debugLine="Buttonsleepmode.Enabled=True";
mostCurrent._buttonsleepmode.setEnabled(anywheresoftware.b4a.keywords.Common.True);
 //BA.debugLineNum = 381;BA.debugLine="Buttonsleepmodeoff.Enabled=True";
mostCurrent._buttonsleepmodeoff.setEnabled(anywheresoftware.b4a.keywords.Common.True);
 //BA.debugLineNum = 382;BA.debugLine="Labeltempout.Text=\"000\"";
mostCurrent._labeltempout.setText((Object)("000"));
 //BA.debugLineNum = 383;BA.debugLine="Labeltempin.Text=\"000\"";
mostCurrent._labeltempin.setText((Object)("000"));
 //BA.debugLineNum = 384;BA.debugLine="Labellightout.Text=\"000\"";
mostCurrent._labellightout.setText((Object)("000"));
 //BA.debugLineNum = 385;BA.debugLine="Labellightin.Text=\"000\"";
mostCurrent._labellightin.setText((Object)("000"));
 //BA.debugLineNum = 386;BA.debugLine="Labelmotion.Text=\"NO MOTION\"";
mostCurrent._labelmotion.setText((Object)("NO MOTION"));
 //BA.debugLineNum = 387;BA.debugLine="Labellpg.Text=\"NO LEAK\"";
mostCurrent._labellpg.setText((Object)("NO LEAK"));
 //BA.debugLineNum = 388;BA.debugLine="Buttonprogfire.Enabled=True";
mostCurrent._buttonprogfire.setEnabled(anywheresoftware.b4a.keywords.Common.True);
 //BA.debugLineNum = 389;BA.debugLine="End Sub";
return "";
}

public static void initializeProcessGlobals() {
    
    if (processGlobalsRun == false) {
	    processGlobalsRun = true;
		try {
		        main._process_globals();
		
        } catch (Exception e) {
			throw new RuntimeException(e);
		}
    }
}
public static String  _globals() throws Exception{
 //BA.debugLineNum = 15;BA.debugLine="Sub Globals";
 //BA.debugLineNum = 18;BA.debugLine="Dim numdial As NumberDialog";
mostCurrent._numdial = new anywheresoftware.b4a.agraham.dialogs.InputDialog.NumberDialog();
 //BA.debugLineNum = 19;BA.debugLine="Dim inpbox As InputDialog";
mostCurrent._inpbox = new anywheresoftware.b4a.agraham.dialogs.InputDialog();
 //BA.debugLineNum = 21;BA.debugLine="Dim t1 As Timer,t2 As Timer	'for animation";
mostCurrent._t1 = new anywheresoftware.b4a.objects.Timer();
mostCurrent._t2 = new anywheresoftware.b4a.objects.Timer();
 //BA.debugLineNum = 22;BA.debugLine="Dim i As Int";
_i = 0;
 //BA.debugLineNum = 23;BA.debugLine="Dim animate1 As Animation,animate2 As Animation";
mostCurrent._animate1 = new anywheresoftware.b4a.objects.AnimationWrapper();
mostCurrent._animate2 = new anywheresoftware.b4a.objects.AnimationWrapper();
 //BA.debugLineNum = 24;BA.debugLine="Dim panimate1 As Animation";
mostCurrent._panimate1 = new anywheresoftware.b4a.objects.AnimationWrapper();
 //BA.debugLineNum = 25;BA.debugLine="Dim ImageView1 As ImageView	'home";
mostCurrent._imageview1 = new anywheresoftware.b4a.objects.ImageViewWrapper();
 //BA.debugLineNum = 26;BA.debugLine="Dim ImageView2 As ImageView	'mobile";
mostCurrent._imageview2 = new anywheresoftware.b4a.objects.ImageViewWrapper();
 //BA.debugLineNum = 27;BA.debugLine="Dim Label1 As Label	'smartphone based";
mostCurrent._label1 = new anywheresoftware.b4a.objects.LabelWrapper();
 //BA.debugLineNum = 28;BA.debugLine="Dim Label2 As Label	'home automation";
mostCurrent._label2 = new anywheresoftware.b4a.objects.LabelWrapper();
 //BA.debugLineNum = 29;BA.debugLine="Dim Label3 As Label	'first dot";
mostCurrent._label3 = new anywheresoftware.b4a.objects.LabelWrapper();
 //BA.debugLineNum = 30;BA.debugLine="Dim Label4 As Label	'second dot";
mostCurrent._label4 = new anywheresoftware.b4a.objects.LabelWrapper();
 //BA.debugLineNum = 31;BA.debugLine="Dim Label5 As Label	'third dot";
mostCurrent._label5 = new anywheresoftware.b4a.objects.LabelWrapper();
 //BA.debugLineNum = 32;BA.debugLine="Dim Label6 As Label";
mostCurrent._label6 = new anywheresoftware.b4a.objects.LabelWrapper();
 //BA.debugLineNum = 33;BA.debugLine="Dim Labelfan As Label";
mostCurrent._labelfan = new anywheresoftware.b4a.objects.LabelWrapper();
 //BA.debugLineNum = 34;BA.debugLine="Dim Labellight1 As Label";
mostCurrent._labellight1 = new anywheresoftware.b4a.objects.LabelWrapper();
 //BA.debugLineNum = 35;BA.debugLine="Dim Labellight2 As Label";
mostCurrent._labellight2 = new anywheresoftware.b4a.objects.LabelWrapper();
 //BA.debugLineNum = 36;BA.debugLine="Dim Labeltelevision As Label";
mostCurrent._labeltelevision = new anywheresoftware.b4a.objects.LabelWrapper();
 //BA.debugLineNum = 37;BA.debugLine="Dim Panelappliances As Panel";
mostCurrent._panelappliances = new anywheresoftware.b4a.objects.PanelWrapper();
 //BA.debugLineNum = 38;BA.debugLine="Dim Buttondoor As Button";
mostCurrent._buttondoor = new anywheresoftware.b4a.objects.ButtonWrapper();
 //BA.debugLineNum = 39;BA.debugLine="Dim Buttonsenfan As Button";
mostCurrent._buttonsenfan = new anywheresoftware.b4a.objects.ButtonWrapper();
 //BA.debugLineNum = 40;BA.debugLine="Dim Buttonsenlight1 As Button";
mostCurrent._buttonsenlight1 = new anywheresoftware.b4a.objects.ButtonWrapper();
 //BA.debugLineNum = 41;BA.debugLine="Dim Buttonsenlight2 As Button";
mostCurrent._buttonsenlight2 = new anywheresoftware.b4a.objects.ButtonWrapper();
 //BA.debugLineNum = 42;BA.debugLine="Dim Imageappliance As ImageView";
mostCurrent._imageappliance = new anywheresoftware.b4a.objects.ImageViewWrapper();
 //BA.debugLineNum = 43;BA.debugLine="Dim Imagedoor As ImageView";
mostCurrent._imagedoor = new anywheresoftware.b4a.objects.ImageViewWrapper();
 //BA.debugLineNum = 44;BA.debugLine="Dim Imagedoorstatus As ImageView";
mostCurrent._imagedoorstatus = new anywheresoftware.b4a.objects.ImageViewWrapper();
 //BA.debugLineNum = 45;BA.debugLine="Dim Imagesensomate As ImageView";
mostCurrent._imagesensomate = new anywheresoftware.b4a.objects.ImageViewWrapper();
 //BA.debugLineNum = 46;BA.debugLine="Dim Imagesensors As ImageView";
mostCurrent._imagesensors = new anywheresoftware.b4a.objects.ImageViewWrapper();
 //BA.debugLineNum = 47;BA.debugLine="Dim Imagesettings As ImageView";
mostCurrent._imagesettings = new anywheresoftware.b4a.objects.ImageViewWrapper();
 //BA.debugLineNum = 48;BA.debugLine="Dim Label10 As Label";
mostCurrent._label10 = new anywheresoftware.b4a.objects.LabelWrapper();
 //BA.debugLineNum = 49;BA.debugLine="Dim Label11 As Label";
mostCurrent._label11 = new anywheresoftware.b4a.objects.LabelWrapper();
 //BA.debugLineNum = 50;BA.debugLine="Dim Label12 As Label";
mostCurrent._label12 = new anywheresoftware.b4a.objects.LabelWrapper();
 //BA.debugLineNum = 51;BA.debugLine="Dim Label13 As Label";
mostCurrent._label13 = new anywheresoftware.b4a.objects.LabelWrapper();
 //BA.debugLineNum = 52;BA.debugLine="Dim Label14 As Label";
mostCurrent._label14 = new anywheresoftware.b4a.objects.LabelWrapper();
 //BA.debugLineNum = 53;BA.debugLine="Dim Label15 As Label";
mostCurrent._label15 = new anywheresoftware.b4a.objects.LabelWrapper();
 //BA.debugLineNum = 54;BA.debugLine="Dim Label16 As Label";
mostCurrent._label16 = new anywheresoftware.b4a.objects.LabelWrapper();
 //BA.debugLineNum = 55;BA.debugLine="Dim Label17 As Label";
mostCurrent._label17 = new anywheresoftware.b4a.objects.LabelWrapper();
 //BA.debugLineNum = 56;BA.debugLine="Dim Label18 As Label";
mostCurrent._label18 = new anywheresoftware.b4a.objects.LabelWrapper();
 //BA.debugLineNum = 57;BA.debugLine="Dim Label7 As Label";
mostCurrent._label7 = new anywheresoftware.b4a.objects.LabelWrapper();
 //BA.debugLineNum = 58;BA.debugLine="Dim Label8 As Label";
mostCurrent._label8 = new anywheresoftware.b4a.objects.LabelWrapper();
 //BA.debugLineNum = 59;BA.debugLine="Dim Label9 As Label";
mostCurrent._label9 = new anywheresoftware.b4a.objects.LabelWrapper();
 //BA.debugLineNum = 60;BA.debugLine="Dim Labeldoorstatus As Label";
mostCurrent._labeldoorstatus = new anywheresoftware.b4a.objects.LabelWrapper();
 //BA.debugLineNum = 61;BA.debugLine="Dim Labellightin As Label";
mostCurrent._labellightin = new anywheresoftware.b4a.objects.LabelWrapper();
 //BA.debugLineNum = 62;BA.debugLine="Dim Labellightout As Label";
mostCurrent._labellightout = new anywheresoftware.b4a.objects.LabelWrapper();
 //BA.debugLineNum = 63;BA.debugLine="Dim Labelmotion As Label";
mostCurrent._labelmotion = new anywheresoftware.b4a.objects.LabelWrapper();
 //BA.debugLineNum = 64;BA.debugLine="Dim Labeltempin As Label";
mostCurrent._labeltempin = new anywheresoftware.b4a.objects.LabelWrapper();
 //BA.debugLineNum = 65;BA.debugLine="Dim Labeltempout As Label";
mostCurrent._labeltempout = new anywheresoftware.b4a.objects.LabelWrapper();
 //BA.debugLineNum = 66;BA.debugLine="Dim Paneldoor As Panel";
mostCurrent._paneldoor = new anywheresoftware.b4a.objects.PanelWrapper();
 //BA.debugLineNum = 67;BA.debugLine="Dim Panelsensomate As Panel";
mostCurrent._panelsensomate = new anywheresoftware.b4a.objects.PanelWrapper();
 //BA.debugLineNum = 68;BA.debugLine="Dim Panelsensors As Panel";
mostCurrent._panelsensors = new anywheresoftware.b4a.objects.PanelWrapper();
 //BA.debugLineNum = 69;BA.debugLine="Dim Panelsettings As Panel";
mostCurrent._panelsettings = new anywheresoftware.b4a.objects.PanelWrapper();
 //BA.debugLineNum = 70;BA.debugLine="Dim Buttonsavelog As Button";
mostCurrent._buttonsavelog = new anywheresoftware.b4a.objects.ButtonWrapper();
 //BA.debugLineNum = 71;BA.debugLine="Dim Buttonbluetoothswitch As Button";
mostCurrent._buttonbluetoothswitch = new anywheresoftware.b4a.objects.ButtonWrapper();
 //BA.debugLineNum = 72;BA.debugLine="Dim ImageView3 As ImageView";
mostCurrent._imageview3 = new anywheresoftware.b4a.objects.ImageViewWrapper();
 //BA.debugLineNum = 73;BA.debugLine="Dim Label19 As Label";
mostCurrent._label19 = new anywheresoftware.b4a.objects.LabelWrapper();
 //BA.debugLineNum = 74;BA.debugLine="Dim Labelbluetoothstatus As Label";
mostCurrent._labelbluetoothstatus = new anywheresoftware.b4a.objects.LabelWrapper();
 //BA.debugLineNum = 75;BA.debugLine="Dim Buttonconnect As Button";
mostCurrent._buttonconnect = new anywheresoftware.b4a.objects.ButtonWrapper();
 //BA.debugLineNum = 76;BA.debugLine="Dim Buttonsenmotion As Button";
mostCurrent._buttonsenmotion = new anywheresoftware.b4a.objects.ButtonWrapper();
 //BA.debugLineNum = 77;BA.debugLine="Dim Label20 As Label";
mostCurrent._label20 = new anywheresoftware.b4a.objects.LabelWrapper();
 //BA.debugLineNum = 78;BA.debugLine="Dim Buttonpassword As Button";
mostCurrent._buttonpassword = new anywheresoftware.b4a.objects.ButtonWrapper();
 //BA.debugLineNum = 79;BA.debugLine="Dim Buttonalloff As Button";
mostCurrent._buttonalloff = new anywheresoftware.b4a.objects.ButtonWrapper();
 //BA.debugLineNum = 80;BA.debugLine="Dim Buttonallon As Button";
mostCurrent._buttonallon = new anywheresoftware.b4a.objects.ButtonWrapper();
 //BA.debugLineNum = 81;BA.debugLine="Dim Buttonsleepmode As Button";
mostCurrent._buttonsleepmode = new anywheresoftware.b4a.objects.ButtonWrapper();
 //BA.debugLineNum = 82;BA.debugLine="Dim Panelabout As Panel";
mostCurrent._panelabout = new anywheresoftware.b4a.objects.PanelWrapper();
 //BA.debugLineNum = 83;BA.debugLine="Dim Labellpg As Label";
mostCurrent._labellpg = new anywheresoftware.b4a.objects.LabelWrapper();
 //BA.debugLineNum = 84;BA.debugLine="Dim Buttonfanoff As Button";
mostCurrent._buttonfanoff = new anywheresoftware.b4a.objects.ButtonWrapper();
 //BA.debugLineNum = 85;BA.debugLine="Dim Buttonfanon As Button";
mostCurrent._buttonfanon = new anywheresoftware.b4a.objects.ButtonWrapper();
 //BA.debugLineNum = 86;BA.debugLine="Dim Buttonlight1off As Button";
mostCurrent._buttonlight1off = new anywheresoftware.b4a.objects.ButtonWrapper();
 //BA.debugLineNum = 87;BA.debugLine="Dim Buttonlight1on As Button";
mostCurrent._buttonlight1on = new anywheresoftware.b4a.objects.ButtonWrapper();
 //BA.debugLineNum = 88;BA.debugLine="Dim Buttonlight2off As Button";
mostCurrent._buttonlight2off = new anywheresoftware.b4a.objects.ButtonWrapper();
 //BA.debugLineNum = 89;BA.debugLine="Dim Buttonlight2on As Button";
mostCurrent._buttonlight2on = new anywheresoftware.b4a.objects.ButtonWrapper();
 //BA.debugLineNum = 90;BA.debugLine="Dim Buttontvoff As Button";
mostCurrent._buttontvoff = new anywheresoftware.b4a.objects.ButtonWrapper();
 //BA.debugLineNum = 91;BA.debugLine="Dim Buttontvon As Button";
mostCurrent._buttontvon = new anywheresoftware.b4a.objects.ButtonWrapper();
 //BA.debugLineNum = 92;BA.debugLine="Dim Buttonresetautoconnect As Button";
mostCurrent._buttonresetautoconnect = new anywheresoftware.b4a.objects.ButtonWrapper();
 //BA.debugLineNum = 93;BA.debugLine="Dim Buttonsleepmodeoff As Button";
mostCurrent._buttonsleepmodeoff = new anywheresoftware.b4a.objects.ButtonWrapper();
 //BA.debugLineNum = 94;BA.debugLine="Dim ImageView4 As ImageView";
mostCurrent._imageview4 = new anywheresoftware.b4a.objects.ImageViewWrapper();
 //BA.debugLineNum = 95;BA.debugLine="Dim ImageView5 As ImageView";
mostCurrent._imageview5 = new anywheresoftware.b4a.objects.ImageViewWrapper();
 //BA.debugLineNum = 96;BA.debugLine="Dim ImageView6 As ImageView";
mostCurrent._imageview6 = new anywheresoftware.b4a.objects.ImageViewWrapper();
 //BA.debugLineNum = 97;BA.debugLine="Dim ImageView7 As ImageView";
mostCurrent._imageview7 = new anywheresoftware.b4a.objects.ImageViewWrapper();
 //BA.debugLineNum = 98;BA.debugLine="Dim Label21 As Label";
mostCurrent._label21 = new anywheresoftware.b4a.objects.LabelWrapper();
 //BA.debugLineNum = 99;BA.debugLine="Dim Label22 As Label";
mostCurrent._label22 = new anywheresoftware.b4a.objects.LabelWrapper();
 //BA.debugLineNum = 100;BA.debugLine="Dim Label23 As Label";
mostCurrent._label23 = new anywheresoftware.b4a.objects.LabelWrapper();
 //BA.debugLineNum = 101;BA.debugLine="Dim Buttonprogfire As Button";
mostCurrent._buttonprogfire = new anywheresoftware.b4a.objects.ButtonWrapper();
 //BA.debugLineNum = 102;BA.debugLine="End Sub";
return "";
}
public static String  _imageappliance_click() throws Exception{
 //BA.debugLineNum = 948;BA.debugLine="Sub Imageappliance_Click";
 //BA.debugLineNum = 949;BA.debugLine="mp.Load(File.DirAssets,\"help_appliances.wav\")";
_mp.Load(anywheresoftware.b4a.keywords.Common.File.getDirAssets(),"help_appliances.wav");
 //BA.debugLineNum = 950;BA.debugLine="mp.Play";
_mp.Play();
 //BA.debugLineNum = 951;BA.debugLine="Msgbox(\"With this,you can manually switch ON/OFF your home appliances!\",\"HELP\")";
anywheresoftware.b4a.keywords.Common.Msgbox("With this,you can manually switch ON/OFF your home appliances!","HELP",mostCurrent.activityBA);
 //BA.debugLineNum = 952;BA.debugLine="End Sub";
return "";
}
public static String  _imagedoor_click() throws Exception{
 //BA.debugLineNum = 943;BA.debugLine="Sub Imagedoor_Click";
 //BA.debugLineNum = 944;BA.debugLine="mp.Load(File.DirAssets,\"help_door.wav\")";
_mp.Load(anywheresoftware.b4a.keywords.Common.File.getDirAssets(),"help_door.wav");
 //BA.debugLineNum = 945;BA.debugLine="mp.Play";
_mp.Play();
 //BA.debugLineNum = 946;BA.debugLine="Msgbox(\"With this,you can check and control your main entrance door!\",\"HELP\")";
anywheresoftware.b4a.keywords.Common.Msgbox("With this,you can check and control your main entrance door!","HELP",mostCurrent.activityBA);
 //BA.debugLineNum = 947;BA.debugLine="End Sub";
return "";
}
public static String  _imagesensomate_click() throws Exception{
 //BA.debugLineNum = 938;BA.debugLine="Sub Imagesensomate_Click";
 //BA.debugLineNum = 939;BA.debugLine="mp.Load(File.DirAssets,\"help_sensomate.wav\")";
_mp.Load(anywheresoftware.b4a.keywords.Common.File.getDirAssets(),"help_sensomate.wav");
 //BA.debugLineNum = 940;BA.debugLine="mp.Play";
_mp.Play();
 //BA.debugLineNum = 941;BA.debugLine="Msgbox(\"With this,you can automate your lights and fan/AC to switch ON/OFF automatically when the light and temperature of your home exceeds a programmable threshold value, and also your motion sensor to activate outdoor light on activity at main door!\",\"HELP\")";
anywheresoftware.b4a.keywords.Common.Msgbox("With this,you can automate your lights and fan/AC to switch ON/OFF automatically when the light and temperature of your home exceeds a programmable threshold value, and also your motion sensor to activate outdoor light on activity at main door!","HELP",mostCurrent.activityBA);
 //BA.debugLineNum = 942;BA.debugLine="End Sub";
return "";
}
public static String  _imagesensors_click() throws Exception{
 //BA.debugLineNum = 933;BA.debugLine="Sub Imagesensors_Click";
 //BA.debugLineNum = 934;BA.debugLine="mp.Load(File.DirAssets,\"help_sensors.wav\")";
_mp.Load(anywheresoftware.b4a.keywords.Common.File.getDirAssets(),"help_sensors.wav");
 //BA.debugLineNum = 935;BA.debugLine="mp.Play";
_mp.Play();
 //BA.debugLineNum = 936;BA.debugLine="Msgbox(\"With this,you can monitor temperature and light conditions outside and inside of your home!\",\"HELP\")";
anywheresoftware.b4a.keywords.Common.Msgbox("With this,you can monitor temperature and light conditions outside and inside of your home!","HELP",mostCurrent.activityBA);
 //BA.debugLineNum = 937;BA.debugLine="End Sub";
return "";
}
public static String  _imagesettings_click() throws Exception{
 //BA.debugLineNum = 928;BA.debugLine="Sub Imagesettings_Click";
 //BA.debugLineNum = 929;BA.debugLine="mp.Load(File.DirAssets,\"help_settings.wav\")";
_mp.Load(anywheresoftware.b4a.keywords.Common.File.getDirAssets(),"help_settings.wav");
 //BA.debugLineNum = 930;BA.debugLine="mp.Play";
_mp.Play();
 //BA.debugLineNum = 931;BA.debugLine="Msgbox(\"With this,you can change the device settings for serial communication over bluetooth!\",\"HELP\")";
anywheresoftware.b4a.keywords.Common.Msgbox("With this,you can change the device settings for serial communication over bluetooth!","HELP",mostCurrent.activityBA);
 //BA.debugLineNum = 932;BA.debugLine="End Sub";
return "";
}
public static String  _mnuabout_click() throws Exception{
 //BA.debugLineNum = 304;BA.debugLine="Sub mnuabout_click";
 //BA.debugLineNum = 305;BA.debugLine="Panelsettings.Visible=False";
mostCurrent._panelsettings.setVisible(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 306;BA.debugLine="Panelappliances.Visible=False";
mostCurrent._panelappliances.setVisible(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 307;BA.debugLine="Panelsensors.Visible=False";
mostCurrent._panelsensors.setVisible(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 308;BA.debugLine="Panelsensomate.Visible=False";
mostCurrent._panelsensomate.setVisible(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 309;BA.debugLine="Paneldoor.Visible=False";
mostCurrent._paneldoor.setVisible(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 310;BA.debugLine="Panelabout.Visible=True";
mostCurrent._panelabout.setVisible(anywheresoftware.b4a.keywords.Common.True);
 //BA.debugLineNum = 312;BA.debugLine="Panelabout.BringToFront	'bring this panel to front";
mostCurrent._panelabout.BringToFront();
 //BA.debugLineNum = 313;BA.debugLine="mp.Load(File.DirAssets,\"about.wav\")";
_mp.Load(anywheresoftware.b4a.keywords.Common.File.getDirAssets(),"about.wav");
 //BA.debugLineNum = 314;BA.debugLine="mp.Play";
_mp.Play();
 //BA.debugLineNum = 315;BA.debugLine="End Sub";
return "";
}
public static String  _mnuappliances_click() throws Exception{
 //BA.debugLineNum = 244;BA.debugLine="Sub mnuappliances_click";
 //BA.debugLineNum = 245;BA.debugLine="Panelappliances.Visible=True";
mostCurrent._panelappliances.setVisible(anywheresoftware.b4a.keywords.Common.True);
 //BA.debugLineNum = 246;BA.debugLine="Panelsensors.Visible=False";
mostCurrent._panelsensors.setVisible(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 247;BA.debugLine="Panelsensomate.Visible=False";
mostCurrent._panelsensomate.setVisible(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 248;BA.debugLine="Paneldoor.Visible=False";
mostCurrent._paneldoor.setVisible(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 249;BA.debugLine="Panelsettings.Visible=False";
mostCurrent._panelsettings.setVisible(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 250;BA.debugLine="Panelabout.Visible=False";
mostCurrent._panelabout.setVisible(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 252;BA.debugLine="Panelappliances.BringToFront	'bring this panel to front";
mostCurrent._panelappliances.BringToFront();
 //BA.debugLineNum = 253;BA.debugLine="mp.Load(File.DirAssets,\"appliancecontrol.wav\")";
_mp.Load(anywheresoftware.b4a.keywords.Common.File.getDirAssets(),"appliancecontrol.wav");
 //BA.debugLineNum = 254;BA.debugLine="mp.Play";
_mp.Play();
 //BA.debugLineNum = 255;BA.debugLine="End Sub";
return "";
}
public static String  _mnudoor_click() throws Exception{
 //BA.debugLineNum = 268;BA.debugLine="Sub mnudoor_click";
 //BA.debugLineNum = 269;BA.debugLine="Paneldoor.Visible=True";
mostCurrent._paneldoor.setVisible(anywheresoftware.b4a.keywords.Common.True);
 //BA.debugLineNum = 270;BA.debugLine="Panelappliances.Visible=False";
mostCurrent._panelappliances.setVisible(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 271;BA.debugLine="Panelsensors.Visible=False";
mostCurrent._panelsensors.setVisible(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 272;BA.debugLine="Panelsensomate.Visible=False";
mostCurrent._panelsensomate.setVisible(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 273;BA.debugLine="Panelsettings.Visible=False";
mostCurrent._panelsettings.setVisible(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 274;BA.debugLine="Panelabout.Visible=False";
mostCurrent._panelabout.setVisible(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 276;BA.debugLine="Paneldoor.BringToFront	'bring this panel to front";
mostCurrent._paneldoor.BringToFront();
 //BA.debugLineNum = 277;BA.debugLine="mp.Load(File.DirAssets,\"door control.wav\")";
_mp.Load(anywheresoftware.b4a.keywords.Common.File.getDirAssets(),"door control.wav");
 //BA.debugLineNum = 278;BA.debugLine="mp.Play";
_mp.Play();
 //BA.debugLineNum = 279;BA.debugLine="End Sub";
return "";
}
public static String  _mnusensomate_click() throws Exception{
 //BA.debugLineNum = 280;BA.debugLine="Sub mnusensomate_click";
 //BA.debugLineNum = 281;BA.debugLine="Panelsensomate.Visible=True";
mostCurrent._panelsensomate.setVisible(anywheresoftware.b4a.keywords.Common.True);
 //BA.debugLineNum = 282;BA.debugLine="Panelappliances.Visible=False";
mostCurrent._panelappliances.setVisible(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 283;BA.debugLine="Panelsensors.Visible=False";
mostCurrent._panelsensors.setVisible(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 284;BA.debugLine="Paneldoor.Visible=False";
mostCurrent._paneldoor.setVisible(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 285;BA.debugLine="Panelsettings.Visible=False";
mostCurrent._panelsettings.setVisible(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 286;BA.debugLine="Panelabout.Visible=False";
mostCurrent._panelabout.setVisible(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 288;BA.debugLine="Panelsensomate.BringToFront	'bring this panel to front";
mostCurrent._panelsensomate.BringToFront();
 //BA.debugLineNum = 289;BA.debugLine="mp.Load(File.DirAssets,\"sensomate.wav\")";
_mp.Load(anywheresoftware.b4a.keywords.Common.File.getDirAssets(),"sensomate.wav");
 //BA.debugLineNum = 290;BA.debugLine="mp.Play";
_mp.Play();
 //BA.debugLineNum = 291;BA.debugLine="End Sub";
return "";
}
public static String  _mnusensors_click() throws Exception{
 //BA.debugLineNum = 256;BA.debugLine="Sub mnusensors_click";
 //BA.debugLineNum = 257;BA.debugLine="Panelsensors.Visible=True";
mostCurrent._panelsensors.setVisible(anywheresoftware.b4a.keywords.Common.True);
 //BA.debugLineNum = 258;BA.debugLine="Panelappliances.Visible=False";
mostCurrent._panelappliances.setVisible(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 259;BA.debugLine="Panelsensomate.Visible=False";
mostCurrent._panelsensomate.setVisible(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 260;BA.debugLine="Paneldoor.Visible=False";
mostCurrent._paneldoor.setVisible(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 261;BA.debugLine="Panelsettings.Visible=False";
mostCurrent._panelsettings.setVisible(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 262;BA.debugLine="Panelabout.Visible=False";
mostCurrent._panelabout.setVisible(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 264;BA.debugLine="Panelsensors.BringToFront	'bring this panel to front";
mostCurrent._panelsensors.BringToFront();
 //BA.debugLineNum = 265;BA.debugLine="mp.Load(File.DirAssets,\"sensors.wav\")";
_mp.Load(anywheresoftware.b4a.keywords.Common.File.getDirAssets(),"sensors.wav");
 //BA.debugLineNum = 266;BA.debugLine="mp.Play";
_mp.Play();
 //BA.debugLineNum = 267;BA.debugLine="End Sub";
return "";
}
public static String  _mnusettings_click() throws Exception{
 //BA.debugLineNum = 292;BA.debugLine="Sub mnusettings_click";
 //BA.debugLineNum = 293;BA.debugLine="Panelsettings.Visible=True";
mostCurrent._panelsettings.setVisible(anywheresoftware.b4a.keywords.Common.True);
 //BA.debugLineNum = 294;BA.debugLine="Panelappliances.Visible=False";
mostCurrent._panelappliances.setVisible(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 295;BA.debugLine="Panelsensors.Visible=False";
mostCurrent._panelsensors.setVisible(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 296;BA.debugLine="Panelsensomate.Visible=False";
mostCurrent._panelsensomate.setVisible(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 297;BA.debugLine="Paneldoor.Visible=False";
mostCurrent._paneldoor.setVisible(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 298;BA.debugLine="Panelabout.Visible=False";
mostCurrent._panelabout.setVisible(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 300;BA.debugLine="Panelsettings.BringToFront	'bring this panel to front";
mostCurrent._panelsettings.BringToFront();
 //BA.debugLineNum = 301;BA.debugLine="mp.Load(File.DirAssets,\"settings.wav\")";
_mp.Load(anywheresoftware.b4a.keywords.Common.File.getDirAssets(),"settings.wav");
 //BA.debugLineNum = 302;BA.debugLine="mp.Play";
_mp.Play();
 //BA.debugLineNum = 303;BA.debugLine="End Sub";
return "";
}
public static String  _process_globals() throws Exception{
 //BA.debugLineNum = 2;BA.debugLine="Sub Process_Globals";
 //BA.debugLineNum = 5;BA.debugLine="Dim mp As MediaPlayer		'for playing audio messages";
_mp = new anywheresoftware.b4a.objects.MediaPlayerWrapper();
 //BA.debugLineNum = 6;BA.debugLine="Dim serial1 As Serial		'for serial communication via bluetooth";
_serial1 = new anywheresoftware.b4a.objects.Serial();
 //BA.debugLineNum = 7;BA.debugLine="Dim astreams As AsyncStreams	'used in handling serial data";
_astreams = new anywheresoftware.b4a.randomaccessfile.AsyncStreams();
 //BA.debugLineNum = 8;BA.debugLine="Dim badmin As BluetoothAdmin	'for handling bluetooth adaptor";
_badmin = new anywheresoftware.b4a.objects.Serial.BluetoothAdmin();
 //BA.debugLineNum = 9;BA.debugLine="Dim connected As Boolean		'depicts global serial connection status";
_connected = false;
 //BA.debugLineNum = 10;BA.debugLine="Dim sensors As String";
_sensors = "";
 //BA.debugLineNum = 11;BA.debugLine="Dim s As String					'general purpose,for sending serial commands";
_s = "";
 //BA.debugLineNum = 12;BA.debugLine="Dim sb As String			'used in fetching encoded serial data so received";
_sb = "";
 //BA.debugLineNum = 13;BA.debugLine="Dim fullrx As Boolean		'used in fetching encoded serial data so received";
_fullrx = false;
 //BA.debugLineNum = 14;BA.debugLine="End Sub";
return "";
}
public static String  _serial1_connected(boolean _success) throws Exception{
 //BA.debugLineNum = 664;BA.debugLine="Sub Serial1_Connected (Success As Boolean)'this event is raised when a connection is established successfully";
 //BA.debugLineNum = 665;BA.debugLine="If Success Then'if successfully connected";
if (_success) { 
 //BA.debugLineNum = 666;BA.debugLine="astreams.Initialize(serial1.InputStream,serial1.OutputStream, \"AStreams\")";
_astreams.Initialize(processBA,_serial1.getInputStream(),_serial1.getOutputStream(),"AStreams");
 //BA.debugLineNum = 668;BA.debugLine="ToastMessageShow(\"Connected to the host server successfully with \" & Chr(10)& \"MAC address:\" & Chr(10)& serial1.Address & Chr(10) & \"Name:\" &Chr(10)& serial1.Name, False)  'here chr(10) is line feed";
anywheresoftware.b4a.keywords.Common.ToastMessageShow("Connected to the host server successfully with "+String.valueOf(anywheresoftware.b4a.keywords.Common.Chr((int)(10)))+"MAC address:"+String.valueOf(anywheresoftware.b4a.keywords.Common.Chr((int)(10)))+_serial1.getAddress()+String.valueOf(anywheresoftware.b4a.keywords.Common.Chr((int)(10)))+"Name:"+String.valueOf(anywheresoftware.b4a.keywords.Common.Chr((int)(10)))+_serial1.getName(),anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 669;BA.debugLine="connected = True";
_connected = anywheresoftware.b4a.keywords.Common.True;
 //BA.debugLineNum = 670;BA.debugLine="enable_main_views";
_enable_main_views();
 //BA.debugLineNum = 671;BA.debugLine="Buttonconnect.Text=\"DISCONNECT\"";
mostCurrent._buttonconnect.setText((Object)("DISCONNECT"));
 }else {
 //BA.debugLineNum = 673;BA.debugLine="astreams.Close";
_astreams.Close();
 //BA.debugLineNum = 674;BA.debugLine="serial1.Disconnect";
_serial1.Disconnect();
 //BA.debugLineNum = 675;BA.debugLine="connected = False";
_connected = anywheresoftware.b4a.keywords.Common.False;
 //BA.debugLineNum = 676;BA.debugLine="disable_main_views";
_disable_main_views();
 //BA.debugLineNum = 677;BA.debugLine="Buttonconnect.Enabled=True";
mostCurrent._buttonconnect.setEnabled(anywheresoftware.b4a.keywords.Common.True);
 //BA.debugLineNum = 678;BA.debugLine="Buttonconnect.Text=\"CONNECT\"";
mostCurrent._buttonconnect.setText((Object)("CONNECT"));
 //BA.debugLineNum = 679;BA.debugLine="ToastMessageShow(\"Connection to the host server failed,please try again\", False)";
anywheresoftware.b4a.keywords.Common.ToastMessageShow("Connection to the host server failed,please try again",anywheresoftware.b4a.keywords.Common.False);
 };
 //BA.debugLineNum = 681;BA.debugLine="End Sub";
return "";
}
public static String  _t1_tick() throws Exception{
 //BA.debugLineNum = 203;BA.debugLine="Sub t1_tick	'main animation routine";
 //BA.debugLineNum = 204;BA.debugLine="Select i";
switch (_i) {
case 0:
 //BA.debugLineNum = 205;BA.debugLine="Case 0 : Label3.Visible=True";
mostCurrent._label3.setVisible(anywheresoftware.b4a.keywords.Common.True);
 break;
case 1:
 //BA.debugLineNum = 206;BA.debugLine="Case 1 : Label4.Visible=True";
mostCurrent._label4.setVisible(anywheresoftware.b4a.keywords.Common.True);
 break;
case 2:
 //BA.debugLineNum = 207;BA.debugLine="Case 2 : Label5.Visible=True";
mostCurrent._label5.setVisible(anywheresoftware.b4a.keywords.Common.True);
 break;
case 3:
 //BA.debugLineNum = 208;BA.debugLine="Case 3 : ImageView2.Visible=True";
mostCurrent._imageview2.setVisible(anywheresoftware.b4a.keywords.Common.True);
 break;
case 4:
 //BA.debugLineNum = 209;BA.debugLine="Case 4 : t1.Enabled=False";
mostCurrent._t1.setEnabled(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 210;BA.debugLine="mp.Load(File.DirAssets,\"welcome.wav\")";
_mp.Load(anywheresoftware.b4a.keywords.Common.File.getDirAssets(),"welcome.wav");
 //BA.debugLineNum = 211;BA.debugLine="mp.Play";
_mp.Play();
 //BA.debugLineNum = 212;BA.debugLine="Label1.Visible=True";
mostCurrent._label1.setVisible(anywheresoftware.b4a.keywords.Common.True);
 //BA.debugLineNum = 213;BA.debugLine="Label2.Visible=True";
mostCurrent._label2.setVisible(anywheresoftware.b4a.keywords.Common.True);
 //BA.debugLineNum = 214;BA.debugLine="animate1.Start(Label1)";
mostCurrent._animate1.Start((android.view.View)(mostCurrent._label1.getObject()));
 //BA.debugLineNum = 215;BA.debugLine="animate2.Start(Label2)";
mostCurrent._animate2.Start((android.view.View)(mostCurrent._label2.getObject()));
 break;
}
;
 //BA.debugLineNum = 218;BA.debugLine="If i>=0 AND i<=3 Then";
if (_i>=0 && _i<=3) { 
 //BA.debugLineNum = 219;BA.debugLine="mp.Load(File.DirAssets,\"ding.wav\")";
_mp.Load(anywheresoftware.b4a.keywords.Common.File.getDirAssets(),"ding.wav");
 //BA.debugLineNum = 220;BA.debugLine="mp.Play";
_mp.Play();
 };
 //BA.debugLineNum = 223;BA.debugLine="i = i + 1";
_i = (int)(_i+1);
 //BA.debugLineNum = 224;BA.debugLine="End Sub";
return "";
}
public static String  _t2_tick() throws Exception{
String _m = "";
 //BA.debugLineNum = 225;BA.debugLine="Sub t2_tick	'after 1.5 second front page animation is over now, now load the actual application interface";
 //BA.debugLineNum = 226;BA.debugLine="t2.Enabled=False";
mostCurrent._t2.setEnabled(anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 227;BA.debugLine="Panelappliances.Visible=True	'this will be the default panel to be displyed first";
mostCurrent._panelappliances.setVisible(anywheresoftware.b4a.keywords.Common.True);
 //BA.debugLineNum = 228;BA.debugLine="Panelappliances.BringToFront 'now bring it to front first";
mostCurrent._panelappliances.BringToFront();
 //BA.debugLineNum = 229;BA.debugLine="panimate1.Start(Panelappliances) 'start the fading animation for this panel";
mostCurrent._panimate1.Start((android.view.View)(mostCurrent._panelappliances.getObject()));
 //BA.debugLineNum = 230;BA.debugLine="panimate1.Duration=700'now change the panel fade animation timings to 700ms";
mostCurrent._panimate1.setDuration((long)(700));
 //BA.debugLineNum = 233;BA.debugLine="If badmin.IsEnabled=True Then";
if (_badmin.IsEnabled()==anywheresoftware.b4a.keywords.Common.True) { 
 //BA.debugLineNum = 234;BA.debugLine="If File.ReadString(File.DirInternal,\"mac.txt\")<>\"\" Then 'some default MAC address exists and app need to be connected to this automatically";
if ((anywheresoftware.b4a.keywords.Common.File.ReadString(anywheresoftware.b4a.keywords.Common.File.getDirInternal(),"mac.txt")).equals("") == false) { 
 //BA.debugLineNum = 235;BA.debugLine="Dim m As String";
_m = "";
 //BA.debugLineNum = 236;BA.debugLine="m = File.ReadString(File.DirInternal,\"mac.txt\")'read the MAC address stored";
_m = anywheresoftware.b4a.keywords.Common.File.ReadString(anywheresoftware.b4a.keywords.Common.File.getDirInternal(),"mac.txt");
 //BA.debugLineNum = 237;BA.debugLine="serial1.Connect(m)'connect to it automatically";
_serial1.Connect(processBA,_m);
 };
 };
 //BA.debugLineNum = 240;BA.debugLine="End Sub";
return "";
}
}
