Is the Nx Cloud up? Visit our Status Page for the current health and performance of the Nx Cloud.

Status Page

Plugin configuration

Answered

Comments

1 comment

  • Andrey Terentyev
    • Network Optix team

    Hello Ivan Benovic ,

    At the moment there is not special button in plugin configuration.

    A plugin is notified about settings when "Ok" or "Apply" button is pressed in GUI.

    Once received new settings values from the GUI, the Server passes these settings to a plugin.

    The Sever calls setSettings method, which invokes the helper class virtual method ConsumingDeviceAgent::doSetSettings or Engine::doSetSettings which in turn invokes corresponding settingsRecieved virtual method.

    settingsRecieved - is the best place for handling and analyzing new received settings.

    This method should return const nx::sdk::IStringMap with error message (if any) per setting.

    So, you could create a "Test connection" check box in plugin settings model.

    Redefine settingsRecieved to analyze "Test connection" value, perform test and return an "error" with a message.

    Here is an example.

    If "Error text" is not empty a plugin returns an error with this text. GUI displays it on the right-hand panel.

    Here is the settingsReceived code

    Result<const IStringMap*> DeviceAgent::settingsReceived()
    {
    // parse settings and save to internal members.
    // "Error text" value is saved into
    // m_deviceAgentSettings.testErrorMessage member
    // "Error text" setting name is statically defined in kTestErrorMessage
    //
    // see stub_analytics_plugin for example of how to parse settings.

    parseSettings();

    // check if "Error text" is empty
    if (m_deviceAgentSettings.testErrorMessage.empty())
    return nullptr;

    // create countable smart pointer. See SDK documentation for details.
    auto errorMap = makePtr<StringMap>();

    // Create an error message to be returned.
    errorMap->setItem(kTestErrorMessage, m_deviceAgentSettings.testErrorMessage);

    // return a pointer to the StringMap
    return errorMap.releasePtr();
    }

     

    0

Please sign in to leave a comment.