void ColorTest::configuration() { Corrade::Utility::Configuration c; Color3f color3(0.5f, 0.75f, 1.0f); std::string value3("0.5 0.75 1"); c.setValue("color3", color3); CORRADE_COMPARE(c.value("color3"), value3); CORRADE_COMPARE(c.value<Color3f>("color3"), color3); Color4f color4(0.5f, 0.75f, 0.0f, 1.0f); std::string value4("0.5 0.75 0 1"); c.setValue("color4", color4); CORRADE_COMPARE(c.value("color4"), value4); CORRADE_COMPARE(c.value<Color4f>("color4"), color4); }
void TrapList::makeAlarmTrapDatagram(Alarm_Trap_type_E type, AlarmRecord *record) { if( !inited ) { return; } if (record == NULL) return; /*检查trapbuf是否满*/ if (endIndex != currentIndex) { //�Ƿ�buffer������� ���� if ((endIndex == TrapMaxNumber - 1) && currentIndex == 0) { return; } else if ((endIndex + 1) == currentIndex) { return; } } /*VBS 初始化*/ OIDImplTrapItem[10] = 3; OIDImplEventID[10] = 2; SNMPPdu pdu; pdu.commond = SNMPPdu::TRAP; VariableBinding vb[5]; pdu.variableBindings.variableBinding = vb; pdu.variableBindings.vbsLength = 5; /*1.3.6.1.2.1.1.3.0 Timeticks*/ OID oid1(OIDImplTimeticks, 9); pdu.variableBindings.getAt(0)->setOID(&oid1); TimeTicks value1(record->itsRaiseTime()); pdu.variableBindings.getAt(0)->setValue(&value1); /*1.3.6.1.6.3.1.1.4.1.0 TrapOID*/ /*1.3.6.1.4.1.25449.1.1.12.2.type alarmType*/ OID oid2(OIDTrapFix, 11); pdu.variableBindings.getAt(1)->setOID(&oid2); OIDImplEventID[11] = record->itsAlarmType(); if( type == alarm_clear ) { OIDImplEventID[11] |= 0x8000; } OID value2(OIDImplEventID, 12); pdu.variableBindings.getAt(1)->setValue(&value2); /*1.3.6.1.4.1.25449.1.1.12.3.1 alarm sn*/ OIDImplTrapItem[11] = 1; OID oid3(OIDImplTrapItem, 12); pdu.variableBindings.getAt(2)->setOID(&oid3); Integer32 value3(record->itsSN()); pdu.variableBindings.getAt(2)->setValue(&value3); //Alarm source ID /*1.3.6.1.4.1.25449.1.1.12.3.2 Alarm source ID*/ OIDImplTrapItem[11] = 2; OID oid4(OIDImplTrapItem, 12); pdu.variableBindings.getAt(3)->setOID(&oid4); Integer32 value4(record->itsAlarmSource()); pdu.variableBindings.getAt(3)->setValue(&value4); //Alarm level /*1.3.6.1.4.1.25449.1.1.12.3.3 Alarm level*/ OIDImplTrapItem[11] = 3; OID oid5(OIDImplTrapItem, 12); pdu.variableBindings.getAt(4)->setOID(&oid5); Integer32 value5(record->itsAlarmLevel()); pdu.variableBindings.getAt(4)->setValue(&value5); int pklen = pdu.getPDUBerLength(); int buflen = pklen + 1 + SNMPPdu::getLengthBerLength(pklen); ///unsigned char *buf = new unsigned char[buflen]; if (pdu.encode((unsigned char*) trapBuffer[endIndex].buffer, buflen, pklen)) { trapBuffer[endIndex].buffersize = buflen; trapBuffer[endIndex].valid = 1; } else { trapBuffer[endIndex].buffersize = 0; trapBuffer[endIndex].valid = 0; } pdu.variableBindings.variableBinding = NULL; endIndex++; if (endIndex >= TrapMaxNumber) { endIndex = 0; } }
RcppExport SEXP xbrlProcessContexts(SEXP epaDoc) { xmlDocPtr doc = (xmlDocPtr) R_ExternalPtrAddr(epaDoc); xmlXPathContextPtr context = xmlXPathNewContext(doc); xmlXPathObjectPtr context_res = xmlXPathEvalExpression((xmlChar*) "//*[local-name()='context']", context); xmlNodeSetPtr context_nodeset = context_res->nodesetval; int context_nodeset_ln = context_nodeset->nodeNr; xmlXPathFreeContext(context); CharacterVector contextId(context_nodeset_ln); CharacterVector scheme(context_nodeset_ln); CharacterVector identifier(context_nodeset_ln); CharacterVector startDate(context_nodeset_ln); CharacterVector endDate(context_nodeset_ln); CharacterVector dimension1(context_nodeset_ln); CharacterVector value1(context_nodeset_ln); CharacterVector dimension2(context_nodeset_ln); CharacterVector value2(context_nodeset_ln); CharacterVector dimension3(context_nodeset_ln); CharacterVector value3(context_nodeset_ln); CharacterVector dimension4(context_nodeset_ln); CharacterVector value4(context_nodeset_ln); for (int i=0; i < context_nodeset_ln; i++) { xmlNodePtr context_node = context_nodeset->nodeTab[i]; xmlChar *tmp_str; if ((tmp_str = xmlGetProp(context_node, (xmlChar*) "id"))) { contextId[i] = (char *) tmp_str; xmlFree(tmp_str); } else { contextId[i] = NA_STRING; } scheme[i] = identifier[i] = startDate[i] = endDate[i] = dimension1[i] = value1[i] = dimension2[i] = value2[i] = dimension3[i] = value3[i] = dimension4[i] = value4[i] = NA_STRING; xmlNodePtr child_node = context_node->xmlChildrenNode; while (child_node) { if (!xmlStrcmp(child_node->name, (xmlChar*) "entity")) { xmlNodePtr gchild_node = child_node->xmlChildrenNode; while (gchild_node) { if (!xmlStrcmp(gchild_node->name, (xmlChar*) "identifier")) { if ((tmp_str = xmlGetProp(gchild_node, (xmlChar*) "scheme"))) { scheme[i] = (char *) tmp_str; xmlFree(tmp_str); } if ((tmp_str = xmlNodeListGetString(doc, gchild_node->xmlChildrenNode, 1))) { identifier[i] = (char *) tmp_str; xmlFree(tmp_str); } } else if (!xmlStrcmp(gchild_node->name, (xmlChar*) "segment")) { xmlNodePtr ggchild_node = gchild_node->xmlChildrenNode; int dimn = 1; while (ggchild_node) { if (!xmlStrcmp(ggchild_node->name, (xmlChar*) "explicitMember")) { if ((tmp_str = xmlGetProp(ggchild_node, (xmlChar*) "dimension"))) { if (dimn == 1) dimension1[i] = (char *) tmp_str; else if (dimn == 2) dimension2[i] = (char *) tmp_str; else if (dimn == 3) dimension3[i] = (char *) tmp_str; else if (dimn == 4) dimension4[i] = (char *) tmp_str; xmlFree(tmp_str); } if ((tmp_str = xmlNodeListGetString(doc, ggchild_node->xmlChildrenNode, 1))) { if (dimn == 1) value1[i] = (char *) tmp_str; else if (dimn == 2) value2[i] = (char *) tmp_str; else if (dimn == 3) value3[i] = (char *) tmp_str; else if (dimn == 4) value4[i] = (char *) tmp_str; xmlFree(tmp_str); } dimn++; } ggchild_node = ggchild_node->next; } } gchild_node = gchild_node->next; } } else if (!xmlStrcmp(child_node->name, (xmlChar*) "period")) { xmlNodePtr gchild_node = child_node->xmlChildrenNode; while (gchild_node) { if (!xmlStrcmp(gchild_node->name, (xmlChar*) "startDate")) { if ((tmp_str = xmlNodeListGetString(doc, gchild_node->xmlChildrenNode, 1))) { startDate[i] = (char *) tmp_str; xmlFree(tmp_str); } } else if (!xmlStrcmp(gchild_node->name, (xmlChar*) "endDate")) { if ((tmp_str = xmlNodeListGetString(doc, gchild_node->xmlChildrenNode, 1))) { endDate[i] = (char *) tmp_str; xmlFree(tmp_str); } } else if (!xmlStrcmp(gchild_node->name, (xmlChar*) "instant")) { if ((tmp_str = xmlNodeListGetString(doc, gchild_node->xmlChildrenNode, 1))) { endDate[i] = (char *) tmp_str; xmlFree(tmp_str); } } gchild_node = gchild_node->next; } } child_node = child_node->next; } } xmlXPathFreeObject(context_res); return DataFrame::create(Named("contextId")=contextId, Named("scheme")=scheme, Named("identifier")=identifier, Named("startDate")=startDate, Named("endDate")=endDate, Named("dimension1")=dimension1, Named("value1")=value1, Named("dimension2")=dimension2, Named("value2")=value2, Named("dimension3")=dimension3, Named("value3")=value3, Named("dimension4")=dimension4, Named("value4")=value4); }