Halcon算子翻译——dev_set_check

名称

dev_set_check - 指定HDevelop中的错误处理方式。

用法

dev_set_check( : : Mode : )

描述

  dev_set_check指定在发生错误时HDevelop如何应对,即如果算子的返回状态不是H_MSG_TRUE(2)。

  如果Mode的值是'give_error'---这是系统默认值---则一个错误的算子调用会抛出一个异常,这个异常在HDevelop程序中可以被catch语句捕获到。 但是,如果在HDevelop程序中没有周围的try-catch块,而且程序在HDevelop中运行,则程序在错误的算子处停止运行,并且打开错误消息框以显示错误文本。 另外,相应的调用的算子被输入到“算子窗口”中,使得用户可以容易地编辑并且可能修正错误的算子调用的参数。 如果该程序是从HDevEngine调用的,并且该异常未在HDevelop程序中捕获,则会抛出一个HDevEngineException对象,并退出该程序。

  如果Mode设置为'〜give_error',则错误将被忽略,程序继续运行下一个算子。 dev_set_check('〜give_error')旨在与dev_error_var一起使用,dev_error_var可以检查算子调用返回的结果状态。

注意

  使用HDevelop的代码导出功能,为该算子生成的代码可能与相关的HALCON算子具有不同的行为。 有关将HDevelop图形算子(graphics operators)导出为不同编程语言的代码的详细说明,请参阅'HDevelop User's Guide'中的'Code Export -> General Aspects of Code Generation -> Graphics Windows'一章。

参数

Mode (input_control)   string → (string)
  错误处理的模式。
  Default value: 'give_error'

示例(HDevelop)

dev_close_window ()
dev_open_window (0, 0, 512, 512, 'black', WindowHandle)
dev_error_var (Error, 1)
dev_set_check ('~give_error')
FileName := 'wrong_name'
read_image (Image, FileName)
ReadError := Error
if (ReadError != H_MSG_TRUE)
  write_string (WindowHandle, 'wrong file name: '+FileName)
endif
* Now the program will stop with an exception
dev_set_check ('give_error')
read_image (Image, FileName)

结果

如果指定参数的值正确,则dev_set_check返回2(H_MSG_TRUE)。 否则会引发异常并返回错误代码。

Possible Successors

dev_error_var

See also

 set_check, try, catch, endtry

模块

Foundation

HDevelop例程

sock_recv.hdev              Receive image and tuple data via socket connection
projective_trans_image.hdev        Apply projective transformations to an image
get_rectangle_pose_barcode.hdev   Estimate 3D pose of bar codes
get_mposition.hdev          Query mouse position and button status
error_handling_timeout.hdev        Handle grab errors
dev_set_check.hdev           Enable/Disable error handling in HDevelop
dev_error_var.hdev            Catch errors in HDevelop
cbm_sbm.hdev              Compare component-based matching to shape-based matching
cbm_param_visual.hdev          Analyze the parameters of component-based matching
cbm_bin_switch.hdev          Locate a switch and test its state using component-based matching
bottlet.hdev               Train numbers on a beer bottle
3d_position_of_rectangle.hdev     Estimate 3D pose of rectangular objects

posted @ 2017-11-15 11:02  水行  阅读(1273)  评论(0编辑  收藏  举报