示例#1
0
    def on_message(self, connMgr, message):

        try:
            # Display the XML representation of the received message
            libgmsec_python3.log_info(
                "[ExampleCallback:on_message] Received:\n" + message.to_XML())

            # Construct Reply subject.
            component = ""

            try:
                component = message.get_string_field("COMPONENT").get_value()

            except GmsecError as e:
                libgmsec_python3.log_warning(
                    "COMPONENT field is not available: " + str(e))

            # Set Status Code to indicate Successful Completion.
            # The GMSEC Interface Specification Document defines 6
            # unique STATUS-CODE values:
            # 1 - Acknowledgement
            # 2 - Working/keep alive
            # 3 - Successful completion
            # 4 - Failed completion
            # 5 - Invalid request
            # 6 - Final message
            # If an asynchronous requestor is awaiting a reply, the
            # ReplyCallback in use will remain active for multiple
            # messages, so long as the messages it receives contain
            # a STATUS-CODE of either 1 or 2.
            status_code = "3"

            # Create the reply subject.
            # See API Interface Specificaiton Document for
            # more information on Reply Message subjects.
            # Generally speaking, they are composed
            # accordingly:
            # [Spec].[Mission].[Satellite ID].
            # [Message Type].[Component Name].[Status Code]

            reply_subject = "GMSEC.MISSION.SAT_ID.RESP.REPLY_ASYNC." + status_code

            reply = libgmsec_python3.Message(reply_subject,
                                             libgmsec_python3.Message.REPLY)

            # Add fields to the reply message
            reply.add_field("COMPONENT", component)
            reply.add_field("ANSWER", "Sure looks like it!")

            # Display XML representation of reply message
            libgmsec_python3.log_info("Prepared Reply:\n" + reply.to_XML())

            # Send Reply
            connMgr.reply(message, reply)

            self.replySent = True

        except libgmsec_python3.GmsecError as e:
            libgmsec_python3.log_error("[ExampleCallback::on_message] " +
                                       str(e))
示例#2
0
    def on_event(self, connMgr, status, event):
        # Print the status of publish operations.  This includes counts
        # for successes, warnings, and errors.
        libgmsec_python3.log_info(status.get_reason())

        if (status.is_error()):
            libgsmsec_python.log_error(
                "The first occurrence of a WebSphere MQ Asynchronous Put Response warning or failure returned the WebSphere Reason Code: "
                + status.get_custom_code())

        self.eventFired = True
示例#3
0
def publishTestMessage(connMgr, subject):

    i = 123

    # Create a Message object
    message = libgmsec_python3.Message(subject,
                                       libgmsec_python3.Message.PUBLISH)

    # Add fields to the Message
    message.add_field("F", False)
    message.add_field(libgmsec_python3.I32Field("I", i))
    message.add_field(libgmsec_python3.U16Field("K", i))
    message.add_field("S", "This is a test")
    message.add_field(libgmsec_python3.F32Field("D", 1 + 1. / i))
    message.add_field(libgmsec_python3.BinaryField("X", "JLMNOPQ", 7))

    # Publish Message
    connMgr.publish(message)

    # Output the Message's XML string representation by invoking Log macro
    libgmsec_python3.log_info("Sent:\n" + message.to_XML())
    def on_message(self, connection, message):
        try:
            libgmsec_python3.log_info("Received a message with subject: " +
                                      message.get_subject())

            libgmsec_python3.log_info("Field Name (Field Type): Field Value")
            iter = message.get_field_iterator()

            while (iter.has_next()):
                field = iter.next()

                # Extract the Field Name, Type, and Value (As
                # a string, to print)
                #
                # Note: 'getter' functions are also defined for
                # Integer, Unsigned Integer, and Double values.
                libgmsec_python3.log_info(field.get_name() + " (" +
                                          typeToString(field.get_type()) +
                                          "): " + field.get_string_value())

                # Field objects can also be converted to
                # specific Field types prior to retrieval of
                # the value contained in the Field.  This is
                # useful for ensuring that data types do not
                # lose any level of precision, but requires
                # a more intricate implementation.
                #
                # See the get_fieldValue() function (commented
                # out at the bottom of this example program)
                # for an example of how field can be done.

        except libgmsec_python3.GmsecError as e:
            libgmsec_python3.log_error(str(e))
示例#5
0
def main():

    if (len(sys.argv) <= 1):
        usageMessage = "usage: " + sys.argv[0] + " mw-id=<middleware ID>"
        print(usageMessage)
        return -1

    # Load the command-line input into a GMSEC Config object
    # A Config object is basically a key-value pair map which is used to
    # pass configuration options into objects such as Connections,
    # ConnectionManagers, Subscribe and Publish function calls, Messages,
    # etc.
    config = libgmsec_python3.Config(sys.argv)

    # Since this example program uses an invalid message, we ensure the
    # validation check is disabled.
    config.add_value("gmsec-msg-content-validate-all", "false")

    # If it was not specified in the command-line arguments, set LOGLEVEL
    # to 'INFO' and LOGFILE to 'stdout' to allow the program report output
    # on the terminal/command line
    initializeLogging(config)

    # Output GMSEC API version
    libgmsec_python3.log_info(
        libgmsec_python3.ConnectionManager.get_API_version())

    try:
        # Create the Connection
        connMgr = libgmsec_python3.ConnectionManager(config)

        # Connect
        connMgr.initialize()

        # output connection middleware version
        libgmsec_python3.log_info(connMgr.get_library_version())

        # Subscribe
        cb = ExampleCallback()

        connMgr.subscribe(DEFAULT_REQUEST_SUBJECT, cb)
        libgmsec_python3.log_info("Subscribed to: " + DEFAULT_REQUEST_SUBJECT)

        # Start the AutoDispatcher to begin async message receipt
        connMgr.start_auto_dispatch()

        # Loop while waiting for the asynchronous response until done
        while (cb.replySent == False):
            libgmsec_python3.TimeUtil.millisleep(100)

        # Clean up
        connMgr.stop_auto_dispatch()

        connMgr.cleanup()

    except libgmsec_python3.GmsecError as e:
        libgmsec_python3.log_error(str(e))

    return 0
示例#6
0
    def on_event(self, connMgr, status, event):
        if (event == libgmsec_python3.Connection.CONNECTION_SUCCESSFUL_EVENT):
            libgmsec_python3.log_info(
                "[on_event]: Connected to the middleware server")

        elif (event == libgmsec_python3.Connection.CONNECTION_BROKEN_EVENT):
            libgmsec_python3.log_info(
                "[on_event]: Connection to the middleware lost or terminated")

        elif (event == libgmsec_python3.Connection.CONNECTION_RECONNECT_EVENT):
            libgmsec_python3.log_info(
                "[on_event]: Attempting to reestablish the connection to the middleware"
            )

        else:
            libgmsec_python3.log_info("[on_event]: " + status.get())
示例#7
0
def main():

    if (len(sys.argv) <= 1):
        usageMessage = "usage: " + sys.argv[0] + " mw-id=<middleware ID>"
        print(usageMessage)
        return -1

    # Load the command-line input into a GMSEC Config object
    # A Config object is basically a key-value pair map which is used to
    # pass configuration options into objects such as Connections,
    # ConnectionManagers, Subscribe and Publish function calls, Messages,
    # etc.
    config = libgmsec_python3.Config(sys.argv)

    # Since this example program uses an invalid message, we ensure the
    # validation check is disabled.
    config.add_value("gmsec-msg-content-validate-all", "false")

    # If it was not specified in the command-line arguments, set LOGLEVEL
    # to 'INFO' and LOGFILE to 'stdout' to allow the program report output
    # on the terminal/command line
    initializeLogging(config)

    # Print the GMSEC API version number using the GMSEC Logging
    # interface
    # This is useful for determining which version of the API is
    # configured within the environment
    libgmsec_python3.log_info(
        libgmsec_python3.ConnectionManager.get_API_version())

    try:
        # Create a ConnectionManager object
        # This is the linchpin for all communications between the
        # GMSEC API and the middleware server
        connMgr = libgmsec_python3.ConnectionManager(config)

        # Open the connection to the middleware
        libgmsec_python3.log_info(
            "Opening the connection to the middleware server")
        connMgr.initialize()

        # Output middleware client library version
        libgmsec_python3.log_info(connMgr.get_library_version())

        libgmsec_python3.log_info(
            "Publishing two messages -- One will be received by the subscriber the other will be filtered out"
        )

        # Create a message which will be received by the subscriber
        # in this set of example programs

        message = libgmsec_python3.Message(EXAMPLE_MESSAGE_SUBJECT,
                                           libgmsec_python3.Message.PUBLISH)
        populateMessage(message)
        # Publish the message to the middleware bus
        connMgr.publish(message)

        # Display the XML string representation of the Message for
        # the sake of review
        libgmsec_python3.log_info("Published message:\n" + message.to_XML())

        # Create a message which will NOT be received by the subscriber
        # in this set of example programs

        message = libgmsec_python3.Message(FILTERED_MESSAGE_SUBJECT,
                                           libgmsec_python3.Message.PUBLISH)
        populateMessage(message)

        # Publish the message to the middleware bus
        connMgr.publish(message)

        # Display the XML string representation of the Message for
        # the sake of review
        libgmsec_python3.log_info("Published message:\n" + message.to_XML())

        # Disconnect from the middleware and clean up the Connection
        connMgr.cleanup()

    except libgmsec_python3.GmsecError as e:
        libgmsec_python3.log_error(str(e))
        return -1

    return 0
