package reparto_izca.keymon.lat;


import anywheresoftware.b4a.BA;
import anywheresoftware.b4a.B4AClass;
import anywheresoftware.b4a.BALayout;
import anywheresoftware.b4a.debug.*;

public class escposprinter extends B4AClass.ImplB4AClass implements BA.SubDelegator{
    private static java.util.HashMap<String, java.lang.reflect.Method> htSubs;
    private void innerInitialize(BA _ba) throws Exception {
        if (ba == null) {
            ba = new BA(_ba, this, htSubs, "reparto_izca.keymon.lat.escposprinter");
            if (htSubs == null) {
                ba.loadHtSubs(this.getClass());
                htSubs = ba.htSubs;
            }
            
        }
        if (BA.isShellModeRuntimeCheck(ba)) 
			   this.getClass().getMethod("_class_globals", reparto_izca.keymon.lat.escposprinter.class).invoke(this, new Object[] {null});
        else
            ba.raiseEvent2(null, true, "class_globals", false);
    }

 public anywheresoftware.b4a.keywords.Common __c = null;
public double _version = 0;
public String _eventname = "";
public Object _callback = null;
public anywheresoftware.b4a.objects.Serial _serial1 = null;
public anywheresoftware.b4a.randomaccessfile.AsyncStreams _astream = null;
public boolean _connected = false;
public String _connectederror = "";
public String _esc = "";
public String _fs = "";
public String _gs = "";
public String _unreverse = "";
public String _reverse = "";
public String _uninvert = "";
public String _invert = "";
public String _unrotate = "";
public String _rotate = "";
public String _ht = "";
public String _uline0 = "";
public String _uline1 = "";
public String _uline2 = "";
public String _bold = "";
public String _nobold = "";
public String _single = "";
public String _high = "";
public String _wide = "";
public String _highwide = "";
public String _leftjustify = "";
public String _linedefault = "";
public String _linset0 = "";
public String _lmargin0 = "";
public String _width0 = "";
public String _charspacing0 = "";
public String _charfont0 = "";
public String _defaults = "";
public b4a.example.dateutils _dateutils = null;
public reparto_izca.keymon.lat.main _main = null;
public reparto_izca.keymon.lat.appupdater _appupdater = null;
public reparto_izca.keymon.lat.foto _foto = null;
public reparto_izca.keymon.lat.mapa_cliente _mapa_cliente = null;
public reparto_izca.keymon.lat.mapa_rutas _mapa_rutas = null;
public reparto_izca.keymon.lat.starter _starter = null;
public reparto_izca.keymon.lat.subs _subs = null;
public reparto_izca.keymon.lat.tracker _tracker = null;
public reparto_izca.keymon.lat.newinst2 _newinst2 = null;
public reparto_izca.keymon.lat.b4xpages _b4xpages = null;
public reparto_izca.keymon.lat.b4xcollections _b4xcollections = null;
public reparto_izca.keymon.lat.httputils2service _httputils2service = null;
public reparto_izca.keymon.lat.xuiviewsutils _xuiviewsutils = null;
public static class _animage{
public boolean IsInitialized;
public int Width;
public int Height;
public byte[] Data;
public void Initialize() {
IsInitialized = true;
Width = 0;
Height = 0;
Data = new byte[0];
;
}
@Override
		public String toString() {
			return BA.TypeToString(this, false);
		}}
public String  _astream_error() throws Exception{
 //BA.debugLineNum = 2285;BA.debugLine="Private Sub AStream_Error";
 //BA.debugLineNum = 2286;BA.debugLine="If SubExists(CallBack, EventName & \"_Error\") Then";
if (__c.SubExists(ba,_callback,_eventname+"_Error")) { 
 //BA.debugLineNum = 2287;BA.debugLine="CallSub(CallBack, EventName & \"_Error\")";
__c.CallSubNew(ba,_callback,_eventname+"_Error");
 };
 //BA.debugLineNum = 2289;BA.debugLine="End Sub";
return "";
}
public String  _astream_newdata(byte[] _buffer) throws Exception{
 //BA.debugLineNum = 2278;BA.debugLine="Private Sub AStream_NewData (Buffer() As Byte)";
 //BA.debugLineNum = 2279;BA.debugLine="If SubExists(CallBack, EventName & \"_NewData\") Th";
if (__c.SubExists(ba,_callback,_eventname+"_NewData")) { 
 //BA.debugLineNum = 2280;BA.debugLine="CallSub2(CallBack, EventName & \"_NewData\", Buffe";
__c.CallSubNew2(ba,_callback,_eventname+"_NewData",(Object)(_buffer));
 };
 //BA.debugLineNum = 2282;BA.debugLine="Log(\"Data \" & Buffer(0))";
__c.LogImpl("528704772","Data "+BA.NumberToString(_buffer[(int) (0)]),0);
 //BA.debugLineNum = 2283;BA.debugLine="End Sub";
return "";
}
public String  _astream_terminated() throws Exception{
 //BA.debugLineNum = 2291;BA.debugLine="Private Sub AStream_Terminated";
 //BA.debugLineNum = 2292;BA.debugLine="Connected = False";
_connected = __c.False;
 //BA.debugLineNum = 2293;BA.debugLine="If SubExists(CallBack, EventName & \"_Terminated\")";
if (__c.SubExists(ba,_callback,_eventname+"_Terminated")) { 
 //BA.debugLineNum = 2294;BA.debugLine="CallSub(CallBack, EventName & \"_Terminated\")";
__c.CallSubNew(ba,_callback,_eventname+"_Terminated");
 };
 //BA.debugLineNum = 2296;BA.debugLine="End Sub";
return "";
}
public String  _class_globals() throws Exception{
 //BA.debugLineNum = 1158;BA.debugLine="Sub Class_Globals";
 //BA.debugLineNum = 1165;BA.debugLine="Private Version As Double = 2.0 ' Printer class v";
_version = 2.0;
 //BA.debugLineNum = 1167;BA.debugLine="Type AnImage(Width As Int, Height As Int, Data()";
;
 //BA.debugLineNum = 1169;BA.debugLine="Private EventName As String 'ignore";
_eventname = "";
 //BA.debugLineNum = 1170;BA.debugLine="Private CallBack As Object 'ignore";
_callback = new Object();
 //BA.debugLineNum = 1172;BA.debugLine="Private Serial1 As Serial";
_serial1 = new anywheresoftware.b4a.objects.Serial();
 //BA.debugLineNum = 1173;BA.debugLine="Private Astream As AsyncStreams";
_astream = new anywheresoftware.b4a.randomaccessfile.AsyncStreams();
 //BA.debugLineNum = 1174;BA.debugLine="Private Connected As Boolean";
_connected = false;
 //BA.debugLineNum = 1175;BA.debugLine="Private ConnectedError As String";
_connectederror = "";
 //BA.debugLineNum = 1177;BA.debugLine="Dim ESC As String = Chr(27)";
_esc = BA.ObjectToString(__c.Chr((int) (27)));
 //BA.debugLineNum = 1178;BA.debugLine="Dim FS As String = Chr(28)";
_fs = BA.ObjectToString(__c.Chr((int) (28)));
 //BA.debugLineNum = 1179;BA.debugLine="Dim GS As String = Chr(29)";
_gs = BA.ObjectToString(__c.Chr((int) (29)));
 //BA.debugLineNum = 1182;BA.debugLine="Dim UNREVERSE As String  = GS & \"B\" & Chr(0)";
_unreverse = _gs+"B"+BA.ObjectToString(__c.Chr((int) (0)));
 //BA.debugLineNum = 1183;BA.debugLine="Dim REVERSE As String = GS & \"B\" & Chr(1)";
_reverse = _gs+"B"+BA.ObjectToString(__c.Chr((int) (1)));
 //BA.debugLineNum = 1186;BA.debugLine="Dim UNINVERT As String = ESC & \"{0\"";
_uninvert = _esc+"{0";
 //BA.debugLineNum = 1187;BA.debugLine="Dim INVERT As String = ESC & \"{1\"";
_invert = _esc+"{1";
 //BA.debugLineNum = 1190;BA.debugLine="Dim UNROTATE As String = ESC & \"V0\"";
_unrotate = _esc+"V0";
 //BA.debugLineNum = 1191;BA.debugLine="Dim ROTATE As String = ESC & \"V1\"";
_rotate = _esc+"V1";
 //BA.debugLineNum = 1194;BA.debugLine="Dim HT As String = Chr(9)";
_ht = BA.ObjectToString(__c.Chr((int) (9)));
 //BA.debugLineNum = 1197;BA.debugLine="Dim ULINE0 As String = ESC & \"-0\"";
_uline0 = _esc+"-0";
 //BA.debugLineNum = 1198;BA.debugLine="Dim ULINE1 As String = ESC & \"-1\"";
_uline1 = _esc+"-1";
 //BA.debugLineNum = 1199;BA.debugLine="Dim ULINE2 As String = ESC & \"-2\"";
_uline2 = _esc+"-2";
 //BA.debugLineNum = 1202;BA.debugLine="Dim BOLD As String = ESC & \"E1\"";
_bold = _esc+"E1";
 //BA.debugLineNum = 1203;BA.debugLine="Dim NOBOLD As String = ESC & \"E0\"";
_nobold = _esc+"E0";
 //BA.debugLineNum = 1206;BA.debugLine="Dim SINGLE As String = GS & \"!\" & Chr(0x00)";
_single = _gs+"!"+BA.ObjectToString(__c.Chr(((int)0x00)));
 //BA.debugLineNum = 1207;BA.debugLine="Dim HIGH As String = GS & \"!\" & Chr(0x01)";
_high = _gs+"!"+BA.ObjectToString(__c.Chr(((int)0x01)));
 //BA.debugLineNum = 1208;BA.debugLine="Dim WIDE As String = GS & \"!\" & Chr(0x10)";
_wide = _gs+"!"+BA.ObjectToString(__c.Chr(((int)0x10)));
 //BA.debugLineNum = 1209;BA.debugLine="Dim HIGHWIDE As String = GS & \"!\" & Chr(0x11)";
_highwide = _gs+"!"+BA.ObjectToString(__c.Chr(((int)0x11)));
 //BA.debugLineNum = 1212;BA.debugLine="Private LEFTJUSTIFY As String = ESC & \"a0\"";
_leftjustify = _esc+"a0";
 //BA.debugLineNum = 1213;BA.debugLine="Private LINEDEFAULT As String = ESC & \"2\"";
_linedefault = _esc+"2";
 //BA.debugLineNum = 1214;BA.debugLine="Private LINSET0 As String = ESC & \"$\" & Chr(0x0)";
_linset0 = _esc+"$"+BA.ObjectToString(__c.Chr(((int)0x0)))+BA.ObjectToString(__c.Chr(((int)0x0)));
 //BA.debugLineNum = 1215;BA.debugLine="Private LMARGIN0 As String = GS & \"L\" & Chr(0x0)";
_lmargin0 = _gs+"L"+BA.ObjectToString(__c.Chr(((int)0x0)))+BA.ObjectToString(__c.Chr(((int)0x0)));
 //BA.debugLineNum = 1216;BA.debugLine="Private WIDTH0 As String = GS & \"W\" & Chr(0xff) &";
_width0 = _gs+"W"+BA.ObjectToString(__c.Chr(((int)0xff)))+BA.ObjectToString(__c.Chr(((int)0xff)));
 //BA.debugLineNum = 1217;BA.debugLine="Private CHARSPACING0 As String = ESC & \" \" & Chr(";
_charspacing0 = _esc+" "+BA.ObjectToString(__c.Chr((int) (0)));
 //BA.debugLineNum = 1218;BA.debugLine="Private CHARFONT0 As String = ESC & \"M\" & Chr(0)";
_charfont0 = _esc+"M"+BA.ObjectToString(__c.Chr((int) (0)));
 //BA.debugLineNum = 1219;BA.debugLine="Dim DEFAULTS As String =  CHARSPACING0 & CHARFONT";
_defaults = _charspacing0+_charfont0+_lmargin0+_width0+_linset0+_linedefault+_leftjustify+_uninvert+_unrotate+_unreverse+_nobold+_uline0;
 //BA.debugLineNum = 1222;BA.debugLine="End Sub";
return "";
}
public boolean  _connect() throws Exception{
anywheresoftware.b4a.objects.collections.Map _paireddevices = null;
anywheresoftware.b4a.objects.collections.List _l = null;
int _i = 0;
int _res = 0;
 //BA.debugLineNum = 1254;BA.debugLine="Public Sub Connect As Boolean";
 //BA.debugLineNum = 1258;BA.debugLine="Try";
try { //BA.debugLineNum = 1259;BA.debugLine="If Starter.MAC_IMPRESORA = \"0\" Then";
if ((_starter._mac_impresora /*String*/ ).equals("0")) { 
 //BA.debugLineNum = 1260;BA.debugLine="Dim PairedDevices As Map";
_paireddevices = new anywheresoftware.b4a.objects.collections.Map();
 //BA.debugLineNum = 1261;BA.debugLine="PairedDevices = Serial1.GetPairedDevices";
_paireddevices = _serial1.GetPairedDevices();
 //BA.debugLineNum = 1262;BA.debugLine="Dim l As List";
_l = new anywheresoftware.b4a.objects.collections.List();
 //BA.debugLineNum = 1263;BA.debugLine="l.Initialize";
_l.Initialize();
 //BA.debugLineNum = 1264;BA.debugLine="For i = 0 To PairedDevices.Size - 1";
{
final int step7 = 1;
final int limit7 = (int) (_paireddevices.getSize()-1);
_i = (int) (0) ;
for (;_i <= limit7 ;_i = _i + step7 ) {
 //BA.debugLineNum = 1265;BA.debugLine="l.Add(PairedDevices.GetKeyAt(i))";
_l.Add(_paireddevices.GetKeyAt(_i));
 }
};
 //BA.debugLineNum = 1267;BA.debugLine="Dim Res As Int";
_res = 0;
 //BA.debugLineNum = 1268;BA.debugLine="Res = InputList(l, \"Choose a printer\", -1) 'sho";
_res = __c.InputList(_l,BA.ObjectToCharSequence("Choose a printer"),(int) (-1),getActivityBA());
 //BA.debugLineNum = 1269;BA.debugLine="If Res <> DialogResponse.CANCEL Then";
if (_res!=__c.DialogResponse.CANCEL) { 
 //BA.debugLineNum = 1270;BA.debugLine="Serial1.Connect(PairedDevices.Get(l.Get(Res)))";
_serial1.Connect(ba,BA.ObjectToString(_paireddevices.Get(_l.Get(_res))));
 //BA.debugLineNum = 1272;BA.debugLine="Starter.mac_impresora = PairedDevices.Get(l.Ge";
_starter._mac_impresora /*String*/  = BA.ObjectToString(_paireddevices.Get(_l.Get(_res)));
 //BA.debugLineNum = 1273;BA.debugLine="Return True";
if (true) return __c.True;
 };
 //BA.debugLineNum = 1275;BA.debugLine="Return False";
if (true) return __c.False;
 }else {
 //BA.debugLineNum = 1277;BA.debugLine="Serial1.Connect(Starter.mac_impresora)";
_serial1.Connect(ba,_starter._mac_impresora /*String*/ );
 //BA.debugLineNum = 1279;BA.debugLine="Return True";
if (true) return __c.True;
 };
 } 
       catch (Exception e23) {
			ba.setLastException(e23); //BA.debugLineNum = 1282;BA.debugLine="Log(LastException)";
__c.LogImpl("525559068",BA.ObjectToString(__c.LastException(getActivityBA())),0);
 };
 //BA.debugLineNum = 1284;BA.debugLine="End Sub";
return false;
}
public String  _connectederrormsg() throws Exception{
 //BA.debugLineNum = 1238;BA.debugLine="Public Sub ConnectedErrorMsg As String";
 //BA.debugLineNum = 1239;BA.debugLine="Return ConnectedError";
if (true) return _connectederror;
 //BA.debugLineNum = 1240;BA.debugLine="End Sub";
return "";
}
public int  _createbox(int _x0,int _y0,int _x1,int _y1,boolean _fill) throws Exception{
int _box = 0;
 //BA.debugLineNum = 1664;BA.debugLine="Public Sub CreateBox(x0 As Int, y0 As Int, x1 As I";
 //BA.debugLineNum = 1665;BA.debugLine="Dim box As Int = 0x10000000";
_box = ((int)0x10000000);
 //BA.debugLineNum = 1666;BA.debugLine="If fill Then box = box + 0x80000000";
if (_fill) { 
_box = (int) (_box+((int)0x80000000));};
 //BA.debugLineNum = 1667;BA.debugLine="box = box + Bit.ShiftLeft(Bit.And(0xf,x0), 24)";
_box = (int) (_box+__c.Bit.ShiftLeft(__c.Bit.And(((int)0xf),_x0),(int) (24)));
 //BA.debugLineNum = 1668;BA.debugLine="box = box + Bit.ShiftLeft(Bit.And(0x1f,y0), 16)";
_box = (int) (_box+__c.Bit.ShiftLeft(__c.Bit.And(((int)0x1f),_y0),(int) (16)));
 //BA.debugLineNum = 1669;BA.debugLine="box = box + Bit.ShiftLeft(Bit.And(0xf,x1), 8)";
_box = (int) (_box+__c.Bit.ShiftLeft(__c.Bit.And(((int)0xf),_x1),(int) (8)));
 //BA.debugLineNum = 1670;BA.debugLine="box = box + Bit.And(0x1f,y1)";
_box = (int) (_box+__c.Bit.And(((int)0x1f),_y1));
 //BA.debugLineNum = 1671;BA.debugLine="Return box";
if (true) return _box;
 //BA.debugLineNum = 1672;BA.debugLine="End Sub";
return 0;
}
public int  _createcircle(int _radius,int _quadrants,int _x1,int _y1,boolean _fill) throws Exception{
int _circle = 0;
 //BA.debugLineNum = 1634;BA.debugLine="Public Sub CreateCircle(radius As Int, quadrants A";
 //BA.debugLineNum = 1635;BA.debugLine="Dim circle As Int = 0x20000000";
_circle = ((int)0x20000000);
 //BA.debugLineNum = 1636;BA.debugLine="If fill Then circle = circle + 0x80000000";
if (_fill) { 
_circle = (int) (_circle+((int)0x80000000));};
 //BA.debugLineNum = 1637;BA.debugLine="circle = circle + Bit.ShiftLeft(radius, 24)";
_circle = (int) (_circle+__c.Bit.ShiftLeft(_radius,(int) (24)));
 //BA.debugLineNum = 1638;BA.debugLine="circle = circle + Bit.ShiftLeft(quadrants, 16)";
_circle = (int) (_circle+__c.Bit.ShiftLeft(_quadrants,(int) (16)));
 //BA.debugLineNum = 1639;BA.debugLine="circle = circle + Bit.ShiftLeft(x1, 8)";
_circle = (int) (_circle+__c.Bit.ShiftLeft(_x1,(int) (8)));
 //BA.debugLineNum = 1640;BA.debugLine="circle = circle + y1";
_circle = (int) (_circle+_y1);
 //BA.debugLineNum = 1641;BA.debugLine="Return circle";
if (true) return _circle;
 //BA.debugLineNum = 1642;BA.debugLine="End Sub";
return 0;
}
public byte[]  _createcustomcharacter(int[] _shapes,int _characterfont) throws Exception{
byte[] _masks = null;
byte[][] _points = null;
int _x = 0;
int _y = 0;
int _size = 0;
byte[] _charbyes = null;
int _c = 0;
int _i = 0;
int _fill = 0;
int _shape = 0;
int _x0 = 0;
int _y0 = 0;
int _x1 = 0;
int _y1 = 0;
int _x2 = 0;
int _y2 = 0;
String _logmsg = "";
byte _bits = (byte)0;
int _b = 0;
 //BA.debugLineNum = 1548;BA.debugLine="Public Sub CreateCustomCharacter(shapes() As Int,";
 //BA.debugLineNum = 1549;BA.debugLine="Dim masks(8) As Byte";
_masks = new byte[(int) (8)];
;
 //BA.debugLineNum = 1550;BA.debugLine="masks(0) = 0x80";
_masks[(int) (0)] = (byte) (((int)0x80));
 //BA.debugLineNum = 1551;BA.debugLine="masks(1) = 0x40";
_masks[(int) (1)] = (byte) (((int)0x40));
 //BA.debugLineNum = 1552;BA.debugLine="masks(2) = 0x20";
_masks[(int) (2)] = (byte) (((int)0x20));
 //BA.debugLineNum = 1553;BA.debugLine="masks(3) = 0x10";
_masks[(int) (3)] = (byte) (((int)0x10));
 //BA.debugLineNum = 1554;BA.debugLine="masks(4) = 0x08";
_masks[(int) (4)] = (byte) (((int)0x08));
 //BA.debugLineNum = 1555;BA.debugLine="masks(5) = 0x04";
_masks[(int) (5)] = (byte) (((int)0x04));
 //BA.debugLineNum = 1556;BA.debugLine="masks(6) = 0x02";
_masks[(int) (6)] = (byte) (((int)0x02));
 //BA.debugLineNum = 1557;BA.debugLine="masks(7) = 0x01";
_masks[(int) (7)] = (byte) (((int)0x01));
 //BA.debugLineNum = 1560;BA.debugLine="Dim points(16,32) As Byte";
_points = new byte[(int) (16)][];
{
int d0 = _points.length;
int d1 = (int) (32);
for (int i0 = 0;i0 < d0;i0++) {
_points[i0] = new byte[d1];
}
}
;
 //BA.debugLineNum = 1562;BA.debugLine="For x = 0 To 15";
{
final int step11 = 1;
final int limit11 = (int) (15);
_x = (int) (0) ;
for (;_x <= limit11 ;_x = _x + step11 ) {
 //BA.debugLineNum = 1563;BA.debugLine="For y = 0 To 31";
{
final int step12 = 1;
final int limit12 = (int) (31);
_y = (int) (0) ;
for (;_y <= limit12 ;_y = _y + step12 ) {
 //BA.debugLineNum = 1564;BA.debugLine="points(x,y) = 0";
_points[_x][_y] = (byte) (0);
 }
};
 }
};
 //BA.debugLineNum = 1567;BA.debugLine="Dim size As Int = 12";
_size = (int) (12);
 //BA.debugLineNum = 1568;BA.debugLine="If characterfont = 1 Then size = 9";
if (_characterfont==1) { 
_size = (int) (9);};
 //BA.debugLineNum = 1569;BA.debugLine="Dim charbyes(size * 3) As Byte";
_charbyes = new byte[(int) (_size*3)];
;
 //BA.debugLineNum = 1570;BA.debugLine="For c = 0 To charbyes.Length - 1";
{
final int step19 = 1;
final int limit19 = (int) (_charbyes.length-1);
_c = (int) (0) ;
for (;_c <= limit19 ;_c = _c + step19 ) {
 //BA.debugLineNum = 1571;BA.debugLine="charbyes(c) = 0";
_charbyes[_c] = (byte) (0);
 }
};
 //BA.debugLineNum = 1574;BA.debugLine="For i = 0 To shapes.Length -1";
{
final int step22 = 1;
final int limit22 = (int) (_shapes.length-1);
_i = (int) (0) ;
for (;_i <= limit22 ;_i = _i + step22 ) {
 //BA.debugLineNum = 1575;BA.debugLine="Dim fill As Int =  Bit.UnsignedShiftRight(Bit.An";
_fill = __c.Bit.UnsignedShiftRight(__c.Bit.And(((int)0x80000000),_shapes[_i]),(int) (31));
 //BA.debugLineNum = 1576;BA.debugLine="Dim shape As Int = Bit.UnsignedShiftRight(Bit.An";
_shape = __c.Bit.UnsignedShiftRight(__c.Bit.And(((int)0x70000000),_shapes[_i]),(int) (28));
 //BA.debugLineNum = 1577;BA.debugLine="Dim x0 As Int = Bit.UnsignedShiftRight(Bit.And(0";
_x0 = __c.Bit.UnsignedShiftRight(__c.Bit.And(((int)0x0f000000),_shapes[_i]),(int) (24));
 //BA.debugLineNum = 1578;BA.debugLine="Dim y0 As Int = Bit.UnsignedShiftRight(Bit.And(0";
_y0 = __c.Bit.UnsignedShiftRight(__c.Bit.And(((int)0x001f0000),_shapes[_i]),(int) (16));
 //BA.debugLineNum = 1579;BA.debugLine="Dim x1 As Int = Bit.UnsignedShiftRight(Bit.And(0";
_x1 = __c.Bit.UnsignedShiftRight(__c.Bit.And(((int)0x00000f00),_shapes[_i]),(int) (8));
 //BA.debugLineNum = 1580;BA.debugLine="Dim y1 As Int = Bit.And(0x0000001f, shapes(i))";
_y1 = __c.Bit.And(((int)0x0000001f),_shapes[_i]);
 //BA.debugLineNum = 1581;BA.debugLine="Dim x2 As Int = Bit.UnsignedShiftRight(Bit.And(0";
_x2 = __c.Bit.UnsignedShiftRight(__c.Bit.And(((int)0x0000f000),_shapes[_i]),(int) (12));
 //BA.debugLineNum = 1582;BA.debugLine="Dim y2 As Int = Bit.UnsignedShiftRight(Bit.And(0";
_y2 = (int) (__c.Bit.UnsignedShiftRight(__c.Bit.And(((int)0x00e00000),_shapes[_i]),(int) (18))+__c.Bit.UnsignedShiftRight(__c.Bit.And(((int)0x000000e0),_shapes[_i]),(int) (5)));
 //BA.debugLineNum = 1588;BA.debugLine="Dim logmsg As String = \": Fill=\" & fill & \" : Po";
_logmsg = ": Fill="+BA.NumberToString(_fill)+" : Points "+BA.NumberToString(_x0)+","+BA.NumberToString(_y0)+"  "+BA.NumberToString(_x1)+","+BA.NumberToString(_y1)+"  "+BA.NumberToString(_x2)+","+BA.NumberToString(_y2);
 //BA.debugLineNum = 1589;BA.debugLine="If shape = 3 Then";
if (_shape==3) { 
 //BA.debugLineNum = 1590;BA.debugLine="Log(\"Triangle \" & logmsg)";
__c.LogImpl("526869802","Triangle "+_logmsg,0);
 //BA.debugLineNum = 1591;BA.debugLine="PlotTriangle(x0, y0, x1, y1, x2, y2, points, fi";
_plottriangle(_x0,_y0,_x1,_y1,_x2,_y2,_points,_fill);
 }else if(_shape==2) { 
 //BA.debugLineNum = 1593;BA.debugLine="Log(\"Circle \" & logmsg)";
__c.LogImpl("526869805","Circle "+_logmsg,0);
 //BA.debugLineNum = 1594;BA.debugLine="PlotCircle(x0, y0, x1, y1, points, fill)";
_plotcircle(_x0,_y0,_x1,_y1,_points,_fill);
 }else if(_shape==1) { 
 //BA.debugLineNum = 1596;BA.debugLine="Log(\"Box \" & logmsg)";
__c.LogImpl("526869808","Box "+_logmsg,0);
 //BA.debugLineNum = 1597;BA.debugLine="PlotBox(x0, y0, x1, y1, points, fill)";
_plotbox(_x0,_y0,_x1,_y1,_points,_fill);
 }else {
 //BA.debugLineNum = 1599;BA.debugLine="Log(\"Line \" & logmsg)";
__c.LogImpl("526869811","Line "+_logmsg,0);
 //BA.debugLineNum = 1600;BA.debugLine="PlotLine(x0, y0, x1, y1, points)";
_plotline(_x0,_y0,_x1,_y1,_points);
 };
 //BA.debugLineNum = 1603;BA.debugLine="For x = 0 To size -1 ' 9 or 12 horizontal bytes";
{
final int step45 = 1;
final int limit45 = (int) (_size-1);
_x = (int) (0) ;
for (;_x <= limit45 ;_x = _x + step45 ) {
 //BA.debugLineNum = 1604;BA.debugLine="For y = 0 To 2 ' 3 vertical bytes";
{
final int step46 = 1;
final int limit46 = (int) (2);
_y = (int) (0) ;
for (;_y <= limit46 ;_y = _y + step46 ) {
 //BA.debugLineNum = 1605;BA.debugLine="Dim bits As Byte = 0";
_bits = (byte) (0);
 //BA.debugLineNum = 1606;BA.debugLine="For b = 0 To 7 ' 8 vertical bits";
{
final int step48 = 1;
final int limit48 = (int) (7);
_b = (int) (0) ;
for (;_b <= limit48 ;_b = _b + step48 ) {
 //BA.debugLineNum = 1607;BA.debugLine="If points(x, y*8+b) <> 0 Then";
if (_points[_x][(int) (_y*8+_b)]!=0) { 
 //BA.debugLineNum = 1608;BA.debugLine="bits = Bit.Or(bits, masks(b))";
_bits = (byte) (__c.Bit.Or((int) (_bits),(int) (_masks[_b])));
 };
 }
};
 //BA.debugLineNum = 1611;BA.debugLine="charbyes(x*3+y) = bits";
_charbyes[(int) (_x*3+_y)] = _bits;
 }
};
 }
};
 }
};
 //BA.debugLineNum = 1615;BA.debugLine="Return charbyes";
if (true) return _charbyes;
 //BA.debugLineNum = 1616;BA.debugLine="End Sub";
return null;
}
public int  _createline(int _x0,int _y0,int _x1,int _y1) throws Exception{
int _line = 0;
 //BA.debugLineNum = 1621;BA.debugLine="Public Sub CreateLine(x0 As Int, y0 As Int, x1 As";
 //BA.debugLineNum = 1622;BA.debugLine="Dim line As Int = 0";
_line = (int) (0);
 //BA.debugLineNum = 1623;BA.debugLine="line = line + Bit.ShiftLeft(Bit.And(0xf,x0), 24)";
_line = (int) (_line+__c.Bit.ShiftLeft(__c.Bit.And(((int)0xf),_x0),(int) (24)));
 //BA.debugLineNum = 1624;BA.debugLine="line = line + Bit.ShiftLeft(Bit.And(0x1f,y0), 16)";
_line = (int) (_line+__c.Bit.ShiftLeft(__c.Bit.And(((int)0x1f),_y0),(int) (16)));
 //BA.debugLineNum = 1625;BA.debugLine="line = line + Bit.ShiftLeft(Bit.And(0xf,x1), 8)";
_line = (int) (_line+__c.Bit.ShiftLeft(__c.Bit.And(((int)0xf),_x1),(int) (8)));
 //BA.debugLineNum = 1626;BA.debugLine="line = line + Bit.And(0x1f,y1)";
_line = (int) (_line+__c.Bit.And(((int)0x1f),_y1));
 //BA.debugLineNum = 1627;BA.debugLine="Return line";
if (true) return _line;
 //BA.debugLineNum = 1628;BA.debugLine="End Sub";
return 0;
}
public int  _createtriangle(int _x0,int _y0,int _x1,int _y1,int _x2,int _y2,boolean _fill) throws Exception{
int _triangle = 0;
 //BA.debugLineNum = 1648;BA.debugLine="Public Sub CreateTriangle(x0 As Int, y0 As Int, x1";
 //BA.debugLineNum = 1649;BA.debugLine="Dim triangle As Int = 0x30000000";
_triangle = ((int)0x30000000);
 //BA.debugLineNum = 1650;BA.debugLine="If fill Then triangle = triangle + 0x80000000";
if (_fill) { 
_triangle = (int) (_triangle+((int)0x80000000));};
 //BA.debugLineNum = 1651;BA.debugLine="triangle = triangle + Bit.ShiftLeft(Bit.And(0xf,x";
_triangle = (int) (_triangle+__c.Bit.ShiftLeft(__c.Bit.And(((int)0xf),_x0),(int) (24)));
 //BA.debugLineNum = 1652;BA.debugLine="triangle = triangle + Bit.ShiftLeft(Bit.And(0x1f,";
_triangle = (int) (_triangle+__c.Bit.ShiftLeft(__c.Bit.And(((int)0x1f),_y0),(int) (16)));
 //BA.debugLineNum = 1653;BA.debugLine="triangle = triangle + Bit.ShiftLeft(Bit.And(0xf,x";
_triangle = (int) (_triangle+__c.Bit.ShiftLeft(__c.Bit.And(((int)0xf),_x1),(int) (8)));
 //BA.debugLineNum = 1654;BA.debugLine="triangle = triangle + Bit.And(0x1f,y1)";
_triangle = (int) (_triangle+__c.Bit.And(((int)0x1f),_y1));
 //BA.debugLineNum = 1655;BA.debugLine="triangle = triangle + Bit.ShiftLeft(Bit.And(0xf,x";
_triangle = (int) (_triangle+__c.Bit.ShiftLeft(__c.Bit.And(((int)0xf),_x2),(int) (12)));
 //BA.debugLineNum = 1656;BA.debugLine="triangle = triangle + Bit.ShiftLeft(Bit.And(0x7,y";
_triangle = (int) (_triangle+__c.Bit.ShiftLeft(__c.Bit.And(((int)0x7),_y2),(int) (5)));
 //BA.debugLineNum = 1657;BA.debugLine="triangle = triangle + Bit.ShiftLeft(Bit.And(0x18,";
_triangle = (int) (_triangle+__c.Bit.ShiftLeft(__c.Bit.And(((int)0x18),_y2),(int) (18)));
 //BA.debugLineNum = 1658;BA.debugLine="Return triangle";
if (true) return _triangle;
 //BA.debugLineNum = 1659;BA.debugLine="End Sub";
return 0;
}
public int  _definecustomcharacter(int _charcode,byte[] _bitdata) throws Exception{
int _excess = 0;
int _size = 0;
byte[] _params = null;
 //BA.debugLineNum = 1496;BA.debugLine="Public Sub DefineCustomCharacter(charcode As Int,";
 //BA.debugLineNum = 1497;BA.debugLine="Dim excess As Int = bitdata.Length Mod 3";
_excess = (int) (_bitdata.length%3);
 //BA.debugLineNum = 1498;BA.debugLine="If excess <> 0 Then Return -1";
if (_excess!=0) { 
if (true) return (int) (-1);};
 //BA.debugLineNum = 1499;BA.debugLine="Dim size As Int = bitdata.Length / 3";
_size = (int) (_bitdata.length/(double)3);
 //BA.debugLineNum = 1500;BA.debugLine="WriteString(ESC & \"&\")";
_writestring(_esc+"&");
 //BA.debugLineNum = 1501;BA.debugLine="Dim params(4) As Byte";
_params = new byte[(int) (4)];
;
 //BA.debugLineNum = 1502;BA.debugLine="params(0) = 3";
_params[(int) (0)] = (byte) (3);
 //BA.debugLineNum = 1503;BA.debugLine="params(1) = charcode";
_params[(int) (1)] = (byte) (_charcode);
 //BA.debugLineNum = 1504;BA.debugLine="params(2) = charcode";
_params[(int) (2)] = (byte) (_charcode);
 //BA.debugLineNum = 1505;BA.debugLine="params(3) = size";
_params[(int) (3)] = (byte) (_size);
 //BA.debugLineNum = 1506;BA.debugLine="WriteBytes(params)";
_writebytes(_params);
 //BA.debugLineNum = 1507;BA.debugLine="WriteBytes(bitdata)";
_writebytes(_bitdata);
 //BA.debugLineNum = 1508;BA.debugLine="Return 0";
if (true) return (int) (0);
 //BA.debugLineNum = 1509;BA.debugLine="End Sub";
return 0;
}
public String  _deletecustomcharacter(int _charcode) throws Exception{
byte[] _params = null;
 //BA.debugLineNum = 1461;BA.debugLine="Public Sub DeleteCustomCharacter(charcode As Int)";
 //BA.debugLineNum = 1462;BA.debugLine="WriteString(ESC & \"?\")";
_writestring(_esc+"?");
 //BA.debugLineNum = 1463;BA.debugLine="Dim params(1) As Byte";
_params = new byte[(int) (1)];
;
 //BA.debugLineNum = 1464;BA.debugLine="params(0) = charcode";
_params[(int) (0)] = (byte) (_charcode);
 //BA.debugLineNum = 1465;BA.debugLine="WriteBytes(params)";
_writebytes(_params);
 //BA.debugLineNum = 1466;BA.debugLine="End Sub";
return "";
}
public String  _disconnect() throws Exception{
 //BA.debugLineNum = 1287;BA.debugLine="Public Sub DisConnect";
 //BA.debugLineNum = 1288;BA.debugLine="Serial1.Disconnect";
_serial1.Disconnect();
 //BA.debugLineNum = 1289;BA.debugLine="Connected = False";
_connected = __c.False;
 //BA.debugLineNum = 1290;BA.debugLine="End Sub";
return "";
}
public reparto_izca.keymon.lat.escposprinter._animage  _ditherimage1d(reparto_izca.keymon.lat.escposprinter._animage _img,int _threshold) throws Exception{
byte[] _pixels = null;
int _error = 0;
int _y = 0;
int _x = 0;
int _lum = 0;
reparto_izca.keymon.lat.escposprinter._animage _ret = null;
 //BA.debugLineNum = 1907;BA.debugLine="Sub DitherImage1D(img As AnImage, threshold As Int";
 //BA.debugLineNum = 1908;BA.debugLine="Dim pixels(img.Data.Length) As Byte";
_pixels = new byte[_img.Data /*byte[]*/ .length];
;
 //BA.debugLineNum = 1909;BA.debugLine="Dim error As Int";
_error = 0;
 //BA.debugLineNum = 1910;BA.debugLine="For y = 0 To img.Height - 1";
{
final int step3 = 1;
final int limit3 = (int) (_img.Height /*int*/ -1);
_y = (int) (0) ;
for (;_y <= limit3 ;_y = _y + step3 ) {
 //BA.debugLineNum = 1911;BA.debugLine="error = 0 ' reset on each new line";
_error = (int) (0);
 //BA.debugLineNum = 1912;BA.debugLine="For x = 0 To img.Width - 1";
{
final int step5 = 1;
final int limit5 = (int) (_img.Width /*int*/ -1);
_x = (int) (0) ;
for (;_x <= limit5 ;_x = _x + step5 ) {
 //BA.debugLineNum = 1913;BA.debugLine="Dim lum As Int = Bit.And(img.Data(y*img.Width +";
_lum = __c.Bit.And((int) (_img.Data /*byte[]*/ [(int) (_y*_img.Width /*int*/ +_x)]),((int)0xff));
 //BA.debugLineNum = 1914;BA.debugLine="lum = lum + error";
_lum = (int) (_lum+_error);
 //BA.debugLineNum = 1915;BA.debugLine="If lum < threshold Then";
if (_lum<_threshold) { 
 //BA.debugLineNum = 1916;BA.debugLine="error = lum";
_error = _lum;
 //BA.debugLineNum = 1917;BA.debugLine="lum = 1";
_lum = (int) (1);
 }else {
 //BA.debugLineNum = 1919;BA.debugLine="error = lum - 255";
_error = (int) (_lum-255);
 //BA.debugLineNum = 1920;BA.debugLine="lum = 0";
_lum = (int) (0);
 };
 //BA.debugLineNum = 1922;BA.debugLine="pixels(y*img.Width + x) = lum";
_pixels[(int) (_y*_img.Width /*int*/ +_x)] = (byte) (_lum);
 }
};
 }
};
 //BA.debugLineNum = 1925;BA.debugLine="Dim ret As AnImage";
_ret = new reparto_izca.keymon.lat.escposprinter._animage();
 //BA.debugLineNum = 1926;BA.debugLine="ret.Width = img.Width";
_ret.Width /*int*/  = _img.Width /*int*/ ;
 //BA.debugLineNum = 1927;BA.debugLine="ret.Height = img.Height";
_ret.Height /*int*/  = _img.Height /*int*/ ;
 //BA.debugLineNum = 1928;BA.debugLine="ret.Data = pixels";
_ret.Data /*byte[]*/  = _pixels;
 //BA.debugLineNum = 1929;BA.debugLine="Return ret";
if (true) return _ret;
 //BA.debugLineNum = 1930;BA.debugLine="End Sub";
return null;
}
public reparto_izca.keymon.lat.escposprinter._animage  _ditherimage2d(reparto_izca.keymon.lat.escposprinter._animage _img,int _threshold) throws Exception{
byte[] _pixels = null;
int _xerror = 0;
int[] _yerrors = null;
int _i = 0;
int _y = 0;
int _x = 0;
int _lum = 0;
reparto_izca.keymon.lat.escposprinter._animage _ret = null;
 //BA.debugLineNum = 1938;BA.debugLine="Sub DitherImage2D(img As AnImage, threshold As Int";
 //BA.debugLineNum = 1939;BA.debugLine="Dim pixels(img.Data.Length) As Byte";
_pixels = new byte[_img.Data /*byte[]*/ .length];
;
 //BA.debugLineNum = 1940;BA.debugLine="Dim xerror As Int";
_xerror = 0;
 //BA.debugLineNum = 1941;BA.debugLine="Dim yerrors(img.Width) As Int";
_yerrors = new int[_img.Width /*int*/ ];
;
 //BA.debugLineNum = 1942;BA.debugLine="For i = 0 To yerrors.Length -1";
{
final int step4 = 1;
final int limit4 = (int) (_yerrors.length-1);
_i = (int) (0) ;
for (;_i <= limit4 ;_i = _i + step4 ) {
 //BA.debugLineNum = 1943;BA.debugLine="yerrors(0) = 0";
_yerrors[(int) (0)] = (int) (0);
 }
};
 //BA.debugLineNum = 1945;BA.debugLine="For y = 0 To img.Height - 1";
{
final int step7 = 1;
final int limit7 = (int) (_img.Height /*int*/ -1);
_y = (int) (0) ;
for (;_y <= limit7 ;_y = _y + step7 ) {
 //BA.debugLineNum = 1946;BA.debugLine="xerror = 0 ' reset on each new line";
_xerror = (int) (0);
 //BA.debugLineNum = 1947;BA.debugLine="For x = 0 To img.Width - 1";
{
final int step9 = 1;
final int limit9 = (int) (_img.Width /*int*/ -1);
_x = (int) (0) ;
for (;_x <= limit9 ;_x = _x + step9 ) {
 //BA.debugLineNum = 1948;BA.debugLine="Dim lum As Int = Bit.And(img.Data(y*img.Width +";
_lum = __c.Bit.And((int) (_img.Data /*byte[]*/ [(int) (_y*_img.Width /*int*/ +_x)]),((int)0xff));
 //BA.debugLineNum = 1949;BA.debugLine="lum = lum + xerror + yerrors(x)";
_lum = (int) (_lum+_xerror+_yerrors[_x]);
 //BA.debugLineNum = 1950;BA.debugLine="If lum < threshold Then";
if (_lum<_threshold) { 
 //BA.debugLineNum = 1951;BA.debugLine="xerror = lum/2";
_xerror = (int) (_lum/(double)2);
 //BA.debugLineNum = 1952;BA.debugLine="yerrors(x) = xerror";
_yerrors[_x] = _xerror;
 //BA.debugLineNum = 1953;BA.debugLine="lum = 1";
_lum = (int) (1);
 }else {
 //BA.debugLineNum = 1955;BA.debugLine="xerror = (lum - 255)/2";
_xerror = (int) ((_lum-255)/(double)2);
 //BA.debugLineNum = 1956;BA.debugLine="yerrors(x) = xerror";
_yerrors[_x] = _xerror;
 //BA.debugLineNum = 1957;BA.debugLine="lum = 0";
_lum = (int) (0);
 };
 //BA.debugLineNum = 1959;BA.debugLine="pixels(y*img.Width + x) = lum";
_pixels[(int) (_y*_img.Width /*int*/ +_x)] = (byte) (_lum);
 }
};
 }
};
 //BA.debugLineNum = 1962;BA.debugLine="Dim ret As AnImage";
_ret = new reparto_izca.keymon.lat.escposprinter._animage();
 //BA.debugLineNum = 1963;BA.debugLine="ret.Width = img.Width";
_ret.Width /*int*/  = _img.Width /*int*/ ;
 //BA.debugLineNum = 1964;BA.debugLine="ret.Height = img.Height";
_ret.Height /*int*/  = _img.Height /*int*/ ;
 //BA.debugLineNum = 1965;BA.debugLine="ret.Data = pixels";
_ret.Data /*byte[]*/  = _pixels;
 //BA.debugLineNum = 1966;BA.debugLine="Return ret";
if (true) return _ret;
 //BA.debugLineNum = 1967;BA.debugLine="End Sub";
return null;
}
public String  _filltriangle(int _x0,int _y0,int _x1,int _y1,int _x2,int _y2,byte[][] _points) throws Exception{
int _tx = 0;
int _ty = 0;
double _dx0 = 0;
double _dx1 = 0;
double _dx2 = 0;
double _x3 = 0;
double _x4 = 0;
double _y3 = 0;
double _y4 = 0;
int _inc = 0;
int _x = 0;
 //BA.debugLineNum = 1688;BA.debugLine="Private Sub FillTriangle(x0 As Int, y0 As Int, x1";
 //BA.debugLineNum = 1690;BA.debugLine="Dim tx, ty As Int";
_tx = 0;
_ty = 0;
 //BA.debugLineNum = 1691;BA.debugLine="If y0 > y1 Then";
if (_y0>_y1) { 
 //BA.debugLineNum = 1692;BA.debugLine="tx = x0 : ty = y0";
_tx = _x0;
 //BA.debugLineNum = 1692;BA.debugLine="tx = x0 : ty = y0";
_ty = _y0;
 //BA.debugLineNum = 1693;BA.debugLine="x0 = x1 : y0 = y1";
_x0 = _x1;
 //BA.debugLineNum = 1693;BA.debugLine="x0 = x1 : y0 = y1";
_y0 = _y1;
 //BA.debugLineNum = 1694;BA.debugLine="x1 = tx : y1 = ty";
_x1 = _tx;
 //BA.debugLineNum = 1694;BA.debugLine="x1 = tx : y1 = ty";
_y1 = _ty;
 };
 //BA.debugLineNum = 1696;BA.debugLine="If y0 > y2 Then";
if (_y0>_y2) { 
 //BA.debugLineNum = 1697;BA.debugLine="tx = x0 : ty = y0";
_tx = _x0;
 //BA.debugLineNum = 1697;BA.debugLine="tx = x0 : ty = y0";
_ty = _y0;
 //BA.debugLineNum = 1698;BA.debugLine="x0 = x2 : y0 = y2";
_x0 = _x2;
 //BA.debugLineNum = 1698;BA.debugLine="x0 = x2 : y0 = y2";
_y0 = _y2;
 //BA.debugLineNum = 1699;BA.debugLine="x2 = tx : y2 = ty";
_x2 = _tx;
 //BA.debugLineNum = 1699;BA.debugLine="x2 = tx : y2 = ty";
_y2 = _ty;
 };
 //BA.debugLineNum = 1701;BA.debugLine="If y1 > y2 Then";
if (_y1>_y2) { 
 //BA.debugLineNum = 1702;BA.debugLine="tx = x1 : ty = y1";
_tx = _x1;
 //BA.debugLineNum = 1702;BA.debugLine="tx = x1 : ty = y1";
_ty = _y1;
 //BA.debugLineNum = 1703;BA.debugLine="x1 = x2 : y1 = y2";
_x1 = _x2;
 //BA.debugLineNum = 1703;BA.debugLine="x1 = x2 : y1 = y2";
_y1 = _y2;
 //BA.debugLineNum = 1704;BA.debugLine="x2 = tx : y2 = ty";
_x2 = _tx;
 //BA.debugLineNum = 1704;BA.debugLine="x2 = tx : y2 = ty";
_y2 = _ty;
 };
 //BA.debugLineNum = 1707;BA.debugLine="Dim dx0, dx1, dx2 As Double";
_dx0 = 0;
_dx1 = 0;
_dx2 = 0;
 //BA.debugLineNum = 1708;BA.debugLine="Dim x3, x4, y3, y4 As Double";
_x3 = 0;
_x4 = 0;
_y3 = 0;
_y4 = 0;
 //BA.debugLineNum = 1709;BA.debugLine="Dim inc As Int";
_inc = 0;
 //BA.debugLineNum = 1711;BA.debugLine="If y1 - y0 > 0 Then	dx0=(x1-x0)/(y1-y0) Else	dx0=";
if (_y1-_y0>0) { 
_dx0 = (_x1-_x0)/(double)(_y1-_y0);}
else {
_dx0 = 0;};
 //BA.debugLineNum = 1712;BA.debugLine="If y2 - y0 > 0 Then dx1=(x2-x0)/(y2-y0) Else dx1=";
if (_y2-_y0>0) { 
_dx1 = (_x2-_x0)/(double)(_y2-_y0);}
else {
_dx1 = 0;};
 //BA.debugLineNum = 1713;BA.debugLine="If y2 - y1 > 0 Then dx2=(x2-x1)/(y2-y1) Else dx2=";
if (_y2-_y1>0) { 
_dx2 = (_x2-_x1)/(double)(_y2-_y1);}
else {
_dx2 = 0;};
 //BA.debugLineNum = 1714;BA.debugLine="x3 = x0 : x4 = x0";
_x3 = _x0;
 //BA.debugLineNum = 1714;BA.debugLine="x3 = x0 : x4 = x0";
_x4 = _x0;
 //BA.debugLineNum = 1715;BA.debugLine="y3 = y0 : y4 = y0";
_y3 = _y0;
 //BA.debugLineNum = 1715;BA.debugLine="y3 = y0 : y4 = y0";
_y4 = _y0;
 //BA.debugLineNum = 1716;BA.debugLine="If dx0 > dx1 Then";
if (_dx0>_dx1) { 
 //BA.debugLineNum = 1717;BA.debugLine="While";
__c.While();
 //BA.debugLineNum = 1718;BA.debugLine="Do While y3 <= y1";
while (_y3<=_y1) {
 //BA.debugLineNum = 1719;BA.debugLine="If x3 > x4 Then inc = -1 Else inc = 1";
if (_x3>_x4) { 
_inc = (int) (-1);}
else {
_inc = (int) (1);};
 //BA.debugLineNum = 1720;BA.debugLine="For x = x3 To x4 Step inc";
{
final int step40 = _inc;
final int limit40 = (int) (_x4);
_x = (int) (_x3) ;
for (;(step40 > 0 && _x <= limit40) || (step40 < 0 && _x >= limit40) ;_x = ((int)(0 + _x + step40))  ) {
 //BA.debugLineNum = 1721;BA.debugLine="points(x, y3) = 1";
_points[_x][(int) (_y3)] = (byte) (1);
 }
};
 //BA.debugLineNum = 1723;BA.debugLine="y3 = y3 + 1 : y4 = y4 + 1 : x3 = x3 + dx1 : x4";
_y3 = _y3+1;
 //BA.debugLineNum = 1723;BA.debugLine="y3 = y3 + 1 : y4 = y4 + 1 : x3 = x3 + dx1 : x4";
_y4 = _y4+1;
 //BA.debugLineNum = 1723;BA.debugLine="y3 = y3 + 1 : y4 = y4 + 1 : x3 = x3 + dx1 : x4";
_x3 = _x3+_dx1;
 //BA.debugLineNum = 1723;BA.debugLine="y3 = y3 + 1 : y4 = y4 + 1 : x3 = x3 + dx1 : x4";
_x4 = _x4+_dx0;
 }
;
 //BA.debugLineNum = 1725;BA.debugLine="x4=x1";
_x4 = _x1;
 //BA.debugLineNum = 1726;BA.debugLine="y4=y1";
_y4 = _y1;
 //BA.debugLineNum = 1727;BA.debugLine="Do While y3 <= y2";
while (_y3<=_y2) {
 //BA.debugLineNum = 1728;BA.debugLine="If x3 > x4 Then inc = -1 Else inc = 1";
if (_x3>_x4) { 
_inc = (int) (-1);}
else {
_inc = (int) (1);};
 //BA.debugLineNum = 1729;BA.debugLine="For x = x3 To x4 Step inc";
{
final int step52 = _inc;
final int limit52 = (int) (_x4);
_x = (int) (_x3) ;
for (;(step52 > 0 && _x <= limit52) || (step52 < 0 && _x >= limit52) ;_x = ((int)(0 + _x + step52))  ) {
 //BA.debugLineNum = 1730;BA.debugLine="points(x ,y3) = 1";
_points[_x][(int) (_y3)] = (byte) (1);
 }
};
 //BA.debugLineNum = 1732;BA.debugLine="y3 = y3 + 1 : y4 = y4 + 1 : x3 = x3 + dx1 : x4";
_y3 = _y3+1;
 //BA.debugLineNum = 1732;BA.debugLine="y3 = y3 + 1 : y4 = y4 + 1 : x3 = x3 + dx1 : x4";
_y4 = _y4+1;
 //BA.debugLineNum = 1732;BA.debugLine="y3 = y3 + 1 : y4 = y4 + 1 : x3 = x3 + dx1 : x4";
_x3 = _x3+_dx1;
 //BA.debugLineNum = 1732;BA.debugLine="y3 = y3 + 1 : y4 = y4 + 1 : x3 = x3 + dx1 : x4";
_x4 = _x4+_dx2;
 }
;
 }else {
 //BA.debugLineNum = 1735;BA.debugLine="While";
__c.While();
 //BA.debugLineNum = 1736;BA.debugLine="Do While y3 <= y1";
while (_y3<=_y1) {
 //BA.debugLineNum = 1737;BA.debugLine="If x3 > x4 Then inc = -1 Else inc = 1";
if (_x3>_x4) { 
_inc = (int) (-1);}
else {
_inc = (int) (1);};
 //BA.debugLineNum = 1738;BA.debugLine="For x = x3 To x4 Step inc";
{
final int step64 = _inc;
final int limit64 = (int) (_x4);
_x = (int) (_x3) ;
for (;(step64 > 0 && _x <= limit64) || (step64 < 0 && _x >= limit64) ;_x = ((int)(0 + _x + step64))  ) {
 //BA.debugLineNum = 1739;BA.debugLine="points(x, y3) = 1";
_points[_x][(int) (_y3)] = (byte) (1);
 }
};
 //BA.debugLineNum = 1741;BA.debugLine="y3 = y3 + 1 : y4 = y4 + 1 : x3 = x3 + dx0 : x4";
_y3 = _y3+1;
 //BA.debugLineNum = 1741;BA.debugLine="y3 = y3 + 1 : y4 = y4 + 1 : x3 = x3 + dx0 : x4";
_y4 = _y4+1;
 //BA.debugLineNum = 1741;BA.debugLine="y3 = y3 + 1 : y4 = y4 + 1 : x3 = x3 + dx0 : x4";
_x3 = _x3+_dx0;
 //BA.debugLineNum = 1741;BA.debugLine="y3 = y3 + 1 : y4 = y4 + 1 : x3 = x3 + dx0 : x4";
_x4 = _x4+_dx1;
 }
;
 //BA.debugLineNum = 1743;BA.debugLine="x3=x1";
_x3 = _x1;
 //BA.debugLineNum = 1744;BA.debugLine="y3=y1";
_y3 = _y1;
 //BA.debugLineNum = 1745;BA.debugLine="Do While y3<=y2";
while (_y3<=_y2) {
 //BA.debugLineNum = 1746;BA.debugLine="If x3 > x4 Then inc = -1 Else inc = 1";
if (_x3>_x4) { 
_inc = (int) (-1);}
else {
_inc = (int) (1);};
 //BA.debugLineNum = 1747;BA.debugLine="For x = x3 To x4 Step inc";
{
final int step76 = _inc;
final int limit76 = (int) (_x4);
_x = (int) (_x3) ;
for (;(step76 > 0 && _x <= limit76) || (step76 < 0 && _x >= limit76) ;_x = ((int)(0 + _x + step76))  ) {
 //BA.debugLineNum = 1748;BA.debugLine="points(x, y3) = 1";
_points[_x][(int) (_y3)] = (byte) (1);
 }
};
 //BA.debugLineNum = 1750;BA.debugLine="y3 = y3 + 1 : y4 = y4 + 1 : x3 = x3 + dx2 : x4";
_y3 = _y3+1;
 //BA.debugLineNum = 1750;BA.debugLine="y3 = y3 + 1 : y4 = y4 + 1 : x3 = x3 + dx2 : x4";
_y4 = _y4+1;
 //BA.debugLineNum = 1750;BA.debugLine="y3 = y3 + 1 : y4 = y4 + 1 : x3 = x3 + dx2 : x4";
_x3 = _x3+_dx2;
 //BA.debugLineNum = 1750;BA.debugLine="y3 = y3 + 1 : y4 = y4 + 1 : x3 = x3 + dx2 : x4";
_x4 = _x4+_dx1;
 }
;
 };
 //BA.debugLineNum = 1753;BA.debugLine="End Sub";
return "";
}
public reparto_izca.keymon.lat.escposprinter._animage  _imagetobwimage(anywheresoftware.b4a.objects.drawable.CanvasWrapper.BitmapWrapper _bmp) throws Exception{
b4a.example.bitmapcreator _bc = null;
int _w = 0;
int _h = 0;
byte[] _pixels = null;
int _y = 0;
int _x = 0;
int _j = 0;
b4a.example.bitmapcreator._argbcolor _col = null;
int _lum = 0;
reparto_izca.keymon.lat.escposprinter._animage _ret = null;
 //BA.debugLineNum = 1857;BA.debugLine="Sub ImageToBWIMage(bmp As Bitmap) As AnImage";
 //BA.debugLineNum = 1858;BA.debugLine="Dim BC As BitmapCreator 'ignore";
_bc = new b4a.example.bitmapcreator();
 //BA.debugLineNum = 1859;BA.debugLine="Dim W As Int = bmp.Width";
_w = _bmp.getWidth();
 //BA.debugLineNum = 1860;BA.debugLine="Dim H As Int = bmp.Height";
_h = _bmp.getHeight();
 //BA.debugLineNum = 1861;BA.debugLine="Dim pixels(W * H) As Byte";
_pixels = new byte[(int) (_w*_h)];
;
 //BA.debugLineNum = 1863;BA.debugLine="For y = 0 To H - 1";
{
final int step5 = 1;
final int limit5 = (int) (_h-1);
_y = (int) (0) ;
for (;_y <= limit5 ;_y = _y + step5 ) {
 //BA.debugLineNum = 1864;BA.debugLine="For x = 0 To W - 1";
{
final int step6 = 1;
final int limit6 = (int) (_w-1);
_x = (int) (0) ;
for (;_x <= limit6 ;_x = _x + step6 ) {
 //BA.debugLineNum = 1865;BA.debugLine="Dim j As Int = bmp.GetPixel(x, y)";
_j = _bmp.GetPixel(_x,_y);
 //BA.debugLineNum = 1867;BA.debugLine="Dim col As ARGBColor";
_col = new b4a.example.bitmapcreator._argbcolor();
 //BA.debugLineNum = 1868;BA.debugLine="BC.ColorToARGB(j, col )";
_bc._colortoargb(_j,_col);
 //BA.debugLineNum = 1869;BA.debugLine="Dim lum As Int = col.r * 0.2 + col.b*0.1 + col.";
_lum = (int) (_col.r*0.2+_col.b*0.1+_col.g*0.7);
 //BA.debugLineNum = 1870;BA.debugLine="If lum> 255 Then lum = 255";
if (_lum>255) { 
_lum = (int) (255);};
 //BA.debugLineNum = 1872;BA.debugLine="pixels(y*W + x) = lum";
_pixels[(int) (_y*_w+_x)] = (byte) (_lum);
 }
};
 }
};
 //BA.debugLineNum = 1875;BA.debugLine="Dim ret As AnImage";
_ret = new reparto_izca.keymon.lat.escposprinter._animage();
 //BA.debugLineNum = 1876;BA.debugLine="ret.Width = bmp.Width";
_ret.Width /*int*/  = _bmp.getWidth();
 //BA.debugLineNum = 1877;BA.debugLine="ret.Height = bmp.Height";
_ret.Height /*int*/  = _bmp.getHeight();
 //BA.debugLineNum = 1878;BA.debugLine="ret.Data = pixels";
_ret.Data /*byte[]*/  = _pixels;
 //BA.debugLineNum = 1879;BA.debugLine="Return ret";
if (true) return _ret;
 //BA.debugLineNum = 1880;BA.debugLine="End Sub";
return null;
}
public String  _initialize(anywheresoftware.b4a.BA _ba,Object _vcallback,String _veventname) throws Exception{
innerInitialize(_ba);
 //BA.debugLineNum = 1229;BA.debugLine="Public Sub Initialize(vCallback As Object, vEventN";
 //BA.debugLineNum = 1230;BA.debugLine="EventName = vEventName";
_eventname = _veventname;
 //BA.debugLineNum = 1231;BA.debugLine="CallBack = vCallback";
_callback = _vcallback;
 //BA.debugLineNum = 1232;BA.debugLine="Serial1.Initialize(\"Serial1\")";
_serial1.Initialize("Serial1");
 //BA.debugLineNum = 1233;BA.debugLine="Connected = False";
_connected = __c.False;
 //BA.debugLineNum = 1234;BA.debugLine="ConnectedError = \"\"";
_connectederror = "";
 //BA.debugLineNum = 1235;BA.debugLine="End Sub";
return "";
}
public boolean  _isbluetoothon() throws Exception{
 //BA.debugLineNum = 1248;BA.debugLine="Public Sub IsBluetoothOn As Boolean";
 //BA.debugLineNum = 1249;BA.debugLine="Return Serial1.IsEnabled";
if (true) return _serial1.IsEnabled();
 //BA.debugLineNum = 1250;BA.debugLine="End Sub";
return false;
}
public boolean  _isconnected() throws Exception{
 //BA.debugLineNum = 1243;BA.debugLine="Public Sub IsConnected As Boolean";
 //BA.debugLineNum = 1244;BA.debugLine="Return Connected";
if (true) return _connected;
 //BA.debugLineNum = 1245;BA.debugLine="End Sub";
return false;
}
public reparto_izca.keymon.lat.escposprinter._animage  _packimage(reparto_izca.keymon.lat.escposprinter._animage _imagedata) throws Exception{
int _xbytes = 0;
byte[] _pixels = null;
byte[] _masks = null;
int _index = 0;
int _y = 0;
int _x = 0;
byte _xbyte = (byte)0;
int _b = 0;
byte _pix = (byte)0;
reparto_izca.keymon.lat.escposprinter._animage _ret = null;
 //BA.debugLineNum = 2009;BA.debugLine="Public Sub PackImage(imagedata As AnImage) As AnIm";
 //BA.debugLineNum = 2010;BA.debugLine="Dim xbytes As Int = imagedata.width/8";
_xbytes = (int) (_imagedata.Width /*int*/ /(double)8);
 //BA.debugLineNum = 2011;BA.debugLine="Dim pixels(xbytes * imagedata.height) As Byte";
_pixels = new byte[(int) (_xbytes*_imagedata.Height /*int*/ )];
;
 //BA.debugLineNum = 2012;BA.debugLine="Dim masks(8) As Byte";
_masks = new byte[(int) (8)];
;
 //BA.debugLineNum = 2013;BA.debugLine="masks(0) = 0x80";
_masks[(int) (0)] = (byte) (((int)0x80));
 //BA.debugLineNum = 2014;BA.debugLine="masks(1) = 0x40";
_masks[(int) (1)] = (byte) (((int)0x40));
 //BA.debugLineNum = 2015;BA.debugLine="masks(2) = 0x20";
_masks[(int) (2)] = (byte) (((int)0x20));
 //BA.debugLineNum = 2016;BA.debugLine="masks(3) = 0x10";
_masks[(int) (3)] = (byte) (((int)0x10));
 //BA.debugLineNum = 2017;BA.debugLine="masks(4) = 0x08";
_masks[(int) (4)] = (byte) (((int)0x08));
 //BA.debugLineNum = 2018;BA.debugLine="masks(5) = 0x04";
_masks[(int) (5)] = (byte) (((int)0x04));
 //BA.debugLineNum = 2019;BA.debugLine="masks(6) = 0x02";
_masks[(int) (6)] = (byte) (((int)0x02));
 //BA.debugLineNum = 2020;BA.debugLine="masks(7) = 0x01";
_masks[(int) (7)] = (byte) (((int)0x01));
 //BA.debugLineNum = 2021;BA.debugLine="Dim index As Int = 0";
_index = (int) (0);
 //BA.debugLineNum = 2022;BA.debugLine="For y = 0 To imagedata.Height - 1";
{
final int step13 = 1;
final int limit13 = (int) (_imagedata.Height /*int*/ -1);
_y = (int) (0) ;
for (;_y <= limit13 ;_y = _y + step13 ) {
 //BA.debugLineNum = 2023;BA.debugLine="For x = 0 To xbytes - 1";
{
final int step14 = 1;
final int limit14 = (int) (_xbytes-1);
_x = (int) (0) ;
for (;_x <= limit14 ;_x = _x + step14 ) {
 //BA.debugLineNum = 2024;BA.debugLine="Dim xbyte As Byte = 0";
_xbyte = (byte) (0);
 //BA.debugLineNum = 2025;BA.debugLine="For b = 0 To 7";
{
final int step16 = 1;
final int limit16 = (int) (7);
_b = (int) (0) ;
for (;_b <= limit16 ;_b = _b + step16 ) {
 //BA.debugLineNum = 2027;BA.debugLine="Dim pix As Byte = imagedata.Data(index)";
_pix = _imagedata.Data /*byte[]*/ [_index];
 //BA.debugLineNum = 2028;BA.debugLine="If pix <> 0 Then";
if (_pix!=0) { 
 //BA.debugLineNum = 2029;BA.debugLine="xbyte = xbyte + masks(b)";
_xbyte = (byte) (_xbyte+_masks[_b]);
 };
 //BA.debugLineNum = 2031;BA.debugLine="index = index + 1";
_index = (int) (_index+1);
 }
};
 //BA.debugLineNum = 2033;BA.debugLine="pixels(y*xbytes + x) = xbyte";
_pixels[(int) (_y*_xbytes+_x)] = _xbyte;
 }
};
 }
};
 //BA.debugLineNum = 2036;BA.debugLine="Dim ret As AnImage";
_ret = new reparto_izca.keymon.lat.escposprinter._animage();
 //BA.debugLineNum = 2037;BA.debugLine="ret.Width = xbytes";
_ret.Width /*int*/  = _xbytes;
 //BA.debugLineNum = 2038;BA.debugLine="ret.Height = imagedata.Height";
_ret.Height /*int*/  = _imagedata.Height /*int*/ ;
 //BA.debugLineNum = 2039;BA.debugLine="ret.Data = pixels";
_ret.Data /*byte[]*/  = _pixels;
 //BA.debugLineNum = 2040;BA.debugLine="Return ret";
if (true) return _ret;
 //BA.debugLineNum = 2041;BA.debugLine="End Sub";
return null;
}
public byte[]  _packimageslice(reparto_izca.keymon.lat.escposprinter._animage _img,int _slice,boolean _dots24) throws Exception{
int _bytes = 0;
byte[] _pixels = null;
int _slicestart = 0;
byte[] _masks = null;
int _x = 0;
int _s = 0;
byte _xbyte = (byte)0;
int _b = 0;
byte _pix = (byte)0;
 //BA.debugLineNum = 2107;BA.debugLine="Public Sub PackImageSlice(img As AnImage, slice As";
 //BA.debugLineNum = 2108;BA.debugLine="Dim bytes As Int = img.width";
_bytes = _img.Width /*int*/ ;
 //BA.debugLineNum = 2109;BA.debugLine="If dots24 Then";
if (_dots24) { 
 //BA.debugLineNum = 2110;BA.debugLine="Dim pixels(bytes * 3) As Byte";
_pixels = new byte[(int) (_bytes*3)];
;
 //BA.debugLineNum = 2111;BA.debugLine="Dim slicestart As Int = slice * bytes * 8 * 3";
_slicestart = (int) (_slice*_bytes*8*3);
 }else {
 //BA.debugLineNum = 2113;BA.debugLine="Dim pixels(bytes) As Byte";
_pixels = new byte[_bytes];
;
 //BA.debugLineNum = 2114;BA.debugLine="Dim slicestart As Int = slice * bytes * 8";
_slicestart = (int) (_slice*_bytes*8);
 };
 //BA.debugLineNum = 2117;BA.debugLine="Dim masks(8) As Byte";
_masks = new byte[(int) (8)];
;
 //BA.debugLineNum = 2118;BA.debugLine="masks(0) = 0x80";
_masks[(int) (0)] = (byte) (((int)0x80));
 //BA.debugLineNum = 2119;BA.debugLine="masks(1) = 0x40";
_masks[(int) (1)] = (byte) (((int)0x40));
 //BA.debugLineNum = 2120;BA.debugLine="masks(2) = 0x20";
_masks[(int) (2)] = (byte) (((int)0x20));
 //BA.debugLineNum = 2121;BA.debugLine="masks(3) = 0x10";
_masks[(int) (3)] = (byte) (((int)0x10));
 //BA.debugLineNum = 2122;BA.debugLine="masks(4) = 0x08";
_masks[(int) (4)] = (byte) (((int)0x08));
 //BA.debugLineNum = 2123;BA.debugLine="masks(5) = 0x04";
_masks[(int) (5)] = (byte) (((int)0x04));
 //BA.debugLineNum = 2124;BA.debugLine="masks(6) = 0x02";
_masks[(int) (6)] = (byte) (((int)0x02));
 //BA.debugLineNum = 2125;BA.debugLine="masks(7) = 0x01";
_masks[(int) (7)] = (byte) (((int)0x01));
 //BA.debugLineNum = 2127;BA.debugLine="If dots24 Then";
if (_dots24) { 
 //BA.debugLineNum = 2128;BA.debugLine="For x = 0 To bytes - 1";
{
final int step19 = 1;
final int limit19 = (int) (_bytes-1);
_x = (int) (0) ;
for (;_x <= limit19 ;_x = _x + step19 ) {
 //BA.debugLineNum = 2129;BA.debugLine="For s = 0 To 2";
{
final int step20 = 1;
final int limit20 = (int) (2);
_s = (int) (0) ;
for (;_s <= limit20 ;_s = _s + step20 ) {
 //BA.debugLineNum = 2130;BA.debugLine="Dim xbyte As Byte = 0";
_xbyte = (byte) (0);
 //BA.debugLineNum = 2131;BA.debugLine="For b = 0 To 7";
{
final int step22 = 1;
final int limit22 = (int) (7);
_b = (int) (0) ;
for (;_b <= limit22 ;_b = _b + step22 ) {
 //BA.debugLineNum = 2133;BA.debugLine="Dim pix As Byte = img.Data(slicestart + ((b +";
_pix = _img.Data /*byte[]*/ [(int) (_slicestart+((_b+_s*8)*_bytes)+_x)];
 //BA.debugLineNum = 2134;BA.debugLine="If pix <> 0 Then";
if (_pix!=0) { 
 //BA.debugLineNum = 2135;BA.debugLine="xbyte = xbyte + masks(b)";
_xbyte = (byte) (_xbyte+_masks[_b]);
 };
 }
};
 //BA.debugLineNum = 2138;BA.debugLine="pixels(x*3+s) = xbyte";
_pixels[(int) (_x*3+_s)] = _xbyte;
 }
};
 }
};
 }else {
 //BA.debugLineNum = 2142;BA.debugLine="For x = 0 To bytes - 1";
{
final int step32 = 1;
final int limit32 = (int) (_bytes-1);
_x = (int) (0) ;
for (;_x <= limit32 ;_x = _x + step32 ) {
 //BA.debugLineNum = 2143;BA.debugLine="Dim xbyte As Byte = 0";
_xbyte = (byte) (0);
 //BA.debugLineNum = 2144;BA.debugLine="For b = 0 To 7";
{
final int step34 = 1;
final int limit34 = (int) (7);
_b = (int) (0) ;
for (;_b <= limit34 ;_b = _b + step34 ) {
 //BA.debugLineNum = 2146;BA.debugLine="Dim pix As Byte = img.Data(slicestart + (b * b";
_pix = _img.Data /*byte[]*/ [(int) (_slicestart+(_b*_bytes)+_x)];
 //BA.debugLineNum = 2147;BA.debugLine="If pix <> 0 Then";
if (_pix!=0) { 
 //BA.debugLineNum = 2148;BA.debugLine="xbyte = xbyte + masks(b)";
_xbyte = (byte) (_xbyte+_masks[_b]);
 };
 }
};
 //BA.debugLineNum = 2151;BA.debugLine="pixels(x) = xbyte";
_pixels[_x] = _xbyte;
 }
};
 };
 //BA.debugLineNum = 2154;BA.debugLine="Return pixels";
if (true) return _pixels;
 //BA.debugLineNum = 2155;BA.debugLine="End Sub";
return null;
}
public String  _plotbox(int _x0,int _y0,int _x1,int _y1,byte[][] _points,int _fill) throws Exception{
int _x = 0;
 //BA.debugLineNum = 1755;BA.debugLine="Private Sub PlotBox(x0 As Int, y0 As Int, x1 As In";
 //BA.debugLineNum = 1757;BA.debugLine="PlotLine(x0, y0, x0, y1, points)";
_plotline(_x0,_y0,_x0,_y1,_points);
 //BA.debugLineNum = 1758;BA.debugLine="PlotLine(x0, y0, x1, y0, points)";
_plotline(_x0,_y0,_x1,_y0,_points);
 //BA.debugLineNum = 1759;BA.debugLine="PlotLine(x1, y0, x1, y1, points)";
_plotline(_x1,_y0,_x1,_y1,_points);
 //BA.debugLineNum = 1760;BA.debugLine="PlotLine(x0, y1, x1, y1, points)";
_plotline(_x0,_y1,_x1,_y1,_points);
 //BA.debugLineNum = 1761;BA.debugLine="If Fill > 0 Then";
if (_fill>0) { 
 //BA.debugLineNum = 1762;BA.debugLine="For x = x0 To x1";
{
final int step6 = 1;
final int limit6 = _x1;
_x = _x0 ;
for (;_x <= limit6 ;_x = _x + step6 ) {
 //BA.debugLineNum = 1763;BA.debugLine="PlotLine(x, y0, x, y1, points)";
_plotline(_x,_y0,_x,_y1,_points);
 }
};
 };
 //BA.debugLineNum = 1766;BA.debugLine="End Sub";
return "";
}
public String  _plotcircle(int _radius,int _quadrants,int _x1,int _y1,byte[][] _points,int _fill) throws Exception{
int _mask = 0;
int _q = 0;
int _i = 0;
double _x = 0;
double _y = 0;
 //BA.debugLineNum = 1769;BA.debugLine="Private Sub PlotCircle(radius As Int, quadrants As";
 //BA.debugLineNum = 1771;BA.debugLine="Dim mask As Int = 1";
_mask = (int) (1);
 //BA.debugLineNum = 1772;BA.debugLine="For q = 3 To 0 Step -1";
{
final int step2 = -1;
final int limit2 = (int) (0);
_q = (int) (3) ;
for (;_q >= limit2 ;_q = _q + step2 ) {
 //BA.debugLineNum = 1773;BA.debugLine="If Bit.And(quadrants, mask) <> 0 Then";
if (__c.Bit.And(_quadrants,_mask)!=0) { 
 //BA.debugLineNum = 1774;BA.debugLine="For i = q*90 To q*90+90 Step 1";
{
final int step4 = 1;
final int limit4 = (int) (_q*90+90);
_i = (int) (_q*90) ;
for (;_i <= limit4 ;_i = _i + step4 ) {
 //BA.debugLineNum = 1775;BA.debugLine="Dim x,y As Double";
_x = 0;
_y = 0;
 //BA.debugLineNum = 1776;BA.debugLine="x = x1 - SinD(i)*radius";
_x = _x1-__c.SinD(_i)*_radius;
 //BA.debugLineNum = 1777;BA.debugLine="y = y1 - CosD(i)*radius";
_y = _y1-__c.CosD(_i)*_radius;
 //BA.debugLineNum = 1778;BA.debugLine="If fill > 0 Then";
if (_fill>0) { 
 //BA.debugLineNum = 1779;BA.debugLine="PlotLine(x1, y1, x, y, points)";
_plotline(_x1,_y1,(int) (_x),(int) (_y),_points);
 }else {
 //BA.debugLineNum = 1781;BA.debugLine="points(Round(x), Round(y)) = 1";
_points[(int) (__c.Round(_x))][(int) (__c.Round(_y))] = (byte) (1);
 };
 }
};
 };
 //BA.debugLineNum = 1785;BA.debugLine="mask = Bit.ShiftLeft(mask, 1)";
_mask = __c.Bit.ShiftLeft(_mask,(int) (1));
 }
};
 //BA.debugLineNum = 1787;BA.debugLine="End Sub";
return "";
}
public String  _plotline(int _x0,int _y0,int _x1,int _y1,byte[][] _points) throws Exception{
 //BA.debugLineNum = 1790;BA.debugLine="Private Sub PlotLine(x0 As Int, y0 As Int, x1 As I";
 //BA.debugLineNum = 1791;BA.debugLine="If Abs(y1 - y0) < Abs(x1 - x0) Then";
if (__c.Abs(_y1-_y0)<__c.Abs(_x1-_x0)) { 
 //BA.debugLineNum = 1792;BA.debugLine="If x0 > x1 Then";
if (_x0>_x1) { 
 //BA.debugLineNum = 1793;BA.debugLine="PlotLineLow(x1, y1, x0, y0, points)";
_plotlinelow(_x1,_y1,_x0,_y0,_points);
 }else {
 //BA.debugLineNum = 1795;BA.debugLine="PlotLineLow(x0, y0, x1, y1, points)";
_plotlinelow(_x0,_y0,_x1,_y1,_points);
 };
 }else {
 //BA.debugLineNum = 1798;BA.debugLine="If y0 > y1 Then";
if (_y0>_y1) { 
 //BA.debugLineNum = 1799;BA.debugLine="PlotLineHigh(x1, y1, x0, y0, points)";
_plotlinehigh(_x1,_y1,_x0,_y0,_points);
 }else {
 //BA.debugLineNum = 1801;BA.debugLine="PlotLineHigh(x0, y0, x1, y1, points)";
_plotlinehigh(_x0,_y0,_x1,_y1,_points);
 };
 };
 //BA.debugLineNum = 1804;BA.debugLine="End Sub";
return "";
}
public String  _plotlinehigh(int _x0,int _y0,int _x1,int _y1,byte[][] _points) throws Exception{
int _dx = 0;
int _dy = 0;
int _xi = 0;
int _d = 0;
int _x = 0;
int _y = 0;
 //BA.debugLineNum = 1806;BA.debugLine="Private Sub PlotLineHigh(x0 As Int, y0 As Int, x1";
 //BA.debugLineNum = 1807;BA.debugLine="Dim dx As Int = x1 - x0";
_dx = (int) (_x1-_x0);
 //BA.debugLineNum = 1808;BA.debugLine="Dim dy  As Int = y1 - y0";
_dy = (int) (_y1-_y0);
 //BA.debugLineNum = 1809;BA.debugLine="Dim xi As Int = 1";
_xi = (int) (1);
 //BA.debugLineNum = 1810;BA.debugLine="If dx < 0 Then";
if (_dx<0) { 
 //BA.debugLineNum = 1811;BA.debugLine="xi = -1";
_xi = (int) (-1);
 //BA.debugLineNum = 1812;BA.debugLine="dx = -dx";
_dx = (int) (-_dx);
 };
 //BA.debugLineNum = 1814;BA.debugLine="Dim D As Int = 2*dx - dy";
_d = (int) (2*_dx-_dy);
 //BA.debugLineNum = 1815;BA.debugLine="Dim x As Int = x0";
_x = _x0;
 //BA.debugLineNum = 1816;BA.debugLine="For y = y0 To y1";
{
final int step10 = 1;
final int limit10 = _y1;
_y = _y0 ;
for (;_y <= limit10 ;_y = _y + step10 ) {
 //BA.debugLineNum = 1817;BA.debugLine="points(x,y) = 1";
_points[_x][_y] = (byte) (1);
 //BA.debugLineNum = 1818;BA.debugLine="If D > 0 Then";
if (_d>0) { 
 //BA.debugLineNum = 1819;BA.debugLine="x = x + xi";
_x = (int) (_x+_xi);
 //BA.debugLineNum = 1820;BA.debugLine="D = D - 2*dy";
_d = (int) (_d-2*_dy);
 };
 //BA.debugLineNum = 1822;BA.debugLine="D = D + 2*dx";
_d = (int) (_d+2*_dx);
 }
};
 //BA.debugLineNum = 1824;BA.debugLine="End Sub";
return "";
}
public String  _plotlinelow(int _x0,int _y0,int _x1,int _y1,byte[][] _points) throws Exception{
int _dx = 0;
int _dy = 0;
int _yi = 0;
int _d = 0;
int _y = 0;
int _x = 0;
 //BA.debugLineNum = 1826;BA.debugLine="Private Sub	PlotLineLow(x0 As Int, y0 As Int, x1 A";
 //BA.debugLineNum = 1827;BA.debugLine="Dim dx As Int = x1 - x0";
_dx = (int) (_x1-_x0);
 //BA.debugLineNum = 1828;BA.debugLine="Dim dy As Int = y1 - y0";
_dy = (int) (_y1-_y0);
 //BA.debugLineNum = 1829;BA.debugLine="Dim yi As Int = 1";
_yi = (int) (1);
 //BA.debugLineNum = 1830;BA.debugLine="If dy < 0 Then";
if (_dy<0) { 
 //BA.debugLineNum = 1831;BA.debugLine="yi = -1";
_yi = (int) (-1);
 //BA.debugLineNum = 1832;BA.debugLine="dy = -dy";
_dy = (int) (-_dy);
 };
 //BA.debugLineNum = 1834;BA.debugLine="Dim D As Int = 2*dy - dx";
_d = (int) (2*_dy-_dx);
 //BA.debugLineNum = 1835;BA.debugLine="Dim y As Int = y0";
_y = _y0;
 //BA.debugLineNum = 1836;BA.debugLine="For x = x0 To x1";
{
final int step10 = 1;
final int limit10 = _x1;
_x = _x0 ;
for (;_x <= limit10 ;_x = _x + step10 ) {
 //BA.debugLineNum = 1837;BA.debugLine="points(x,y) = 1";
_points[_x][_y] = (byte) (1);
 //BA.debugLineNum = 1838;BA.debugLine="If D > 0 Then";
if (_d>0) { 
 //BA.debugLineNum = 1839;BA.debugLine="y = y + yi";
_y = (int) (_y+_yi);
 //BA.debugLineNum = 1840;BA.debugLine="D = D - 2*dx";
_d = (int) (_d-2*_dx);
 };
 //BA.debugLineNum = 1842;BA.debugLine="D = D + 2*dy";
_d = (int) (_d+2*_dy);
 }
};
 //BA.debugLineNum = 1844;BA.debugLine="End Sub";
return "";
}
public String  _plottriangle(int _x0,int _y0,int _x1,int _y1,int _x2,int _y2,byte[][] _points,int _fill) throws Exception{
 //BA.debugLineNum = 1678;BA.debugLine="Private Sub PlotTriangle(x0 As Int, y0 As Int, x1";
 //BA.debugLineNum = 1680;BA.debugLine="PlotLine(x0, y0, x1, y1, points)";
_plotline(_x0,_y0,_x1,_y1,_points);
 //BA.debugLineNum = 1681;BA.debugLine="PlotLine(x1, y1, x2, y2, points)";
_plotline(_x1,_y1,_x2,_y2,_points);
 //BA.debugLineNum = 1682;BA.debugLine="PlotLine(x2, y2, x0, y0, points)";
_plotline(_x2,_y2,_x0,_y0,_points);
 //BA.debugLineNum = 1683;BA.debugLine="If Fill > 0 Then";
if (_fill>0) { 
 //BA.debugLineNum = 1684;BA.debugLine="FillTriangle(x0, y0, x1, y1, x2, y2, points)";
_filltriangle(_x0,_y0,_x1,_y1,_x2,_y2,_points);
 };
 //BA.debugLineNum = 1686;BA.debugLine="End Sub";
return "";
}
public String  _printandfeedpaper(int _units) throws Exception{
byte[] _params = null;
 //BA.debugLineNum = 1304;BA.debugLine="Public Sub PrintAndFeedPaper(units As Int)";
 //BA.debugLineNum = 1305;BA.debugLine="WriteString(ESC & \"J\")";
_writestring(_esc+"J");
 //BA.debugLineNum = 1306;BA.debugLine="Dim params(1) As Byte";
_params = new byte[(int) (1)];
;
 //BA.debugLineNum = 1307;BA.debugLine="params(0) = units";
_params[(int) (0)] = (byte) (_units);
 //BA.debugLineNum = 1308;BA.debugLine="WriteBytes(params)";
_writebytes(_params);
 //BA.debugLineNum = 1309;BA.debugLine="End Sub";
return "";
}
public int  _printimage(reparto_izca.keymon.lat.escposprinter._animage _img) throws Exception{
int _xh = 0;
int _xl = 0;
int _yh = 0;
int _yl = 0;
byte[] _params = null;
 //BA.debugLineNum = 1981;BA.debugLine="Public Sub PrintImage(img As AnImage) As Int";
 //BA.debugLineNum = 1984;BA.debugLine="If img.width > 72 Then Return -1";
if (_img.Width /*int*/ >72) { 
if (true) return (int) (-1);};
 //BA.debugLineNum = 1985;BA.debugLine="If img.height > 512 Then Return -2";
if (_img.Height /*int*/ >512) { 
if (true) return (int) (-2);};
 //BA.debugLineNum = 1986;BA.debugLine="If img.data.Length < img.width * img.height Then";
if (_img.Data /*byte[]*/ .length<_img.Width /*int*/ *_img.Height /*int*/ ) { 
if (true) return (int) (-3);};
 //BA.debugLineNum = 1987;BA.debugLine="Dim xh As Int = img.width / 256";
_xh = (int) (_img.Width /*int*/ /(double)256);
 //BA.debugLineNum = 1988;BA.debugLine="Dim xl As Int = img.width - xh * 256";
_xl = (int) (_img.Width /*int*/ -_xh*256);
 //BA.debugLineNum = 1989;BA.debugLine="Dim yh As Int = img.height / 256";
_yh = (int) (_img.Height /*int*/ /(double)256);
 //BA.debugLineNum = 1990;BA.debugLine="Dim yl As Int = img.height - yh * 256";
_yl = (int) (_img.Height /*int*/ -_yh*256);
 //BA.debugLineNum = 1991;BA.debugLine="Dim params(5) As Byte";
_params = new byte[(int) (5)];
;
 //BA.debugLineNum = 1992;BA.debugLine="params(0) = 0 '";
_params[(int) (0)] = (byte) (0);
 //BA.debugLineNum = 1993;BA.debugLine="params(1) = xl";
_params[(int) (1)] = (byte) (_xl);
 //BA.debugLineNum = 1994;BA.debugLine="params(2) = xh";
_params[(int) (2)] = (byte) (_xh);
 //BA.debugLineNum = 1995;BA.debugLine="params(3) = yl";
_params[(int) (3)] = (byte) (_yl);
 //BA.debugLineNum = 1996;BA.debugLine="params(4) = yh";
_params[(int) (4)] = (byte) (_yh);
 //BA.debugLineNum = 1997;BA.debugLine="WriteString(GS & \"v0\")";
_writestring(_gs+"v0");
 //BA.debugLineNum = 1998;BA.debugLine="WriteBytes(params)";
_writebytes(_params);
 //BA.debugLineNum = 1999;BA.debugLine="WriteBytes(img.data)";
_writebytes(_img.Data /*byte[]*/ );
 //BA.debugLineNum = 2000;BA.debugLine="WriteString(CRLF)";
_writestring(__c.CRLF);
 //BA.debugLineNum = 2001;BA.debugLine="Return 0";
if (true) return (int) (0);
 //BA.debugLineNum = 2002;BA.debugLine="End Sub";
return 0;
}
public int  _printimage2(int _width,byte[] _data,boolean _highdensity,boolean _dotds24) throws Exception{
String _d = "";
int _xh = 0;
int _xl = 0;
byte[] _params = null;
 //BA.debugLineNum = 2071;BA.debugLine="Public Sub PrintImage2(width As Int, data() As Byt";
 //BA.debugLineNum = 2072;BA.debugLine="Dim d As String = Chr(0)";
_d = BA.ObjectToString(__c.Chr((int) (0)));
 //BA.debugLineNum = 2073;BA.debugLine="If Not(highdensity) And Not(dotds24 )	 Then";
if (__c.Not(_highdensity) && __c.Not(_dotds24)) { 
 //BA.debugLineNum = 2074;BA.debugLine="d = Chr(0)";
_d = BA.ObjectToString(__c.Chr((int) (0)));
 //BA.debugLineNum = 2075;BA.debugLine="If width > 288 Then Return -1";
if (_width>288) { 
if (true) return (int) (-1);};
 //BA.debugLineNum = 2076;BA.debugLine="If data.Length <> width Then Return -3";
if (_data.length!=_width) { 
if (true) return (int) (-3);};
 }else if(_highdensity && __c.Not(_dotds24)) { 
 //BA.debugLineNum = 2078;BA.debugLine="d = Chr(1)";
_d = BA.ObjectToString(__c.Chr((int) (1)));
 //BA.debugLineNum = 2079;BA.debugLine="If width > 576 Then Return -1";
if (_width>576) { 
if (true) return (int) (-1);};
 //BA.debugLineNum = 2080;BA.debugLine="If data.Length <> width Then Return -3";
if (_data.length!=_width) { 
if (true) return (int) (-3);};
 }else if(__c.Not(_highdensity) && _dotds24) { 
 //BA.debugLineNum = 2082;BA.debugLine="d = Chr(32)";
_d = BA.ObjectToString(__c.Chr((int) (32)));
 //BA.debugLineNum = 2083;BA.debugLine="If width > 288 Then Return -1";
if (_width>288) { 
if (true) return (int) (-1);};
 //BA.debugLineNum = 2084;BA.debugLine="If data.Length <> width*3 Then Return -3";
if (_data.length!=_width*3) { 
if (true) return (int) (-3);};
 }else {
 //BA.debugLineNum = 2086;BA.debugLine="d = Chr(33)";
_d = BA.ObjectToString(__c.Chr((int) (33)));
 //BA.debugLineNum = 2087;BA.debugLine="If width > 576 Then Return -1";
if (_width>576) { 
if (true) return (int) (-1);};
 //BA.debugLineNum = 2088;BA.debugLine="If data.Length <> width*3 Then Return -3";
if (_data.length!=_width*3) { 
if (true) return (int) (-3);};
 };
 //BA.debugLineNum = 2090;BA.debugLine="Dim xh As Int = width / 256";
_xh = (int) (_width/(double)256);
 //BA.debugLineNum = 2091;BA.debugLine="Dim xl As Int = width - xh * 256";
_xl = (int) (_width-_xh*256);
 //BA.debugLineNum = 2092;BA.debugLine="Dim params(2) As Byte";
_params = new byte[(int) (2)];
;
 //BA.debugLineNum = 2093;BA.debugLine="params(0) = xl";
_params[(int) (0)] = (byte) (_xl);
 //BA.debugLineNum = 2094;BA.debugLine="params(1) = xh";
_params[(int) (1)] = (byte) (_xh);
 //BA.debugLineNum = 2095;BA.debugLine="WriteString(ESC & \"*\" & d)";
_writestring(_esc+"*"+_d);
 //BA.debugLineNum = 2096;BA.debugLine="WriteBytes(params)";
_writebytes(_params);
 //BA.debugLineNum = 2097;BA.debugLine="WriteBytes(data)";
_writebytes(_data);
 //BA.debugLineNum = 2098;BA.debugLine="WriteString(CRLF)";
_writestring(__c.CRLF);
 //BA.debugLineNum = 2099;BA.debugLine="Return 0";
if (true) return (int) (0);
 //BA.debugLineNum = 2100;BA.debugLine="End Sub";
return 0;
}
public String  _reset() throws Exception{
 //BA.debugLineNum = 1293;BA.debugLine="Public Sub Reset";
 //BA.debugLineNum = 1294;BA.debugLine="WriteString(ESC & \"@\")";
_writestring(_esc+"@");
 //BA.debugLineNum = 1295;BA.debugLine="End Sub";
return "";
}
public String  _serial1_connected(boolean _success) throws Exception{
 //BA.debugLineNum = 2259;BA.debugLine="Private Sub Serial1_Connected (Success As Boolean)";
 //BA.debugLineNum = 2260;BA.debugLine="If Success Then";
if (_success) { 
 //BA.debugLineNum = 2261;BA.debugLine="Astream.Initialize(Serial1.InputStream, Serial1.";
_astream.Initialize(ba,_serial1.getInputStream(),_serial1.getOutputStream(),"astream");
 //BA.debugLineNum = 2262;BA.debugLine="Connected = True";
_connected = __c.True;
 //BA.debugLineNum = 2263;BA.debugLine="ConnectedError = \"\"";
_connectederror = "";
 //BA.debugLineNum = 2264;BA.debugLine="Serial1.Listen";
_serial1.Listen(ba);
 }else {
 //BA.debugLineNum = 2266;BA.debugLine="Connected = False";
_connected = __c.False;
 //BA.debugLineNum = 2267;BA.debugLine="ConnectedError = LastException.Message";
_connectederror = __c.LastException(getActivityBA()).getMessage();
 };
 //BA.debugLineNum = 2269;BA.debugLine="If SubExists(CallBack, EventName & \"_Connected\")";
if (__c.SubExists(ba,_callback,_eventname+"_Connected")) { 
 //BA.debugLineNum = 2270;BA.debugLine="CallSub2(CallBack, EventName & \"_Connected\", Suc";
__c.CallSubNew2(ba,_callback,_eventname+"_Connected",(Object)(_success));
 };
 //BA.debugLineNum = 2272;BA.debugLine="End Sub";
return "";
}
public String  _setbarcodeheight(int _height) throws Exception{
byte[] _params = null;
 //BA.debugLineNum = 2163;BA.debugLine="Public Sub setBarCodeHeight(height As Int)";
 //BA.debugLineNum = 2164;BA.debugLine="WriteString(GS & \"h\")";
_writestring(_gs+"h");
 //BA.debugLineNum = 2165;BA.debugLine="Dim params(1) As Byte";
_params = new byte[(int) (1)];
;
 //BA.debugLineNum = 2166;BA.debugLine="params(0) = height";
_params[(int) (0)] = (byte) (_height);
 //BA.debugLineNum = 2167;BA.debugLine="WriteBytes(params)";
_writebytes(_params);
 //BA.debugLineNum = 2168;BA.debugLine="End Sub";
return "";
}
public String  _setbarcodeleft(int _left) throws Exception{
byte[] _params = null;
 //BA.debugLineNum = 2172;BA.debugLine="Public Sub setBarCodeLeft(left As Int)";
 //BA.debugLineNum = 2173;BA.debugLine="WriteString(GS & \"x\")";
_writestring(_gs+"x");
 //BA.debugLineNum = 2174;BA.debugLine="Dim params(1) As Byte";
_params = new byte[(int) (1)];
;
 //BA.debugLineNum = 2175;BA.debugLine="params(0) = left";
_params[(int) (0)] = (byte) (_left);
 //BA.debugLineNum = 2176;BA.debugLine="WriteBytes(params)";
_writebytes(_params);
 //BA.debugLineNum = 2177;BA.debugLine="End Sub";
return "";
}
public String  _setbarcodewidth(int _width) throws Exception{
byte[] _params = null;
 //BA.debugLineNum = 2182;BA.debugLine="Public Sub setBarCodeWidth(width As Int)";
 //BA.debugLineNum = 2183;BA.debugLine="WriteString(GS & \"w\")";
_writestring(_gs+"w");
 //BA.debugLineNum = 2184;BA.debugLine="Dim params(1) As Byte";
_params = new byte[(int) (1)];
;
 //BA.debugLineNum = 2185;BA.debugLine="params(0) = width";
_params[(int) (0)] = (byte) (_width);
 //BA.debugLineNum = 2186;BA.debugLine="WriteBytes(params)";
_writebytes(_params);
 //BA.debugLineNum = 2187;BA.debugLine="End Sub";
return "";
}
public String  _setcharacterfont(int _font) throws Exception{
 //BA.debugLineNum = 1391;BA.debugLine="Public Sub setCharacterFont(font As Int)";
 //BA.debugLineNum = 1392;BA.debugLine="WriteString(ESC & \"M\" & Chr(Bit.And(1,font)))";
_writestring(_esc+"M"+BA.ObjectToString(__c.Chr(__c.Bit.And((int) (1),_font))));
 //BA.debugLineNum = 1393;BA.debugLine="End Sub";
return "";
}
public String  _setcharacterspacing(int _spacing) throws Exception{
byte[] _params = null;
 //BA.debugLineNum = 1312;BA.debugLine="Public Sub setCharacterSpacing(spacing As Int)";
 //BA.debugLineNum = 1313;BA.debugLine="WriteString(ESC & \" \")";
_writestring(_esc+" ");
 //BA.debugLineNum = 1314;BA.debugLine="Dim params(1) As Byte";
_params = new byte[(int) (1)];
;
 //BA.debugLineNum = 1315;BA.debugLine="params(0) = spacing";
_params[(int) (0)] = (byte) (_spacing);
 //BA.debugLineNum = 1316;BA.debugLine="WriteBytes(params)";
_writebytes(_params);
 //BA.debugLineNum = 1317;BA.debugLine="End Sub";
return "";
}
public String  _setcodepage(int _codepage) throws Exception{
byte[] _params = null;
 //BA.debugLineNum = 1380;BA.debugLine="Public Sub setCodePage(codepage As Int)";
 //BA.debugLineNum = 1381;BA.debugLine="WriteString(ESC & \"t\")";
_writestring(_esc+"t");
 //BA.debugLineNum = 1382;BA.debugLine="Dim params(1) As Byte";
_params = new byte[(int) (1)];
;
 //BA.debugLineNum = 1383;BA.debugLine="params(0) = codepage";
_params[(int) (0)] = (byte) (_codepage);
 //BA.debugLineNum = 1384;BA.debugLine="WriteBytes(params)";
_writebytes(_params);
 //BA.debugLineNum = 1385;BA.debugLine="End Sub";
return "";
}
public String  _sethrifont(int _font) throws Exception{
 //BA.debugLineNum = 2204;BA.debugLine="Public Sub setHriFont(font As Int)";
 //BA.debugLineNum = 2205;BA.debugLine="WriteString(GS & \"f\" & Chr(font))";
_writestring(_gs+"f"+BA.ObjectToString(__c.Chr(_font)));
 //BA.debugLineNum = 2206;BA.debugLine="End Sub";
return "";
}
public String  _sethriposn(int _posn) throws Exception{
byte[] _params = null;
 //BA.debugLineNum = 2193;BA.debugLine="Public Sub setHriPosn(posn As Int)";
 //BA.debugLineNum = 2194;BA.debugLine="WriteString(GS & \"H\")";
_writestring(_gs+"H");
 //BA.debugLineNum = 2195;BA.debugLine="Dim params(1) As Byte";
_params = new byte[(int) (1)];
;
 //BA.debugLineNum = 2196;BA.debugLine="params(0) = posn";
_params[(int) (0)] = (byte) (_posn);
 //BA.debugLineNum = 2197;BA.debugLine="WriteBytes(params)";
_writebytes(_params);
 //BA.debugLineNum = 2198;BA.debugLine="End Sub";
return "";
}
public String  _setjustify(int _justify) throws Exception{
 //BA.debugLineNum = 1374;BA.debugLine="Public Sub setJustify(justify As Int)";
 //BA.debugLineNum = 1375;BA.debugLine="WriteString(ESC & \"a\" & Chr(justify + 48))";
_writestring(_esc+"a"+BA.ObjectToString(__c.Chr((int) (_justify+48))));
 //BA.debugLineNum = 1376;BA.debugLine="End Sub";
return "";
}
public String  _setleftinset(int _inset) throws Exception{
int _dh = 0;
int _dl = 0;
byte[] _params = null;
 //BA.debugLineNum = 1322;BA.debugLine="Public Sub setLeftInset(inset As Int)";
 //BA.debugLineNum = 1323;BA.debugLine="Dim dh As Int = inset / 256";
_dh = (int) (_inset/(double)256);
 //BA.debugLineNum = 1324;BA.debugLine="Dim dl As Int = inset - dh";
_dl = (int) (_inset-_dh);
 //BA.debugLineNum = 1325;BA.debugLine="WriteString(ESC & \"$\" & Chr(dl) & Chr(dh))";
_writestring(_esc+"$"+BA.ObjectToString(__c.Chr(_dl))+BA.ObjectToString(__c.Chr(_dh)));
 //BA.debugLineNum = 1326;BA.debugLine="Dim params(2) As Byte";
_params = new byte[(int) (2)];
;
 //BA.debugLineNum = 1327;BA.debugLine="params(0) = dl";
_params[(int) (0)] = (byte) (_dl);
 //BA.debugLineNum = 1328;BA.debugLine="params(1) = dh";
_params[(int) (1)] = (byte) (_dh);
 //BA.debugLineNum = 1329;BA.debugLine="WriteBytes(params)";
_writebytes(_params);
 //BA.debugLineNum = 1330;BA.debugLine="End Sub";
return "";
}
public String  _setleftmargin(int _margin) throws Exception{
int _dh = 0;
int _dl = 0;
byte[] _params = null;
 //BA.debugLineNum = 1335;BA.debugLine="Public Sub setLeftMargin(margin As Int)";
 //BA.debugLineNum = 1336;BA.debugLine="Dim dh As Int = margin / 256";
_dh = (int) (_margin/(double)256);
 //BA.debugLineNum = 1337;BA.debugLine="Dim dl As Int = margin - dh";
_dl = (int) (_margin-_dh);
 //BA.debugLineNum = 1338;BA.debugLine="WriteString(GS & \"L\")";
_writestring(_gs+"L");
 //BA.debugLineNum = 1339;BA.debugLine="Dim params(2) As Byte";
_params = new byte[(int) (2)];
;
 //BA.debugLineNum = 1340;BA.debugLine="params(0) = dl";
_params[(int) (0)] = (byte) (_dl);
 //BA.debugLineNum = 1341;BA.debugLine="params(1) = dh";
_params[(int) (1)] = (byte) (_dh);
 //BA.debugLineNum = 1342;BA.debugLine="WriteBytes(params)";
_writebytes(_params);
 //BA.debugLineNum = 1343;BA.debugLine="End Sub";
return "";
}
public String  _setlinespacing(int _spacing) throws Exception{
byte[] _params = null;
 //BA.debugLineNum = 1361;BA.debugLine="Public Sub setLineSpacing(spacing As Int)";
 //BA.debugLineNum = 1362;BA.debugLine="If spacing < 0 Then";
if (_spacing<0) { 
 //BA.debugLineNum = 1363;BA.debugLine="WriteString(ESC & \"2\")";
_writestring(_esc+"2");
 }else {
 //BA.debugLineNum = 1365;BA.debugLine="WriteString(ESC & \"3\")";
_writestring(_esc+"3");
 //BA.debugLineNum = 1366;BA.debugLine="Dim params(1) As Byte";
_params = new byte[(int) (1)];
;
 //BA.debugLineNum = 1367;BA.debugLine="params(0) = spacing";
_params[(int) (0)] = (byte) (_spacing);
 //BA.debugLineNum = 1368;BA.debugLine="WriteBytes(params)";
_writebytes(_params);
 };
 //BA.debugLineNum = 1370;BA.debugLine="End Sub";
return "";
}
public String  _setprintwidth(int _width) throws Exception{
int _dh = 0;
int _dl = 0;
byte[] _params = null;
 //BA.debugLineNum = 1349;BA.debugLine="Public Sub setPrintWidth(width As Int)";
 //BA.debugLineNum = 1350;BA.debugLine="Dim dh As Int = width / 256";
_dh = (int) (_width/(double)256);
 //BA.debugLineNum = 1351;BA.debugLine="Dim dl As Int = width - dh";
_dl = (int) (_width-_dh);
 //BA.debugLineNum = 1352;BA.debugLine="WriteString(GS & \"W\")";
_writestring(_gs+"W");
 //BA.debugLineNum = 1353;BA.debugLine="Dim params(2) As Byte";
_params = new byte[(int) (2)];
;
 //BA.debugLineNum = 1354;BA.debugLine="params(0) = dl";
_params[(int) (0)] = (byte) (_dl);
 //BA.debugLineNum = 1355;BA.debugLine="params(1) = dh";
_params[(int) (1)] = (byte) (_dh);
 //BA.debugLineNum = 1356;BA.debugLine="WriteBytes(params)";
_writebytes(_params);
 //BA.debugLineNum = 1357;BA.debugLine="End Sub";
return "";
}
public String  _setrelativeprintposn(int _relposn) throws Exception{
int _dh = 0;
int _dl = 0;
byte[] _params = null;
 //BA.debugLineNum = 1413;BA.debugLine="Public Sub setRelativePrintPosn(relposn As Int)";
 //BA.debugLineNum = 1414;BA.debugLine="Dim dh As Int = relposn / 256";
_dh = (int) (_relposn/(double)256);
 //BA.debugLineNum = 1415;BA.debugLine="Dim dl As Int = relposn - dh";
_dl = (int) (_relposn-_dh);
 //BA.debugLineNum = 1416;BA.debugLine="WriteString(ESC & \"\\\")";
_writestring(_esc+"\\");
 //BA.debugLineNum = 1417;BA.debugLine="Dim params(2) As Byte";
_params = new byte[(int) (2)];
;
 //BA.debugLineNum = 1418;BA.debugLine="params(0) = dl";
_params[(int) (0)] = (byte) (_dl);
 //BA.debugLineNum = 1419;BA.debugLine="params(1) = dh";
_params[(int) (1)] = (byte) (_dh);
 //BA.debugLineNum = 1420;BA.debugLine="WriteBytes(params)";
_writebytes(_params);
 //BA.debugLineNum = 1421;BA.debugLine="End Sub";
return "";
}
public String  _settabpositions(int[] _tabs) throws Exception{
byte[] _data = null;
int _i = 0;
 //BA.debugLineNum = 1399;BA.debugLine="Public Sub setTabPositions(tabs() As Int)";
 //BA.debugLineNum = 1400;BA.debugLine="WriteString(ESC & \"D\")";
_writestring(_esc+"D");
 //BA.debugLineNum = 1401;BA.debugLine="Dim data(tabs.Length+1) As Byte";
_data = new byte[(int) (_tabs.length+1)];
;
 //BA.debugLineNum = 1402;BA.debugLine="For i = 0 To tabs.Length - 1";
{
final int step3 = 1;
final int limit3 = (int) (_tabs.length-1);
_i = (int) (0) ;
for (;_i <= limit3 ;_i = _i + step3 ) {
 //BA.debugLineNum = 1403;BA.debugLine="data(i) = tabs(i)";
_data[_i] = (byte) (_tabs[_i]);
 }
};
 //BA.debugLineNum = 1405;BA.debugLine="data(tabs.Length) = 0";
_data[_tabs.length] = (byte) (0);
 //BA.debugLineNum = 1406;BA.debugLine="WriteBytes(data)";
_writebytes(_data);
 //BA.debugLineNum = 1407;BA.debugLine="End Sub";
return "";
}
public String  _setusecustomcharacters(boolean _custom) throws Exception{
 //BA.debugLineNum = 1473;BA.debugLine="Public Sub setUseCustomCharacters(custom As Boolea";
 //BA.debugLineNum = 1474;BA.debugLine="If custom Then";
if (_custom) { 
 //BA.debugLineNum = 1475;BA.debugLine="WriteString(ESC & \"%1\")";
_writestring(_esc+"%1");
 }else {
 //BA.debugLineNum = 1477;BA.debugLine="WriteString(ESC & \"%0\")";
_writestring(_esc+"%0");
 };
 //BA.debugLineNum = 1479;BA.debugLine="End Sub";
return "";
}
public reparto_izca.keymon.lat.escposprinter._animage  _thresholdimage(reparto_izca.keymon.lat.escposprinter._animage _img,int _threshold) throws Exception{
byte[] _pixels = null;
int _i = 0;
int _lum = 0;
reparto_izca.keymon.lat.escposprinter._animage _ret = null;
 //BA.debugLineNum = 1884;BA.debugLine="Sub ThresholdImage(img As AnImage, threshold As In";
 //BA.debugLineNum = 1885;BA.debugLine="Dim pixels(img.Data.Length) As Byte";
_pixels = new byte[_img.Data /*byte[]*/ .length];
;
 //BA.debugLineNum = 1886;BA.debugLine="For i = 0 To pixels.Length - 1";
{
final int step2 = 1;
final int limit2 = (int) (_pixels.length-1);
_i = (int) (0) ;
for (;_i <= limit2 ;_i = _i + step2 ) {
 //BA.debugLineNum = 1887;BA.debugLine="Dim lum As Int = Bit.And(img.Data(i), 0xff) ' by";
_lum = __c.Bit.And((int) (_img.Data /*byte[]*/ [_i]),((int)0xff));
 //BA.debugLineNum = 1888;BA.debugLine="If lum < threshold Then";
if (_lum<_threshold) { 
 //BA.debugLineNum = 1889;BA.debugLine="lum = 1";
_lum = (int) (1);
 }else {
 //BA.debugLineNum = 1891;BA.debugLine="lum = 0";
_lum = (int) (0);
 };
 //BA.debugLineNum = 1893;BA.debugLine="pixels(i) = lum";
_pixels[_i] = (byte) (_lum);
 }
};
 //BA.debugLineNum = 1895;BA.debugLine="Dim ret As AnImage";
_ret = new reparto_izca.keymon.lat.escposprinter._animage();
 //BA.debugLineNum = 1896;BA.debugLine="ret.Width = img.Width";
_ret.Width /*int*/  = _img.Width /*int*/ ;
 //BA.debugLineNum = 1897;BA.debugLine="ret.Height = img.Height";
_ret.Height /*int*/  = _img.Height /*int*/ ;
 //BA.debugLineNum = 1898;BA.debugLine="ret.Data = pixels";
_ret.Data /*byte[]*/  = _pixels;
 //BA.debugLineNum = 1899;BA.debugLine="Return ret";
if (true) return _ret;
 //BA.debugLineNum = 1900;BA.debugLine="End Sub";
return null;
}
public String  _writebarcode(String _bartype,String _data) throws Exception{
byte[] _databytes = null;
int _dlow = 0;
byte[] _params = null;
 //BA.debugLineNum = 2220;BA.debugLine="Public Sub WriteBarCode(bartype As String, data As";
 //BA.debugLineNum = 2221;BA.debugLine="Dim databytes() As Byte = data.GetBytes(\"ASCII\")";
_databytes = _data.getBytes("ASCII");
 //BA.debugLineNum = 2222;BA.debugLine="Dim dlow As Int = databytes.Length";
_dlow = _databytes.length;
 //BA.debugLineNum = 2223;BA.debugLine="Log(\"Barcode \" & bartype & \", Size \" & dlow & \",";
__c.LogImpl("528508163","Barcode "+_bartype+", Size "+BA.NumberToString(_dlow)+", "+_data,0);
 //BA.debugLineNum = 2224;BA.debugLine="WriteString(GS & \"k\" & bartype.ToUpperCase.CharAt";
_writestring(_gs+"k"+BA.ObjectToString(_bartype.toUpperCase().charAt((int) (0))));
 //BA.debugLineNum = 2225;BA.debugLine="Dim params(1) As Byte";
_params = new byte[(int) (1)];
;
 //BA.debugLineNum = 2226;BA.debugLine="params(0) = dlow";
_params[(int) (0)] = (byte) (_dlow);
 //BA.debugLineNum = 2227;BA.debugLine="WriteBytes(params)";
_writebytes(_params);
 //BA.debugLineNum = 2228;BA.debugLine="WriteBytes(databytes)";
_writebytes(_databytes);
 //BA.debugLineNum = 2229;BA.debugLine="End Sub";
return "";
}
public String  _writebytes(byte[] _data) throws Exception{
 //BA.debugLineNum = 1425;BA.debugLine="Public Sub WriteBytes(data() As Byte)";
 //BA.debugLineNum = 1426;BA.debugLine="If Connected Then";
if (_connected) { 
 //BA.debugLineNum = 1427;BA.debugLine="Astream.Write(data)";
_astream.Write(_data);
 };
 //BA.debugLineNum = 1429;BA.debugLine="End Sub";
return "";
}
public String  _writeqrcode(int _size,String _ec,int _scale,String _data) throws Exception{
byte[] _databytes = null;
int _dhigh = 0;
int _dlow = 0;
byte[] _params = null;
 //BA.debugLineNum = 2236;BA.debugLine="Public Sub WriteQRCode(size As Int, EC As String,";
 //BA.debugLineNum = 2237;BA.debugLine="Dim databytes() As Byte = data.GetBytes(\"ISO-8859";
_databytes = _data.getBytes("ISO-8859-1");
 //BA.debugLineNum = 2238;BA.debugLine="Dim dhigh As Int = databytes.Length / 256";
_dhigh = (int) (_databytes.length/(double)256);
 //BA.debugLineNum = 2239;BA.debugLine="Dim dlow As Int = databytes.Length - dhigh*256";
_dlow = (int) (_databytes.length-_dhigh*256);
 //BA.debugLineNum = 2240;BA.debugLine="Log(\"QR Code : Size \" & size & \", EC \" & EC & \",";
__c.LogImpl("528573700","QR Code : Size "+BA.NumberToString(_size)+", EC "+_ec+", Scale "+BA.NumberToString(_scale)+", Size "+BA.NumberToString(_dlow)+" "+BA.NumberToString(_dhigh)+" : Data = "+_data,0);
 //BA.debugLineNum = 2241;BA.debugLine="Dim params(3) As Byte";
_params = new byte[(int) (3)];
;
 //BA.debugLineNum = 2242;BA.debugLine="params(0) = scale";
_params[(int) (0)] = (byte) (_scale);
 //BA.debugLineNum = 2243;BA.debugLine="params(1) = dlow";
_params[(int) (1)] = (byte) (_dlow);
 //BA.debugLineNum = 2244;BA.debugLine="params(2) = dhigh";
_params[(int) (2)] = (byte) (_dhigh);
 //BA.debugLineNum = 2245;BA.debugLine="WriteString(ESC & \"Z\" & Chr(size) & EC.ToUpperCas";
_writestring(_esc+"Z"+BA.ObjectToString(__c.Chr(_size))+BA.ObjectToString(_ec.toUpperCase().charAt((int) (0))));
 //BA.debugLineNum = 2246;BA.debugLine="WriteBytes(params)";
_writebytes(_params);
 //BA.debugLineNum = 2247;BA.debugLine="WriteBytes(databytes)";
_writebytes(_databytes);
 //BA.debugLineNum = 2248;BA.debugLine="End Sub";
return "";
}
public String  _writestring(String _data) throws Exception{
 //BA.debugLineNum = 1435;BA.debugLine="Public Sub WriteString(data As String)";
 //BA.debugLineNum = 1436;BA.debugLine="WriteString2(data, \"IBM437\")";
_writestring2(_data,"IBM437");
 //BA.debugLineNum = 1437;BA.debugLine="End Sub";
return "";
}
public String  _writestring2(String _data,String _encoding) throws Exception{
 //BA.debugLineNum = 1443;BA.debugLine="Public Sub WriteString2(data As String, encoding A";
 //BA.debugLineNum = 1444;BA.debugLine="Try";
try { //BA.debugLineNum = 1445;BA.debugLine="If Connected Then";
if (_connected) { 
 //BA.debugLineNum = 1446;BA.debugLine="Astream.Write(data.GetBytes(encoding))";
_astream.Write(_data.getBytes(_encoding));
 };
 } 
       catch (Exception e6) {
			ba.setLastException(e6); //BA.debugLineNum = 1449;BA.debugLine="Log(\"Printer error : \" & LastException.Message)";
__c.LogImpl("526607622","Printer error : "+__c.LastException(getActivityBA()).getMessage(),0);
 //BA.debugLineNum = 1450;BA.debugLine="AStream_Error";
_astream_error();
 };
 //BA.debugLineNum = 1452;BA.debugLine="End Sub";
return "";
}
public Object callSub(String sub, Object sender, Object[] args) throws Exception {
BA.senderHolder.set(sender);
return BA.SubDelegator.SubNotFound;
}
}
