예제 #1
0
    static int Main(string[] args)
    {
        if (args.Length < 1)
        {
            Console.WriteLine("usage resource_service.exe mw-id=<middleware ID>");
            return(-1);
        }

        Config config = new Config(args);

        InitializeLogging(config);

        Log.Info(ConnectionManager.GetAPIVersion());

        try
        {
            ConnectionManager connManager = new ConnectionManager(config);

            Log.Info("Opening the connection to the middleware server");
            connManager.Initialize();

            Log.Info(connManager.GetLibraryVersion());

            //o Create all of the GMSEC Message header Fields which will
            // be used by all GMSEC Messages
            List <Field> headerFields = new List <Field>();

            F32Field    versionField   = new F32Field("HEADER-VERSION", 2010.0f);
            StringField missionField   = new StringField("MISSION-ID", "GMSEC");
            StringField facilityField  = new StringField("FACILITY", "GMSEC Lab");
            StringField componentField = new StringField("COMPONENT", "heartbeat_service");

            headerFields.Add(versionField);
            headerFields.Add(missionField);
            headerFields.Add(facilityField);
            headerFields.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(headerFields);

            //o Create and publish a Resource message using
            // createResourceMessage() 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
            Message rsrcMsg = connManager.CreateResourceMessage(RSRC_MESSAGE_SUBJECT, 1, 10);
            Log.Info("Publishing the GMSEC C2CX RSRC message which was created using createResourceMessage():\n" + rsrcMsg.ToXML());
            connManager.Publish(rsrcMsg);

            //o Kick off the Resource Service -- This will publish resource
            // messages automatically every X seconds, where X is the second
            // parameter provided to the startResourceMessageService() function.
            // If an interval is not provided, the service will default to
            // publishing a message every 60 seconds.
            int interval_s = 30;
            Log.Info("Starting the Resource Message service, a message will be published every " + interval_s + " seconds");
            connManager.StartResourceMessageService(RSRC_MESSAGE_SUBJECT, interval_s, 1, 10);

            //o Wait for user input to end the program
            Log.Info("Publishing C2CX Resource Messages indefinitely, press <enter> to exit the program");
            Console.ReadLine();

            //o Stop the Heartbeat Service
            connManager.StopResourceMessageService();

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

        return(0);
    }
예제 #2
0
 /// <summary>Copy constructor</summary>
 /// <param name="other">The other F32Field object to copy</param>
 public F32Field(F32Field other)
 {
 }