Temperature Service¶
The Knut temperature service is represented by the Temperature
object. The incoming communication from the server is handled by the
TemperatureClient
which calls a corresponding handler method for
each message type. The temperature object it self can only read data from the
server and can not change the temperature (… that would be an awesome
feature).
-
class
Temperature
: public QObject¶ Property
-
property
Temperature::condition
The code point for the current of the weather icon.
-
property
Temperature::location
The location where the temperature is measured.
-
property
Temperature::temperature
The temperature in degree Celsius.
-
property
Temperature::unit
The unit symbol in which the temperature is given.
-
property
Temperature::timeHistory
The time points matching the temperatureHistory in milliseconds since the epoch January 1, 1970, 00:00:00 (UTC).
-
property
Temperature::temperatureHistory
The temperature history matching the timeHistory.
-
property
-
class
TemperatureClient
: public QObject¶ Public Types
-
enum
MessageId
¶ Message ID used to communicate with the Knut server via the KnutClient::writeRequest().
For more details read the client API documentation of the server.
Values:
-
STATUS_REQUEST
= 1¶ Requests the temperature status for a single location. The message must have the key
uniqueName
.
-
STATUS_RESPONSE
= 2¶ The status of a single temperature.
-
TEMPERATURE_LIST_REQUEST
= 3¶ Request a list of all temperature locations with their status.
-
TEMPERATURE_LIST_RESPONSE
= 4¶ A list of temperature locations with their status.
-
TEMPERATURE_HISTORY_REQUEST
= 5¶ Request the temperature history for a single location.
-
TEMPERATURE_HISTORY_RESPONSE
= 6¶ The temperature history of a single location with the corresponding time history.
-
Public Functions
-
void
connectToClient
(KnutClient *socket)¶ Connects to the KnutClient knutClient.
Connects the onKnutConnected() slot to the KnutClient::knutConnected() signal and the onReadyRead() slot to the signal KnutClient::receivedMessage() signal.
Public Slots
-
void
onKnutConnected
()¶ Slot is called when the connection state of the KnutClient to the Knut server changed.
-
void
onReadyRead
(const QJsonObject &payload, const quint8 &serviceId, const quint16 &messageId)¶ Slot called when a message is available.
If a message is received by the KnutClient, this slot is called. If the serviceId is
0x01
, a corresponding response handle method is called for the messageId.- See
TemperatureClient::MessageId
Property
-
property
TemperatureClient::temperatureModel
The model of all temperatures with the roles
location
andtemperature
wheretemperature
references to a Temperature service.
-
property
TemperatureClient::localWeather
The local weather Temperature object.
-
enum