--*****************************************************************************
--                                                                          
--    Copyright 2013 Electroline Equipment Inc                                   
--    All Rights Reserved       
--                                                                          
--                                                                          
--                                                                          
--*****************************************************************************
--    Filename: ELECTROLINE-DHT-TEST.mib
--    Author:   Alain Leclerc
--    Creation Date: 2013.09.06
--*****************************************************************************
--    Description:
--
--	This file contains the SNMPv2 MIB definition of the Configuration branch 
--      for the DHT (3) products.
--		
--*****************************************************************************
--   Revision History:
--   2013.09.06	Alain Leclerc			First Draft
--*****************************************************************************

ELECTROLINE-DHT-TEST-MIB DEFINITIONS ::= BEGIN

IMPORTS
    MODULE-IDENTITY,
    OBJECT-TYPE,
    Integer32
        FROM SNMPv2-SMI
    RowStatus, TruthValue, DateAndTime
        FROM SNMPv2-TC        
    dhtPrivate
        FROM ELECTROLINE-DHT-ROOT-MIB
    DisplayString
    	FROM RFC1213-MIB
    SnmpAdminString
        FROM SNMP-FRAMEWORK-MIB;   -- RFC 3411;   
        
-- ****************************************************************************
-- * Definition of dvmTest Sub-groups
-- ****************************************************************************
dhtTest OBJECT IDENTIFIER
	--STATUS current
	--DESCRIPTION "Group of configuration objects related to all DVM models"
	::= { dhtPrivate 1 } 

dhtAnalogPorts   		OBJECT IDENTIFIER ::= { dhtTest 1 }
dhtDigitalPorts  		OBJECT IDENTIFIER ::= { dhtTest 2 }
dhtMicroControllers 	OBJECT IDENTIFIER ::= { dhtTest 3 }
dhtExternalDevices    	OBJECT IDENTIFIER ::= { dhtTest 4 }


-- ****************
-- * ANALOG VALUES *
-- *****************

currentAnalogValueTable OBJECT-TYPE
     SYNTAX SEQUENCE OF CurrentAnalogValueEntry
     MAX-ACCESS  not-accessible
     STATUS current
     DESCRIPTION
          "Provide Read access to Analog Ports"
     ::= { dhtAnalogPorts 1 }

currentAnalogValueEntry OBJECT-TYPE
     SYNTAX CurrentAnalogValueEntry
     MAX-ACCESS not-accessible
     STATUS current
     DESCRIPTION
          "Analog port index and value"
     INDEX { analogPortId }
     ::= { currentAnalogValueTable 1 }

CurrentAnalogValueEntry ::=
     SEQUENCE
     {
          analogPortId
               INTEGER,

          analogValue
               INTEGER, 
               
          analogPortIdDesc
          	OCTET STRING
     }

analogPortId OBJECT-TYPE
     SYNTAX INTEGER
     MAX-ACCESS read-only
     STATUS current
     DESCRIPTION
          "Index into analog value table, all analog ports are enumerated 
          together starting at zero."
     ::= { currentAnalogValueEntry 1 }

analogValue OBJECT-TYPE
     SYNTAX INTEGER
     MAX-ACCESS read-only
     STATUS current
     DESCRIPTION
          "Returns the current value of the analog port. When calibrated, the displayed value
          is in the unit used for the calibration settings."
     ::= { currentAnalogValueEntry 2 }

analogPortIdDesc OBJECT-TYPE
     SYNTAX OCTET STRING
     MAX-ACCESS read-only
     STATUS current
     DESCRIPTION
          "Returns the name of the current PortId"
     ::= { currentAnalogValueEntry 3 }

analogCalibrationValue OBJECT-TYPE
     SYNTAX INTEGER
     MAX-ACCESS read-write
     STATUS current
     DESCRIPTION
          "Calibration value for portID"
     ::= { dhtAnalogPorts 2 }
     
analogPortToCalibrate OBJECT-TYPE
     SYNTAX INTEGER
     MAX-ACCESS read-write
     STATUS current
     DESCRIPTION
          "portID to calibrate:  Writes analogCalibrationValue first then sets associated portID.
          The analogCalibrationCommit must be set after all ports are calibrated to store the 
          values in non-volatile memory"
     ::= { dhtAnalogPorts 3 }
     
analogCalibrationCommit OBJECT-TYPE
     SYNTAX INTEGER (0..1)
     MAX-ACCESS read-write
     STATUS current
     DESCRIPTION
          "Must be set to 1 after all ports are calibrated in order to store the values in non-volatile 
          memory. The Read command always returns the value 0."
     ::= { dhtAnalogPorts 4 } 
     
