static int Main(string[] args) { if (args.Length < 1) { Console.WriteLine("usage device_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"); // TODO: Once available, replace this statement with usage of // ConnectionManager::getAPIVersion (See RTC 4798) Log.Info(Connection.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 // // 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. List <Field> definedFields = new List <Field>(); 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); I32Field paramVal = new I32Field("DEVICE.1.PARAM.1.VALUE", 79); DeviceParam param = new DeviceParam("DEV parameter 1", "parameter 1 timestamp", paramVal); Device device1 = new Device("device 1", Device.DeviceStatus.RED); device1.SetGroup("group"); device1.SetRole("role"); device1.SetModel("model"); device1.SetSerial("1138"); device1.SetVersion("1.4.5.2.3.4.5"); I16Field devInfo = new I16Field("info", 5); device1.SetInfo(devInfo); I16Field devNum = new I16Field("num", 5); device1.SetNumber(devNum); device1.AddParam(param); //o Construct an DEV Message and add the Device values to it using (GMSEC.API.MIST.MESSAGE.DeviceMessage devMessage = new GMSEC.API.MIST.MESSAGE.DeviceMessage(DEV_MESSAGE_SUBJECT, connManager.GetSpecification())) { devMessage.AddDevice(device1); connManager.AddStandardFields(devMessage); connManager.Publish(devMessage); Log.Info("Published DEV message:\n" + devMessage.ToXML()); } connManager.Cleanup(); } catch (GMSEC_Exception e) { Log.Error(e.ToString()); return(-1); } return(0); }
/// <summary>Copy constructor</summary> /// <param name="other">The other I32Field object to copy</param> public I32Field(I32Field other) { }