Danaher Motion
06/2005
Error Handling
M-SS-005-03 Rev
E
163
If the exception number is not specified, the system associates exceptions
with some numeric value, which can be queried. However, the system will
not guarantee that this value is the same from load to load. Do not make any
assumption about this number. It is a mechanism to maintain the exception
database.
11.4.2. Deletion
All exceptions declared at task level are lost when the task is killed. The
exception declared at the system level (
Common Shared
) can be deleted if
not in use – similar to numeric variables. For example:
DeleteVar MyNote
11.4.3. Assertion
The application asserts (throws) an exception from within an application. The
system behaves like it is a regular (predefined in firmware) application error.
You are able to catch application exception with
TRY/Catch
,
OnError
or
OnSystemError
.
Exception assertion is possible with
THROW
.
THROW
accepts the name of
any defined exception. Other expressions are not allowed to be arguments to
THROW
.
The scope of
THROW
is not limited. It can be executed inside of
Try
,
Catch
,
Finally
, outside the Try block in
OnError
and
OnEvent
. For example:
Dim shared LimitError as Error msg= ”Over travel”
Program
Attach a1
Jog a1 100
While 1
‘check the axis position and assert and error,
‘the system should stop the task and motion
If a1.pfb > 1e10 Then
Throw LimitError
End If
End while
End program
Another example:
Dim shared Error1 as Error msg= ”” ‘ no message
Program
Try
‘ check Input #1 and do not continue
‘ if it’s “1”
If Sys.din.1=1 Then
Throw Error1
End if
Move a1 1e3
Catch Error1
Print “I/O error”
End try
End program