public void UpdateTags(NurApi.TagTrackingTag tag) { string epc = NurApi.BinToHexString(tag.epc, tag.epcLen); int sector = 0; if (tag.visible == 1) { for (int n = 0; n < epcBoxes.Length; n++) { sector = ((int)epcBoxes[n].Tag); //we don't want to hide tags here which are not yet actually missing(i.e. by visibility change) if (tag.maxRssiAnt != -1) { if (sector == tag.maxRssiAnt && !epcBoxes[n].Items.Contains(epc)) { epcBoxes[n].Items.Add(epc); } else if (sector != tag.maxRssiAnt && epcBoxes[n].Items.Contains(epc)) { epcBoxes[n].Items.RemoveAt(epcBoxes[n].Items.IndexOf(epc)); } } } } else { Remove(tag); } }
public void Remove(NurApi.TagTrackingTag tag) { string epc = NurApi.BinToHexString(tag.epc, tag.epcLen); for (int n = 0; n < epcBoxes.Length; n++) { if (epcBoxes[n].Items.Contains(epc)) { epcBoxes[n].Items.RemoveAt(epcBoxes[n].Items.IndexOf(epc)); } } }
private void AddEventListItem(DateTime time, NurApi.TagTrackingTag tag) { ListViewItem item = new ListViewItem(new string[] { time.ToLongTimeString(), ChangedEventToString(tag.changedEvents), tag.maxRssiAnt != -1 ? mApi.NurAntennaIdToPhysicalAntenna(tag.maxRssiAnt) : tag.maxRssiAnt.ToString(), tag.firstTTIOReadSource != -1 ? mApi.NurAntennaIdToPhysicalAntenna(tag.firstTTIOReadSource) : tag.firstTTIOReadSource.ToString(), tag.secondTTIOReadSource != -1 ? mApi.NurAntennaIdToPhysicalAntenna(tag.secondTTIOReadSource) : tag.secondTTIOReadSource.ToString(), TagDirectionToString(tag.directionTTIO), tag.visible.ToString(), }, -1); eventhistoryListView.Items.Add(item); }
private void KeepInCircle(ref NurApi.TagTrackingTag tag, float radius) { // Make sure 'pos' is kept inside given radius PointF pos = new PointF(tag.X, tag.Y); PointF center = new PointF(0.5f, 0.5f); PointF delta = new PointF(pos.X - center.X, pos.Y - center.Y); float vectorLen = (float)Math.Sqrt((delta.X * delta.X) + (delta.Y * delta.Y)); if (vectorLen > radius) { float radians = (float)Math.Atan2((double)(pos.Y - center.Y), (double)(pos.X - center.X)); tag.X = center.X + radius * (float)Math.Cos(radians); tag.Y = center.Y + radius * (float)Math.Sin(radians); } }
void RemoveMissingTag(NurApi.TagTrackingTag tag) { string epc = NurApi.BinToHexString(tag.epc, tag.epcLen); TagUserData ud = null; if (ttStorage.TryGetValue(epc, out ud)) { if (ud != null) { tagviewpanel.Controls.Remove(ud.tagViewCtl); } ttStorage.Remove(epc); } if (this.tagsPerBeamControl1 != null) { tagsPerBeamControl1.Remove(tag); } }
private void AddEventListItem(DateTime time, NurApi.TagTrackingTag tag) { if (this.InvokeRequired) { this.Invoke(new AddEventListItemDelegate(AddEventListItem), new object[] { time, tag }); return; } ListViewItem item = new ListViewItem(new string[] { time.ToLongTimeString(), ChangedEventToString(tag.changedEvents), tag.maxRssiAnt.ToString(), tag.maxRssi.ToString(), tag.visible.ToString(), "X " + tag.X.ToString() + " Y" + tag.Y.ToString(), tag.directionTTIO.ToString(), tag.firstTTIOReadSource.ToString(), tag.secondTTIOReadSource.ToString(), }, -1); eventhistoryListView.Items.Add(item); }
public void UpdateTags(NurApi.TagTrackingTag tag) { string epc = NurApi.BinToHexString(tag.epc, tag.epcLen); int sector = 0; if (tag.visible == 1) { for (int n = 0; n < epcBoxes.Length; n++) { sector = ((int)epcBoxes[n].Tag + 1); if (sector == tag.sector && !epcBoxes[n].Items.Contains(epc)) { epcBoxes[n].Items.Add(epc); } else if (sector != tag.sector && epcBoxes[n].Items.Contains(epc)) { epcBoxes[n].Items.RemoveAt(epcBoxes[n].Items.IndexOf(epc)); } } } }
void UpdateTag(NurApi.TagTrackingTag tag) { string epc = NurApi.BinToHexString(tag.epc, tag.epcLen); DateTime n = DateTime.Now; Dictionary <DateTime, NurApi.TagTrackingTag> entries; if (!ttStorage.TryGetValue(epc, out entries)) { entries = new Dictionary <DateTime, NurApi.TagTrackingTag>(); ttStorage.Add(epc, entries); ListViewItem lvi = new ListViewItem(epc); lvi.Name = epc; lvi.Tag = entries; lvi.SubItems.Add("bob"); lvi.SubItems.Add("smith"); tagListView.Items.Add(lvi); } entries.Add(n, tag); if (tagListView.SelectedItems != null) { foreach (ListViewItem item in tagListView.SelectedItems) { if (item.Name == epc) { AddEventListItem(n, tag); } } } if (this.tagsPerAntennaControl1 != null) { tagsPerAntennaControl1.UpdateTags(tag); } }
private void UpdateTag(NurApi.TagTrackingTag tag) { string epc = NurApi.BinToHexString(tag.epc, tag.epcLen); DateTime n = DateTime.Now; Dictionary <DateTime, NurApi.TagTrackingTag> entries; if (!ttStorage.TryGetValue(epc, out entries)) { // not seen, add to our internal storage entries = new Dictionary <DateTime, NurApi.TagTrackingTag>(); ttStorage.Add(epc, entries); ListViewItem lvi = new ListViewItem(epc); lvi.Name = epc; lvi.Tag = entries; lvi.SubItems.Add("bob"); lvi.SubItems.Add("smith"); tagListView.Items.Add(lvi); } entries.Add(n, tag); //Tag moved from in to out or out to in if ((tag.changedEvents & NurApi.TTEV_INOUT) != 0) { ListViewItem item = new ListViewItem(new string[] { epc, "1" }, -1); item.Name = epc; if ((tag.directionTTIO & NurApi.TTIO_DIRECTION_INTOOUT) != 0) { //Add it to out-list, otherwise just increment the count if (!listOUT.Items.ContainsKey(epc)) { listOUT.Items.Add(item); } else { int cnt = Convert.ToInt32(listOUT.Items[epc].SubItems[1].Text) + 1; listOUT.Items[epc].SubItems[1] = new ListViewItem.ListViewSubItem(listOUT.Items[epc], cnt.ToString()); } } else if ((tag.directionTTIO & NurApi.TTIO_DIRECTION_OUTTOIN) != 0) { //Add it to in-list, otherwise just increment the count if (!listIN.Items.ContainsKey(epc)) { listIN.Items.Add(item); } else { int cnt = Convert.ToInt32(listIN.Items[epc].SubItems[1].Text) + 1; listIN.Items[epc].SubItems[1] = new ListViewItem.ListViewSubItem(listIN.Items[epc], cnt.ToString()); } } lbl_incnt.Text = listIN.Items.Count.ToString(); lbl_outcnt.Text = listOUT.Items.Count.ToString(); } if (tagListView.SelectedItems != null) { foreach (ListViewItem item in tagListView.SelectedItems) { if (item.Name == epc) { AddEventListItem(n, tag); } } } }
void UpdateTagPos(NurApi.TagTrackingTag tag) { string epc = NurApi.BinToHexString(tag.epc, tag.epcLen); TagUserData ud = null; //Have we seen this epc already? if (!ttStorage.TryGetValue(epc, out ud)) { // New tag, create tag control Label ctl = new Label(); ctl.Size = new Size(10, 10); ctl.BackColor = Color.Black; ctl.BringToFront(); // Make it round var path = new System.Drawing.Drawing2D.GraphicsPath(); path.AddEllipse(0, 0, ctl.Width, ctl.Height); ctl.Region = new Region(path); // Add to tagview tagviewpanel.Controls.Add(ctl); // Add to tag listview ListViewItem lvi = new ListViewItem(epc); lvi.Name = epc; lvi.SubItems.Add("bob"); lvi.SubItems.Add("smith"); if (!tagListView.Items.ContainsKey(epc)) { tagListView.Items.Add(lvi); } else { lvi = tagListView.Items[epc]; } // Userdata holder ud = new TagUserData() { tag = tag, tagViewCtl = ctl, lvItem = lvi }; // Set userdata references lvi.Tag = ud; ctl.Tag = ud; //e.tag.UserData = ud; ttStorage.Add(epc, ud); //hNur.ULog("Add " + epc); } else { ttStorage[epc].tag = tag; //hNur.ULog("Update " + epc); } ud.lvItem.SubItems[1].Text = tag.maxRssi.ToString(); ud.lvItem.SubItems[2].Text = tag.sector.ToString(); SetControlTagViewPosition(ud.tagViewCtl); if (this.tagsPerBeamControl1 != null) { tagsPerBeamControl1.UpdateTags(tag); } }