example.remote.interface.demo/src/terra/harvest/standalone/demo/RemoteInterfaceStandaloneDemo.java
public void runConfigurationDemo() throws IOException
    {

        String logWriterPid = "mil.dod.th.ose.logging.LogWriter";
        
        // ---------------------------------------------------------------------
        // REQUEST THE CONFIGURATION INFO
        // Users may request configuration info to see which configurations are
        // present on an instance of controller software.
        // ---------------------------------------------------------------------
        // Build the request
        GetConfigurationInfoRequestData requestForInfo = 
                GetConfigurationInfoRequestData.newBuilder() // Start a new builder
                    .setFilter("(service.pid=" + logWriterPid + ")") // Get the LogWriter bundle
                    .setIncludeProperties(false) //Don't include configuration properties
                    .build(); // Finalize construction

        // Construct and send a TerraHarvestMessage
        ConfigAdminNamespace.Builder getConfigBuilder = ConfigAdminNamespace.newBuilder().setType(
                ConfigAdminMessageType.GetConfigurationInfoRequest).setData(requestForInfo.toByteString());
        TerraHarvestMessage messageForInfoRequest = this.createTerraHarvestMsg(Namespace.ConfigAdmin, getConfigBuilder);
        messageForInfoRequest.writeDelimitedTo(sock.getOutputStream());

        // Read in the response
        // The response should be non-null and contain a message of the ConfigAdmin namespace.
        TerraHarvestMessage responseToInfoRequest = TerraHarvestMessage.parseDelimitedFrom(sock.getInputStream());

        // Read in the payload information from the response
        TerraHarvestPayload payload = TerraHarvestPayload.parseFrom(responseToInfoRequest.getTerraHarvestPayload());
        // Parse the message namespace type
        ConfigAdminNamespace namespaceOfInfoResponse = ConfigAdminNamespace.parseFrom(payload.getNamespaceMessage());
        System.out.println("The type of the response is " + namespaceOfInfoResponse.getType());

        // Get the data from the response.
        GetConfigurationInfoResponseData responseData = 
                GetConfigurationInfoResponseData.parseFrom(namespaceOfInfoResponse.getData());
        List<ConfigurationInfoType> data = responseData.getConfigurationsList();
        System.out.println("The data is " + data);

        // ---------------------------------------------------------------------
        // UPDATE OR CREATE A REMOTE CONFIGURATION
        // To update a remote configuration, send a message setting any
        // parameter. This example updates a parameter called 'logMBSizeLimit' of
        // type INT32. The parameter value is "2".
        //
        // A ConfigAdminMessageType.SetPropertyRequest creates the
        // configuration if a configuration does not exist; otherwise, it
        // updates the configuration. If a configuration does not already
        // exist, then a ConfigAdminMessageType.SetPropertyRequest must be the
        // first call to the remote system.
        // ---------------------------------------------------------------------

        String logWriterProp = "logMBSizeLimit";

        // Build a parameter to send
        Multitype mtype = Multitype.newBuilder() // Start the builder
                .setType(Type.INT32) // Designate it as type INT32
                .setInt32Value(2) // Assign a value to the variable
                .build(); // Finalize construction

        //Build the property to be set
        SimpleTypesMapEntry prop = SimpleTypesMapEntry.newBuilder().setKey(logWriterProp).setValue(mtype).build();
        
        // Build a message using the above payload
        SetPropertyRequestData request = 
                SetPropertyRequestData.newBuilder().setPid(logWriterPid).addProperties(prop).build();

        // Construct and send a TerraHarvestMessage
        ConfigAdminNamespace.Builder configMessageBuilder = ConfigAdminNamespace.newBuilder().setType(
                ConfigAdminMessageType.SetPropertyRequest).setData(request.toByteString());
        TerraHarvestMessage message = this.createTerraHarvestMsg(Namespace.ConfigAdmin, configMessageBuilder);
        message.writeDelimitedTo(sock.getOutputStream());

        // The response should be a non-null response with a namespace type Namespace.ConfigAdmin.
        TerraHarvestMessage response = TerraHarvestMessage.parseDelimitedFrom(sock.getInputStream());
        // get the payload information
        TerraHarvestPayload payloadForResponse = TerraHarvestPayload.parseFrom(response.getTerraHarvestPayload());

        System.out.println("Response namespace is " + payloadForResponse.getNamespace());

        // The message namespace should be of type ConfigAdminMessageType.SetPropertyResponse.
        ConfigAdminNamespace namespaceResponse = 
                ConfigAdminNamespace.parseFrom(payloadForResponse.getNamespaceMessage());
        System.out.println("Namespace response type is " + namespaceResponse.getType());

        // ---------------------------------------------------------------------
        // REQUEST A PARAMETER
        // Request the value of a specific parameter belonging to a known
        // configuration from a specific remote controller software.
        // This example requests the current log level from the LogWriter.
        // ---------------------------------------------------------------------
        // Build the request
        GetPropertyRequestData requestName = GetPropertyRequestData.newBuilder().setPid(logWriterPid).setKey(
                logWriterProp).build();

        // Construct and send the request
        ConfigAdminNamespace.Builder getPropertyBuilder = ConfigAdminNamespace.newBuilder().setType(
                ConfigAdminMessageType.GetPropertyRequest).setData(requestName.toByteString());
        TerraHarvestMessage messageRequestingName = this.createTerraHarvestMsg(Namespace.ConfigAdmin,
                getPropertyBuilder);
        messageRequestingName.writeDelimitedTo(sock.getOutputStream());

        // Read in the response. The response should be non-null, of namespace type ConfigAdmin, and have a message
        // containing the response for the requested property.
        TerraHarvestMessage responseForNameRequest = TerraHarvestMessage.parseDelimitedFrom(sock.getInputStream());
        TerraHarvestPayload payloadForNameRequest = 
                TerraHarvestPayload.parseFrom(responseForNameRequest.getTerraHarvestPayload());

        System.out.println("Response for the name request:\n" + responseForNameRequest);

        // Parse specific message type. It should be a 'GetPropertyResponse'
        ConfigAdminNamespace namespaceResponseForNameRequest = 
                ConfigAdminNamespace.parseFrom(payloadForNameRequest.getNamespaceMessage());
        System.out.println("The message contained inside the response is\n" + namespaceResponseForNameRequest);

        // Get the type and value of the property
        // Getting the type is important because a property may be overridden by a different type of data.
        // For example, one analyst might remotely assign a parameter called "ID" parameter as a string, while another
        // analyst may habitually assign a parameter with the same name ("ID") as an integer value.
        GetPropertyResponseData propData = GetPropertyResponseData.parseFrom(namespaceResponseForNameRequest.getData());
        // Get the parameter data type and value
        Multitype value = propData.getValue();
        System.out.println("The type of the requested property is " + value.getType());
        // Because this is a demo and we know the type is a String, we'll skip using any conditional logic
        System.out.println("The value of the requested property is " + value.getInt32Value());

        // ---------------------------------------------------------------------
        // REQUEST THE LIST OF PARAMETER KEYS
        // This is useful when you need to see what parameter keys are on the
        // remote device. If you use an invalid PID, a non-null response is
        // returned with an empty array of data.
        // Currently, the two keys in the configuration should be "logLevel"
        // and "service.pid". All configurations have a "service.pid" property,
        // equal to the value used in setPid (below).
        // ---------------------------------------------------------------------
        // Build the request
        GetPropertyKeysRequestData requestPropertyKeys = 
                GetPropertyKeysRequestData.newBuilder().setPid(logWriterPid).build();

        // Construct and send the TerraHarvestMessage
        ConfigAdminNamespace.Builder getPropKeysBuilder = ConfigAdminNamespace.newBuilder().setType(
                ConfigAdminMessageType.GetPropertyKeysRequest).setData(requestPropertyKeys.toByteString());
        TerraHarvestMessage messageRequestingKeys = this.createTerraHarvestMsg(Namespace.ConfigAdmin,
                getPropKeysBuilder);
        messageRequestingKeys.writeDelimitedTo(sock.getOutputStream());

        // Read in response and parse message
        TerraHarvestMessage responseToKeyRequest = TerraHarvestMessage.parseDelimitedFrom(sock.getInputStream());
        TerraHarvestPayload payloadToKeyRequest = 
                TerraHarvestPayload.parseFrom(responseToKeyRequest.getTerraHarvestPayload());

        ConfigAdminNamespace namespaceResponseToKeyRequest = 
                ConfigAdminNamespace.parseFrom(payloadToKeyRequest.getNamespaceMessage());
        GetPropertyKeysResponseData keysData = 
                GetPropertyKeysResponseData.parseFrom(namespaceResponseToKeyRequest.getData());
        System.out.println("Keys are " + keysData.getKeyList() + " with " + keysData.getKeyCount() + " keys");

    }
