void EntityFactory::LoadItems(const char* filename) { TiXmlDocument doc; if (!doc.LoadFile(filename)) { DIE("can't open items definition %s\n%s", filename, doc.ErrorDesc()); } TiXmlHandle handle(&doc); TiXmlElement* elem = handle.FirstChildElement().FirstChildElement().Element(); const char* name; while (elem != NULL) { QueryPtr(elem, "name", name); Item::Type item_type = Item::StringToType(name); ItemPattern item; QueryStr(elem, "label", item.label); QueryInt(elem, "x", item.x); QueryInt(elem, "y", item.y); QueryInt(elem, "w", item.w); QueryInt(elem, "h", item.h); items_[Item::StringToType(name)] = item; elem = elem->NextSiblingElement(); } }
void MainProcessCommand(char cmd, char *qi){ char buf[50]; int iVal; char cVal; double dVal; int ch; switch(cmd){ case 'h': MainMenu(); break; case 'a' : ch = QueryInt("Analog Channel",0,16,ch,qi); printf("ch %d : %.4lf V\n", ch, HW->ReadAnalogCh((IoHardware::AnalogInputCh) ch)); //HW->AnalogInAvgStart((IoHardware::AnalogInputCh) ch); sleep(1); //printf("ch %d : %.4lf V\n", ch, HW->AnalogInAvgGet()); break; case 'g': SampleLoop->Kp = QueryReal("Value Kp",0.,10000.0,SampleLoop->Kp,qi); SampleLoop->Kd = QueryReal("Value Kd",0.,10000.0,SampleLoop->Kd,qi); SampleLoop->Ki = QueryReal("Value Ki",0.,10000.0,SampleLoop->Ki,qi); break; case 'o': printf("SampleLoop Overrun = %d\n", SampleLoop->mOverRun); break; case 't': dVal = QueryReal("Test duration [s]",0.,10000.0,10.,qi); SampleLoop->TimingStart(dVal); break; case 'c': SampleLoop->camera = !(SampleLoop->camera); if(SampleLoop->camera == 0) printf("camera is OFF.\n"); else printf("camera is ON.\n"); break; case 'm': if(HW->motorStatus == MOTOR_OFF){ HW->WriteDigitalBit(IoHardware::MOTOR_ENABLE, MOTOR_ON); HW->motorStatus = MOTOR_ON; printf("motor is ON.\n"); } else{ HW->WriteDigitalBit(IoHardware::MOTOR_ENABLE, MOTOR_OFF); HW->motorStatus = MOTOR_OFF; printf("motor is OFF.\n"); } break; case 'f': SampleLoop->currentI = QueryReal("Value iCmd",-0.1,0.1,SampleLoop->currentI,qi); break; case 'e': startpos = (HW->GetEncoderCount(IoHardware::ENC_0) % 100000 + 100000) % 100000; printf("set start encoder:%d\n", startpos); break; case 's': if (setstartpos(startpos)) printf("start position setted!\n"); else printf("Didn't get it.."); break; default: printf("Bad command %c. Try 'h'.\n", cmd); } }