Exemple #1
0
EntityPtr Entity::Clone(bool local, bool temporary, const QString &cloneName, AttributeChange::Type changeType) const
{
    QDomDocument doc("Scene");
    QDomElement sceneElem = doc.createElement("scene");
    QDomElement entityElem = doc.createElement("entity");
    entityElem.setAttribute("sync", BoolToString(!local));
    entityElem.setAttribute("id", local ? scene_->NextFreeIdLocal() : scene_->NextFreeId());
    // Set the temporary status in advance so it's valid when Scene::CreateContentFromXml signals changes in the scene
    entityElem.setAttribute("temporary", BoolToString(temporary));
    // Setting of a new name for the clone is a bit clumsy, but this is the best way to do it currently.
    const bool setNameForClone = !cloneName.isEmpty();
    bool cloneNameWritten = false;
    for(ComponentMap::const_iterator i = components_.begin(); i != components_.end(); ++i)
    {
        i->second->SerializeTo(doc, entityElem);
        if (setNameForClone && !cloneNameWritten && i->second->TypeId() == EC_Name::ComponentTypeId)
        {
            // Now that we've serialized the Name component, overwrite value of the "name" attribute.
            QDomElement nameComponentElem = entityElem.lastChildElement();
            nameComponentElem.firstChildElement().setAttribute("value", cloneName);
            cloneNameWritten = true;
        }
    }
    sceneElem.appendChild(entityElem);
    doc.appendChild(sceneElem);

    QList<Entity *> newEntities = scene_->CreateContentFromXml(doc, true, changeType);
    return (!newEntities.isEmpty() && newEntities.first() ? newEntities.first()->shared_from_this() : EntityPtr());
}
void QgsConfigParser::appendExGeographicBoundingBox( QDomElement& layerElem,
    QDomDocument& doc,
    const QgsRectangle& layerExtent,
    const QgsCoordinateReferenceSystem& layerCRS ) const
{
  if ( layerElem.isNull() )
  {
    return;
  }

  QgsCoordinateReferenceSystem wgs84;
  wgs84.createFromOgcWmsCrs( GEO_EPSG_CRS_AUTHID );

  //Ex_GeographicBoundingBox
  //transform the layers native CRS into WGS84
  QgsCoordinateTransform exGeoTransform( layerCRS, wgs84 );
  QgsRectangle wgs84BoundingRect = exGeoTransform.transformBoundingBox( layerExtent );

  QDomElement ExGeoBBoxElement = doc.createElement( "EX_GeographicBoundingBox" );
  QDomElement wBoundLongitudeElement = doc.createElement( "westBoundLongitude" );
  QDomText wBoundLongitudeText = doc.createTextNode( QString::number( wgs84BoundingRect.xMinimum() ) );
  wBoundLongitudeElement.appendChild( wBoundLongitudeText );
  ExGeoBBoxElement.appendChild( wBoundLongitudeElement );
  QDomElement eBoundLongitudeElement = doc.createElement( "eastBoundLongitude" );
  QDomText eBoundLongitudeText = doc.createTextNode( QString::number( wgs84BoundingRect.xMaximum() ) );
  eBoundLongitudeElement.appendChild( eBoundLongitudeText );
  ExGeoBBoxElement.appendChild( eBoundLongitudeElement );
  QDomElement sBoundLatitudeElement = doc.createElement( "southBoundLatitude" );
  QDomText sBoundLatitudeText = doc.createTextNode( QString::number( wgs84BoundingRect.yMinimum() ) );
  sBoundLatitudeElement.appendChild( sBoundLatitudeText );
  ExGeoBBoxElement.appendChild( sBoundLatitudeElement );
  QDomElement nBoundLatitudeElement = doc.createElement( "northBoundLatitude" );
  QDomText nBoundLatitudeText = doc.createTextNode( QString::number( wgs84BoundingRect.yMaximum() ) );
  nBoundLatitudeElement.appendChild( nBoundLatitudeText );
  ExGeoBBoxElement.appendChild( nBoundLatitudeElement );

  //BoundingBox element
  QDomElement bBoxElement = doc.createElement( "BoundingBox" );
  if ( layerCRS.isValid() )
  {
    bBoxElement.setAttribute( "CRS", layerCRS.authid() );
  }

  bBoxElement.setAttribute( "minx", QString::number( layerExtent.xMinimum() ) );
  bBoxElement.setAttribute( "miny", QString::number( layerExtent.yMinimum() ) );
  bBoxElement.setAttribute( "maxx", QString::number( layerExtent.xMaximum() ) );
  bBoxElement.setAttribute( "maxy", QString::number( layerExtent.yMaximum() ) );

  QDomElement lastCRSElem = layerElem.lastChildElement( "CRS" );
  if ( !lastCRSElem.isNull() )
  {
    layerElem.insertAfter( ExGeoBBoxElement, lastCRSElem );
    layerElem.insertAfter( bBoxElement, ExGeoBBoxElement );
  }
  else
  {
    layerElem.appendChild( ExGeoBBoxElement );
    layerElem.appendChild( bBoxElement );
  }
}
Attribute::Attribute(const QDomElement& element)
    : m_references()
{
    if (element.firstChildElement() != element.lastChildElement()) {
        kFatal() << "We don't handle complex attributes so far";
    }
    QDomElement content = element.firstChildElement();
    if (content.tagName() == "ref") {
        m_references << content.attribute("name");
    }
    m_name = element.attribute("name");
    m_values = listValuesFromNode(element);
    if (m_name == "style:border-line-width")
        m_requiredExtraAttributes["fo:border"] = "double";
    else if (m_name == "style:border-line-width-left")
        m_requiredExtraAttributes["fo:border-left"] = "double";
    else if (m_name == "style:border-line-width-right")
        m_requiredExtraAttributes["fo:border-right"] = "double";
    else if (m_name == "style:border-line-width-top")
        m_requiredExtraAttributes["fo:border-top"] = "double";
    else if (m_name == "style:border-line-width-bottom")
        m_requiredExtraAttributes["fo:border-bottom"] = "double";
    else if (m_name == "style:diagonal-tl-br-widths")
        m_requiredExtraAttributes["style:diagonal-tl-br"] = "double";
    else if (m_name == "style:diagonal-bl-tr-widths")
        m_requiredExtraAttributes["style:diagonal-bl-tr"] = "double";
    
}
Exemple #4
0
bool Converter::convertFrame(const QDomElement &element)
{
    QDomElement child = element.firstChildElement();
    QDomElement suchild = element.lastChildElement("title");
    /// svg:title alt && title 
    while (!child.isNull())
    {
        if (child.tagName() == QLatin1String("image"))
        {
            const QString href = child.attribute("href");
            const QString xname = element.attribute("name");
            QString alttitle = QString("Name:%1 - Ref:%2").arg(xname).arg(href);
            if (suchild.tagName() == QLatin1String("title"))
            {
                alttitle.append(QString(" - Title:%1").arg(suchild.text()));
            }
            QTextImageFormat format;
            format.setToolTip(alttitle);
            format.setWidth(4.0/3.0*StyleParser::convertUnit(element.attribute("width")));
            format.setHeight(4.0/3.0*StyleParser::convertUnit(element.attribute("height")));
            format.setName(href);
            format.setBackground(Qt::white);
            m_Cursor->insertImage(format);
        }

        child = child.nextSiblingElement();
    }

    return true;
}
void PhonemeEditorWidget::parseXmlFile()
{
    // Clear old text boxes
    QList<TimeLineTextEdit *> oldText= m_text->findChildren<TimeLineTextEdit *>();
    while(!oldText.isEmpty())
        delete oldText.takeFirst();

    // Clear old phoneme comboboxes
    QList<TimeLineComboBox *> oldPhoneme = m_phonemes->findChildren<TimeLineComboBox *>();
    while(!oldPhoneme.isEmpty())
        delete oldPhoneme.takeFirst();

    // Get new items from phoneme xml
    QDomElement timings = m_phonemeXml.firstChildElement("PhonemeTimings");

    // Get length of phoneme timings
    QDomElement last = timings.lastChildElement("word");
    int sentenceLength = 0;
    if(!last.isNull()) sentenceLength = last.attribute("end", "0").toInt();
    last = timings.lastChildElement("phn");
    if( !last.isNull() ) sentenceLength = max(sentenceLength, last.attribute("end", "0").toInt() );

    // Get minimal phoneme width
    QDomNodeList phnlist = timings.elementsByTagName("phn");
    int minPhnWidth = 999999;
    for(unsigned int i=0; i<phnlist.length(); i++)
    {
        QDomElement phn = phnlist.item(i).toElement();
        // Skip silence
        if( phn.attribute("value").compare("x") == 0 ) continue;
        int start = phn.attribute("start", "0").toInt();
        int end = phn.attribute("end", "999999").toInt();
        if( end-start < minPhnWidth ) minPhnWidth = end-start;
    }
    int minWidth =  (int)( 39.5f / minPhnWidth * sentenceLength );

    // Get length of panels and enlarge them if too small
    if( m_text->width()-2 < minWidth)
    {
        m_text->setFixedWidth(minWidth+2);
        m_phonemes->setFixedWidth(minWidth+2);
        m_phonemeScrollArea->setFixedWidth(m_text->x()+minWidth+2);
    }

    // Add wordBoxes in reverse direction, because first nodes have higher priority
    // and should be printed above of the others
    QDomNode wordNode = timings.lastChild();
    while(!wordNode.isNull())
    {
        // Get words
        if( wordNode.nodeName().compare("word") == 0)
        {
            QDomElement word = wordNode.toElement();
            TimeLineTextEdit* wordBox = new TimeLineTextEdit(word, sentenceLength, m_text);
            connect(wordBox, SIGNAL(xmlNodeChanged()), this, SLOT(enableSaveButton()) );
            wordBox->setVisible(true);

            // Get phonemes of a word
            QDomNodeList phonemeList = word.elementsByTagName("phn");
            // also reverse direction
            for(int i = phonemeList.size()-1; i >=0; i--)
            {
                QDomElement phoneme = phonemeList.item(i).toElement();
                // Skip silence
                if( phoneme.attribute("value").compare("x") == 0 ) continue;
                TimeLineComboBox* phonemeBox = new TimeLineComboBox(phoneme, sentenceLength, m_phonemeList, m_phonemes);
                connect(phonemeBox, SIGNAL(xmlNodeChanged()), this, SLOT(enableSaveButton()) );
                connect(phonemeBox, SIGNAL(xmlNodeChanged()), wordBox, SLOT(updateFromXml()));
                phonemeBox->setVisible(true);
            }
        }
        // Get phonemes which don't belong to words
        else if( wordNode.nodeName().compare("phn") == 0 )
        {
            QDomElement phoneme = wordNode.toElement();
            // Skip silence
            if( phoneme.attribute("value").compare("x") != 0 )
            {
                TimeLineComboBox* phonemeBox = new TimeLineComboBox(phoneme, sentenceLength, m_phonemeList, m_phonemes);
                connect(phonemeBox, SIGNAL(xmlNodeChanged()), this, SLOT(enableSaveButton()) );
                phonemeBox->setVisible(true);
            }
        }

        wordNode = wordNode.previousSibling();
    }
}
Exemple #6
0
/************************************************
 Duplicate <MergeXXX> elements (that specify the same file) are handled as with
 duplicate <AppDir> elements (the last duplicate is used).
 ************************************************/
