/// <summary> /// Fires <see cref="IChemObjectIOListener.ProcessIOSettingQuestion(IOSetting)"/> for all managed listeners. /// </summary> /// <param name="setting">the setting to process</param> protected void ProcessIOSettingQuestion(IOSetting setting) { foreach (var listener in listeners) { listener.ProcessIOSettingQuestion(setting); } }
protected internal virtual void fireIOSettingQuestion(IOSetting setting) { for (int i = 0; i < listenerList.Count; ++i) { IChemObjectIOListener listener = (IChemObjectIOListener)listenerList[i]; listener.processIOSettingQuestion(setting); } }
private void InitIOSettings() { var basisOptions = new List <string> { "6-31g", "6-31g*", "6-31g(d)", "6-311g", "6-311+g**" }; basis = new OptionIOSetting("Basis", Importance.Medium, "Which basis set do you want to use?", basisOptions, "6-31g"); var methodOptions = new List <string> { "rb3lyp", "b3lyp", "rhf" }; method = new OptionIOSetting("Method", Importance.Medium, "Which method do you want to use?", methodOptions, "b3lyp"); var commandOptions = new List <string> { "energy calculation", "geometry optimization", "IR frequency calculation", "IR frequency calculation (with Raman)" }; command = IOSettings.Add(new OptionIOSetting("Command", Importance.High, "What kind of job do you want to perform?", commandOptions, "energy calculation")); comment = IOSettings.Add(new StringIOSetting("Comment", Importance.Low, "What comment should be put in the file?", "Created with CDK (http://cdk.sf.net/)")); memory = IOSettings.Add(new StringIOSetting("Memory", Importance.Low, "How much memory do you want to use?", "unset")); shell = IOSettings.Add(new BooleanIOSetting("OpenShell", Importance.Medium, "Should the calculation be open shell?", "false")); proccount = IOSettings.Add(new IntegerIOSetting("ProcessorCount", Importance.Low, "How many processors should be used by Gaussian?", "1")); usecheckpoint = new BooleanIOSetting("UseCheckPointFile", Importance.Low, "Should a check point file be saved?", "false"); }
public void ProcessIOSettingQuestion(IOSetting setting) { if (string.Equals("ForceReadAs3DCoordinates", setting.Name, StringComparison.Ordinal)) { try { setting.Setting = "true"; } catch (CDKException e) { Trace.TraceError($"Could not set forceReadAs3DCoords setting: {e.Message}"); Debug.WriteLine(e); } } }
/// <summary> /// Processes the IOSettings by listing the question, giving the options /// and asking the user to provide their choice. /// </summary> /// <remarks> /// Note: if the input reader is <see langword="null"/>, then the method /// does not wait for an answer, and takes the default.</remarks> public void ProcessIOSettingQuestion(IOSetting setting) { string questionName = setting.Name; if (props != null) { string propValue = props[questionName] ?? setting.Setting; try { setting.Setting = propValue; } catch (CDKException) { OutputWriter.WriteLine($"Submitted Value ({propValue}) is not valid!"); } } }
/// <summary> /// Processes the IOSettings by listing the question, giving the options /// and asking the user to provide their choice. /// </summary> /// <remarks> /// Note: if the input reader is <see langword="null"/>, then the method /// does not wait for an answer, and takes the default.</remarks> public void ProcessIOSettingQuestion(IOSetting setting) { // post the question if (setting.Level.Ordinal <= this.level.Ordinal) { // output the option name this.output.Write("[" + setting.Name + "]: "); // post the question this.output.Write(setting.Question); if (setting is BooleanIOSetting boolSet) { bool set = boolSet.IsSet; if (set) { this.output.Write(" [Yn]"); } else { this.output.Write(" [yN]"); } } else if (setting is OptionIOSetting optionSet) { var settings = optionSet.GetOptions(); for (int i = 0; i < settings.Count; i++) { this.output.Write('\n'); string option = settings[i]; this.output.Write((i + 1) + ". " + option); if (string.Equals(option, setting.Setting, StringComparison.Ordinal)) { this.output.Write(" (Default)"); } } } else { this.output.Write(" [" + setting.Setting + "]"); } this.output.Write('\n'); this.output.Flush(); // get the answer, only if input != null if (this.ins == null) { // don't really ask questions. This is intentional behaviour to // allow for listing all questions. The settings is now defaulted, // which is the intention too. } else { bool gotAnswer = false; while (!gotAnswer) { try { this.output.Write("> "); this.output.Flush(); string answer = ins.ReadLine(); if (answer.Length == 0) { // pressed ENTER -> take default } else if (setting is OptionIOSetting) { ((OptionIOSetting)setting).SetSetting(int.Parse(answer, NumberFormatInfo.InvariantInfo)); } else if (setting is BooleanIOSetting) { switch (answer.ToUpperInvariant()) { case "N": case "NO": answer = "false"; break; case "Y": case "YES": answer = "true"; break; } setting.Setting = answer; } else { setting.Setting = answer; } gotAnswer = true; } catch (IOException) { this.output.WriteLine("Cannot read from STDIN. Skipping question."); } catch (FormatException) { this.output.WriteLine("Answer is not a number."); } catch (CDKException exception) { this.output.Write('\n'); this.output.WriteLine(exception.ToString()); } } } } }
public virtual void ProcessIOSettingQuestion(IOSetting setting) { timesCalled++; }