SEMA (FB) ¶ FUNCTION_BLOCK FINAL SEMA This function block realizes a counting semaphore. It is based on the runtime system function SysCpuTestAndSet . A function block of type SEMA is used to manage limited resources. The counter of the semaphore symbolizes the number of resources available. If there is no special parameterization, the semaphore counter has the value one. The resources assigned to the semaphore are accessed with the Request method. This works as long as the counter is not zero at the time of the Request call. The counter is then reduced by one. With the method Release the resource previously called is released and the counter is increased by one. The call of the method Preset adjusts the initial counter of the semaphore in accordance with the requirements. If the method was executed successfully TRUE is returned, else FALSE is returned. A resource may thus only be used if the call Request returns TRUE. InOut: Scope Name Type Initial Input Const ctPreset COUNT 1 Properties: Preset Methods: Init Release Request Structure: Init (Method) Preset (Property) Release (Method) Request (Method)
SEMA.Init (METH) ¶ METHOD PROTECTED Init
SEMA.Preset (PROP) ¶ PROPERTY Preset : COUNT Init value of SEMA
SEMA.Release (METH) ¶ METHOD Release : BOOL InOut: Scope Name Type Return Release BOOL
SEMA.Request (METH) ¶ METHOD Request : BOOL InOut: Scope Name Type Return Request BOOL
GlobalConstants ¶ Constants (GVL) System (GVL)
Constants (GVL) ¶ InOut: Scope Name Type Initial Comment Constant gc_hINVALID HANDLE 0 Invalid Handle gc_pNULL PVOID 0 Invalid Pointer gc_szZERO SIZE 0 Invalid Size gc_ctMAX_COUNT COUNT -1 Invalid Counter Value gc_idMAX_IDENT IDENT -1 Invalid Key Value
System (GVL) ¶ InOut: Scope Name Type Initial Comment Constant gc_eENDIANESS ENDIANESS ENDIANESS.LITTLE The endianness of a this system gc_eSYSTYPE SYSTYPE SYSTYPE.MEDIUM The type system of this system
GlobalVariables ¶ Architecture (GVL)
Architecture (GVL) ¶ InOut: Name Type Initial Comment g_eENDIANESS ENDIANESS CalcEndianess() The endianness of a this system g_eSYSTYPE SYSTYPE CalcSystemType() The system type of this system