void XdgMenuReader::processMergeTags(QDomElement& element)
{
    QDomElement n = element.lastChildElement();
    QStringList mergedFiles;


    while (!n.isNull())
    {
        QDomElement next = n.previousSiblingElement();
        // MergeFile ..................
        if (n.tagName() == "MergeFile")
        {
            processMergeFileTag(n, &mergedFiles);
            n.parentNode().removeChild(n);
        }

        // MergeDir ...................
        else if(n.tagName() == "MergeDir")
        {
            processMergeDirTag(n, &mergedFiles);
            n.parentNode().removeChild(n);
        }

        // DefaultMergeDirs ...........
        else if (n.tagName() == "DefaultMergeDirs")
        {
            processDefaultMergeDirsTag(n, &mergedFiles);
            n.parentNode().removeChild(n);
        }

        // AppDir ...................
        else if(n.tagName() == "AppDir")
        {
            processAppDirTag(n);
            n.parentNode().removeChild(n);
        }

        // DefaultAppDirs .............
        else if(n.tagName() == "DefaultAppDirs")
        {
            processDefaultAppDirsTag(n);
            n.parentNode().removeChild(n);
        }

        // DirectoryDir ...................
        else if(n.tagName() == "DirectoryDir")
        {
            processDirectoryDirTag(n);
            n.parentNode().removeChild(n);
        }

        // DefaultDirectoryDirs ...........
        else if(n.tagName() == "DefaultDirectoryDirs")
        {
            processDefaultDirectoryDirsTag(n);
            n.parentNode().removeChild(n);
        }


        // Menu .......................
        else if(n.tagName() == "Menu")
        {
            processMergeTags(n);
        }

        n = next;
    }

}
Exemple #7
0
void writeJob::dragModuleName(const QString name, const int index, const int allRow, const QString upOrDown)
{
    qDebug()<<"4.dragModuleName";
    QDomElement root = doc.documentElement();
    QDomElement modEle = root.firstChildElement("Module");
    if(index==0)  //插到头
    {
        while (!modEle.isNull())
        {
            if(modEle.attribute("name")==name && modEle.attribute("id")==moduleID)
            {
                QDomElement firstModEle=root.firstChildElement("Module");
                root.insertBefore(modEle,firstModEle);
                break;
            }
            modEle = modEle.nextSiblingElement("Module");
        }
    }
    else if(index==(allRow-1))  // 插到尾
    {
        while (!modEle.isNull())
        {
            if(modEle.attribute("name")==name && modEle.attribute("id")==moduleID)
            {
                QDomElement lastModEle=root.lastChildElement("Module");
                root.insertAfter(modEle,lastModEle);
                break;
            }
            modEle = modEle.nextSiblingElement("Module");
        }
    }

    else   //其他情况
    {
        QDomElement insertAfterEle;
        QDomElement rightEle;

        insertAfterEle=modEle;
        //难道还要分上到下,下到上??
        if(upOrDown=="up")
        {
            for(int i=0; i<index-1;i++)
            {
                modEle = modEle.nextSiblingElement("Module");
                insertAfterEle=modEle;
                qDebug()<<i<<insertAfterEle.attribute("name");
            }
        }
        if(upOrDown=="down")
        {
            for(int i=0; i<index;i++)
            {
                modEle = modEle.nextSiblingElement("Module");
                insertAfterEle=modEle;
                qDebug()<<i<<insertAfterEle.attribute("name");
            }
        }
        modEle=root.firstChildElement("Module");
        while (!modEle.isNull())
        {
            if(modEle.attribute("name")==name && modEle.attribute("id")==moduleID)
            {
                rightEle=modEle;
                qDebug()<<rightEle.attribute("name")<<insertAfterEle.attribute("name");
                root.insertAfter(rightEle,insertAfterEle);
                break;
            }
            modEle = modEle.nextSiblingElement("Module");
        }
    }

    if(!write())
        qDebug()<<"delete job failed";
}
Exemple #8
0
ResourcePtr ModelMaker::readResource(Model& model, const QDomElement& el)
{
    QString rdfns = RDFVocab::self()->namespaceURI();
    QString about = QLatin1String("about");
    QString resource = QLatin1String("resource");
    QString descriptionStr = QLatin1String("Description");

    ResourcePtr res;

    ResourcePtr type = model.createResource(el.namespaceURI() + el.localName());

    if (*type == *(RDFVocab::self()->seq()))
    {
        SequencePtr seq = model.createSequence(el.attribute(about));
        
        res = seq;
    }
    else
    {
        res = model.createResource(el.attribute(about));
    }

    model.addStatement(res, RDFVocab::self()->type(), type);

    QDomNodeList children = el.childNodes();

    bool isSeq = res->isSequence();
    
    for (uint i = 0; i < children.length(); ++i)
    {
        if (children.item(i).isElement())
        {
            QDomElement ce = children.item(i).toElement();
        
            PropertyPtr pred = model.createProperty(ce.namespaceURI() + ce.localName());
        
            if (ce.hasAttribute(resource)) // referenced Resource via (rdf:)resource
            {
                NodePtr obj = model.createResource(ce.attribute(resource));
                
                if (isSeq && *pred == *(RDFVocab::self()->li()))
                {
                    SequencePtr tseq = boost::static_pointer_cast<Sequence>(res);
                    tseq->append(obj);
                }
                else
                    model.addStatement(res, pred, obj);
            }
            else if (!ce.text().isEmpty() && ce.lastChildElement().isNull()) // Literal
            {
                NodePtr obj = model.createLiteral(ce.text());
                
                if (isSeq && *pred == *(RDFVocab::self()->li()))
                {
                    SequencePtr tseq = boost::static_pointer_cast<Sequence>(res);
                    tseq->append(obj);
                }
                else
                    model.addStatement(res, pred, obj);
            }
            else // embedded description
            {
                QDomElement re = ce.lastChildElement();
                
                QString uri = re.attribute(about);
                
                // read recursively
                NodePtr obj = readResource(model, re);
                
                if (isSeq && *pred == *(RDFVocab::self()->li()))
                {
                    SequencePtr tseq = boost::static_pointer_cast<Sequence>(res);
                    tseq->append(obj);
                }
                else
                    model.addStatement(res, pred, obj);

            }
        
        //TODO: bag, reification (nice to have, but not important for basic RSS 1.0)
        }
    }
    
    return res;
}
//解析xml协议
void StreamMonitor::doParseXml(QString xml)
{
    LOG(INFO,"rcv xml msg:");
    qInfo()<<xml;
    QDomDocument document;
    QString error;
    int row = 0, column = 0;
    if(!document.setContent(xml, false, &error, &row, &column))     //加载xml内容
    {
        qCritical()<<(QString("parse file failed at line row and column") + QString::number(row, 10) + QString(",") + QString::number(column, 10));
        return ;
    }
    if(document.isNull())
    {
        LOG(WARNING,"document is null");
        return ;
    }

    //解析
    QDomElement message = document.documentElement();        //<message>
    QDomElement type = message.firstChildElement();		//<TYPE>标签
    qInfo()<<"type="<<type.text().toInt();

    switch (type.text().toInt()) {
        case Rcv_Cameras_Info:
        {
            qInfo()<<" Cameras List Parse";
            QDomElement action = message.firstChildElement("ACTION");          //<ACTION>
            qInfo()<<"action(1,init; 2,add; 3,del)="<<action.text().toInt();
            //<Equipment>
            QDomNodeList equipments = message.elementsByTagName("Equipment");
            int nCount = equipments.count();
            for(int i=0; i<nCount; i++)
            {
                QDomNode eqNode = equipments.item(i);
                QDomElement equipment = eqNode.toElement();         //<EquipMent>
                QDomElement cameraId = equipment.firstChildElement(); //<CAMID>
                CameraStateInfo camInfo;
                camInfo.cmareId = cameraId.text();
                qInfo()<<"cameraId="<<cameraId.text();
                QDomElement udpAddr = equipment.lastChildElement("UDP");  //<UDP>
                camInfo.udpAddr = udpAddr.text();
                qInfo()<<"udpAddr="<<udpAddr.text();

                QDomElement uuid = equipment.firstChildElement("UUID");     //<UUID>
                camInfo.uuid = uuid.text();
                QDomElement status = equipment.firstChildElement("STATUS");     //<STATUS>
                camInfo.online = status.text().toInt()? false:true;     //0在线 1不在线
                switch (action.text().toInt())
                {
                case 1:         //init
                case 2:         //add
                {
                    if(!camerasInfo.contains(camInfo))
                    {
                        camerasInfo.append(camInfo);
                    }else
                        camerasInfo[camerasInfo.indexOf(camInfo)] = camInfo;
                }
                    break;
                case 3:            //del
                {
                    if(camerasInfo.contains(camInfo))
                    {
                        camerasInfo.removeOne(camInfo);
                    }
                }
                    break;
                default:
                    break;
                }
            }
        }
            break;
        case Rcv_Camera_Online:
        {
            qInfo()<<" Cameras online Parse";
            //<Equipment>
            QDomNodeList equipments = message.elementsByTagName("Equipment");
            int nCount = equipments.count();
            for(int i=0; i<nCount; i++)
            {
                QDomNode eqNode = equipments.item(i);
                QDomElement equipment = eqNode.toElement();         //<EquipMent>
                QDomElement cameraId = equipment.firstChildElement(); //<CAMID>
                QDomElement status = equipment.lastChildElement();          //<STATUS>

                CameraStateInfo camInfo;
                camInfo.cmareId = cameraId.text();
                camInfo.online = status.text().toInt()==0? true:false;
                if(camerasInfo.contains(camInfo))
                {
                    camerasInfo[camerasInfo.indexOf(camInfo)].online=camInfo.online;
                }else
                    camerasInfo.append(camInfo);
                qInfo()<<"cameraId="<<cameraId.text()<<" status(0 normal)="<<status.text().toInt();
                //来一条在线状态就要转发给运维
                OMData om;
                om.uuid = uuid;
                om.devId= camerasInfo[camerasInfo.indexOf(camInfo)].uuid;
                om.type="j7";
                om.status=camInfo.online? "0":"1";
                SendDataToOM(om);
            }
        }
            break;
        case RcV_Threads_Info:
        {
            qInfo()<<" threads list Parse";
            //<Equipment>
            QDomNodeList equipments = message.elementsByTagName("Equipment");
            int nCount = equipments.count();
            for(int i=0; i<nCount; i++)
            {
                QDomNode eqNode = equipments.item(i);
                QDomElement equipment = eqNode.toElement();         //<EquipMent>
                QDomElement threadId = equipment.firstChildElement("THRID"); //<THRID>
                QDomElement action = equipment.lastChildElement("ACTION");          //<ACTION>
                QDomElement optType = equipment.lastChildElement("OPTTYPE");         //<OPTTYPE>
                ThreadStateInfo threadInfo;
                threadInfo.threadId = threadId.text();
                threadInfo.action = action.text().toInt();
                if(!threadsInfo.contains(threadInfo))
                {
                    if(optType.text().toInt()==1)
                        threadsInfo.append(threadInfo);
                }else
                {
                    if(optType.text().toInt()==2)           //1 add  2 delete
                        threadsInfo.removeOne(threadInfo);
                    else
                        threadsInfo[threadsInfo.indexOf(threadInfo)].action = threadInfo.action;
                }
                qInfo()<<"threadId="<<threadId.text()<<" action="<<action.text().toInt();
            }
        }
            break;
        case Rcv_HisFile_Info:
        {
            qInfo()<<" HisFile Info Parse";
            //<Equipment>
            QDomNodeList equipments = message.elementsByTagName("Equipment");
            int nCount = equipments.count();
            for(int i=0; i<nCount; i++)
            {
                QDomNode eqNode = equipments.item(i);
                QDomElement equipment = eqNode.toElement();         //<EquipMent>
                QDomElement cameraId = equipment.firstChildElement(); //<CAMID>
                QDomElement filepath = equipment.lastChildElement();          //<FILE>
                CameraStateInfo camInfo;
                camInfo.cmareId=cameraId.text();
                camInfo.hisVdSta.hisVdPath=filepath.text();
                if(camerasInfo.contains(camInfo))
                {
                    camerasInfo[camerasInfo.indexOf(camInfo)].hisVdSta.hisVdPath = camInfo.hisVdSta.hisVdPath;
                }else
                    camerasInfo.append(camInfo);

                //check the history file
                checkHisFile(camerasInfo[camerasInfo.indexOf(camInfo)]);
                qInfo()<<"cameraId="<<cameraId.text()
                   <<" filepath="<<filepath.text();
            }
        }
            break;
        case Rcv_Thread_Heart:
        {
            qInfo()<<" Thread Heart Parse";
            //<Equipment>
            QDomNodeList equipments = message.elementsByTagName("Equipment");
            int nCount = equipments.count();
            for(int i=0; i<nCount; i++)
            {
                QDomNode eqNode = equipments.item(i);
                QDomElement equipment = eqNode.toElement();         //<EquipMent>
                QDomElement threadId = equipment.firstChildElement(); //<THRID>
                qInfo()<<"threadId="<<threadId.text();
                for(int j=0; j<threadsInfo.size(); j++)
                {
                    if(threadsInfo[j].threadId == threadId.text())
                    {
                        threadsInfo[j].heartime = time(NULL);
                        break;
                    }
                }
            }
        }
            break;
        case Rcv_RelVd_Res:     //改用gsoap调用,所以该case分支不再使用,代码暂且保留。
        {
            qInfo()<<" Rel Vedeo Res Parse";
            //<Equipment>
            QDomNodeList equipments = message.elementsByTagName("Equipment");
            int nCount = equipments.count();
            for(int i=0; i<nCount; i++)
            {
                QDomNode eqNode = equipments.item(i);
                QDomElement equipment = eqNode.toElement();         //<EquipMent>
                QDomElement cameraId = equipment.firstChildElement(); //<CAMID>
                QDomElement status = equipment.lastChildElement();          //<Status>
                qInfo()<<"cameraId="<<cameraId.text()<<" status(0 normal)="<<status.text().toInt();
            }
        }
            break;
        case Rcv_HisVd_Res:
        {
            qInfo()<<"接收到历史视频调看请求的回应";
            //<Equipment>
            QDomNodeList equipments = message.elementsByTagName("Equipment");
            int nCount = equipments.count();
            for(int i=0; i<nCount; i++)
            {
                QDomNode eqNode = equipments.item(i);
                QDomElement equipment = eqNode.toElement();         //<EquipMent>
                QDomElement cameraId = equipment.firstChildElement(); //<CAMID>
                QDomElement httpurl = equipment.lastChildElement();          //<Httpurl>
                qInfo()<<"cameraId="<<cameraId.text()<<" httpurl(0 normal)="<<httpurl.text().toInt();
                checkHisURL(httpurl.text());
            }
        }
            break;
        case Rcv_YUNWEI_Info:
        {
            QDomElement uuidEl = message.firstChildElement("UUID");           //<UUID>
            QDomElement addr = message.firstChildElement("ADDRESS");               //<ADDRESS>
            uuid = uuidEl.text();
            if(isOMInited)
            {
                if(!NetMasterDestroy())
                {
                    LOG(INFO, ">>>>>> [NetMasterDestroy] is Success. <<<<<<\n");
                    isOMInited = false;
                    if(!NetMasterInit(addr.text().toStdString().c_str(), uuidEl.text().toStdString().c_str()))
                    {
                        LOG(INFO, ">>>>>> [NetMasterInit] is Success. <<<<<<");
                        isOMInited = true;
                        qInfo()<<"启动计时器,发送所有数据到运维";
                        sendToOMTimer->start(15000);
                    }else
                    {
                        LOG(INFO, ">>>>>> [NetMasterInit] is Fail! <<<<<<" );
                        isOMInited = false;
                    }
                }
                else
                {
                    LOG(INFO, ">>>>>> [NetMasterDestroy] is Fail! <<<<<<\n");
                    LOG(INFO, ("OM INFO:  uuid:"+uuidEl.text() +" ADDR:"+addr.text()).toStdString().c_str());
                }
            }else
            {
                if(!NetMasterInit(addr.text().toStdString().c_str(), uuidEl.text().toStdString().c_str()))
                {
                    LOG(INFO, ">>>>>> [NetMasterInit] is Success. <<<<<<");
                    isOMInited = true;
                    qInfo()<<"启动计时器,发送所有数据到运维";
                    sendToOMTimer->start(15000);
                }else
                {
                    LOG(INFO, ">>>>>> [NetMasterInit] is Fail! <<<<<<" );
                    isOMInited = false;
                }
            }
        }
            break;
        default:
            break;
    }

}
void PluginManager::addPlugin(QDir* dir) {
    QDomDocument doc;
    QFile pluginXmlFile(dir->absolutePath()+QDir::separator()+"plugin.xml");
    if(!pluginXmlFile.exists()) {
        qDebug("error plugin.xml not exist "+dir->absolutePath().toUtf8());
        return;
    }
    pluginXmlFile.open(QIODevice::ReadOnly);
    doc.setContent(&pluginXmlFile);
    pluginXmlFile.close();
    QDomElement plugin = doc.documentElement();
    QString name = plugin.lastChildElement("name").text();
    QString version = plugin.lastChildElement("version").text();
    QString description = plugin.lastChildElement("description").text();
    QString cellBackground = dir->absolutePath()+QDir::separator()+plugin.lastChildElement("cellBackground").text();
    Plugin* p =  new Plugin(name, description,version);
    p->setCellBackground(cellBackground);
    qDebug("Plugin: "+name.toUtf8());
    QDomNodeList listPawns = plugin.lastChildElement("pawns").elementsByTagName("pawn");
    for(int i = 0;i < listPawns.count(); i++)
    {
        QString pid = listPawns.at(i).lastChildElement("id").text();
        QString pname = listPawns.at(i).lastChildElement("name").text();
        QString picon = dir->absolutePath()+QDir::separator()+listPawns.at(i).lastChildElement("icon").text();
        if(!p->existPawn(pid))
        {
            qDebug("  Pawn: "+pname.toUtf8()+" (id:"+pid.toUtf8()+", icon:"+picon.toUtf8()+")");
            Pawn* pawn =  new Pawn(pid, pname, picon);
            p->addPawn(pawn);
        }
        else
        {
            qDebug("  Pawn can't add");
        }
    }
    QDomNodeList listrules = plugin.lastChildElement("rules").elementsByTagName("rule");
    for(int i = 0;i < listrules.count(); i++)
    {
        QString from = listrules.at(i).attributes().namedItem("pawn").toAttr().value();
        QString to = listrules.at(i).attributes().namedItem("newPawn").toAttr().value();
        if(p->existPawn(from) && p->existPawn(to)) {
            Rule* r = new Rule(p->getPawn(from), p->getPawn(to));
            qDebug("  Rule: (from:"+from.toUtf8()+" to:"+to.toUtf8()+")");
            for(int j = 0;j < listrules.at(i).childNodes().count(); j++)
            {
                QString op = listrules.at(i).childNodes().at(j).nodeName();
                QString pawn = listrules.at(i).childNodes().at(j).attributes().namedItem("pawn").toAttr().value();
                QString value = listrules.at(i).childNodes().at(j).toElement().text();

                int intValue = value.toInt();
                AbstractOperator* o = NULL;
                if(op == "pawnNumberIsEqual")
                    o = new EqualOperator(intValue, pawn);
                if(op == "pawnNumberIsLower")
                    o = new LowerOperator(intValue, pawn);
                if(op == "pawnNumberIsGreater")
                    o = new GreaterOperator(intValue, pawn);

                if(o != NULL && p->existPawn(pawn))
                {
                    r->addOperator(o);
                    qDebug("    with "+pawn.toUtf8()+" "+op.toUtf8()+" "+value.toUtf8());
                }
                else
                {
                    qDebug("    Operator can't add");
                }

            }
            p->getPawn(from)->addRule(r);
        }
        else
        {
            qDebug("  Rule can't add");
        }
    }
    plugins->push_back(p);
}