analogCalibrationSetDefault OBJECT-TYPE
	SYNTAX INTEGER (0..1)
	MAX-ACCESS read-write
	STATUS current
	DESCRIPTION
		"Set this MIB to 1 to reset all the calibration values to the factory default."
	::= {dhtAnalogPorts 5}
	
currentCalibrationValueTable OBJECT-TYPE
     SYNTAX SEQUENCE OF CurrentCalibrationValueEntry
     MAX-ACCESS  not-accessible
     STATUS current
     DESCRIPTION
          "Provides Read access to Analog Calibration Table."
     ::= { dhtAnalogPorts 6 }

currentCalibrationValueEntry OBJECT-TYPE
     SYNTAX CurrentCalibrationValueEntry
     MAX-ACCESS not-accessible
     STATUS current
     DESCRIPTION
          "Displays the stored analog calibration table content."
     INDEX { analogCalibrationPortId }
     ::= { currentCalibrationValueTable 1 }

CurrentCalibrationValueEntry ::=
     SEQUENCE
     {
          analogCalibrationPortId
               INTEGER,

          rawValue
               INTEGER,

          calibratedValue
               INTEGER,    
               
          calibratedPortIdDesc
          	   OCTET STRING
     }

analogCalibrationPortId OBJECT-TYPE
     SYNTAX INTEGER
     MAX-ACCESS read-only
     STATUS current
     DESCRIPTION
          "Index into analog value table. Each analog port has an entry in the calibration table."
     ::= { currentCalibrationValueEntry 1 }

rawValue OBJECT-TYPE
     SYNTAX INTEGER
     MAX-ACCESS read-only
     STATUS current
     DESCRIPTION
          "Returns a rawValue that corresponds to the calibrated value."
     ::= { currentCalibrationValueEntry 2 }
     
calibratedValue OBJECT-TYPE
     SYNTAX INTEGER
     MAX-ACCESS read-only
     STATUS current
     DESCRIPTION
          "Returns the real display value at calibration time."
     ::= { currentCalibrationValueEntry 3 }
     
calibratedPortIdDesc OBJECT-TYPE
     SYNTAX OCTET STRING
     MAX-ACCESS read-only
     STATUS current
     DESCRIPTION
          "Returns the name of the current PortId."
     ::= { currentCalibrationValueEntry 4 }
      
     	 
-- ****************
-- * DIGITAL VALUES*
-- *****************

currentDigitalStatusTable OBJECT-TYPE
     SYNTAX SEQUENCE OF CurrentDigitalStatusEntry
     MAX-ACCESS  not-accessible
     STATUS current
     DESCRIPTION
          "Provides Read access to Digital Status (Input)Ports."
     ::= { dhtDigitalPorts 1 }

currentDigitalStatusEntry OBJECT-TYPE
     SYNTAX CurrentDigitalStatusEntry
     MAX-ACCESS not-accessible
     STATUS current
     DESCRIPTION
          "Digital Status (Input) port index and value."
     INDEX { statusPortId }
     ::= { currentDigitalStatusTable 1 }

CurrentDigitalStatusEntry ::=
     SEQUENCE
     {
          statusPortId
               INTEGER,

          statusValue
               INTEGER,   
               
          statusPortIdDesc     
			OCTET STRING
     }


statusPortId OBJECT-TYPE
     SYNTAX INTEGER
     MAX-ACCESS read-only
     STATUS current
     DESCRIPTION
          "Index into digital Status value table. All digital ports 
          are enumerated together starting at zero."
     ::= { currentDigitalStatusEntry 1 }

statusValue OBJECT-TYPE
     SYNTAX INTEGER
     MAX-ACCESS read-only
     STATUS current
     DESCRIPTION
          "Current value of the port
          0: Unknown state (read error)
          1: OFF (Inactive)
          2: ON	(Active)
		  Note that inverse polarity is taken into account."
     ::= { currentDigitalStatusEntry 2 }    

statusPortIdDesc OBJECT-TYPE
     SYNTAX OCTET STRING
     MAX-ACCESS read-only
     STATUS current
     DESCRIPTION
          "Returns the name of the current PortId."
     ::= { currentDigitalStatusEntry 3 }
     

currentDigitalControlTable OBJECT-TYPE
     SYNTAX SEQUENCE OF CurrentDigitalControlEntry
     MAX-ACCESS  not-accessible
     STATUS current
     DESCRIPTION
          "Provides Read/Write access to Digital Control (output) Ports."
     ::= { dhtDigitalPorts 2 }

