ClassesClasses | | Operators

create_messagecreate_messageCreateMessageCreateMessage (Operator)

Name

create_messagecreate_messageCreateMessageCreateMessage — Create a new empty message.

Signature

create_message( : : : MessageHandle)

Herror create_message(Hlong* 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()

Description

create_messagecreate_messageCreateMessageCreateMessageCreateMessage creates a new empty message. The output parameter MessageHandleMessageHandleMessageHandleMessageHandlemessageHandle 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 allowing to store an arbitrary number of values associated with unique keys (strings). 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_tupleSetMessageTupleSetMessageTupleSetMessageTuple or set_message_objset_message_objSetMessageObjSetMessageObjSetMessageObj, respectively, from where they can be retrieved again using get_message_tupleget_message_tupleGetMessageTupleGetMessageTupleGetMessageTuple or get_message_objget_message_objGetMessageObjGetMessageObjGetMessageObj.

The data stored in the message are always deep copies of the original data, being it control parameters or objects. The original data can thus be reused immediately after the set_message_tupleset_message_tupleSetMessageTupleSetMessageTupleSetMessageTuple or set_message_objset_message_objSetMessageObjSetMessageObjSetMessageObj calls without affecting the message. Notable exceptions are handles which are treated as regular integer values by HALCON, therefore storing any handle in the message will copy the handle value, but not the resource behind the handle.

Finally, 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_messageEnqueueMessageEnqueueMessageEnqueueMessage and retrieved from the queue by multiple receiver threads using dequeue_messagedequeue_messageDequeueMessageDequeueMessageDequeueMessage. 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_messageEnqueueMessageEnqueueMessageEnqueueMessage operation. The original message(s) can thus be immediately reused after the enqueue_messageenqueue_messageEnqueueMessageEnqueueMessageEnqueueMessage call without affecting the enqueued copy.

When the message is no more needed, all associated resources, in particular the tuple or object data stored in the message, should be released using clear_messageclear_messageClearMessageClearMessageClearMessage.

Execution Information

Parameters

MessageHandleMessageHandleMessageHandleMessageHandlemessageHandle (output_control)  message HMessage, HTupleHTupleHtuple (integer) (IntPtr) (Hlong) (Hlong)

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
* ...
clear_message (MessageHandles)

Result

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

Possible Successors

set_message_tupleset_message_tupleSetMessageTupleSetMessageTupleSetMessageTuple, set_message_objset_message_objSetMessageObjSetMessageObjSetMessageObj

See also

clear_messageclear_messageClearMessageClearMessageClearMessage, set_message_tupleset_message_tupleSetMessageTupleSetMessageTupleSetMessageTuple, get_message_tupleget_message_tupleGetMessageTupleGetMessageTupleGetMessageTuple, set_message_objset_message_objSetMessageObjSetMessageObjSetMessageObj, get_message_objget_message_objGetMessageObjGetMessageObjGetMessageObj, set_message_paramset_message_paramSetMessageParamSetMessageParamSetMessageParam, get_message_paramget_message_paramGetMessageParamGetMessageParamGetMessageParam, enqueue_messageenqueue_messageEnqueueMessageEnqueueMessageEnqueueMessage, dequeue_messagedequeue_messageDequeueMessageDequeueMessageDequeueMessage

Module

Foundation


ClassesClasses | | Operators