public AdvancedOptionsViewModel() { AcousticOuput = new LsmppOption("Acoustic output", "BEM="); InterfaceSegment = new LsmppOption("Interface segment", "L="); VdaGeometry = new LsmppOption("Vda geometry", "V="); Cal3dInput = new LsmppOption("CAL3D input", "Y="); Topaz3dfile = new LsmppOption("TOPAZ3D file", "T="); StressInitialization = new LsmppOption("Stress initialization", "M="); MappingInputFile = new LsmppOption("Mapping input file", "MAP="); Graphics = new LsmppOption("Graphics", "G="); TimeHistories = new LsmppOption("Time histories", "F="); InterfaceForce = new LsmppOption("Interface force", "S="); FsiInterfaceForce = new LsmppOption("FSI interface force", "H="); DynamicRelaxation = new LsmppOption("Dynamic relaxation", "B=", "d3drfl"); DemInterfaceForce = new LsmppOption("DEM interface force", "DEM="); InputEcho = new LsmppOption("Input echo", "E="); RestartDump = new LsmppOption("Restart dump", "D=", "d3dump"); InterfaceSegmentSave = new LsmppOption("Interface segment save", "Z="); RemapCrackDatabase = new LsmppOption("Remap Crack database", "Q=", "remap"); RunningRestartDump = new LsmppOption("Running restart dump", "A=", "runrsf"); PropertyOutput = new LsmppOption("Property output", "D3PROP=", "d3prop"); MappingOutputFile = new LsmppOption("Mapping output file", "MAP="); }
public SettingsViewModel() { this.WhenAnyValue(x => x.LicenseTypeIndex).Select(x => x.Equals(1)).ToProperty(this, x => x.IsNetworkLicense, out _isNetworkLicense); this.WhenAnyValue(x => x.LicenseTypeIndex).Select(x => x.Equals(0)).ToProperty(this, x => x.IsLocalLicense, out _isLocalLicense); LicenseType = new LsmppOption("License Type", "-env lstc_license "); LicenseFile = new LsmppOption("Local License File", "-env lstc_file "); LicenseServer = new LsmppOption("License Server", "-env lstc_license_server "); LicensePort = new LsmppOption("Network License Port", "-env lstc_license_port "); this.WhenAnyValue(x => x.LicenseType.Value).Where(x => !String.IsNullOrWhiteSpace(x)).Subscribe(x => { Properties.Settings.Default.LSTC_LICENSE = x; Properties.Settings.Default.Save(); }); this.WhenAnyValue(x => x.LicenseFile.Value).Where(x => !String.IsNullOrWhiteSpace(x)).Throttle(TimeSpan.FromSeconds(3)).Subscribe(x => { Properties.Settings.Default.LSTC_FILE = x; Properties.Settings.Default.Save(); }); this.WhenAnyValue(x => x.LicensePort.Value).Where(x => !String.IsNullOrWhiteSpace(x)).Throttle(TimeSpan.FromSeconds(3)).Subscribe(x => { Properties.Settings.Default.LSTC_LICENSE_SERVER_PORT = x; Properties.Settings.Default.Save(); }); this.WhenAnyValue(x => x.LicenseServer.Value).Where(x => !String.IsNullOrWhiteSpace(x)).Throttle(TimeSpan.FromSeconds(3)).Subscribe(x => { Properties.Settings.Default.LSTC_LICENSE_SERVER = x; Properties.Settings.Default.Save(); }); this.WhenAnyValue(x => x.LSTCPath).Where(x => !String.IsNullOrWhiteSpace(x)).Throttle(TimeSpan.FromSeconds(3)).Subscribe(x => { Properties.Settings.Default.LSTC_PATH = x; Properties.Settings.Default.Save(); }); ImportLicense = ReactiveCommand.CreateAsyncTask(async _ => { //await Task.Delay(60); await CopyLicense(); }); ImportLicense.ThrownExceptions.Subscribe(ex => { MessageBox.Show("Error"); }); StartLicenseManager = ReactiveCommand.CreateAsyncTask(_ => LstcLicenseManager("start")); StopLicenseManager = ReactiveCommand.CreateAsyncTask(_ => LstcLicenseManager("stop")); LaunchLicenseManager = ReactiveCommand.CreateAsyncTask(_ => LstcLicenseManager("launch")); StartLicenseManager.ThrownExceptions.Subscribe(ex => MessageBox.Show("Check LSTC Path", "Error Starting License Manager")); StopLicenseManager.ThrownExceptions.Subscribe(ex => MessageBox.Show("Check LSTC Path", "Error Stoping License Manager")); //LaunchLicenseManager.ThrownExceptions.Subscribe(ex => MessageBox.Show("lstclmui.exe not found. Check LSTC Path.", "Error Launching License Manager")); LaunchLicenseManager.ThrownExceptions .Select(ex => new UserError("lstclmui.exe not found. Check LSTC Path setting.", "Check LSTC Path")) .SelectMany(UserError.Throw) .Subscribe(); _SpinnerVisibility = ImportLicense.IsExecuting .Select(x => x ? Visibility.Visible : Visibility.Hidden) .ToProperty(this, x => x.SpinnerVisibility, Visibility.Visible); this.WhenAnyValue(x => x.LicenseTypeIndex).Subscribe(x => { if (x.Equals(0)) { this.LicenseFile.IsActive = true; this.LicensePort.IsActive = false; this.LicenseServer.IsActive = false; } else { this.LicenseFile.IsActive = false; this.LicensePort.IsActive = true; this.LicenseServer.IsActive = true; } }); }
public MainViewModel(AdvancedOptionsViewModel AdvancedOptions, SettingsViewModel Settings) { // Master list of command line options this is a reactive list so we can track changes and build the command Options = new ReactiveList <LsmppOption>() { ChangeTrackingEnabled = true }; // Track changes to options and when an option value changes set it to active Options.ItemChanged.Where(x => x.PropertyName == "Value").Select(x => x.Sender).Subscribe(x => x.IsActive = true); // Here we are updating the command for mpp any time an option changes Options.ItemChanged.Select(_ => String.Join(" ", Options.Where(x => x.IsActive).Select(x => x.ToString()).ToArray())).ToProperty(this, x => x.mppCommand, out _mppCommand); // Add all the various commandline options to Options MpiExe = new LsmppOption("MPI EXE", ""); Options.Add(MpiExe); Processors = new LsmppOption("Processors", "-np "); Options.Add(Processors); Affinity = new LsmppOption("Affinity", "", "-affinity"); Options.Add(Affinity); Options.Add(Settings.LicenseType); Options.Add(Settings.LicenseFile); Options.Add(Settings.LicenseServer); Options.Add(Settings.LicensePort); ExtraMPICommands = new LsmppOption("Extra MPI commands", ""); Options.Add(ExtraMPICommands); Solver = new LsmppOption("Solver", ""); Options.Add(Solver); InputFile = new LsmppOption("Input File", "I="); Options.Add(InputFile); RestartFile = new LsmppOption("Restart File", "R="); Options.Add(RestartFile); OutputFile = new LsmppOption("Output File", "O="); Options.Add(OutputFile); Memory = new LsmppOption("Memory", "Memory="); Options.Add(Memory); Memory2 = new LsmppOption("Memory2", "Memory2="); Options.Add(Memory2); ExtraMPPCommands = new LsmppOption("Extra MPP commands", ""); Options.Add(ExtraMPPCommands); // Advanced Options Options.Add(AdvancedOptions.AcousticOuput); Options.Add(AdvancedOptions.InterfaceSegment); Options.Add(AdvancedOptions.VdaGeometry); Options.Add(AdvancedOptions.Cal3dInput); Options.Add(AdvancedOptions.Topaz3dfile); Options.Add(AdvancedOptions.StressInitialization); Options.Add(AdvancedOptions.MappingInputFile); Options.Add(AdvancedOptions.Graphics); Options.Add(AdvancedOptions.TimeHistories); Options.Add(AdvancedOptions.InterfaceForce); Options.Add(AdvancedOptions.FsiInterfaceForce); Options.Add(AdvancedOptions.DynamicRelaxation); Options.Add(AdvancedOptions.AcousticOuput); Options.Add(AdvancedOptions.DemInterfaceForce); Options.Add(AdvancedOptions.InputEcho); Options.Add(AdvancedOptions.RestartDump); Options.Add(AdvancedOptions.InterfaceSegmentSave); Options.Add(AdvancedOptions.RemapCrackDatabase); Options.Add(AdvancedOptions.RunningRestartDump); Options.Add(AdvancedOptions.PropertyOutput); Options.Add(AdvancedOptions.MappingOutputFile); // Set the working directory when the user selects an input or restart file this.WhenAny( x => x.InputFile.Value, x => x.RestartFile.Value, (input, restart) => ToWorkingDir(input.Value, restart.Value)).ToProperty(this, x => x.WorkingDir, out _workingDir); BrowseInputFile = ReactiveCommand.Create(); BrowseRestartFile = ReactiveCommand.Create(); BrowseOutputFile = ReactiveCommand.Create(); BrowseSolver = ReactiveCommand.Create(); var canRunMPP = this.WhenAny( x => x.InputFile.Value, x => x.RestartFile.Value, x => x.OutputFile.Value, x => x.Solver.Value, x => x.Processors.Value, (input, restart, output, solver, processors) => (!String.IsNullOrWhiteSpace(input.Value) || !String.IsNullOrWhiteSpace(restart.Value)) && !String.IsNullOrWhiteSpace(output.Value) && !String.IsNullOrWhiteSpace(solver.Value) && processors.Value != "0"); Run = ReactiveCommand.Create(canRunMPP); SWRestartStop = ReactiveCommand.Create(canRunMPP); SWRestartContinue = ReactiveCommand.Create(canRunMPP); SWRezonerToggle = ReactiveCommand.Create(canRunMPP); SWTimeAndCycle = ReactiveCommand.Create(canRunMPP); SWVisToggle = ReactiveCommand.Create(canRunMPP); SWPlotState = ReactiveCommand.Create(canRunMPP); SWASCIIFlush = ReactiveCommand.Create(canRunMPP); SWStop = ReactiveCommand.Create(canRunMPP); this.WhenAnyValue(x => x.RestartFile.Value).Where(x => x.ToLowerInvariant().Contains("full")).Subscribe(_ => this.RestartFile.Flag = "N="); this.WhenAnyValue(x => x.RestartFile.Value).Where(x => x.ToLowerInvariant().Contains("dump")).Subscribe(_ => this.RestartFile.Flag = "R="); this.WhenAnyValue(x => x.MemorySize).Subscribe(_ => this.Memory.Value = this.Memory.Value + this.MemorySize); }