示例#8
0
def main():

    if (len(sys.argv) <= 1):
        usageMessage = "usage: " + sys.argv[0] + " mw-id=<middleware ID>"
        print(usageMessage)
        return -1

    # Load the command-line input into a GMSEC Config object
    # A Config object is basically a key-value pair map which is used to
    # pass configuration options into objects such as Connections,
    # ConnectionManagers, Subscribe and Publish function calls, Messages,
    # etc.
    config = libgmsec_python3.Config(sys.argv)

    # If it was not specified in the command-line arguments, set LOGLEVEL
    # to 'INFO' and LOGFILE to 'stdout' to allow the program report output
    # on the terminal/command line
    initializeLogging(config)

    # Print the GMSEC API version number using the GMSEC Logging
    # interface
    # This is useful for determining which version of the API is
    # configured within the environment
    libgmsec_python3.log_info(
        libgmsec_python3.ConnectionManager.get_API_version())

    try:
        # Create a ConnectionManager object
        connManager = libgmsec_python3.ConnectionManager(config)

        # Open the connection to the middleware
        libgmsec_python3.log_info(
            "Opening the connection to the middleware server")
        connManager.initialize()

        # Output middleware client library version
        libgmsec_python3.log_info(connManager.get_library_version())

        # Begin the steps necessary to create a GMSEC-compliant LOG
        # message using the ConnectionManager

        # Create all of the GMSEC Message header Fields which will
        # be used by all GMSEC Messages

        # Note: Since these Fields contain variable values which are
        # based on the context in which they are used, they cannot be
        # automatically populated using MistMessage.
        definedFields = libgmsec_python3.FieldList()

        missionField = libgmsec_python3.StringField("MISSION-ID", "MISSION")
        # Note: SAT-ID-PHYSICAL is an optional header Field, according
        # to the GMSEC ISD.
        satIdField = libgmsec_python3.StringField("SAT-ID-PHYSICAL",
                                                  "SPACECRAFT")
        facilityField = libgmsec_python3.StringField("FACILITY", "GMSEC Lab")
        componentField = libgmsec_python3.StringField("COMPONENT",
                                                      "log_message")

        definedFields.append(missionField)
        definedFields.append(satIdField)
        definedFields.append(facilityField)
        definedFields.append(componentField)

        # Use set_standard_fields to define a set of header fields for
        # all messages which are created or published on the
        # ConnectionManager using the following functions:
        # create_log_message, publish_log, create_heartbeat_message,
        # start_heartbeat_service, create_resource_message,
        # publishResourceMessage, or start_resource_message_service
        connManager.set_standard_fields(definedFields)

        # Use MistMessage to construct a GMSEC LOG message based off
        # of the latest XML templates provided with the GMSEC API.
        # This will automatically populate the Message with all of the
        # Fields which have specific values defined for them in the XML
        # template files.  For more information on which Fields have
        # values defined for them, please review the XML template files
        # located in GMSEC_API/templates.

        # Note: The second parameter is an identifier for the type of
        # message to construct.
        logMsg = libgmsec_python3.MistMessage(LOG_MESSAGE_SUBJECT, "MSG.LOG",
                                              connManager.get_specification())

        # Add the LOG-specific fields to the LOG message

        # Note: Since these Fields contain variable values which are
        # based on the context in which they are used, they cannot be
        # automatically populated using MistMessage.
        eventTime = libgmsec_python3.TimeUtil.format_time(
            libgmsec_python3.TimeUtil.get_current_time())

        logMsg.add_field(libgmsec_python3.I16Field("SEVERITY", 1))
        logMsg.set_value("MSG-TEXT", "Creating an example GMSEC LOG Message")
        logMsg.set_value("OCCURRENCE-TYPE", "SYS")
        logMsg.set_value("SUBCLASS", "AST")
        logMsg.set_value("EVENT-TIME", eventTime)

        # Add the standard fields to the LOG message
        connManager.add_standard_fields(logMsg)

        libgmsec_python3.log_info("Publishing LOG message:\n" +
                                  logMsg.to_XML())
        connManager.publish(logMsg)

    except libgmsec_python3.GmsecError as e:
        libgmsec_python3.log_error(str(e))
        return -1

    return 0
示例#9
0
def main():
    
    if(len(sys.argv) <= 1):
        usageMessage = "usage: " +  sys.argv[0] + " mw-id=<middleware ID>"
        print(usageMessage)
        return -1


    # Load the command-line input into a GMSEC Config object
    # A Config object is basically a key-value pair map which is used to
    # pass configuration options into objects such as Connections,
    # ConnectionManagers, Subscribe and Publish function calls, Messages,
    # etc.
    config = libgmsec_python3.Config(sys.argv)

    # If it was not specified in the command-line arguments, set LOGLEVEL
    # to 'INFO' and LOGFILE to 'stdout' to allow the program report output
    # on the terminal/command line
    initializeLogging(config)

    # Print the GMSEC API version number using the GMSEC Logging
    # interface
    # This is useful for determining which version of the API is
    # configured within the environment
    libgmsec_python3.log_info(libgmsec_python3.ConnectionManager.get_API_version())

    try:
        # Create a ConnectionManager object
        connManager = libgmsec_python3.ConnectionManager(config)

        # Open the connection to the middleware
        libgmsec_python3.log_info("Opening the connection to the middleware server")
        connManager.initialize()

        # Output middleware client library version
        libgmsec_python3.log_info(connManager.get_library_version())

        # Create all of the GMSEC Message header Fields which will
        # be used by all GMSEC Messages
                
        # Note: Since these Fields contain variable values which are
        # based on the context in which they are used, they cannot be
        # automatically populated using MistMessage.
        definedFields = libgmsec_python3.FieldList() 

        missionField = libgmsec_python3.StringField("MISSION-ID", "MISSION")
        # Note: SAT-ID-PHYSICAL is an optional header Field, according

        satIdField = libgmsec_python3.StringField("SAT-ID-PHYSICAL", "SPACECRAFT")
        facilityField = libgmsec_python3.StringField("FACILITY", "GMSEC Lab")
        componentField = libgmsec_python3.StringField("COMPONENT", "product_message")

        definedFields.append(missionField)
        definedFields.append(satIdField)
        definedFields.append(facilityField)
        definedFields.append(componentField)

        # Use set_standard_fields to define a set of header fields for
        # all messages which are created or published on the
        # ConnectionManager using the following functions:
        # create_log_message, publish_log, create_heartbeat_message,
        # start_heartbeat_service, create_resource_message, 
        # publishResourceMessage, or start_resource_message_service
        connManager.set_standard_fields(definedFields)

        # Create a ProductFile object with the product name,
        # description, version, file format, and the URI
        externalFile = libgmsec_python3.ProductFile("External File", "External File Description", "1.0.0", "TXT", "//hostname/dir/filename")

        filePayload = bytearray()
    
        for i in range(0, 256):
            filePayload.append(i)

        # Create a ProductFile object with the product name,
        # description, version, format, binary array, and file size
        binaryFile = libgmsec_python3.ProductFile("File as Binary", "Binary File Description", "1.0.0", "BIN", filePayload, len(filePayload))

        # Create a Product File Message with the subject,
        # RESPONSE-STATUS Field value, Message type (publish, request,
        # or reply), PROD-TYPE Field value, PROD-SUBTYPE Field value,
        # and pass it the Specification object from the Connection
        # Manager
        productMessage = libgmsec_python3.ProductFileMessage(PROD_MESSAGE_SUBJECT, libgmsec_python3.ResponseStatus.SUCCESSFUL_COMPLETION, libgmsec_python3.Message.PUBLISH, "AUTO", "DM", connManager.get_specification())
        productMessage.add_product_file(externalFile)
        productMessage.add_product_file(binaryFile)

        connManager.add_standard_fields(productMessage)

        libgmsec_python3.log_info("Publishing DEV message:\n" + productMessage.to_XML())
        connManager.publish(productMessage)
        
    except libgmsec_python3.GmsecError as e:
        libgmsec_python3.log_error(str(e))
        return -1

    return 0
示例#10
0
def main():

    if (len(sys.argv) <= 1):
        usageMessage = "usage: " + sys.argv[0] + " mw-id=<middleware ID>"
        print(usageMessage)
        return -1

    cb = AsyncStatusCheckCallback()

    # Load the command-line input into a GMSEC Config object
    # A Config object is basically a key-value pair map which is used to
    # pass configuration options into objects such as Connections,
    # ConnectionManagers, Subscribe and Publish function calls, Messages,
    # etc.
    config = libgmsec_python3.Config(sys.argv)

    # Since this example program uses an invalid message, we ensure the
    # validation check is disabled.
    config.add_value("gmsec-msg-content-validate-all", "false")

    # If it was not specified in the command-line arguments, set LOGLEVEL
    # to 'INFO' and LOGFILE to 'stdout' to allow the program report output
    # on the terminal/command line
    initializeLogging(config)

    # Toggle the WebSphere MQ client libraries-level asynchronous publish
    # functionality on
    config.add_value("MW-ASYNC-PUBLISH", "true")

    # Toggle the periodic WebSphere MQ asynchronous publish status report
    # functionality on.  The GMSEC API Connection will periodically fire
    # off an Event which will trigger the on_event function of an
    # EventCallback registered to the event labeled,
    # Connection::WSMQ_ASYNC_STATUS_CHECK_EVENT
    config.add_value("MW-ASYNC-STATUS-CHECK", "true")

    # Additionally, the "MW-ASYNC-STATUS-CHECK-MESSAGE-INTERVAL"
    # configuration option can be used to instruct the GMSEC Connection
    # on how frequently (in number of publish operations) it should
    # periodically fire the WSMQ_ASYNC_STATUS_CHECK_EVENT. By default, it
    # will fire once every 100 messages.
    # For the sake of this example, we will use 500 messages.
    config.add_value("MW-ASYNC-STATUS-CHECK-MESSAGE-INTERVAL", "500")

    # Print the GMSEC API version number using the GMSEC Logging
    # interface
    libgmsec_python3.log_info(
        libgmsec_python3.ConnectionManager.get_API_version())

    try:
        # Create the Connection
        connMgr = libgmsec_python3.ConnectionManager(config)

        # Connect
        connMgr.initialize()

        # Register the event callback with the connection to catch
        # the WebSphere asynchronous publish status events which are
        # eminated from the API
        connMgr.register_event_callback(
            libgmsec_python3.Connection.WSMQ_ASYNC_STATUS_CHECK_EVENT, cb)
        # Output middleware version
        libgmsec_python3.log_info("Middleware version = " +
                                  connMgr.get_library_version())

        libgmsec_python3.log_info("Publishing messages using the subject: " +
                                  EXAMPLE_MESSAGE_SUBJECT)

        # Create a GMSEC Message object
        message = libgmsec_python3.Message(EXAMPLE_MESSAGE_SUBJECT,
                                           libgmsec_python3.Message.PUBLISH)

        # Publish message as quickly as possible
        # (i.e. No sleep operation between each publish operation)
        count = 0
        while (not cb.eventFired):
            # Populate the Message with fields, increment a
            # counter so that a publisher can track how many
            # messages were published (if they are interested)
            count += 1
            populateMessage(message, count)

            # Publish the message to the middleware bus
            connMgr.publish(message)

            # Note: We do not recommend printing the output of a
            # message when publishing it while using the WebSphere
            # async publish functionality, as it is
            # counter-intuitive to take take up CPU resources
            # performing I/O operations when attempting to achieve
            # high message throughput rates. As such, if you want
            # to analyze the messages published by this program,
            # we recommend you execute GMSEC_API/bin/gmsub to
            # receive the messages.

        libgmsec_python3.log_info(
            "Event detected, ending example demonstration")

        # Clean up the ConnectionManager before exiting the program
        connMgr.cleanup()

    except libgmsec_python3.GmsecError as e:
        libgmsec_python3.log_error(str(e))
        return -1

    return 0
