Пример #1
0
bool ledPresets::saveXML() {
    printf("SAVING XML: %s", xmlName.c_str() );
//    XML.addTag("PRESETS");
//    XML.pushTag("PRESETS");
    unsigned int ct = 0;
    ofxXmlSettings TMP;
    
    for (int i=0; i<presetsNum; i++){
//        XML.addTag("PRESET");
//        XML.pushTag("PRESET", i);
//        XML.addTag("GENERATORS");
//        XML.pushTag("GENERATORS");

        for (int j=0; j<4; j++){
            int lastTagNumber = TMP.addTag("GENERATOR");
//            XML.pushTag("GENERATOR", lastTagNumber);
            if (presets[i].is_active) {
                TMP.setValue("GENERATOR:att", presets[i].generators[j].att, lastTagNumber);
                TMP.setValue("GENERATOR:dec", presets[i].generators[j].dec, lastTagNumber);
                TMP.setValue("GENERATOR:rel", presets[i].generators[j].rel, lastTagNumber);
                TMP.setValue("GENERATOR:quant", (int)presets[i].generators[j].quant, lastTagNumber);
                TMP.setValue("GENERATOR:isActive", 1, lastTagNumber);
                string strmat((char *) presets[i].generators[j].matrix, ledsW*ledsH*3);
                printf("strmat = %s\n", strmat.c_str());
                TMP.setValue("GENERATOR:bitmap", strmat, lastTagNumber);
//                TMP.setValue(
                string strseq = hexString(presets[i].generators[j].sequence, 16*3);
                printf("\nSEQ = ");
                for (int z=0; z<16*3; z++) printf("%02X", presets[i].generators[j].sequence[i]);
                printf("\nstrseq = %s\n", strseq.c_str());
                TMP.setValue("GENERATOR:seq", strseq, lastTagNumber);
            } else {
                TMP.setValue("GENERATOR:att", 0, lastTagNumber);
                TMP.setValue("GENERATOR:dec", 0, lastTagNumber);
                TMP.setValue("GENERATOR:rel", 0, lastTagNumber);
                TMP.setValue("GENERATOR:quant", 0, lastTagNumber);
            }
            printf("GEN %d\n", lastTagNumber);
            ct++;
            TMP.popTag();
        }
//        XML.popTag();
//        XML.popTag();
//        XML.popTag();  
    }
//    XML.popTag();
    
    TMP.saveFile(xmlName);
    
    return true;
}
Пример #2
0
void Spell::xml_write (xml_document<> * doc, xml_node<> * node )
{
  xml_attribute<> *attr;
  char *node_name = doc->allocate_string(name.c_str());
  attr = doc->allocate_attribute("name"      ,node_name); node->append_attribute(attr);
  node_name = doc->allocate_string(type      .c_str());
  attr = doc->allocate_attribute("kind"      ,node_name); node->append_attribute(attr);
  node_name = doc->allocate_string(casttime  .c_str());
  attr = doc->allocate_attribute("casttime"  ,node_name); node->append_attribute(attr);
  node_name = doc->allocate_string(duration  .c_str());
  attr = doc->allocate_attribute("duration"  ,node_name); node->append_attribute(attr);
  node_name = doc->allocate_string(range     .c_str());
  attr = doc->allocate_attribute("range"     ,node_name); node->append_attribute(attr);
  node_name = doc->allocate_string(save      .c_str());
  attr = doc->allocate_attribute("save"      ,node_name); node->append_attribute(attr);
  node_name = doc->allocate_string(damage    .c_str());
  attr = doc->allocate_attribute("damage"    ,node_name); node->append_attribute(attr);
  node_name = doc->allocate_string(dmgtype   .c_str());
  attr = doc->allocate_attribute("dmgtype"   ,node_name); node->append_attribute(attr);
  node_name = doc->allocate_string(num_result.c_str());
  attr = doc->allocate_attribute("number"    ,node_name); node->append_attribute(attr);
  node_name = doc->allocate_string(empowered .c_str());
  attr = doc->allocate_attribute("empower"   ,node_name); node->append_attribute(attr);
  node_name = doc->allocate_string(short_desc.c_str());
  attr = doc->allocate_attribute("shortdesc" ,node_name); node->append_attribute(attr);
  node_name = doc->allocate_string(long_desc .c_str());
  attr = doc->allocate_attribute("longdesc"  ,node_name); node->append_attribute(attr);

  attr = doc->allocate_attribute("level"  ,double2char(&*doc,level        )); node->append_attribute(attr);
  attr = doc->allocate_attribute("ritual" ,double2char(&*doc,ritual       )); node->append_attribute(attr);
  attr = doc->allocate_attribute("init"   ,double2char(&*doc,init         )); node->append_attribute(attr);
  attr = doc->allocate_attribute("conc"   ,double2char(&*doc,concentration)); node->append_attribute(attr);
  attr = doc->allocate_attribute("halfdmg",double2char(&*doc,halfdmg      )); node->append_attribute(attr);

  string strcc("");
  for (size_t i=0;i<cclasses.size();i++){strcc+=cclasses[i]+" ";}
  node_name = doc->allocate_string(strcc.c_str());
  attr = doc->allocate_attribute("cclass",node_name); node->append_attribute(attr);

  string strmat("");
  for (size_t i=0;i<materials.size();i++){strmat+=materials[i]+" ";}
  node_name = doc->allocate_string(strmat.c_str());
  attr = doc->allocate_attribute("components",node_name); node->append_attribute(attr);

}
Пример #3
0
void SolveSist(TPZAnalysis *an, TPZCompMesh *Cmesh)
{
//    TPZParFrontStructMatrix<TPZFrontSym<STATE> > strmat(Cmesh);
    TPZSkylineStructMatrix strmat(Cmesh);
//    TPZSymetricSpStructMatrix strmat(Cmesh);
    strmat.SetNumThreads(8);
    an->SetStructuralMatrix(strmat);

    int64_t neq = Cmesh->NEquations();
    
    if(neq > 20000)
    {
        std::cout << "Entering Assemble Equations\n";
        std::cout.flush();
    }
#ifdef USING_BOOST
    boost::posix_time::ptime t1 = boost::posix_time::microsec_clock::local_time();
#endif
    TPZStepSolver<STATE> step;
    step.SetDirect(ECholesky);
    an->SetSolver(step);

    an->Assemble();
    
//    std::ofstream andrade("../Andrade.mtx");
//    andrade.precision(16);
//    an->Solver().Matrix()->Print("Andrade",andrade,EMatrixMarket);
//    std::cout << "Leaving Assemble\n";
#ifdef USING_BOOST
    boost::posix_time::ptime t2 = boost::posix_time::microsec_clock::local_time();
#endif
    
//#define NONO
#ifdef NONO
    step.SetMatrix(an->Solver().Matrix());

    TPZAutoPointer<TPZMatrix<STATE> > matrix = an->Solver().Matrix();
    TPZSkylMatrix<STATE> *skylmat = dynamic_cast<TPZSkylMatrix<STATE> *>(matrix.operator->());
    TPZSkylMatrix<float> * floatmat = new TPZSkylMatrix<float>;
    floatmat->CopyFrom(*skylmat);
    floatmat->Decompose_Cholesky();
    TPZSkylMatrix<STATE> *floatdec = new TPZSkylMatrix<STATE>;
    floatdec->CopyFrom(*floatmat);
    TPZStepSolver<STATE> stepfloat;
    stepfloat.SetMatrix(floatdec);
    stepfloat.SetDirect(ECholesky);

    step.SetCG(10, stepfloat, 1.e-6, 0);
    
    an->SetSolver(step);

#endif

    if(neq > 20000)
    {
        std::cout << "Entering Solve\n";
        std::cout.flush();
    }
    
    an->Solve(); 
    
#ifdef USING_BOOST
    boost::posix_time::ptime t3 = boost::posix_time::microsec_clock::local_time();
    std::cout << "Time for assembly " << t2-t1 << " Time for solving " << t3-t2 << std::endl;
#endif

    
}
Пример #4
0
int Operand6502::parse(char *op)
{
	char ch;
	char ch1;
	int reg;
	AsmBuf eb(100);
	AsmBuf ob(op+1,strlen(op+1)+1);

	theAssembler.errtype = true;

	type = 0;
	val.value = 0;
	r1 = 0;
	r2 = 0;

	if (isAReg(op))
		return type = AM_ACC;

	// Immediate
	if(op[0] == '#') {
		val = ob.expeval(NULL);
		type = AM_IMM;
		return type;
	}

	// (d,s),y
    if (strmat(op, " ( %s, %c ) , %c ", eb.buf(), &ch1, &ch))
    {
		if (tolower(ch1) == 's') {
			val = eb.expeval(NULL);
			if (tolower(ch)!='y')
				Err(E_INVOPERAND, op);
			return type = AM_SRIY;
		}
    }

	// (zp),y
    if (strmat(op, " ( %s) , %c ", eb.buf(), &ch))
    {
		val = eb.expeval(NULL);
		if (tolower(ch)!='y')
			Err(E_INVOPERAND, op);
		r1 = 3;
		return type = AM_IY;
    }

	// [zp],y
    if (strmat(op, " [ %s] , %c ", eb.buf(), &ch))
    {
		val = eb.expeval(NULL);
		if (tolower(ch)!='y')
			Err(E_INVOPERAND, op);
		return type = AM_IYL;
    }

	// (zp,x)
	if(strmat(op, " ( %s, %c) ", eb.buf(), &ch))
	{
		val = eb.expeval(NULL);
		r1 = 2;
		if (tolower(ch)!='x')
			Err(E_INVOPERAND, op);
		return type = AM_IX;
	}

	// (abs)  { jmp }
	if(strmat(op, " ( %s) ", eb.buf()))
	{
		val = eb.expeval(NULL);
        if (val.value < 256 && val.value >= 0)
			return type = AM_ZI;
		return type = AM_I;
	}

	// [abs]  { jmp }
	if(strmat(op, " [ %s] ", eb.buf()))
	{
		val = eb.expeval(NULL);
        if (val.value < 256 && val.value >= 0)
			return type = AM_ZIL;
		return type = AM_IL;
	}

	// d,sp
    if (strmat(op, " %s, %c ", eb.buf(), &ch))
    {
		if (tolower(ch)=='s') {
			val = eb.expeval(NULL);
			return type = AM_SR;
		}
    }

    // Could be indexed
    if (strmat(op, " %s, %c ", eb.buf(), &ch))
	{
		val = eb.expeval(NULL);
        if (val.value < 256 && val.value >= 0)
		{
			if (tolower(ch)=='x')
				return type = AM_ZX;
			else if (tolower(ch)=='y')
				return type = AM_ZY;
			else 
				Err(E_INVOPERAND, op);
			return AM_Z;
		}
        else {
			if (tolower(ch)=='x')
				return type = AM_AX;
			else if (tolower(ch)=='y')
				return type = AM_AY;
			else 
				Err(E_INVOPERAND, op);
			return AM_A;
		}
	}


	// Assume
	// Absolute / Zero page
	// This must be the last mode tested for since anything will
	// match
	strmat(op, " %s ", eb.buf());
	val = eb.expeval(NULL);
	if (val.value < 256 && val.value >= 0) {
		r2 = 0;
		return type = AM_Z;
	}
	return type = AM_A;
}