void MainWindow::slotAboutApplication() { QMessageBox::about(this, tr("About TelldusCenter"), tr("<center><img src=':/images/TelldusCenter_128.png' width=128 height=128 /><h2>TelldusCenter %1</h2>" "<p>Copyright © 2011 Telldus Technologies AB<p></center>").arg(VERSION_STRING(VERSION))); }
int main(int argc, const char** argv) { int retval = 0; boost::program_options::options_description general_options_description("Options", 140, 60); boost::program_options::variables_map vm; std::string colorArg, deviceArg; try { std::set<Nebula::HAL::Device*> devices; std::mutex devicesMutex; installSignalHandlers(); general_options_description.add_options() (Options::kDevice, boost::program_options::value<std::string>(), "specify device") (Options::kChannel, boost::program_options::value<RT::s4>()->default_value(0), "specify LED strip channel") (Options::kNumberOfLeds, boost::program_options::value<RT::s4>()->default_value(0), "set number of leds") ("nn", boost::program_options::value<RT::s4>()->default_value(100), "set running light increment") ("size,s", boost::program_options::value<RT::s4>()->default_value(100), "Ambilight sensing zones size") (Options::kFrequency, boost::program_options::value<float>()->default_value(24.0f), "set number of LEDs color updates per second") (Options::kColor, boost::program_options::value<std::string>()->default_value(std::string("255,255,255")), "set LEDs color") (Options::kBrightness, boost::program_options::value<float>()->default_value(0.5f), "set LEDs brightness") (Options::kRate, boost::program_options::value<float>()->default_value(1.0f), "set dynamic lighting effect rate") //(Options::kStrobe, "run in stroboscope mode") (Options::kDebug, boost::program_options::value<RT::u4>()->default_value(0), "stroboscope mode"); if (argc < 2) optionsError("mode was not specified\n"); auto mode = determineMode(argv[1]); if (mode == Mode::none) optionsError("invalid mode was specified\n"); boost::program_options::store(boost::program_options::command_line_parser(argc - 1, argv + 1).options(general_options_description).run(), vm, true); boost::program_options::notify(vm); switch (mode) { case Mode::help: print_usage(general_options_description); exit(0); case Mode::version: std::cout << VERSION_STRING(VERSION, __DATE__, __TIME__) << std::endl; exit(0); default: break; } auto onDeviceAddition = [&](Nebula::HAL::Device* device) -> void { std::lock_guard<std::mutex> lock(devicesMutex); devices.insert(device); }; auto onDeviceRemoval = [&](Nebula::HAL::Device* device) -> void { std::lock_guard<std::mutex> lock(devicesMutex); devices.erase(device); }; std::unique_ptr<Nebula::HAL::Context> nebula(Nebula::HAL::createContext(onDeviceAddition, onDeviceRemoval)); if (mode == Mode::list) { std::lock_guard<std::mutex> lock(devicesMutex); for (auto device : devices) printDeviceInfo(device); } else { auto firstDeviceIterator = devices.begin(); if (firstDeviceIterator != devices.end()) { auto device = *firstDeviceIterator; auto channel = vm["channel"].as<RT::s4>(); auto numberOfLeds = vm["nleds"].as<RT::s4>(); auto frequency = vm["freq"].as<float>(); auto brightness = vm["brightness"].as<float>(); bool animate = false; if (channel < 0) optionsError("channel should be >= 0\n"); if (numberOfLeds <= 0) optionsError("number of LEDs should be > 0\n"); if (frequency <= 0.0f) optionsError("frequency should be > 0\n"); if (brightness < 0.0f) optionsError("brightness should be >= 0\n"); std::unique_ptr<Nebula::Color::RGB<RT::u1>> colors(new Nebula::Color::RGB<RT::u1>[numberOfLeds]); std::mutex colorsMutex; Nebula::HAL::Device::IoctlParameters::SetNumberOfLeds setNumberOfLedsIoctlParameters(channel, numberOfLeds); Nebula::HAL::Device::IoctlParameters::Colors colorsIoctlParameters(channel, colors.get(), numberOfLeds); device->controlIn(Nebula::HAL::Device::Request::setNumberOfLeds, &setNumberOfLedsIoctlParameters, sizeof(setNumberOfLedsIoctlParameters)); switch (mode) { case Mode::continuous: { RT::u4 r, g, b; sscanf(vm["color"].as<std::string>().c_str(), "%u,%u,%u", &r, &g, &b); r *= brightness; g *= brightness; b *= brightness; for (auto i = 0; i < numberOfLeds; i++) colors.get()[convertLedNumber(i)].set(r, g, b); device->controlIn(Nebula::HAL::Device::Request::setColors, &colorsIoctlParameters, sizeof(colorsIoctlParameters)); } break; case Mode::rainbow: case Mode::ambilight: case Mode::run: animate = true; break; default: break; } if (animate) { std::unique_ptr<Nebula::Generator> generator(createGenerator(mode, vm)); std::unique_ptr<Nebula::Transformation> transformation(new Reorder(numberOfLeds, 3)); TimerCallbackParameters timerCallbackParameters(device, &colorsIoctlParameters, &colorsMutex); std::thread pluginThread([&]() -> void { std::unique_ptr<Nebula::Color::RGB<RT::u1>> localColors(new Nebula::Color::RGB<RT::u1>[numberOfLeds]); time_t t1, t2; RT::u8 count = 0; time(&t1); while (!doTerminate) { generator->generate(localColors.get()); transformation->transformInPlace(localColors.get()); guardedMemcpy(localColors.get(), colors.get(), numberOfLeds * sizeof(Nebula::Color::RGB<RT::u1>), &colorsMutex); count++; } time(&t2); if (count > 0) printf("updates per second = %f\n", float(count) / float(t2 - t1)); }); try { runLoop(&timerCallbackParameters, frequency); } catch(...) { pluginThread.join(); throw; } pluginThread.join(); } } else printf("No device found\n"); } } catch (RT::u4 ID) { printf("Error 0x%x\n", ID); } catch (OptionsError e) { printf("Invalid program invocation: %s", e.getMessage()); print_usage(general_options_description); retval = -1; } catch (...) { printf("Exception occured\n"); } return retval; }
HELP_HEAD("Model PCA") USAGE("pmmpca","OPTION","PDB/XTC File") OPTIONS_HEAD " --help -h Display this help\n" " --mean -m <model file> Write average model to <model file>\n" " --variance -v <model file>\n" " Write variance model to <model file>\n" " --evecs -e <model file> Write eigenvectors to <model file>\n" " --evals -V <file> Write eigenvalues to <file>\n" " --length -l <int> Set the number of eigenvectors to be written\n" " --structure -s <pdb file> Structure reference\n" " --evec-sacle -S <float> Scaling eigenvectors\n" " --align -a Align data\n\n"; static char version [] = VERSION_STRING("Model PCA"); int main(int argc, char *argv[]) { int i=1; int align=0; size_t length=0; PMProtein *data,*mean,*evecs; float *evals=0; char *fnevecs=0, *fnmean=0, *fnvar=0, *fnevals=0; float S=1.0; data = pmCreateNew(PM_TYPE_MODEL); if(!data) FAIL("MALLOC: no memmory assigned")
#include "calc.h" static char help [] = HELP_HEAD("Density PCA") USAGE("pmdpca","OPTION","MRC File") OPTIONS_HEAD " --help -h Display this help\n" " --mean -m <density file> Write average density to <density file>\n" " --variance -v <density file>\n" " Write variance density to <density file>\n" " --evecs -e <density file> Write eigenvectors to <density file>\n" " --evals -V <file> Write eigenvalues to <file>\n" " --length -l <int> Set the number of eigenvectors to be written\n\n"; static char version [] = VERSION_STRING("Density PCA"); int main(int argc, char *argv[]) { int i=1; size_t length=0; PMProtein *data,*mean,*evecs; float *evals=0; char *fnevecs=0, *fnmean=0, *fnvar=0, *fnevals=0; data = pmCreateNew(PM_TYPE_DENSITY); if(!data) FAIL("MALLOC: no memmory assigned") //loop options