Operator Reference

create_messageT_create_messageCreateMessageCreateMessagecreate_message (Operator)

create_messageT_create_messageCreateMessageCreateMessagecreate_message — Create a new empty message.

Signature

create_message( : : : MessageHandle)

Herror T_create_message(Htuple* MessageHandle)

void CreateMessage(HTuple* MessageHandle)

void HMessage::HMessage()

void HMessage::CreateMessage()

static void HOperatorSet.CreateMessage(out HTuple messageHandle)

public HMessage()

void HMessage.CreateMessage()

def create_message() -> HHandle

Description

create_messagecreate_messageCreateMessageCreateMessagecreate_message creates a new empty message. The output parameter MessageHandleMessageHandleMessageHandlemessageHandlemessage_handle is a handle to the newly created message and is used to identify the message in any subsequent operator call using the message.

The message serves as a dictionary-like container that can be passed between the threads of an application using asynchronous message queues. Alternatively, HALCON also provides dictionaries (create_dictcreate_dictCreateDictCreateDictcreate_dict) to group parameters in programs and procedures.

Messages can store an arbitrary number of entries, each having its unique key (string or integer) and associated value. Each key can refer either to a control parameter tuple or to an iconic object. These data are stored to the message using set_message_tupleset_message_tupleSetMessageTupleSetMessageTupleset_message_tuple or set_message_objset_message_objSetMessageObjSetMessageObjset_message_obj, respectively, from where they can be retrieved again using get_message_tupleget_message_tupleGetMessageTupleGetMessageTupleget_message_tuple or get_message_objget_message_objGetMessageObjGetMessageObjget_message_obj.

The control parameter tuples stored in the message are always deep copies of the original data. The original data can thus be reused immediately after the set_message_tupleset_message_tupleSetMessageTupleSetMessageTupleset_message_tuple call without affecting the message. Notable exceptions are handles: Storing any handle in the message will copy the handle value, but not the resource behind the handle.

As mentioned above, the messages can be passed between the threads of an application using asynchronous message queues. The data can be appended to the queue by multiple producer threads using enqueue_messageenqueue_messageEnqueueMessageEnqueueMessageenqueue_message and retrieved from the queue by multiple receiver threads using dequeue_messagedequeue_messageDequeueMessageDequeueMessagedequeue_message. All these operations are internally properly synchronized. Therefore, the queue can be safely accessed by all producers and consumers without any explicit locking. All the enqueued messages are copied by the enqueue_messageenqueue_messageEnqueueMessageEnqueueMessageenqueue_message operation. The original message(s) can thus be immediately reused after the enqueue_messageenqueue_messageEnqueueMessageEnqueueMessageenqueue_message call without affecting the enqueued copy.

Execution Information

  • Multithreading type: reentrant (runs in parallel with non-exclusive operators).
  • Multithreading scope: global (may be called from any thread).
  • Processed without parallelization.

Parameters

MessageHandleMessageHandleMessageHandlemessageHandlemessage_handle (output_control)  message HMessage, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)

Handle of the newly created message.

Number of elements: MessageHandle == 1

Assertion: MessageHandle != 0

Example (HDevelop)

MessageHandles := []
for idx := 0 to 4 by 1
  create_message (MessageHandle)
  MessageHandles[idx]:= MessageHandle
endfor
* ...

Result

Returns 2 ( H_MSG_TRUE) unless a resource allocation error occurs.

Possible Successors

set_message_tupleset_message_tupleSetMessageTupleSetMessageTupleset_message_tuple, set_message_objset_message_objSetMessageObjSetMessageObjset_message_obj

Alternatives

create_dictcreate_dictCreateDictCreateDictcreate_dict

See also

clear_messageclear_messageClearMessageClearMessageclear_message, set_message_tupleset_message_tupleSetMessageTupleSetMessageTupleset_message_tuple, get_message_tupleget_message_tupleGetMessageTupleGetMessageTupleget_message_tuple, set_message_objset_message_objSetMessageObjSetMessageObjset_message_obj, get_message_objget_message_objGetMessageObjGetMessageObjget_message_obj, set_message_paramset_message_paramSetMessageParamSetMessageParamset_message_param, get_message_paramget_message_paramGetMessageParamGetMessageParamget_message_param, enqueue_messageenqueue_messageEnqueueMessageEnqueueMessageenqueue_message, dequeue_messagedequeue_messageDequeueMessageDequeueMessagedequeue_message

Module

Foundation