Exemplo n.º 1
0
void ImportIED::impIED(IED* ied)
{
    QDomNode iedNode;
    //*******
    QList<QDomNode> ldList;
    QList<QDomNode> dsList;
    QList<QDomNode> pointList;

    QDomElement ldEle;
    QDomElement dsEle;
    QDomNode ln0Node;

    //初始化
    dataTypeTemplates = xmlhelplib.selectNodesList("SCL/DataTypeTemplates").at(0);
    subNetList = xmlhelplib.selectNodesList("SCL/Communication/SubNetwork");
    allPointList.clear();
    QString iedName = ied->name;
    qDebug()<<"***Imp:"<<iedName;
    iedNode = xmlhelplib.selectSingleNode(QString("SCL/IED[@name=%1]").arg(iedName));

    //************TCP NET
//    QList<TcpNet*> netList = getNetList(iedName);

    //***LD
    ldList = getLdByIed(iedNode);
    for(int j=0;j<ldList.size();j++)
    {
        QDomNode ldNode = ldList.at(j);
        ldEle = ldNode.toElement();
        Ldevice* ld = new Ldevice;
        ld->name = ldEle.attribute("inst");
        ld->desc = ldEle.attribute("desc");

        //*********12.17日增加 logicnode 表************//
        ln0Node = xmlhelplib.getChildNode(ldEle,"LN0");//*
        QList<QDomNode> lnList = xmlhelplib.getChildNodes(ldNode,"LN");
        lnList.insert(0,ln0Node);
        //插入逻辑节点,并返回逻辑节点的Hash
        QHash<QString,QDomNode> lnHash;
        QString ln0NodeId;
        QString ln0NodeChildID;
        foreach(QDomNode lnNode,lnList)
        {
            LdNode* ln = getLN(lnNode);
            if(ln->lnClass == "LLN0")
            {
                ln0NodeId = ln->id;
                ln0NodeChildID = ln->cId;
            }

            QString key = QString("%1%2%3").arg(ln->prefix).arg(ln->lnClass).arg(ln->inst);
            lnHash.insert(key,lnNode);
        }

        //***控制点集合
        QList<Pointdef*> ctrlPointList = getCtlPoints(lnList);
        if(!ctrlPointList.isEmpty())
        {
            Dataset* ctrlDS = new Dataset;
            ctrlDS->name = "dsCtrl";
            ctrlDS->desc = tr("dsCtrl");

            for(int n=0;n<ctrlPointList.size();n++)
            {
                Pointdef *point = ctrlPointList[n];
                allPointList.append(point);
//                insertCtrlPoints2DB(ctrlDS->id,ctrlDS->cId,point); //插入控制点
            }
        }

        //***ds数据集处理
        dsList = getDsByLd(ldEle);
        for(int k=0;k<dsList.size();k++)
        {
            dsEle = dsList.at(k).toElement();
            Dataset* ds = new Dataset;
            ds->name = dsEle.attribute("name");
            ds->desc = dsEle.attribute("desc");

            //***点
            pointList = getPointByDs(dsList.at(k));
            for(int m=0;m<pointList.size();m++)
            {
                QDomElement pointEle = pointList.at(m).toElement();
                QDomElement pointLN = getPointLN(pointEle,lnHash);

                Pointdef* po = getPoint(pointEle,pointLN);
                allPointList.append(po);
            }
        }
    }
Exemplo n.º 2
0
int main() {
#if HIGH_LEVEL_INTERFACE == 1
	start();

	interface_gse_send_E1Q1SB1_C1_Performance(1, 512);

	return 0;
#else
    int len = 0;

	initialise_iec61850();
	fp = initWinpcap();

	srand(time(NULL));
	float valueGSE = (float) rand() / (float) RAND_MAX;
	float valueSV = (float) rand() / (float) RAND_MAX;

	// test GOOSE
	E1Q1SB1.S1.C1.TVTRa_1.Vol.instMag.f = valueGSE;
	len = E1Q1SB1.S1.C1.LN0.ItlPositions.send(buf, 0, 512);
	pcap_sendpacket(fp, buf, len);

	gse_sv_packet_filter(buf, len);
	printf("GSE test: %s\n", D1Q1SB4.S1.C1.RSYNa_1.gse_inputs_ItlPositions.E1Q1SB1_C1_Positions.C1_TVTR_1_Vol_instMag.f == valueGSE ? "passed" : "failed");
	fflush(stdout);

	// test database lookup
	unsigned char databaseValueResult = 0;
	Item *ln = getLN("E1Q1SB1", "C1", "TVTRa_1");
	if (ln != NULL) {
		Item *valueDatabaseRef = getItem(ln, 3, "Vol", "instMag", "f");
		if (valueDatabaseRef != NULL) {
			float *databaseValue = (float *) (valueDatabaseRef->data);
			if (*databaseValue == valueGSE) {
				databaseValueResult = TRUE;
			}
		}
		else {
			printf("Database lookup test: item null\n");
		}
	}
	else {
		printf("Database lookup test: LN null\n");
	}
	printf("Database lookup test: %s\n", databaseValueResult ? "passed" : "failed");
	fflush(stdout);

	// test database lookup 2
	Item *valueDatabaseRef2 = getItemFromPath("E1Q1SB1", "C1/TVTRa_1.Vol.instMag.f");
	char databaseBuf[64] = {0};
	itemToJSON(databaseBuf, valueDatabaseRef2);
	printf("Database lookup test 2: %f, %s\n", *(float *) valueDatabaseRef2->data, databaseBuf);
	fflush(stdout);

	// test database print
	printf("Database print test:\n");
	char printBuf[10000];
	int charsPrinted =  itemTreeToJSON(printBuf, getIED("E1Q1SB1"), 0);
	printf("%d\n%s\n", charsPrinted, printBuf);
	charsPrinted =  itemTreeToJSONPretty(printBuf, getIED("E1Q1SB1"), 0);
	printf("%d\n%s\n", charsPrinted, printBuf);
	fflush(stdout);

	// test Sampled Values
	E1Q1SB1.S1.C1.exampleRMXU_1.AmpLocPhsA.instMag.f = valueSV;
	int i = 0;
	for (i = 0; i < E1Q1SB1.S1.C1.LN0.rmxuCB.noASDU; i++) {
		len = E1Q1SB1.S1.C1.LN0.rmxuCB.update(buf);

		if (len > 0) {
			pcap_sendpacket(fp, buf, len);
			gse_sv_packet_filter(buf, len);

			printf("SV test: %s\n", D1Q1SB4.S1.C1.exampleMMXU_1.sv_inputs_rmxuCB.E1Q1SB1_C1_rmxu[15].C1_RMXU_1_AmpLocPhsA.instMag.f == valueSV ? "passed" : "failed");
			fflush(stdout);
		}
	}

	pcap_close(fp);

	return 0;
#endif
}