Class RfidService
- All Implemented Interfaces:
com.tccc.kos.commons.core.context.CtxEventListener,com.tccc.kos.commons.core.service.handle.ContextHandleAware,com.tccc.kos.commons.core.service.handle.HandleAware,com.tccc.kos.commons.util.ready.Ready,com.tccc.kos.commons.util.ready.ReadyAndReadyListener,com.tccc.kos.commons.util.ready.ReadyListener
RfidScanner
objects based on a specified scan type. As scanType is
an arbitrary string that identifies the purpose of the scan.
The scanType will be provided to callbacks so they can
perform conditional logic based on the type.
RfidScanner objects are collected into groups and
groups can be tagged with scan types. When performing a scan
with a scanType, all groups that are tagged with the
scanType will be run. This will cause all scanners
in the group to be run in the order in which they were added
to the group.
Groups and scan types allow complex scanning policy to be
constructed without having to write custom code. For example,
consider a dispenser with three cartridge shelves, each with
a multi-position antenna. When the door of the dispenser is
open the goal is to scan all shelves sequentially for cartridges.
By added a RfidScanner for each shelf and adding to a
group, scanning the group will automatically scan all the shelves
in sequence.
Now consider the same dispenser has an antenna on the door which can be used while the door is open to scan product information. This scanner can be added to the group and it will be scanned at after all three shelves are scanned. If lower latency is desired, the same scanner can be added after each shelf scanner, resulting in the door being check three times per group scan, once at the end of each shelf scan.
Now consider that while the door is closed, the door antenna
should be scanned for a product or technician tag. A second
group can be added that only has the door scanner. By tagging
the first group with a scan type of "doorClosed" and the second
group with a scan type of "doorOpen", simply calling
startRecurring() with the correct scan type will result
in the desired scanning policy.
This service supports both single and recurring scanning. It is
possible to run a single scan while a recurring scan is running.
Scanning callbacks are based on changes in tags. That is, if a
new tag is discovered, or an existing tag is no longer visible,
events are generated and passed to the registered listeners.
When performing a single scan, an optional Set can be
provided and that will contain all the visible tags during that
scan, even if they've been previously scanned.
Many simple applications may only require a simple scan policy.
To simplify this use case, the service contains a default group
and scanners can be added directly to this group. This group
has a scan type of "default" and can be scanned using this
type or startRecurringDefaultGroup() can be used.
- Version:
- 2023-10-14
-
Method Summary
Modifier and TypeMethodDescriptionvoidStop the currently active recurring scan as quickly as possible.voidaddGroup(RfidScanGroup group) Add a scan group to the service.voidaddScanner(RfidScanner<?> scanner) Add aRfidScannerto the default group.Return the default scan group.voidperformSingleScan(String scanType, Set<RfidTag> gather) Perform a single scan of the specifiedscanType.voidremoveGroup(RfidScanGroup group) Remove a scan group from the service.voidstartRecurring(String scanType) Start a recurring scan of the specified type.voidStart a recurring scan of the default group.voidStop the currently active recurring scan at the end of the current scan.Methods inherited from class com.tccc.kos.commons.core.service.AbstractService
getHandle, getHandlePrefixMethods inherited from class com.tccc.kos.commons.util.ready.ReadyBean
getReadyMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.tccc.kos.commons.core.context.CtxEventListener
onCtxAutowiringCompleted, onCtxDestroyed, onCtxPhaseCompletedMethods inherited from interface com.tccc.kos.commons.core.service.handle.HandleAware
addHandleChild, getName, getPathMethods inherited from interface com.tccc.kos.commons.util.ready.Ready
isReady, setReadyMethods inherited from interface com.tccc.kos.commons.util.ready.ReadyAndReadyListener
onBeanReady, onDependenciesReadyMethods inherited from interface com.tccc.kos.commons.util.ready.ReadyListener
onDependenciesGroupReady
-
Method Details
-
getDefaultGroup
Return the default scan group. This group has a name of "default" and can be scanned using that name or by callingstartRecurringDefaultGroup(). The default group only exists for convenience as most applications only use a single group for scanning. -
addScanner
Add aRfidScannerto the default group. Scanners will be run in the order in which they're added, and scanners can be added to the group multiple times. This allows a group to provide fine grained control over scanning order.- Parameters:
scanner- the scanner to add to the default group
-
addGroup
Add a scan group to the service.- Parameters:
group- the group to add
-
removeGroup
Remove a scan group from the service.- Parameters:
group- the group to remove
-
startRecurringDefaultGroup
public void startRecurringDefaultGroup()Start a recurring scan of the default group. This is simply a convenience method forstartRecurring("default"). -
startRecurring
Start a recurring scan of the specified type. This will continue scanning untilstopRecurring(), orstartRecurring(null)is called. ThescanTypecan be changed while a recurring scan is in progress. The existing scan will complete and then the next recurring scan will use the new type if applicable.- Parameters:
scanType- the type of scan to run
-
stopRecurring
public void stopRecurring()Stop the currently active recurring scan at the end of the current scan. -
abortRecurring
public void abortRecurring()Stop the currently active recurring scan as quickly as possible. -
performSingleScan
Perform a single scan of the specifiedscanType. This will run concurrently with any active scanning. Ifgatheris provided then any tags read during this scan will be added to thegatherset.- Parameters:
scanType- the type of scan to rungather- optional to set hold any tags read
-