diff options
| author | Mirta <mirta@twine-s.com> | 2020-12-30 16:39:52 +0200 |
|---|---|---|
| committer | Mirta <mirta@twine-s.com> | 2020-12-30 16:39:52 +0200 |
| commit | 00a491d93733d4625ad329b2ba8237f445364b3f (patch) | |
| tree | 4b24c6fa78d7648f4bb7cefafa464bb0b063fec4 /Software/Visual_Studio/Tango.Stubs/ViewModels | |
| parent | 124ad4150f80c6846fdee41dbbda9848c105f6e5 (diff) | |
| download | Tango-00a491d9.tar.gz Tango-00a491d9.zip | |
merge
Diffstat (limited to 'Software/Visual_Studio/Tango.Stubs/ViewModels')
| -rw-r--r-- | Software/Visual_Studio/Tango.Stubs/ViewModels/StubsViewVM.cs | 62 |
1 files changed, 24 insertions, 38 deletions
diff --git a/Software/Visual_Studio/Tango.Stubs/ViewModels/StubsViewVM.cs b/Software/Visual_Studio/Tango.Stubs/ViewModels/StubsViewVM.cs index f52457f81..7684892cd 100644 --- a/Software/Visual_Studio/Tango.Stubs/ViewModels/StubsViewVM.cs +++ b/Software/Visual_Studio/Tango.Stubs/ViewModels/StubsViewVM.cs @@ -15,7 +15,6 @@ using System.Windows; using System.Windows.Controls; using System.Windows.Input; using System.Windows.Threading; -using Tango.Core; using Tango.Core.Commands; using Tango.Integration.Operation; using Tango.PMR; @@ -37,7 +36,6 @@ namespace Tango.Stubs.ViewModels private StubManager _stubManager; private TextBox _logTextBox; private StubsSettings _settings; - private Core.Threading.IntervalMessageDispatcher<String> _consoleDispatcher; #region Properties @@ -269,9 +267,6 @@ namespace Tango.Stubs.ViewModels /// </summary> public StubsViewVM() { - _consoleDispatcher = new Core.Threading.IntervalMessageDispatcher<string>(OnConsoleLog); - _consoleDispatcher.Start(); - DisplayConnectionPane = true; _settings = SettingsManager.Default.GetOrCreate<StubsSettings>(); @@ -420,18 +415,6 @@ namespace Tango.Stubs.ViewModels Examples = Examples.OrderBy(x => x.Name).ToList(); } - private void OnConsoleLog(String log) - { - InvokeUINow(() => - { - if (_logTextBox.Text.Length > 99999) - { - _logTextBox.Clear(); - } - _logTextBox.AppendText(log); - }); - } - public StubsViewVM(ConnectionMode connectionMode) : this() { ConnectionMode = connectionMode; @@ -632,7 +615,6 @@ namespace Tango.Stubs.ViewModels { Mouse.OverrideCursor = Cursors.Wait; AppendTextLog("Connecting..." + Environment.NewLine); - Integration.Operation.MachineOperator.EnableSessionLogFile = false; _machineOperator = new MachineOperator(); _machineOperator.EnableDiagnostics = false; _machineOperator.EnableEmbeddedDebugging = false; @@ -692,22 +674,20 @@ namespace Tango.Stubs.ViewModels SelectedCodeTab.IsRunning = true; _logTextBox.Text = (DateTime.Now.ToTimeString() + ": ") + "Executing script '" + SelectedCodeTab.Title + "'..." + Environment.NewLine; - Status = "Running..."; - await Task.Factory.StartNew(async () => { try { _stubManager = new StubManager(_machineOperator, (txt) => - { - AppendTextLog(txt + Environment.NewLine); - }, (txt) => - { - AppendTextLog(txt); - }, () => - { - ClearTextLog(); - }); + { + AppendTextLog(txt + Environment.NewLine); + }, (txt) => + { + AppendTextLog(txt); + }, () => + { + + }); var thisStubManager = _stubManager; _stubManager.Completed += Manager_Completed; _stubManager.Failed += Manager_Failed; @@ -719,20 +699,12 @@ namespace Tango.Stubs.ViewModels engine.ReferencedAssemblies.Add(this.GetType()); engine.ReferencedAssemblies.Add(typeof(PMR.Stubs.CalculateRequest)); engine.ReferencedAssemblies.Add(typeof(IMessage)); - - Status = $"Running '{SelectedCodeTab.Title}'..."; - await engine.Run(SelectedCodeTab.Code, Path.GetDirectoryName(SelectedCodeTab.File)); if (!thisStubManager.Aborted) { IsRunning = false; SelectedCodeTab.IsRunning = false; - Status = "Aboted"; - } - else - { - Status = "Completed"; } } catch (Exception ex) @@ -821,6 +793,8 @@ namespace Tango.Stubs.ViewModels { AppendTextLog((DateTime.Now.ToTimeString() + ": ") + "Executing '" + stubName + "'..." + Environment.NewLine); } + + Status = "Executing " + stubName + "..."; } /// <summary> @@ -836,6 +810,8 @@ namespace Tango.Stubs.ViewModels { AppendTextLog((DateTime.Now.ToTimeString() + ": ") + ex.Message + Environment.NewLine); } + + Status = "Failed!"; } } @@ -851,11 +827,21 @@ namespace Tango.Stubs.ViewModels AppendTextLog((DateTime.Now.ToTimeString() + ": ") + "Response Received:" + Environment.NewLine); AppendTextLog((DateTime.Now.ToTimeString() + ": ") + response + Environment.NewLine); } + Status = "Completed"; } private void AppendTextLog(String log) { - _consoleDispatcher.Push(log); + LogManager.Log(log); + + InvokeUI(() => + { + if (_logTextBox.Text.Length > 99999) + { + _logTextBox.Clear(); + } + _logTextBox.AppendText(log); + }); } private void ClearTextLog() |
