package b4a.HC05DCMotor;

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

public class main_subs_0 {


public static void  _activity_create(RemoteObject _firsttime) throws Exception{
try {
		Debug.PushSubsStack("Activity_Create (main) ","main",0,main.mostCurrent.activityBA,main.mostCurrent,35);
if (RapidSub.canDelegate("activity_create")) { b4a.HC05DCMotor.main.remoteMe.runUserSub(false, "main","activity_create", _firsttime); return;}
ResumableSub_Activity_Create rsub = new ResumableSub_Activity_Create(null,_firsttime);
rsub.resume(null, null);
}
catch (Exception e) {
			throw Debug.ErrorCaught(e);
		} 
finally {
			Debug.PopSubsStack();
		}}
public static class ResumableSub_Activity_Create extends BA.ResumableSub {
public ResumableSub_Activity_Create(b4a.HC05DCMotor.main parent,RemoteObject _firsttime) {
this.parent = parent;
this._firsttime = _firsttime;
}
java.util.LinkedHashMap<String, Object> rsLocals = new java.util.LinkedHashMap<String, Object>();
b4a.HC05DCMotor.main parent;
RemoteObject _firsttime;
RemoteObject _permission = RemoteObject.createImmutable("");
RemoteObject _result = RemoteObject.createImmutable(false);

@Override
public void resume(BA ba, RemoteObject result) throws Exception{
try {
		Debug.PushSubsStack("Activity_Create (main) ","main",0,main.mostCurrent.activityBA,main.mostCurrent,35);
Debug.locals = rsLocals;Debug.currentSubFrame.locals = rsLocals;

    while (true) {
        switch (state) {
            case -1:
return;

case 0:
//C
this.state = 1;
Debug.locals.put("FirstTime", _firsttime);
 BA.debugLineNum = 36;BA.debugLine="Activity.LoadLayout(\"Main\")";
Debug.ShouldStop(8);
parent.mostCurrent._activity.runMethodAndSync(false,"LoadLayout",(Object)(RemoteObject.createImmutable("Main")),main.mostCurrent.activityBA);
 BA.debugLineNum = 38;BA.debugLine="rp.CheckAndRequest(rp.PERMISSION_ACCESS_FINE_LOCA";
Debug.ShouldStop(32);
parent._rp.runVoidMethod ("CheckAndRequest",main.processBA,(Object)(parent._rp.getField(true,"PERMISSION_ACCESS_FINE_LOCATION")));
 BA.debugLineNum = 39;BA.debugLine="Wait For Activity_PermissionResult (Permission As";
Debug.ShouldStop(64);
parent.mostCurrent.__c.runVoidMethod ("WaitFor","activity_permissionresult", main.processBA, anywheresoftware.b4a.pc.PCResumableSub.createDebugResumeSub(this, "main", "activity_create"), null);
this.state = 5;
return;
case 5:
//C
this.state = 1;
_permission = (RemoteObject) result.getArrayElement(true,RemoteObject.createImmutable(0));Debug.locals.put("Permission", _permission);
_result = (RemoteObject) result.getArrayElement(true,RemoteObject.createImmutable(1));Debug.locals.put("Result", _result);
;
 BA.debugLineNum = 40;BA.debugLine="If Result = False Then";
Debug.ShouldStop(128);
if (true) break;

case 1:
//if
this.state = 4;
if (RemoteObject.solveBoolean("=",_result,parent.mostCurrent.__c.getField(true,"False"))) { 
this.state = 3;
}if (true) break;

case 3:
//C
this.state = 4;
 BA.debugLineNum = 41;BA.debugLine="ToastMessageShow(\"No permission...\", False)";
Debug.ShouldStop(256);
parent.mostCurrent.__c.runVoidMethod ("ToastMessageShow",(Object)(BA.ObjectToCharSequence("No permission...")),(Object)(parent.mostCurrent.__c.getField(true,"False")));
 BA.debugLineNum = 42;BA.debugLine="Return";
Debug.ShouldStop(512);
if (true) return ;
 if (true) break;

case 4:
//C
this.state = -1;
;
 BA.debugLineNum = 44;BA.debugLine="End Sub";
Debug.ShouldStop(2048);
if (true) break;

            }
        }
    }
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,50);
if (RapidSub.canDelegate("activity_pause")) { return b4a.HC05DCMotor.main.remoteMe.runUserSub(false, "main","activity_pause", _userclosed);}
Debug.locals.put("UserClosed", _userclosed);
 BA.debugLineNum = 50;BA.debugLine="Sub Activity_Pause (UserClosed As Boolean)";
Debug.ShouldStop(131072);
 BA.debugLineNum = 51;BA.debugLine="If UserClosed = True And lblStatus.Text = \"connec";
Debug.ShouldStop(262144);
if (RemoteObject.solveBoolean("=",_userclosed,main.mostCurrent.__c.getField(true,"True")) && RemoteObject.solveBoolean("=",main.mostCurrent._lblstatus.runMethod(true,"getText"),BA.ObjectToString("connected"))) { 
 BA.debugLineNum = 52;BA.debugLine="CallSub2(Starter, \"SendMessage\", Array As Byte(0";
Debug.ShouldStop(524288);
main.mostCurrent.__c.runMethodAndSync(false,"CallSubNew2",main.processBA,(Object)((main.mostCurrent._starter.getObject())),(Object)(BA.ObjectToString("SendMessage")),(Object)((RemoteObject.createNewArray("byte",new int[] {2},new Object[] {BA.numberCast(byte.class, 0),BA.numberCast(byte.class, 0)}))));
 };
 BA.debugLineNum = 54;BA.debugLine="End Sub";
Debug.ShouldStop(2097152);
return RemoteObject.createImmutable("");
}
catch (Exception e) {
			throw Debug.ErrorCaught(e);
		} 
finally {
			Debug.PopSubsStack();
		}}
