Esempio n. 1
0
  double GetStandardDeviation(void) const {
    if (k == 0)
      return 0.0;

    DBG_Assert(SigmaSqSum >= 0.0);
    return std::sqrt(SigmaSqSum) / (double) k;
  }
Esempio n. 2
0
/*! Inits the internet discovery manager.
 */
void DeRestPluginPrivate::initInternetDicovery()
{
    inetDiscoveryManager = new QNetworkAccessManager(this);
    connect(inetDiscoveryManager, SIGNAL(finished(QNetworkReply*)),
            this, SLOT(internetDiscoveryFinishedRequest(QNetworkReply*)));


    DBG_Assert(gwAnnounceInterval >= 0);
    if (gwAnnounceInterval < 0)
    {
        gwAnnounceInterval = 15;
    }

    inetDiscoveryTimer = new QTimer(this);

    connect(inetDiscoveryTimer, SIGNAL(timeout()),
            this, SLOT(internetDiscoveryTimerFired()));

    setInternetDiscoveryInterval(gwAnnounceInterval);

    // force first run
    if (gwAnnounceInterval > 0)
    {
        QTimer::singleShot(5000, this, SLOT(internetDiscoveryTimerFired()));
    }
}
Esempio n. 3
0
/*! Sets the light dimm level.
    \param level the dimm level (0..255)
 */
void LightNode::setLevel(uint16_t level)
{
    DBG_Assert(level <= 255);
    if (level <= 255)
    {
        m_level = level;
    }
}
Esempio n. 4
0
/*! Sets the lights CIE color coordinates.
    \param x the x coordinate (0..65279)
    \param y the y coordinate (0..65279)
 */
void LightNode::setColorXY(uint16_t x, uint16_t y)
{
    DBG_Assert(x <= 65279);
    DBG_Assert(y <= 65279);

    if (x > 65279)
    {
        x = 65279;
    }

    if (y > 65279)
    {
        y = 65279;
    }

    m_colorX = x;
    m_colorY = y;
}
Esempio n. 5
0
/*! Sets the lights enhanced hue.
    \param ehue the enhanced hue (0..65535)
 */
void LightNode::setEnhancedHue(uint16_t ehue)
{
    m_normHue = (((double)ehue) / 65535.0f);
    DBG_Assert(m_normHue >= 0.0f);
    DBG_Assert(m_normHue <= 1.0f);

    if (m_normHue < 0.0f)
    {
        m_normHue = 0.0f;
    }
    else if (m_normHue > 1.0f)
    {
        m_normHue = 1.0f;
    }
    m_hue = m_normHue * 254.0f;
    DBG_Assert(m_hue <= 254);

    m_ehue = ehue;
}
Esempio n. 6
0
/*! Sets the lights hue.
    \param hue the hue (0..254)
 */
void LightNode::setHue(uint8_t hue)
{
    DBG_Assert(hue <= 254);
    if (hue <= 254)
    {
        m_hue = hue;

        m_normHue = ((double)hue * 360.0f / 254.0f) / 360.0f;

        DBG_Assert(m_normHue >= 0.0f);
        DBG_Assert(m_normHue <= 1.0f);

        if (m_normHue < 0.0f)
        {
            m_normHue = 0.0f;
        }
        else if (m_normHue > 1.0f)
        {
            m_normHue = 1.0f;
        }

        m_ehue = (m_normHue * 65535.0f);
    }
}
Esempio n. 7
0
/*! Callback for finished HTTP requests.

    \param reply the reply to a HTTP request
 */
void DeRestPluginPrivate::internetDiscoveryFinishedRequest(QNetworkReply *reply)
{
    DBG_Assert(reply != 0);

    if (!reply)
    {
        return;
    }

    if (reply->error() == QNetworkReply::NoError)
    {
        DBG_Printf(DBG_INFO, "Announced to internet\n");
#ifdef ARCH_ARM
        // currently this is only supported for the RaspBee Gateway
        internetDiscoveryExtractVersionInfo(reply);
#endif // ARCH_ARM
    }
    else
    {
        DBG_Printf(DBG_INFO, "discovery network reply error: %s\n", qPrintable(reply->errorString()));
    }

    reply->deleteLater();
}
Esempio n. 8
0
/*! Sets the current colormode.
 * \param colorMode the colormode ("hs", "xy", "ct")
 */
void LightNode::setColorMode(const QString &colorMode)
{
    DBG_Assert((colorMode == "hs") || (colorMode == "xy") || (colorMode == "ct"));
    m_colorMode = colorMode;
}