aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio
diff options
context:
space:
mode:
authorAvi Levkovich <avi@twine-s.com>2018-04-16 09:27:48 +0300
committerAvi Levkovich <avi@twine-s.com>2018-04-16 09:27:48 +0300
commiteafb576fe1bf76898b9cc17671a89d1585e2c8e4 (patch)
treed833a983eb84c53b35b19a45af475aa3e88953c0 /Software/Visual_Studio/MachineStudio
parentcf441513c1010eb4363e985b3b7af61a8503456e (diff)
parent53f93d7fd2d2aa4571bad6e93e0c519fce242753 (diff)
downloadTango-eafb576fe1bf76898b9cc17671a89d1585e2c8e4.tar.gz
Tango-eafb576fe1bf76898b9cc17671a89d1585e2c8e4.zip
Merge branch 'master' of https://twinetfs.visualstudio.com/_git/Tango
Diffstat (limited to 'Software/Visual_Studio/MachineStudio')
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/ViewModels/MainViewVM.cs4
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj10
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs40
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml3
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/bip.wavbin161420 -> 0 bytes
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/error.wavbin146748 -> 0 bytes
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Converters/StringToFirstLineConverter.cs23
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Images/application-logs.pngbin0 -> 16421 bytes
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Images/embedded-logs.pngbin0 -> 19230 bytes
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Images/events.pngbin0 -> 32989 bytes
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Navigation/LoggingNavigationView.cs3
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Parsing/ApplicationLogFileParser.cs64
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Parsing/EmbeddedLogFileParser.cs70
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Parsing/ILogFileParser.cs15
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Parsing/LogFile.cs15
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Tango.MachineStudio.Logging.csproj32
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModelLocator.cs24
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/ApplicationLogsViewVM.cs99
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/EventsViewVM.cs (renamed from Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/MainViewVM.cs)7
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/HomeViewVM.cs28
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Views/ApplicationLogsView.xaml196
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Views/ApplicationLogsView.xaml.cs28
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Views/EventsView.xaml9
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Views/HomeView.xaml87
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Views/HomeView.xaml.cs28
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Views/MainView.xaml8
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Views/TimelineView.xaml3
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Views/TimelineWrapperView.xaml2
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs392
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/HiveColorPickerControl.xaml.cs5
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/EventLogging/DefaultEventLogger.cs17
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.xaml.cs6
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Html/HtmlWindow.xaml2
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Modules/DefaultStudioModuleLoader.cs7
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DefaultNotificationProvider.cs21
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj8
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModelLocator.cs9
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/ConnectedMachineViewVM.cs36
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs127
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/ConnectedMachineView.xaml111
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/ConnectedMachineView.xaml.cs28
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MachineConnectionView.xaml2
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml.cs5
43 files changed, 1320 insertions, 254 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/ViewModels/MainViewVM.cs
index af65c1430..40a407093 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/ViewModels/MainViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DataCapture/ViewModels/MainViewVM.cs
@@ -372,7 +372,7 @@ namespace Tango.MachineStudio.DataCapture.ViewModels
}
}
- private void StartDiagnosticsRecording()
+ public void StartDiagnosticsRecording()
{
using (_notification.PushTaskItem("Starting Recording..."))
{
@@ -384,7 +384,7 @@ namespace Tango.MachineStudio.DataCapture.ViewModels
InvalidateRelayCommands();
}
- private async void StopRecorderOrPlayer()
+ public async void StopRecorderOrPlayer()
{
if (Recorder.IsRecording)
{
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj
index c165552d1..ed55edbe6 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj
@@ -267,6 +267,10 @@
<Project>{cb0b0aa2-bb24-4bca-a720-45e397684e12}</Project>
<Name>Tango.MachineStudio.Common</Name>
</ProjectReference>
+ <ProjectReference Include="..\Tango.MachineStudio.DataCapture\Tango.MachineStudio.DataCapture.csproj">
+ <Project>{fc337a7f-1214-41d8-9992-78092a3b961e}</Project>
+ <Name>Tango.MachineStudio.DataCapture</Name>
+ </ProjectReference>
<ProjectReference Include="..\Tango.MachineStudio.DB\Tango.MachineStudio.DB.csproj">
<Project>{94f7acf8-55e1-4a02-b9bc-a818413fdbbf}</Project>
<Name>Tango.MachineStudio.DB</Name>
@@ -351,13 +355,7 @@
<Resource Include="Images\job-emb.png" />
</ItemGroup>
<ItemGroup>
- <EmbeddedResource Include="bip.wav" />
- </ItemGroup>
- <ItemGroup>
<Resource Include="Images\seamless-grid.jpg" />
</ItemGroup>
- <ItemGroup>
- <EmbeddedResource Include="error.wav" />
- </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project> \ No newline at end of file
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs
index cdfeee54d..036b01e34 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs
@@ -35,6 +35,7 @@ using System.Speech.Synthesis;
using System.Media;
using Tango.MachineStudio.Common.EventLogging;
using Tango.MachineStudio.Common.Speech;
+using Microsoft.Practices.ServiceLocation;
namespace Tango.MachineStudio.Developer.ViewModels
{
@@ -58,6 +59,8 @@ namespace Tango.MachineStudio.Developer.ViewModels
private ObservablesContext _activeJobDbContext;
private IEventLogger _eventLogger;
private ISpeechProvider _speech;
+ private DataCapture.ViewModels.MainViewVM _dataCaptureVM;
+ private bool _isRecording;
#region Properties
@@ -556,6 +559,11 @@ namespace Tango.MachineStudio.Developer.ViewModels
public RelayCommand StartJobCommand { get; set; }
/// <summary>
+ /// Gets or sets the start job and record command.
+ /// </summary>
+ public RelayCommand StartJobAndRecordCommand { get; set; }
+
+ /// <summary>
/// Gets or sets the stop job command.
/// </summary>
public RelayCommand StopJobCommand { get; set; }
@@ -642,6 +650,9 @@ namespace Tango.MachineStudio.Developer.ViewModels
LogManager.Log("Initializing relay commands...");
+ _dataCaptureVM = ServiceLocator.Current.GetInstance<DataCapture.ViewModels.MainViewVM>();
+ _dataCaptureVM.RelayCommandsInvalidated += (_, __) => StartJobAndRecordCommand.RaiseCanExecuteChanged();
+
//Initialize Commands...
EditMachineCommand = new RelayCommand(EditMachine, () => SelectedMachine != null);
EditRMLCommand = new RelayCommand(EditRML, () => SelectedRML != null);
@@ -656,6 +667,7 @@ namespace Tango.MachineStudio.Developer.ViewModels
SaveJobCommand = new RelayCommand(SaveActiveJob, () => SelectedMachine != null);
DiscardJobCommand = new RelayCommand(BackToJobs, () => SelectedMachine != null);
StartJobCommand = new RelayCommand(StartJob, () => ActiveJob != null && !IsJobRunning && MachineOperator != null && !MachineOperator.MachineEventsStateProvider.Events.ToList().Exists(x => x.ActionTypes.Contains(BL.Enumerations.ActionTypes.PreventJobExecution)));
+ StartJobAndRecordCommand = new RelayCommand(StartJobAndRecord, () => !_dataCaptureVM.Recorder.IsRecording && !_dataCaptureVM.Player.IsPlaying && ActiveJob != null && !IsJobRunning && MachineOperator != null && !MachineOperator.MachineEventsStateProvider.Events.ToList().Exists(x => x.ActionTypes.Contains(BL.Enumerations.ActionTypes.PreventJobExecution)));
StopJobCommand = new RelayCommand(StopJob, () => IsJobRunning);
CloseJobCompletionStatusCommand = new RelayCommand(CloseJobCompletionStatusBar);
LoadJobCommand = new RelayCommand(LoadSelectedJob, () => SelectedMachineJob != null);
@@ -1053,7 +1065,7 @@ namespace Tango.MachineStudio.Developer.ViewModels
if (segment.ID != -1)
{
_speech.SpeakInfo(String.Format("Segment {0} Started.", segment.SegmentIndex));
- _eventLogger.Log(String.Format("Segment {0} Started.", segment.SegmentIndex));
+ _eventLogger.Log(String.Format("Segment {0} Started.", segment.SegmentIndex) + Environment.NewLine + segment.ToJsonString());
}
else
{
@@ -1081,6 +1093,7 @@ namespace Tango.MachineStudio.Developer.ViewModels
InvokeUI(() =>
{
_notification.ShowError("Job failed. " + ex.Message);
+ StopRecordingIfInProgress();
});
};
@@ -1089,12 +1102,14 @@ namespace Tango.MachineStudio.Developer.ViewModels
LogManager.Log(String.Format("Job {0} has completed.", RunningJob.Name));
_eventLogger.Log(String.Format("Job {0} has completed.", RunningJob.Name));
SetJobCompleted();
+ StopRecordingIfInProgress();
};
_jobHandler.Canceled += (x, y) =>
{
LogManager.Log(String.Format("Job {0} has been canceled.", RunningJob.Name));
_eventLogger.Log(String.Format("Job {0} has been canceled.", RunningJob.Name));
+ StopRecordingIfInProgress();
//Finally Canceled..
};
}
@@ -1104,6 +1119,29 @@ namespace Tango.MachineStudio.Developer.ViewModels
_eventLogger.Log(ex, "An error occurred while starting the job.");
_notification.ShowError("An error occurred while starting the job. " + Environment.NewLine + ex.Message);
SetJobFailed();
+ StopRecordingIfInProgress();
+ }
+ }
+
+ /// <summary>
+ /// Starts the job and record using the data capture module.
+ /// </summary>
+ private void StartJobAndRecord()
+ {
+ _isRecording = true;
+ _dataCaptureVM.StartDiagnosticsRecording();
+ StartJob();
+ }
+
+ /// <summary>
+ /// Stops the recording if in progress.
+ /// </summary>
+ private void StopRecordingIfInProgress()
+ {
+ if (_isRecording)
+ {
+ _isRecording = false;
+ InvokeUI(() => _dataCaptureVM.StopRecorderOrPlayer());
}
}
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml
index 4c0784d1d..c575ef2a3 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml
@@ -1066,6 +1066,9 @@
<TextBlock VerticalAlignment="Center" Margin="10 0 0 0" FontSize="18">START JOB</TextBlock>
</StackPanel>
</Button>
+ <Button Height="60" Width="60" Margin="-60 0 0 0" Padding="0" Command="{Binding StartJobAndRecordCommand}" Click="OnJobStartClick" ToolTip="Start Job and Record">
+ <materialDesign:PackIcon VerticalAlignment="Center" Width="38" Height="38" Kind="Record" Foreground="#FF6D6D" />
+ </Button>
</StackPanel>
</Grid>
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/bip.wav b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/bip.wav
deleted file mode 100644
index 5a1d74045..000000000
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/bip.wav
+++ /dev/null
Binary files differ
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/error.wav b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/error.wav
deleted file mode 100644
index 4dce7d623..000000000
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/error.wav
+++ /dev/null
Binary files differ
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Converters/StringToFirstLineConverter.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Converters/StringToFirstLineConverter.cs
new file mode 100644
index 000000000..2fa456054
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Converters/StringToFirstLineConverter.cs
@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Data;
+
+namespace Tango.MachineStudio.Logging.Converters
+{
+ public class StringToFirstLineConverter : IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ return value.ToString().ToLines().First();
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Images/application-logs.png b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Images/application-logs.png
new file mode 100644
index 000000000..584379dc8
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Images/application-logs.png
Binary files differ
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Images/embedded-logs.png b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Images/embedded-logs.png
new file mode 100644
index 000000000..86cd56486
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Images/embedded-logs.png
Binary files differ
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Images/events.png b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Images/events.png
new file mode 100644
index 000000000..437679cd6
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Images/events.png
Binary files differ
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Navigation/LoggingNavigationView.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Navigation/LoggingNavigationView.cs
index 6f4fcbceb..e8a14cc3d 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Navigation/LoggingNavigationView.cs
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Navigation/LoggingNavigationView.cs
@@ -8,7 +8,10 @@ namespace Tango.MachineStudio.Logging.Navigation
{
public enum LoggingNavigationView
{
+ HomeView,
EventsView,
TimelineView,
+ ApplicationLogsView,
+ EmbeddedLogsView,
}
}
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Parsing/ApplicationLogFileParser.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Parsing/ApplicationLogFileParser.cs
new file mode 100644
index 000000000..d082aeca6
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Parsing/ApplicationLogFileParser.cs
@@ -0,0 +1,64 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Text.RegularExpressions;
+using System.Threading.Tasks;
+using Tango.Logging;
+
+namespace Tango.MachineStudio.Logging.Parsing
+{
+ public class ApplicationLogFileParser : ILogFileParser<MessageLogItem>
+ {
+ public List<LogFile> GetLogFiles()
+ {
+ List<LogFile> logFiles = new List<LogFile>();
+
+ foreach (var file in Directory.GetFiles(FileLogger.DefaultLogsFolder, "*.log").Where(x => Path.GetFileName(x).StartsWith("Tango.MachineStudio.UI")))
+ {
+ String dateString = Path.GetFileNameWithoutExtension(file).Replace("Tango.MachineStudio.UI-", "");
+ DateTime date = DateTime.ParseExact(dateString, "dd-MM-yyyy_HH-mm-ss", CultureInfo.InvariantCulture);
+ logFiles.Add(new LogFile() { DateTime = date, File = file });
+ }
+
+ return logFiles;
+ }
+
+ public List<MessageLogItem> Parse(LogFile logFile)
+ {
+ List<MessageLogItem> logItems = new List<MessageLogItem>();
+
+ String text = File.ReadAllText(logFile.File);
+ var logs = Regex.Split(text, @"(\[\d{2}:\d{2}:\d{2}.\d{2}\])");
+
+ for (int i = 1; i < logs.Length; i += 2)
+ {
+ try
+ {
+ DateTime date = DateTime.ParseExact(logs[i].Replace("[", "").Replace("]", ""), "HH:mm:ss.ff", CultureInfo.InvariantCulture);
+ String rest = logs[i + 1];
+
+ var entries = Regex.Split(rest, @"\[(.*?)\]");
+
+ MessageLogItem item = new MessageLogItem();
+ item.TimeStamp = new DateTime(logFile.DateTime.Year, logFile.DateTime.Month, logFile.DateTime.Day, date.Hour, date.Minute, date.Second, date.Millisecond);
+ item.Category = (LogCategory)Enum.Parse(typeof(LogCategory), entries[1]);
+ item.CallerFile = entries[3];
+ item.CallerMethodName = entries[5];
+ item.CallerLineNumber = int.Parse(entries[7]);
+ item.Message = new String(entries[8].Skip(2).ToArray());
+
+ logItems.Add(item);
+ }
+ catch (Exception ex)
+ {
+ //TODO: What to do now ?
+ }
+ }
+
+ return logItems;
+ }
+ }
+}
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Parsing/EmbeddedLogFileParser.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Parsing/EmbeddedLogFileParser.cs
new file mode 100644
index 000000000..76ca0d162
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Parsing/EmbeddedLogFileParser.cs
@@ -0,0 +1,70 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Text.RegularExpressions;
+using System.Threading.Tasks;
+using Tango.Integration.Operation;
+using Tango.Logging;
+using Tango.Settings;
+
+namespace Tango.MachineStudio.Logging.Parsing
+{
+ public class EmbeddedLogFileParser : ILogFileParser<EmbeddedLogItem>
+ {
+ public List<LogFile> GetLogFiles()
+ {
+ List<LogFile> logFiles = new List<LogFile>();
+
+ foreach (var file in Directory.GetFiles(SettingsManager.DefaultFolder + "\\embedded logs", "*.log").Where(x => Path.GetFileName(x).StartsWith("embedded")))
+ {
+ String dateString = Path.GetFileNameWithoutExtension(file).Replace("embedded-", "");
+ DateTime date = DateTime.ParseExact(dateString, "dd-MM-yyyy_HH-mm-ss", CultureInfo.InvariantCulture);
+ logFiles.Add(new LogFile() { DateTime = date, File = file });
+ }
+
+ return logFiles;
+ }
+
+ public List<EmbeddedLogItem> Parse(LogFile logFile)
+ {
+ List<EmbeddedLogItem> logItems = new List<EmbeddedLogItem>();
+
+ String text = File.ReadAllText(logFile.File);
+ var logs = Regex.Split(text, @"(\[\d{2}:\d{2}:\d{2}.\d{2}\])");
+
+ for (int i = 1; i < logs.Length; i += 2)
+ {
+ try
+ {
+ DateTime date = DateTime.ParseExact(logs[i].Replace("[", "").Replace("]", ""), "HH:mm:ss.ff", CultureInfo.InvariantCulture);
+ String rest = logs[i + 1];
+
+ var entries = Regex.Split(rest, @"\[(.*?)\]");
+
+ EmbeddedLogItem item = new EmbeddedLogItem(new PMR.Debugging.DebugLogResponse()
+ {
+ Category = (PMR.Debugging.DebugLogCategory)Enum.Parse(typeof(PMR.Debugging.DebugLogCategory), entries[1]),
+ FileName = entries[3],
+ LineNumber = uint.Parse(entries[5]),
+ ModuleId = uint.Parse(entries[7]),
+ Filter = uint.Parse(entries[9]),
+ Message = new String(entries[10].Skip(2).ToArray())
+ });
+
+ item.TimeStamp = new DateTime(logFile.DateTime.Year, logFile.DateTime.Month, logFile.DateTime.Day, date.Hour, date.Minute, date.Second, date.Millisecond);
+
+ logItems.Add(item);
+ }
+ catch (Exception ex)
+ {
+ //TODO: What to do now ?
+ }
+ }
+
+ return logItems;
+ }
+ }
+}
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Parsing/ILogFileParser.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Parsing/ILogFileParser.cs
new file mode 100644
index 000000000..05003c1a2
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Parsing/ILogFileParser.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tango.MachineStudio.Logging.Parsing
+{
+ public interface ILogFileParser<T>
+ {
+ List<T> Parse(LogFile logFile);
+
+ List<LogFile> GetLogFiles();
+ }
+}
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Parsing/LogFile.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Parsing/LogFile.cs
new file mode 100644
index 000000000..4248bdbdc
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Parsing/LogFile.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tango.MachineStudio.Logging.Parsing
+{
+ public class LogFile
+ {
+ public DateTime DateTime { get; set; }
+
+ public String File { get; set; }
+ }
+}
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Tango.MachineStudio.Logging.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Tango.MachineStudio.Logging.csproj
index 4b817a124..42229544a 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Tango.MachineStudio.Logging.csproj
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Tango.MachineStudio.Logging.csproj
@@ -87,22 +87,35 @@
<Compile Include="Converters\EventsToTimeRulerTicksConverter.cs" />
<Compile Include="Converters\MachineEventToXConverter.cs" />
<Compile Include="Converters\SecondsToWidthConverter.cs" />
+ <Compile Include="Converters\StringToFirstLineConverter.cs" />
<Compile Include="Converters\TimeSpanToXConverter.cs" />
<Compile Include="Helpers\TimelineHelper.cs" />
<Compile Include="LoggingModule.cs" />
<Compile Include="Navigation\LoggingNavigationManager.cs" />
<Compile Include="Navigation\LoggingNavigationView.cs" />
+ <Compile Include="Parsing\ApplicationLogFileParser.cs" />
+ <Compile Include="Parsing\EmbeddedLogFileParser.cs" />
+ <Compile Include="Parsing\ILogFileParser.cs" />
+ <Compile Include="Parsing\LogFile.cs" />
<Compile Include="ViewModelLocator.cs" />
+ <Compile Include="ViewModels\ApplicationLogsViewVM.cs" />
<Compile Include="ViewModels\EventDetailsViewVM.cs" />
- <Compile Include="ViewModels\MainViewVM.cs" />
+ <Compile Include="ViewModels\HomeViewVM.cs" />
+ <Compile Include="ViewModels\EventsViewVM.cs" />
<Compile Include="ViewModels\TimelineEventGroup.cs" />
<Compile Include="ViewModels\TimelineViewVM.cs" />
<Compile Include="Views\EventDetailsView.xaml.cs">
<DependentUpon>EventDetailsView.xaml</DependentUpon>
</Compile>
+ <Compile Include="Views\ApplicationLogsView.xaml.cs">
+ <DependentUpon>ApplicationLogsView.xaml</DependentUpon>
+ </Compile>
<Compile Include="Views\EventsView.xaml.cs">
<DependentUpon>EventsView.xaml</DependentUpon>
</Compile>
+ <Compile Include="Views\HomeView.xaml.cs">
+ <DependentUpon>HomeView.xaml</DependentUpon>
+ </Compile>
<Compile Include="Views\MainView.xaml.cs">
<DependentUpon>MainView.xaml</DependentUpon>
</Compile>
@@ -188,10 +201,18 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
+ <Page Include="Views\ApplicationLogsView.xaml">
+ <Generator>MSBuild:Compile</Generator>
+ <SubType>Designer</SubType>
+ </Page>
<Page Include="Views\EventsView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
+ <Page Include="Views\HomeView.xaml">
+ <SubType>Designer</SubType>
+ <Generator>MSBuild:Compile</Generator>
+ </Page>
<Page Include="Views\MainView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@@ -208,5 +229,14 @@
<ItemGroup>
<Resource Include="Images\machine-trans.png" />
</ItemGroup>
+ <ItemGroup>
+ <Resource Include="Images\application-logs.png" />
+ </ItemGroup>
+ <ItemGroup>
+ <Resource Include="Images\embedded-logs.png" />
+ </ItemGroup>
+ <ItemGroup>
+ <Resource Include="Images\events.png" />
+ </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project> \ No newline at end of file
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModelLocator.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModelLocator.cs
index ef6923e27..0b1af937f 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModelLocator.cs
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModelLocator.cs
@@ -18,17 +18,35 @@ namespace Tango.MachineStudio.Logging
static ViewModelLocator()
{
ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default);
- SimpleIoc.Default.Register<MainViewVM>();
+ SimpleIoc.Default.Register<EventsViewVM>();
+ SimpleIoc.Default.Register<ApplicationLogsViewVM>();
+ SimpleIoc.Default.Register<HomeViewVM>();
SimpleIoc.Default.Unregister<LoggingNavigationManager>();
SimpleIoc.Default.Register<LoggingNavigationManager>(() => new LoggingNavigationManager());
}
- public static MainViewVM MainViewVM
+ public static EventsViewVM EventsViewVM
{
get
{
- return ServiceLocator.Current.GetInstance<MainViewVM>();
+ return ServiceLocator.Current.GetInstance<EventsViewVM>();
+ }
+ }
+
+ public static ApplicationLogsViewVM ApplicationLogsViewVM
+ {
+ get
+ {
+ return ServiceLocator.Current.GetInstance<ApplicationLogsViewVM>();
+ }
+ }
+
+ public static HomeViewVM HomeViewVM
+ {
+ get
+ {
+ return ServiceLocator.Current.GetInstance<HomeViewVM>();
}
}
}
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/ApplicationLogsViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/ApplicationLogsViewVM.cs
new file mode 100644
index 000000000..8ddc544c0
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/ApplicationLogsViewVM.cs
@@ -0,0 +1,99 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tango.Core.Commands;
+using Tango.Logging;
+using Tango.MachineStudio.Logging.Navigation;
+using Tango.MachineStudio.Logging.Parsing;
+using Tango.SharedUI;
+
+namespace Tango.MachineStudio.Logging.ViewModels
+{
+ public class ApplicationLogsViewVM : ViewModel
+ {
+ private ApplicationLogFileParser _parser;
+ private List<LogFile> _logFiles;
+
+ private ObservableCollection<MessageLogItem> _logs;
+ public ObservableCollection<MessageLogItem> Logs
+ {
+ get { return _logs; }
+ set { _logs = value; RaisePropertyChangedAuto(); }
+ }
+
+ private ObservableCollection<DateTime> _dates;
+ public ObservableCollection<DateTime> Dates
+ {
+ get { return _dates; }
+ set { _dates = value; RaisePropertyChangedAuto(); }
+ }
+
+ private DateTime _selectedDate;
+ public DateTime SelectedDate
+ {
+ get { return _selectedDate; }
+ set { _selectedDate = value; RaisePropertyChangedAuto(); OnSelectedDateChanged(); }
+ }
+
+ private DateTime _minDate;
+ public DateTime MinDate
+ {
+ get { return _minDate; }
+ set { _minDate = value; RaisePropertyChangedAuto(); }
+ }
+
+ private DateTime _maxDate;
+ public DateTime MaxDate
+ {
+ get { return _maxDate; }
+ set { _maxDate = value; RaisePropertyChangedAuto(); }
+ }
+
+
+ private bool _isRealTime;
+ public bool IsRealTime
+ {
+ get { return _isRealTime; }
+ set { _isRealTime = value; RaisePropertyChangedAuto(); OnSelectedDateChanged(); }
+ }
+
+ public RelayCommand NavigateToHomeCommand { get; set; }
+
+ public ApplicationLogsViewVM(LoggingNavigationManager navigation)
+ {
+ NavigateToHomeCommand = new RelayCommand(() => navigation.NavigateTo(LoggingNavigationView.HomeView));
+
+ _parser = new ApplicationLogFileParser();
+
+ _logFiles = _parser.GetLogFiles();
+ Dates = new ObservableCollection<DateTime>(_logFiles.Select(x => x.DateTime).OrderBy(x => x));
+
+ SelectedDate = Dates.Last();
+
+ MinDate = Dates.Min();
+ MaxDate = Dates.Max();
+ }
+
+ private void OnSelectedDateChanged()
+ {
+ if (IsRealTime)
+ {
+ //Events = _realTimeEvents;
+ }
+ else
+ {
+ List<MessageLogItem> logs = new List<MessageLogItem>();
+
+ foreach (var logFile in _logFiles.Where(x => x.DateTime.Date == SelectedDate.Date))
+ {
+ logs.AddRange(_parser.Parse(logFile));
+ }
+
+ Logs = logs.ToObservableCollection();
+ }
+ }
+ }
+}
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/EventsViewVM.cs
index e5121e709..361adef01 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/MainViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/EventsViewVM.cs
@@ -18,7 +18,7 @@ using Tango.SharedUI;
namespace Tango.MachineStudio.Logging.ViewModels
{
- public class MainViewVM : ViewModel
+ public class EventsViewVM : ViewModel
{
private INotificationProvider _notification;
private IStudioApplicationManager _application;
@@ -96,7 +96,9 @@ namespace Tango.MachineStudio.Logging.ViewModels
public RelayCommand NavigateToEventsCommand { get; set; }
- public MainViewVM(INotificationProvider notification, IEventLogger eventLogger, IStudioApplicationManager application, LoggingNavigationManager navigation)
+ public RelayCommand NavigateToHomeCommand { get; set; }
+
+ public EventsViewVM(INotificationProvider notification, IEventLogger eventLogger, IStudioApplicationManager application, LoggingNavigationManager navigation)
{
TimelineViewVM = new TimelineViewVM(notification);
@@ -110,6 +112,7 @@ namespace Tango.MachineStudio.Logging.ViewModels
RegisterMessage<MachineConnectionChangedMessage>(OnMachineConnectionChanged);
DisplayTimelineCommand = new RelayCommand<MachinesEvent>(DisplayTimeline);
NavigateToEventsCommand = new RelayCommand(() => _navigation.NavigateTo(LoggingNavigationView.EventsView));
+ NavigateToHomeCommand = new RelayCommand(() => _navigation.NavigateTo(LoggingNavigationView.HomeView));
}
private void OnMachineConnectionChanged(MachineConnectionChangedMessage msg)
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/HomeViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/HomeViewVM.cs
new file mode 100644
index 000000000..b87323491
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/HomeViewVM.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tango.Core.Commands;
+using Tango.MachineStudio.Logging.Navigation;
+using Tango.SharedUI;
+
+namespace Tango.MachineStudio.Logging.ViewModels
+{
+ public class HomeViewVM : ViewModel
+ {
+ private LoggingNavigationManager _navigation;
+
+ public RelayCommand<String> NavigateToCommand { get; set; }
+
+ public HomeViewVM(LoggingNavigationManager navigation)
+ {
+ _navigation = navigation;
+
+ NavigateToCommand = new RelayCommand<string>((view) =>
+ {
+ navigation.NavigateTo((LoggingNavigationView)Enum.Parse(typeof(LoggingNavigationView), view));
+ });
+ }
+ }
+}
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Views/ApplicationLogsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Views/ApplicationLogsView.xaml
new file mode 100644
index 000000000..1274f6523
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Views/ApplicationLogsView.xaml
@@ -0,0 +1,196 @@
+<UserControl x:Class="Tango.MachineStudio.Logging.Views.ApplicationLogsView"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:autoComplete="clr-namespace:Tango.AutoComplete.Editors;assembly=Tango.AutoComplete"
+ xmlns:autoCompleteMachine="clr-namespace:Tango.MachineStudio.Common.AutoComplete;assembly=Tango.MachineStudio.Common"
+ xmlns:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI"
+ xmlns:global="clr-namespace:Tango.MachineStudio.Logging"
+ xmlns:localConverters="clr-namespace:Tango.MachineStudio.Logging.Converters"
+ xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
+ xmlns:vm="clr-namespace:Tango.MachineStudio.Logging.ViewModels"
+ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+ xmlns:local="clr-namespace:Tango.MachineStudio.Logging.Views"
+ mc:Ignorable="d"
+ d:DesignHeight="1080" d:DesignWidth="1920" d:DataContext="{d:DesignInstance Type=vm:ApplicationLogsViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.ApplicationLogsViewVM}">
+ <UserControl.Resources>
+ <autoCompleteMachine:MachinesProvider x:Key="MachinesProvider" />
+ <converters:DateTimeUTCToShortDateTimeConverter x:Key="DateTimeUTCToShortDateTimeConverter" />
+ <converters:DateTimeUTCToStringConverter x:Key="DateTimeUTCToStringConverter" />
+ <localConverters:DateIsInListToBooleanConverter x:Key="DateIsInListToBooleanConverter" />
+
+ <Style x:Key="CustomCalendarDayButtonStyle" TargetType="{x:Type CalendarDayButton}" BasedOn="{StaticResource MaterialDesignCalendarDayButton}">
+ <Style.Triggers>
+ <DataTrigger Value="True">
+ <DataTrigger.Binding>
+ <MultiBinding Converter="{StaticResource DateIsInListToBooleanConverter}">
+ <Binding />
+ <Binding RelativeSource="{RelativeSource AncestorType=UserControl}" Path="DataContext.Dates" />
+ <Binding RelativeSource="{RelativeSource AncestorType=DatePicker}" Path="IsDropDownOpen" ></Binding>
+ </MultiBinding>
+ </DataTrigger.Binding>
+ <Setter Property="Foreground" Value="{StaticResource AccentColorBrush}" />
+ </DataTrigger>
+ </Style.Triggers>
+ </Style>
+
+ <Style x:Key="HighlightDatePickerStyle" TargetType="{x:Type Calendar}" BasedOn="{StaticResource {x:Type Calendar}}">
+ <Setter Property="CalendarDayButtonStyle" Value="{StaticResource CustomCalendarDayButtonStyle}" />
+ </Style>
+
+ <Style TargetType="DatePickerTextBox" BasedOn="{StaticResource {x:Type DatePickerTextBox}}">
+ <Setter Property="IsReadOnly" Value="True"/>
+ </Style>
+ </UserControl.Resources>
+
+ <Grid>
+ <Grid>
+ <Grid.RowDefinitions>
+ <RowDefinition Height="79"/>
+ <RowDefinition Height="1*"/>
+ </Grid.RowDefinitions>
+
+ <Border Background="#F1F1F1">
+ <Border.Effect>
+ <DropShadowEffect />
+ </Border.Effect>
+ <Grid>
+ <StackPanel Orientation="Horizontal">
+ <Button Margin="10 0 0 0" Height="50" Style="{StaticResource MaterialDesignFlatButton}" Command="{Binding NavigateToHomeCommand}" HorizontalContentAlignment="Left">
+ <StackPanel Orientation="Horizontal" >
+ <materialDesign:PackIcon Kind="KeyboardBackspace" Width="20" Height="20" />
+ <TextBlock Margin="5 0 0 0" FontSize="16">BACK</TextBlock>
+ </StackPanel>
+ </Button>
+ <Border Margin="10" Padding="5" BorderBrush="DimGray" BorderThickness="1">
+ <Border.Background>
+ <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
+ <GradientStop Color="White"/>
+ <GradientStop Color="#FFEAEAEA" Offset="1"/>
+ </LinearGradientBrush>
+ </Border.Background>
+ <StackPanel Orientation="Horizontal">
+ <materialDesign:PackIcon Kind="Calendar" Width="24" Height="24" VerticalAlignment="Bottom" Margin="0 0 0 5" />
+ <DatePicker x:Name="datePicker" DisplayDateStart="{Binding MinDate}" DisplayDateEnd="{Binding MaxDate}" CalendarStyle="{StaticResource HighlightDatePickerStyle}" SelectedDate="{Binding SelectedDate}" materialDesign:HintAssist.Hint="Pick Date" Margin="10 0 0 5" Width="200" VerticalAlignment="Bottom" FontSize="16">
+ </DatePicker>
+ <ToggleButton VerticalAlignment="Bottom" Margin="20 0 0 5" IsChecked="{Binding IsRealTime}"></ToggleButton>
+ <TextBlock VerticalAlignment="Center" Margin="10 17 0 0">Real-Time</TextBlock>
+ </StackPanel>
+ </Border>
+ </StackPanel>
+ </Grid>
+ </Border>
+
+ <Grid Grid.Row="1" Background="#B3FFFFFF">
+ <Grid Margin="10">
+ <Grid.ColumnDefinitions>
+
+ <ColumnDefinition Width="1*"/>
+ </Grid.ColumnDefinitions>
+
+ <Grid>
+ <Grid>
+ <Grid>
+ <DataGrid Background="Transparent" AutoGenerateColumns="False" SelectionMode="Single" ItemsSource="{Binding Logs}" SelectedItem="{Binding SelectedEvent}" RowHeight="40" CanUserAddRows="False" CanUserDeleteRows="False" CanUserReorderColumns="True" IsReadOnly="True">
+ <DataGrid.RowStyle>
+ <Style TargetType="DataGridRow" BasedOn="{StaticResource {x:Type DataGridRow}}">
+ <Style.Triggers>
+ <Trigger Property="IsMouseOver" Value="True">
+ <Setter Property="Background" Value="Transparent"></Setter>
+ <Setter Property="Foreground" Value="{StaticResource AccentColorBrush}" />
+ <Setter Property="Cursor" Value="Hand"></Setter>
+ </Trigger>
+ <Trigger Property="IsSelected" Value="True">
+ <Setter Property="Background" Value="Transparent"></Setter>
+ </Trigger>
+ <Trigger Property="IsFocused" Value="True">
+ <Setter Property="Background" Value="Transparent"></Setter>
+ </Trigger>
+ <DataTrigger Binding="{Binding CallerMethodName}" Value="OnStartup">
+ <Setter Property="Background" Value="{StaticResource AccentColorBrush}"></Setter>
+ <Setter Property="Foreground" Value="White" />
+ <Setter Property="FontWeight" Value="SemiBold"></Setter>
+ <Setter Property="Cursor" Value="Arrow"></Setter>
+ </DataTrigger>
+ </Style.Triggers>
+ </Style>
+ </DataGrid.RowStyle>
+ <DataGrid.CellStyle>
+ <Style TargetType="DataGridCell" BasedOn="{StaticResource {x:Type DataGridCell}}">
+ <Setter Property="BorderThickness" Value="0"/>
+ <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
+ <Setter Property="VerticalContentAlignment" Value="Center"></Setter>
+ <Style.Triggers>
+ <Trigger Property="IsSelected" Value="True">
+ <Setter Property="Background" Value="Transparent"></Setter>
+ </Trigger>
+ <DataTrigger Binding="{Binding CallerMethodName}" Value="OnStartup">
+ <Setter Property="Background" Value="{StaticResource AccentColorBrush}"></Setter>
+ <Setter Property="Foreground" Value="White" />
+ <Setter Property="FontWeight" Value="SemiBold"></Setter>
+ <Setter Property="Cursor" Value="Arrow"></Setter>
+ </DataTrigger>
+ </Style.Triggers>
+ </Style>
+ </DataGrid.CellStyle>
+ <DataGrid.Columns>
+ <DataGridTemplateColumn Header="#">
+ <DataGridTemplateColumn.CellTemplate>
+ <DataTemplate>
+ <materialDesign:PackIcon Width="16" Height="16">
+ <materialDesign:PackIcon.Style>
+ <Style TargetType="materialDesign:PackIcon">
+ <Setter Property="Kind" Value="Alert"></Setter>
+ <Style.Triggers>
+ <DataTrigger Binding="{Binding Category}" Value="Info">
+ <Setter Property="Kind" Value="Information"></Setter>
+ <Setter Property="Foreground" Value="DimGray"></Setter>
+ </DataTrigger>
+ <DataTrigger Binding="{Binding Category}" Value="Warning">
+ <Setter Property="Kind" Value="Alert"></Setter>
+ <Setter Property="Foreground" Value="#FFA300"></Setter>
+ </DataTrigger>
+ <DataTrigger Binding="{Binding Category}" Value="Error">
+ <Setter Property="Kind" Value="AlertOctagon"></Setter>
+ <Setter Property="Foreground" Value="#FF5C5C"></Setter>
+ </DataTrigger>
+ <DataTrigger Binding="{Binding Category}" Value="Critical">
+ <Setter Property="Kind" Value="BellPlus"></Setter>
+ <Setter Property="Foreground" Value="Red"></Setter>
+ </DataTrigger>
+ <DataTrigger Binding="{Binding Category}" Value="Debug">
+ <Setter Property="Kind" Value="Bug"></Setter>
+ <Setter Property="Foreground" Value="#303030"></Setter>
+ </DataTrigger>
+ <DataTrigger Binding="{Binding CallerMethodName}" Value="OnStartup">
+ <Setter Property="Kind" Value="ClockFast"></Setter>
+ <Setter Property="Foreground" Value="White"></Setter>
+ </DataTrigger>
+ </Style.Triggers>
+ </Style>
+ </materialDesign:PackIcon.Style>
+ </materialDesign:PackIcon>
+ </DataTemplate>
+ </DataGridTemplateColumn.CellTemplate>
+ </DataGridTemplateColumn>
+ <DataGridTextColumn Header="DATE TIME" Binding="{Binding TimeStamp,Converter={StaticResource DateTimeUTCToStringConverter},ConverterParameter='MM/dd/yyyy HH:mm:ss.ff'}" />
+ <DataGridTextColumn Header="FILE" Binding="{Binding CallerFile}" />
+ <DataGridTextColumn Header="METHOD" Binding="{Binding CallerMethodName}" />
+ <DataGridTextColumn Header="LINE" Binding="{Binding CallerLineNumber}" />
+ <DataGridTemplateColumn Header="MESSAGE" Width="1*">
+ <DataGridTemplateColumn.CellTemplate>
+ <DataTemplate>
+ <TextBlock Text="{Binding Message}" TextTrimming="CharacterEllipsis"></TextBlock>
+ </DataTemplate>
+ </DataGridTemplateColumn.CellTemplate>
+ </DataGridTemplateColumn>
+ </DataGrid.Columns>
+ </DataGrid>
+ </Grid>
+ </Grid>
+ </Grid>
+ </Grid>
+ </Grid>
+ </Grid>
+ </Grid>
+</UserControl>
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Views/ApplicationLogsView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Views/ApplicationLogsView.xaml.cs
new file mode 100644
index 000000000..6cdf6ea53
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Views/ApplicationLogsView.xaml.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace Tango.MachineStudio.Logging.Views
+{
+ /// <summary>
+ /// Interaction logic for EventsView.xaml
+ /// </summary>
+ public partial class ApplicationLogsView : UserControl
+ {
+ public ApplicationLogsView()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Views/EventsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Views/EventsView.xaml
index d92e56ddc..3089ad610 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Views/EventsView.xaml
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Views/EventsView.xaml
@@ -12,7 +12,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Tango.MachineStudio.Logging.Views"
mc:Ignorable="d"
- d:DesignHeight="1080" d:DesignWidth="1920" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}">
+ d:DesignHeight="1080" d:DesignWidth="1920" d:DataContext="{d:DesignInstance Type=vm:EventsViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.EventsViewVM}">
<UserControl.Resources>
<autoCompleteMachine:MachinesProvider x:Key="MachinesProvider" />
<converters:DateTimeUTCToShortDateTimeConverter x:Key="DateTimeUTCToShortDateTimeConverter" />
@@ -56,6 +56,13 @@
</Border.Effect>
<Grid>
<StackPanel Orientation="Horizontal">
+ <Button Margin="10 0 0 0" Height="50" Style="{StaticResource MaterialDesignFlatButton}" Command="{Binding NavigateToHomeCommand}" HorizontalContentAlignment="Left">
+ <StackPanel Orientation="Horizontal" >
+ <materialDesign:PackIcon Kind="KeyboardBackspace" Width="20" Height="20" />
+ <TextBlock Margin="5 0 0 0" FontSize="16">BACK</TextBlock>
+ </StackPanel>
+ </Button>
+
<Border Margin="10" Padding="5" BorderBrush="DimGray" BorderThickness="1">
<Border.Background>
<LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Views/HomeView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Views/HomeView.xaml
new file mode 100644
index 000000000..b41351064
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Views/HomeView.xaml
@@ -0,0 +1,87 @@
+<UserControl x:Class="Tango.MachineStudio.Logging.Views.HomeView"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+ xmlns:global="clr-namespace:Tango.MachineStudio.Logging"
+ xmlns:vm="clr-namespace:Tango.MachineStudio.Logging.ViewModels"
+ xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
+ xmlns:local="clr-namespace:Tango.MachineStudio.Logging.Views"
+ mc:Ignorable="d"
+ d:DesignHeight="1080" d:DesignWidth="1920" d:DataContext="{d:DesignInstance Type=vm:HomeViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.HomeViewVM}">
+
+ <UserControl.Resources>
+ <Style TargetType="Border" x:Key="LogBorder">
+ <Setter Property="Padding" Value="50"></Setter>
+ <Setter Property="Background">
+ <Setter.Value>
+ <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
+ <GradientStop Color="#35FFFFFF"/>
+ <GradientStop Color="White" Offset="1"/>
+
+ </LinearGradientBrush>
+ </Setter.Value>
+ </Setter>
+ <Setter Property="CornerRadius" Value="20"></Setter>
+ <Setter Property="Width" Value="450"></Setter>
+ <Setter Property="Height" Value="400"></Setter>
+ <Setter Property="TextElement.Foreground" Value="#202020"></Setter>
+ <Setter Property="TextElement.FontSize" Value="25"></Setter>
+ <Setter Property="BorderThickness" Value="1"></Setter>
+ <Setter Property="BorderBrush" Value="#D6D6D6"></Setter>
+ <Setter Property="Cursor" Value="Hand"></Setter>
+ <Style.Triggers>
+ <Trigger Property="IsMouseOver" Value="True">
+ <Setter Property="TextElement.Foreground" Value="DodgerBlue"></Setter>
+ <Setter Property="BorderBrush" Value="DodgerBlue"></Setter>
+ </Trigger>
+ </Style.Triggers>
+ </Style>
+ </UserControl.Resources>
+
+ <Grid>
+
+ <TextBlock Margin="80 50" FontSize="16">
+ <Run FontSize="20">Machine Studio logs information from multiple source.</Run>
+ <LineBreak/>
+ <LineBreak/>
+ <LineBreak/>
+ <Run FontWeight="SemiBold">• Machine Events</Run> <Run>are predefined events that occurs only when a set of predefined actions have occurred (e.g 'Job executed', 'Thread Break').</Run>
+ <LineBreak/>
+ <LineBreak/>
+ <Run FontWeight="SemiBold">• Application Logs</Run> <Run>are the standard machine studio logs which can be used to trace issues in code.</Run>
+ <LineBreak/>
+ <LineBreak/>
+ <Run FontWeight="SemiBold">• Embedded Logs</Run> <Run>are logs transmitted from the machine's embedded device software.</Run>
+ </TextBlock>
+
+ <UniformGrid Columns="3" Rows="1" VerticalAlignment="Center" Margin="50 150 50 0">
+ <Button Style="{StaticResource emptyButton}" Margin="70" Padding="0" Height="Auto" Command="{Binding NavigateToCommand}" CommandParameter="EventsView">
+ <Border Style="{StaticResource LogBorder}">
+ <DockPanel>
+ <TextBlock HorizontalAlignment="Center" Margin="0 20 0 0" DockPanel.Dock="Bottom">MACHINE EVENTS</TextBlock>
+ <Image Source="../Images/events.png"></Image>
+ </DockPanel>
+ </Border>
+ </Button>
+
+ <Button Style="{StaticResource emptyButton}" Margin="70" Padding="0" Height="Auto" Command="{Binding NavigateToCommand}" CommandParameter="ApplicationLogsView">
+ <Border Style="{StaticResource LogBorder}">
+ <DockPanel>
+ <TextBlock HorizontalAlignment="Center" Margin="0 20 0 0" DockPanel.Dock="Bottom">APPLICATION LOGS</TextBlock>
+ <Image Source="../Images/application-logs.png"></Image>
+ </DockPanel>
+ </Border>
+ </Button>
+
+ <Button Style="{StaticResource emptyButton}" Margin="70" Padding="0" Height="Auto" Command="{Binding NavigateToCommand}" CommandParameter="EmbeddedLogsView">
+ <Border Style="{StaticResource LogBorder}">
+ <DockPanel>
+ <TextBlock HorizontalAlignment="Center" Margin="0 20 0 0" DockPanel.Dock="Bottom">EMBEDDED LOGS</TextBlock>
+ <Image Source="../Images/embedded-logs.png"></Image>
+ </DockPanel>
+ </Border>
+ </Button>
+ </UniformGrid>
+ </Grid>
+</UserControl>
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Views/HomeView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Views/HomeView.xaml.cs
new file mode 100644
index 000000000..36d261a2f
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Views/HomeView.xaml.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace Tango.MachineStudio.Logging.Views
+{
+ /// <summary>
+ /// Interaction logic for HomeView.xaml
+ /// </summary>
+ public partial class HomeView : UserControl
+ {
+ public HomeView()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Views/MainView.xaml
index 6d5f98b51..b6ac29893 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Views/MainView.xaml
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Views/MainView.xaml
@@ -13,11 +13,17 @@
xmlns:controls="clr-namespace:Tango.SharedUI.Controls;assembly=Tango.SharedUI"
xmlns:vm="clr-namespace:Tango.MachineStudio.Logging.ViewModels"
mc:Ignorable="d"
- d:DesignHeight="1080" d:DesignWidth="1920" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}">
+ d:DesignHeight="1080" d:DesignWidth="1920" d:DataContext="{d:DesignInstance Type=vm:EventsViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.EventsViewVM}">
<Grid>
<controls:MultiTransitionControl x:Name="TransitionControl" x:FieldModifier="internal" TransitionType="Slide">
<controls:MultiTransitionControl.Controls>
+ <ContentControl Tag="HomeView">
+ <local:HomeView/>
+ </ContentControl>
+ <ContentControl Tag="ApplicationLogsView">
+ <local:ApplicationLogsView/>
+ </ContentControl>
<ContentControl Tag="EventsView">
<local:EventsView/>
</ContentControl>
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Views/TimelineView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Views/TimelineView.xaml
index 504514cbb..1046fa4e8 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Views/TimelineView.xaml
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Views/TimelineView.xaml
@@ -20,6 +20,7 @@
<localConverters:MachineEventToXConverter x:Key="MachineEventToXConverter" />
<localConverters:SecondsToWidthConverter x:Key="SecondsToWidthConverter" />
<converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
+ <localConverters:StringToFirstLineConverter x:Key="StringToFirstLineConverter" />
<LinearGradientBrush x:Key="infoBrush" StartPoint="0.5,0" EndPoint="0.5,1">
<GradientStop Color="White"/>
@@ -146,7 +147,7 @@
</Border.Style>
<StackPanel Orientation="Horizontal">
<TextBlock FontWeight="SemiBold" Text="{Binding EventType.Name}" Height="14" FontSize="11"></TextBlock>
- <TextBlock Margin="10 0 0 0" Text="{Binding Description}" Height="14" FontSize="11"></TextBlock>
+ <TextBlock Margin="10 0 0 0" Text="{Binding Description,Converter={StaticResource StringToFirstLineConverter}}" Height="14" FontSize="11"></TextBlock>
</StackPanel>
</Border>
</Grid>
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Views/TimelineWrapperView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Views/TimelineWrapperView.xaml
index abab55264..b436c55f5 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Views/TimelineWrapperView.xaml
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Views/TimelineWrapperView.xaml
@@ -8,7 +8,7 @@
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:local="clr-namespace:Tango.MachineStudio.Logging.Views"
mc:Ignorable="d"
- d:DesignHeight="1080" d:DesignWidth="1920" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}">
+ d:DesignHeight="1080" d:DesignWidth="1920" d:DataContext="{d:DesignInstance Type=vm:EventsViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.EventsViewVM}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="70"/>
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs
index 63aca3e70..88c50b549 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs
@@ -29,6 +29,7 @@ using Tango.SharedUI;
using Tango.Integration.Services;
using Tango.BL.Enumerations;
using Tango.BL;
+using Tango.MachineStudio.Common.EventLogging;
namespace Tango.MachineStudio.Technician.ViewModels
{
@@ -45,6 +46,7 @@ namespace Tango.MachineStudio.Technician.ViewModels
private static object _elementsLock = new object();
private String _lastTechProjectFile;
private INotificationProvider _notification;
+ private IEventLogger _eventLogger;
private DateTime _lastDiagnosticsResponseUpdate;
private const int MIN_DIAGNOSTICS_UPDATE_MILI = 500;
@@ -171,9 +173,10 @@ namespace Tango.MachineStudio.Technician.ViewModels
/// </summary>
/// <param name="applicationManager">The application manager.</param>
/// <param name="notificationProvider">The notification provider.</param>
- public MachineTechViewVM(IStudioApplicationManager applicationManager, INotificationProvider notificationProvider, IDiagnosticsFrameProvider _diagnosticsFrameProvider)
+ public MachineTechViewVM(IStudioApplicationManager applicationManager, INotificationProvider notificationProvider, IDiagnosticsFrameProvider _diagnosticsFrameProvider, IEventLogger eventLogger)
{
_notification = notificationProvider;
+ _eventLogger = eventLogger;
_singleControllers = new Dictionary<SingleGraphItem, GraphController>();
_multiControllers = new Dictionary<MultiGraphItem, GraphMultiController>();
AvailableTechItems = TechItem.GetAvailableTechItems().ToObservableCollection();
@@ -581,7 +584,8 @@ namespace Tango.MachineStudio.Technician.ViewModels
else if (item is ControllerItem)
{
(item as ControllerItem).TechController = Adapter.TechControllers.FirstOrDefault(x => x.Guid == item.ItemGuid);
- CreateElement<ControllerElementEditor>(item);
+ var editor = CreateElement<ControllerElementEditor>(item);
+ InitControllerItem(editor.ControllerItem);
}
}
@@ -695,68 +699,78 @@ namespace Tango.MachineStudio.Technician.ViewModels
{
item.ActionExecuted += async (x, action) =>
{
- if (action == MotorActionType.ForwardPressed)
- {
- await MachineOperator.StartMotorJogging(new MotorJoggingRequest()
- {
- Code = item.TechMotor.Code,
- Direction = MotorDirection.Forward,
- });
- }
- else if (action == MotorActionType.ForwardReleased)
+ try
{
- await MachineOperator.StopMotorJogging(new MotorAbortJoggingRequest()
+ CheckMachineOperator();
+
+ if (action == MotorActionType.ForwardPressed)
{
- Code = item.TechMotor.Code,
- });
- }
- else if (action == MotorActionType.BackwardPressed)
- {
- await MachineOperator.StartMotorJogging(new MotorJoggingRequest()
+ await MachineOperator.StartMotorJogging(new MotorJoggingRequest()
+ {
+ Code = item.TechMotor.Code,
+ Direction = MotorDirection.Forward,
+ });
+ }
+ else if (action == MotorActionType.ForwardReleased)
{
- Code = item.TechMotor.Code,
- Direction = MotorDirection.Backward,
- });
- }
- else if (action == MotorActionType.BackwardReleased)
- {
- await MachineOperator.StopMotorJogging(new MotorAbortJoggingRequest()
+ await MachineOperator.StopMotorJogging(new MotorAbortJoggingRequest()
+ {
+ Code = item.TechMotor.Code,
+ });
+ }
+ else if (action == MotorActionType.BackwardPressed)
{
- Code = item.TechMotor.Code,
- });
- }
- else if (action == MotorActionType.HomingStarted)
- {
- item.HomingProgress = 0;
- item.IsHoming = true;
- item.IsHomingCompleted = false;
-
- MachineOperator.StartMotorHoming(new MotorHomingRequest()
+ await MachineOperator.StartMotorJogging(new MotorJoggingRequest()
+ {
+ Code = item.TechMotor.Code,
+ Direction = MotorDirection.Backward,
+ });
+ }
+ else if (action == MotorActionType.BackwardReleased)
{
- Code = item.TechMotor.Code
- })
- .Subscribe((response) =>
+ await MachineOperator.StopMotorJogging(new MotorAbortJoggingRequest()
+ {
+ Code = item.TechMotor.Code,
+ });
+ }
+ else if (action == MotorActionType.HomingStarted)
{
+ item.HomingProgress = 0;
+ item.IsHoming = true;
+ item.IsHomingCompleted = false;
+
+ MachineOperator.StartMotorHoming(new MotorHomingRequest()
+ {
+ Code = item.TechMotor.Code
+ })
+ .Subscribe((response) =>
+ {
- item.HomingMaximumProgress = response.MaxProgress;
- item.HomingProgress = response.Progress;
+ item.HomingMaximumProgress = response.MaxProgress;
+ item.HomingProgress = response.Progress;
+
+ }, () =>
+ {
- }, () =>
+ item.IsHoming = false;
+ item.IsHomingCompleted = true;
+
+ });
+ }
+ else if (action == MotorActionType.HomingStopped)
{
+ await MachineOperator.StopMotorHoming(new MotorAbortHomingRequest()
+ {
+ Code = item.TechMotor.Code,
+ });
item.IsHoming = false;
- item.IsHomingCompleted = true;
-
- });
+ }
}
- else if (action == MotorActionType.HomingStopped)
+ catch (Exception ex)
{
- await MachineOperator.StopMotorHoming(new MotorAbortHomingRequest()
- {
- Code = item.TechMotor.Code,
- });
-
- item.IsHoming = false;
+ LogManager.Log(ex, String.Format("Error executing technician command '{0}' on item '{1}'.", action,item.TechName));
+ _eventLogger.Log(ex, String.Format("Error executing technician command '{0}' on item '{1}'.", action, item.TechName));
}
};
}
@@ -769,68 +783,78 @@ namespace Tango.MachineStudio.Technician.ViewModels
{
item.ActionExecuted += async (x, action) =>
{
- if (action == MotorActionType.ForwardPressed)
- {
- await MachineOperator.StartDispenserJogging(new DispenserJoggingRequest()
- {
- Code = item.TechDispenser.Code,
- Direction = MotorDirection.Forward,
- });
- }
- else if (action == MotorActionType.ForwardReleased)
+ try
{
- await MachineOperator.StopDispenserJogging(new DispenserAbortJoggingRequest()
+ CheckMachineOperator();
+
+ if (action == MotorActionType.ForwardPressed)
{
- Code = item.TechDispenser.Code,
- });
- }
- else if (action == MotorActionType.BackwardPressed)
- {
- await MachineOperator.StartDispenserJogging(new DispenserJoggingRequest()
+ await MachineOperator.StartDispenserJogging(new DispenserJoggingRequest()
+ {
+ Code = item.TechDispenser.Code,
+ Direction = MotorDirection.Forward,
+ });
+ }
+ else if (action == MotorActionType.ForwardReleased)
{
- Code = item.TechDispenser.Code,
- Direction = MotorDirection.Backward,
- });
- }
- else if (action == MotorActionType.BackwardReleased)
- {
- await MachineOperator.StopDispenserJogging(new DispenserAbortJoggingRequest()
+ await MachineOperator.StopDispenserJogging(new DispenserAbortJoggingRequest()
+ {
+ Code = item.TechDispenser.Code,
+ });
+ }
+ else if (action == MotorActionType.BackwardPressed)
{
- Code = item.TechDispenser.Code,
- });
- }
- else if (action == MotorActionType.HomingStarted)
- {
- item.HomingProgress = 0;
- item.IsHoming = true;
- item.IsHomingCompleted = false;
-
- MachineOperator.StartDispenserHoming(new DispenserHomingRequest()
+ await MachineOperator.StartDispenserJogging(new DispenserJoggingRequest()
+ {
+ Code = item.TechDispenser.Code,
+ Direction = MotorDirection.Backward,
+ });
+ }
+ else if (action == MotorActionType.BackwardReleased)
{
- Code = item.TechDispenser.Code
- })
- .Subscribe((response) =>
+ await MachineOperator.StopDispenserJogging(new DispenserAbortJoggingRequest()
+ {
+ Code = item.TechDispenser.Code,
+ });
+ }
+ else if (action == MotorActionType.HomingStarted)
{
+ item.HomingProgress = 0;
+ item.IsHoming = true;
+ item.IsHomingCompleted = false;
- item.HomingMaximumProgress = response.MaxProgress;
- item.HomingProgress = response.Progress;
+ MachineOperator.StartDispenserHoming(new DispenserHomingRequest()
+ {
+ Code = item.TechDispenser.Code
+ })
+ .Subscribe((response) =>
+ {
- }, () =>
+ item.HomingMaximumProgress = response.MaxProgress;
+ item.HomingProgress = response.Progress;
+
+ }, () =>
+ {
+
+ item.IsHoming = false;
+ item.IsHomingCompleted = true;
+
+ });
+ }
+ else if (action == MotorActionType.HomingStopped)
{
+ await MachineOperator.StopDispenserHoming(new DispenserAbortHomingRequest()
+ {
+ Code = item.TechDispenser.Code,
+ });
item.IsHoming = false;
- item.IsHomingCompleted = true;
-
- });
+ }
}
- else if (action == MotorActionType.HomingStopped)
+ catch (Exception ex)
{
- await MachineOperator.StopDispenserHoming(new DispenserAbortHomingRequest()
- {
- Code = item.TechDispenser.Code,
- });
-
- item.IsHoming = false;
+ LogManager.Log(ex, String.Format("Error executing technician command '{0}' on item '{1}'.", action, item.TechName));
+ _eventLogger.Log(ex, String.Format("Error executing technician command '{0}' on item '{1}'.", action, item.TechName));
}
};
}
@@ -886,23 +910,33 @@ namespace Tango.MachineStudio.Technician.ViewModels
{
item.ActionExecuted += async (x, action) =>
{
- if (action == MotorActionType.ForwardPressed)
+ try
{
- await MachineOperator.StartThreadJogging(new ThreadJoggingRequest()
+ CheckMachineOperator();
+
+ if (action == MotorActionType.ForwardPressed)
{
- Direction = MotorDirection.Forward,
- });
- }
- else if (action == MotorActionType.BackwardPressed)
- {
- await MachineOperator.StartThreadJogging(new ThreadJoggingRequest()
+ await MachineOperator.StartThreadJogging(new ThreadJoggingRequest()
+ {
+ Direction = MotorDirection.Forward,
+ });
+ }
+ else if (action == MotorActionType.BackwardPressed)
{
- Direction = MotorDirection.Backward,
- });
+ await MachineOperator.StartThreadJogging(new ThreadJoggingRequest()
+ {
+ Direction = MotorDirection.Backward,
+ });
+ }
+ else if (action == MotorActionType.ForwardReleased || action == MotorActionType.BackwardReleased)
+ {
+ await MachineOperator.StopThreadJogging(new ThreadAbortJoggingRequest());
+ }
}
- else if (action == MotorActionType.ForwardReleased || action == MotorActionType.BackwardReleased)
+ catch (Exception ex)
{
- await MachineOperator.StopThreadJogging(new ThreadAbortJoggingRequest());
+ LogManager.Log(ex, String.Format(String.Format("Error executing technician command '{0}' on item '{1}'.", action, item.TechName)));
+ _eventLogger.Log(ex, String.Format("Error executing technician command '{0}' on item '{1}'.", action, item.TechName));
}
};
}
@@ -915,69 +949,79 @@ namespace Tango.MachineStudio.Technician.ViewModels
{
item.ActionExecuted += async (x, action) =>
{
- if (action == MotorActionType.ForwardPressed)
+ try
{
- await Task.WhenAll(item.TechMotors.Select(motor => MachineOperator.StartMotorJogging(new MotorJoggingRequest()
+ CheckMachineOperator();
+
+ if (action == MotorActionType.ForwardPressed)
{
- Code = motor.Code,
- Direction = MotorDirection.Forward,
- })));
- }
- else if (action == MotorActionType.ForwardReleased)
- {
- await Task.WhenAll(item.TechMotors.Select(motor => MachineOperator.StopMotorJogging(new MotorAbortJoggingRequest()
+ await Task.WhenAll(item.TechMotors.Select(motor => MachineOperator.StartMotorJogging(new MotorJoggingRequest()
+ {
+ Code = motor.Code,
+ Direction = MotorDirection.Forward,
+ })));
+ }
+ else if (action == MotorActionType.ForwardReleased)
{
- Code = motor.Code,
- })));
- }
- else if (action == MotorActionType.BackwardPressed)
- {
- await Task.WhenAll(item.TechMotors.Select(motor => MachineOperator.StartMotorJogging(new MotorJoggingRequest()
+ await Task.WhenAll(item.TechMotors.Select(motor => MachineOperator.StopMotorJogging(new MotorAbortJoggingRequest()
+ {
+ Code = motor.Code,
+ })));
+ }
+ else if (action == MotorActionType.BackwardPressed)
{
- Code = motor.Code,
- Direction = MotorDirection.Backward,
- })));
- }
- else if (action == MotorActionType.BackwardReleased)
- {
- await Task.WhenAll(item.TechMotors.Select(motor => MachineOperator.StopMotorJogging(new MotorAbortJoggingRequest()
+ await Task.WhenAll(item.TechMotors.Select(motor => MachineOperator.StartMotorJogging(new MotorJoggingRequest()
+ {
+ Code = motor.Code,
+ Direction = MotorDirection.Backward,
+ })));
+ }
+ else if (action == MotorActionType.BackwardReleased)
{
- Code = motor.Code,
- })));
- }
- //else if (action == MotorActionType.HomingStarted)
- //{
- // item.HomingProgress = 0;
- // item.IsHoming = true;
- // item.IsHomingCompleted = false;
+ await Task.WhenAll(item.TechMotors.Select(motor => MachineOperator.StopMotorJogging(new MotorAbortJoggingRequest()
+ {
+ Code = motor.Code,
+ })));
+ }
+ //else if (action == MotorActionType.HomingStarted)
+ //{
+ // item.HomingProgress = 0;
+ // item.IsHoming = true;
+ // item.IsHomingCompleted = false;
- // MachineOperator.StartMotorHoming(new MotorHomingRequest()
- // {
- // Code = item.TechMotor.Code
- // })
- // .Subscribe((response) =>
- // {
+ // MachineOperator.StartMotorHoming(new MotorHomingRequest()
+ // {
+ // Code = item.TechMotor.Code
+ // })
+ // .Subscribe((response) =>
+ // {
- // item.HomingMaximumProgress = response.Message.MaxProgress;
- // item.HomingProgress = response.Message.Progress;
+ // item.HomingMaximumProgress = response.Message.MaxProgress;
+ // item.HomingProgress = response.Message.Progress;
- // }, () =>
- // {
+ // }, () =>
+ // {
- // item.IsHoming = false;
- // item.IsHomingCompleted = true;
+ // item.IsHoming = false;
+ // item.IsHomingCompleted = true;
- // });
- //}
- //else if (action == MotorActionType.HomingStopped)
- //{
- // await MachineOperator.StopMotorHoming(new MotorAbortHomingRequest()
- // {
- // Code = item.TechMotor.Code,
- // });
+ // });
+ //}
+ //else if (action == MotorActionType.HomingStopped)
+ //{
+ // await MachineOperator.StopMotorHoming(new MotorAbortHomingRequest()
+ // {
+ // Code = item.TechMotor.Code,
+ // });
- // item.IsHoming = false;
- //}
+ // item.IsHoming = false;
+ //}
+ }
+ catch (Exception ex)
+ {
+ LogManager.Log(ex, String.Format("Error executing technician command '{0}' on item '{1}'.", action, item.TechName));
+ _eventLogger.Log(ex, String.Format("Error executing technician command '{0}' on item '{1}'.", action, item.TechName));
+ }
};
}
@@ -991,11 +1035,13 @@ namespace Tango.MachineStudio.Technician.ViewModels
{
try
{
+ CheckMachineOperator();
await MachineOperator.SetDigitalOut(new SetDigitalOutRequest() { Port = item.TechIo.Port, Value = value });
}
catch (Exception ex)
{
- //TODO: Show Exception.
+ LogManager.Log(ex, String.Format("Error executing technician set digital out command on '{0}'.", item.TechName));
+ _eventLogger.Log(ex, String.Format("Error executing technician set digital out command on '{0}'.", item.TechName));
}
};
}
@@ -1010,6 +1056,7 @@ namespace Tango.MachineStudio.Technician.ViewModels
{
try
{
+ CheckMachineOperator();
await MachineOperator.SetComponentValue(new SetComponentValueRequest()
{
Component = (ValueComponent)item.TechController.Code,
@@ -1018,11 +1065,24 @@ namespace Tango.MachineStudio.Technician.ViewModels
}
catch (Exception ex)
{
- //TODO: Show Exception.
+ LogManager.Log(ex, String.Format("Error executing technician set value component command on '{0}'.", item.TechName));
+ _eventLogger.Log(ex, String.Format("Error executing technician set value component command on '{0}'.", item.TechName));
}
};
}
+ /// <summary>
+ /// Checks the machine operator.
+ /// </summary>
+ /// <exception cref="InvalidOperationException">No machine connected.</exception>
+ private void CheckMachineOperator()
+ {
+ if (MachineOperator == null || MachineOperator.State != Transport.TransportComponentState.Connected)
+ {
+ throw new InvalidOperationException("No machine connected.");
+ }
+ }
+
#endregion
#region Public Methods
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/HiveColorPickerControl.xaml.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/HiveColorPickerControl.xaml.cs
index 41b362889..b8ebe9f6a 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/HiveColorPickerControl.xaml.cs
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/HiveColorPickerControl.xaml.cs
@@ -93,7 +93,10 @@ namespace Tango.MachineStudio.Common.Controls
private void HiveCombo_HiveGenerated(object sender, EventArgs e)
{
- hiveCombo.GenerateDemoModeHiveColors(SelectedColor.Value);
+ if (SelectedColor.HasValue)
+ {
+ hiveCombo.GenerateDemoModeHiveColors(SelectedColor.Value);
+ }
}
private void OnSelectedHiveColorChanged()
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/EventLogging/DefaultEventLogger.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/EventLogging/DefaultEventLogger.cs
index f3ae1002b..0a4af6218 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/EventLogging/DefaultEventLogger.cs
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/EventLogging/DefaultEventLogger.cs
@@ -120,6 +120,8 @@ namespace Tango.MachineStudio.Common.EventLogging
{
machine.MachineEventsStateProvider.NewEvents -= MachineEventsStateProvider_NewEvents;
machine.MachineEventsStateProvider.NewEvents += MachineEventsStateProvider_NewEvents;
+ machine.MachineEventsStateProvider.EventsResolved -= MachineEventsStateProvider_EventsResolved;
+ machine.MachineEventsStateProvider.EventsResolved += MachineEventsStateProvider_EventsResolved;
}
machine.RequestSent -= Machine_RequestSent;
@@ -175,6 +177,19 @@ namespace Tango.MachineStudio.Common.EventLogging
}
}
+ /// <summary>
+ /// Handles the connected machine events state provider EventsResolved event.
+ /// </summary>
+ /// <param name="sender">The sender.</param>
+ /// <param name="events">The events.</param>
+ private void MachineEventsStateProvider_EventsResolved(object sender, IEnumerable<MachinesEvent> events)
+ {
+ foreach (var ev in events)
+ {
+ Log(String.Format("Event '{0}' resolved.", ev.EventType.Name));
+ }
+ }
+
#endregion
#region Logging
@@ -206,7 +221,7 @@ namespace Tango.MachineStudio.Common.EventLogging
}
LogManager.Log("Logging event " + machineEvent.EventType.Name + " - " + machineEvent.Description);
- machineEvent.MachineGuid = _application.ConnectedMachine.Guid;
+ machineEvent.MachineGuid = _application.ConnectedMachine.Machine.Guid;
machineEvent.UserGuid = _authentication.CurrentUser.Guid;
machineEvent.User = _authentication.CurrentUser;
_events.Enqueue(machineEvent);
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.xaml.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.xaml.cs
index 76c7b3e58..1334a349d 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.xaml.cs
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.xaml.cs
@@ -28,6 +28,9 @@ namespace Tango.MachineStudio.UI
protected override void OnStartup(StartupEventArgs e)
{
+ LogManager.RegisterLogger(new VSOutputLogger());
+ LogManager.RegisterLogger(new FileLogger());
+
LogManager.Log("Application Started...");
base.OnStartup(e);
@@ -44,9 +47,6 @@ namespace Tango.MachineStudio.UI
LogManager.Categories.AddRange(SettingsManager.Default.MachineStudio.LoggingCategories);
- LogManager.RegisterLogger(new VSOutputLogger());
- LogManager.RegisterLogger(new FileLogger());
-
exceptionTrapper = new WpfGlobalExceptionTrapper();
exceptionTrapper.Initialize(this);
exceptionTrapper.ApplicationCrashed += ExceptionTrapper_ApplicationCrashed;
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Html/HtmlWindow.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Html/HtmlWindow.xaml
index d7032cedc..f984a985f 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Html/HtmlWindow.xaml
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Html/HtmlWindow.xaml
@@ -18,7 +18,7 @@
<Grid>
<DockPanel>
<Grid DockPanel.Dock="Bottom">
- <Button Margin="10" Width="140" HorizontalAlignment="Right" Click="OKClicked">OK</Button>
+ <Button Margin="10" Width="140" HorizontalAlignment="Right" Click="OKClicked">RESOLVE</Button>
</Grid>
<WebBrowser x:Name="webBrowser"
OverridesDefaultStyle="False"
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Modules/DefaultStudioModuleLoader.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Modules/DefaultStudioModuleLoader.cs
index 121d429ec..07834393b 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Modules/DefaultStudioModuleLoader.cs
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Modules/DefaultStudioModuleLoader.cs
@@ -80,8 +80,12 @@ namespace Tango.MachineStudio.UI.Modules
if (!_loaded)
{
//Preloaded
+
+ LogManager.Log(String.Format("Loading module '{0}'...", nameof(StubsModule)));
AllModules.Add(new StubsModule());
+ LogManager.Log(String.Format("Loading module '{0}'...", nameof(DBModule)));
AllModules.Add(new DBModule());
+ LogManager.Log(String.Format("Loading module '{0}'...", nameof(MachineDesignerModule)));
AllModules.Add(new MachineDesignerModule());
//Preloaded
@@ -103,6 +107,7 @@ namespace Tango.MachineStudio.UI.Modules
{
try
{
+ LogManager.Log(String.Format("Loading module '{0}'...", moduleType.Name));
var module = Activator.CreateInstance(moduleType) as IStudioModule;
AllModules.Add(module);
}
@@ -117,7 +122,7 @@ namespace Tango.MachineStudio.UI.Modules
catch { }
}
- _loaded = true;
+ _loaded = true;
}
UserModules.Clear();
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DefaultNotificationProvider.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DefaultNotificationProvider.cs
index 1c9b8732f..cb36d8d29 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DefaultNotificationProvider.cs
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Notifications/DefaultNotificationProvider.cs
@@ -112,14 +112,16 @@ namespace Tango.MachineStudio.UI.Notifications
dialog.DataContext = context;
Action onAcceptAction = null;
+ Action onCancelAction = null;
+
onAcceptAction = new Action(() =>
{
dialog.Close();
onAccept(context);
context.Accepted -= onAcceptAction;
+ context.Canceled -= onCancelAction;
});
- Action onCancelAction = null;
onCancelAction = new Action(() =>
{
dialog.Close();
@@ -129,6 +131,7 @@ namespace Tango.MachineStudio.UI.Notifications
onCancel();
}
+ context.Accepted -= onAcceptAction;
context.Canceled -= onCancelAction;
});
@@ -163,14 +166,16 @@ namespace Tango.MachineStudio.UI.Notifications
dialog.DataContext = context;
Action onAcceptAction = null;
+ Action onCancelAction = null;
+
onAcceptAction = new Action(() =>
{
dialog.Close();
onAccept(context);
context.Accepted -= onAcceptAction;
+ context.Canceled -= onCancelAction;
});
- Action onCancelAction = null;
onCancelAction = new Action(() =>
{
dialog.Close();
@@ -180,6 +185,7 @@ namespace Tango.MachineStudio.UI.Notifications
onCancel();
}
+ context.Accepted -= onAcceptAction;
context.Canceled -= onCancelAction;
});
@@ -213,14 +219,16 @@ namespace Tango.MachineStudio.UI.Notifications
dialog.DataContext = context;
Action onAcceptAction = null;
+ Action onCancelAction = null;
+
onAcceptAction = new Action(() =>
{
dialog.Close();
onAccept(context);
context.Accepted -= onAcceptAction;
+ context.Canceled -= onCancelAction;
});
- Action onCancelAction = null;
onCancelAction = new Action(() =>
{
dialog.Close();
@@ -231,6 +239,7 @@ namespace Tango.MachineStudio.UI.Notifications
}
context.Canceled -= onCancelAction;
+ context.Accepted -= onAcceptAction;
});
context.Accepted += onAcceptAction;
@@ -279,15 +288,18 @@ namespace Tango.MachineStudio.UI.Notifications
}
dialog.DataContext = context;
+ Action onCancelAction = null;
Action onAcceptAction = null;
+
onAcceptAction = new Action(() =>
{
dialog.Close();
onAccept(context);
+
+ context.Canceled -= onCancelAction;
context.Accepted -= onAcceptAction;
});
- Action onCancelAction = null;
onCancelAction = new Action(() =>
{
dialog.Close();
@@ -298,6 +310,7 @@ namespace Tango.MachineStudio.UI.Notifications
}
context.Canceled -= onCancelAction;
+ context.Accepted -= onAcceptAction;
});
context.Accepted += onAcceptAction;
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj
index c13970674..eb4139936 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj
@@ -159,6 +159,7 @@
<DependentUpon>MessageBoxWindow.xaml</DependentUpon>
</Compile>
<Compile Include="SupervisingController\IMainView.cs" />
+ <Compile Include="ViewModels\ConnectedMachineViewVM.cs" />
<Compile Include="ViewModels\LoadingViewVM.cs" />
<Compile Include="ViewModels\LoginViewVM.cs" />
<Compile Include="ViewModels\MachineConnectionViewVM.cs" />
@@ -169,6 +170,9 @@
<Compile Include="ViewModels\ModuleWindowVM.cs" />
<Compile Include="ViewModels\ShutdownViewVM.cs" />
<Compile Include="ViewModels\UpdateViewVM.cs" />
+ <Compile Include="Views\ConnectedMachineView.xaml.cs">
+ <DependentUpon>ConnectedMachineView.xaml</DependentUpon>
+ </Compile>
<Compile Include="Views\LoadingView.xaml.cs">
<DependentUpon>LoadingView.xaml</DependentUpon>
</Compile>
@@ -234,6 +238,10 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
+ <Page Include="Views\ConnectedMachineView.xaml">
+ <SubType>Designer</SubType>
+ <Generator>MSBuild:Compile</Generator>
+ </Page>
<Page Include="Views\LoadingView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModelLocator.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModelLocator.cs
index bbb916d02..97eb2913b 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModelLocator.cs
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModelLocator.cs
@@ -82,6 +82,7 @@ namespace Tango.MachineStudio.UI
SimpleIoc.Default.Register<ShutdownViewVM>();
SimpleIoc.Default.Register<LoginViewVM>();
SimpleIoc.Default.Register<MachineConnectionViewVM>();
+ SimpleIoc.Default.Register<ConnectedMachineViewVM>();
SimpleIoc.Default.Register<MachineLoginViewVM>();
SimpleIoc.Default.Register<UpdateViewVM>();
@@ -133,6 +134,14 @@ namespace Tango.MachineStudio.UI
}
}
+ public ConnectedMachineViewVM ConnectedMachineViewVM
+ {
+ get
+ {
+ return ServiceLocator.Current.GetInstance<ConnectedMachineViewVM>();
+ }
+ }
+
public MachineLoginViewVM MachineLoginViewVM
{
get
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/ConnectedMachineViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/ConnectedMachineViewVM.cs
new file mode 100644
index 000000000..9f84cfb53
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/ConnectedMachineViewVM.cs
@@ -0,0 +1,36 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tango.BL.Entities;
+using Tango.Core.Commands;
+using Tango.MachineStudio.Common.Notifications;
+using Tango.MachineStudio.Common.StudioApplication;
+using Tango.SharedUI;
+
+namespace Tango.MachineStudio.UI.ViewModels
+{
+ public class ConnectedMachineViewVM : DialogViewVM
+ {
+ private IStudioApplicationManager _applicationManager;
+ public IStudioApplicationManager ApplicationManager
+ {
+ get { return _applicationManager; }
+ set { _applicationManager = value; RaisePropertyChangedAuto(); }
+ }
+
+ public RelayCommand DisconnectCommand { get; set; }
+
+ public ConnectedMachineViewVM(IStudioApplicationManager application)
+ {
+ ApplicationManager = application;
+ DisconnectCommand = new RelayCommand(Disconnect);
+ }
+
+ private void Disconnect()
+ {
+ Accept();
+ }
+ }
+}
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs
index f9bffae29..8e451cdce 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs
@@ -384,89 +384,101 @@ namespace Tango.MachineStudio.UI.ViewModels
/// </summary>
private void ConnectToMachine()
{
- _notificationProvider.ShowModalDialog<MachineConnectionViewVM>(async (x) =>
+ if (ApplicationManager.ConnectedMachine == null)
{
- if (x.SelectedMachine != null)
+ _notificationProvider.ShowModalDialog<MachineConnectionViewVM>(async (x) =>
{
- if (ApplicationManager.IsMachineConnected)
+ if (x.SelectedMachine != null)
{
- using (_notificationProvider.PushTaskItem("Disconnecting..."))
+ if (ApplicationManager.IsMachineConnected)
{
- await ApplicationManager.ConnectedMachine.Disconnect();
- await Task.Delay(1000);
- }
- }
-
- if (x.SelectedMachine.RequiresAuthentication)
- {
- _notificationProvider.ShowModalDialog<MachineLoginViewVM>(async (login) =>
- {
- using (NotificationProvider.PushTaskItem("Connecting to machine " + x.SelectedMachine.ToString() + "..."))
+ using (_notificationProvider.PushTaskItem("Disconnecting..."))
{
- try
- {
- await x.SelectedMachine.Connect();
-
- var authenticated = await x.SelectedMachine.As<IExternalBridgeSecureClient>().Authenticate(login.Password);
- if (!authenticated)
- {
- _notificationProvider.ShowError("It seems like you are not authorized to access the selected machine.");
- }
- else
- {
- ApplicationManager.ConnectedMachine = x.SelectedMachine;
- PostMessage(new MachineConnectionChangedMessage() { Machine = x.SelectedMachine });
- _eventLogger.Log(String.Format("Successfully connected to machine {0} via TCP", x.SelectedMachine.SerialNumber));
- }
- }
- catch (Exception ex)
- {
- LogManager.Log(ex);
- _eventLogger.Log(ex, "Error connecting to machine " + x.SelectedMachine.SerialNumber);
- _notificationProvider.ShowError(ex.Message);
- }
-
- InvalidateRelayCommands();
+ await ApplicationManager.ConnectedMachine.Disconnect();
+ await Task.Delay(1000);
}
- });
- }
- else
- {
- _notificationProvider.ShowModalDialog<MachineSerialViewVM>(async (vm) =>
+ }
+
+ if (x.SelectedMachine.RequiresAuthentication)
{
- if (vm.SelectedMachine != null)
+ _notificationProvider.ShowModalDialog<MachineLoginViewVM>(async (login) =>
{
- using (NotificationProvider.PushTaskItem("Connecting to " + x.SelectedMachine.ToString() + "..."))
+ using (NotificationProvider.PushTaskItem("Connecting to machine " + x.SelectedMachine.ToString() + "..."))
{
try
{
await x.SelectedMachine.Connect();
- x.SelectedMachine.SerialNumber = vm.SelectedMachine.SerialNumber;
- ApplicationManager.ConnectedMachine = x.SelectedMachine;
- PostMessage(new MachineConnectionChangedMessage() { Machine = x.SelectedMachine });
- _eventLogger.Log(String.Format("Successfully connected to machine {0} via USB", x.SelectedMachine.SerialNumber));
- SettingsManager.Default.MachineStudio.LastVirtualMachineSerialNumber = vm.SelectedMachine.SerialNumber;
- SettingsManager.SaveDefaultSettings();
+ var authenticated = await x.SelectedMachine.As<IExternalBridgeSecureClient>().Authenticate(login.Password);
+ if (!authenticated)
+ {
+ _notificationProvider.ShowError("It seems like you are not authorized to access the selected machine.");
+ }
+ else
+ {
+ ApplicationManager.ConnectedMachine = x.SelectedMachine;
+ PostMessage(new MachineConnectionChangedMessage() { Machine = x.SelectedMachine });
+ _eventLogger.Log(String.Format("Successfully connected to machine {0} via TCP", x.SelectedMachine.SerialNumber));
+ }
}
catch (Exception ex)
{
LogManager.Log(ex);
_eventLogger.Log(ex, "Error connecting to machine " + x.SelectedMachine.SerialNumber);
- _notificationProvider.ShowError(ex.Message);
+ _notificationProvider.ShowError("Could not connect to the selected machine." + Environment.NewLine + ex.Message);
}
InvalidateRelayCommands();
}
- }
- });
+ });
+ }
+ else
+ {
+ _notificationProvider.ShowModalDialog<MachineSerialViewVM>(async (vm) =>
+ {
+ if (vm.SelectedMachine != null)
+ {
+ using (NotificationProvider.PushTaskItem("Connecting to " + x.SelectedMachine.ToString() + "..."))
+ {
+ try
+ {
+ await x.SelectedMachine.Connect();
+ x.SelectedMachine.SerialNumber = vm.SelectedMachine.SerialNumber;
+ ApplicationManager.ConnectedMachine = x.SelectedMachine;
+
+ PostMessage(new MachineConnectionChangedMessage() { Machine = x.SelectedMachine });
+ _eventLogger.Log(String.Format("Successfully connected to machine {0} via USB", x.SelectedMachine.SerialNumber));
+ SettingsManager.Default.MachineStudio.LastVirtualMachineSerialNumber = vm.SelectedMachine.SerialNumber;
+ SettingsManager.SaveDefaultSettings();
+ }
+ catch (Exception ex)
+ {
+ LogManager.Log(ex);
+ _eventLogger.Log(ex, "Error connecting to machine " + x.SelectedMachine.SerialNumber);
+ _notificationProvider.ShowError("Could not connect to the selected machine." + Environment.NewLine + ex.Message);
+ }
+
+ InvalidateRelayCommands();
+ }
+ }
+ });
+ }
+
+ InvalidateRelayCommands();
}
InvalidateRelayCommands();
- }
+ });
+ }
+ else
+ {
+ _notificationProvider.ShowModalDialog<ConnectedMachineViewVM>((x) =>
+ {
+ DisconnectFromMachine();
+ });
+ }
- InvalidateRelayCommands();
- });
+ InvalidateRelayCommands();
}
/// <summary>
@@ -581,6 +593,7 @@ namespace Tango.MachineStudio.UI.ViewModels
{
if (ApplicationManager.ConnectedMachine != null && machineEvent.EventType.Resolvable)
{
+ _eventLogger.Log(String.Format("Event '{0}' resolved by user.", machineEvent.EventType.Name));
await ApplicationManager.ConnectedMachine.ResolveEvent((PMR.Diagnostics.EventType)machineEvent.Type);
}
}
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/ConnectedMachineView.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/ConnectedMachineView.xaml
new file mode 100644
index 000000000..797d4dcb0
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/ConnectedMachineView.xaml
@@ -0,0 +1,111 @@
+<UserControl x:Class="Tango.MachineStudio.UI.Views.ConnectedMachineView"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:mahapps="http://metro.mahapps.com/winfx/xaml/controls"
+ xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
+ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ xmlns:integration="clr-namespace:Tango.Integration.Services;assembly=Tango.Integration"
+ xmlns:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI"
+ xmlns:controls="clr-namespace:Tango.SharedUI.Controls;assembly=Tango.SharedUI"
+ xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+ xmlns:local="clr-namespace:Tango.MachineStudio.UI.Views"
+ mc:Ignorable="d"
+ d:DesignHeight="300" d:DesignWidth="300" Width="600" Height="400" Background="White" DataContext="{Binding ConnectedMachineViewVM, Source={StaticResource Locator}}">
+
+ <UserControl.Resources>
+ <converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"></converters:BooleanToVisibilityConverter>
+ <converters:BooleanToVisibilityInverseConverter x:Key="BooleanToVisibilityInverseConverter"></converters:BooleanToVisibilityInverseConverter>
+ <converters:BooleanInverseConverter x:Key="BooleanInverseConverter"></converters:BooleanInverseConverter>
+ <converters:ByteArrayToFileSizeConverter x:Key="ByteArrayToFileSizeConverter" />
+ </UserControl.Resources>
+
+ <Grid>
+ <Grid>
+ <Grid.RowDefinitions>
+ <RowDefinition Height="80"/>
+ <RowDefinition Height="1*"/>
+ </Grid.RowDefinitions>
+
+ <Grid>
+ <StackPanel Orientation="Horizontal" Margin="10">
+ <ContentControl Content="{Binding ApplicationManager.ConnectedMachine}">
+ <ContentControl.Resources>
+ <DataTemplate DataType="{x:Type integration:ExternalBridgeTcpClient}">
+ <Image Source="/Images/external-bridge-tcp.png" Width="48" Height="48" RenderOptions.BitmapScalingMode="Fant"></Image>
+ </DataTemplate>
+
+ <DataTemplate DataType="{x:Type integration:ExternalBridgeUsbClient}">
+ <Image Source="/Images/external-bridge-usb.png" Width="48" Height="48" RenderOptions.BitmapScalingMode="Fant"></Image>
+ </DataTemplate>
+ </ContentControl.Resources>
+ </ContentControl>
+
+ <TextBlock Text="Machine Connection" VerticalAlignment="Center" Margin="10 0 0 0" FontSize="20"></TextBlock>
+ </StackPanel>
+ </Grid>
+
+ <Grid Grid.Row="1" Margin="10 0 10 10">
+ <Grid.RowDefinitions>
+ <RowDefinition Height="1*"/>
+ <RowDefinition Height="50"/>
+ </Grid.RowDefinitions>
+
+ <Grid>
+ <ContentControl Content="{Binding ApplicationManager.ConnectedMachine}">
+ <ContentControl.Resources>
+ <DataTemplate DataType="{x:Type integration:ExternalBridgeTcpClient}">
+ <controls:TableGrid RowHeight="30">
+ <TextBlock FontWeight="SemiBold" Text="Serial Number:" />
+ <TextBlock Text="{Binding SerialNumber}" />
+ <TextBlock FontWeight="SemiBold" Text="Name:" />
+ <TextBlock Text="{Binding Machine.Name}" />
+ <TextBlock FontWeight="SemiBold" Text="Organization:" />
+ <TextBlock Text="{Binding Machine.Organization.Name}" />
+ <TextBlock FontWeight="SemiBold" Text="IP Address:" />
+ <TextBlock Text="{Binding IPAddress}" />
+ <TextBlock FontWeight="SemiBold" Text="Total Bytes Sent:" />
+ <TextBlock Text="{Binding Adapter.TotalBytesSent,Converter={StaticResource ByteArrayToFileSizeConverter},Mode=OneWay}" />
+ <TextBlock FontWeight="SemiBold" Text="Total Bytes Received:" />
+ <TextBlock Text="{Binding Adapter.TotalBytesReceived,Converter={StaticResource ByteArrayToFileSizeConverter},Mode=OneWay}" />
+ <TextBlock FontWeight="SemiBold" Text="Transfer Rate:" />
+ <TextBlock>
+ <Run Text="{Binding Adapter.TransferRate,Converter={StaticResource ByteArrayToFileSizeConverter},Mode=OneWay}"></Run>
+ <Run Text="/ second"></Run>
+ </TextBlock>
+ </controls:TableGrid>
+ </DataTemplate>
+
+ <DataTemplate DataType="{x:Type integration:ExternalBridgeUsbClient}">
+ <controls:TableGrid RowHeight="30">
+ <TextBlock FontWeight="SemiBold" Text="Serial Number:" />
+ <TextBlock Text="{Binding SerialNumber}" />
+ <TextBlock FontWeight="SemiBold" Text="Name:" />
+ <TextBlock Text="{Binding Machine.Name}" />
+ <TextBlock FontWeight="SemiBold" Text="Organization:" />
+ <TextBlock Text="{Binding Machine.Organization.Name}" />
+ <TextBlock FontWeight="SemiBold" Text="COM Port:" />
+ <TextBlock Text="{Binding ComPort}" />
+ <TextBlock FontWeight="SemiBold" Text="Device:" />
+ <TextBlock Text="{Binding Device}" />
+ <TextBlock FontWeight="SemiBold" Text="Total Bytes Sent:" />
+ <TextBlock Text="{Binding Adapter.TotalBytesSent,Converter={StaticResource ByteArrayToFileSizeConverter},Mode=OneWay}" />
+ <TextBlock FontWeight="SemiBold" Text="Total Bytes Received:" />
+ <TextBlock Text="{Binding Adapter.TotalBytesReceived,Converter={StaticResource ByteArrayToFileSizeConverter},Mode=OneWay}" />
+ <TextBlock FontWeight="SemiBold" Text="Transfer Rate:" />
+ <TextBlock>
+ <Run Text="{Binding Adapter.TransferRate,Converter={StaticResource ByteArrayToFileSizeConverter},Mode=OneWay}"></Run>
+ <Run Text="/ second"></Run>
+ </TextBlock>
+ </controls:TableGrid>
+ </DataTemplate>
+ </ContentControl.Resources>
+ </ContentControl>
+ </Grid>
+
+ <Grid Grid.Row="1">
+ <Button HorizontalAlignment="Right" Width="140" Command="{Binding DisconnectCommand}">DISCONNECT</Button>
+ </Grid>
+ </Grid>
+ </Grid>
+ </Grid>
+</UserControl>
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/ConnectedMachineView.xaml.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/ConnectedMachineView.xaml.cs
new file mode 100644
index 000000000..cc8ac2237
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/ConnectedMachineView.xaml.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace Tango.MachineStudio.UI.Views
+{
+ /// <summary>
+ /// Interaction logic for ConnectedMachineView.xaml
+ /// </summary>
+ public partial class ConnectedMachineView : UserControl
+ {
+ public ConnectedMachineView()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MachineConnectionView.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MachineConnectionView.xaml
index 1626e67ef..6f0a74805 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MachineConnectionView.xaml
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MachineConnectionView.xaml
@@ -70,7 +70,7 @@
<Run FontWeight="Bold">IP Address:</Run> <Run Text="{Binding IPAddress,Mode=OneWay}"></Run>
</TextBlock>
<TextBlock FontSize="11">
- <Run FontWeight="Bold">Organization:</Run> <Run Text="{Binding Organization,Mode=OneWay}"></Run>
+ <Run FontWeight="Bold">Organization:</Run> <Run Text="{Binding Machine.Organization.Name,Mode=OneWay}"></Run>
</TextBlock>
</StackPanel>
</StackPanel>
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml.cs
index e0ae60b87..442d11cdd 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml.cs
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml.cs
@@ -25,6 +25,7 @@ using Tango.MachineStudio.Common;
using System.Threading;
using Tango.Core.Helpers;
using Tango.SharedUI.Helpers;
+using Tango.Logging;
namespace Tango.MachineStudio.UI.Views
{
@@ -54,6 +55,8 @@ namespace Tango.MachineStudio.UI.Views
Task.Factory.StartNew(() =>
{
+ LogManager.Default.Log("Loading modules views...");
+
var item = ServiceLocator.Current.GetInstance<INotificationProvider>().PushTaskItem("Loading Modules...");
var modules = _loader.UserModules.ToList();
@@ -67,6 +70,8 @@ namespace Tango.MachineStudio.UI.Views
foreach (var module in modules)
{
+ LogManager.Default.Log("Loading module view '" + module.Name + "'...");
+
ThreadsHelper.InvokeUI(() =>
{
Grid grid = new Grid();