Ejemplo n.º 1
0
bool AvolitesD4Parser::fillFixtureDef(QLCFixtureDef* fixtureDef)
{
    if (m_documentRoot.isNull())
    {
        m_lastError = "no XML loaded to process";
        return false;
    }

    fixtureDef->setManufacturer(fixtureCompany());
    fixtureDef->setModel(fixtureName());
    fixtureDef->setAuthor(copyright());

    // Parse all channels
    if (!parseChannels(m_documentRoot.namedItem(KD4TagFixture).toElement().namedItem(KD4TagControl).toElement(), fixtureDef))
        return false;

    // Parse all modes
    if (!parseModes(m_documentRoot.namedItem(KD4TagFixture).toElement(), fixtureDef))
        return false;

    fixtureDef->setType(guessType(fixtureDef));

    // TODO TODO TODO
    // Maybe also import preset palettes and macros ?!?!?!?!
    /**
        Can't be done for now, as qxf files don't have any information on preset palettes or macros
        for fixtures, they are automatically generated on the main application maybe in future... **/

    return true;
}
Ejemplo n.º 2
0
bool Config::parse()
{
    std::ifstream ifs(m_path);

    // File exists?
    if (ifs.good())
    {
        const auto jsonDoc = json::parse(ifs);

        if (jsonDoc.is_object() && (jsonDoc.find("ipdvrConfig") != jsonDoc.end()))
        {
            DEBUG_PRINT("Found a valid ipdvrConfig root tag in file: " << m_path << std::endl);
        }
        else
        {
            ERROR_PRINT("Error parsing config file: " << m_path << std::endl);
            return false;
        }

        const auto rootNode = jsonDoc["ipdvrConfig"];
        if (rootNode.find("channels") != rootNode.end())
        {
            m_channelDataList = parseChannels(rootNode["channels"]);
            DEBUG_PRINT("Parsed a channel list with " << m_channelDataList.size() << " entries." << std::endl);
            return true;
        }
        else
        {
            ERROR_PRINT("No channels defined!" << std::endl);
            return false;
        }
    }
    else
    {
        ERROR_PRINT("Could not open configuration file: " << m_path << std::endl);
        return false;
    }
}