示例#11
0
def main():

    if (len(sys.argv) <= 1):
        usageMessage = "usage: " + sys.argv[0] + " mw-id=<middleware ID>"
        print(usageMessage)
        return -1

    # Load the command-line input into a GMSEC Config object
    # A Config object is basically a key-value pair map which is used to
    # pass configuration options into objects such as Connections,
    # ConnectionManagers, Subscribe and Publish function calls, Messages,
    # etc.
    config = libgmsec_python3.Config(sys.argv)

    # If it was not specified in the command-line arguments, set LOGLEVEL
    # to 'INFO' and LOGFILE to 'stdout' to allow the program report output
    # on the terminal/command line
    initializeLogging(config)

    # Print the GMSEC API version number using the GMSEC Logging
    # interface
    # This is useful for determining which version of the API is
    # configured within the environment
    libgmsec_python3.log_info(
        libgmsec_python3.ConnectionManager.get_API_version())

    try:
        # Create a ConnectionManager object
        # This is the linchpin for all communications between the
        # GMSEC API and the middleware server
        connMgr = libgmsec_python3.ConnectionManager(config)

        # Open the connection to the middleware
        libgmsec_python3.log_info(
            "Opening the connection to the middleware server")
        connMgr.initialize()

        # Output middleware client library version
        libgmsec_python3.log_info(connMgr.get_library_version())

        # Set up a subscription to listen for Messages with the topic
        # "GMSEC.TEST.PUBLISH" which are published to the middleware
        # bus
        # Subscription subject wildcard syntax:
        # * - Matches any one token separated by periods in a subject
        # > - Reading left to right, matches everything up to and ONE
        #     or more tokens in a subject
        # + - Reading left to right, matches everything up to and ZERO
        #     or more tokens in a subject
        # For more information on wildcards, please see the GMSEC API
        # User's Guide
        libgmsec_python3.log_info("Subscribing to the topic: " +
                                  EXAMPLE_SUBSCRIPTION_SUBJECT)
        connMgr.subscribe(EXAMPLE_SUBSCRIPTION_SUBJECT)

        # Call receive() to synchronously retrieve a message that has
        # been received by the middleware client libraries
        # Timeout periods:
        # -1 - Wait forever
        #  0 - Return immediately
        # >0 - Time in milliseconds before timing out
        libgmsec_python3.log_info("Waiting to receive a Message")
        message = connMgr.receive(-1)

        # Example error handling for calling receive() with a timeout
        if (message != None):
            libgmsec_python3.log_info("Received message:\n" + message.to_XML())

            # Dispose of the received message
            connMgr.release(message)

        # Disconnect from the middleware and clean up the Connection
        connMgr.cleanup()

    except libgmsec_python3.GmsecError as e:
        libgmsec_python3.log_error(str(e))
        return -1

    return 0
示例#12
0
 def on_message(self, connection, message):
     libgmsec_python3.log_info("[ExampleCallback.on_message] Received:\n" +
                               message.to_XML())
     self.receivedMessage = True
示例#13
0
def displayMessage(msg, description):

    xml = msg.to_XML()
    libgmsec_python3.log_info(description + "\n" + xml)
示例#14
0
def main():

    if (len(sys.argv) <= 1):
        usageMessage = "usage: " + sys.argv[0] + " mw-id=<middleware ID>"
        print(usageMessage)
        return -1

    # Load the command-line input into a GMSEC Config object
    # A Config object is basically a key-value pair map which is used to
    # pass configuration options into objects such as Connections,
    # ConnectionManagers, Subscribe and Publish function calls, Messages,
    # etc.
    config = libgmsec_python3.Config(sys.argv)

    # If it was not specified in the command-line arguments, set LOGLEVEL
    # to 'INFO' and LOGFILE to 'stdout' to allow the program report output
    # on the terminal/command line
    initializeLogging(config)

    # Print the GMSEC API version number using the GMSEC Logging
    # interface
    # This is useful for determining which version of the API is
    # configured within the environment
    libgmsec_python3.log_info(
        libgmsec_python3.ConnectionManager.get_API_version())

    try:
        # Create a ConnectionManager object
        connManager = libgmsec_python3.ConnectionManager(config)

        # Open the connection to the middleware
        libgmsec_python3.log_info(
            "Opening the connection to the middleware server")
        connManager.initialize()

        # Output middleware client library version
        libgmsec_python3.log_info(connManager.get_library_version())

        # Create all of the GMSEC Message header Fields which will
        # be used by all GMSEC Messages
        headerFields = libgmsec_python3.FieldList()

        version = connManager.get_specification().get_version()

        missionField = libgmsec_python3.StringField("MISSION-ID", "MY-MISSION")
        facilityField = libgmsec_python3.StringField("FACILITY", "MY-FACILITY")
        componentField = libgmsec_python3.StringField("COMPONENT",
                                                      "RESOURCE-SERVICE")
        domain1Field = libgmsec_python3.StringField("DOMAIN1", "MY-DOMAIN-1")
        domain2Field = libgmsec_python3.StringField("DOMAIN2", "MY-DOMAIN-2")
        msgID = libgmsec_python3.StringField("MSG-ID", "MY-MSG-ID")

        headerFields.append(missionField)
        headerFields.append(facilityField)
        headerFields.append(componentField)

        if (version == 201400):
            headerFields.append(msgID)

        elif (version >= 201800):
            headerFields.append(domain1Field)
            headerFields.append(domain2Field)

        # Use set_standard_fields to define a set of header fields for
        # all messages which are created or published on the
        # ConnectionManager using the following functions:
        # create_log_message, publish_log, create_heartbeat_message,
        # start_heartbeat_service, create_resource_message,
        # publishResourceMessage, or start_resource_message_service
        connManager.set_standard_fields(headerFields)

        # Create and publish a Resource message using
        # create_resource_message() and publish()

        # Note: This is useful for applications which may need to add
        # additional Fields to the Resource Messages which are not
        # currently added by the GMSEC API
        rsrcMsg = connManager.create_resource_message(RSRC_MESSAGE_SUBJECT)
        libgmsec_python3.log_info(
            "Publishing the GMSEC C2CX RSRC message which was created using create_resource_message():\n"
            + rsrcMsg.to_XML())
        connManager.publish(rsrcMsg)

        # Kick off the Resource Service -- This will publish resource
        # messages automatically every X seconds, where X is the second
        # parameter provided to the start_resource_message_service() function.
        # If an interval is not provided, the service will default to
        # publishing a message every 60 seconds.
        libgmsec_python3.log_info(
            "Starting the Resource Message service, a message will be published every "
            + str(RSRC_PUBLISH_RATE) + " seconds")

        connManager.start_resource_message_service(RSRC_MESSAGE_SUBJECT,
                                                   RSRC_PUBLISH_RATE)

        # Wait for user input to end the program
        libgmsec_python3.log_info(
            "Publishing C2CX Resource Messages indefinitely, press <enter> to exit the program"
        )
        input("")

        # Stop the Heartbeat Service
        connManager.stop_resource_message_service()

        # Cleanup
        connManager.cleanup()

    except libgmsec_python3.GmsecError as e:
        libgmsec_python3.log_error(str(e))
        return -1

    return 0
