Ejemplo n.º 1
0
 /// <summary>Copy constructor - initializes the message instance using the other given ProductFileMessage.<summary>
 ///
 /// <param name="other">The ProductFileMessage to be copied.</param>
 ///
 /// <exception cref="GmsecException">Thrown if the given ProductFileMessage is null.</exception>
 public ProductFileMessage(ProductFileMessage other)
 {
 }
Ejemplo n.º 2
0
    static int Main(string[] args)
    {
        if (args.Length < 1)
        {
            Console.WriteLine("usage product_message.exe mw-id=<middleware ID>");
            return(-1);
        }

        Config config = new Config(args);

        InitializeLogging(config);

        //o Enable Message validation.  This parameter is "false" by default.
        config.AddValue("GMSEC-MSG-CONTENT-VALIDATE", "true");

        Log.Info("API version: " + ConnectionManager.GetAPIVersion());

        try
        {
            using (ConnectionManager connManager = new ConnectionManager(config))
            {
                Log.Info("Opening the connection to the middleware server");
                connManager.Initialize();

                Log.Info("Middleware version: " + connManager.GetLibraryVersion());

                //o 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.
                FieldList definedFields = new FieldList();

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

                definedFields.Add(missionField);
                definedFields.Add(satIdField);
                definedFields.Add(facilityField);
                definedFields.Add(componentField);

                //o Use setStandardFields to define a set of header fields for
                // all messages which are created or published on the
                // ConnectionManager using the following functions:
                // createLogMessage, publishLog, createHeartbeatMessage,
                // startHeartbeatService, createResourceMessage,
                // publishResourceMessage, or startResourceMessageService
                connManager.SetStandardFields(definedFields);

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

                int    fSize       = 8;
                byte[] filePayload = new byte[8];
                for (byte idx = 0; idx < fSize; idx++)
                {
                    filePayload[idx] = idx;
                }

                //o Create a ProductFile object with the product name,
                // description, version, format, binary array, and file size
                ProductFile binaryFile = new ProductFile("File as Binary", "Binary File Description", "1.0.0", "BIN", filePayload);

                //o 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
                using (ProductFileMessage productMessage = new ProductFileMessage(PROD_MESSAGE_SUBJECT, ResponseStatus.Response.SUCCESSFUL_COMPLETION, Message.MessageKind.PUBLISH, "AUTO", "DM", connManager.GetSpecification()))
                {
                    productMessage.AddProductFile(externalFile);
                    productMessage.AddProductFile(binaryFile);

                    connManager.AddStandardFields(productMessage);

                    connManager.Publish(productMessage);

                    Log.Info("Published DEV message:\n" + productMessage.ToXML());
                }

                connManager.Cleanup();
            }
        }
        catch (GmsecException e)
        {
            Log.Error(e.ToString());
            return(-1);
        }

        return(0);
    }