Time Zone Information ¶ The World is divided in time zones which are based on the degrees of longitude. The English town Greenwich is situated in their centre on the so-called prime meridian that defines the starting point for the count of the world’s degrees of longitude. By taking a closer look at a globe, one can distinguish the degrees of longitude and latitude which clasp the world like a grid. The degrees of longitude go from north to south and connect the two poles. The time being measured in the observatory in Greenwich is called GMT which is the abbreviation for Greenwich Mean Time . The GMT serves as a basis for calculating the respecting times in all countries of the world. However nowadays the term GMT is not used any more as it has been replaced by the expression Universal Time Coordinated (UTC). [CC BY-SA 4.0 ( Wikimedia Commons )] GetTimeZoneInformation (FunctionBlock) SetTimeZoneInformation (FunctionBlock)
GetTimeZoneInformation (FB) ¶ FUNCTION_BLOCK GetTimeZoneInformation This function block reads the specific information on the time zone. InOut: Scope Name Type Comment Input xExecute BOOL Rising edge: Action start Falling edge: Resets outputs. If a falling edge occurs before the function block has completed its action, the outputs operate in the usual manner and are only reset if either the action is completed or in the event of an error. In this case, the corresponding output values (xDone, xError, iError) are present at the outputs for exactly one cycle. Output xDone BOOL Action successfully completed xBusy BOOL Function block active xError BOOL TRUE : error occurred, function block aborts action FALSE : no error eError ERROR Error description for diagnosis tziInfo RTCLK_TIME_ZONE_INFO Information on the time zone
SetTimeZoneInformation (FB) ¶ FUNCTION_BLOCK SetTimeZoneInformation With this function block the specific information of the time zone can be modified. The time zone setting will be kept even after a Reset-Origin of the controller and can only be modified by being overwritten again. If no automatic switch is desired, all elements of tziInfo.stStandardDate and tziInfo.stDaylightDate must be set to 0. InOut: Scope Name Type Comment Input xExecute BOOL Rising edge: Action start Falling edge: Resets outputs. If a falling edge occurs before the function block has completed its action, the outputs operate in the usual manner and are only reset if either the action is completed or in the event of an error. In this case, the corresponding output values (xDone, xError, iError) are present at the outputs for exactly one cycle. tziInfo RTCLK_TIME_ZONE_INFO Information on the time zone Output xDone BOOL Action successfully completed xBusy BOOL Function block active xError BOOL TRUE : error occurred, function block aborts action FALSE : no error eError ERROR Error description for diagnosis
Time and Date ¶ Modules of this library support reading and setting of the realtime clock. These modules, however, might not take into account the time zone and a possible switch between summer and standard time. If an automatic switch is desired all the same, the function blocks of the CAA_DTUtility library can be used for reading and setting the realtime clock. In this case the time switch is done via the CAA_DTUtility library . If the runtime system supports the automatic switch between summer and standard time, the calls of the library will be forwarded directly to the corresponding functions of library CAA_RealTimeClock and the clock switch will be done by the runtime system. GetDateAndTime (FunctionBlock) SetDateAndTime (FunctionBlock)
GetDateAndTime (FB) ¶ FUNCTION_BLOCK GetDateAndTime This function block reads the realtime clock. It returns the time of the local time zone (i.e. a possible switch to summer/standard time will be regarded). The current time zone switch can be defined by SetTimeZoneInformation . If a switch to summer/standard time has become necessary since the last polling of the time, this is done automatically. At the start of the module the outputs dtDateAndTime and eTimezone are reset. ( DT#1970-01-01-00:00 and RTCLK_UNKNOWN ). After successful operation they will contain the current local time. InOut: Scope Name Type Comment Input xExecute BOOL Rising edge: Action start Falling edge: Resets outputs. If a falling edge occurs before the function block has completed its Action, the outputs operate in the usual manner and are only reset if either the action is completed or in the event of an error. In this case, the corresponding output values (xDone, xError, iError) are present at the outputs for exactly one cycle. Output xDone BOOL Action successfully completed xBusy BOOL Function block active xError BOOL TRUE : error occurred, function block aborts action FALSE : no error eError ERROR Error description for diagnosis dtDateAndTime DT Current local time eTimezone PERIODE Current time zone
SetDateAndTime (FB) ¶ FUNCTION_BLOCK SetDateAndTime This function block sets the realtime clock. The current local time is passed in the parameter dtDateAndTime . Speciality: If the time is within the not-unique interval shortly after the switch to standard (winter) time, standard time will be assumed. This case occurs for example in the Central European countries, if on the last Sunday of October the time is set at 2:30 a.m.. Here it is not clear, whether 2:30 a.m. is still summer time or already standard (winter) time. In this case the module assumes standard (winter) time. InOut: Scope Name Type Comment Input xExecute BOOL Rising edge: Action start Falling edge: Resets outputs. If a falling edge occurs before the function block has completed its action, the outputs operate in the usual manner and are only reset if either the action is completed or in the event of an error. In this case, the corresponding output values (xDone, xError, iError) are present at the outputs for exactly one cycle. dtDateAndTime DT Current time Output xDone BOOL Action successfully completed xBusy BOOL Function block active xError BOOL TRUE : error occurred, function block aborts action FALSE : no error eError ERROR Error description for diagnosis
TCP_Server (FB) ¶ FUNCTION_BLOCK TCP_Server EXTENDS CBM.LTrig IMPLEMENTS ITCPServer Sets up a server over the ip and port specified in ipAddr and uiPort . A server can handle several connections. The output handle hServer of these function block can be used to establish a connection via TCP_Connection . The output``xDone`` has no meaning. InOut: Scope Name Type Initial Comment Inherited from Input xEnable BOOL TRUE : Action starts FALSE : Action stops, outputs xDone , xBusy , xError are resetted LTrig Output xDone BOOL TRUE : Action successfully completed LTrig xBusy BOOL TRUE : Function block active LTrig xError BOOL TRUE : Error occurred, function block aborts action FALSE : No error LTrig Input ipAddr IP_ADDR STRUCT(sAddr := ‘0.0.0.0’) uiPort UINT Output eError ERROR hServer CAA.HANDLE
TCP_Write (FB) ¶ FUNCTION_BLOCK TCP_Write EXTENDS CBM.ETrigTo This function block serves to write data to the previously established connection given in hConnection . The content of the memory area indicated by pointer pData contains the data to be written. szSize defines the number of bytes to be written. When xDone is set to TRUE the data was written successfully. The time out value has no effect at this function block. InOut: Scope Name Type Comment Inherited from Input xExecute BOOL Rising edge: Action starts Falling edge: Resets outputs If a falling edge occurs before the function block has completed its action, the outputs operate in the usual manner and are only reset if either the action is completed or in the event of an error. In this case, the corresponding output values ( xDone , xError ) are present at the outputs for exactly one cycle. ETrigTo udiTimeOut UDINT Defines the time (µs) after which an FB (e.g. requiring an external acknowledgement) aborts operation due to a timeout with error message. ETrigTo Output xDone BOOL TRUE : Action successfully completed ETrigTo xBusy BOOL TRUE : Function block active ETrigTo xError BOOL TRUE : Error occurred, function block aborts action FALSE : No error ETrigTo Input hConnection CAA.HANDLE szSize CAA.SIZE pData CAA.PVOID Output eError ERROR
TCP_WriteBuffer (FB) ¶ FUNCTION_BLOCK TCP_WriteBuffer EXTENDS CBM.ETrigTo Like TCP_Write this function block serves to write data to the previously established connection given in hConnection . Instead of a pointer to the data, this function block expects a handle of the buffer containing the data to be written. The buffer is passed on and not copied like at TCP_Write . The time out value has no effect at this function block. InOut: Scope Name Type Comment Inherited from Input xExecute BOOL Rising edge: Action starts Falling edge: Resets outputs If a falling edge occurs before the function block has completed its action, the outputs operate in the usual manner and are only reset if either the action is completed or in the event of an error. In this case, the corresponding output values ( xDone , xError ) are present at the outputs for exactly one cycle. ETrigTo udiTimeOut UDINT Defines the time (µs) after which an FB (e.g. requiring an external acknowledgement) aborts operation due to a timeout with error message. ETrigTo Output xDone BOOL TRUE : Action successfully completed ETrigTo xBusy BOOL TRUE : Function block active ETrigTo xError BOOL TRUE : Error occurred, function block aborts action FALSE : No error ETrigTo Input hConnection CAA.HANDLE hBuffer CAA.HANDLE Output eError ERROR
UDP ¶ UDP_Peer (FunctionBlock) UDP_Receive (FunctionBlock) UDP_ReceiveBuffer (FunctionBlock) UDP_Send (FunctionBlock) UDP_SendBuffer (FunctionBlock)