Pigeon Agents Development ODR Agent - DatasmithSA/Pigeon-Voice-Training GitHub Wiki

An ODR (Output Data Record) is an asynchronous message over TCP/IP; meaning that once a Task/Voice Application makes an ODR request it will get queued on the voice device instead of being sent immediately. The ODR queue is held either in RAM, or flash persistence can be enabled to safeguard for cases where the battery on the device goes flat. Voice Client/Voice Catalyst processes the ODRs in the queue on a regular interval, attempting to send them to the Pigeon Voice Server when a connection is established. This serves as a safety mechanism for cases where there are dead spots in the wireless network coverage. While the ODRs are being queued and processed, the Task/Voice Application continues its execution without blocking (waiting) for a request from the Pigeon Voice Server. Once the Pigeon Voice Server processes an ODR it will respond to the device with an acknowledgement, at which point Voice Client/Voice Catalyst will delete the ODR from the device's queue. The sending of the acknowledgement back to the device is handled automatically by the Pigeon Voice Server without requiring any coding. ODRs are typically used in cases where a message needs to be sent to the server without requiring any result back e.g. a pick confirmation needs to be sent, but you don't the device operator to wait until the device receives a response from the server.

Developing Pigeon ODR Agents allows you to handle ODR message requests from Vocollect Voice devices. A ODR agent will need to be developed for every type of ODR message request from the device e.g. one for a pick confirmation, another to inform the server that device operator has logged off etc.

In this example we will create a simple ODR agent that writes out the default request details to the console, as well as the input parameters passed in from the Task/Voice Application.

  1. Create a new class in the TCP_IP folder and call it: ODRCountAgent
  2. At the top of the file, add the following using clauses to import the Pigeon Voice SDK namespaces:
    • using Pigeon.Voice.SDK.AgentBase.TCP_IP;
    • using Pigeon.Voice.SDK.Sockets.ODR;
  3. Inherit from the PVOdrAgentBase abstract class located in the Pigeon Voice SDK. This marks your agent class as being an ODR Agent.
  4. Override the abstract Process method of the PVOdrAgentBase class. It is within this method that your own business logic will be coded for the agent e.g. updating the WMS database or performing a calculation etc.
  5. The Process method provides a single input parameter, an PVOdrResponse object which encapsulates both the response and request details. The PVOdrResponse object contains a property called Request which holds a PVSocketRequest object containing all the request details.
  6. In the example below we write the default request properties to the console for display purposes. These properties are common to all request LUT and ODR requests from voice devices.
  7. The custom properties sent by the Task/Voice Application are held within the Request's InputRecordFieldValues property which is simply a generic list of strings. They can also be accessed directly via an a zero based index on the Request's indexer property e.g. response.Request[0] will return the input record's first field/column.
  8. The Pigeon Voice Server will automatically populate an ODR acknowledgment on the response. The acknowledgment will inform Voice Client/Voice Catalyst on the device that the ODR has been processed and can be safely removed off the device's ODR queue. Therefore ODR Agents do not require you to add an output record on the response.

    #region Using Directives

    using System;
    using Pigeon.Voice.SDK.AgentBase.TCP_IP;
    using Pigeon.Voice.SDK.Sockets.ODR;

    #endregion //Using Directives

    public class ODRCountAgent : PVOdrAgentBase
    {
        #region Methods

        public override void Process(PVOdrResponse response)
        {
            //Inputs (do something with them)
            Console.WriteLine(response.Request.ClientIpAddress);
            Console.WriteLine(response.Request.RawMessageContents);
            Console.WriteLine(response.Request.EndOfRecordTerminator);
            Console.WriteLine(response.Request.EndOfRecordSetTerminator);
            Console.WriteLine(response.Request.SocketClientDateTimeFormat);
            Console.WriteLine(response.Request.CommandName);
            Console.WriteLine(response.Request.RequestDateTimeClientOriginalFormat);
            Console.WriteLine(response.Request.RequestDateTimeClient);
            Console.WriteLine(response.Request.RequestDateTimeServer);
            Console.WriteLine(response.Request.DeviceId);
            Console.WriteLine(response.Request.OperatorId);
            Console.WriteLine(response.Request.InputRecordFieldValuesCount);
            response.Request.InputRecordFieldValues.ForEach(fieldValue => Console.WriteLine(fieldValue));

            //ODR confirmation byte will autotmatically be sent back to the voice device.
        }

        #endregion //Methods
    }