interrupt_operatorinterrupt_operatorInterruptOperatorInterruptOperatorinterrupt_operator (算子名称)

名称

interrupt_operatorinterrupt_operatorInterruptOperatorInterruptOperatorinterrupt_operator — Attempt to interrupt an operator running in a different thread.

参数签名

interrupt_operator( : : HThreadID, Mode : )

Herror interrupt_operator(const Hlong HThreadID, const char* Mode)

Herror T_interrupt_operator(const Htuple HThreadID, const Htuple Mode)

void InterruptOperator(const HTuple& HThreadID, const HTuple& Mode)

static void HSystem::InterruptOperator(Hlong HThreadID, const HString& Mode)

static void HSystem::InterruptOperator(Hlong HThreadID, const char* Mode)

static void HSystem::InterruptOperator(Hlong HThreadID, const wchar_t* Mode)   ( Windows only)

static void HOperatorSet.InterruptOperator(HTuple HThreadID, HTuple mode)

static void HSystem.InterruptOperator(int HThreadID, string mode)

def interrupt_operator(hthread_id: int, mode: str) -> None

描述

interrupt_operatorinterrupt_operatorInterruptOperatorInterruptOperatorInterruptOperatorinterrupt_operator attempts to gracefully interrupt 该算子 currently running in the HALCON thread represented by HThreadIDHThreadIDHThreadIDHThreadIDHThreadIDhthread_id. If that currently running operator supports interruption, it will abort its execution depending on ModeModeModeModemodemode (see below). If the thread is currently not executing any operator, or if the currently running operator does not support interruptions, interrupt_operatorinterrupt_operatorInterruptOperatorInterruptOperatorInterruptOperatorinterrupt_operator is a no-op. The execution of any future operator in the other thread is not affected.

The ID representing a thread can be obtained with get_current_hthread_idget_current_hthread_idGetCurrentHthreadIdGetCurrentHthreadIdGetCurrentHthreadIdget_current_hthread_id.

interrupt_operatorinterrupt_operatorInterruptOperatorInterruptOperatorInterruptOperatorinterrupt_operator supports currently only one type of interruption, which can be set in ModeModeModeModemodemode. Note that the corresponding type must also be supported by 该算子 currently running in the other thread. To determine if an operator is interruptible and which kind of interrupts it supports, please see the "Execution Information" section of 该算子 documentation or query the information using the parameter 'interrupt_mode'"interrupt_mode""interrupt_mode""interrupt_mode""interrupt_mode""interrupt_mode" of 该算子 get_operator_infoget_operator_infoGetOperatorInfoGetOperatorInfoGetOperatorInfoget_operator_info.

Some operators, for which no interruptibility is mentioned in the reference documentation, can still be interrupted at some points of their execution. However, such interruptabilities are not guaranteed and can change without further notice between different versions of HALCON.

'cancel'"cancel""cancel""cancel""cancel""cancel":

Abort the execution of 该算子. All results computed by 该算子 are discarded and the operator returns the error code H_ERR_CANCEL (22).

注意

Note that not all operators support interruption. If a given operator supports interruptions and which modes are supported is described in the execution information section of the reference documentation of the corresponding operator.

Also note that there is no hard guarantee about the granularity of the interruption. The granularity can depend on 该算子, its input data and the speed of the device. It is typically finer than 10 ms.

运行信息

参数表

HThreadIDHThreadIDHThreadIDHThreadIDHThreadIDhthread_id (input_control)  integer HTupleintHTupleHtuple (integer) (int / long) (Hlong) (Hlong)

Thread that runs 该算子 to interrupt.

ModeModeModeModemodemode (input_control)  string HTuplestrHTupleHtuple (string) (string) (HString) (char*)

Interruption mode.

Default: 'cancel' "cancel" "cancel" "cancel" "cancel" "cancel"

List of values: 'cancel'"cancel""cancel""cancel""cancel""cancel"

例程 (HDevelop)

global tuple HThreadID
get_current_hthread_id (HThreadID)
* call some slow operator...

* In a different thread
wait_seconds(2)
* Interrupt the long-running operator in the other thread
interrupt_operator (HThreadID, 'cancel')

结果

If all 该算子 parameters are valid, interrupt_operatorinterrupt_operatorInterruptOperatorInterruptOperatorInterruptOperatorinterrupt_operator returns 2 ( H_MSG_TRUE) . Otherwise an exception is raised.

可能的前置算子

get_current_hthread_idget_current_hthread_idGetCurrentHthreadIdGetCurrentHthreadIdGetCurrentHthreadIdget_current_hthread_id

可替代算子

set_operator_timeoutset_operator_timeoutSetOperatorTimeoutSetOperatorTimeoutSetOperatorTimeoutset_operator_timeout

参考其它

get_current_hthread_idget_current_hthread_idGetCurrentHthreadIdGetCurrentHthreadIdGetCurrentHthreadIdget_current_hthread_id, set_operator_timeoutset_operator_timeoutSetOperatorTimeoutSetOperatorTimeoutSetOperatorTimeoutset_operator_timeout

模块

Foundation