# Reader Reference

# Controlling RFID Devices via PLC

The following sections describe how the RFID Edge Server communicates with and controls RFID devices by interacting with a programmable logic controller (PLC).

- Overview of PLC Communications
- Configuring the Edge Server for PLC Communications

## Overview of PLC Communications

The WebLogic RFID Edge Server allows you to receive information about other devices and control them, by communicating with a programmable logic controller (PLC), which is a specialized industrial computer used for automation of real-world processes. A PLC has a number of registers, which are used to hold information. Registers are sometimes referred to as items or tags (not to be confused with EPC tags). Applications interacting with the PLC can either:

- read the contents of one or more registers (referred to as inbound messages) and take actions based on the values read, or
- write information to one or more registers to make it available to other applications (referred to as outbound messages).

## Configuring the Edge Server for PLC Communications

Configuring the RFID Edge Server to enable PLC communications requires adding the following items to the `edge.props` file:

- One or more transports, which specify the underlying mechanism used to send messages and the location to which messages should be sent. There may be other configuration options specific to the transport chosen. The available implementations are `OPC_XML`, `StarThis`, `ModBus` and `Reader` (replaces `GPIO`, deprecated in this release).
- One or more message conventions, which must correspond to the conventions expected by the PLC with which the Edge Server communicates. The conventions supported are `Simple`, `CounterPair`, and `Multiple`. More than one message can use the same message convention.
- One or more messages, which specify the registers on the PLC to read from or write to, and the values to be written. The same message can be sent for multiple events. The messages supported are `inboundMessage` and `outboundMessage`.

In general, users who want to enable their installation of the RFID Edge Server to control RFID devices using programmable logic controllers will need some custom development effort. The examples provided below illustrate possible configurations after custom development work has been completed.

### PLC-Connected Reader and Printer Example

Note: | All property names shown in this section should be prefixed with `com.connecterra.ale.plc`, which is abbreviated `[CCAP]` in the properties below.

1. Create a backup copy of `edge.props` and open the original for editing.
2. Define a transport to be used for PLC communications. The supported implementations are `OPC_XML`, `StarThis`, and `ModBus`.

    # ModBus configuration
    [CCAP].plcTransport.modbus1.metaName = ModBus
    [CCAP].plcTransport.modbus1.hostname = ip_address
    [CCAP].plcTransport.modbus1.socketTimeout = 10000
    [CCAP].plcTransport.modbus1.pollInterval = 500

    # OPC_XML configuration
    [CCAP].plcTransport.opcABC.metaName = OPC_XML
    [CCAP].plcTransport.opcABC.hostname = http://plchost/path

    # StarThis configuration
    [CCAP].plcTransport.ab1756.metaName = StarThis
    [CCAP].plcTransport.ab1756.licenseDir = ..\licenses
    [CCAP].plcTransport.ab1756.storageDir = ..\var\plc-storage
    [CCAP].plcTransport.ab1756.hostname = ab1756
    [CCAP].plcTransport.ab1756.backplanePort = 0
    [CCAP].plcTransport.ab1756.pollInterval = 50

3. Choose a message convention. The types supported are `Simple`, `CounterPair`, and `Multiple`. The notations `<var1>` and `<var2>` should be replaced by property names that you choose.

    # SimpleTransaction configuration
    [CCAP].plcMessageConvention.<var1>.metaName = Simple
    # The plcTransport name shown below should be a hostname from step 2.
    [CCAP].plcMessageConvention.<var1>.plcTransport = ab1756

    # CounterPairTransaction configuration
    [CCAP].plcMessageConvention.<var2>.metaName = CounterPair

    # Define ModBus PLC message convention for writing
    [CCAP].plcMessageConvention.multiple.metaName = Multiple
    [CCAP].plcMessageConvention.multiple.plcTransport = modbus1

    # The plcTransport name shown below should be a hostname from step 2.
    [CCAP].plcMessageConvention.<var2>.plcTransport = ab1756
    [CCAP].plcMessageConvention.<var2>.restart.receiveCounterItem = PLCRestart[2]
    [CCAP].plcMessageConvention.<var2>.restart.ackCounterItem = PLCRestartAck[2]
    [CCAP].plcMessageConvention.<var2>.restart.dataItems = PLCRestart[0]
    [CCAP].plcMessageConvention.<var2>.restart.prefetch = true

    # Configure the next two properties on ONE client only
    [CCAP].plcMessageConvention.<var2>.restartAckStatusItem = PLCRestartAck[0]
    [CCAP].plcMessageConvention.<var2>.restartDelay = 100