/**
     * Run the Configuration Management Demo.
     * 
     * Configuration management allows remote setting and getting of controller software parameters. This allows the
     * user to configure any OSGi managed service (that is, any class implementing an interface containing
     * "ManagedService" in its name). This includes assets, comms layers, and other components.
     * 
     * If the demo runs successfully, the output should look similar to this: Creating new demo instance... Connecting
     * to controller... Running ConfigAdmin demo... The type of the response is GetConfigurationInfoResponse The data is
     * [pid: "mil.dod.th.ose.logging.LogWriter" bundleLocation:
     * "file:/C:/Users/user/Desktop/controller-app-generic/bundle/mil.dod.th.ose.remoteinterface.jar" ] Response
     * namespace is ConfigAdmin Namespace response type is SetPropertyResponse Response for the name request: sourceId:
     * 0 destId: 0 namespace: ConfigAdmin messageId: 2 message: "\b\004\022\006\n\004\b\003\030\002"
     * 
     * The message contained inside the response is type: GetPropertyResponse data: "\n\004\b\003\030\002"
     * 
     * The type of the requested property is INT32 The value of the requested property is Keys are [service.pid,
     * logLevel] with 2 keys Running MissionProgramming demo... Uncomment the next line to see the stored templates. The
     * response is of namespace MissionProgramming and has error code NO_ERROR. The response message type is
     * LoadTemplateResponse Cleaning up... Finished running RemoteInterfaceDemo!
     */
