void MainWindow::slotOutputSource() { QString dir = QFileDialog::getExistingDirectory( this, "Select folder to save source", QFileInfo( mFileName ).path() ); if( Path::mkdir( dir + "/autoimp" ) && Path::mkdir( dir + "/autocore" ) ) writeSource( mSchema, dir ); }
void doCycle(void) { short offset; offset = 0; while(1) { writeSource(offset); updateLEDs(); Delay10KTCYx(50); offset++; if (offset >= STRIP_LENGTH) offset = 0; } }
void doOscillate(void) { short offset; char dir = 1; offset = 0; while(1) { writeSource(offset); updateLEDs(); offset+= dir; if (offset > STRIP_LENGTH) { offset = STRIP_LENGTH; dir = -1; } else if (offset < 0) { offset = 0; dir = 1; } } }
int main(int argc, char **argv) { po::options_description desc("Allowed options"); // These operator() really screw up clang-format // clang-format off desc.add_options() ("help", "Show help message") ("xml,x", po::value<std::string>(),"Input XML file") ("output-header,h", po::value<std::string>(), "Path to output generated header file") ("output-source,o", po::value<std::string>(), "Path to output generated source file") ; // clang-format on po::variables_map vm; po::store(po::parse_command_line(argc, argv, desc), vm); po::notify(vm); std::string inputXmlPath; std::string outputHeaderPath; std::string outputSourcePath; if (vm.count("help")) { std::cout << desc << "\n"; return 1; } if (!vm.count("xml")) { std::cerr << "Must specify input XML file\n" << desc << "\n"; return 1; } if (!vm.count("output-header")) { std::cerr << "Must specify output header file\n" << desc << "\n"; return 1; } if (!vm.count("output-source")) { std::cerr << "Must specify output source file\n" << desc << "\n"; return 1; } inputXmlPath = vm["xml"].as<std::string>(); outputHeaderPath = vm["output-header"].as<std::string>(); outputSourcePath = vm["output-source"].as<std::string>(); std::ifstream inputXmlFile(inputXmlPath); if (!inputXmlFile) { std::cerr << "Failed to open input XML file \"" << inputXmlPath << "\"\n"; return 1; } std::ofstream outputSourceFile(outputSourcePath); if (!outputSourceFile) { std::cerr << "Failed to open output source file at \"" << outputSourcePath << "\"\n"; return 1; } std::ofstream outputHeaderFile(outputHeaderPath); if (!outputHeaderFile) { std::cerr << "Failed to open output header file at \"" << outputHeaderPath << "\"\n"; return 1; } StateDefinition state; if (!readXml(inputXmlFile, state)) { std::cerr << "Reading input XML file \"" << inputXmlPath << "\" failed\n"; return 1; } writeHeader(outputHeaderFile, state); writeSource(outputSourceFile, state); return 0; }
int main( int argc, char * argv[] ) { #ifdef Q_WS_X11 bool useGUI = getenv( "DISPLAY" ) != 0; #else bool useGUI = true; #endif // Q_WS_X11 #ifdef Q_OS_WIN QDir::setCurrent( QFileInfo(currentExecutableFilePath()).path() ); #endif QApplication a( argc, argv, useGUI ); if( !initConfig( "classmaker.ini" ) ) return -1; Schema * schema = 0; QString fileName; for( int i=1; i<argc; i++ ) { QString arg( argv[i] ); if( arg == "--schema" || arg == "-s" ){ if( i+1==argc ) { usage(); return 1; } fileName = QString( argv[i+1] ); if( i<argc && QFile::exists( fileName ) ){ schema = Schema::createFromXmlSchema( fileName, /*isfilename=*/true, /*ignoreDocs=*/false ); }else{ LOG_1( "File not found: " + fileName ); return 1; } i++; } else if( arg == "--output" || arg == "-o" ) { if( i+1==argc ) { usage(); return 1; } if( !schema ) LOG_1( "Must first specify the schema to load with --schema" ); else if( i >= argc || !QDir( argv[i+1] ).exists() ) LOG_1( "Output Directory not found" ); else { writeSource( schema, argv[i+1] ); return 0; } return 1; } else if ( arg == "--help" || arg == "-h" ) { usage(); return 1; } } initStone( argc, argv ); if( useGUI ) { MainWindow * mw = new MainWindow( schema ); if( !fileName.isEmpty() ) mw->setFileName( fileName ); if( schema ) mw->setSchema( schema ); mw->show(); int i = a.exec(); shutdown(); return 0; } else { qWarning( "Classmaker usage without xserver is limited to the -s -o options" ); } shutdown(); return 0; }