def main():

    if (len(sys.argv) <= 1):
        usageMessage = "usage: " + sys.argv[0] + " mw-id=<middleware ID>"
        print(usageMessage)
        return -1

    # Load the command-line input into a GMSEC Config object
    # A Config object is basically a key-value pair map which is used to
    # pass configuration options into objects such as Connections,
    # ConnectionManagers, Subscribe and Publish function calls, Messages,
    # etc.
    config = libgmsec_python3.Config(sys.argv)

    initializeLogging(config)

    #Print the GMSEC API version number using the GMSEC Logging
    # interface
    # This is useful for determining which version of the API is
    # configured within the environment
    libgmsec_python3.log_info(
        libgmsec_python3.ConnectionManager.get_API_version())

    try:
        # Create a ConnectionManager object
        # This is the linchpin for all communications between the
        # GMSEC API and the middleware server
        connMgr = libgmsec_python3.ConnectionManager(config)

        # Open the connection to the middleware
        libgmsec_python3.log_info(
            "Opening the connection to the middleware server")
        connMgr.initialize()

        # Output middleware client library version
        libgmsec_python3.log_info(connMgr.get_library_version())

        # Set up a subscription to listen for Messages with the topic
        # "GMSEC.TEST.PUBLISH" which are published to the middleware
        # bus and register the callback object to the subscription
        # Subscription subject wildcard syntax:
        # * - Matches any one token separated by periods in a subject
        # > - Reading left to right, matches everything up to and ONE
        #     or more tokens in a subject
        # + - Reading left to right, matches everything up to and ZERO
        #     or more tokens in a subject
        # For more information on wildcards, please see the GMSEC API
        # User's Guide
        libgmsec_python3.log_info("Subscribing to the topic: " +
                                  DEFAULT_SUBSCRIPTION_SUBJECT)
        cb = FieldIterationCallback()
        connMgr.subscribe(DEFAULT_SUBSCRIPTION_SUBJECT, cb)

        # Start the AutoDispatcher to begin asynchronously processing
        # messages
        connMgr.start_auto_dispatch()

        # Wait for user input to end the program
        libgmsec_python3.log_info(
            "Listening for Messages indefinitely, press <enter> to exit the program"
        )

        input("")

        # Clean up
        connMgr.stop_auto_dispatch()
        connMgr.cleanup()

    except libgmsec_python3.GmsecError as e:
        libgmsec_python3.log_error(str(e))
        return -1

    return 0
示例#16
0
def main():

    if(len(sys.argv) <= 1):
        print("Usage: " + sys.argv[0] + " mw-id=<middleware ID>")
        return -1

    # Setup configuration with the supplied command line arguments
    config = libgmsec_python3.Config(sys.argv)

    # Unless otherwise configured, setup configuration that allows us to
    # log messages to stderr.
    initializeLogging(config)

    # Display the version number of the GMSEC API
    libgmsec_python3.log_info(libgmsec_python3.ConnectionManager.get_API_version())

    # Obtain the specification version that we are running with; if not provided, default to GMSEC_ISD_CURRENT
    specVersion = config.get_integer_value("gmsec-specification-version", libgmsec_python3.GMSEC_ISD_CURRENT)

    # Define standard fields that will be included with the heartbeat messages
    standardFields = libgmsec_python3.FieldList()

    component = libgmsec_python3.StringField("COMPONENT", "HEARTBEAT-GENERATOR")
    mission   = libgmsec_python3.StringField("MISSION-ID", "MY-MISSION")
    satellite = libgmsec_python3.StringField("SAT-ID-PHYSICAL", "MY-SAT-ID")
    facility  = libgmsec_python3.StringField("FACILITY", "MY-FACILITY")

    standardFields.push_back(component)
    standardFields.push_back(mission)
    standardFields.push_back(satellite)
    standardFields.push_back(facility)

    if specVersion == libgmsec_python3.GMSEC_ISD_2014_00:
        msgID = libgmsec_python3.StringField("MSG-ID", "MY-MSG-ID")
        standardFields.push_back(msgID)

    elif specVersion >= libgmsec_python3.GMSEC_ISD_2018_00:
        domain1 = libgmsec_python3.StringField("DOMAIN1", "MY-DOMAIN-1")
        domain2 = libgmsec_python3.StringField("DOMAIN2", "MY-DOMAIN-2")
        standardFields.push_back(domain1)
        standardFields.push_back(domain2)

    try:
        # Instantiate the heartbeat generator
        hbgen = libgmsec_python3.HeartbeatGenerator(config, HB_MESSAGE_SUBJECT, HB_PUBLISH_RATE, standardFields)

        # Start the heartbeat generator
        hbgen.start()
        libgmsec_python3.log_info("Heartbeat Generator is running; use gmsub or other utility to monitor messages.")

        # Wait for input from user to stop the heartbeat generator
        libgmsec_python3.log_info("Press <enter> to stop the heartbeat generator")
        input("")

        # Stop the heartbeat generator
        hbgen.stop();
        libgmsec_python3.log_info("Heartbeat Generator has been stopped.")

    except libgmsec_python3.GmsecError as e:
        libgmsec_python3.log_error(str(e))
        return -1

    return 0
示例#17
0
def main():

    if(len(sys.argv) <= 1):
        usageMessage = "usage: " +  sys.argv[0] + " mw-id=<middleware ID>"
        print(usageMessage)
        return -1


    # Load the command-line input into a GMSEC Config object
    # A Config object is basically a key-value pair map which is used to
    # pass configuration options into objects such as Connections,
    # ConnectionManagers, Subscribe and Publish function calls, Messages,
    # etc.
    config = libgmsec_python3.Config(sys.argv)

    # Since this example program uses an invalid message, we ensure the
    # validation check is disabled.
    config.add_value("gmsec-msg-content-validate-all", "false")

    # If it was not specified in the command-line arguments, set LOGLEVEL
    # to 'INFO' and LOGFILE to 'stdout' to allow the program report output
    # on the terminal/command line
    initializeLogging(config)

    # Output GMSEC API version
    libgmsec_python3.log_info(libgmsec_python3.Connection.get_API_version())

    try:
        # Create the Connection
        connMgr = libgmsec_python3.ConnectionManager(config)

        # Connect
        connMgr.initialize()

        # output connection middleware version
        libgmsec_python3.log_info(connMgr.get_library_version())

        # Create request message
        requestMsg = libgmsec_python3.Message(DEFAULT_REQUEST_SUBJECT, libgmsec_python3.Message.REQUEST)

        # Add fields to request message
        requestMsg.add_field("QUESTION", "Does the request/reply functionality still work?")
        requestMsg.add_field("COMPONENT", "request_async")

        # Display XML representation of request message
        libgmsec_python3.log_info("Requesting:\n" + requestMsg.to_XML())

        cb = ExampleReplyCallback()
        connMgr.request(requestMsg, libgmsec_python3.GMSEC_WAIT_FOREVER, cb)

        libgmsec_python3.log_info("Waiting for response...")

        # Loop while waiting for the asynchronous response until done
        while (cb.receivedReply == 0):
            libgmsec_python3.TimeUtil.millisleep(100)
                
        if (cb.receivedReply):
            libgmsec_python3.log_info("Response Received!")
        else:
            libgmsec_python3.log_warning("No response received")

        connMgr.cleanup()
            
    except libgmsec_python3.GmsecError as e:
        libgmsec_python3.log_error(str(e))
        return -1
        
    return 0
示例#18
0
 def on_reply(self, connection, request, reply):
     # Display XML representation of reply message
     libgmsec_python3.log_info("[ExampleReplyCallback::on_reply]\n" + reply.to_XML())
     self.receivedReply = True
示例#19
0
def main():

    if (len(sys.argv) <= 1):
        usageMessage = "usage: " + sys.argv[0] + " mw-id=<middleware ID>"
        print(usageMessage)
        return -1

    # Load the command-line input into a GMSEC Config object
    config = libgmsec_python3.Config()

    for arg in sys.argv[1:]:
        value = arg.split('=')
        config.add_value(value[0], value[1])

    # If it was not specified in the command-line arguments, set LOGLEVEL
    # to 'INFO' and LOGFILE to 'stdout' to allow the program report output
    # on the terminal/command line

    initializeLogging(config)

    # Enable Message validation.  This parameter is "false" by default.
    config.add_value("GMSEC-MSG-CONTENT-VALIDATE", "true")

    # Tell the API that there is an additional layer of message schema to
    # validate (The 'EXAMPLE' message definitions).  This value is set to
    # 0 (Only 'GMSEC' specification validation) by default.

    # Note: These levels for validation are determined by the "LEVEL-X"
    # attributes defined in the .DIRECTORY.xml file contained in the XML
    # templates directory.  In thise case, Level-0 means GMSEC and Level-1
    # means EXAMPLE.

    # Note: The GMSEC team envisions using message specifications in a
    # layered hierarchical fashion.  For example, the "GMSEC" message
    # specification would be 'layer 0', followed by an organization-level
    # message specification at 'layer 1' which builds upon the message
    # specification outlined in the GMSEC ISD.  This would be followed by
    # a mission-level message specification at 'layer 2' and so on.
    config.add_value("GMSEC-SCHEMA-LEVEL", "1")

    # Tell the API where to find all of the schema files.

    # Note: This example only demonstrates a simple usage case of this
    # functionality.  When using this functionality, if the intent is
    # to use any of the GMSEC message definitions, then ALL of the XML
    # template files must be contained in the same directory.
    # e.g. GMSEC_API/templates/2016.00 (Or the location defined in
    # GMSEC-SCHEMA-PATH)
    config.add_value("GMSEC-SCHEMA-PATH", "templates")

    # Since this example relies on the 2016.00 version of the templates,
    # we indicate such within the configuration object.
    config.add_value("GMSEC-SPECIFICATION-VERSION", "201600")

    libgmsec_python3.log_info(
        libgmsec_python3.ConnectionManager.get_API_version())

    try:
        connMgr = libgmsec_python3.ConnectionManager(config)

        libgmsec_python3.log_info(
            "Opening the connection to the middleware server")
        connMgr.initialize()

        libgmsec_python3.log_info(connMgr.get_library_version())

        definedFields = libgmsec_python3.FieldList()

        missionField = libgmsec_python3.StringField("MISSION-ID", "MISSION")
        satIdField = libgmsec_python3.StringField("SAT-ID-PHYSICAL",
                                                  "SPACECRAFT")
        facilityField = libgmsec_python3.StringField("FACILITY", "GMSEC Lab")
        componentField = libgmsec_python3.StringField("COMPONENT",
                                                      "log_message")

        definedFields.append(missionField)
        definedFields.append(satIdField)
        definedFields.append(facilityField)
        definedFields.append(componentField)

        connMgr.set_standard_fields(definedFields)

        # Create a Message using a subject defined in the XML template
        # outlining our example addendum message definitions
        message = libgmsec_python3.MistMessage(EXAMPLE_MESSAGE_SUBJECT,
                                               "MSG.LOG",
                                               connMgr.get_specification())

        # Add all of the necessary Fields to our message
        message.add_field(libgmsec_python3.U16Field("NUM-OF-EVENTS", 2))
        message.set_value("EVENT.1", addTimeToString("AOS occurred at: "))
        message.set_value("EVENT.2",
                          addTimeToString("Telemetry downlink began at: "))

        connMgr.add_standard_fields(message)

        # Publish the message to the middleware bus
        connMgr.publish(message)

        # Display the XML string representation of the Message for
        # the sake of review
        libgmsec_python3.log_info("Published message:\n" + message.to_XML())

        # Setup a new message without some of the Required Fields and
        # attempt to publish it (i.e. Trigger a validation failure)
        badMessage = libgmsec_python3.MistMessage(EXAMPLE_MESSAGE_SUBJECT,
                                                  "MSG.LOG",
                                                  connMgr.get_specification())

        try:
            connMgr.publish(badMessage)
        except libgmsec_python3.GmsecError as e:
            libgmsec_python3.log_error("This error is expected:\n" + str(e))

        # Disconnect from the middleware and clean up the Connection
        connMgr.cleanup()

    except libgmsec_python3.GmsecError as e:
        libgmsec_python3.log_error(str(e))
        return -1

    return 0
