<?php
# Generated by the protocol buffer compiler.  DO NOT EDIT!
# NO CHECKED-IN PROTOBUF GENCODE
# source: device.proto

namespace OS\PB;

use UnexpectedValueException;

/**
 ** \@brief  Configures a route to another device, based on its DestinationDeviceId
 * \@version 0.9, full implementation from 1.4
 * \@details This is for a database of one or more networking routes is defined for a DestinationDeviceId (primary key)
 *          and can be updated or deleted at will by the cloud.
 *          
 *          Each device's routing config table only contains the routes of the next device it should know about. 
 *          From 1.4: The maximum number of DeviceRoutes that can be specified is 3 for a single destination.
 *          A DeviceRoutingConfig does the following things:
 *          1. It creates a queue based on the DestinationDeviceId
 *          2. If the DestinationDeviceId and Route DeviceId matches, it is a direct route, it creates a persistent Connection object using the Address details
 *          3. If the DestinationDeviceId and Route DeviceId does not match, it is an indirect route, and is only for informational purposes of which interface to direct traffic 
 *          Connection objects are addressed by serial, hence must always have SerialAddress.
 *          When sending to a DestinationDeviceId, the routes are attempted in order as the way have been defined in the DeviceRoutingConfig repeated Routes field.
 *          If the connection that a route specifies is not in a connected state, then it moves onto the next route.
 *          If that connection is already busy sending some other packet, then it waits for the connection to be free before trying again.
 *          If some other error occurs, then it moves onto the next route.
 *          If a device responds with NACK NoRoute, it will update the DeviceRoutingConfig entry that the Route is bad and generate a BadRoute event for Cloud to resolve.
 *          If the DeviceId in a route reports via a packet (SourceDeviceId) that is different from the configured route, it will generate a DeviceIdMismatch event for Cloud to resolve.
 *
 * Protobuf type <code>OS.PB.DeviceRouteFlags</code>
 */
class DeviceRouteFlags
{
    /**
     * Flags will depend on the behavior of the platform (Cloud Gateways will initiate a connection over RS485 and BLE, MRG will not)
     *
     * Generated from protobuf enum <code>DeviceRouteFlags_NotSet = 0;</code>
     */
    const DeviceRouteFlags_NotSet = 0;
    /**
     * Direct Routes only: Will initiate the connection handshake (overriding default behaviour)
     *
     * Generated from protobuf enum <code>DeviceRoute_Client = 1;</code>
     */
    const DeviceRoute_Client = 1;
    /**
     * Indirect Routes only: This route is flagged as bad for the DeviceRoutingConfig DestinationDeviceId
     *
     * Generated from protobuf enum <code>DeviceRoute_Bad = 8;</code>
     */
    const DeviceRoute_Bad = 8;

    private static $valueToName = [
        self::DeviceRouteFlags_NotSet => 'DeviceRouteFlags_NotSet',
        self::DeviceRoute_Client => 'DeviceRoute_Client',
        self::DeviceRoute_Bad => 'DeviceRoute_Bad',
    ];

    public static function name($value)
    {
        if (!isset(self::$valueToName[$value])) {
            throw new UnexpectedValueException(sprintf(
                    'Enum %s has no name defined for value %s', __CLASS__, $value));
        }
        return self::$valueToName[$value];
    }


    public static function value($name)
    {
        $const = __CLASS__ . '::' . strtoupper($name);
        if (!defined($const)) {
            throw new UnexpectedValueException(sprintf(
                    'Enum %s has no value defined for name %s', __CLASS__, $name));
        }
        return constant($const);
    }
}

