READERNAME TagMemory.java

From RifidiWiki

Jump to: navigation, search

This class is in charge of remembering tags that the reader has seen. It works in conjunction with the Radio. It should implement TagMemory. In addition, it should use the RifidiTagMap to store tags.

updateMemory

This method is called after a scan. It contains a list of tags that the reader has seen on its most recent scan. It is up to the reader's tag memory to decide what to do with the tags that have been seen.

public void updateMemory(Collection<RifidiTag> tagsToAdd);

Arguments

  1. tagsToAdd - The collection of tags that have been seen in the latest scan.

Reference Implementation

This is the implementation of the addProtocol() method in the symbol reader. The symbol reader keeps two lists of tags: those tags that can be currently seen by the reader (visible tags), and those that have been seen by the reader, but have not been purged(invisible). Every time the updateMemory method is called, the symbol reader adds the tags that it has just seen to the list of visible tags. It then generates the set difference between the visible and the tags that have just been seen (those tags that are still in the visible list, but not in the 'just seen list'). These tags must be added to the invisible list and removed from the visible list.

As you can see, every reader will handle this method completely differently, depending on its tag memory model.

	public void updateMemory(Collection<RifidiTag> tagsSeen) {
		if (!suspended) {
			//add new tags to visible
			tagBufferVisible.addTags(tagsSeen);
			
			//move old tags to invisible tags
			Collection<RifidiTag>diff = tagBufferVisible.generateSetDiff(tagsSeen);
			tagBufferInvisible.addTags(diff);
			tagBufferVisible.removeTags_tag(diff);
		}
	}

getTagReport

This method returns a tag list. Most readers will need a method such as this one

public Collection<RifidiTag> getTagReport();

Return Value

A collection of RifidiTags

Reference Implementation

This is the implementation of the getTagReport() method in the symbol reader

	public Collection<RifidiTag> getTagReport() {
		return this.tagBufferVisible.getTagList();
	}

clear

This method purges the tag list

public void clear();

Reference Implementation

This is the implementation of the clear() method in the symbol reader

	public void clear() {
		this.tagBufferVisible.clear();
		this.tagBufferInvisible.clear();		
	}

suspend

Readers need to be able to suspend and resume their tag memories to make sure that they don't change while the reader is suspended

public void suspend();

Reference Implementation

Normally readers can just have a boolean in the tagMemory that will not allow anything to happen if the boolean is true. See the updateTagMemory() method above for an example.

	public void suspend() {
		suspended = true;
	}

resume

Readers need to be able to suspend and resume their tag memories to make sure that they don't change while the reader is suspended

public void resume();

Reference Implementation

Normally readers can just have a boolean in the tagMemory that will not allow anything to happen if the boolean is true. See the updateTagMemory() method above for an example.

	public void resume() {
		suspended = false;
	}
Personal tools