示例#20
0
def main():

    if (len(sys.argv) <= 1):
        usageMessage = "usage: " + sys.argv[0] + " mw-id=<middleware ID>"
        print(usageMessage)
        return -1

    # Load the command-line input into a GMSEC Config object
    # A Config object is basically a key-value pair map which is used to
    # pass configuration options into objects such as Connections,
    # ConnectionManagers, Subscribe and Publish function calls, Messages,
    # etc.
    config = libgmsec_python3.Config(sys.argv)

    # Since this example program uses an invalid message, we ensure the
    # validation check is disabled.
    config.add_value("gmsec-msg-content-validate-all", "false")

    # If it was not specified in the command-line arguments, set LOGLEVEL
    # to 'INFO' and LOGFILE to 'stdout' to allow the program report output
    # on the terminal/command line
    initializeLogging(config)

    # Print the GMSEC API version number using the GMSEC Logging
    # interface
    # This is useful for determining which version of the API is
    # configured within the environment
    libgmsec_python3.log_info(
        libgmsec_python3.ConnectionManager.get_API_version())

    try:

        # Create a ConnectionManager object
        # This is the linchpin for all communications between the
        # GMSEC API and the middleware server
        connMgr = libgmsec_python3.ConnectionManager(config)

        # Open the connection to the middleware
        libgmsec_python3.log_info(
            "Opening the connection to the middleware server")
        connMgr.initialize()

        # Output middleware client library version
        libgmsec_python3.log_info(connMgr.get_library_version())

        # Create a message
        # Disclaimer: This message is not based off of a Message
        # Definition outlined by the GMSEC Interface
        # Specification Document (ISD).  It is meant to be an example
        # to demonstrate the various capabilities of the GMSEC Message
        # and Field classes. The GMSEC Team recommends that you map
        # your data into the Messages defined in the GMSEC ISD, as
        # doing so will make your software "GMSEC Compliant" resulting
        # in plug-and-play type functionality with other GMSEC
        # compliant software.
        message = libgmsec_python3.Message(EXAMPLE_MESSAGE_SUBJECT,
                                           libgmsec_python3.Message.PUBLISH)
        populateMessage(message)

        # Publish the message to the middleware bus
        connMgr.publish(message)

        # Display the XML string representation of the Message for
        # the sake of review
        libgmsec_python3.log_info("Published message:\n" + message.to_XML())

        # Disconnect from the middleware and clean up the Connection
        connMgr.cleanup()

    except libgmsec_python3.GmsecError as e:
        libgmsec_python3.log_error(str(e))
        return -1

    return 0
示例#21
0
def main(argv=None):

    if(len(sys.argv) <= 1):
        usageMessage = "usage: " + sys.argv[0] + " mw-id=<middleware ID>"
        print(usageMessage)
        return -1


    # Load the command-line input into a GMSEC Config object
    # A Config object is basically a key-value pair map which is used to
    # pass configuration options into objects such as Connections,
    # ConnectionManagers, Subscribe and Publish function calls, Messages,
    # etc.
    config = libgmsec_python3.Config(sys.argv)

    # If it was not specified in the command-line arguments, set LOGLEVEL
    # to 'INFO' and LOGFILE to 'stdout' to allow the program report output
    # on the terminal/command line
    initializeLogging(config)

    # Print the GMSEC API version number using the GMSEC Logging
    # interface
    # This is useful for determining which version of the API is
    # configured within the environment
    libgmsec_python3.log_info(libgmsec_python3.ConnectionManager.get_API_version())

    try:
        # Create a ConnectionManager object
        connManager = libgmsec_python3.ConnectionManager(config)

        # Open the connection to the middleware
        libgmsec_python3.log_info("Opening the connection to the middleware server")
        connManager.initialize()

        # Output middleware client library version
        libgmsec_python3.log_info(connManager.get_library_version())

        # Create all of the GMSEC Message header Fields which will
        # be used by all GMSEC Messages
        headerFields = libgmsec_python3.FieldList()

        version = connManager.get_specification().get_version()

        missionField = libgmsec_python3.StringField("MISSION-ID", "MY-MISSION")
        facilityField = libgmsec_python3.StringField("FACILITY", "MY-FACILITY")
        componentField = libgmsec_python3.StringField("COMPONENT", "HEARTBEAT-SERVICE")
        domain1Field = libgmsec_python3.StringField("DOMAIN1", "MY-DOMAIN-1")
        domain2Field =libgmsec_python3.StringField("DOMAIN2", "MY-DOMAIN-2")
        msgID = libgmsec_python3.StringField("MSG-ID", "MY-MSG-ID")

        headerFields.append(missionField)
        headerFields.append(facilityField)
        headerFields.append(componentField)

        if (version == 201400):
            headerFields.append(msgID)

        elif (version >= 201800):
            headerFields.append(domain1Field)
            headerFields.append(domain2Field)


        # Use set_standard_fields to define a set of header fields for
        # all messages which are created or published on the
        # ConnectionManager using the following functions:
        # create_log_message, publish_log, create_heartbeat_message,
        # start_heartbeat_service, create_resource_message,
        # publishResourceMessage, or start_resource_message_service
        connManager.set_standard_fields(headerFields)

        # Note: Fields are immutable, so plan appropriately if you wish
        # to re-use variable names!

        # Create all of the GMSEC Message header Fields which
        # will be used by all GMSEC HB Messages
        hbStandardFields = libgmsec_python3.FieldList()

        pubRateField = libgmsec_python3.U16Field("PUB-RATE", HB_PUBLISH_RATE)
        counterField = libgmsec_python3.U16Field("COUNTER", 1)
        # Note: COMPONENT-STATUS is an optional field used to
        # denote the operating status of the component, the
        # values are as follows:
        # 0 - Debug
        # 1 - Normal / Green
        # 2 - Warning / Yellow
        # 3 - Orange
        # 4 - Error / Red
        componentStatusField = libgmsec_python3.I16Field("COMPONENT-STATUS", 0)

        hbStandardFields.append(pubRateField)
        hbStandardFields.append(counterField)
        hbStandardFields.append(componentStatusField)


        # Create and publish a Heartbeat message using
        # create_log_message() and publish()

        # Note: This is useful for applications which may need
        # to create proxy heartbeats on behalf of a subsystem,
        # as creating multiple ConnectionManagers can consume
        # more memory than necessary.  In this case, extra
        # logic would need to be added to handle the timing of
        # the publications.
        hbMsg = connManager.create_heartbeat_message(HB_MESSAGE_SUBJECT, hbStandardFields)
        libgmsec_python3.log_info("Publishing the GMSEC C2CX HB message which was just created using create_heartbeat_message():\n" + hbMsg.to_XML())
        connManager.publish(hbMsg)

        # Kick off the Heartbeat Service -- This will publish
        # heartbeat messages automatically every X seconds,
        # where Xis the value which was provided for PUB-RATE
        # Note: If PUB-RATE was not provided, it will default
        # to 30 seconds per automatic Heartbeat publication
        libgmsec_python3.log_info("Starting the Heartbeat service, a message will be published every " + pubRateField.get_string_value() + " seconds")

        connManager.start_heartbeat_service(HB_MESSAGE_SUBJECT, hbStandardFields)

        # Use set_heartbeat_service_field to change the state of the
        # COMPONENT-STATUS Field to indicate that the component has
        # transitioned from a startup/debug state to a running/green
        # state.
        componentStatusField = libgmsec_python3.I16Field("COMPONENT-STATUS", 1)
        connManager.set_heartbeat_service_field(componentStatusField)

        libgmsec_python3.log_info("Publishing C2CX Heartbeat Messages indefinitely, press <enter> to exit the program")

        input("")

        # Stop the Heartbeat Service
        connManager.stop_heartbeat_service()

        # Cleanup
        connManager.cleanup()

    except libgmsec_python3.GmsecError as e:
        libgmsec_python3.log_error(str(e))
        return -1

    return 0