Run the Configuration Management Demo.

Configuration management allows remote setting and getting of controller software parameters. This allows the
user to configure any OSGi managed service (that is, any class implementing an interface containing
"ManagedService" in its name). This includes assets, comms layers, and other components.

If the demo runs successfully, the output should look similar to this: Creating new demo instance... Connecting
to controller...



The type of the requested property is INT32 The value of the requested property is Keys are [service.pid,
logLevel] with 2 keys Running MissionProgramming demo... Uncomment the next line to see the stored templates. The
response is of namespace MissionProgramming and has error code NO_ERROR. The response message type is
LoadTemplateResponse Cleaning up...
Run the Configuration Management Demo . Configuration management allows remote setting and getting of controller software parameters . This allows the user to configure any OSGi managed service ( that is any class implementing an interface containing " ManagedService " in its name ) . This includes assets comms layers and other components . If the demo runs successfully the output should look similar to this : Creating new demo instance ... Connecting to controller ... The type of the requested property is INT32 The value of the requested property is Keys are [ service . pid logLevel ] with 2 keys Running MissionProgramming demo ... Uncomment the next line to see the stored templates . The response is of namespace MissionProgramming and has error code NO_ERROR . The response message type is LoadTemplateResponse Cleaning up ...
public void runConfigurationDemo() throws IOException
    {
        String logWriterPid = "mil.dod.th.ose.logging.LogWriter";
        GetConfigurationInfoRequestData requestForInfo = 
                GetConfigurationInfoRequestData.newBuilder() 
                    .setFilter("(service.pid=" + logWriterPid + ")") 
                    .setIncludeProperties(false) 
                    .build(); 
        ConfigAdminNamespace.Builder getConfigBuilder = ConfigAdminNamespace.newBuilder().setType(
                ConfigAdminMessageType.GetConfigurationInfoRequest).setData(requestForInfo.toByteString());
        TerraHarvestMessage messageForInfoRequest = this.createTerraHarvestMsg(Namespace.ConfigAdmin, getConfigBuilder);
        messageForInfoRequest.writeDelimitedTo(sock.getOutputStream());
        TerraHarvestMessage responseToInfoRequest = TerraHarvestMessage.parseDelimitedFrom(sock.getInputStream());
        TerraHarvestPayload payload = TerraHarvestPayload.parseFrom(responseToInfoRequest.getTerraHarvestPayload());
        ConfigAdminNamespace namespaceOfInfoResponse = ConfigAdminNamespace.parseFrom(payload.getNamespaceMessage());
        System.out.println("The type of the response is " + namespaceOfInfoResponse.getType());
        GetConfigurationInfoResponseData responseData = 
                GetConfigurationInfoResponseData.parseFrom(namespaceOfInfoResponse.getData());
        List<ConfigurationInfoType> data = responseData.getConfigurationsList();
        System.out.println("The data is " + data);
         A ConfigAdminMessageType.SetPropertyRequest creates the
         configuration if a configuration does not exist; otherwise, it
         updates the configuration. If a configuration does not already
         exist, then a ConfigAdminMessageType.SetPropertyRequest must be the
         first call to the remote system.
        String logWriterProp = "logMBSizeLimit";
         Build a parameter to send
        Multitype mtype = Multitype.newBuilder()  Start the builder
                .setType(Type.INT32)  Designate it as type INT32
                .setInt32Value(2)  Assign a value to the variable
                .build(); 
        Build the property to be set
        SimpleTypesMapEntry prop = SimpleTypesMapEntry.newBuilder().setKey(logWriterProp).setValue(mtype).build();
         Build a message using the above payload
        SetPropertyRequestData request = 
                SetPropertyRequestData.newBuilder().setPid(logWriterPid).addProperties(prop).build();
        ConfigAdminNamespace.Builder configMessageBuilder = ConfigAdminNamespace.newBuilder().setType(
                ConfigAdminMessageType.SetPropertyRequest).setData(request.toByteString());
        TerraHarvestMessage message = this.createTerraHarvestMsg(Namespace.ConfigAdmin, configMessageBuilder);
        message.writeDelimitedTo(sock.getOutputStream());
         The response should be a non-null response with a namespace type Namespace.ConfigAdmin.
        TerraHarvestMessage response = TerraHarvestMessage.parseDelimitedFrom(sock.getInputStream());
         get the payload information
        TerraHarvestPayload payloadForResponse = TerraHarvestPayload.parseFrom(response.getTerraHarvestPayload());
        System.out.println("Response namespace is " + payloadForResponse.getNamespace());
         The message namespace should be of type ConfigAdminMessageType.SetPropertyResponse.
        ConfigAdminNamespace namespaceResponse = 
                ConfigAdminNamespace.parseFrom(payloadForResponse.getNamespaceMessage());
        System.out.println("Namespace response type is " + namespaceResponse.getType());
         REQUEST A PARAMETER
         Request the value of a specific parameter belonging to a known
         configuration from a specific remote controller software.
         This example requests the current log level from the LogWriter.
        GetPropertyRequestData requestName = GetPropertyRequestData.newBuilder().setPid(logWriterPid).setKey(
                logWriterProp).build();
         Construct and send the request
        ConfigAdminNamespace.Builder getPropertyBuilder = ConfigAdminNamespace.newBuilder().setType(
                ConfigAdminMessageType.GetPropertyRequest).setData(requestName.toByteString());
        TerraHarvestMessage messageRequestingName = this.createTerraHarvestMsg(Namespace.ConfigAdmin,
                getPropertyBuilder);
        messageRequestingName.writeDelimitedTo(sock.getOutputStream());
        . The response should be non-null, of namespace type ConfigAdmin, and have a message
         containing the response for the requested property.
        TerraHarvestMessage responseForNameRequest = TerraHarvestMessage.parseDelimitedFrom(sock.getInputStream());
        TerraHarvestPayload payloadForNameRequest = 
                TerraHarvestPayload.parseFrom(responseForNameRequest.getTerraHarvestPayload());
        System.out.println("Response for the name request:\n" + responseForNameRequest);
         Parse specific message type. It should be a 'GetPropertyResponse'
        ConfigAdminNamespace namespaceResponseForNameRequest = 
                ConfigAdminNamespace.parseFrom(payloadForNameRequest.getNamespaceMessage());
        System.out.println("The message contained inside the response is\n" + namespaceResponseForNameRequest);
         Get the type and value of the property
         Getting the type is important because a property may be overridden by a different type of data.
         For example, one analyst might remotely assign a parameter called "ID" parameter as a string, while another
         analyst may habitually assign a parameter with the same name ("ID") as an integer value.
        GetPropertyResponseData propData = GetPropertyResponseData.parseFrom(namespaceResponseForNameRequest.getData());
         Get the parameter data type and value
        Multitype value = propData.getValue();
        System.out.println("The type of the requested property is " + value.getType());
         Because this is a demo and we know the type is a String, we'll skip using any conditional logic
        System.out.println("The value of the requested property is " + value.getInt32Value());
         REQUEST THE LIST OF PARAMETER KEYS
         This is useful when you need to see what parameter keys are on the
         remote device. If you use an invalid PID, a non-null response is
         returned with an empty array of data.
         Currently, the two keys in the configuration should be "logLevel"
         and "service.pid". All configurations have a "service.pid" property,
         equal to the value used in setPid (below).
        GetPropertyKeysRequestData requestPropertyKeys = 
                GetPropertyKeysRequestData.newBuilder().setPid(logWriterPid).build();
         Construct and send the TerraHarvestMessage
        ConfigAdminNamespace.Builder getPropKeysBuilder = ConfigAdminNamespace.newBuilder().setType(
                ConfigAdminMessageType.GetPropertyKeysRequest).setData(requestPropertyKeys.toByteString());
        TerraHarvestMessage messageRequestingKeys = this.createTerraHarvestMsg(Namespace.ConfigAdmin,
                getPropKeysBuilder);
        messageRequestingKeys.writeDelimitedTo(sock.getOutputStream());
         Read in response and parse message
        TerraHarvestMessage responseToKeyRequest = TerraHarvestMessage.parseDelimitedFrom(sock.getInputStream());
        TerraHarvestPayload payloadToKeyRequest = 
                TerraHarvestPayload.parseFrom(responseToKeyRequest.getTerraHarvestPayload());
        ConfigAdminNamespace namespaceResponseToKeyRequest = 
                ConfigAdminNamespace.parseFrom(payloadToKeyRequest.getNamespaceMessage());
        GetPropertyKeysResponseData keysData = 
                GetPropertyKeysResponseData.parseFrom(namespaceResponseToKeyRequest.getData());
        System.out.println("Keys are " + keysData.getKeyList() + " with " + keysData.getKeyCount() + " keys");
    }