currentDigitalControlEntry OBJECT-TYPE
     SYNTAX CurrentDigitalControlEntry
     MAX-ACCESS not-accessible
     STATUS current
     DESCRIPTION
          "Digital Control (output) port index and value."
     INDEX { controlPortId }
     ::= { currentDigitalControlTable 1 }

CurrentDigitalControlEntry ::=
     SEQUENCE
     {
          controlPortId
               INTEGER,

          controlValue
               INTEGER,
               
          controlPortIdDesc
          	OCTET STRING
     }

controlPortId OBJECT-TYPE
     SYNTAX INTEGER
     MAX-ACCESS read-only
     STATUS current
     DESCRIPTION
          "Index into digital Control value table. All digital ports 
          are enumerated together starting at zero."
     ::= { currentDigitalControlEntry 1 }

controlValue OBJECT-TYPE
     SYNTAX INTEGER
     MAX-ACCESS read-write
     STATUS current
     DESCRIPTION
          "Current value of the digital port
          0: Unknown state (Read Error)
          1: OFF (Inactive)
          2: ON	(Active)
          
          Note that inverse polarity is taken into account."

     ::= { currentDigitalControlEntry 2 }

controlPortIdDesc OBJECT-TYPE
     SYNTAX OCTET STRING
     MAX-ACCESS read-only
     STATUS current
     DESCRIPTION
          "Gives the name of the current PortId"
     ::= { currentDigitalControlEntry 3 }

-- *******************
-- * Micro-Controller *
-- ********************

usmFirmwareVersion OBJECT-TYPE
     SYNTAX OCTET STRING
     MAX-ACCESS read-only
     STATUS current
     DESCRIPTION
          "ID & version of the USM micro-controller.
          The MSB byte represents the firmware ID and the LSB byte the revision number.
          Unavailable indicates a communication problem with the micro-controller"
	::= {dhtMicroControllers 1}

batFirmwareVersion OBJECT-TYPE
     SYNTAX OCTET STRING
     MAX-ACCESS read-only
     STATUS current
     DESCRIPTION
          "ID & version of the Battery micro-controller.
          The MSB byte represents the firmware ID and the LSB byte the revision number.
          Unavailable indicates a communication problem with the micro-controller."
	::= {dhtMicroControllers 2}

reset OBJECT-TYPE
	SYNTAX INTEGER (1..5)
	MAX-ACCESS read-write
	STATUS current
	DESCRIPTION
		"The Read command returns the last DHT reset cause as follows:
		    0: Unknown reset cause (= error while reading).
		    1: Power On reset
		    2: Hard reset
		    3: Soft reset
		    4: Atmel Watchdog reset
		    5: Shutdown reset
		
		Writing a value to this MIB causes the DHT to execute a reset of the
		requested type (Only Hard, Soft and ShutDown are allowed).

		The shutdown reset uses the parameters wakeUpVoltage and wakeUpPortId
		which must be set before setting this MIB to 5."

	::= {dhtMicroControllers 3}

wakeUpVoltage OBJECT-TYPE
	SYNTAX INTEGER
	MAX-ACCESS read-write
	STATUS current
	DESCRIPTION
		"This is the battery voltage at which the DHT automatically 
		wakes up when a shutdown is requested. The specified voltage units must
		match the calibrated units for the selected port."
	::= {dhtMicroControllers 4}

wakeUpPortId OBJECT-TYPE
	SYNTAX INTEGER
	MAX-ACCESS read-write
	STATUS current
	DESCRIPTION
		"Enter the portID corresponding to the battery to be monitored. When
		its voltage rises above the wakeUpVoltage, the DHT restarts.

		Note that although this was designed to be used with the battery voltage, any 
		analog port ID may be selected."
	::= {dhtMicroControllers 5}

spiExternalTest OBJECT-TYPE
	SYNTAX INTEGER {failed(1), passed(2)}
	MAX-ACCESS read-only
	STATUS current
	DESCRIPTION
		"SpiExternalTest returns 1 if an Spi Communication test has failed. 
		 The value 2 is returned if an Spi Communication test has passed."
	::= {dhtExternalDevices 1}

cprTest OBJECT-TYPE
	SYNTAX INTEGER {failed(1), passed(2)}
	MAX-ACCESS read-only
	STATUS current
	DESCRIPTION
		"CprTest returns 1 if an Spi Communication test has failed. 
		 The value 2 is returned if an CprTest has passed."
	::= {dhtExternalDevices 2}

END