示例#22
0
def main():

    if (len(sys.argv) <= 1):
        usageMessage = "usage: " + sys.argv[0] + " mw-id=<middleware ID>"
        print(usageMessage)
        return -1

    # Load the command-line input into a GMSEC Config object
    # A Config object is basically a key-value pair map which is used to
    # pass configuration options into objects such as Connections,
    # ConnectionManagers, Subscribe and Publish function calls, Messages,
    # etc.
    config = libgmsec_python3.Config(sys.argv)

    # If it was not specified in the command-line arguments, set LOGLEVEL
    # to 'INFO' and LOGFILE to 'stdout' to allow the program report output
    # on the terminal/command line
    initializeLogging(config)

    # Print the GMSEC API version number using the GMSEC Logging
    # interface
    # This is useful for determining which version of the API is
    # configured within the environment
    libgmsec_python3.log_info(
        libgmsec_python3.ConnectionManager.get_API_version())

    try:
        # Create a ConnectionManager object
        connManager = libgmsec_python3.ConnectionManager(config)

        # Open the connection to the middleware
        libgmsec_python3.log_info(
            "Opening the connection to the middleware server")
        connManager.initialize()

        # Output middleware client library version
        libgmsec_python3.log_info(connManager.get_library_version())

        # Create all of the GMSEC Message header Fields which will
        # be used by all GMSEC Messages

        # Note: Since these Fields contain variable values which are
        # based on the context in which they are used, they cannot be
        # automatically populated using MistMessage.
        definedFields = libgmsec_python3.FieldList()

        missionField = libgmsec_python3.StringField("MISSION-ID", "MISSION")
        # Note: SAT-ID-PHYSICAL is an optional header Field, according
        # to the GMSEC ISD.
        satIdField = libgmsec_python3.StringField("SAT-ID-PHYSICAL",
                                                  "SPACECRAFT")
        facilityField = libgmsec_python3.StringField("FACILITY", "GMSEC Lab")
        componentField = libgmsec_python3.StringField("COMPONENT",
                                                      "mnemonic_message")

        definedFields.append(missionField)
        definedFields.append(satIdField)
        definedFields.append(facilityField)
        definedFields.append(componentField)

        # Use set_standard_fields to define a set of header fields for
        # all messages which are created or published on the
        # ConnectionManager using the following functions:
        # create_log_message, publish_log, create_heartbeat_message,
        # start_heartbeat_service, create_resource_message,
        # publishResourceMessage, or start_resource_message_service
        connManager.set_standard_fields(definedFields)

        # Populate the Mnemonic Sample(s)
        mSample = libgmsec_python3.MnemonicSample(
            "MS1", libgmsec_python3.I32Field("MS1", 15))
        mSample.set_EU_value(libgmsec_python3.F32Field("My EU", 15.0))
        mSample.set_flags(1)
        mSample.set_limit(libgmsec_python3.MnemonicSample.RED_HIGH)
        # Implicitly set limit enable/disable with setting of limit
        mSample.set_quality(True)
        mSample.set_staleness_status(False)
        mSample.set_text_value("15")

        mnemonic_samples = libgmsec_python3.MnemonicSampleList()
        mnemonic_samples.append(mSample)

        # Add the Mnemonic values to a Mnemonic object
        mnemonic = libgmsec_python3.Mnemonic("M1", mnemonic_samples)
        statusField = libgmsec_python3.I16Field("status", 5)
        mnemonic.set_status(statusField)
        mnemonic.set_units("units")

        # Build up the Schema ID -- This is used to identify the
        # specific type of MVAL message to construct

        schemaId = GMSEC_SPEC_VERSION + ".GMSEC.MSG.MVAL"

        # Construct an MVAL Message and add the Mnemonic values to it
        mvalMessage = libgmsec_python3.MnemonicMessage(
            MVAL_MESSAGE_SUBJECT, schemaId, connManager.get_specification())
        mvalMessage.add_mnemonic(mnemonic)

        # Add the header fields to the MVAL message
        connManager.add_standard_fields(mvalMessage)

        libgmsec_python3.log_info("Publishing MVAL message:\n" +
                                  mvalMessage.to_XML())
        connManager.publish(mvalMessage)

    except libgmsec_python3.GmsecError as e:
        libgmsec_python3.log_error(str(e))
        return -1

    return 0
示例#23
0
def main(argv=None):

    if (len(sys.argv) <= 1):
        usageMessage = ("\nUsage: configfile <filename>\n")
        print(usageMessage)
        return -1

    try:
        initializeLogging()

        # load configuration file
        cfgFile = libgmsec_python3.ConfigFile()
        cfgFilename = sys.argv[1]
        cfgFile.load(cfgFilename)

        # retrieve config objects from the Config file
        c1 = cfgFile.lookup_config("config1")
        c2 = cfgFile.lookup_config("config2")

        # Display log of XML representation of Config objects
        libgmsec_python3.log_info("Config 1:\n" + c1.to_XML())
        libgmsec_python3.log_info("Config 2:\n" + c2.to_XML())

        # lookup subscription topic from configuration file, including excluded topics
        subEntry = cfgFile.lookup_subscription_entry("events")

        libgmsec_python3.log_info("Subscription pattern: " +
                                  subEntry.get_pattern())

        while (subEntry.has_next_excluded_pattern()):
            libgmsec_python3.log_info("Subscription excluded pattern: " +
                                      subEntry.next_excluded_pattern())

        # lookup a Message from the configuration file
        message = cfgFile.lookup_message("msg1")

        # Display XML representation of the message
        libgmsec_python3.log_info("Message:\n" + message.to_XML())

        # Obtain ConfigFile Iterator to examine all of the various
        # entries defined in the ConfigFile
        iterator = cfgFile.get_iterator()

        # Acquire and display all Config entries
        while (iterator.has_next_config()):
            entry = iterator.next_config()

            libgmsec_python3.log_info("\nConfig Name: " + entry.get_name() +
                                      "\nConfig:\n" +
                                      entry.get_config().to_XML())

        # Acquire and display all Message entries
        while (iterator.has_next_message()):
            entry = iterator.next_message()

            libgmsec_python3.log_info("\nMessage Name: " + entry.get_name() +
                                      "\nMessage:\n" +
                                      entry.get_message().to_XML())

        # Acquire and display all subscription entries
        while (iterator.has_next_subscription()):
            entry = iterator.next_subscription()

            libgmsec_python3.log_info("\nSubscription Name: " +
                                      entry.get_name() +
                                      "\nSubscription Topic: " +
                                      entry.get_pattern())

            while (entry.has_next_excluded_pattern()):
                libgmsec_python3.log_info("\nExcluded Pattern: " +
                                          entry.next_excluded_pattern())

        # Acquire and display all custom XML entries
        while (iterator.has_next_custom_element()):
            element = iterator.next_custom_element()

            libgmsec_python3.log_info("\nCustom XML Element:\n" + element)

    except libgmsec_python3.GmsecError as e:
        libgmsec_python3.log_error(str(e))
        return -1

    return 0
示例#24
0
def main():

    if (len(sys.argv) <= 1):
        usageMessage = "usage: " + sys.argv[0] + " mw-id=<middleware ID>"
        print(usageMessage)
        return -1

    # Load the command-line input into a GMSEC Config object
    # A Config object is basically a key-value pair map which is used to
    # pass configuration options into objects such as Connections,
    # ConnectionManagers, Subscribe and Publish function calls, Messages,
    # etc.
    config = libgmsec_python3.Config(sys.argv)

    # Since this example program uses an invalid message, we ensure the
    # validation check is disabled.
    config.add_value("gmsec-msg-content-validate-all", "false")

    # If it was not specified in the command-line arguments, set LOGLEVEL
    # to 'INFO' and LOGFILE to 'stdout' to allow the program report output
    # on the terminal/command line
    initializeLogging(config)

    # Print the GMSEC API version number using the GMSEC Logging
    # interface
    # This is useful for determining which version of the API is
    # configured within the environment
    libgmsec_python3.log_info(libgmsec_python3.Connection.get_API_version())

    try:
        # Create the ConnectionManager
        connMgr = libgmsec_python3.ConnectionManager(config)

        # Open the connection to the middleware
        connMgr.initialize()

        # Output middleware client library version
        libgmsec_python3.log_info(connMgr.get_library_version())

        # Output information
        libgmsec_python3.log_info(
            "Issuing a request using the DEFAULT_REQUEST_SUBJECT '" +
            DEFAULT_REQUEST_SUBJECT + "'")

        # Create message
        requestMsg = libgmsec_python3.Message(DEFAULT_REQUEST_SUBJECT,
                                              libgmsec_python3.Message.REQUEST)

        # Add fields to message
        requestMsg.add_field("QUESTION", "Is there anyone out there?")
        requestMsg.add_field("COMPONENT", "request")

        # Display XML representation of request message
        libgmsec_python3.log_info("Sending request message:\n" +
                                  requestMsg.to_XML())

        # Send Request Message
        # Timeout periods:
        # -1 - Wait forever
        # 0 - Return immediately
        # >0 - Time in milliseconds before timing out
        replyMsg = connMgr.request(requestMsg,
                                   libgmsec_python3.GMSEC_WAIT_FOREVER)

        # Example error handling for calling request() with a timeout
        if (replyMsg):
            # Display the XML string representation of the reply
            libgmsec_python3.log_info("Received replyMsg:\n" +
                                      replyMsg.to_XML())

            # Destroy the replyMsg message
            connMgr.release(replyMsg)

        # Disconnect from the middleware and clean up the Connection
        connMgr.cleanup()

    except GmsecError as e:
        libgmsec_python3.log_error(str(e))
        return -1

    return 0
