/******************************************************************************\
   SLGlobal: Default storage class for global variables | Width: 32
\******************************************************************************/
Int32 Sb1_In_Winkelgeschwindigkeit /* LSB: 2^-16 OFF:  0 MIN/MAX:  -32768 .. 32767.9999847412 */;
Int32 Sb1_Out_Winkel /* LSB: 2^-16 OFF:  0 MIN/MAX:  -32768 .. 32767.9999847412 */;

/*----------------------------------------------------------------------------*\
  PARAMETERIZED MACROS
\*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*\
  FUNCTION PROTOTYPES
\*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*\
  INLINE FUNCTIONS
\*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*\
  FUNCTION DEFINITIONS
\*----------------------------------------------------------------------------*/

/**************************************************************************************************\
 ***  FUNCTION:
 ***      Lagebestimmung
 *** 
 ***  DESCRIPTION:
 ***      
 *** 
 ***  PARAMETERS:
 ***      Type               Name                Description
 ***      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 ***
 ***  RETURNS:
 ***      Void
 ***
 ***  SETTINGS:
 ***
\**************************************************************************************************/
Void Lagebestimmung(Void)
{
   /* SLLocal: Default storage class for local variables | Width: 32 */
   Int32 Sb1_Sum1 /* LSB: 2^-16 OFF:  0 MIN/MAX:  -32768 .. 32767.9999847412 */;
   Int32 Sb3_Switch2 /* LSB: 2^-16 OFF:  0 MIN/MAX:  -32768 .. 32767.9999847412 */;

   /* SLStaticLocalInit: Default storage class for static local variables with initvalue | Width: 32
    */
   static Int32 X_Sb1_Unit_Delay = 0 /* LSB: 2^-16 OFF:  0 MIN/MAX:  -32768 .. 32767.9999847412 */;

   /* Sum: Lagebestimmung/Sum1
      # combined # Gain: Lagebestimmung/Zeitkonstante */
   Sb1_Sum1 = (Int32) (((UInt32) X_Sb1_Unit_Delay) + ((UInt32) (Sb1_In_Winkelgeschwindigkeit / 
    ((Int32) 100))));

   /* Switch: Lagebestimmung/korrigiere_Winkel_03/Switch2
      # combined # Lagebestimmung/korrigiere_Winkel_03/InPort
      # combined # Sum: Lagebestimmung/Sum4 */
   if (Sb1_Sum1 > -205888 /* -3.141592654 */) {
      /* Switch: Lagebestimmung/korrigiere_Winkel_03/Switch1
         # combined # Lagebestimmung/korrigiere_Winkel_03/InPort
         # combined # Sum: Lagebestimmung/Sum4 */
      if (Sb1_Sum1 >= 205888 /* 3.141592654 */) {
         /* # combined # Sum: Lagebestimmung/korrigiere_Winkel_03/Sum4
            # combined # Lagebestimmung/korrigiere_Winkel_03/InPort
            # combined # Sum: Lagebestimmung/Sum4 */
         Sb3_Switch2 = (Int32) (((UInt32) Sb1_Sum1) - 411775);
      }
      else {
         /* # combined # Lagebestimmung/korrigiere_Winkel_03/InPort
            # combined # Sum: Lagebestimmung/Sum4 */
         Sb3_Switch2 = Sb1_Sum1;
      }
   }
   else {
      /* # combined # Sum: Lagebestimmung/korrigiere_Winkel_03/Sum2
         # combined # Lagebestimmung/korrigiere_Winkel_03/InPort
         # combined # Sum: Lagebestimmung/Sum4 */
      Sb3_Switch2 = (Int32) (((UInt32) Sb1_Sum1) + 411775);
   }

   /* TargetLink outport: Lagebestimmung/Out_Winkel 
      # combined # Lagebestimmung/korrigiere_Winkel_03/OutPort */
   Sb1_Out_Winkel = Sb3_Switch2;
   LOG_VAR(b, _Sb1_Out_Winkel, Sb1_Out_Winkel);

   /* Unit delay: Lagebestimmung/Unit Delay 
      # combined # Lagebestimmung/korrigiere_Winkel_03/OutPort */
   X_Sb1_Unit_Delay = Sb3_Switch2;
}