Note: | The array elements shown above and in step 4 refer to PLC registers on the PLCs in use at your organization. Both the register names and element numbers may differ from the sample information shown.

4. Define the inbound and outbound messages for the message convention chosen in the prior step. The notations `<var1>` and `<var2>` should be replaced by the property names you chose in step 3.

    # Simple inboundMessage configuration
    [CCAP].inboundMessage.doorOpen.plcMessageConvention = <var1>
    [CCAP].inboundMessage.doorOpen.receiveItem = D2052
    [CCAP].inboundMessage.doorOpen.matchValues = true

    # CounterPair inboundMessage configuration
    [CCAP].inboundMessage.BCRArrival.plcMessageConvention = <var2>
    [CCAP].inboundMessage.BCRArrival.receiveCounterItem = BCRArrival[19]
    [CCAP].inboundMessage.BCRArrival.ackCounterItem = BCRArrivalAck[0]
    [CCAP].inboundMessage.BCRArrival.dataItems = BCRArrival

    # CounterPair outboundMessage configuration
    [CCAP].outboundMessage.SgtinAssign.plcMessageConvention = <var2>
    [CCAP].outboundMessage.SgtinAssign.sendCounterItem = SgtinAssign[59]
    [CCAP].outboundMessage.SgtinAssign.ackCounterItem = SGTINAssignAck[0]
    [CCAP].outboundMessage.SgtinAssign.dataItems = SgtinAssign

5. Save the changes to `edge.props` and restart the Edge Server.
6. Configure your RFID devices to communicate with the PLC by defining devices as shown below using the RFID Devices node in the Administration Console:

- Device Type: PLC-Connected Barcode Reader
  Logical Reader Name: <a reader name you choose>
  Inbound PLC Message Name: <must match the name of the inboundMessage carrying the bar code; for example, `BCRArrival` in step 4>
- Device Type: PLC-Connected Label Print & Apply
  Logical Reader Name: <a reader name you choose>
  Outbound PLC Message Name: <must match the name of the outboundMessage; for example, `SgtinAssign` in step 4>

### PLC Stack Light Example

For a PLC stack light, there are two components that you must configure:

- PLC stack light device (a PLC stack light logical reader)
- PLC outbound message definition

You can configure the PLC stack light device in the Administration Console or `edge.props` file. The PLC outbound message can only be defined in `edge.props`.

In order to map which PLC outbound message the PLC stack light device uses, you specify the PLC outbound message name, defined in `edge.props` (in step 3 below, `[CCAP].outboundMessage.``stacklight``.plcMessageConvention = multiple`) when you configure the PLC stack light device in the Administration Console (in step 5 below, PLC set stack light message name = stacklight). The PLC outbound message name (for example, stacklight) can be any string you choose, but it must be specified in both the PLC stack light device configuration and the PLC outbound message definition.

1. Create a backup copy of `edge.props` and open the original for editing.
2. Define a PLC stack light device.

    #Define ModBus PLC stack light reader. Note that the stack light reader is
    #defined either using the Administration Console or by editing the
    #edge.props file. The default behavior
    #com.connecterra.ale.dynamicConfig.enabled = true, means that you configure
    #the reader using the Administration Console. If you want to define and
    #configure the reader in the edge.props file, set this property to false.
    com.connecterra.ale.reader.stacklight.class = com.connecterra.ale.readertypes.PLCStackLightPhysicalReader
    com.connecterra.ale.reader.stacklight.plcMessage = stacklight
    com.connecterra.ale.reader.stacklight.defaultRate = 0
    com.connecterra.ale.reader.stacklight.stackLightLogicalReaderName = StackLight

3. Choose a message convention and define the outbound messages for the message convention.

    # Multiple outboundMesssage configuration for `stacklight'
    com.connecterra.ale.plc.outboundMessage.stacklight.plcMessageConvention = multiple
    com.connecterra.ale.plc.outboundMessage.stacklight.items = c1 c2 c3 c4 c5

4. Save the changes to `edge.props` and restart the Edge Server.
5. Configure your RFID devices to communicate with the PLC by defining devices as shown below using the RFID Devices node in the Administration Console:

- Note: If you configured the stack light reader in `edge.props`, do not perform this configuration step in the Administration Console.
  Device Type: PLC Stack Light
  PLC Stack Light Logical Reader Name: <a reader name you choose>
  PLC set stack light message name: <must match the name of the outboundMessage; for example, `stacklight` in step 3>
  Enable PLC command optimization: `false`