private byte DoeventsComStr(string str, int chaotim) { byte[] array = new byte[1000]; PosLaction posLaction = default(PosLaction); int num = 0; byte result; while (chaotim > 0) { while (this.com1.BytesToRead > 0) { array[num] = (byte)this.com1.ReadByte(); num++; if (num > 999) { break; } } if (num > 0) { posLaction.star = 0; posLaction.end = (ushort)(num - 1); } if (Strmake.Strmake_StrSubstring(ref array, ref posLaction, str, 1) != 65535) { result = 1; return(result); } chaotim -= 10; this.Doyanshi(10); } result = 0; return(result); }
public static unsafe ushort Attmake_GetstrAtt(byte *buf, ref PosLaction thispos, ref runattinf att) { ushort num; fixed(PosLaction *lactionRef = (&thispos)) { fixed(runattinf *runattinfRef = (&att)) { num = Attmake_GetstrAtt(buf, lactionRef, runattinfRef); } } return(num); }
public static unsafe void Attmake_GetAtt(byte *buf, PosLaction *bufpos, runattinf *att) { PosLaction laction = new PosLaction(); pagexinxi page = new pagexinxi(); strxinxi str = new strxinxi(); uint add = 0; ushort index = 0; ushort num5 = 0; ushort num6 = 0; ushort num7 = 0; att->datafrom = 0xff; att->isref = 0; if (buf[bufpos->star] != 0x2e) { uint attdatapos; if (buf[bufpos->star] == 1) { Kuozhan.memcpy((byte *)&attdatapos, buf + (bufpos->star + 1), 4); attdatapos = (uint)(attdatapos * datasize.attxinxisize); attdatapos += myapp.app.attdatapos; } else { for (uint i = bufpos->star; i <= bufpos->end; i++) { if (buf[i] < 9) { i += 5; } if ((buf[i] == 0x2e) && (add != 1)) { if (num6 == 0) { num6 = (ushort)i; continue; } if (num7 == 0) { num7 = (ushort)i; continue; } return; } if (buf[i] == 0x5b) { add = 1; } else if (buf[i] == 0x5d) { add = 2; } } if (num6 == 0) { Sysatt.Sysatt_GetSysname(buf + bufpos->star, (byte)((bufpos->end - bufpos->star) + 1), att); return; } laction.star = bufpos->star; laction.end = (ushort)(num6 - 1); if (num7 > 0) { index = Hmi.Hmi_GetPageid(buf, &laction); if (index == 0xffff) { return; } laction.star = (ushort)(num6 + 1); laction.end = (ushort)(num7 - 1); if (index == myapp.dpage) { num5 = Hmi.Hmi_GetObjid(buf, &laction, myapp.dobjnameseradd, myapp.dpagexinxi.objqyt); attdatapos = myapp.dpagexinxi.attdatapos; } else { Readdata.Readdata_ReadPage(ref page, index); Readdata.Readdata_ReadStr(ref str, page.zhilingstar); num5 = Hmi.Hmi_GetObjid(buf, &laction, str.addbeg + myapp.app.strdataadd, page.objqyt); attdatapos = page.attdatapos; } laction.star = (ushort)(num7 + 1); } else { index = myapp.dpage; num5 = Hmi.Hmi_GetObjid(buf, &laction, myapp.dobjnameseradd, myapp.dpagexinxi.objqyt); laction.star = (ushort)(num6 + 1); attdatapos = myapp.dpagexinxi.attdatapos; } laction.end = bufpos->end; if ((num5 == 0xffff) || (laction.star > laction.end)) { return; } num6 = Attmake_GetAttindex(buf + laction.star, (byte)((laction.end - laction.star) + 1)); if (num6 == 0xff) { return; } if (index != myapp.dpage) { add = myapp.app.objadd + ((uint)(((ushort)(num5 + page.objstar)) * (datasize.objxinxisize + 180))); num7 = 0; Readdata.SPI_Flash_Read((byte *)&num7, add + 15, 1); if (num7 != 1) { return; } } else { add = myapp.app.objadd + ((uint)(((ushort)(num5 + myapp.dpagexinxi.objstar)) * (datasize.objxinxisize + 180))); } Readdata.SPI_Flash_Read((byte *)&num6, (uint)((add + datasize.objxinxisize) + (num6 * 2)), 2); if (num6 == 0xffff) { return; } attdatapos += (uint)(datasize.attxinxisize * num6); } add = myapp.app.strdataadd + attdatapos; Readdata.SPI_Flash_Read((byte *)&att->att, add, (uint)datasize.attxinxisize); att->attlei = (byte)(att->att.state & 15); if ((att->att.state & 0x10) > 0) { att->isxiugai = 1; att->datafrom = 0xfe; att->Pz = myapp.mymerry + att->att.pos; } else { att->isxiugai = 0; if (att->attlei != attshulei.Sstr.typevalue) { att->datafrom = 0xfd; } else { att->datafrom = 0xfc; } } if ((att->att.state & 0x20) > 0) { att->isref = 1; } if (att->attlei != attshulei.Sstr.typevalue) { att->val = 0; if (att->datafrom == 0xfe) { if (att->attlei == attshulei.SS16.typevalue) { short num8 = 0; Kuozhan.memcpy((byte *)&num8, myapp.mymerry + att->att.pos, att->att.merrylenth); att->val = num8; } else { Kuozhan.memcpy((byte *)&att->val, myapp.mymerry + att->att.pos, att->att.merrylenth); } } else { Kuozhan.memcpy((byte *)&att->val, (byte *)&att->att.pos, 4); } } } }
public static unsafe ushort Attmake_GetstrAtt(byte *buf, PosLaction *bufpos, runattinf *att) { ushort star = bufpos->star; ushort num3 = 0; ushort index = 0; PosLaction laction = new PosLaction(); att->datafrom = 0xff; att->isref = 0; if (bufpos->end < bufpos->star) { myapp.errcode = 0x1a; return(0xffff); } if (buf[star] != 0x22) { if ((((buf[star] >= 9) || (buf[star] <= 1)) && (buf[star] != 0x2d)) && ((buf[star] <= 0x2f) || (buf[star] >= 0x3a))) { laction.star = bufpos->star; if (Strmake.Strmake_IsAttendbyte(buf[star]) == 1) { myapp.errcode = 0x1a; return(0xffff); } int num = 0; while (star <= bufpos->end) { num3 = 0; while (star <= bufpos->end) { if (buf[star] < 9) { num3 = (ushort)(num3 + 5); star = (ushort)(star + 5); } if ((num == 0) && (Strmake.Strmake_IsAttendbyte(buf[star]) == 1)) { star = (ushort)(star - 1); break; } if (buf[star] == 0x5b) { num++; } else if (buf[star] == 0x5d) { num--; } if (num3 == 0x31) { myapp.errcode = 0x23; return(0xffff); } num3 = (ushort)(num3 + 1); star = (ushort)(star + 1); } if (star > bufpos->end) { star = bufpos->end; } laction.end = star; Attmake_GetAtt(buf, &laction, att); if (att->datafrom == 0xff) { myapp.errcode = 0x1a; return(0xffff); } return(star); } myapp.errcode = 0x1a; return(0xffff); } if (buf[star] < 9) { if (buf[star] == 3) { Kuozhan.memcpy((byte *)&att->val, buf + (star + 1), 4); att->datafrom = 0xfd; att->att.merrylenth = 4; att->attlei = attshulei.SS32.typevalue; att->isxiugai = 0; } else if (buf[bufpos->star] == 2) { att->datafrom = 0xfc; Kuozhan.memcpy((byte *)&att->att.pos, buf + (bufpos->star + 1), 4); att->att.state = attshulei.Sstr.typevalue; att->isxiugai = 0; } else if (buf[bufpos->star] == 4) { Sysatt.Sysatt_GetXitongval(buf[bufpos->star + 1], buf[bufpos->star + 2], att); } return((ushort)(star + 4)); } if (buf[star] == 0x2d) { star = (ushort)(star + 1); } while (star <= bufpos->end) { if ((buf[star] < 0x30) || (buf[star] > 0x39)) { star = (ushort)(star - 1); break; } if (star == bufpos->end) { break; } star = (ushort)(star + 1); } } else { buf[star] = 0; star = (ushort)(star + 1); num3 = 0xffff; index = star; while (star <= bufpos->end) { if (buf[star] == 0x5c) { if (star == bufpos->end) { myapp.errcode = 0x20; return(0xffff); } star = (ushort)(star + 1); if ((buf[star] == 0x5c) || (buf[star] == 0x22)) { buf[index] = buf[star]; } else if (buf[star] == 0x72) { buf[index] = 13; index = (ushort)(index + 1); buf[index] = 10; } else { myapp.errcode = 0x20; return(0xffff); } if (star == bufpos->end) { myapp.errcode = 0x20; return(0xffff); } star = (ushort)(star + 1); index = (ushort)(index + 1); } else { buf[index] = buf[star]; if (buf[star] == 0x22) { buf[index] = 0; num3 = star; break; } star = (ushort)(star + 1); index = (ushort)(index + 1); } } if (num3 != 0xffff) { att->att.pos = (ushort)(bufpos->star + 1); att->attlei = attshulei.Sstr.typevalue; att->att.merrylenth = (ushort)(index - bufpos->star); att->datafrom = 0xfd; att->isxiugai = 0; att->Pz = buf + att->att.pos; att->att.encodeh_star = myapp.encodeh_star; return(num3); } myapp.errcode = 0x1a; return(0xffff); } att->val = Strmake.Strmake_StrToS32(buf + bufpos->star, (byte)((star - bufpos->star) + 1)); att->datafrom = 0xfd; att->att.merrylenth = 4; att->attlei = attshulei.SS32.typevalue; att->isxiugai = 0; return(star); }
public int Getcomstr() { int num = 0; byte[] array = new byte[500]; PosLaction posLaction = default(PosLaction); PosLaction[] array2 = new PosLaction[30]; int result; try { while (this.com1.BytesToRead > 0) { array[num] = (byte)this.com1.ReadByte(); num++; if (num > 499) { break; } } num -= 4; if (num < 1) { result = 0; return(result); } posLaction.star = 0; posLaction.end = (ushort)num; int num2 = (int)Strmake.Strmake_StrSubstring(ref array, ref posLaction, "comok ", 1); this.FlashSize = 0; if (num2 != 65535) { posLaction.star = (ushort)(num2 + 1); if (Strmake.Strmake_StrGetcanshu(ref array, ref posLaction, ref array2, 7) == 1) { this.touch = array2[0].PosByteGetstring(array).Getint(); this.Lcdid = array2[1].PosByteGetstring(array).Getint(); this.xinghao = array2[2].PosByteGetstring(array); this.gujianver = (ushort)((byte)array2[3].PosByteGetstring(array).Getint()); this.cpuchip = (ushort)array2[4].PosByteGetstring(array).Getint(); this.FlashIDstring = array2[5].PosByteGetstring(array); this.FlashSize = array2[6].PosByteGetstring(array).Getint(); string text = this.xinghao.Trim(); modelxinxi modelxinxi; if (text.Length > 1) { string a = text.Substring(text.Length - 1, 1); if (a == "R" || a == "N" || a == "C") { text = text.Substring(0, text.Length - 1); } else { this.xilie = 0; modelxinxi = datasize.Getmodelxinxi("123", this.xilie); if (this.islaodmessage) { MessageOpen.Show("非法型号".Language() + this.xinghao); result = 3; return(result); } result = 1; return(result); } } this.xilie = 0; modelxinxi = datasize.Getmodelxinxi(text, this.xilie); if (modelxinxi.Modelstring == "") { this.xilie = 1; modelxinxi = datasize.Getmodelxinxi(text, this.xilie); } if (!(modelxinxi.Modelstring == "")) { result = 1; return(result); } if (this.islaodmessage) { MessageOpen.Show("非法型号".Language() + this.xinghao); result = 3; return(result); } result = 1; return(result); } else if (Strmake.Strmake_StrGetcanshu(ref array, ref posLaction, ref array2, 6) == 1) { this.touch = array2[0].PosByteGetstring(array).Getint(); this.Lcdid = array2[1].PosByteGetstring(array).Getint(); this.xinghao = array2[2].PosByteGetstring(array); this.gujianver = (ushort)((byte)array2[4].PosByteGetstring(array).Getint()); this.gujianver *= 256; this.gujianver += (ushort)((byte)array2[3].PosByteGetstring(array).Getint()); this.FlashIDstring = array2[5].PosByteGetstring(array); string text = this.xinghao.Trim(); modelxinxi modelxinxi; if (text.Length > 1) { string a = text.Substring(text.Length - 1, 1); if (a == "R" || a == "N" || a == "C") { text = text.Substring(0, text.Length - 1); } else { this.xilie = 0; modelxinxi = datasize.Getmodelxinxi("123", this.xilie); if (this.islaodmessage) { MessageOpen.Show("非法型号".Language() + this.xinghao); result = 3; return(result); } result = 1; return(result); } } this.xilie = 0; modelxinxi = datasize.Getmodelxinxi(text, this.xilie); if (modelxinxi.Modelstring == "") { this.xilie = 1; modelxinxi = datasize.Getmodelxinxi(text, this.xilie); } if (!(modelxinxi.Modelstring == "")) { result = 1; return(result); } if (this.islaodmessage) { MessageOpen.Show("非法型号".Language() + this.xinghao); result = 3; return(result); } result = 1; return(result); } } else { num2 = (int)Strmake.Strmake_StrSubstring(ref array, ref posLaction, "downbin", 1); if (num2 != 65535) { result = 2; return(result); } } } catch (Exception ex) { MessageOpen.Show(ex.Message); result = 0; return(result); } result = 0; return(result); }
// run.objedit public unsafe void Chonghuibmp() { List <byte[]> list = new List <byte[]>(); byte[] array = new byte[1]; PosLaction posLaction = default(PosLaction); try { if (this.runscr1.myapp.upapp.filesr != null) { if (this.dobj.atts[0].zhi[0] == objtype.page) { lock (this.runscr1.myapp.upapp.Screenbm) { Graphics.FromImage(this.runscr1.myapp.upapp.Screenbm).Clear(Color.White); } } else if (this.dobj.Mypage.mypage.pagelock == 0) { lock (this.runscr1.myapp.upapp.Screenbm) { Graphics.FromImage(this.runscr1.myapp.upapp.Screenbm).Clear(Color.FromArgb(0, 0, 0, 0)); } } this.runscr1.myapp.upapp.havetouming = false; if (objtype.getobjmark(this.dobj.atts[0].zhi[0]).show == 0) { this.Ref(); } else { if (this.dobj.myobj.redian.x < 0 || this.dobj.myobj.redian.endx >= this.Myapp.lcdwidth || this.dobj.myobj.redian.y < 0 || this.dobj.myobj.redian.endy >= this.Myapp.lcdheight) { this.thisbm = new Bitmap(base.Width, base.Height); this.BackgroundImage = null; } else { if (this.dobj.atts[0].zhi[0] < 50) { objxinxi myobj = this.dobj.myobj; array = new byte[128000]; myobj.attpos = 0; myobj.attposqyt = this.dobj.GetobjRambytes(ref array, 0); array = array.subbytes(0, (int)myobj.attposqyt); array.BytesToptr(0, this.runscr1.myapp.mymerry); array = new byte[1]; GuiObjControl.GuiObjControls[(int)this.dobj.atts[0].zhi[0]].Init(&myobj, (byte)this.dobj.objid); } else { this.dobj.Getbianji(ref list); if (list.Count > 0) { posLaction.star = 0; foreach (byte[] current in list) { try { fixed(byte *ptr = current) { posLaction.end = (ushort)(current.Length - 1); CodeRun.Coderun_Run(ptr, &posLaction); } } finally { byte *ptr = null; } } } } if (this.dobj.Mypage.mypage.pagelock == 0) { this.thisbm = new Bitmap(base.Width, base.Height); lock (this.runscr1.myapp.upapp.Screenbm) { Graphics.FromImage(this.thisbm).DrawImage(this.runscr1.myapp.upapp.Screenbm, new Rectangle(0, 0, base.Width, base.Height), new Rectangle(base.Left, base.Top, base.Width, base.Height), GraphicsUnit.Pixel); } if (base.Parent != null && this.dobj.atts[0].zhi[0] == objtype.page) { base.Visible = false; this.Ref(); } else if (this.dobj.atts[0].zhi[0] != objtype.page) { base.Visible = true; this.Ref(); } } } if (this.dobj.Mypage.mypage.pagelock == 1) { base.Enabled = false; if (this.dobj.atts[0].zhi[0] == objtype.page) { string text = "页面已锁定".Language(); this.thisbm = new Bitmap(this.runscr1.myapp.upapp.Screenbm.Width, this.runscr1.myapp.upapp.Screenbm.Height); Graphics.FromImage(this.thisbm).Clear(Color.FromArgb(50, 72, 149, 253)); Graphics.FromImage(this.thisbm).FillRectangle(new SolidBrush(Color.White), (this.thisbm.Width - this.imageList1.Images[0].Width) / 2 - 20, (this.thisbm.Height - this.imageList1.Images[0].Height) / 2 - 20, this.imageList1.Images[0].Width + 40, this.imageList1.Images[0].Height + 40); Graphics.FromImage(this.thisbm).DrawImage(this.imageList1.Images[0], (this.thisbm.Width - this.imageList1.Images[0].Width) / 2, (this.thisbm.Height - this.imageList1.Images[0].Height) / 2); this.BackgroundImage = this.thisbm; base.Visible = true; } else { base.Visible = false; } } } if (this.runscr1.myapp.upapp.havetouming) { this.BackColor = Color.FromArgb(0, 0, 0, 0); } if (this.dobj.Mypage.mypage.pagelock == 1 && this.dobj.objid == this.dobj.Mypage.objs.Count - 1) { lock (this.runscr1.myapp.upapp.Screenbm) { this.thisbm = new Bitmap(this.runscr1.myapp.upapp.Screenbm.Width, this.runscr1.myapp.upapp.Screenbm.Height); Graphics.FromImage(this.thisbm).DrawImage(this.runscr1.myapp.upapp.Screenbm, 0, 0); this.runscr1.BackgroundImage = this.thisbm; } } } } catch (Exception ex) { MessageOpen.Show("重绘控件出现错误 ".Language() + ex.Message); } }