// metodo para actualizar la pantalla con los datos del usuario parte de un tag y recupera la informacion desde la BD // incluye proteccion de un solo hilo (uno solo pinta completamente la pantalla un hilo) private void actualizaPantalla(TAG tag) { if (InvokeRequired) { actualizaPantalla_Delegate task = new actualizaPantalla_Delegate(actualizaPantalla); BeginInvoke(task, new object[] { tag }); } else { lock (guiLock) { if (lbl_id_tag.Text.Equals(tag.TagOrigId) == false) { //MessageBox.Show("Tag Recibido Evento recepciĆ³n:" + tag.TagOrigId + " Tiempo:" + tag.Time + " ms" + tag.ApiTimeStampUTC.Millisecond); Participante par = modP.recuperaPxTag(tag.TagOrigId); this.lbl_id_tag.Text = tag.TagOrigId; this.lbl_nombre.Text = par.nombre; this.lbl_numero.Text = par.snumero; this.lbl_categoria.Text = par.categoria; this.lbl_pais.Text = par.pais; this.lbl_prueba.Text = par.prueba; } } } }
// metodo para actualizar la pantalla con los datos del usuario parte de un tag y recupera la informacion desde la BD // incluye proteccion de un solo hilo (uno solo pinta completamente la pantalla un hilo) private void actualizaTag(TAG tag) { if (InvokeRequired) { actualizaTag_Delegate task = new actualizaTag_Delegate(actualizaTag); BeginInvoke(task, new object[] { tag }); } else { lock (guiLock) { if (labelCodigoP.Text.Equals(tag.TagOrigId) == false) { //MessageBox.Show("Tag Recibido Evento recepciĆ³n:" + tag.TagOrigId + " Tiempo:" + tag.Time + " ms" + tag.ApiTimeStampUTC.Millisecond); sTag = tag.TagOrigId; this.labelCodigoP.Text = tag.TagOrigId; } } } }
//constructor public InsertaLecturaE(TAG tag, string strConexion) { this.tag = tag; this.strConexion = strConexion; }
public void parseRecords(string str, StateObject state) { if (str.StartsWith("cmd=evtNtf")) { //cmd=evtNtf&batchEnd=yes if (str.Contains("batchEnd=yes")) { saveToLogVerbose("BatchEnd Found"); OnTagListEvent(new TagListEventArgs(state.list)); state.list.Clear(); OnBatchEnd(new BatchEndEventArgs(DateTime.Now.ToString())); return; } //cmd=evtNtf&evt_id=TagfoundAction&msg=invenDisabled&trig=irNotfound&time=1175329956 if (str.Contains("msg=")) { INVENTORY_NTF_INFO info = new INVENTORY_NTF_INFO(); string[] Invkeys = str.Split('&'); foreach (string s in Invkeys) { if (s.StartsWith("evt_id=", StringComparison.OrdinalIgnoreCase)) { info.id = s.Substring(7); } else if (s.StartsWith("msg=", StringComparison.OrdinalIgnoreCase)) { info.msg = s.Substring(4); } else if (s.StartsWith("trig=", StringComparison.OrdinalIgnoreCase)) { info.trigger = s.Substring(5); } else if (s.StartsWith("time=", StringComparison.OrdinalIgnoreCase)) { info.time = s.Substring(5); } } saveToLogVerbose(String.Format("{0} {1} Found", info.id, info.msg)); OnInventory(new InventoryEventArgs(info)); return; } //cmd=evtNtf&evt_id=DemoEvent&src_ip=192.168.25.249&ant=Antenna1&cp_id=Capture Point 1&idx=B1&tag_id=100000000000000000000004&rssi=-48&time=1173077508 TAG intag = new TAG(); string[] keys = str.Split('&'); foreach (string s in keys) { if (s.StartsWith("evt_id=", StringComparison.OrdinalIgnoreCase)) { intag.EventId = s.Substring(7); } else if (s.StartsWith("src_ip=", StringComparison.OrdinalIgnoreCase)) { intag.ServerIp = s.Substring(7); } else if (s.StartsWith("ant=", StringComparison.OrdinalIgnoreCase)) { intag.Antenna = s.Substring(4); } else if (s.StartsWith("cp_id=", StringComparison.OrdinalIgnoreCase)) { intag.CapturePointId = s.Substring(6); } else if (s.StartsWith("idx=", StringComparison.OrdinalIgnoreCase)) { if (s.Length > 5) { intag.Index = s.Substring(5); intag.session = s.Substring(4, 1); } } else if (s.StartsWith("tag_id=", StringComparison.OrdinalIgnoreCase)) { intag.TagOrigId = s.Substring(7); } else if (s.StartsWith("rssi=", StringComparison.OrdinalIgnoreCase)) { double.TryParse(s.Substring(5), out intag.RSSI); } else if (s.StartsWith("time=", StringComparison.OrdinalIgnoreCase)) { Int32.TryParse(s.Substring(5), out intag.Time); } else if (s.StartsWith("cnt=", StringComparison.OrdinalIgnoreCase)) { Int32.TryParse(s.Substring(4), out intag.count); } else if (s.StartsWith("bank0=", StringComparison.OrdinalIgnoreCase)) { intag.Bank0 = s.Substring(6); } else if (s.StartsWith("bank2=", StringComparison.OrdinalIgnoreCase)) { intag.Bank2 = s.Substring(6); } else if (s.StartsWith("bank3=", StringComparison.OrdinalIgnoreCase)) { intag.Bank3 = s.Substring(6); } } intag.ApiTimeStampUTC = DateTime.UtcNow; OnTagReceiveEvent(new TagReceiveEventArgs(intag)); state.list.Add(intag); } else if (str.StartsWith("cmd=blog")) { //cmd=blogNtf&dataEnd=yes if (str.Contains("dataEnd=yes")) { saveToLogVerbose("DataEnd Found"); OnDataEnd(new DataEndEventArgs(DateTime.Now.ToString())); return; } //cmd=blogNtf&evt_id=DemoEvent&src_ip=192.168.25.249&ant=Antenna1&cp_id=Capture Point 1&idx=C31&tag_id=000000000000000000000006&rssi=-49&time=1173076720 } else if (str.StartsWith("cmd=errNtf")) { //cmd=errNtf&status=buffer overflow&time=1173076720 string status = null; string time = null; string[] keys = str.Split('&'); foreach (string s in keys) { if (s.StartsWith("status=", StringComparison.OrdinalIgnoreCase)) { if (s.Length > 7) status = s.Substring(7); } else if (s.StartsWith("time=", StringComparison.OrdinalIgnoreCase)) { if (s.Length > 5) time = s.Substring(5); } } if (status.Equals("buffer overflow", StringComparison.OrdinalIgnoreCase)) { saveToLogVerbose("BufferOverflow Found"); OnBufferOverflowEvent(new BufferOverflowEventArgs(time)); return; } } else if (str.StartsWith("cmd=antNtf")) { //cmd=antNtf&mismatch=1234&time=1173076720 string port = null; string time = null; string[] keys = str.Split('&'); foreach (string s in keys) { if (s.StartsWith("mismatch=", StringComparison.OrdinalIgnoreCase)) { if (s.Length > 9) port = s.Substring(9); } else if (s.StartsWith("time=", StringComparison.OrdinalIgnoreCase)) { if (s.Length > 5) time = s.Substring(5); } } saveToLogVerbose("AntennaNtf Found"); OnAntennaEvent(new AntennaEventArgs(port, time)); } }
public System.Collections.ArrayList getCaptureTagsRawEPC() { System.Collections.ArrayList tags = new System.Collections.ArrayList(); try { StringBuilder sbReq = new StringBuilder(); sbReq.Append(String.Format("{0}API?command=getCaptureTagsRaw&mode=getEPC&session_id={1}", httpUri.AbsoluteUri, SessionId)); string resp = sendHTTPRequest(sbReq.ToString()); if (resp == null) return null; XmlDataDocument doc = new XmlDataDocument(); doc.LoadXml(resp); XmlElement element = doc.DocumentElement; if (element.Name == "CSL") { XmlNode node = doc.SelectSingleNode("CSL/Command"); if (node != null) { if (node.InnerXml.Equals("getcapturetagsraw", StringComparison.OrdinalIgnoreCase)) { node = doc.SelectSingleNode("CSL/TagList/tagEPC"); if (node != null) { //<Ack> TAG tag; while (node != null) { tag = new TAG(); foreach (XmlAttribute att in node.Attributes) { if (att.Name.Equals("capturepoint_id", StringComparison.OrdinalIgnoreCase)) { tag.Antenna = att.InnerXml; } else if (att.Name.Equals("capturepoint_name", StringComparison.OrdinalIgnoreCase)) { tag.CapturePointId = att.InnerXml; } else if (att.Name.Equals("freq", StringComparison.OrdinalIgnoreCase)) { if (att.InnerXml != null) { double d; if (double.TryParse(att.InnerXml, out d)) { tag.Frequency = d * 0.05 + 860.0; } } } else if (att.Name.Equals("index", StringComparison.OrdinalIgnoreCase)) { string s = att.InnerXml; if (s.Length > 1) { tag.Index = s.Substring(1); tag.session = s.Substring(0, 1); } } else if (att.Name.Equals("rssi", StringComparison.OrdinalIgnoreCase)) { tag.RSSI = double.Parse(att.InnerXml); } else if (att.Name.Equals("tag_id", StringComparison.OrdinalIgnoreCase)) { tag.TagOrigId = att.InnerXml; } else if (att.Name.Equals("time", StringComparison.OrdinalIgnoreCase)) { int.TryParse(att.InnerXml, out tag.Time); } else if (att.Name.Equals("event_id", StringComparison.OrdinalIgnoreCase)) { tag.EventId = att.InnerXml; } else if (att.Name.Equals("reader_ip", StringComparison.OrdinalIgnoreCase)) { tag.ServerIp = att.InnerXml; } } tag.ApiTimeStampUTC = DateTime.UtcNow; tag.ServerIp = httpUri.Host; tags.Add(tag); node = node.NextSibling; } ErrorCode = ERR_CODE_NO_ERROR; ErrorMsg = ""; return tags; } node = doc.SelectSingleNode("CSL/Error"); if (node != null) { //<Error> foreach (XmlAttribute att in node.Attributes) { if (att.Name.Equals("msg", StringComparison.OrdinalIgnoreCase)) { ErrorMsg = att.InnerXml.Substring(6).Trim(); } else if (att.Name.Equals("code", StringComparison.OrdinalIgnoreCase)) { Int32.TryParse(att.InnerXml, out ErrorCode); } } return null; } } } } } catch (WebException wex) { ErrorMsg = wex.Message; return null; } ErrorMsg = "Invalid isOnline response."; return null; }