示例#25
0
def main():

    if(len(sys.argv) <= 1):
        usageMessage = "usage: " +  sys.argv[0] + " mw-id=<middleware ID>"
        print(usageMessage)
        return -1


    # Load the command-line input into a GMSEC Config object
    # A Config object is basically a key-value pair map which is used to
    # pass configuration options into objects such as Connections,
    # ConnectionManagers, Subscribe and Publish function calls, Messages,
    # etc.
    config = libgmsec_python3.Config(sys.argv)

    # Since this example program uses an invalid message, we ensure the
    # validation check is disabled.
    config.add_value("gmsec-msg-content-validate-all", "false")

    # If it was not specified in the command-line arguments, set LOGLEVEL
    # to 'INFO' and LOGFILE to 'stdout' to allow the program report output
    # on the terminal/command line
    initializeLogging(config)

    # Output GMSEC API version
    libgmsec_python3.log_info(libgmsec_python3.ConnectionManager.get_API_version())

    try:
        # Create the Connection
        connMgr = libgmsec_python3.ConnectionManager(config)

        # Open the connection to the middleware
        libgmsec_python3.log_info("Opening the connection to the middleware server")
        connMgr.initialize()

        # Output middleware client/wrapper version
        libgmsec_python3.log_info(connMgr.get_library_version())

        connMgr.subscribe(DEFAULT_REQUEST_SUBJECT)
        libgmsec_python3.log_info("Subscribed to: " + DEFAULT_REQUEST_SUBJECT);

        # Call receive() to synchronously retrieve a message that has
        # been received by the middleware client libraries
        # Timeout periods:
        # -1 - Wait forever
        #  0 - Return immediately
        # >0 - Time in milliseconds before timing out
        requestMsg = connMgr.receive(-1)

        # Example error handling for calling receive() with a timeout
        if (requestMsg):
                
            # Display the XML representation of the received message
            libgmsec_python3.log_info("Received a message\n" + requestMsg.to_XML())

            # Double-check the Message type to ensure that it is a request
            if (requestMsg.get_kind() == libgmsec_python3.Message.REQUEST):
                            
                # Get the name of the component who issued the request
                component = 0

                # Construct a Reply message
                try:
                    compField = requestMsg.get_string_field("COMPONENT")
                    component = compField.get_value()
                                
                except GmsecError as e:
                     libgmsec_python3.log_error(str(e))
                                

                # Set Status Code to indicate Successful Completion.
                # The GMSEC Interface Specification Document defines 6
                # unique STATUS-CODE values:
                # 1 - Acknowledgement
                # 2 - Working/keep alive
                # 3 - Successful completion
                # 4 - Failed completion
                # 5 - Invalid request
                # 6 - Final message
                # If an asynchronous requestor is awaiting a reply, the
                # ReplyCallback in use will remain active for multiple
                # messages, so long as the messages it receives contain
                # a STATUS-CODE of either 1 or 2.
                status_code = "3"

                # Set the reply subject.
                # See API Interface Specificaiton Document for
                # more information on Reply Message subjects.
                # Generally speaking, they are composed
                # accordingly:
                # [Spec].[Mission].[Satellite ID].
                # [Message Type].[Component Name].[Status Code]
                               
                reply_subject = "GMSEC.MISSION.SAT_ID.RESP.REPLY." + status_code

                # Create reply message
                replyMsg = libgmsec_python3.Message(reply_subject, libgmsec_python3.Message.REPLY)

                # Add fields to the reply message
                replyMsg.add_field("ANSWER", "Yup, I'm here!")
                replyMsg.add_field("COMPONENT", component)

                # Display XML representation of the reply message
                libgmsec_python3.log_info("Prepared Reply:\n" + replyMsg.to_XML())

                # Send Reply
                connMgr.reply(requestMsg, replyMsg)

            # Destroy request message to release its memory
            connMgr.release(requestMsg)

        connMgr.cleanup()
                
        
    except libgmsec_python3.GmsecError as e:
        libgmsec_python3.log_error(str(e))
        return -1
        
    return 0
示例#26
0
def main(agrv=None):

    if (len(sys.argv) <= 1):
        usageMessage = "usage: " + sys.argv[0] + " mw-id=<middleware ID>"
        print(usageMessage)
        return -1

    config = libgmsec_python3.Config(sys.argv)

    # Create and register log handlers
    errorHandler = ErrorHandler()
    warningHandler = WarningHandler()
    infoHandler = InfoHandler()
    anyHandler = AnyHandler()

    libgmsec_python3.Log.register_handler(errorHandler,
                                          libgmsec_python3.logERROR)
    libgmsec_python3.Log.register_handler(warningHandler,
                                          libgmsec_python3.logWARNING)
    libgmsec_python3.Log.register_handler(infoHandler,
                                          libgmsec_python3.logINFO)
    # Note: At this time, for the Python3 binding, setting log handlers for logVERBOSE and logDEBUG are not permitted,
    # This is because certain middleware wrappers output log messages after the custom Python log handler
    # has been garbage collected, and this can lead to fatal errors.
    libgmsec_python3.Log.register_handler(
        anyHandler, libgmsec_python3.logVERBOSE
    )  # has no effect, but shown for demo purposes
    libgmsec_python3.Log.register_handler(
        anyHandler, libgmsec_python3.logDEBUG
    )  # has no effect, but shown for demo purposes

    # Set logging reporting level
    libgmsec_python3.Log.set_reporting_level(libgmsec_python3.logVERBOSE)
    libgmsec_python3.log_verbose(
        "The log reporting level is now set to: " +
        str(libgmsec_python3.Log.get_reporting_level()))

    # Print the GMSEC API version number using the GMSEC Logging
    # interface
    # This is useful for determining which version of the API is
    # configured within the environment
    libgmsec_python3.log_info(
        libgmsec_python3.ConnectionManager.get_API_version())

    try:
        # Create the ConnectionManager
        connMgr = libgmsec_python3.ConnectionManager(config)

        # Connect
        connMgr.initialize()

        # Output middleware client library version
        libgmsec_python3.log_info(connMgr.get_library_version())

        # Publish a message
        publishTestMessage(connMgr, "GMSEC.TEST.PUBLISH")

        # Disconnect from the middleware and clean up the Connection
        connMgr.cleanup()

    except libgmsec_python3.GmsecError as e:
        libgmsec_python3.log_error(str(e))
        return -1

    # Unregister log handlers
    libgmsec_python3.Log.register_handler(None)

    # Set log stream to stderr
    config.add_value("LOGFILE", "STDERR")
    libgmsec_python3.log_info(
        "This message should go to stderr, not stdout.  " +
        "For example, in bash test by running as:\n" +
        "./logging mw-id=bolt 2> testfile.txt\n" +
        "... and then check the contents of testfile.txt")

    # Reset log stream to stdout
    config.add_value("LOGFILE", "STDOUT")

    libgmsec_python3.log_error("This is an example error message.")
    libgmsec_python3.log_warning("This is an example warning message.")
    libgmsec_python3.log_verbose("This is an example \"verbose\" message.")
    libgmsec_python3.log_debug(
        "This is an example debug message which should not show.")

    # This last message cannot be shown right now because
    # Log::set_reporting_level(logVERBOSE), used above, does not
    # allow DEBUG messages to come out.
    libgmsec_python3.log_verbose(
        "This is another example \"verbose\" message.")

    # Set logging reporting level to now allow DEBUG messages to be shown
    libgmsec_python3.Log.set_reporting_level(libgmsec_python3.logDEBUG)
    if (libgmsec_python3.Log.get_reporting_level() == libgmsec_python3.logDEBUG
        ):
        libgmsec_python3.log_info("Changed reporting level to logDEBUG")

    else:
        libgmsec_python3.log_error(
            "Failed to change reporting level to logDEBUG")

    # The DEBUG message below will be shown successfully, unlike the last
    # debug message.
    libgmsec_python3.log_debug(
        "This is an example debug message which should show.")

    libgmsec_python3.log_debug("NONE reporting level, numerically, is " +
                               str(libgmsec_python3.Log.from_string("NONE")))
    libgmsec_python3.log_debug("ERROR reporting level, numerically, is " +
                               str(libgmsec_python3.Log.from_string("ERROR")))
    libgmsec_python3.log_debug("SECURE reporting level, numerically, is " +
                               str(libgmsec_python3.Log.from_string("SECURE")))
    libgmsec_python3.log_debug(
        "WARNING reporting level, numerically, is " +
        str(libgmsec_python3.Log.from_string("WARNING")))
    libgmsec_python3.log_debug("INFO reporting level, numerically, is " +
                               str(libgmsec_python3.Log.from_string("INFO")))
    libgmsec_python3.log_debug(
        "VERBOSE reporting level, numerically, is " +
        str(libgmsec_python3.Log.from_string("VERBOSE")))
    libgmsec_python3.log_debug("DEBUG reporting level, numerically, is " +
                               str(libgmsec_python3.Log.from_string("DEBUG")))

    # Register general-purpose handler and test
    try:
        libgmsec_python3.Log.register_handler(anyHandler)

    except libgmsec_python3.GmsecError as e:
        print(str(e))

    libgmsec_python3.log_error("NONE reporting level, numerically, is " +
                               str(libgmsec_python3.Log.from_string("NONE")))
    libgmsec_python3.log_error("ERROR reporting level, numerically, is " +
                               str(libgmsec_python3.Log.from_string("ERROR")))
    libgmsec_python3.log_warning(
        "WARNING reporting level, numerically, is " +
        str(libgmsec_python3.Log.from_string("WARNING")))
    libgmsec_python3.log_info("INFO reporting level, numerically, is " +
                              str(libgmsec_python3.Log.from_string("INFO")))
    libgmsec_python3.log_verbose(
        "VERBOSE reporting level, numerically, is " +
        str(libgmsec_python3.Log.from_string("VERBOSE")))
    libgmsec_python3.log_debug("DEBUG reporting level, numerically, is " +
                               str(libgmsec_python3.Log.from_string("DEBUG")))

    # Unregister log handlers
    libgmsec_python3.Log.register_handler(None)

    return 0
