// Helper method to connect Reader to MainForm
public void HandleTagReceived(MyTag tag)
{
if (tag == null)
{
// todo - some gui display thing
//AppendToMainTextBox("No Tags Seen");
}
else if (IsInventoryRunning()) // if reader is running
{
handleTags.HandleTagReceived(tag);
channel_index = Convert.ToInt32(tag.GetFrequency());
if (channel_index == last_channel_index)
{
tagInfo.rssi[channel_index - 1] = tagInfo.rssi[channel_index - 1] + Convert.ToInt32(tag.GetRSSI());
channel_counter = channel_counter + 1;
}
else
{
if (channel_counter != 0)
{
tagInfo.rssi[last_channel_index - 1] = tagInfo.rssi[last_channel_index - 1] / channel_counter;
tagInfo.rssi[channel_index - 1] = Convert.ToInt32(tag.GetRSSI());
channel_counter = 1;
last_channel_index = channel_index;
}
else
{
tagInfo.rssi[channel_index - 1] = Convert.ToInt32(tag.GetRSSI());
channel_counter = 1;
last_channel_index = channel_index;
}
}
}
}