机器视觉 dev_get_exception_data算子
Posted 沧海一笑-dj
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了机器视觉 dev_get_exception_data算子相关的知识,希望对你有一定的参考价值。
00. 目录
01. 概述
dev_get_exception_data - 访问exception元组的元素。
02. 签名
dev_get_exception_data( : : Exception, Name : Value)
03. 描述
算子dev_get_exception_data允许访问由算子catch捕获的exception元组的特定项目。 除了从来都是作为exception元组的第一个元素传递的错误代码外,exception元组的所有其他数据都必须通过算子dev_get_exception_data专门访问。 这是因为提供的数据的顺序和范围在将来的版本中可能会改变,并且可能会因不同的导出代码类型而有所不同。
如果一个算子在HDevelop或HDevEngine中发生错误,则捕获的exception元组包含下面列出的数据项。 这个元组必须传递给参数Exception。 请求的数据位置(slot)的名称必须传递给参数Name。 请求的数据在参数Value中返回。 通过将slot名称的元组传递给Name,可以在dev_get_exception_data的单个调用中请求多个异常数据项。 在这种情况下,相应的数据元组被返回到Value中。 对于不可用的请求项目,算子返回空字符串(’’)。
支持的data slots:
‘error_code’:
HALCON或用户定义的错误代码。 HALCON错误代码列表(代码<10000)可以在“Extension Package Programmer’s Manua”的附录中找到。
‘error_message’:
HALCON错误信息。
‘add_error_code’:
附加的HDevelop特定的错误代码。 这些错误代码指定在HALCON算子(代码= 21000)内还是在算子外部(例如在判断和分配参数表达式期间)是否捕获到错误。 在后一种情况下,错误代码更精确地指定错误类型。 相关的错误代码列在“HDevelop User’s Guide”中。
‘add_error_message’:
更精确地描述HDevelop特定错误的附加错误消息。
‘program_line’:
程序发生错误行的编号。
‘operator’:
抛出异常的算子的名称(如果异常在受保护的程序中抛出,则返回“ - protected - ”而不是算子名称)。
‘call_stack_depth’:
调用堆栈的深度(如果‘main’发生错误则返回深度1)。
‘procedure’:
发生错误的程序的名称。
‘user_data’:
用户定义的exception元组。 如果算子异常被捕获并重新抛出,则这是在throw调用中被追加到捕获的异常元组中的元组。 如果是完全由用户定义的异常,则返回除包含错误代码(> = 30000)的第一个元素之外的所有元组项。 如果没有通过异常元组传递用户数据,则返回一个空元组。 请注意,在同一个dev_get_exception_data调用中,用户数据元组(user data tuple)不能和任何其他异常数据一起请求。
原文描述:
The operator dev_get_exception_data enables to access specific items of an exception tuple that was caught by the operator catch. Except the error code that is always passed as the first element of the exception tuple all other data of the exception tuple has to be accessed exclusively via the operator dev_get_exception_data. This is due to the fact that the order and the extent of the provided data may change in future versions and may vary for the different code exports.
If an operator error occurred within HDevelop or HDevEngine, the caught exception tuple contains the data items listed below. This tuple has to be passed to the parameter Exception. The name of the requested data slot has to be passed to the parameter Name. The requested data is returned in the parameter Value. By passing a tuple of slot names to Name it is possible to request several exception data items in a single call of dev_get_exception_data. In that case a corresponding data tuple is returned in Value. For requested items that are not available an empty string (’’) is returned.
Note that the operator dev_get_exception_data is meant to be used within HDevelop or HDevEngine. Some information is not available when the operator is exported.
Supported data slots:
‘error_code’:
HALCON or user defined error code. A list of HALCON error codes (codes < 10000) can be found in the appendix of the “Extension Package Programmer’s Manual”.
‘add_error_code’:
Additional HDevelop specific error code. These error codes specify whether an error was caught within the HALCON operator (code = 21000) or outside the operator, e.g., during the evaluation and assignment of the parameter expressions. In the latter case the error code specifies the error type more precisely. The relevant error codes are listed in the “HDevelop User’s Guide”.
‘error_message’:
HALCON error message.
‘add_error_message’:
Additional error message that describes the HDevelop specific error more precisely.
‘program_line’:
Number of the program line, where the error occurred.
‘operator’:
Name of the operator that threw the exception (if the exception was thrown in a protected procedure, ‘–protected–’ is returned instead of the operator name).
‘call_stack_depth’:
Depth of the call stack (if the error occurred in ‘main’ a depth of 1 is returned).
‘procedure’:
Name of the procedure where the error occurred.
‘user_data’:
User defined exception tuple. If an operator exception was caught and rethrown, this is the tuple that was appended to the caught exception tuple in the call of throw. In case of a completely user defined exception all tuple items except the first element containing the error code (>= 30000) are returned. If no user data was passed with the exception tuple, an empty tuple is returned. Note, that the user data tuple cannot be requested together with any other exception data in one dev_get_exception_data call.
04. 注意
无
05. 参数
Exception (input_control) exception-array → (integer / string)
包含exception数据或用户定义的错误代码的元组。
Name (input_control) attribute.name(-array) → (string)
请求的exception数据的名称。
Default value: ‘error_code’
List of values: ‘add_error_code’, ‘add_error_message’, ‘call_stack_depth’, ‘error_code’, ‘error_message’, ‘operator’, ‘procedure’, ‘program_line’, ‘user_data’
Value (output_control) attribute.value-array → (integer / string)
请求的exception数据。
06. 结果
如果指定参数的值正确,则dev_get_exception_data(作为算子)返回2(H_MSG_TRUE)。 否则会引发异常并返回错误代码。
HDevelop例程
try_catch.hdev Demonstrate the usage of the exception handling in HDevelop
set_shape_model_timeout.hdev Demonstrate how to use the timeout mechanism for shape-based matching
程序示例
07. 附录
7.1 机器视觉博客汇总
网址:https://dengjin.blog.csdn.net/article/details/116837497
以上是关于机器视觉 dev_get_exception_data算子的主要内容,如果未能解决你的问题,请参考以下文章