void RotateTask::initTaskSettings() { ConfigSettings *settings = config()->settings(); m_degree = settings->getSetting(RotateSettings::Degree); m_degree->initIfNull( RotateSettings::DefaultDegree ); }
//save the position and dimensions of the window gboolean save_posdim(GtkWidget *widget, GdkEventConfigure *event, gpointer data){ settings.window_x = event->x; settings.window_y = event->y; settings.window_width = event->width; settings.window_height = event->height; settings.write_config(); }
void LevelTask::initTaskSettings() { ConfigSettings *settings = config()->settings(); m_blackpoint = settings->getSetting( LevelSettings::Blackpoint ); m_blackpoint->initIfNull( LevelSettings::DefaultBlackpoint ); m_midpoint = settings->getSetting( LevelSettings::Midpoint ); m_midpoint->initIfNull( LevelSettings::DefaultMidpoint ); m_whitepoint = settings->getSetting( LevelSettings::Whitepoint ); m_whitepoint->initIfNull( LevelSettings::DefaultWhitepoint ); m_brightness = settings->getSetting( LevelSettings::Brightness ); m_brightness->initIfNull( LevelSettings::DefaultBrightness ); m_saturation = settings->getSetting( LevelSettings::Saturation ); m_saturation->initIfNull( LevelSettings::DefaultSaturation ); }
bool loop(int argc, char** argv) { char home[256]; //NEED TO MAKE THIS DYNAMIC strcpy(home, getenv("HOME")); //parse the config file settings.parse_config(strcat(home, config_file)); //load the controls into list ElementList list(settings.card); list_ptr = &list; //reorder the controls to the order specified in the config file settings.reorder_list(&list); //set the scale list.set_scale((Element::scale_t)settings.scaling); //set the auto_mute list.set_auto_mute(settings.auto_mute); //initialize gtk gtk_init(&argc, &argv); //set up the tray_slider that goes in the tray if (settings.enable_tray_icon){ GtkWidget *tray_frame; tray_frame = gtk_alignment_new(0.5,0.0,0,0); settings.tray_slider = new retro_slider; settings.set_tray_slider(&list); settings.apply_to_tray_slider(settings.tray_slider); if (list.num_elems > 0){ settings.tray_slider->init(tray_frame, (void*)settings.tray_control, &Element::get_callback, &Element::set_callback, (settings.tray_control->values > 1)); } else { settings.tray_control = NULL; } //set up the small window that holds the tray_slider settings.slider_window = gtk_window_new (GTK_WINDOW_POPUP); gtk_window_set_resizable(GTK_WINDOW(settings.slider_window), false); gtk_window_set_decorated(GTK_WINDOW(settings.slider_window), false); gtk_window_set_skip_taskbar_hint(GTK_WINDOW(settings.slider_window), true); gtk_window_set_skip_pager_hint(GTK_WINDOW(settings.slider_window), true); gtk_widget_set_usize(settings.slider_window, settings.tray_slider->width, settings.tray_slider->height); //don't want accidental closure of the slider window to destroy the window g_signal_connect(settings.slider_window, "delete-event", G_CALLBACK (gtk_widget_hide_on_delete), NULL); //want the widow to go away when it loses focus g_signal_connect(settings.slider_window, "focus-out-event", G_CALLBACK (gtk_widget_hide), NULL); gtk_container_add( GTK_CONTAINER(settings.slider_window), tray_frame ); //we want it hidden by default, but it must be shown at least once or else scrolling over the icon will cause a hang gtk_widget_show_all(settings.slider_window); gtk_widget_hide_all(settings.slider_window); //set up tray icon #if GTK_CHECK_VERSION(2,16,0) settings.tray_icon = gtk_status_icon_new(); gtk_status_icon_set_from_file(settings.tray_icon, VOL_MUTED_IMAGE); #else settings.tray_icon = GTK_WIDGET(egg_tray_icon_new("Retrovol Tray Icon")); //set the background color bool enable_tray_icon_background_color = settings.enable_tray_icon_background_color; GdkColor bg_color; char bg_color_str[8]; if (cmdline_enable_bg_color){ enable_tray_icon_background_color = true; strcpy(bg_color_str, cmdline_bg_color); } else if (settings.enable_tray_icon_background_color){ settings.nftoh(settings.tray_icon_background_color, bg_color_str); } if (enable_tray_icon_background_color){ if (gdk_color_parse(bg_color_str, &bg_color)){ GtkStyle *style = gtk_style_copy(gtk_widget_get_style(settings.tray_icon)); style->bg[GTK_STATE_NORMAL] = bg_color; gtk_widget_set_style(settings.tray_icon, style); } else { fprintf(stderr, _("Error: Failed to set background color to %s\n"), bg_color_str); } } //set up the images settings.tray_icon_image = gtk_image_new(); gtk_container_add( GTK_CONTAINER(settings.tray_icon), settings.tray_icon_image ); gtk_image_set_from_file(GTK_IMAGE(settings.tray_icon_image), VOL_MEDIUM_IMAGE); //set the event mask gtk_widget_set_events (settings.tray_icon, GDK_BUTTON_PRESS_MASK | GDK_SCROLL_MASK); #endif //signals g_signal_connect(G_OBJECT(settings.tray_icon), "button_press_event", G_CALLBACK (&tray_button_press_event_callback), settings.slider_window); if (settings.tray_control){ g_signal_connect(G_OBJECT(settings.tray_icon), "scroll_event", G_CALLBACK (&retro_slider::scroll_event_callback), settings.tray_slider); } #if GTK_CHECK_VERSION(2,16,0) //make icon visible gtk_status_icon_set_visible(settings.tray_icon, true); #else //handle situations where the icon's window dies, such as due to the tray itself exiting g_signal_connect(G_OBJECT(settings.tray_icon), "delete-event", G_CALLBACK (gtk_widget_hide_on_delete), NULL); //make icon visible gtk_widget_show_all(settings.tray_icon); #endif //set up the popup menu (the function checks if it should actually do anything) set_menu(); } //set up the window settings.main_window = gtk_window_new(GTK_WINDOW_TOPLEVEL); //gtk_window_set_position(GTK_WINDOW(settings.main_window), GTK_WIN_POS_CENTER); gtk_window_set_default_size(GTK_WINDOW(settings.main_window), settings.window_width, settings.window_height); gtk_window_set_title(GTK_WINDOW(settings.main_window), "Retrovol"); restore_posdim(); g_signal_connect(settings.main_window, "configure-event", G_CALLBACK (save_posdim), NULL); //if the tray icon is enabled, we want the window to hide rather than closing if (settings.enable_tray_icon){ g_signal_connect(settings.main_window, "delete-event", G_CALLBACK (gtk_widget_hide_on_delete), NULL); } //make the over_box, which will hold stuff like the menu, status bar, and the actual content in the middle GtkWidget *over_box; over_box = gtk_vbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(settings.main_window), over_box); //define the menu GtkItemFactoryEntry menu_items_1[] = { { (gchar*)_("/_File"), NULL, NULL, 0, (gchar*)"<Branch>" }, { (gchar*)_("/File/_Configure"), (gchar*)"<CTRL>C", G_CALLBACK(configure), 0, (gchar*)"<StockItem>", GTK_STOCK_EXECUTE }, { (gchar*)_("/File/_Quit"), (gchar*)"<CTRL>Q", G_CALLBACK(close_window), 0, (gchar*)"<StockItem>", GTK_STOCK_QUIT }, }; gint nmenu_items_1 = sizeof (menu_items_1) / sizeof (menu_items_1[0]); GtkItemFactoryEntry menu_items_2[] = { { (gchar*)_("/_File"), NULL, NULL, 0, (gchar*)"<Branch>" }, { (gchar*)_("/File/_Configure"), (gchar*)"<CTRL>C", G_CALLBACK(configure), 0, (gchar*)"<StockItem>", GTK_STOCK_EXECUTE }, { (gchar*)_("/File/_Exit completely"), (gchar*)"<CTRL>E", G_CALLBACK(gtk_main_quit), 0, (gchar*)"<StockItem>", GTK_STOCK_QUIT }, { (gchar*)_("/File/_Quit"), (gchar*)"<CTRL>Q", G_CALLBACK(close_window), 0, (gchar*)"<StockItem>", GTK_STOCK_QUIT }, }; gint nmenu_items_2 = sizeof (menu_items_2) / sizeof (menu_items_2[0]); GtkItemFactoryEntry *menu_items; gint nmenu_items; //if the tray menu is enabled, don't have the "Exit" entry in the main menu if (settings.enable_tray_menu){ menu_items = menu_items_1; nmenu_items = nmenu_items_1; } else { menu_items = menu_items_2; nmenu_items = nmenu_items_2; } //build the menu GtkWidget *menubar; menubar = get_menubar_menu(settings.main_window, menu_items, nmenu_items, "<RetrovolMain>"); gtk_box_pack_start(GTK_BOX(over_box), menubar, FALSE, TRUE, 0); //use a scrolled window GtkWidget *scrolled_window; scrolled_window = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_policy((GtkScrolledWindow*)scrolled_window, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_container_add(GTK_CONTAINER(over_box), scrolled_window); //put the stuff into a viewport manually, so we can specify that it should have no shadow GtkWidget *viewport; viewport = gtk_viewport_new(NULL, NULL); gtk_viewport_set_shadow_type(GTK_VIEWPORT(viewport), GTK_SHADOW_NONE); gtk_container_add(GTK_CONTAINER(scrolled_window), viewport); //and create an Hbox to hold all the stuff GtkWidget *hbox; if (settings.vertical){ hbox = gtk_hbox_new(TRUE, 2); gtk_container_add(GTK_CONTAINER(viewport), hbox); } else { hbox = gtk_vbox_new(TRUE, 2); gtk_container_add(GTK_CONTAINER(viewport), hbox); } //add the sliders retro_slider *sliders = new retro_slider[list.num_items]; for(int i=0; i<list.num_items; i++){ //use a vbox w/ slider on top and label on bottom GtkWidget *vbox; if (settings.vertical){ vbox = gtk_vbox_new(FALSE, 2); } else { vbox = gtk_hbox_new(FALSE, 2); } gtk_box_pack_start(GTK_BOX(hbox), vbox, false, false, 0); if (strcmp(list.items[i]->type, "INTEGER") == 0){ //integers need sliders //the rslider pseudo-widget likes to be inside a container, lets use a GtkAlignment GtkWidget *frame; if (settings.vertical){ frame = gtk_alignment_new(0.5,0.0,0,0); gtk_box_pack_start(GTK_BOX(vbox), frame, false, false, 0); } else { frame = gtk_alignment_new(0.0,0.5,0,0); gtk_box_pack_end(GTK_BOX(vbox), frame, false, false, 0); } //make the slider and associate with a control settings.apply_to_slider(&sliders[i]); sliders[i].init(frame, (void*)list.items[i], &Element::get_callback, &Element::set_callback, (list.items[i]->values > 1)); } else if (strcmp(list.items[i]->type, "BOOLEAN") == 0){ //booleans need checkboxes GtkWidget *alignment; if (settings.vertical){ alignment = gtk_alignment_new(0.5,1.0,0,0); gtk_box_pack_start(GTK_BOX(vbox), alignment, true, true, 0); } else { alignment = gtk_alignment_new(1.0,0.5,0,0); gtk_box_pack_end(GTK_BOX(vbox), alignment, true, true, 0); } GtkWidget *chkbx; chkbx = gtk_check_button_new(); //set it to the current state gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chkbx), (bool)list.items[i]->get()); //bind to the toggle_checkbox function Element* ptr = list.items[i]; g_signal_connect(GTK_TOGGLE_BUTTON(chkbx), "toggled", G_CALLBACK (toggle_checkbox), ptr); g_signal_connect_after(GTK_TOGGLE_BUTTON(chkbx), "expose-event", G_CALLBACK (refresh_checkbox), ptr); gtk_container_add(GTK_CONTAINER(alignment), chkbx); } else if (strcmp(list.items[i]->type, "ENUMERATED") == 0){ GtkWidget *alignment; if (settings.vertical){ alignment = gtk_alignment_new(0.5,0.5,0,0); gtk_box_pack_start(GTK_BOX(vbox), alignment, true, true, 0); } else { alignment = gtk_alignment_new(1.0,0.5,0,0); gtk_box_pack_end(GTK_BOX(vbox), alignment, true, true, 0); } //insert a combobox with the different options GtkWidget *combo_box; combo_box=gtk_combo_box_new_text(); for(unsigned int n=0; n<list.items[i]->number_of_enums; n++){ gtk_combo_box_append_text(GTK_COMBO_BOX(combo_box), list.items[i]->enums[n]); } gtk_combo_box_set_active(GTK_COMBO_BOX(combo_box), list.items[i]->get()); //bind to the change_combo_box function g_signal_connect(GTK_COMBO_BOX(combo_box), "changed", G_CALLBACK (change_combo_box), list.items[i]); gtk_container_add(GTK_CONTAINER(alignment), combo_box); } //add a checkbox for sliders that are muteable if (list.items[i]->switch_id >= 0){ GtkWidget *alignment; if (settings.vertical){ alignment = gtk_alignment_new(0.5,1.0,0,0); gtk_box_pack_start(GTK_BOX(vbox), alignment, true, true, 0); } else { alignment = gtk_alignment_new(1.0,0.5,0,0); gtk_box_pack_end(GTK_BOX(vbox), alignment, true, true, 0); } GtkWidget *chkbx; chkbx = gtk_check_button_new(); //set it to the current state gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chkbx), (bool)list.elems[list.items[i]->switch_id].get()); //bind to the toggle_checkbox function g_signal_connect(GTK_TOGGLE_BUTTON(chkbx), "toggled", G_CALLBACK (toggle_checkbox), &(list.elems[list.items[i]->switch_id])); g_signal_connect_after(GTK_TOGGLE_BUTTON(chkbx), "expose-event", G_CALLBACK (refresh_checkbox), &(list.elems[list.items[i]->switch_id])); gtk_container_add(GTK_CONTAINER(alignment), chkbx); } //display the name of the control GtkWidget *alignment; char wrapped[256]; if (settings.vertical){ alignment = gtk_alignment_new(0.5,1.0,0,0); gtk_box_pack_end(GTK_BOX(vbox), alignment, false, false, 0); word_wrap(wrapped, list.items[i]->short_name); } else { alignment = gtk_alignment_new(1.0,0.5,0,0); gtk_box_pack_start(GTK_BOX(vbox), alignment, false, false, 0); strcpy(wrapped, list.items[i]->short_name); } GtkWidget *label; label = gtk_label_new(wrapped); gtk_container_add(GTK_CONTAINER(alignment), label); } //finish the window stuff if (!start_hidden){ gtk_widget_show_all(settings.main_window); } g_signal_connect(settings.main_window, "destroy", G_CALLBACK (gtk_main_quit), NULL); //add some periodic refreshment to keep the icon and window up-to-date #if GTK_CHECK_VERSION(2,14,0) int timeout = g_timeout_add_seconds(1, update, NULL); #else //this is less efficient than g_timeout_add_seconds() int timeout = g_timeout_add(1000, update, NULL); #endif //finished with gtk setup gtk_main(); //stop the timeout g_source_remove(timeout); //have the window shown again if it was open before we restarted if (settings.resume_main){ settings.resume_main = false; start_hidden = false; } else { start_hidden = true; } return(settings.restart); }
int main(int argc, char **argv) { #if defined(__linux__) || (defined(__APPLE__) && defined(__MACH__)) //Lower the process priority on linux and mac. setpriority(PRIO_PROCESS, 0, 10); #endif signal(SIGFPE, signal_FPE); GCodeExport gcode; ConfigSettings config; int fileNr = 0; config.filamentDiameter = 2890; config.filamentFlow = 100; config.initialLayerThickness = 300; config.layerThickness = 100; config.extrusionWidth = 400; config.insetCount = 2; config.downSkinCount = 6; config.upSkinCount = 6; config.initialSpeedupLayers = 4; config.initialLayerSpeed = 20; config.printSpeed = 50; config.infillSpeed = 50; config.moveSpeed = 200; config.fanFullOnLayerNr = 2; config.skirtDistance = 6000; config.skirtLineCount = 1; config.skirtMinLength = 0; config.sparseInfillLineDistance = 100 * config.extrusionWidth / 20; config.infillOverlap = 15; config.objectPosition.X = 102500; config.objectPosition.Y = 102500; config.objectSink = 0; config.supportAngle = -1; config.supportEverywhere = 0; config.supportLineDistance = config.sparseInfillLineDistance; config.supportExtruder = -1; config.supportXYDistance = 700; config.supportZDistance = 150; config.retractionAmount = 4500; config.retractionSpeed = 45; config.retractionAmountExtruderSwitch = 14500; config.retractionMinimalDistance = 1500; config.minimalExtrusionBeforeRetraction = 100; config.enableCombing = 1; config.multiVolumeOverlap = 0; config.minimalLayerTime = 5; config.minimalFeedrate = 10; config.coolHeadLift = 1; config.fanSpeedMin = 100; config.fanSpeedMax = 100; config.raftMargin = 5000; config.raftLineSpacing = 1000; config.raftBaseThickness = 0; config.raftBaseLinewidth = 0; config.raftInterfaceThickness = 0; config.raftInterfaceLinewidth = 0; config.spiralizeMode = 0; config.fixHorrible = 0; config.gcodeFlavor = GCODE_FLAVOR_REPRAP; config.startCode = "M109 S210 ;Heatup to 210C\n" "G21 ;metric values\n" "G90 ;absolute positioning\n" "G28 ;Home\n" "G1 Z15.0 F300 ;move the platform down 15mm\n" "G92 E0 ;zero the extruded length\n" "G1 F200 E5 ;extrude 5mm of feed stock\n" "G92 E0 ;zero the extruded length again\n"; config.endCode = "M104 S0 ;extruder heater off\n" "M140 S0 ;heated bed heater off (if you have it)\n" "G91 ;relative positioning\n" "G1 E-1 F300 ;retract the filament a bit before lifting the nozzle, to release some of the pressure\n" "G1 Z+0.5 E-5 X-20 Y-20 F9000 ;move Z up a bit and retract filament even more\n" "G28 X0 Y0 ;move X/Y to min endstops, so the head is out of the way\n" "M84 ;steppers off\n" "G90 ;absolute positioning\n"; fprintf(stderr,"Cura_SteamEngine version %s\n", VERSION); for(int argn = 1; argn < argc; argn++) { char* str = argv[argn]; if (str[0] == '-') { for(str++; *str; str++) { switch(*str) { case 'h': print_usage(); exit(1); case 'v': verbose_level++; break; case 'b': argn++; binaryMeshBlob = fopen(argv[argn], "rb"); break; case 'o': argn++; gcode.setFilename(argv[argn]); if (!gcode.isValid()) { logError("Failed to open %s for output.\n", argv[argn]); exit(1); } break; case 's': { argn++; char* valuePtr = strchr(argv[argn], '='); if (valuePtr) { *valuePtr++ = '\0'; if (!config.setSetting(argv[argn], valuePtr)) printf("Setting found: %s %s\n", argv[argn], valuePtr); } } break; case 'm': argn++; sscanf(argv[argn], "%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf", &config.matrix.m[0][0], &config.matrix.m[0][1], &config.matrix.m[0][2], &config.matrix.m[1][0], &config.matrix.m[1][1], &config.matrix.m[1][2], &config.matrix.m[2][0], &config.matrix.m[2][1], &config.matrix.m[2][2]); break; default: logError("Unknown option: %c\n", *str); break; } } } else { if (!gcode.isValid()) { logError("No output file specified\n"); return 1; } gcode.addComment("Generated with Cura_SteamEngine %s", VERSION); processFile(argv[argn], config, gcode, fileNr == 0); fileNr ++; } } if (gcode.isValid()) { gcode.addFanCommand(0); gcode.setZ(maxObjectHeight + 5000); gcode.addMove(gcode.getPositionXY(), config.moveSpeed, 0); gcode.addCode(config.endCode); log("Print time: %d\n", int(gcode.getTotalPrintTime())); log("Filament: %d\n", int(gcode.getTotalFilamentUsed())); if (gcode.getFlavor() == GCODE_FLAVOR_ULTIGCODE) { char numberString[16]; sprintf(numberString, "%d", int(gcode.getTotalPrintTime())); gcode.replaceTagInStart("<__TIME__>", numberString); sprintf(numberString, "%d", int(gcode.getTotalFilamentUsed())); gcode.replaceTagInStart("<FILAMENT>", numberString); } } }
int main(int argc, char **argv) { #if defined(__linux__) || (defined(__APPLE__) && defined(__MACH__)) //Lower the process priority on linux and mac. On windows this is done on process creation from the GUI. setpriority(PRIO_PROCESS, 0, 10); #endif //Register the exception handling for arithmic exceptions, this prevents the "something went wrong" dialog on windows to pop up on a division by zero. signal(SIGFPE, signal_FPE); ConfigSettings config; fffProcessor processor(config); logError("Cura_SteamEngine version %s\n", VERSION); if(!config.readSettings()) { logError("Default config '%s' not used\n", DEFAULT_CONFIG_PATH); } for(int argn = 1; argn < argc; argn++) { char* str = argv[argn]; if (str[0] == '-') { for(str++; *str; str++) { switch(*str) { case 'h': print_usage(); exit(1); case 'v': increaseVerboseLevel(); break; case 'p': enableProgressLogging(); break; case 'g': argn++; //Connect the GUI socket to the given port number. processor.guiConnect(atoi(argv[argn])); break; case 'b': argn++; //The binaryMeshBlob is depricated and will be removed in the future. binaryMeshBlob = fopen(argv[argn], "rb"); break; case 'o': argn++; if (!processor.setTargetFile(argv[argn])) { logError("Failed to open %s for output.\n", argv[argn]); exit(1); } break; case 'c': { // Read a config file from the given path argn++; if(!config.readSettings(argv[argn])) { logError("Failed to read config '%s'\n", argv[argn]); } } break; case 's': { //Parse the given setting and store it. argn++; char* valuePtr = strchr(argv[argn], '='); if (valuePtr) { *valuePtr++ = '\0'; if (!config.setSetting(argv[argn], valuePtr)) logError("Setting not found: %s %s\n", argv[argn], valuePtr); } } break; case 'm': //Read the given rotation/scale matrix argn++; sscanf(argv[argn], "%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf", &config.matrix.m[0][0], &config.matrix.m[0][1], &config.matrix.m[0][2], &config.matrix.m[1][0], &config.matrix.m[1][1], &config.matrix.m[1][2], &config.matrix.m[2][0], &config.matrix.m[2][1], &config.matrix.m[2][2]); break; default: logError("Unknown option: %c\n", *str); break; } } }else{ try { //Catch all exceptions, this prevents the "something went wrong" dialog on windows to pop up on a thrown exception. // Only ClipperLib currently throws exceptions. And only in case that it makes an internal error. processor.processFile(argv[argn]); }catch(...){ logError("Unknown exception\n"); exit(1); } } } //Finalize the processor, this adds the end.gcode. And reports statistics. processor.finalize(); }
void SDRDevicesDialog::refreshDeviceProperties() { SDRDeviceInfo *selDev = getSelectedDevice(devTree->GetSelection()); if (selDev && selDev->isAvailable()) { dev = selDev; selId = devTree->GetSelection(); DeviceConfig *devConfig = wxGetApp().getConfig()->getDevice(dev->getName()); m_propertyGrid->Clear(); SoapySDR::Device *soapyDev = dev->getSoapyDevice(); SoapySDR::ArgInfoList args = soapyDev->getSettingInfo(); //A) General settings: name, offset, sample rate, agc, antennas (if > 1) m_propertyGrid->Append(new wxPropertyCategory("General Settings")); devSettings.clear(); //A-1) Name devSettings["name"] = m_propertyGrid->Append( new wxStringProperty("Name", wxPG_LABEL, devConfig->getDeviceName()) ); //A-2) Offset devSettings["offset"] = m_propertyGrid->Append( new wxIntProperty("Offset (KHz)", wxPG_LABEL, devConfig->getOffset() / 1000) ); //A-3) Antennas, is there are more than 1 RX antenna, else do not expose the setting. //get the saved setting const std::string& currentSetAntenna = devConfig->getAntennaName(); //compare to the list of existing antennas SoapySDR::ArgInfo antennasArg; std::vector<std::string> antennaOpts = selDev->getAntennaNames(SOAPY_SDR_RX, 0); //only do something if there is more than 1 antenna if (antennaOpts.size() > 1) { //by default, choose the first of the list. std::string antennaToSelect = antennaOpts.front(); auto found_i = std::find(antennaOpts.begin(), antennaOpts.end(), currentSetAntenna); if (found_i != antennaOpts.end()) { antennaToSelect = currentSetAntenna; } else { //erroneous antenna name, re-write device config with the first choice of teh list. devConfig->setAntennaName(antennaToSelect); } //build device settings for (std::string antenna : antennaOpts) { antennasArg.options.push_back(antenna); antennasArg.optionNames.push_back(antenna); } antennasArg.type = SoapySDR::ArgInfo::STRING; antennasArg.units = ""; antennasArg.name = "Antenna"; antennasArg.key = "antenna"; antennasArg.value = antennaToSelect; devSettings["antenna"] = addArgInfoProperty(m_propertyGrid, antennasArg); deviceArgs["antenna"] = antennasArg; } //end if more than 1 antenna else { devConfig->setAntennaName(""); } //A-4) Sample_rate: long currentSampleRate = wxGetApp().getSampleRate(); long deviceSampleRate = devConfig->getSampleRate(); if (!deviceSampleRate) { deviceSampleRate = selDev->getSampleRateNear(SOAPY_SDR_RX, 0, currentSampleRate); } SoapySDR::ArgInfo sampleRateArg; std::vector<long> rateOpts = selDev->getSampleRates(SOAPY_SDR_RX, 0); for (long rate : rateOpts) { sampleRateArg.options.push_back(std::to_string(rate)); sampleRateArg.optionNames.push_back(frequencyToStr(rate)); } sampleRateArg.type = SoapySDR::ArgInfo::STRING; sampleRateArg.units = "Hz"; sampleRateArg.name = "Sample Rate"; sampleRateArg.key = "sample_rate"; sampleRateArg.value = std::to_string(deviceSampleRate); devSettings["sample_rate"] = addArgInfoProperty(m_propertyGrid, sampleRateArg); deviceArgs["sample_rate"] = sampleRateArg; //B) Runtime Settings: runtimeArgs.clear(); runtimeProps.clear(); streamProps.clear(); if (args.size()) { m_propertyGrid->Append(new wxPropertyCategory("Run-time Settings")); for (SoapySDR::ArgInfoList::const_iterator args_i = args.begin(); args_i != args.end(); args_i++) { SoapySDR::ArgInfo arg = (*args_i); //We-reread the Device configuration, else we use the user settings. if (dev) { //Apply saved settings DeviceConfig *devConfig = wxGetApp().getConfig()->getDevice(dev->getDeviceId()); arg.value = devConfig->getSetting(arg.key, soapyDev->readSetting(arg.key)); //use SoapyDevice data as fallback. } else { //re-read the SoapyDevice arg.value = soapyDev->readSetting(arg.key); } runtimeProps[arg.key] = addArgInfoProperty(m_propertyGrid, arg); runtimeArgs[arg.key] = arg; } } if (dev) { args = dev->getSoapyDevice()->getStreamArgsInfo(SOAPY_SDR_RX, 0); DeviceConfig *devConfig = wxGetApp().getConfig()->getDevice(dev->getDeviceId()); ConfigSettings devStreamOpts = devConfig->getStreamOpts(); if (devStreamOpts.size()) { for (int j = 0, jMax = args.size(); j < jMax; j++) { if (devStreamOpts.find(args[j].key) != devStreamOpts.end()) { args[j].value = devStreamOpts[args[j].key]; } } } if (args.size()) { m_propertyGrid->Append(new wxPropertyCategory("Stream Settings")); for (SoapySDR::ArgInfo arg : args) { streamProps[arg.key] = addArgInfoProperty(m_propertyGrid, arg); } } } if (selDev->isManual()) { m_addRemoteButton->SetLabel("Remove"); removeId = selId; } else { m_addRemoteButton->SetLabel("Add"); removeId = nullptr; } } else if (selDev && !selDev->isAvailable() && selDev->isManual()) { m_propertyGrid->Clear(); devSettings.clear(); runtimeArgs.clear(); runtimeProps.clear(); streamProps.clear(); removeId = devTree->GetSelection(); dev = nullptr; selId = nullptr; editId = nullptr; m_addRemoteButton->SetLabel("Remove"); } else if (!selDev) { m_addRemoteButton->SetLabel("Add"); removeId = nullptr; } }
std::vector<SDRDeviceInfo *> *SDREnumerator::enumerate_devices(std::string remoteAddr, bool noInit) { if (SDREnumerator::devs[remoteAddr].size()) { return &SDREnumerator::devs[remoteAddr]; } if (noInit) { return NULL; } if (!soapy_initialized) { std::cout << "SoapySDR init.." << std::endl; std::cout << "\tAPI Version: v" << SoapySDR::getAPIVersion() << std::endl; std::cout << "\tABI Version: v" << SoapySDR::getABIVersion() << std::endl; std::cout << "\tInstall root: " << SoapySDR::getRootPath() << std::endl; std::cout << "\tLoading modules... " << std::endl; std::string userModPath = wxGetApp().getModulePath(); if (userModPath != "") { wxGetApp().sdrEnumThreadNotify(SDREnumerator::SDR_ENUM_MESSAGE, "Loading SoapySDR modules from " + userModPath + ".."); std::vector<std::string> localMods = SoapySDR::listModules(userModPath); for (std::vector<std::string>::iterator mods_i = localMods.begin(); mods_i != localMods.end(); mods_i++) { wxGetApp().sdrEnumThreadNotify(SDREnumerator::SDR_ENUM_MESSAGE, "Initializing user specified SoapySDR module " + (*mods_i) + ".."); std::cout << "Initializing user specified SoapySDR module " << (*mods_i) << ".." << std::endl; SoapySDR::loadModule(*mods_i); } } else { #ifdef BUNDLE_SOAPY_MODS bool localModPref = wxGetApp().getUseLocalMod(); if (localModPref) { wxGetApp().sdrEnumThreadNotify(SDREnumerator::SDR_ENUM_MESSAGE, "Loading SoapySDR modules.."); std::cout << "Checking local system SoapySDR modules.." << std::flush; SoapySDR::loadModules(); } wxFileName exePath = wxFileName(wxStandardPaths::Get().GetExecutablePath()); std::vector<std::string> localMods = SoapySDR::listModules(exePath.GetPath().ToStdString() + "/modules/"); for (std::vector<std::string>::iterator mods_i = localMods.begin(); mods_i != localMods.end(); mods_i++) { wxGetApp().sdrEnumThreadNotify(SDREnumerator::SDR_ENUM_MESSAGE, "Initializing bundled SoapySDR module " + (*mods_i) + ".."); std::cout << "Loading bundled SoapySDR module " << (*mods_i) << ".." << std::endl; SoapySDR::loadModule(*mods_i); } if (!localModPref) { wxGetApp().sdrEnumThreadNotify(SDREnumerator::SDR_ENUM_MESSAGE, "Loading SoapySDR modules.."); std::cout << "Checking system SoapySDR modules.." << std::flush; SoapySDR::loadModules(); } #else wxGetApp().sdrEnumThreadNotify(SDREnumerator::SDR_ENUM_MESSAGE, "Loading SoapySDR modules.."); SoapySDR::loadModules(); #endif } if (SDREnumerator::factories.size()) { SDREnumerator::factories.erase(SDREnumerator::factories.begin(), SDREnumerator::factories.end()); } std::cout << "\tAvailable factories..."; SoapySDR::FindFunctions factories = SoapySDR::Registry::listFindFunctions(); for (SoapySDR::FindFunctions::const_iterator it = factories.begin(); it != factories.end(); ++it) { if (it != factories.begin()) { std::cout << ", "; } std::cout << it->first; if (it->first == "remote") { has_remote = true; } SDREnumerator::factories.push_back(it->first); } if (factories.empty()) { std::cout << "No factories found!" << std::endl; } if ((factories.size() == 1) && factories.find("null") != factories.end()) { std::cout << "Just 'null' factory found." << std::endl; wxGetApp().sdrEnumThreadNotify(SDREnumerator::SDR_ENUM_FAILED, std::string("No modules available.")); } std::cout << std::endl; soapy_initialized = true; } modules = SoapySDR::listModules(); std::vector<SoapySDR::Kwargs> results; SoapySDR::Kwargs enumArgs; bool isRemote = false; if (remoteAddr.length()) { std::cout << "Enumerating remote address: " << remoteAddr << std::endl; enumArgs["driver"] = "remote"; enumArgs["remote"] = remoteAddr; isRemote = true; results = SoapySDR::Device::enumerate(enumArgs); } else { results = SoapySDR::Device::enumerate(); } int manualsIdx = results.size(); std::vector<std::string> manualParams; std::vector<bool> manualResult; if (manuals.size()) { for (std::vector<SDRManualDef>::const_iterator m_i = manuals.begin(); m_i != manuals.end(); m_i++) { std::vector<SoapySDR::Kwargs> manual_result; std::string strDevArgs = "driver="+m_i->factory+","+m_i->params; manualParams.push_back(m_i->params); wxGetApp().sdrEnumThreadNotify(SDREnumerator::SDR_ENUM_MESSAGE, std::string("Enumerating manual device '") + strDevArgs + "'.."); manual_result = SoapySDR::Device::enumerate(strDevArgs); if (manual_result.size()) { for (std::vector<SoapySDR::Kwargs>::const_iterator i = manual_result.begin(); i != manual_result.end(); i++) { results.push_back(*i); manualResult.push_back(true); } } else { SoapySDR::Kwargs failedEnum; failedEnum = argsStrToKwargs(strDevArgs); failedEnum["label"] = "Not Found ("+m_i->factory+")"; results.push_back(failedEnum); manualResult.push_back(false); } } } if (isRemote) { wxGetApp().sdrEnumThreadNotify(SDREnumerator::SDR_ENUM_MESSAGE, std::string("Opening remote server ") + remoteAddr + ".."); } for (size_t i = 0; i < results.size(); i++) { SDRDeviceInfo *dev = new SDRDeviceInfo(); SoapySDR::Kwargs deviceArgs = results[i]; for (SoapySDR::Kwargs::const_iterator it = deviceArgs.begin(); it != deviceArgs.end(); ++it) { std::cout << " " << it->first << " = " << it->second << std::endl; if (it->first == "driver") { dev->setDriver(it->second); } else if (it->first == "label" || it->first == "device") { dev->setName(it->second); } } if (deviceArgs.count("remote")) { isRemote = true; } else { isRemote = false; } dev->setRemote(isRemote); dev->setManual(i>=manualsIdx); if (i>=manualsIdx) { dev->setManualParams(manualParams[i-manualsIdx]); } std::cout << "Make device " << i << std::endl; if (i<manualsIdx || manualResult[i-manualsIdx]) try { SoapySDR::Device *device = SoapySDR::Device::make(deviceArgs); SoapySDR::Kwargs info = device->getHardwareInfo(); for (SoapySDR::Kwargs::const_iterator it = info.begin(); it != info.end(); ++it) { std::cout << " " << it->first << "=" << it->second << std::endl; if (it->first == "hardware") { dev->setHardware(it->second); } } if (isRemote) { wxGetApp().sdrEnumThreadNotify(SDREnumerator::SDR_ENUM_MESSAGE, "Querying remote " + remoteAddr + " device #" + std::to_string(i) + ": " + dev-> getName()); } else { wxGetApp().sdrEnumThreadNotify(SDREnumerator::SDR_ENUM_MESSAGE, std::string("Querying device #") + std::to_string(i) + ": " + dev->getName()); } SoapySDR::ArgInfoList settingsInfo = device->getSettingInfo(); DeviceConfig *cfg = wxGetApp().getConfig()->getDevice(dev->getDeviceId()); ConfigSettings devSettings = cfg->getSettings(); if (devSettings.size()) { for (ConfigSettings::const_iterator set_i = devSettings.begin(); set_i != devSettings.end(); set_i++) { deviceArgs[set_i->first] = set_i->second; } for (int j = 0; j < settingsInfo.size(); j++) { if (deviceArgs.find(settingsInfo[j].key) != deviceArgs.end()) { settingsInfo[j].value = deviceArgs[settingsInfo[j].key]; } } } dev->setDeviceArgs(deviceArgs); dev->setSettingsInfo(settingsInfo); int numChan = device->getNumChannels(SOAPY_SDR_RX); for (int i = 0; i < numChan; i++) { SDRDeviceChannel *chan = new SDRDeviceChannel(); SoapySDR::RangeList rfRange = device->getFrequencyRange(SOAPY_SDR_RX, i); double rfMin = rfRange[0].minimum(); double rfMax = rfRange[rfRange.size()-1].maximum(); chan->setChannel(i); chan->setFullDuplex(device->getFullDuplex(SOAPY_SDR_RX, i)); chan->setRx(true); chan->setTx(false); chan->getRFRange().setLow(rfMin); chan->getRFRange().setHigh(rfMax); std::vector<std::string> freqs = device->listFrequencies(SOAPY_SDR_RX,i); if (std::find(freqs.begin(), freqs.end(), "CORR") != freqs.end()) { chan->setCORR(true); } else { chan->setCORR(false); } if (device->hasDCOffsetMode(SOAPY_SDR_RX, i)) { chan->setHardwareDC(true); } else { chan->setHardwareDC(false); } std::vector<double> rates = device->listSampleRates(SOAPY_SDR_RX, i); for (std::vector<double>::iterator i = rates.begin(); i != rates.end(); i++) { chan->getSampleRates().push_back((long)(*i)); } ConfigSettings devStreamOpts = cfg->getStreamOpts(); if (devStreamOpts.size()) { dev->setStreamArgs(devStreamOpts); } SoapySDR::ArgInfoList optArgs = device->getStreamArgsInfo(SOAPY_SDR_RX, i); if (devStreamOpts.size()) { for (int j = 0, jMax = optArgs.size(); j < jMax; j++) { if (devStreamOpts.find(optArgs[j].key) != devStreamOpts.end()) { optArgs[j].value = devStreamOpts[optArgs[j].key]; } } } chan->setStreamArgsInfo(optArgs); std::vector<std::string> gainNames = device->listGains(SOAPY_SDR_RX, i); for (std::vector<std::string>::iterator gname = gainNames.begin(); gname!= gainNames.end(); gname++) { chan->addGain((*gname),device->getGainRange(SOAPY_SDR_RX, i, (*gname))); } dev->addChannel(chan); } SoapySDR::Device::unmake(device); dev->setAvailable(true); } catch (const std::exception &ex) { std::cerr << "Error making device: " << ex.what() << std::endl; wxGetApp().sdrEnumThreadNotify(SDREnumerator::SDR_ENUM_MESSAGE, std::string("Error querying device #") + std::to_string(i)); dev->setAvailable(false); } else { dev->setAvailable(false); } std::cout << std::endl; SDREnumerator::devs[remoteAddr].push_back(dev); } if (SDREnumerator::devs[remoteAddr].empty()) { wxGetApp().sdrEnumThreadNotify(SDREnumerator::SDR_ENUM_MESSAGE, std::string("No devices found!")); } std::cout << std::endl; return &SDREnumerator::devs[remoteAddr]; }
void SDRDevicesDialog::OnSelectionChanged( wxTreeEvent& event ) { SDRDeviceInfo *selDev = getSelectedDevice(devTree->GetSelection()); if (selDev && selDev->isAvailable()) { dev = selDev; selId = devTree->GetSelection(); DeviceConfig *devConfig = wxGetApp().getConfig()->getDevice(dev->getName()); m_propertyGrid->Clear(); SoapySDR::ArgInfoList args = dev->getSettingsArgInfo(); SoapySDR::ArgInfoList::const_iterator args_i; m_propertyGrid->Append(new wxPropertyCategory("General Settings")); devSettings.erase(devSettings.begin(),devSettings.end()); devSettings["name"] = m_propertyGrid->Append( new wxStringProperty("Name", wxPG_LABEL, devConfig->getDeviceName()) ); devSettings["offset"] = m_propertyGrid->Append( new wxIntProperty("Offset (Hz)", wxPG_LABEL, devConfig->getOffset()) ); props.erase(props.begin(), props.end()); if (args.size()) { m_propertyGrid->Append(new wxPropertyCategory("Run-time Settings")); for (args_i = args.begin(); args_i != args.end(); args_i++) { SoapySDR::ArgInfo arg = (*args_i); props.push_back(addArgInfoProperty(m_propertyGrid, arg)); } } if (dev->getRxChannel()) { args = dev->getRxChannel()->getStreamArgsInfo(); DeviceConfig *devConfig = wxGetApp().getConfig()->getDevice(dev->getDeviceId()); ConfigSettings devStreamOpts = devConfig->getStreamOpts(); if (devStreamOpts.size()) { for (int j = 0, jMax = args.size(); j < jMax; j++) { if (devStreamOpts.find(args[j].key) != devStreamOpts.end()) { args[j].value = devStreamOpts[args[j].key]; } } } if (args.size()) { m_propertyGrid->Append(new wxPropertyCategory("Stream Settings")); for (args_i = args.begin(); args_i != args.end(); args_i++) { SoapySDR::ArgInfo arg = (*args_i); props.push_back(addArgInfoProperty(m_propertyGrid, arg)); } } } if (selDev->isManual()) { m_addRemoteButton->SetLabel("Remove"); removeId = selId; } else { m_addRemoteButton->SetLabel("Add"); removeId = nullptr; } } else if (selDev && !selDev->isAvailable() && selDev->isManual()) { m_propertyGrid->Clear(); devSettings.erase(devSettings.begin(),devSettings.end()); props.erase(props.begin(), props.end()); removeId = devTree->GetSelection(); dev = nullptr; selId = nullptr; editId = nullptr; m_addRemoteButton->SetLabel("Remove"); } else if (!selDev) { m_addRemoteButton->SetLabel("Add"); removeId = nullptr; } event.Skip(); }
int main(int argc, char **argv) { #if defined(__linux__) || (defined(__APPLE__) && defined(__MACH__)) //Lower the process priority on linux and mac. On windows this is done on process creation from the GUI. setpriority(PRIO_PROCESS, 0, 10); #endif //Register the exception handling for arithmic exceptions, this prevents the "something went wrong" dialog on windows to pop up on a division by zero. signal(SIGFPE, signal_FPE); ConfigSettings config; fffProcessor processor(config); std::vector<std::string> files; cura::logError("Cura_SteamEngine version %s\n", VERSION); cura::logError("Copyright (C) 2014 David Braam\n"); cura::logError("\n"); cura::logError("This program is free software: you can redistribute it and/or modify\n"); cura::logError("it under the terms of the GNU Affero General Public License as published by\n"); cura::logError("the Free Software Foundation, either version 3 of the License, or\n"); cura::logError("(at your option) any later version.\n"); cura::logError("\n"); cura::logError("This program is distributed in the hope that it will be useful,\n"); cura::logError("but WITHOUT ANY WARRANTY; without even the implied warranty of\n"); cura::logError("MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"); cura::logError("GNU Affero General Public License for more details.\n"); cura::logError("\n"); cura::logError("You should have received a copy of the GNU Affero General Public License\n"); cura::logError("along with this program. If not, see <http://www.gnu.org/licenses/>.\n"); if(!config.readSettings()) { cura::logError("Default config '%s' not used\n", DEFAULT_CONFIG_PATH); } for(int argn = 1; argn < argc; argn++) cura::log("Arg: %s\n", argv[argn]); // for(int argn = 1; argn < argc; argn++) // { // char* str = argv[argn]; // if (str[0] == '-') // { // for(str++; *str; str++) // { // switch(*str) // { // case 'h': // print_usage(); // exit(1); // case 'v': // cura::increaseVerboseLevel(); // break; // case 'p': // cura::enableProgressLogging(); // break; // case 'g': // argn++; // //Connect the GUI socket to the given port number. // processor.guiConnect(atoi(argv[argn])); // break; // case 'b': // argn++; // //The binaryMeshBlob is depricated and will be removed in the future. // binaryMeshBlob = fopen(argv[argn], "rb"); // break; // case 'o': // argn++; // if (!processor.setTargetFile(argv[argn])) // { // cura::logError("Failed to open %s for output.\n", argv[argn]); // exit(1); // } // break; // case 'c': // { // // Read a config file from the given path // argn++; // if(!config.readSettings(argv[argn])) { // cura::logError("Failed to read config '%s'\n", argv[argn]); // } // } // break; // case 's': // { // //Parse the given setting and store it. // argn++; // char* valuePtr = strchr(argv[argn], '='); // if (valuePtr) // { // *valuePtr++ = '\0'; // // if (!config.setSetting(argv[argn], valuePtr)) // cura::logError("Setting not found: %s %s\n", argv[argn], valuePtr); // } // } // break; // case 'm': // //Read the given rotation/scale matrix // argn++; // sscanf(argv[argn], "%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf", // &config.matrix.m[0][0], &config.matrix.m[0][1], &config.matrix.m[0][2], // &config.matrix.m[1][0], &config.matrix.m[1][1], &config.matrix.m[1][2], // &config.matrix.m[2][0], &config.matrix.m[2][1], &config.matrix.m[2][2]); // break; // case '-': // try { // //Catch all exceptions, this prevents the "something went wrong" dialog on windows to pop up on a thrown exception. // // Only ClipperLib currently throws exceptions. And only in case that it makes an internal error. // if (files.size() > 0) // processor.processFile(files); // files.clear(); // }catch(...){ // cura::logError("Unknown exception\n"); // exit(1); // } // break; // default: // cura::logError("Unknown option: %c\n", *str); // break; // } // } // }else{ // if (argv[argn][0] == '$') // { // try { // //Catch all exceptions, this prevents the "something went wrong" dialog on windows to pop up on a thrown exception. // // Only ClipperLib currently throws exceptions. And only in case that it makes an internal error. // std::vector<std::string> tmp; // tmp.push_back(argv[argn]); // processor.processFile(tmp); // }catch(...){ // cura::logError("Unknown exception\n"); // exit(1); // } // }else{ // files.push_back(argv[argn]); // } // } // } printf("your stl input is \n"); printf("%s\n",argv[1]); files.push_back(argv[1]); printf("your gcode output is \n"); printf("%s\n",argv[2]); if (!processor.setTargetFile(argv[2])) { cura::logError("Failed to open %s for output.\n", argv[2]); exit(1); } try { //Catch all exceptions, this prevents the "something went wrong" dialog on windows to pop up on a thrown exception. // Only ClipperLib currently throws exceptions. And only in case that it makes an internal error. if (files.size() > 0) processor.processFile(files); } catch(...) { cura::logError("Unknown exception\n"); exit(1); } //Finalize the processor, this adds the end.gcode. And reports statistics. processor.finalize(); // debugPrint(); return 0; }
int main(int argc, char **argv) { #if defined(__linux__) || (defined(__APPLE__) && defined(__MACH__)) //Lower the process priority on linux and mac. setpriority(PRIO_PROCESS, 0, 10); #endif signal(SIGFPE, signal_FPE); ConfigSettings config; fffProcessor processor(config); config.filamentDiameter = 2890; config.filamentFlow = 100; config.initialLayerThickness = 300; config.layerThickness = 100; config.extrusionWidth = 400; config.insetCount = 2; config.downSkinCount = 6; config.upSkinCount = 6; config.initialSpeedupLayers = 4; config.initialLayerSpeed = 20; config.printSpeed = 50; config.infillSpeed = 50; config.moveSpeed = 200; config.fanFullOnLayerNr = 2; config.skirtDistance = 6000; config.skirtLineCount = 1; config.skirtMinLength = 0; config.sparseInfillLineDistance = 100 * config.extrusionWidth / 20; config.infillOverlap = 15; config.objectPosition.X = 102500; config.objectPosition.Y = 102500; config.objectSink = 0; config.supportAngle = -1; config.supportEverywhere = 0; config.supportLineDistance = config.sparseInfillLineDistance; config.supportExtruder = -1; config.supportXYDistance = 700; config.supportZDistance = 150; config.retractionAmount = 4500; config.retractionSpeed = 45; config.retractionAmountExtruderSwitch = 14500; config.retractionMinimalDistance = 1500; config.minimalExtrusionBeforeRetraction = 100; config.enableOozeShield = 0; config.enableCombing = 1; config.wipeTowerSize = 0; config.multiVolumeOverlap = 0; config.minimalLayerTime = 5; config.minimalFeedrate = 10; config.coolHeadLift = 1; config.fanSpeedMin = 100; config.fanSpeedMax = 100; config.raftMargin = 5000; config.raftLineSpacing = 1000; config.raftBaseThickness = 0; config.raftBaseLinewidth = 0; config.raftInterfaceThickness = 0; config.raftInterfaceLinewidth = 0; config.spiralizeMode = 0; config.fixHorrible = 0; config.gcodeFlavor = GCODE_FLAVOR_REPRAP; memset(config.extruderOffset, 0, sizeof(config.extruderOffset)); config.startCode = "M109 S210 ;Heatup to 210C\n" "G21 ;metric values\n" "G90 ;absolute positioning\n" "G28 ;Home\n" "G1 Z15.0 F300 ;move the platform down 15mm\n" "G92 E0 ;zero the extruded length\n" "G1 F200 E5 ;extrude 5mm of feed stock\n" "G92 E0 ;zero the extruded length again\n"; config.endCode = "M104 S0 ;extruder heater off\n" "M140 S0 ;heated bed heater off (if you have it)\n" "G91 ;relative positioning\n" "G1 E-1 F300 ;retract the filament a bit before lifting the nozzle, to release some of the pressure\n" "G1 Z+0.5 E-5 X-20 Y-20 F9000 ;move Z up a bit and retract filament even more\n" "G28 X0 Y0 ;move X/Y to min endstops, so the head is out of the way\n" "M84 ;steppers off\n" "G90 ;absolute positioning\n"; fprintf(stdout,"Cura_SteamEngine version %s\n", VERSION); for(int argn = 1; argn < argc; argn++) { char* str = argv[argn]; if (str[0] == '-') { for(str++; *str; str++) { switch(*str) { case 'h': print_usage(); exit(1); case 'v': verbose_level++; break; case 'b': argn++; binaryMeshBlob = fopen(argv[argn], "rb"); break; case 'o': argn++; if (!processor.setTargetFile(argv[argn])) { logError("Failed to open %s for output.\n", argv[argn]); exit(1); } break; case 's': { argn++; char* valuePtr = strchr(argv[argn], '='); if (valuePtr) { *valuePtr++ = '\0'; if (!config.setSetting(argv[argn], valuePtr)) printf("Setting not found: %s %s\n", argv[argn], valuePtr); } } break; case 'm': argn++; sscanf(argv[argn], "%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf", &config.matrix.m[0][0], &config.matrix.m[0][1], &config.matrix.m[0][2], &config.matrix.m[1][0], &config.matrix.m[1][1], &config.matrix.m[1][2], &config.matrix.m[2][0], &config.matrix.m[2][1], &config.matrix.m[2][2]); break; default: logError("Unknown option: %c\n", *str); break; } } }else{ try { processor.processFile(argv[argn]); }catch(...){ printf("Unknown exception\n"); exit(1); } } } processor.finalize(); }
void SDRDevicesDialog::refreshDeviceProperties() { SDRDeviceInfo *selDev = getSelectedDevice(devTree->GetSelection()); if (selDev && selDev->isAvailable()) { dev = selDev; selId = devTree->GetSelection(); DeviceConfig *devConfig = wxGetApp().getConfig()->getDevice(dev->getName()); m_propertyGrid->Clear(); SoapySDR::Device *soapyDev = dev->getSoapyDevice(); SoapySDR::ArgInfoList args = soapyDev->getSettingInfo(); SoapySDR::ArgInfoList::const_iterator args_i; m_propertyGrid->Append(new wxPropertyCategory("General Settings")); devSettings.erase(devSettings.begin(),devSettings.end()); devSettings["name"] = m_propertyGrid->Append( new wxStringProperty("Name", wxPG_LABEL, devConfig->getDeviceName()) ); devSettings["offset"] = m_propertyGrid->Append( new wxIntProperty("Offset (Hz)", wxPG_LABEL, devConfig->getOffset()) ); runtimeArgs.erase(runtimeArgs.begin(), runtimeArgs.end()); runtimeProps.erase(runtimeProps.begin(), runtimeProps.end()); streamProps.erase(streamProps.begin(), streamProps.end()); if (args.size()) { m_propertyGrid->Append(new wxPropertyCategory("Run-time Settings")); for (args_i = args.begin(); args_i != args.end(); args_i++) { SoapySDR::ArgInfo arg = (*args_i); arg.value = soapyDev->readSetting(arg.key); runtimeProps[arg.key] = addArgInfoProperty(m_propertyGrid, arg); runtimeArgs[arg.key] = arg; } } if (dev) { args = dev->getSoapyDevice()->getStreamArgsInfo(SOAPY_SDR_RX, 0); DeviceConfig *devConfig = wxGetApp().getConfig()->getDevice(dev->getDeviceId()); ConfigSettings devStreamOpts = devConfig->getStreamOpts(); if (devStreamOpts.size()) { for (int j = 0, jMax = args.size(); j < jMax; j++) { if (devStreamOpts.find(args[j].key) != devStreamOpts.end()) { args[j].value = devStreamOpts[args[j].key]; } } } if (args.size()) { m_propertyGrid->Append(new wxPropertyCategory("Stream Settings")); for (args_i = args.begin(); args_i != args.end(); args_i++) { SoapySDR::ArgInfo arg = (*args_i); streamProps[arg.key] = addArgInfoProperty(m_propertyGrid, arg); } } } if (selDev->isManual()) { m_addRemoteButton->SetLabel("Remove"); removeId = selId; } else { m_addRemoteButton->SetLabel("Add"); removeId = nullptr; } } else if (selDev && !selDev->isAvailable() && selDev->isManual()) { m_propertyGrid->Clear(); devSettings.erase(devSettings.begin(),devSettings.end()); runtimeArgs.erase(runtimeArgs.begin(), runtimeArgs.end()); runtimeProps.erase(runtimeProps.begin(), runtimeProps.end()); streamProps.erase(streamProps.begin(), streamProps.end()); removeId = devTree->GetSelection(); dev = nullptr; selId = nullptr; editId = nullptr; m_addRemoteButton->SetLabel("Remove"); } else if (!selDev) { m_addRemoteButton->SetLabel("Add"); removeId = nullptr; } }