public static RemoteObject  _activity_permissionresult(RemoteObject _permission,RemoteObject _result) throws Exception{
try {
		Debug.PushSubsStack("Activity_PermissionResult (main) ","main",0,main.mostCurrent.activityBA,main.mostCurrent,56);
if (RapidSub.canDelegate("activity_permissionresult")) { return b4a.HC05DCMotor.main.remoteMe.runUserSub(false, "main","activity_permissionresult", _permission, _result);}
Debug.locals.put("Permission", _permission);
Debug.locals.put("Result", _result);
 BA.debugLineNum = 56;BA.debugLine="Private Sub Activity_PermissionResult (Permission";
Debug.ShouldStop(8388608);
 BA.debugLineNum = 58;BA.debugLine="End Sub";
Debug.ShouldStop(33554432);
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,46);
if (RapidSub.canDelegate("activity_resume")) { return b4a.HC05DCMotor.main.remoteMe.runUserSub(false, "main","activity_resume");}
 BA.debugLineNum = 46;BA.debugLine="Sub Activity_Resume";
Debug.ShouldStop(8192);
 BA.debugLineNum = 47;BA.debugLine="SetState";
Debug.ShouldStop(16384);
_setstate();
 BA.debugLineNum = 48;BA.debugLine="End Sub";
Debug.ShouldStop(32768);
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,80);
if (RapidSub.canDelegate("btnconnect_click")) { return b4a.HC05DCMotor.main.remoteMe.runUserSub(false, "main","btnconnect_click");}
 BA.debugLineNum = 80;BA.debugLine="Sub btnConnect_Click";
Debug.ShouldStop(32768);
 BA.debugLineNum = 81;BA.debugLine="CallSub(Starter, \"Connect\")";
Debug.ShouldStop(65536);
main.mostCurrent.__c.runMethodAndSync(false,"CallSubNew",main.processBA,(Object)((main.mostCurrent._starter.getObject())),(Object)(RemoteObject.createImmutable("Connect")));
 BA.debugLineNum = 82;BA.debugLine="End Sub";