public void runConfigurationDemo ( ) throws IOException { String logWriterPid = "mil.dod.th.ose.logging.LogWriter" ; GetConfigurationInfoRequestData requestForInfo = GetConfigurationInfoRequestData . newBuilder ( ) . setFilter ( "(service.pid=" + logWriterPid + ")" ) . setIncludeProperties ( false ) . build ( ) ; ConfigAdminNamespace . Builder getConfigBuilder = ConfigAdminNamespace . newBuilder ( ) . setType ( ConfigAdminMessageType . GetConfigurationInfoRequest ) . setData ( requestForInfo . toByteString ( ) ) ; TerraHarvestMessage messageForInfoRequest = this . createTerraHarvestMsg ( Namespace . ConfigAdmin , getConfigBuilder ) ; messageForInfoRequest . writeDelimitedTo ( sock . getOutputStream ( ) ) ; TerraHarvestMessage responseToInfoRequest = TerraHarvestMessage . parseDelimitedFrom ( sock . getInputStream ( ) ) ; TerraHarvestPayload payload = TerraHarvestPayload . parseFrom ( responseToInfoRequest . getTerraHarvestPayload ( ) ) ; ConfigAdminNamespace namespaceOfInfoResponse = ConfigAdminNamespace . parseFrom ( payload . getNamespaceMessage ( ) ) ; System . out . println ( "The type of the response is " + namespaceOfInfoResponse . getType ( ) ) ; GetConfigurationInfoResponseData responseData = GetConfigurationInfoResponseData . parseFrom ( namespaceOfInfoResponse . getData ( ) ) ; List < ConfigurationInfoType > data = responseData . getConfigurationsList ( ) ; System . out . println ( "The data is " + data ) ; String logWriterProp = "logMBSizeLimit" ; Multitype mtype = Multitype . newBuilder ( ) . setType ( Type . INT32 ) . setInt32Value ( 2 ) . build ( ) ; SimpleTypesMapEntry prop = SimpleTypesMapEntry . newBuilder ( ) . setKey ( logWriterProp ) . setValue ( mtype ) . build ( ) ; SetPropertyRequestData request = SetPropertyRequestData . newBuilder ( ) . setPid ( logWriterPid ) . addProperties ( prop ) . build ( ) ; ConfigAdminNamespace . Builder configMessageBuilder = ConfigAdminNamespace . newBuilder ( ) . setType ( ConfigAdminMessageType . SetPropertyRequest ) . setData ( request . toByteString ( ) ) ; TerraHarvestMessage message = this . createTerraHarvestMsg ( Namespace . ConfigAdmin , configMessageBuilder ) ; message . writeDelimitedTo ( sock . getOutputStream ( ) ) ; TerraHarvestMessage response = TerraHarvestMessage . parseDelimitedFrom ( sock . getInputStream ( ) ) ; TerraHarvestPayload payloadForResponse = TerraHarvestPayload . parseFrom ( response . getTerraHarvestPayload ( ) ) ; System . out . println ( "Response namespace is " + payloadForResponse . getNamespace ( ) ) ; ConfigAdminNamespace namespaceResponse = ConfigAdminNamespace . parseFrom ( payloadForResponse . getNamespaceMessage ( ) ) ; System . out . println ( "Namespace response type is " + namespaceResponse . getType ( ) ) ; GetPropertyRequestData requestName = GetPropertyRequestData . newBuilder ( ) . setPid ( logWriterPid ) . setKey ( logWriterProp ) . build ( ) ; ConfigAdminNamespace . Builder getPropertyBuilder = ConfigAdminNamespace . newBuilder ( ) . setType ( ConfigAdminMessageType . GetPropertyRequest ) . setData ( requestName . toByteString ( ) ) ; TerraHarvestMessage messageRequestingName = this . createTerraHarvestMsg ( Namespace . ConfigAdmin , getPropertyBuilder ) ; messageRequestingName . writeDelimitedTo ( sock . getOutputStream ( ) ) ; TerraHarvestMessage responseForNameRequest = TerraHarvestMessage . parseDelimitedFrom ( sock . getInputStream ( ) ) ; TerraHarvestPayload payloadForNameRequest = TerraHarvestPayload . parseFrom ( responseForNameRequest . getTerraHarvestPayload ( ) ) ; System . out . println ( "Response for the name request:\n" + responseForNameRequest ) ; ConfigAdminNamespace namespaceResponseForNameRequest = ConfigAdminNamespace . parseFrom ( payloadForNameRequest . getNamespaceMessage ( ) ) ; System . out . println ( "The message contained inside the response is\n" + namespaceResponseForNameRequest ) ; GetPropertyResponseData propData = GetPropertyResponseData . parseFrom ( namespaceResponseForNameRequest . getData ( ) ) ; Multitype value = propData . getValue ( ) ; System . out . println ( "The type of the requested property is " + value . getType ( ) ) ; System . out . println ( "The value of the requested property is " + value . getInt32Value ( ) ) ; GetPropertyKeysRequestData requestPropertyKeys = GetPropertyKeysRequestData . newBuilder ( ) . setPid ( logWriterPid ) . build ( ) ; ConfigAdminNamespace . Builder getPropKeysBuilder = ConfigAdminNamespace . newBuilder ( ) . setType ( ConfigAdminMessageType . GetPropertyKeysRequest ) . setData ( requestPropertyKeys . toByteString ( ) ) ; TerraHarvestMessage messageRequestingKeys = this . createTerraHarvestMsg ( Namespace . ConfigAdmin , getPropKeysBuilder ) ; messageRequestingKeys . writeDelimitedTo ( sock . getOutputStream ( ) ) ; TerraHarvestMessage responseToKeyRequest = TerraHarvestMessage . parseDelimitedFrom ( sock . getInputStream ( ) ) ; TerraHarvestPayload payloadToKeyRequest = TerraHarvestPayload . parseFrom ( responseToKeyRequest . getTerraHarvestPayload ( ) ) ; ConfigAdminNamespace namespaceResponseToKeyRequest = ConfigAdminNamespace . parseFrom ( payloadToKeyRequest . getNamespaceMessage ( ) ) ; GetPropertyKeysResponseData keysData = GetPropertyKeysResponseData . parseFrom ( namespaceResponseToKeyRequest . getData ( ) ) ; System . out . println ( "Keys are " + keysData . getKeyList ( ) + " with " + keysData . getKeyCount ( ) + " keys" ) ; }
Run the Configuration Management Demo.
Run the Configuration Management Demo .
// --------------------------------------------------------------------- // REQUEST THE CONFIGURATION INFO // Users may request configuration info to see which configurations are // present on an instance of controller software. // --------------------------------------------------------------------- // Build the request // Start a new builder // Get the LogWriter bundle //Don't include configuration properties // Finalize construction // Construct and send a TerraHarvestMessage // Read in the response // The response should be non-null and contain a message of the ConfigAdmin namespace. // Read in the payload information from the response // Parse the message namespace type // Get the data from the response. // --------------------------------------------------------------------- // UPDATE OR CREATE A REMOTE CONFIGURATION // To update a remote configuration, send a message setting any // parameter. This example updates a parameter called 'logMBSizeLimit' of // type INT32. The parameter value is "2". // // A ConfigAdminMessageType.SetPropertyRequest creates the // configuration if a configuration does not exist; otherwise, it // updates the configuration. If a configuration does not already // exist, then a ConfigAdminMessageType.SetPropertyRequest must be the // first call to the remote system. // --------------------------------------------------------------------- // Build a parameter to send // Start the builder // Designate it as type INT32 // Assign a value to the variable // Finalize construction //Build the property to be set // Build a message using the above payload // Construct and send a TerraHarvestMessage // The response should be a non-null response with a namespace type Namespace.ConfigAdmin. // get the payload information // The message namespace should be of type ConfigAdminMessageType.SetPropertyResponse. // --------------------------------------------------------------------- // REQUEST A PARAMETER // Request the value of a specific parameter belonging to a known // configuration from a specific remote controller software. // This example requests the current log level from the LogWriter. // --------------------------------------------------------------------- // Build the request // Construct and send the request // Read in the response. The response should be non-null, of namespace type ConfigAdmin, and have a message // containing the response for the requested property. // Parse specific message type. It should be a 'GetPropertyResponse' // Get the type and value of the property // Getting the type is important because a property may be overridden by a different type of data. // For example, one analyst might remotely assign a parameter called "ID" parameter as a string, while another // analyst may habitually assign a parameter with the same name ("ID") as an integer value. // Get the parameter data type and value // Because this is a demo and we know the type is a String, we'll skip using any conditional logic // --------------------------------------------------------------------- // REQUEST THE LIST OF PARAMETER KEYS // This is useful when you need to see what parameter keys are on the // remote device. If you use an invalid PID, a non-null response is // returned with an empty array of data. // Currently, the two keys in the configuration should be "logLevel" // and "service.pid". All configurations have a "service.pid" property, // equal to the value used in setPid (below). // --------------------------------------------------------------------- // Build the request // Construct and send the TerraHarvestMessage // Read in response and parse message