protected void FindAllMethodsOrFileds() { Method method = null; MethodLines = new StringBuilder(); MethodRects = new StringBuilder(); CallMethods = new StringBuilder(); IIGlobalMethod loadMethod = null; ICallBackAble call = null; string field = ""; foreach (var c in this.TagList.OrderByDescending(x => x.Lev)) { if (c is ICallBackAble) { call = c as ICallBackAble; method = call.GetCallMethod(); GetMethodsLines(method); CallMethods.AppendFormat("{0}callback = {1}();\r\n", Method.getSpaces(2), method.Name); CallMethods.AppendFormat("{0}if (callback != null)\r\n", Method.getSpaces(2)); CallMethods.Append(Method.getSpaces(2) + "{\r\n"); CallMethods.AppendFormat("{0}return callback;\r\n", Method.getSpaces(3)); CallMethods.Append(Method.getSpaces(2) + "}\r\n"); continue; } if (c is IIGlobalMethod) { loadMethod = c as IIGlobalMethod; if (loadMethod.InPage(Html)) { method = loadMethod.GetIGlobalMethod(); GetMethodsLines(method); if (c is ReadTag) { ReadTag rd = c as ReadTag; var inl = rd.getListMethods(); if (inl != null && inl.Count > 0) { foreach (var x in inl) { x.InPageLoad = false; GetMethodsLines(x); } } } } } if (c is IGlobalField) { field = (c as IGlobalField).GetGloabalField(); if (GloabalFileds.Contains(field)) { continue; } GloabalFileds += field; } } }
public void init() { accessResult = null; detectBarcode = null; commandComplete = null; changedActionState = null; onAsReaderTriggerKeyEvent = null; onAsReaderLeftModeKeyEvent = null; onAsReaderRightModeKeyEvent = null; readerInitialized = null; updateDeviceState = null; readTag = null; onAsReaderGUNDisconnected = null; }
public static bool ReadEpc(byte[] selCode, MemoryBank selArea, ushort qvalue, out byte[] epc, out string errInfo) { epc = null; errInfo = ""; Invengo.NetAPI.Protocol.IRP1.ReadTag msg = new ReadTag(ReadTag.ReadMemoryBank.EPC_6C, true); //msg.IsLoop = false; //msg.IsReturn = true; if (selCode != null) { if (!TargetTag_6C(selCode, selArea, 0x00, (byte)selCode.Length, out errInfo)) { return(false); } } if (RfReader.Send(msg)) { if (msg.ReceivedMessage != null) { RXD_TagData[] brecv = msg.ReceivedMessage.List_RXD_TagData; if (brecv != null && brecv.Length > 0) { epc = brecv[0].ReceivedMessage.EPC; return(true); } } } else { if (msg.ErrInfo == null || msg.ErrInfo == "") { errInfo = string.Format("0x{0}", msg.StatusCode.ToString("X2")); } else { errInfo = msg.ErrInfo; } Log.Debug(errInfo); } return(false); }
/// <summary> /// Read TID /// </summary> /// <param name="selCode"></param> /// <param name="selArea"></param> /// <param name="qvalue"></param> /// <param name="epc"></param> /// <param name="errInfo"></param> /// <returns></returns> public static bool ReadTID(byte[] selCode, MemoryBank selArea, ushort qvalue, out byte[] TID, out string errInfo) { TID = null; errInfo = ""; Invengo.NetAPI.Protocol.IRP1.ReadTag msg = new ReadTag(ReadTag.ReadMemoryBank.TID_6C, false); //msg.IsLoop = false; //msg.IsReturn = true; try { if (RfReader.Send(msg, 1000)) { RXD_TagData[] brecv = msg.ReceivedMessage.List_RXD_TagData; if (brecv != null && brecv.Length > 0) { TID = brecv[0].ReceivedMessage.TID; return(true); } } else { if (msg.ErrInfo == null || msg.ErrInfo == "") { errInfo = string.Format("0x{0}", msg.StatusCode.ToString("X2")); } else { errInfo = msg.ErrInfo; } Log.Debug(errInfo); } } catch (Exception e) { string err = e.ToString(); errInfo = "No tag respondse!"; return(false); } return(false); }
public static ReadTag ConcreateReadTag(byte TargetCodeArea, ushort qvalue, int readTime, int stopTime) { ReadTag msg = null; switch (TargetCodeArea) { case 0: msg = new ReadTag(ReadTag.ReadMemoryBank.TID_6C, readTime, stopTime); break; case 1: msg = new ReadTag(ReadTag.ReadMemoryBank.EPC_6C, readTime, stopTime); break; case 2: msg = new ReadTag(ReadTag.ReadMemoryBank.EPC_TID_UserData_6C, readTime, stopTime); break; case 3: msg = new ReadTag(ReadTag.ReadMemoryBank.EPC_TID_UserData_6C_2, readTime, stopTime); break; case 4: msg = new ReadTag(ReadTag.ReadMemoryBank.ID_6B, readTime, stopTime); break; case 5: msg = new ReadTag(ReadTag.ReadMemoryBank.ID_UserData_6B, readTime, stopTime); break; case 6: msg = new ReadTag(ReadTag.ReadMemoryBank.EPC_TID_UserData_Reserved_6C_ID_UserData_6B, readTime, stopTime); break; } if (msg != null) { msg.Q = (byte)qvalue; msg.Antenna = AntennaNo; //EPC_TID_UserData_6C_2 actived if (TargetCodeArea == 3) //6C { msg.TidLen = (byte)(TidLength / 2); msg.UserDataPtr_6C = (byte)UserdataOffset; msg.UserDataLen_6C = (byte)(UserdataLength / 2); } else if (TargetCodeArea == 5) //6B { msg.UserDataPtr_6B = (byte)UserdataOffset; msg.UserDataLen_6B = (byte)UserdataLength; } else if (TargetCodeArea == 6) //6B/6C { msg.ReadTimes_6C = Readtimes_6C; msg.ReadTimes_6B = Readtimes_6B; msg.AccessPwd = Util.ConvertHexStringToByteArray(strpwd);; msg.TidLen = (byte)(TidLength / 2); msg.UserDataPtr_6C = (byte)UserdataOffset; msg.UserDataLen_6C = (byte)(UserdataLength / 2); msg.UserDataPtr_6B = (byte)UserdataOffset; msg.UserDataLen_6B = (byte)UserdataLength; } } return(msg); }
/// <summary> /// 读取标签或停止读取 /// </summary> private void ReadLoopRaw(object sender, EventArgs e) { try { AddToStatusAsync(""); if ((string)ibScan.Tag == "Start") { string err = ""; totalTimes = 0; //totalTags = 0; readMoment = Environment.TickCount; try { QValue = Convert.ToUInt16(txtqvalue.Text.Trim()); //MessageBox.Show(QValue.ToString); } catch { AddToStatusAsync("Q Value Must Be Integer!"); return; } readSnd.Start(); ReadTag msg = msg = ReadTagBll.ConcreateReadTag((byte)TargetCodeArea, QValue); if (reader.Send(msg)) { if (!ReadTagBll.IsLoop) { readSnd.Stop(); return; } IsRunning = true; ibScan.Text = "Stop"; ibScan.Tag = "Stop"; AddToStatusAsync("Scanning Tag!"); this.timer1.Enabled = true; } else { AddToStatusAsync("Scan Failure !"); } } else { readSnd.Stop(); BaseMessage msgPoweroff = new PowerOff(); msgPoweroff.IsReturn = false; bool ret = reader.Send(msgPoweroff); if (ret) { IsRunning = false; ibScan.Text = "Scan"; ibScan.Tag = "Start"; this.timer1.Enabled = false; AddToStatusAsync("Stop Scan Tag"); Update(); } else { AddToStatusAsync(" Stop Failure"); } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
/// <summary> /// 测试标签 /// </summary> /// <param name="text">文本(经过格式化)</param> /// <param name="origin">原始文本</param> /// <param name="regex">正则表达式</param> /// <param name="type">目标标签类型</param> private void MatchTag(string text, string origin, Regex regex, TagType type) { if (this.Config.tagregex.TagPairEndTest.IsMatch(text) || this.Config.tagregex.EmptyTest.IsMatch(text) || this.Config.tagregex.ifTagKeyTest.IsMatch(text)) { return; } TheMatch = regex.Match(text); if (TheMatch.Success) { this.Html = this.Html.Replace(origin, text); if (type == TagType._tag_list) { text = FindFirstListTagStr(text, this.TagList.Count()); } if (type == TagType._tag_command) { CMDTag tag = new CMDTag(text, origin, Deep, this.Config, this.TagList.Count); GetCMD(tag); this.TagList.Add(tag); } else if (type == TagType._tag_list) { if (this is SubListPage) { ListTag tag = new ListTag(text, origin, Deep, (this as SubListPage).PageName, this.Config, this.TagList.Count); this.TagList.Add(tag); } else { ListTag tag = new ListTag(text, origin, Deep, this is ItemPage ? (this as ItemPage).PageName : "", this.Config, this.TagList.Count); this.TagList.Add(tag); } } else if (type == TagType._tag_read) { ReadTag tag = new ReadTag(text, origin, Deep, this.Config, this.TagList.Count); this.TagList.Add(tag); } else if (type == TagType._tag_label) { LabelTag tag = new LabelTag(text, origin, Deep, this is LabelPage ? (this as LabelPage).PageName : "", this.Config, this.TagList.Count); tag.LazyLoad(); this.TagList.Add(tag); } else if (type == TagType._tag_static) { StaticTag tag = new StaticTag(text, origin, Deep, this is StaticPage ? (this as StaticPage).PageName : "", this.Config, this.TagList.Count); this.TagList.Add(tag); } else if (type == TagType._tag_filed) { FieldTag tag = new FieldTag(text, origin, Deep, this.Config, this.TagList.Count); this.TagList.Add(tag); } else if (type == TagType._tag_method) { MethodTag tag = new MethodTag(text, origin, Deep, this.Config, this.TagList.Count); this.TagList.Add(tag); } else if (type == TagType._tag_pager) { PagerTag tag = new PagerTag(text, origin, Deep, this.Config, this.TagList.Count); this.TagList.Add(tag); } else if (type == TagType._tag_form) { FormTag tag = new FormTag(text, origin, Deep, this.Config, this.TagList.Count); this.TagList.Add(tag); this.TagCallBack = "form"; } else if (type == TagType._tag_json) { JsonTag tag = new JsonTag(text, origin, Deep, this.Config, this.TagList.Count); this.TagList.Add(tag); this.TagCallBack = "json"; } } }