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

namespace OS\PB\DeviceRestartEvent;

use UnexpectedValueException;

/**
 * Protobuf type <code>OS.PB.DeviceRestartEvent.RestartReasonType</code>
 */
class RestartReasonType
{
    /**
     * Generated from protobuf enum <code>RestartReason_NotSet = 0;</code>
     */
    const RestartReason_NotSet = 0;
    /**
     * an action caused the restart
     *
     * Generated from protobuf enum <code>RestartReason_Action = 1;</code>
     */
    const RestartReason_Action = 1;
    /**
     * exiting from DFU caused the reset
     *
     * Generated from protobuf enum <code>RestartReason_DFU = 2;</code>
     */
    const RestartReason_DFU = 2;
    /**
     * DFU rolled back due to instabilities 
     *
     * Generated from protobuf enum <code>RestartReason_DFURollBack = 3;</code>
     */
    const RestartReason_DFURollBack = 3;
    /**
     * debugger instructed device to reset, this can be generally ignored
     *
     * Generated from protobuf enum <code>RestartReason_Debugger = 4;</code>
     */
    const RestartReason_Debugger = 4;
    /**
     * flash erasing timed out
     *
     * Generated from protobuf enum <code>RestartReason_FlashErase = 5;</code>
     */
    const RestartReason_FlashErase = 5;
    /**
     * format action caused device to reset
     *
     * Generated from protobuf enum <code>RestartReason_Format = 6;</code>
     */
    const RestartReason_Format = 6;
    /**
     * below are warnings, indicating something unexpected happened
     *
     * Generated from protobuf enum <code>RestartReason_PowerOn = 10;</code>
     */
    const RestartReason_PowerOn = 10;
    /**
     * below are errors, indicating instabilities
     *
     * Generated from protobuf enum <code>RestartReason_Software = 20;</code>
     */
    const RestartReason_Software = 20;
    /**
     * watchdog was triggered because the dog wasn't fed in time
     *
     * Generated from protobuf enum <code>RestartReason_Watchdog = 21;</code>
     */
    const RestartReason_Watchdog = 21;
    /**
     * cpu lockup was detected and reset
     *
     * Generated from protobuf enum <code>RestartReason_CPUFreeze = 22;</code>
     */
    const RestartReason_CPUFreeze = 22;
    /**
     * below are reported by onedevice
     *
     * Generated from protobuf enum <code>RestartReason_Fatal_KernalPanic = 30;</code>
     */
    const RestartReason_Fatal_KernalPanic = 30;
    /**
     * Received a packet from the cloud and caused a fatal panic while decoding it (memory protection from )
     *
     * Generated from protobuf enum <code>RestartReason_Fatal_PacketFromCloud = 31;</code>
     */
    const RestartReason_Fatal_PacketFromCloud = 31;
    /**
     * Onedevice got into a state where it is not behaving correctly, so it recovered by restarting
     *
     * Generated from protobuf enum <code>RestartReason_Fatal_Recovery = 32;</code>
     */
    const RestartReason_Fatal_Recovery = 32;
    /**
     * onedevice could not write to file system and restarted to free up some space
     *
     * Generated from protobuf enum <code>RestartReason_Fatal_NoFreeSpace = 33;</code>
     */
    const RestartReason_Fatal_NoFreeSpace = 33;

    private static $valueToName = [
        self::RestartReason_NotSet => 'RestartReason_NotSet',
        self::RestartReason_Action => 'RestartReason_Action',
        self::RestartReason_DFU => 'RestartReason_DFU',
        self::RestartReason_DFURollBack => 'RestartReason_DFURollBack',
        self::RestartReason_Debugger => 'RestartReason_Debugger',
        self::RestartReason_FlashErase => 'RestartReason_FlashErase',
        self::RestartReason_Format => 'RestartReason_Format',
        self::RestartReason_PowerOn => 'RestartReason_PowerOn',
        self::RestartReason_Software => 'RestartReason_Software',
        self::RestartReason_Watchdog => 'RestartReason_Watchdog',
        self::RestartReason_CPUFreeze => 'RestartReason_CPUFreeze',
        self::RestartReason_Fatal_KernalPanic => 'RestartReason_Fatal_KernalPanic',
        self::RestartReason_Fatal_PacketFromCloud => 'RestartReason_Fatal_PacketFromCloud',
        self::RestartReason_Fatal_Recovery => 'RestartReason_Fatal_Recovery',
        self::RestartReason_Fatal_NoFreeSpace => 'RestartReason_Fatal_NoFreeSpace',
    ];

    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);
    }
}