Debug.ShouldStop(131072);
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 tgbMotorOnOff, tgbMotorDirection As Toggl";
main.mostCurrent._tgbmotoronoff = RemoteObject.createNew ("anywheresoftware.b4a.objects.CompoundButtonWrapper.ToggleButtonWrapper");
main.mostCurrent._tgbmotordirection = 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 = 25;BA.debugLine="Private skbMotorSpeed As SeekBar";
main.mostCurrent._skbmotorspeed = RemoteObject.createNew ("anywheresoftware.b4a.objects.SeekBarWrapper");
 //BA.debugLineNum = 26;BA.debugLine="Private lblMotorSpeed As Label";
main.mostCurrent._lblmotorspeed = RemoteObject.createNew ("anywheresoftware.b4a.objects.LabelWrapper");
 //BA.debugLineNum = 28;BA.debugLine="Private Status As String";
main.mostCurrent._status = RemoteObject.createImmutable("");
 //BA.debugLineNum = 30;BA.debugLine="Private MsgMotorOnOff = 0 As Byte";
main._msgmotoronoff = BA.numberCast(byte.class, 0);
 //BA.debugLineNum = 31;BA.debugLine="Private MsgMotorDirection = 1 As Byte";
main._msgmotordirection = BA.numberCast(byte.class, 1);
 //BA.debugLineNum = 32;BA.debugLine="Private MsgMotorSpeed = 2 As Byte";
main._msgmotorspeed = BA.numberCast(byte.class, 2);
 //BA.debugLineNum = 33;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,76);
if (RapidSub.canDelegate("messagefromdevice")) { return b4a.HC05DCMotor.main.remoteMe.runUserSub(false, "main","messagefromdevice", _msg);}
Debug.locals.put("msg", _msg);
 BA.debugLineNum = 76;BA.debugLine="Public Sub MessageFromDevice(msg As String)";
Debug.ShouldStop(2048);
 BA.debugLineNum = 77;BA.debugLine="lblMessage.Text = msg";
Debug.ShouldStop(4096);
main.mostCurrent._lblmessage.runMethod(true,"setText",BA.ObjectToCharSequence(_msg));
 BA.debugLineNum = 78;BA.debugLine="End Sub";
Debug.ShouldStop(8192);
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.HC05DCMotor.main");
starter.myClass = BA.getDeviceClass ("b4a.HC05DCMotor.starter");
asyncstreamstext.myClass = BA.getDeviceClass ("b4a.HC05DCMotor.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 = 16;BA.debugLine="Public rp As RuntimePermissions";
main._rp = RemoteObject.createNew ("anywheresoftware.b4a.objects.RuntimePermissions");
 //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,60);
if (RapidSub.canDelegate("setstate")) { return b4a.HC05DCMotor.main.remoteMe.runUserSub(false, "main","setstate");}
 BA.debugLineNum = 60;BA.debugLine="Public Sub SetState";
Debug.ShouldStop(134217728);
 BA.debugLineNum = 61;BA.debugLine="btnConnect.Enabled = Not(Starter.connected)";
Debug.ShouldStop(268435456);
main.mostCurrent._btnconnect.runMethod(true,"setEnabled",main.mostCurrent.__c.runMethod(true,"Not",(Object)(main.mostCurrent._starter._connected /*RemoteObject*/ )));
 BA.debugLineNum = 62;BA.debugLine="ProgressBar1.Visible = Starter.connecting";
Debug.ShouldStop(536870912);
main.mostCurrent._progressbar1.runMethod(true,"setVisible",main.mostCurrent._starter._connecting /*RemoteObject*/ );
 BA.debugLineNum = 63;BA.debugLine="Dim Status As String";
Debug.ShouldStop(1073741824);
main.mostCurrent._status = RemoteObject.createImmutable("");
 BA.debugLineNum = 64;BA.debugLine="If Starter.Connected Then";
Debug.ShouldStop(-2147483648);
if (main.mostCurrent._starter._connected /*RemoteObject*/ .<Boolean>get().booleanValue()) { 
 BA.debugLineNum = 65;BA.debugLine="Status = \"connected\"";
Debug.ShouldStop(1);
main.mostCurrent._status = BA.ObjectToString("connected");
 }else 
{ BA.debugLineNum = 66;BA.debugLine="Else If Starter.TryToConnect Then";
Debug.ShouldStop(2);
if (main.mostCurrent._starter._trytoconnect /*RemoteObject*/ .<Boolean>get().booleanValue()) { 
 BA.debugLineNum = 67;BA.debugLine="Status = \"trying to connect...\"";
Debug.ShouldStop(4);
main.mostCurrent._status = BA.ObjectToString("trying to connect...");
 }else 
{ BA.debugLineNum = 68;BA.debugLine="Else If Starter.Connecting Then";
Debug.ShouldStop(8);
if (main.mostCurrent._starter._connecting /*RemoteObject*/ .<Boolean>get().booleanValue()) { 
 BA.debugLineNum = 69;BA.debugLine="Status = \"HC-05 found connecting...\"";
Debug.ShouldStop(16);
main.mostCurrent._status = BA.ObjectToString("HC-05 found connecting...");
 }else {
 BA.debugLineNum = 71;BA.debugLine="Status = \"disconnected\"";
Debug.ShouldStop(64);
main.mostCurrent._status = BA.ObjectToString("disconnected");
 }}}
;
 BA.debugLineNum = 73;BA.debugLine="lblStatus.Text = $\"Status: ${Status}\"$";
Debug.ShouldStop(256);
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 = 74;BA.debugLine="End Sub";
Debug.ShouldStop(512);
return RemoteObject.createImmutable("");
}
catch (Exception e) {
			throw Debug.ErrorCaught(e);
		} 
