State
The state
object represents the current state of the Read Point within your application. It contains properties related to RFID functionality, General Purpose Inputs (GPIs), printer settings, and automation features. When using RFID in the application the state.seenSinceLastClear
object can for example provide an easier way of controlling the RFID reader and reading RFID tags. Although the same can be done by using triggers
and actions
.
RFID
The rfid
property within the state
object is an object with the state of the RFID reader connected to the Read Point. Besides that it contains functions to enable/disable the reader named: startReading
stopReading
. It also contains an seenSinceLastClear
object and a current
object. The seenSinceLastClear
object can be used to keep a list of RFID tags read since the last time the list is cleared. To enable this functionality the seenSinceLastClear.enable()
function should be called. After that the list of seenSinceLastClear.epcs
contains the list of read epcs
. When the read tags are GS1 encoded the seenSinceLastClear
also contains an array called gtinQuantities
with the epcs
grouped by gtin
.
General Purpose Inputs
The gpis
property within the state
object is an array that contains information about the connected GPI ports. Per connected GPI an object with the active portNumber
and level
will be added to the array.
Printer
The printer
property within the state
object shows the current printer state when there is a printer connected to the Read Point.
Automation
The automation
property within the state
object shows the current automation state when there is an automation device ( for example an RFID tunnel) added to the Read Point.
Properties:
rfid
(object):enabled
(boolean):- Indicates whether RFID functionality is currently enabled (
true
) or disabled (false
).
- Indicates whether RFID functionality is currently enabled (
seenSinceLastClear
(object):- Contains information about RFID tags that have been seen since the last clear operation. It includes the following properties:
epcs
(array): An array of EPC (Electronic Product Code) codes for the seen since the last clear operation.gtinQuantities
(array): An array of GTIN (Global Trade Item Number) codes seen since the last clear operation.
- Contains information about RFID tags that have been seen since the last clear operation. It includes the following properties:
current
(object):- Contains information about currently detected RFID tags. It includes the following properties:
epcs
(array): An array of EPC codes for the currently detected RFID tags.gtinQuantities
(array): An array of GTIN codes for the currently detected RFID tags.
- Contains information about currently detected RFID tags. It includes the following properties:
**gpis**
(array):- Per connected GPI an object with the active
portNumber
andlevel
.
- Per connected GPI an object with the active
**printer**
(object):- Contains the state of the printer when one is connected to the Read Point.
**automation**
(object):- Contains the state of an Automation when one is connected to the Read Point.
Example code:
export default function Application({ state }) {
const { startReading, stopReading, enabled } = state.rfid
const { enable, clear, gtinQuantities } = state.rfid.seenSinceLastClear
useEffect(() => {
enable()
}, [enable])
return (
<Space
direction="vertical"
style={{ width: '100%' }}
size="large"
align="center"
>
<Space>
<Button
onClick={startReading}
disabled={enabled}
size="large"
type="primary"
icon={<PlayCircleOutlined />}
>
Start Reading
</Button>
<Button
onClick={stopReading}
disabled={!enabled}
size="large"
icon={<PauseCircleOutlined />}
>
Stop Reading
</Button>
<Button onClick={clear} size="large" icon={<RollbackOutlined />}>
Clear
</Button>
</Space>
<Table
dataSource={gtinQuantities}
columns={[
{
title: 'GTIN',
dataIndex: 'gtin',
key: 'gtin',
},
{
title: 'Quantity',
dataIndex: 'quantity',
key: 'quantity',
},
]}
pagination={false}
rowKey="gtin"
size="large"
/>
</Space>
)
}
Updated over 1 year ago