示例#27
0
def main():
    if (len(sys.argv) <= 1):
        usageMessage = "usage: " + sys.argv[0] + " mw-id=<middleware ID>"
        print(usageMessage)
        return -1

    cb = ConnectionStateCallback()

    # Load the command-line input into a GMSEC Config object
    config = libgmsec_python3.Config(sys.argv)

    # If it was not specified in the command-line arguments, set LOGLEVEL
    # to 'INFO' and LOGFILE to 'stdout' to allow the program report output
    # on the terminal/command line
    initializeLogging(config)

    # Print the GMSEC API version number using the GMSEC Logging
    # interface
    libgmsec_python3.log_info(
        libgmsec_python3.ConnectionManager.get_API_version())

    try:
        # Create the Connection
        connMgr = libgmsec_python3.ConnectionManager(config)

        # Register the event callback with the connection to catch
        # connection state changes, including:
        # 1. Connection successfully established to middleware
        # 2. Connection broken from middleware
        # 3. Reconnecting to the middleware
        connMgr.register_event_callback(
            libgmsec_python3.Connection.CONNECTION_SUCCESSFUL_EVENT, cb)
        connMgr.register_event_callback(
            libgmsec_python3.Connection.CONNECTION_BROKEN_EVENT, cb)
        connMgr.register_event_callback(
            libgmsec_python3.Connection.CONNECTION_RECONNECT_EVENT, cb)

        # Connect
        connMgr.initialize()

        # Output middleware version
        libgmsec_python3.log_info("Middleware version = " +
                                  connMgr.get_library_version())

        # Assuming that the user provided proper reconnection syntax
        # for the corresponding middleware they are using, one could
        # kill the middleware server at this point, then start it back
        # up to demonstrate the EventCallback.on_event() function
        # triggering

        # Wait for user input to end the program
        libgmsec_python3.log_info(
            "Waiting for Connection events to occur, press <enter> to exit the program"
        )

        input("")

        # Clean up the ConnectionManager before exiting the program
        connMgr.cleanup()

    except libgmsec_python3.GmsecError as e:
        libgmsec_python3.log_error(str(e))
        return -1

    return 0
示例#28
0
def main():

    if (len(sys.argv) <= 1):
        usageMessage = "usage: " + sys.argv[0] + " mw-id=<middleware ID>"
        print(usageMessage)
        return -1

    # Load the command-line input into a GMSEC Config object
    # A Config object is basically a key-value pair map which is used to
    # pass configuration options into objects such as Connections,
    # ConnectionManagers, Subscribe and Publish function calls, Messages,
    # etc.
    config = libgmsec_python3.Config(sys.argv)

    # If it was not specified in the command-line arguments, set LOGLEVEL
    # to 'INFO' and LOGFILE to 'stdout' to allow the program report output
    # on the terminal/command line
    initializeLogging(config)

    # Print the GMSEC API version number using the GMSEC Logging
    # interface
    # This is useful for determining which version of the API is
    # configured within the environment
    libgmsec_python3.log_info(
        libgmsec_python3.ConnectionManager.get_API_version())

    try:
        # Create a ConnectionManager object
        connManager = libgmsec_python3.ConnectionManager(config)

        # Open the connection to the middleware
        libgmsec_python3.log_info(
            "Opening the connection to the middleware server")
        connManager.initialize()

        # Output middleware client library version
        libgmsec_python3.log_info(connManager.get_library_version())

        # Create all of the GMSEC Message header Fields which will
        # be used by all GMSEC Messages

        # Note: Since these Fields contain variable values which are
        # based on the context in which they are used, they cannot be
        # automatically populated using MistMessage.
        definedFields = libgmsec_python3.FieldList()

        missionField = libgmsec_python3.StringField("MISSION-ID", "MISSION")
        # Note: SAT-ID-PHYSICAL is an optional header Field, according
        # to the GMSEC ISD.
        satIdField = libgmsec_python3.StringField("SAT-ID-PHYSICAL",
                                                  "SPACECRAFT")
        facilityField = libgmsec_python3.StringField("FACILITY", "GMSEC Lab")
        componentField = libgmsec_python3.StringField("COMPONENT",
                                                      "device_message")

        definedFields.append(missionField)
        definedFields.append(satIdField)
        definedFields.append(facilityField)
        definedFields.append(componentField)

        # Use set_standard_fields to define a set of header fields for
        # all messages which are created or published on the
        # ConnectionManager using the following functions:
        # create_log_message, publish_log, create_heartbeat_message,
        # start_heartbeat_service, create_resource_message,
        # publishResourceMessage, or start_resource_message_service
        connManager.set_standard_fields(definedFields)

        paramVal = libgmsec_python3.I32Field("DEVICE.1.PARAM.1.VALUE", 79)
        param = libgmsec_python3.DeviceParam("DEV parameter 1",
                                             "parameter 1 timestamp", paramVal)

        device1 = libgmsec_python3.Device("device 1",
                                          libgmsec_python3.Device.RED)
        device1.set_group("group")
        device1.set_role("role")
        device1.set_model("model")
        device1.set_serial("1138")
        device1.set_version("1.4.5.2.3.4.5")
        devInfo = libgmsec_python3.I16Field("info", 5)
        device1.set_info(devInfo)
        devNum = libgmsec_python3.I16Field("num", 5)
        device1.set_number(devNum)
        device1.add_param(param)

        # Construct an DEV Message and add the Device values to it
        devMessage = libgmsec_python3.DeviceMessage(
            DEV_MESSAGE_SUBJECT, connManager.get_specification())
        devMessage.add_device(device1)

        connManager.add_standard_fields(devMessage)

        libgmsec_python3.log_info("Publishing DEV message:\n" +
                                  devMessage.to_XML())
        connManager.publish(devMessage)

    except libgmsec_python3.GmsecError as e:
        libgmsec_python3.log_error(str(e))
        return -1

    return 0
示例#29
0
def main():

    if(len(sys.argv) <= 1):
        usageMessage = "usage: " + sys.argv[0] + " mw-id=<middleware ID>" 
        print(usageMessage)
        return -1


    # Load the command-line input into a GMSEC Config object
    # A Config object is basically a key-value pair map which is used to
    # pass configuration options into objects such as Connections,
    # ConnectionManagers, Subscribe and Publish function calls, Messages,
    # etc.
    config = libgmsec_python3.Config(sys.argv)

    # Enable Message Binning
    config.add_value("GMSEC-USE-MSG-BINS", "true")

    # Specify the number of messages to be aggregated prior to publishing
    # the aggregate message to the middleware server (This applies to all
    # of the messages which match the subject(s) provided in the
    # GMSEC-MSG-BIN-SUBJECT-N configuration parameters
    # Note: The aggregate message will be sent to the middleware server
    # immediately upon this many messages being published, regardless of
    # the value supplied for GMSEC-MSG-BIN-TIMEOUT.
    config.add_value("GMSEC-MSG-BIN-SIZE", "10")

    # Specify a timeout (in milliseconds) for the aggregate message to be
    # sent to the middleware server
    # Note: The aggregate message will be sent to the middleware server
    # after this period of time if the message bin does not fill up (per
    # the value provided for GMSEC-MSG-BIN-SIZE) prior to this timeout
    config.add_value("GMSEC-MSG-BIN-TIMEOUT", "5000")

    # Specify the subjects to aggreate messages for.
    # Note: Subscription wildcard syntax can be used here, and has been
    # supported since GMSEC API version 4.3.
    config.add_value("GMSEC-MSG-BIN-SUBJECT-1", "GMSEC.*.PUBLISH")

    # Specify any subjects that should be excluded from being aggregated
    # This is useful if a wildcard subscription is provided in one of the
    # GMSEC-MSG-BIN-SUBJECT-N parameters.
    config.add_value("GMSEC-MSG-BIN-EXCLUDE-SUBJECT-1", EXAMPLE_BIN_EXCLUDE_SUBJECT)

    # Since this example program uses an invalid message, we ensure the
    # validation check is disabled.
    config.add_value("gmsec-msg-content-validate-all", "false")

    # If it was not specified in the command-line arguments, set LOGLEVEL
    # to 'INFO' and LOGFILE to 'stdout' to allow the program report output
    # on the terminal/command line
    initializeLogging(config)
    # Print the GMSEC API version number using the GMSEC Logging
    # interface
    # This is useful for determining which version of the API is
    # configured within the environment
    libgmsec_python3.log_info(libgmsec_python3.ConnectionManager.get_API_version())

    try:
        # Create a ConnectionManager object
        # This is the linchpin for all communications between the
        # GMSEC API and the middleware server
        connMgr = libgmsec_python3.ConnectionManager(config)

        # Open the connection to the middleware
        libgmsec_python3.log_info("Opening the connection to the middleware server")
        connMgr.initialize()

        # Output middleware client library version
        libgmsec_python3.log_info(connMgr.get_library_version())

                
        # Create a message 
        message = libgmsec_python3.Message(EXAMPLE_MESSAGE_SUBJECT, libgmsec_python3.Message.PUBLISH)

        for i in range(0,5):
            populateMessage(message, i+1)

            # Publish the message to the middleware bus
            connMgr.publish(message)

            # Display the XML string representation of the Message for
            # the sake of review
            libgmsec_python3.log_info("Published message: " + message.to_XML())

        # Create another message
        message = libgmsec_python3.Message(EXAMPLE_BIN_EXCLUDE_SUBJECT, libgmsec_python3.Message.PUBLISH)

        populateMessage(message, 1)

        # Publish the message to the middleware bus
        # Note: When calling publish(), if a message does NOT match
        # one of the subjects to be aggregated, it will be immediately
        # published
        connMgr.publish(message)

        # Display the XML string representation of the Message for
        # the sake of review
        libgmsec_python3.log_info("Published message: " + message.to_XML())
                

        # Disconnect from the middleware and clean up the Connection
        connMgr.cleanup()
        
    except libgmsec_python3.GmsecError as e:
        libgmsec_python3.log_error(str(e))
        return -1

    return 0