diff --git a/doc/plugin-json.qdoc b/doc/plugin-json.qdoc index 756f6c3a..06731a7f 100644 --- a/doc/plugin-json.qdoc +++ b/doc/plugin-json.qdoc @@ -204,7 +204,7 @@ \endlist \note For more information please take a look at \l{CreateMethods and SetupMethods} documentation. \li - \underline{\e pairingInfo:} Optional: The \l{DeviceClass::pairingInfo()}{pairingInfo} will inform the user how to pair the device \unicode{0x2192} \l{DeviceClass::setupMethod()}. This parameter will only be used for \l{DeviceClass::SetupMethodDisplayPin}{DisplayPin} and \l{DeviceClass::SetupMethodEnterPin}{EnterPin} and \l{DeviceClass::SetupMethodPushButton}{PushButton}. Example: "Please press the button on the device before continue." - \li - \underline{\e criticalStateTypeId:} Optional: Define which \l{StateType} is critical for this \l{Device}. The given \l{StateTypeId} sould refer to a \tt{bool} \l{State} which enables / disables the whole \l{Device} i.e. \e{"connected"}, \e{"available"} or \e{"reachable"}. This allowes a client developer to disable the device until this \l{State} becomes true. + \li - \underline{\e criticalStateTypeId:} Optional: Define which \l{StateType} is critical for this \l{Device}. The given \l{StateTypeId} has to be a \tt{bool} \l{State} which enables / disables the whole \l{Device} i.e. \e{"connected"}, \e{"available"} or \e{"reachable"}. This allowes a client application to disable the device until this \l{State} becomes true. \li - \underline{\e primaryStateTypeId:} Optional: Define which \l{StateType} is the primary \l{State} for this \l{Device}. This allowes a client developer to place the primary \l{State} value in the device overview. \li - \underline{\e primaryActionTypeId:} Optional: Define which \l{ActionType} is the primary \l{Action} for this \l{Device}. This allowes a client developer to place the primary \l{Action} element in the device overview. \li - \underline{\e discoveryParamTypes:} Optional: A list of \l{ParamType}{ParamTypes} which will be needed for discovering a device \unicode{0x2192} \l{DeviceClass::discoveryParamTypes()}. This parameter will only be used for devices with the \l{DeviceClass::CreateMethodDiscovery}{CreateMethodDiscovery} (see section "\l{The ParamType definition}"). @@ -287,6 +287,7 @@ A \l{StateType} has following parameters: "type": "DataType", "ruleRelevant": "bool", "eventRuleRelevant": "bool", + "graphRelevant": "bool", "unit": "The unit of the state value.", "defaultValue": "The state will be initialized with this value." "minValue": "Numeric minimum value for this state.", @@ -307,7 +308,8 @@ A \l{StateType} has following parameters: \li - \underline{\e index:} The order index of the \l{StateType} \unicode{0x2192} \l{StateType::index()}. This index will be used for sorting the \l{State}{States} of a \l{Device} to make sure the types looks the same on all clients. Please make sure all \l{StateType}{StateTypes} together will create a list from \tt 0 to \tt x. \li - \underline{\e type:} The data type of this state \unicode{0x2192} \l{StateType::type()}. \li - \underline{\e ruleRelevant:} Optional: Since not all \l{State}{States} make sense for the user in a rule, with this flag can be specidied if this state should be visible in the rule engine for the user or not. This flag has no effect to the ruleengine mechanism and is only ment to filter out not interesting \l{State}{States}. By default, every state is rule relevant. - \li - \underline{\e eventRuleRelevant:} The same thing as \e{ruleRelevat}, but this flag is for the \l{EventType}, which will be generated for this \l{StateType}. + \li - \underline{\e graphRelevant:} Optional: This flag indicates that this \l{State} is interesting to be shown in a graph/chart. By default every state is \underline not \tt {graphRelevant}. The corresponding EventType will not be graphRelevant, because the graph will be generated from the \l{State} logs. + \li - \underline{\e eventRuleRelevant:} The same thing as \e {ruleRelevat}, but this flag is for the \l{EventType}, which will be generated for this \l{StateType}. \li - \underline{\e unit:} Optional: With this parameter you can specify the unit of the state value i.e. \unicode{0x00B0}C \unicode{0x2192} DegreeCelsius (\l{Types::Unit}). \li - \underline{\e defaultValue:} The state will be initialized with this value. \li - \underline{\e possibleValues:} Optional: Gives you the possibility to define a list of possible values which this state can have. This allowes a user to create a rule based on a state and define only values which are possible. This is typically used for strings i.e. ["Loading", "Installing", "Removing"]. @@ -412,6 +414,7 @@ This mechanism was created to ensure that the \l{EventType} and \l{ActionType} w "id": "uuid", "index": "int", "ruleRelevant": "bool", + "graphRelevant": "bool", "paramTypes": [ ... ] @@ -423,9 +426,10 @@ This mechanism was created to ensure that the \l{EventType} and \l{ActionType} w \list \li - \underline{\e name:} The visible name of the \l{EventType} \unicode{0x2192} \l{EventType::name()}. \li - \underline{\e idName:} This parameter will be used to define the EventTypeId variable named EventTypeId in the plugininfo.h, so it can be used in the code. - \li - \underline{\e id:} The actual uuid (\l{EventTypeId}) of the \l{EventType} \unicode{0x2192} \l{EventType::id()}. + \li - \underline{\e id:} The actual uuid (\l{EventTypeId}) of the \l{EventType} \unicode{0x2192} \l{EventType::id()}. \li - \underline{\e index:} The order index of the \l{EventType} \unicode{0x2192} \l{EventType::index()}. This index will be used for sorting the \l{Event}{Events} of a \l{Device} to make sure the \l{Device} looks the same on all clients. Please make sure all \l{EventType}{EventTypes} together will create a list from \tt 0 to \tt x. \li - \underline{\e ruleRelevant:} Optional: Since not all \l{Event}{Events} make sense for the user in a rule, with this flag can be specidied if this event should be visible in the rule engine for the user or not. This flag has no effect to the ruleengine mechanism and is only ment to filter out not interesting \l{Event}{Events}. By default, every event is rule relevant. + \li - \underline{\e graphRelevant:} Optional: This flag indicates that this \l{Event} is interesting to be shown in a graph/chart. By default all \l{Event} are \underline not \tt {graphRelevant}. \li - \underline{\e paramTypes:} Optional: A list of \l{ParamType}{ParamTypes} (see section "\l{The ParamType definition}") for this \l{EventType}. This parameter is optional. You can also create an \l{EventType} which has no \l{ParamType}{ParamTypes}. \endlist diff --git a/libguh/plugin/deviceplugin.cpp b/libguh/plugin/deviceplugin.cpp index a99c2498..f5a33e7c 100644 --- a/libguh/plugin/deviceplugin.cpp +++ b/libguh/plugin/deviceplugin.cpp @@ -293,6 +293,9 @@ QList DevicePlugin::supportedDevices() const if (st.contains("ruleRelevant")) stateType.setRuleRelevant(st.value("ruleRelevant").toBool()); + if (st.contains("graphRelevant")) + stateType.setGraphRelevant(st.value("graphRelevant").toBool()); + if (st.contains("possibleValues")) { QVariantList possibleValues; foreach (const QJsonValue &possibleValueJson, st.value("possibleValues").toArray()) { @@ -377,6 +380,9 @@ QList DevicePlugin::supportedDevices() const if (et.contains("ruleRelevant")) eventType.setRuleRelevant(et.value("ruleRelevant").toBool()); + if (et.contains("graphRelevant")) + eventType.setGraphRelevant(et.value("graphRelevant").toBool()); + QPair > paramVerification = parseParamTypes(et.value("paramTypes").toArray()); if (!paramVerification.first) { broken = true; diff --git a/libguh/types/eventtype.cpp b/libguh/types/eventtype.cpp index 7261cfd8..7e647ba9 100644 --- a/libguh/types/eventtype.cpp +++ b/libguh/types/eventtype.cpp @@ -35,7 +35,8 @@ EventType::EventType(const EventTypeId &id): m_id(id), m_index(0), - m_ruleRelevant(true) + m_ruleRelevant(true), + m_graphRelevant(false) { } @@ -96,3 +97,15 @@ void EventType::setRuleRelevant(const bool &ruleRelevant) { m_ruleRelevant = ruleRelevant; } + +/*! Returns true if this EventType is interesting to visualize the logs in a graph/chart from a user perspective. */ +bool EventType::graphRelevant() const +{ + return m_graphRelevant; +} + +/*! Sets this EventType \a graphRelevant to inform the client application if this \l{EventType} is interesting to visualize the logs in a graph/chart. */ +void EventType::setGraphRelevant(const bool &graphRelevant) +{ + m_graphRelevant = graphRelevant; +} diff --git a/libguh/types/eventtype.h b/libguh/types/eventtype.h index 3ad41082..6155815f 100644 --- a/libguh/types/eventtype.h +++ b/libguh/types/eventtype.h @@ -47,12 +47,16 @@ public: bool ruleRelevant() const; void setRuleRelevant(const bool &ruleRelevant); + bool graphRelevant() const; + void setGraphRelevant(const bool &graphRelevant); + private: EventTypeId m_id; QString m_name; int m_index; QList m_paramTypes; bool m_ruleRelevant; + bool m_graphRelevant; }; #endif // TRIGGERTYPE_H diff --git a/libguh/types/state.h b/libguh/types/state.h index d3a3eb5b..5cbc006f 100644 --- a/libguh/types/state.h +++ b/libguh/types/state.h @@ -38,7 +38,6 @@ public: StateTypeId stateTypeId() const; DeviceId deviceId() const; - //QStringList stateNames() const; QVariant value() const; void setValue(const QVariant &value); @@ -52,5 +51,4 @@ private: QDebug operator<<(QDebug dbg, const State &event); QDebug operator<<(QDebug dbg, const QList &events); - #endif // STATE_H diff --git a/libguh/types/statetype.cpp b/libguh/types/statetype.cpp index 577db4b5..959c7266 100644 --- a/libguh/types/statetype.cpp +++ b/libguh/types/statetype.cpp @@ -42,7 +42,8 @@ StateType::StateType(const StateTypeId &id): m_maxValue(QVariant()), m_possibleValues(QVariantList()), m_unit(Types::UnitNone), - m_ruleRelevant(true) + m_ruleRelevant(true), + m_graphRelevant(false) { } @@ -163,3 +164,15 @@ void StateType::setRuleRelevant(const bool &ruleRelevant) { m_ruleRelevant = ruleRelevant; } + +/*! Returns true if this StateType is interesting to visualize the logs in a graph/chart from a user perspective. */ +bool StateType::graphRelevant() const +{ + return m_graphRelevant; +} + +/*! Sets this StateType \a graphRelevant to inform the client application if this \l{StateType} is interesting to visualize the logs in a graph/chart. */ +void StateType::setGraphRelevant(const bool &graphRelevant) +{ + m_graphRelevant = graphRelevant; +} diff --git a/libguh/types/statetype.h b/libguh/types/statetype.h index 83716818..6cd43790 100644 --- a/libguh/types/statetype.h +++ b/libguh/types/statetype.h @@ -61,6 +61,9 @@ public: bool ruleRelevant() const; void setRuleRelevant(const bool &ruleRelevant); + bool graphRelevant() const; + void setGraphRelevant(const bool &graphRelevant); + private: StateTypeId m_id; QString m_name; @@ -72,6 +75,8 @@ private: QVariantList m_possibleValues; Types::Unit m_unit; bool m_ruleRelevant; + bool m_graphRelevant; + }; #endif // STATETYPE_H diff --git a/plugins/deviceplugins/mock/devicepluginmock.json b/plugins/deviceplugins/mock/devicepluginmock.json index 1822a2f4..9885486d 100644 --- a/plugins/deviceplugins/mock/devicepluginmock.json +++ b/plugins/deviceplugins/mock/devicepluginmock.json @@ -72,6 +72,7 @@ "name": "Dummy int state", "index": 0, "defaultValue": 10, + "graphRelevant": true, "type": "int" }, { @@ -86,7 +87,8 @@ { "id": "45bf3752-0fc6-46b9-89fd-ffd878b5b22b", "index": 0, - "name": "Mock Event 1" + "name": "Mock Event 1", + "graphRelevant": true }, { "id": "863d5920-b1cf-4eb9-88bd-8f7b8583b1cf", diff --git a/server/jsonrpc/jsontypes.cpp b/server/jsonrpc/jsontypes.cpp index ded1e5f7..3379be0e 100644 --- a/server/jsonrpc/jsontypes.cpp +++ b/server/jsonrpc/jsontypes.cpp @@ -172,6 +172,7 @@ void JsonTypes::init() s_stateType.insert("defaultValue", basicTypeToString(Variant)); s_stateType.insert("o:unit", unitRef()); s_stateType.insert("o:ruleRelevant", basicTypeToString(Bool)); + s_stateType.insert("o:graphRelevant", basicTypeToString(Bool)); s_stateType.insert("o:minValue", basicTypeToString(Variant)); s_stateType.insert("o:maxValue", basicTypeToString(Variant)); s_stateType.insert("o:possibleValues", QVariantList() << basicTypeToString(Variant)); @@ -198,6 +199,7 @@ void JsonTypes::init() s_eventType.insert("index", basicTypeToString(Int)); s_eventType.insert("paramTypes", QVariantList() << paramTypeRef()); s_eventType.insert("o:ruleRelevant", basicTypeToString(Bool)); + s_eventType.insert("o:graphRelevant", basicTypeToString(Bool)); // Event s_event.insert("eventTypeId", basicTypeToString(Uuid)); @@ -397,6 +399,9 @@ QVariantMap JsonTypes::packEventType(const EventType &eventType) if (!eventType.ruleRelevant()) variant.insert("ruleRelevant", false); + if (eventType.graphRelevant()) + variant.insert("graphRelevant", true); + QVariantList paramTypes; foreach (const ParamType ¶mType, eventType.paramTypes()) { paramTypes.append(packParamType(paramType)); @@ -513,6 +518,9 @@ QVariantMap JsonTypes::packStateType(const StateType &stateType) if (!stateType.ruleRelevant()) variantMap.insert("ruleRelevant", false); + if (stateType.graphRelevant()) + variantMap.insert("graphRelevant", true); + if (stateType.maxValue().isValid()) variantMap.insert("maxValue", stateType.maxValue());