finally {
			Debug.PopSubsStack();
		}}
public static RemoteObject  _skbmotorspeed_valuechanged(RemoteObject _value,RemoteObject _userchanged) throws Exception{
try {
		Debug.PushSubsStack("skbMotorSpeed_ValueChanged (main) ","main",0,main.mostCurrent.activityBA,main.mostCurrent,104);
if (RapidSub.canDelegate("skbmotorspeed_valuechanged")) { return b4a.HC05DCMotor.main.remoteMe.runUserSub(false, "main","skbmotorspeed_valuechanged", _value, _userchanged);}
RemoteObject _b = RemoteObject.createImmutable((byte)0);
Debug.locals.put("Value", _value);
Debug.locals.put("UserChanged", _userchanged);
 BA.debugLineNum = 104;BA.debugLine="Sub skbMotorSpeed_ValueChanged (Value As Int, User";
Debug.ShouldStop(128);
 BA.debugLineNum = 105;BA.debugLine="lblMotorSpeed.Text = Value";
Debug.ShouldStop(256);
main.mostCurrent._lblmotorspeed.runMethod(true,"setText",BA.ObjectToCharSequence(_value));
 BA.debugLineNum = 106;BA.debugLine="Dim b As Byte";
Debug.ShouldStop(512);
_b = RemoteObject.createImmutable((byte)0);Debug.locals.put("b", _b);
 BA.debugLineNum = 107;BA.debugLine="b = Value";
Debug.ShouldStop(1024);
_b = BA.numberCast(byte.class, _value);Debug.locals.put("b", _b);
 BA.debugLineNum = 109;BA.debugLine="End Sub";
Debug.ShouldStop(4096);
return RemoteObject.createImmutable("");
}
catch (Exception e) {
			throw Debug.ErrorCaught(e);
		} 
finally {
			Debug.PopSubsStack();
		}}
