The function block returns information about Speed Limit Alerts(SLA).
Note that the SLA is only valid after an "SLA" event is raised; the event will be removed when this function block is called.
An "SLA" event is raised when SLA is enabled with navSpeedLimitAlertSetup and the speed has been exceeded.
Input:
None.
Output:
time : DINT
The timestamp for the alert.
latitude : DINT
The latitude of the position of the alert.
longitude : DINT
The longitude of the position of the alert.
speed : INT
The speed at the time of the alert.
speed_limit : INT
The speed limit at the time of the alert.
max_speed : INT
The maximum speed since the last alert.
type : SINT
The type of alert:
0
|
- Speeding has begun.
|
1
|
- Speed limit has changed.
|
2
|
- Speeding has ended.
|
3
|
- Internal error.
|
4
|
- Invalid alert. If over 50 alerts have been queued without being received by the RTCU device, the queue is cleared and this alert is added.
Can also happen if changing the SLA setup while driving.
|
ready : BOOL
TRUE:
|
If data is ready.
|
FALSE:
|
If data is not ready.
|
Declaration:
FUNCTION_BLOCK navSpeedLimitAlert;
VAR_OUTPUT
ready : BOOL;
type : SINT;
time : DINT;
latitude : DINT;
longitude : DINT;
speed : INT;
speed_limit : INT;
max_speed : INT;
END_VAR;
Example:
INCLUDE rtcu.inc
VAR
slaRcv : navSpeedLimitAlert;
END_VAR;
FUNCTION ReadSLA;
slaRcv();
IF slaRcv.ready THEN
DebugMsg(message := "*** SLA received ***");
DebugFmt(message := "-time=\4", v4 := slaRcv.time);
DebugFmt(message := "-type=\1", v1 := slaRcv.type);
DebugFmt(message := "-latitude=\4", v4 := slaRcv.latitude);
DebugFmt(message := "-longitude=\4", v4 := slaRcv.longitude);
DebugFmt(message := "-speed=\1", v1 := slaRcv.speed);
DebugFmt(message := "-speed_limit=\1", v1 := slaRcv.speed_limit);
DebugFmt(message := "-max_speed=\1", v1 := slaRcv.max_speed);
END_IF;
END_FUNCTION;
THREAD_BLOCK navMonitor;
VAR
event : INT := 0;
END_VAR;
WHILE event <> -1 DO
event := navWaitEvent(timeout := -1);
CASE event OF
...
15: ReadSLA();
...
END_CASE;
END_WHILE;
END_THREAD_BLOCK;
|