package b4a.HC05LightDimmer;

import anywheresoftware.b4a.BA;
import anywheresoftware.b4a.pc.*;

public class main_subs_0 {


public static RemoteObject  _activity_create(RemoteObject _firsttime) throws Exception{
try {
		Debug.PushSubsStack("Activity_Create (main) ","main",0,main.mostCurrent.activityBA,main.mostCurrent,29);
if (RapidSub.canDelegate("activity_create")) { return b4a.HC05LightDimmer.main.remoteMe.runUserSub(false, "main","activity_create", _firsttime);}
Debug.locals.put("FirstTime", _firsttime);
 BA.debugLineNum = 29;BA.debugLine="Sub Activity_Create(FirstTime As Boolean)";
Debug.ShouldStop(268435456);
 BA.debugLineNum = 30;BA.debugLine="Activity.LoadLayout(\"Main\")";
Debug.ShouldStop(536870912);
main.mostCurrent._activity.runMethodAndSync(false,"LoadLayout",(Object)(RemoteObject.createImmutable("Main")),main.mostCurrent.activityBA);
 BA.debugLineNum = 31;BA.debugLine="End Sub";
Debug.ShouldStop(1073741824);
return RemoteObject.createImmutable("");
}
catch (Exception e) {
			throw Debug.ErrorCaught(e);
		} 
finally {
			Debug.PopSubsStack();
		}}
public static RemoteObject  _activity_pause(RemoteObject _userclosed) throws Exception{
try {
		Debug.PushSubsStack("Activity_Pause (main) ","main",0,main.mostCurrent.activityBA,main.mostCurrent,37);
if (RapidSub.canDelegate("activity_pause")) { return b4a.HC05LightDimmer.main.remoteMe.runUserSub(false, "main","activity_pause", _userclosed);}
Debug.locals.put("UserClosed", _userclosed);
 BA.debugLineNum = 37;BA.debugLine="Sub Activity_Pause (UserClosed As Boolean)";
Debug.ShouldStop(16);
 BA.debugLineNum = 38;BA.debugLine="If UserClosed = True And Status = \"connected\" The";
Debug.ShouldStop(32);
if (RemoteObject.solveBoolean("=",_userclosed,main.mostCurrent.__c.getField(true,"True")) && RemoteObject.solveBoolean("=",main.mostCurrent._status,BA.ObjectToString("connected"))) { 
 BA.debugLineNum = 39;BA.debugLine="CallSub2(Starter, \"SendMessage\", Array As Byte(0";
Debug.ShouldStop(64);
main.mostCurrent.__c.runMethodAndSync(false,"CallSubNew2",main.processBA,(Object)((main.mostCurrent._starter.getObject())),(Object)(BA.ObjectToString("SendMessage")),(Object)((RemoteObject.createNewArray("byte",new int[] {1},new Object[] {BA.numberCast(byte.class, 0)}))));
 };
 BA.debugLineNum = 41;BA.debugLine="End Sub";
Debug.ShouldStop(256);
return RemoteObject.createImmutable("");
}
catch (Exception e) {
			throw Debug.ErrorCaught(e);
		} 
finally {
			Debug.PopSubsStack();
		}}
public static RemoteObject  _activity_resume() throws Exception{
try {
		Debug.PushSubsStack("Activity_Resume (main) ","main",0,main.mostCurrent.activityBA,main.mostCurrent,33);
if (RapidSub.canDelegate("activity_resume")) { return b4a.HC05LightDimmer.main.remoteMe.runUserSub(false, "main","activity_resume");}
 BA.debugLineNum = 33;BA.debugLine="Sub Activity_Resume";
Debug.ShouldStop(1);
 BA.debugLineNum = 34;BA.debugLine="SetState";
Debug.ShouldStop(2);
_setstate();
 BA.debugLineNum = 35;BA.debugLine="End Sub";
Debug.ShouldStop(4);
return RemoteObject.createImmutable("");
}
catch (Exception e) {
			throw Debug.ErrorCaught(e);
		} 
finally {
			Debug.PopSubsStack();
		}}
public static RemoteObject  _btnconnect_click() throws Exception{
try {
		Debug.PushSubsStack("btnConnect_Click (main) ","main",0,main.mostCurrent.activityBA,main.mostCurrent,73);
if (RapidSub.canDelegate("btnconnect_click")) { return b4a.HC05LightDimmer.main.remoteMe.runUserSub(false, "main","btnconnect_click");}
 BA.debugLineNum = 73;BA.debugLine="Sub btnConnect_Click";
Debug.ShouldStop(256);
 BA.debugLineNum = 74;BA.debugLine="CallSub(Starter, \"Connect\")";
Debug.ShouldStop(512);
main.mostCurrent.__c.runMethodAndSync(false,"CallSubNew",main.processBA,(Object)((main.mostCurrent._starter.getObject())),(Object)(RemoteObject.createImmutable("Connect")));
 BA.debugLineNum = 75;BA.debugLine="End Sub";
Debug.ShouldStop(1024);
return RemoteObject.createImmutable("");
}
catch (Exception e) {
			throw Debug.ErrorCaught(e);
		} 
finally {
			Debug.PopSubsStack();
		}}
public static RemoteObject  _globals() throws Exception{
 //BA.debugLineNum = 19;BA.debugLine="Sub Globals";
 //BA.debugLineNum = 20;BA.debugLine="Private tbtLED As ToggleButton";
main.mostCurrent._tbtled = RemoteObject.createNew ("anywheresoftware.b4a.objects.CompoundButtonWrapper.ToggleButtonWrapper");
 //BA.debugLineNum = 21;BA.debugLine="Private lblStatus As Label";
main.mostCurrent._lblstatus = RemoteObject.createNew ("anywheresoftware.b4a.objects.LabelWrapper");
 //BA.debugLineNum = 22;BA.debugLine="Private btnConnect As Button";
main.mostCurrent._btnconnect = RemoteObject.createNew ("anywheresoftware.b4a.objects.ButtonWrapper");
 //BA.debugLineNum = 23;BA.debugLine="Private lblMessage As Label";
main.mostCurrent._lblmessage = RemoteObject.createNew ("anywheresoftware.b4a.objects.LabelWrapper");
 //BA.debugLineNum = 24;BA.debugLine="Private ProgressBar1 As ProgressBar";
main.mostCurrent._progressbar1 = RemoteObject.createNew ("anywheresoftware.b4a.objects.ProgressBarWrapper");
 //BA.debugLineNum = 26;BA.debugLine="Private Status As String";
main.mostCurrent._status = RemoteObject.createImmutable("");
 //BA.debugLineNum = 27;BA.debugLine="End Sub";
return RemoteObject.createImmutable("");
}
public static RemoteObject  _messagefromdevice(RemoteObject _msg) throws Exception{
try {
		Debug.PushSubsStack("MessageFromDevice (main) ","main",0,main.mostCurrent.activityBA,main.mostCurrent,59);
if (RapidSub.canDelegate("messagefromdevice")) { return b4a.HC05LightDimmer.main.remoteMe.runUserSub(false, "main","messagefromdevice", _msg);}
Debug.locals.put("msg", _msg);
 BA.debugLineNum = 59;BA.debugLine="Public Sub MessageFromDevice(msg As String)";
Debug.ShouldStop(67108864);
 BA.debugLineNum = 60;BA.debugLine="lblMessage.Text = msg";
Debug.ShouldStop(134217728);
main.mostCurrent._lblmessage.runMethod(true,"setText",BA.ObjectToCharSequence(_msg));
 BA.debugLineNum = 61;BA.debugLine="End Sub";
Debug.ShouldStop(268435456);
return RemoteObject.createImmutable("");
}
catch (Exception e) {
			throw Debug.ErrorCaught(e);
		} 
finally {
			Debug.PopSubsStack();
		}}

public static void initializeProcessGlobals() {
    
    if (main.processGlobalsRun == false) {
	    main.processGlobalsRun = true;
		try {
		        main_subs_0._process_globals();
starter_subs_0._process_globals();
main.myClass = BA.getDeviceClass ("b4a.HC05LightDimmer.main");
starter.myClass = BA.getDeviceClass ("b4a.HC05LightDimmer.starter");
asyncstreamstext.myClass = BA.getDeviceClass ("b4a.HC05LightDimmer.asyncstreamstext");
		
        } catch (Exception e) {
			throw new RuntimeException(e);
		}
    }
}public static RemoteObject  _process_globals() throws Exception{
 //BA.debugLineNum = 15;BA.debugLine="Sub Process_Globals";
 //BA.debugLineNum = 17;BA.debugLine="End Sub";
return RemoteObject.createImmutable("");
}
public static RemoteObject  _setstate() throws Exception{
try {
		Debug.PushSubsStack("SetState (main) ","main",0,main.mostCurrent.activityBA,main.mostCurrent,43);
if (RapidSub.canDelegate("setstate")) { return b4a.HC05LightDimmer.main.remoteMe.runUserSub(false, "main","setstate");}
 BA.debugLineNum = 43;BA.debugLine="Public Sub SetState";
Debug.ShouldStop(1024);
 BA.debugLineNum = 44;BA.debugLine="tbtLED.Enabled = Starter.connected";
Debug.ShouldStop(2048);
main.mostCurrent._tbtled.runMethod(true,"setEnabled",main.mostCurrent._starter._connected);
 BA.debugLineNum = 45;BA.debugLine="btnConnect.Enabled = Not(Starter.connected)";
Debug.ShouldStop(4096);
main.mostCurrent._btnconnect.runMethod(true,"setEnabled",main.mostCurrent.__c.runMethod(true,"Not",(Object)(main.mostCurrent._starter._connected)));
 BA.debugLineNum = 46;BA.debugLine="ProgressBar1.Visible = Starter.connecting";
Debug.ShouldStop(8192);
main.mostCurrent._progressbar1.runMethod(true,"setVisible",main.mostCurrent._starter._connecting);
 BA.debugLineNum = 47;BA.debugLine="If Starter.Connected Then";
Debug.ShouldStop(16384);
if (main.mostCurrent._starter._connected.<Boolean>get().booleanValue()) { 
 BA.debugLineNum = 48;BA.debugLine="Status = \"connected\"";
Debug.ShouldStop(32768);
main.mostCurrent._status = BA.ObjectToString("connected");
 }else 
{ BA.debugLineNum = 49;BA.debugLine="Else If Starter.TryToConnect Then";
Debug.ShouldStop(65536);
if (main.mostCurrent._starter._trytoconnect.<Boolean>get().booleanValue()) { 
 BA.debugLineNum = 50;BA.debugLine="Status = \"trying to connect...\"";
Debug.ShouldStop(131072);
main.mostCurrent._status = BA.ObjectToString("trying to connect...");
 }else 
{ BA.debugLineNum = 51;BA.debugLine="Else If Starter.Connecting Then";
Debug.ShouldStop(262144);
if (main.mostCurrent._starter._connecting.<Boolean>get().booleanValue()) { 
 BA.debugLineNum = 52;BA.debugLine="Status = \"HC-05 found connecting...\"";
Debug.ShouldStop(524288);
main.mostCurrent._status = BA.ObjectToString("HC-05 found connecting...");
 }else {
 BA.debugLineNum = 54;BA.debugLine="Status = \"disconnected\"";
Debug.ShouldStop(2097152);
main.mostCurrent._status = BA.ObjectToString("disconnected");
 }}}
;
 BA.debugLineNum = 56;BA.debugLine="lblStatus.Text = $\"Status: ${Status}\"$";
Debug.ShouldStop(8388608);
main.mostCurrent._lblstatus.runMethod(true,"setText",BA.ObjectToCharSequence((RemoteObject.concat(RemoteObject.createImmutable("Status: "),main.mostCurrent.__c.runMethod(true,"SmartStringFormatter",(Object)(BA.ObjectToString("")),(Object)((main.mostCurrent._status))),RemoteObject.createImmutable("")))));
 BA.debugLineNum = 57;BA.debugLine="End Sub";
Debug.ShouldStop(16777216);
return RemoteObject.createImmutable("");
}
catch (Exception e) {
			throw Debug.ErrorCaught(e);
		} 
finally {
			Debug.PopSubsStack();
		}}
public static RemoteObject  _tbtled_checkedchange(RemoteObject _checked) throws Exception{
try {
		Debug.PushSubsStack("tbtLED_CheckedChange (main) ","main",0,main.mostCurrent.activityBA,main.mostCurrent,63);
if (RapidSub.canDelegate("tbtled_checkedchange")) { return b4a.HC05LightDimmer.main.remoteMe.runUserSub(false, "main","tbtled_checkedchange", _checked);}
RemoteObject _b = RemoteObject.createImmutable((byte)0);
Debug.locals.put("Checked", _checked);
 BA.debugLineNum = 63;BA.debugLine="Sub tbtLED_CheckedChange(Checked As Boolean)";
Debug.ShouldStop(1073741824);
 BA.debugLineNum = 64;BA.debugLine="Dim b As Byte";
Debug.ShouldStop(-2147483648);
_b = RemoteObject.createImmutable((byte)0);Debug.locals.put("b", _b);
 BA.debugLineNum = 65;BA.debugLine="If Checked = True Then";
Debug.ShouldStop(1);
if (RemoteObject.solveBoolean("=",_checked,main.mostCurrent.__c.getField(true,"True"))) { 
 BA.debugLineNum = 66;BA.debugLine="b = 1";
Debug.ShouldStop(2);
_b = BA.numberCast(byte.class, 1);Debug.locals.put("b", _b);
 }else {
 BA.debugLineNum = 68;BA.debugLine="b = 0";
Debug.ShouldStop(8);
_b = BA.numberCast(byte.class, 0);Debug.locals.put("b", _b);
 };
 BA.debugLineNum = 70;BA.debugLine="CallSub2(Starter, \"SendMessage\", Array As Byte(b)";
Debug.ShouldStop(32);
main.mostCurrent.__c.runMethodAndSync(false,"CallSubNew2",main.processBA,(Object)((main.mostCurrent._starter.getObject())),(Object)(BA.ObjectToString("SendMessage")),(Object)((RemoteObject.createNewArray("byte",new int[] {1},new Object[] {_b}))));
 BA.debugLineNum = 71;BA.debugLine="End Sub";
Debug.ShouldStop(64);
return RemoteObject.createImmutable("");
}
catch (Exception e) {
			throw Debug.ErrorCaught(e);
		} 
finally {
			Debug.PopSubsStack();
		}}
}