Class RfidScanner<T extends RfidTag>

java.lang.Object
com.tccc.kos.ext.freestyle.service.rfid.RfidScanner<T>
Direct Known Subclasses:
FreestyleCartridgeScanner

public class RfidScanner<T extends RfidTag> extends Object
Identifies the positions on an antenna that should be scanned to generate add/remove events. This scanner tracks the tag read from pass to pass and if a tag appears, an add event will be generated. If a tag is no longer visible, a remove event will be generated. This effectively converts tag scanning into an event stream based on tag visibility.

An antenna may be used in multiple scanners, including using the same positions. This will cause the position to be read multiple times, once per scanner.

Version:
2023-10-13
  • Constructor Details

    • RfidScanner

      public RfidScanner(RfidAntenna antenna, RfidTagFactory<T> factory)
      Create a scanner for the specified positions on the specified antenna. The RfidTagFactory is used to convert RFID data from the physical tag to a logical RfidTag object. The factory can implement multiple RfidReadDescriptor which will all be evaluated per tag read (typically resulting in multiple physical reads per position). This allows a high degree of control over what tags are ultimately accepted and generated by this scanner.
      Parameters:
      antenna - the antenna to scan
      factory - the factory for generating tags
  • Method Details

    • addPosition

      public RfidPositionInfo<T> addPosition(int pos, Object userData)
      Add a position to the scanner.
      Parameters:
      pos - the position on the antenna
      userData - user data for the position
      Returns:
      the newly created RfidScannerPosition object
    • removePosition

      public RfidPositionInfo<T> removePosition(int pos)
      Remove a position from the scanner.
      Parameters:
      pos - the position on the antenna
      Returns:
      the RfidScannerPosition that was removed
    • enablePosition

      public void enablePosition(int pos, boolean enabled)
      Enable/disable an rfid position. When disabled, the position will behave as if there are no tags available on subsequent reads, resulting in a remove tag event.
      Parameters:
      pos - the position on the antenna
      enabled - if true, enable the position, otherwise disable it
    • addListener

      public RfidScanner<T> addListener(RfidTagListener<T> listener)
      Add a tag listener to the scanner.
      Parameters:
      listener - the listener to add
    • removeListener

      public void removeListener(RfidTagListener<T> listener)
      Remove a tag listener from the scanner.
      Parameters:
      listener - the listener to remove
    • getVerifyReadCount

      public int getVerifyReadCount()
      Return the number of reads performed when verifying a missing tag.
    • setVerifyReadCount

      public void setVerifyReadCount(int verifyReadCount)
      Set the number of reads to perform to verify a tag is missing. This mitigates issues with spurious read failures during normal scanning as it ensures the tag is really gone before generating a remove event.
    • getScanCount

      public int getScanCount()
      Return the number of times the scanner has been run.
    • scanPosition

      public boolean scanPosition(RfidPositionInfo<?> posInfo)
      Called for each position just before scanning it. Returning true will cause the scan to be performed normally. Returning false will cause the position to be skipped. This is equivalent to scanning the position and finding no tags in that it will generate remove events if a tag was previously scanned. Override as needed to implement scan policy.
      Parameters:
      posInfo - information associated with the position to be scanned
    • getAntenna

      public RfidAntenna getAntenna()
    • setScanCount

      public void setScanCount(int scanCount)