public static RemoteObject  _tgbmotordirection_checkedchange(RemoteObject _checked) throws Exception{
try {
		Debug.PushSubsStack("tgbMotorDirection_CheckedChange (main) ","main",0,main.mostCurrent.activityBA,main.mostCurrent,94);
if (RapidSub.canDelegate("tgbmotordirection_checkedchange")) { return b4a.HC05DCMotor.main.remoteMe.runUserSub(false, "main","tgbmotordirection_checkedchange", _checked);}
RemoteObject _b = RemoteObject.createImmutable((byte)0);
Debug.locals.put("Checked", _checked);
 BA.debugLineNum = 94;BA.debugLine="Private Sub tgbMotorDirection_CheckedChange(Checke";
Debug.ShouldStop(536870912);
 BA.debugLineNum = 95;BA.debugLine="Dim b As Byte";
Debug.ShouldStop(1073741824);
_b = RemoteObject.createImmutable((byte)0);Debug.locals.put("b", _b);
 BA.debugLineNum = 96;BA.debugLine="If Checked = True Then";
Debug.ShouldStop(-2147483648);
if (RemoteObject.solveBoolean("=",_checked,main.mostCurrent.__c.getField(true,"True"))) { 
 BA.debugLineNum = 97;BA.debugLine="b = 1";
Debug.ShouldStop(1);
_b = BA.numberCast(byte.class, 1);Debug.locals.put("b", _b);
 }else {
 BA.debugLineNum = 99;BA.debugLine="b = 0";
Debug.ShouldStop(4);
_b = BA.numberCast(byte.class, 0);Debug.locals.put("b", _b);
 };
 BA.debugLineNum = 101;BA.debugLine="CallSub2(Starter, \"SendMessage\", Array As Byte(Ms";
Debug.ShouldStop(16);
main.mostCurrent.__c.runMethodAndSync(false,"CallSubNew2",main.processBA,(Object)((main.mostCurrent._starter.getObject())),(Object)(BA.ObjectToString("SendMessage")),(Object)((RemoteObject.createNewArray("byte",new int[] {2},new Object[] {main._msgmotordirection,_b}))));
 BA.debugLineNum = 102;BA.debugLine="End Sub";
Debug.ShouldStop(32);
return RemoteObject.createImmutable("");
}
catch (Exception e) {
			throw Debug.ErrorCaught(e);
		} 
finally {
			Debug.PopSubsStack();
		}}
public static RemoteObject  _tgbmotoronoff_checkedchange(RemoteObject _checked) throws Exception{
try {
		Debug.PushSubsStack("tgbMotorOnOff_CheckedChange (main) ","main",0,main.mostCurrent.activityBA,main.mostCurrent,84);
if (RapidSub.canDelegate("tgbmotoronoff_checkedchange")) { return b4a.HC05DCMotor.main.remoteMe.runUserSub(false, "main","tgbmotoronoff_checkedchange", _checked);}
RemoteObject _b = RemoteObject.createImmutable((byte)0);
Debug.locals.put("Checked", _checked);
 BA.debugLineNum = 84;BA.debugLine="Private Sub tgbMotorOnOff_CheckedChange(Checked As";
Debug.ShouldStop(524288);
 BA.debugLineNum = 85;BA.debugLine="Dim b As Byte";
Debug.ShouldStop(1048576);
_b = RemoteObject.createImmutable((byte)0);Debug.locals.put("b", _b);
 BA.debugLineNum = 86;BA.debugLine="If Checked = True Then";
Debug.ShouldStop(2097152);
if (RemoteObject.solveBoolean("=",_checked,main.mostCurrent.__c.getField(true,"True"))) { 
 BA.debugLineNum = 87;BA.debugLine="b = 1";
Debug.ShouldStop(4194304);
_b = BA.numberCast(byte.class, 1);Debug.locals.put("b", _b);
 }else {
 BA.debugLineNum = 89;BA.debugLine="b = 0";
Debug.ShouldStop(16777216);
_b = BA.numberCast(byte.class, 0);Debug.locals.put("b", _b);
 };
 BA.debugLineNum = 91;BA.debugLine="CallSub2(Starter, \"SendMessage\", Array As Byte(Ms";
Debug.ShouldStop(67108864);
main.mostCurrent.__c.runMethodAndSync(false,"CallSubNew2",main.processBA,(Object)((main.mostCurrent._starter.getObject())),(Object)(BA.ObjectToString("SendMessage")),(Object)((RemoteObject.createNewArray("byte",new int[] {2},new Object[] {main._msgmotoronoff,_b}))));
 BA.debugLineNum = 92;BA.debugLine="End Sub";
Debug.ShouldStop(134217728);
return RemoteObject.createImmutable("");
}
catch (Exception e) {
			throw Debug.ErrorCaught(e);
		} 
finally {
			Debug.PopSubsStack();
		}}
}