simple_lib.inc

Top  Previous  Next

//-----------------------------------------------------------------------------
// simple_lib.inc
// This file contains the simple library.
//
//-----------------------------------------------------------------------------
 
/*
   @brief A fixed password
   @helpid 10
   @helpfile ExampleLib.chm
   @menu Simple/Configuration
*/
#DEFINE MAIN_PASSWORD "password"
 
VAR
   /*
   Undocumented variable, used to indicate that SimpleLibInit has been called.
   */
   simple_lib_initialized : BOOL := FALSE;
   /*
   @brief A device specific password.
   @helpid 20
   @helpfile ExampleLib.chm
   @menu Simple/Configuration
   */
   generated_password:STRING;
END_VAR;
 
/*
   @brief Initializes this library
   @helpid 100
   @helpfile ExampleLib.chm
   @menu Simple
*/
FUNCTION SimpleLibInit;   
   generated_password:= dintToHex(v:=boardSerialNumber());
   
   simple_lib_initialized := TRUE;
END_FUNCTION;
 
/*
   @brief Prints information about the board to the device output.
   @helpid 110
   @helpfile ExampleLib.chm
   @menu Simple/Info
 
*/
FUNCTION SimpleLibBoardInfo;
VAR
   str:STRING;
END_VAR;
   DebugMsg(message:=" --------------"+"--------- ");
   DebugFmt(message:=" Serial: \4", v4:=boardSerialNumber());
   DebugFmt(message:=" Type  : \1", v1:=boardType());
   str := "Unknown";
   CASE boardSupplyType() OF
      1: str := "Battery";
      2: str := "DC Power";
      3: str := "AC Power";
   END_CASE;
   DebugFmt(message:=" Supply: "+str+", \1.\2 V ", v1:=boardSupplyVoltage()/10, v2:=boardSupplyVoltage() MOD 10);
   DebugFmt(message:=" Temperature: \1.\2 °C ", v1:=boardTemperature()/100, v2:=(boardTemperature()/10) MOD 10);
   
   
   DebugMsg(message:=" --------------"+"--------- ");
END_FUNCTION;