From c400fa026cdb2bc5c1c5c25f5bfae37461e87cab Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Wed, 11 Apr 2018 14:50:47 +0300 Subject: Added Disconnect & Connect requests. Fixed issue with Machine Connection View Scanning. Fixed issue with ShowModalDialog close event.. Added ConnectedMachineView. Added TransferRate for Adapters. --- .../EventLogging/DefaultEventLogger.cs | 2 +- .../Tango.MachineStudio.UI/Html/HtmlWindow.xaml | 2 +- .../Notifications/DefaultNotificationProvider.cs | 21 +++- .../Tango.MachineStudio.UI.csproj | 8 ++ .../Tango.MachineStudio.UI/ViewModelLocator.cs | 9 ++ .../ViewModels/ConnectedMachineViewVM.cs | 36 ++++++ .../ViewModels/MainViewVM.cs | 125 ++++++++++++--------- .../Views/ConnectedMachineView.xaml | 111 ++++++++++++++++++ .../Views/ConnectedMachineView.xaml.cs | 28 +++++ .../Views/MachineConnectionView.xaml | 2 +- 10 files changed, 281 insertions(+), 63 deletions(-) create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/ConnectedMachineViewVM.cs create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/ConnectedMachineView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/ConnectedMachineView.xaml.cs (limited to 'Software/Visual_Studio/MachineStudio') 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..2a5dcb3a0 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/EventLogging/DefaultEventLogger.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/EventLogging/DefaultEventLogger.cs @@ -206,7 +206,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/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 @@ - + { 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 @@ MessageBoxWindow.xaml + @@ -169,6 +170,9 @@ + + ConnectedMachineView.xaml + LoadingView.xaml @@ -234,6 +238,10 @@ MSBuild:Compile Designer + + Designer + MSBuild:Compile + Designer MSBuild:Compile 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(); SimpleIoc.Default.Register(); SimpleIoc.Default.Register(); + SimpleIoc.Default.Register(); SimpleIoc.Default.Register(); SimpleIoc.Default.Register(); @@ -133,6 +134,14 @@ namespace Tango.MachineStudio.UI } } + public ConnectedMachineViewVM ConnectedMachineViewVM + { + get + { + return ServiceLocator.Current.GetInstance(); + } + } + 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..f78cc15be 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs @@ -384,70 +384,42 @@ namespace Tango.MachineStudio.UI.ViewModels /// private void ConnectToMachine() { - _notificationProvider.ShowModalDialog(async (x) => + if (ApplicationManager.ConnectedMachine == null) { - if (x.SelectedMachine != null) + _notificationProvider.ShowModalDialog(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(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().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(async (vm) => + } + + if (x.SelectedMachine.RequiresAuthentication) { - if (vm.SelectedMachine != null) + _notificationProvider.ShowModalDialog(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().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) { @@ -458,15 +430,55 @@ namespace Tango.MachineStudio.UI.ViewModels InvalidateRelayCommands(); } - } - }); + }); + } + else + { + _notificationProvider.ShowModalDialog(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(ex.Message); + } + + InvalidateRelayCommands(); + } + } + }); + } + + InvalidateRelayCommands(); } InvalidateRelayCommands(); - } + }); + } + else + { + _notificationProvider.ShowModalDialog((x) => + { + DisconnectFromMachine(); + }); + } - InvalidateRelayCommands(); - }); + InvalidateRelayCommands(); } /// @@ -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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 +{ + /// + /// Interaction logic for ConnectedMachineView.xaml + /// + 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 @@ IP Address: - Organization: + Organization: -- cgit v1.3.1 From 9c0bad738d47742f39f2b02b240591653da6bc12 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Thu, 12 Apr 2018 12:47:19 +0300 Subject: Added changes to PMR hardware. Implemented Start Job and Record. Fixed issue with logs timeline event width. Implemented 'Event Resolved' event to event logs. --- Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 1572864 -> 1572864 bytes Software/PMR/Messages/Diagnostics/EventType.proto | 8 +- .../PMR/Messages/Hardware/HardwareDancer.proto | 8 + Software/PMR/Messages/Hardware/HardwareMotor.proto | 24 +- .../PMR/Messages/Hardware/HardwarePidControl.proto | 2 + .../Messages/Hardware/HardwarePidControlType.proto | 3 - Software/PMR/Messages/Printing/JobSpool.proto | 14 +- .../ViewModels/MainViewVM.cs | 4 +- .../Tango.MachineStudio.Developer.csproj | 4 + .../ViewModels/MainViewVM.cs | 40 ++- .../Views/JobView.xaml | 3 + .../Converters/StringToFirstLineConverter.cs | 23 ++ .../Tango.MachineStudio.Logging.csproj | 1 + .../Views/TimelineView.xaml | 3 +- .../Controls/HiveColorPickerControl.xaml.cs | 5 +- .../EventLogging/DefaultEventLogger.cs | 15 + .../Tango.BL/Entities/HardwareDancer.cs | 60 ++++ .../Tango.BL/Entities/HardwareMotor.cs | 168 +++------ .../Tango.BL/Entities/HardwarePidControl.cs | 20 ++ .../Tango.BL/Enumerations/ActionTypes.cs | 6 - .../Enumerations/HardwarePidControlTypes.cs | 6 - .../Visual_Studio/Tango.Core/ExtendedObject.cs | 8 + .../Tango.DAL.Remote/DB/HARDWARE_DANCERS.cs | 3 + .../Tango.DAL.Remote/DB/HARDWARE_MOTORS.cs | 17 +- .../Tango.DAL.Remote/DB/HARDWARE_PID_CONTROLS.cs | 1 + .../Tango.DAL.Remote/DB/RemoteADO.edmx | 63 ++-- .../Tango.DAL.Remote/DB/RemoteADO.edmx.diagram | 104 +++--- .../Tango.PMR/Diagnostics/EventType.cs | 17 +- .../Visual_Studio/Tango.PMR/ExtensionMethods.cs | 2 +- .../Tango.PMR/Hardware/HardwareDancer.cs | 122 ++++++- .../Tango.PMR/Hardware/HardwareMotor.cs | 389 ++++++++------------- .../Tango.PMR/Hardware/HardwarePidControl.cs | 36 +- .../Tango.PMR/Hardware/HardwarePidControlType.cs | 9 +- 34 files changed, 682 insertions(+), 506 deletions(-) create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Converters/StringToFirstLineConverter.cs (limited to 'Software/Visual_Studio/MachineStudio') diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index 5712f04b8..70a049035 100644 Binary files a/Software/DB/Tango.mdf and b/Software/DB/Tango.mdf differ diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf index 672af33ad..c563dabe9 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ diff --git a/Software/PMR/Messages/Diagnostics/EventType.proto b/Software/PMR/Messages/Diagnostics/EventType.proto index 487310ff0..9c29f708e 100644 --- a/Software/PMR/Messages/Diagnostics/EventType.proto +++ b/Software/PMR/Messages/Diagnostics/EventType.proto @@ -16,7 +16,7 @@ option java_package = "com.twine.tango.pmr.diagnostics"; enum EventType { - //Dancer overshot / Thread break sensor (Group = Thread Feeding System, Category = Error, Actions = Soft Visual Notification, Abort Running Job, Prevent Job Execution) + //Dancer overshot / Thread break sensor (Group = Thread Feeding System, Category = Error, Actions = Abort Running Job, Prevent Job Execution, Soft Visual Notification) ThreadBreak = 0; //Dancer not stable or got down (Group = Thread Feeding System, Category = Error, Actions = Abort Running Job, Soft Visual Notification, Prevent Job Execution) @@ -124,4 +124,10 @@ enum EventType //Notifies about application termination (Group = Application, Category = Info, Actions = ) ApplicationTerminated = 35; + //Occures when a diagnostics recording has been started (Group = Application, Category = Info, Actions = ) + RecordingStarted = 36; + + //Occures when a diagnostics recording has been stopped (Group = Application, Category = Info, Actions = ) + RecordingStopped = 37; + } diff --git a/Software/PMR/Messages/Hardware/HardwareDancer.proto b/Software/PMR/Messages/Hardware/HardwareDancer.proto index 5933b7cb4..103b16e58 100644 --- a/Software/PMR/Messages/Hardware/HardwareDancer.proto +++ b/Software/PMR/Messages/Hardware/HardwareDancer.proto @@ -28,4 +28,12 @@ message HardwareDancer int32 PulsePerMmSpring = 5; + int32 MaximalMovementMm = 6; + + int32 ZeroPoint = 7; + + int32 ResolutionBits = 8; + + int32 ArmLength = 9; + } diff --git a/Software/PMR/Messages/Hardware/HardwareMotor.proto b/Software/PMR/Messages/Hardware/HardwareMotor.proto index dbce226c7..d0162a34f 100644 --- a/Software/PMR/Messages/Hardware/HardwareMotor.proto +++ b/Software/PMR/Messages/Hardware/HardwareMotor.proto @@ -24,28 +24,22 @@ message HardwareMotor int32 MaxFrequency = 3; - int32 MinMicroStep = 4; + int32 SetMicroStep = 4; - int32 MaxMicroStep = 5; + int32 MicroStep = 5; - double LinearRatio = 6; + double MaxChangeSlope = 6; - int32 MedianPosition = 7; + double HighLengthMicroSecond = 7; - double CorrectionGain = 8; + bool SpeedMaster = 8; - double RatioToDryerSpeed = 9; + int32 PulsePerRound = 9; - double Kp = 10; + double PulleyRadius = 10; - double Ki = 11; + int32 ConfigWord = 11; - double Kd = 12; - - double ChangeSlope = 13; - - double HighLengthMicroSecond = 14; - - bool SpeedMaster = 15; + bool DirectionThreadWize = 12; } diff --git a/Software/PMR/Messages/Hardware/HardwarePidControl.proto b/Software/PMR/Messages/Hardware/HardwarePidControl.proto index dc1907bd5..001b5d328 100644 --- a/Software/PMR/Messages/Hardware/HardwarePidControl.proto +++ b/Software/PMR/Messages/Hardware/HardwarePidControl.proto @@ -52,4 +52,6 @@ message HardwarePidControl int32 AcHeatersHalfCycleTime = 17; + double ProportionalGain = 18; + } diff --git a/Software/PMR/Messages/Hardware/HardwarePidControlType.proto b/Software/PMR/Messages/Hardware/HardwarePidControlType.proto index 38785e85b..ca8a70bee 100644 --- a/Software/PMR/Messages/Hardware/HardwarePidControlType.proto +++ b/Software/PMR/Messages/Hardware/HardwarePidControlType.proto @@ -55,7 +55,4 @@ enum HardwarePidControlType //Winder Motor MotorWinder = 12; - //Dryer Heater 400 - DryerHeater400 = 13; - } diff --git a/Software/PMR/Messages/Printing/JobSpool.proto b/Software/PMR/Messages/Printing/JobSpool.proto index 03958c894..ba140aaaa 100644 --- a/Software/PMR/Messages/Printing/JobSpool.proto +++ b/Software/PMR/Messages/Printing/JobSpool.proto @@ -20,20 +20,20 @@ message JobSpool JobSpoolType JobSpoolType = 1; - double Length = 2; // the spool winding initial length in mm + double Length = 2; double Weight = 3; - double Diameter = 4; // in mm initial data required for speed calculation + double Diameter = 4; - int32 StartOffsetPulses = 5; // distance between the limit switch and the initial spool home position + int32 StartOffsetPulses = 5; - int32 BackingRate = 6; // the angle of the top of the spool + int32 BackingRate = 6; - int32 SegmentOffsetPulses = 7; // the spool winding initial length in mm + int32 SegmentOffsetPulses = 7; - int32 SpoolBottomBackingRate = 8;// the angle of the bottom of the spool + int32 BottomBackingRate = 8; - double NumberOfRotationPerPassage = 9; // how many rotations per spool passage + double RotationsPerPassage = 9; } 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..0459b3e24 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 @@ {cb0b0aa2-bb24-4bca-a720-45e397684e12} Tango.MachineStudio.Common + + {fc337a7f-1214-41d8-9992-78092a3b961e} + Tango.MachineStudio.DataCapture + {94f7acf8-55e1-4a02-b9bc-a818413fdbbf} Tango.MachineStudio.DB 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 @@ -555,6 +558,11 @@ namespace Tango.MachineStudio.Developer.ViewModels /// public RelayCommand StartJobCommand { get; set; } + /// + /// Gets or sets the start job and record command. + /// + public RelayCommand StartJobAndRecordCommand { get; set; } + /// /// Gets or sets the stop job command. /// @@ -642,6 +650,9 @@ namespace Tango.MachineStudio.Developer.ViewModels LogManager.Log("Initializing relay commands..."); + _dataCaptureVM = ServiceLocator.Current.GetInstance(); + _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(); + } + } + + /// + /// Starts the job and record using the data capture module. + /// + private void StartJobAndRecord() + { + _isRecording = true; + _dataCaptureVM.StartDiagnosticsRecording(); + StartJob(); + } + + /// + /// Stops the recording if in progress. + /// + 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 @@ START JOB + 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/Tango.MachineStudio.Logging.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Tango.MachineStudio.Logging.csproj index 4b817a124..b893dcb53 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,6 +87,7 @@ + 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 @@ + @@ -146,7 +147,7 @@ - + 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 2a5dcb3a0..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 } } + /// + /// Handles the connected machine events state provider EventsResolved event. + /// + /// The sender. + /// The events. + private void MachineEventsStateProvider_EventsResolved(object sender, IEnumerable events) + { + foreach (var ev in events) + { + Log(String.Format("Event '{0}' resolved.", ev.EventType.Name)); + } + } + #endregion #region Logging diff --git a/Software/Visual_Studio/Tango.BL/Entities/HardwareDancer.cs b/Software/Visual_Studio/Tango.BL/Entities/HardwareDancer.cs index 65997b195..e847eb7cb 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/HardwareDancer.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/HardwareDancer.cs @@ -136,6 +136,26 @@ namespace Tango.BL.Entities } + protected Int32 _maximalmovementmm; + /// + /// Gets or sets the hardwaredancer maximal movement mm. + /// + [Column("MAXIMAL_MOVEMENT_MM")] + + public Int32 MaximalMovementMm + { + get + { + return _maximalmovementmm; + } + + set + { + _maximalmovementmm = value; RaisePropertyChanged(nameof(MaximalMovementMm)); + } + + } + protected Int32 _zeropoint; /// /// Gets or sets the hardwaredancer zero point. @@ -156,6 +176,46 @@ namespace Tango.BL.Entities } + protected Int32 _resolutionbits; + /// + /// Gets or sets the hardwaredancer resolution bits. + /// + [Column("RESOLUTION_BITS")] + + public Int32 ResolutionBits + { + get + { + return _resolutionbits; + } + + set + { + _resolutionbits = value; RaisePropertyChanged(nameof(ResolutionBits)); + } + + } + + protected Int32 _armlength; + /// + /// Gets or sets the hardwaredancer arm length. + /// + [Column("ARM_LENGTH")] + + public Int32 ArmLength + { + get + { + return _armlength; + } + + set + { + _armlength = value; RaisePropertyChanged(nameof(ArmLength)); + } + + } + protected HardwareDancerType _hardwaredancertype; /// /// Gets or sets the hardwaredancer hardware dancer types. diff --git a/Software/Visual_Studio/Tango.BL/Entities/HardwareMotor.cs b/Software/Visual_Studio/Tango.BL/Entities/HardwareMotor.cs index ab61f4c02..75fb30549 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/HardwareMotor.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/HardwareMotor.cs @@ -96,242 +96,182 @@ namespace Tango.BL.Entities } - protected Int32 _minmicrostep; + protected Int32 _setmicrostep; /// - /// Gets or sets the hardwaremotor min micro step. + /// Gets or sets the hardwaremotor set micro step. /// - [Column("MIN_MICRO_STEP")] + [Column("SET_MICRO_STEP")] - public Int32 MinMicroStep + public Int32 SetMicroStep { get { - return _minmicrostep; + return _setmicrostep; } set { - _minmicrostep = value; RaisePropertyChanged(nameof(MinMicroStep)); + _setmicrostep = value; RaisePropertyChanged(nameof(SetMicroStep)); } } - protected Int32 _maxmicrostep; + protected Int32 _microstep; /// - /// Gets or sets the hardwaremotor max micro step. + /// Gets or sets the hardwaremotor micro step. /// - [Column("MAX_MICRO_STEP")] + [Column("MICRO_STEP")] - public Int32 MaxMicroStep + public Int32 MicroStep { get { - return _maxmicrostep; + return _microstep; } set { - _maxmicrostep = value; RaisePropertyChanged(nameof(MaxMicroStep)); + _microstep = value; RaisePropertyChanged(nameof(MicroStep)); } } - protected Double _linearratio; + protected Double _maxchangeslope; /// - /// Gets or sets the hardwaremotor linear ratio. + /// Gets or sets the hardwaremotor max change slope. /// - [Column("LINEAR_RATIO")] + [Column("MAX_CHANGE_SLOPE")] - public Double LinearRatio + public Double MaxChangeSlope { get { - return _linearratio; + return _maxchangeslope; } set { - _linearratio = value; RaisePropertyChanged(nameof(LinearRatio)); + _maxchangeslope = value; RaisePropertyChanged(nameof(MaxChangeSlope)); } } - protected Int32 _medianposition; - /// - /// Gets or sets the hardwaremotor median position. - /// - [Column("MEDIAN_POSITION")] - - public Int32 MedianPosition - { - get - { - return _medianposition; - } - - set - { - _medianposition = value; RaisePropertyChanged(nameof(MedianPosition)); - } - - } - - protected Double _correctiongain; - /// - /// Gets or sets the hardwaremotor correction gain. - /// - [Column("CORRECTION_GAIN")] - - public Double CorrectionGain - { - get - { - return _correctiongain; - } - - set - { - _correctiongain = value; RaisePropertyChanged(nameof(CorrectionGain)); - } - - } - - protected Double _ratiotodryerspeed; - /// - /// Gets or sets the hardwaremotor ratio to dryer speed. - /// - [Column("RATIO_TO_DRYER_SPEED")] - - public Double RatioToDryerSpeed - { - get - { - return _ratiotodryerspeed; - } - - set - { - _ratiotodryerspeed = value; RaisePropertyChanged(nameof(RatioToDryerSpeed)); - } - - } - - protected Double _kp; + protected Double _highlengthmicrosecond; /// - /// Gets or sets the hardwaremotor kp. + /// Gets or sets the hardwaremotor high length micro second. /// - [Column("KP")] + [Column("HIGH_LENGTH_MICRO_SECOND")] - public Double Kp + public Double HighLengthMicroSecond { get { - return _kp; + return _highlengthmicrosecond; } set { - _kp = value; RaisePropertyChanged(nameof(Kp)); + _highlengthmicrosecond = value; RaisePropertyChanged(nameof(HighLengthMicroSecond)); } } - protected Double _ki; + protected Boolean _speedmaster; /// - /// Gets or sets the hardwaremotor ki. + /// Gets or sets the hardwaremotor speed master. /// - [Column("KI")] + [Column("SPEED_MASTER")] - public Double Ki + public Boolean SpeedMaster { get { - return _ki; + return _speedmaster; } set { - _ki = value; RaisePropertyChanged(nameof(Ki)); + _speedmaster = value; RaisePropertyChanged(nameof(SpeedMaster)); } } - protected Double _kd; + protected Int32 _pulseperround; /// - /// Gets or sets the hardwaremotor kd. + /// Gets or sets the hardwaremotor pulse per round. /// - [Column("KD")] + [Column("PULSE_PER_ROUND")] - public Double Kd + public Int32 PulsePerRound { get { - return _kd; + return _pulseperround; } set { - _kd = value; RaisePropertyChanged(nameof(Kd)); + _pulseperround = value; RaisePropertyChanged(nameof(PulsePerRound)); } } - protected Double _changeslope; + protected Double _pulleyradius; /// - /// Gets or sets the hardwaremotor change slope. + /// Gets or sets the hardwaremotor pulley radius. /// - [Column("CHANGE_SLOPE")] + [Column("PULLEY_RADIUS")] - public Double ChangeSlope + public Double PulleyRadius { get { - return _changeslope; + return _pulleyradius; } set { - _changeslope = value; RaisePropertyChanged(nameof(ChangeSlope)); + _pulleyradius = value; RaisePropertyChanged(nameof(PulleyRadius)); } } - protected Double _highlengthmicrosecond; + protected Int32 _configword; /// - /// Gets or sets the hardwaremotor high length micro second. + /// Gets or sets the hardwaremotor config word. /// - [Column("HIGH_LENGTH_MICRO_SECOND")] + [Column("CONFIG_WORD")] - public Double HighLengthMicroSecond + public Int32 ConfigWord { get { - return _highlengthmicrosecond; + return _configword; } set { - _highlengthmicrosecond = value; RaisePropertyChanged(nameof(HighLengthMicroSecond)); + _configword = value; RaisePropertyChanged(nameof(ConfigWord)); } } - protected Boolean _speedmaster; + protected Boolean _directionthreadwize; /// - /// Gets or sets the hardwaremotor speed master. + /// Gets or sets the hardwaremotor direction thread wize. /// - [Column("SPEED_MASTER")] + [Column("DIRECTION_THREAD_WIZE")] - public Boolean SpeedMaster + public Boolean DirectionThreadWize { get { - return _speedmaster; + return _directionthreadwize; } set { - _speedmaster = value; RaisePropertyChanged(nameof(SpeedMaster)); + _directionthreadwize = value; RaisePropertyChanged(nameof(DirectionThreadWize)); } } diff --git a/Software/Visual_Studio/Tango.BL/Entities/HardwarePidControl.cs b/Software/Visual_Studio/Tango.BL/Entities/HardwarePidControl.cs index 04049ef3c..882bbbdf6 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/HardwarePidControl.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/HardwarePidControl.cs @@ -376,6 +376,26 @@ namespace Tango.BL.Entities } + protected Double _proportionalgain; + /// + /// Gets or sets the hardwarepidcontrol proportional gain. + /// + [Column("PROPORTIONAL_GAIN")] + + public Double ProportionalGain + { + get + { + return _proportionalgain; + } + + set + { + _proportionalgain = value; RaisePropertyChanged(nameof(ProportionalGain)); + } + + } + protected HardwarePidControlType _hardwarepidcontroltype; /// /// Gets or sets the hardwarepidcontrol hardware pid control types. diff --git a/Software/Visual_Studio/Tango.BL/Enumerations/ActionTypes.cs b/Software/Visual_Studio/Tango.BL/Enumerations/ActionTypes.cs index a95d35cd7..e8a46921c 100644 --- a/Software/Visual_Studio/Tango.BL/Enumerations/ActionTypes.cs +++ b/Software/Visual_Studio/Tango.BL/Enumerations/ActionTypes.cs @@ -39,11 +39,5 @@ namespace Tango.BL.Enumerations [Description("Displays a graceful notification to the user")] SoftVisualNotification = 4, - /// - /// (Displays a guide and requires confirmation) - /// - [Description("Displays a guide and requires confirmation")] - DisplayGuideAndConfirm = 5, - } } diff --git a/Software/Visual_Studio/Tango.BL/Enumerations/HardwarePidControlTypes.cs b/Software/Visual_Studio/Tango.BL/Enumerations/HardwarePidControlTypes.cs index 9f894db6d..389510997 100644 --- a/Software/Visual_Studio/Tango.BL/Enumerations/HardwarePidControlTypes.cs +++ b/Software/Visual_Studio/Tango.BL/Enumerations/HardwarePidControlTypes.cs @@ -87,11 +87,5 @@ namespace Tango.BL.Enumerations [Description("Winder Motor")] MotorWinder = 12, - /// - /// (Dryer Heater 400) - /// - [Description("Dryer Heater 400")] - DryerHeater400 = 13, - } } diff --git a/Software/Visual_Studio/Tango.Core/ExtendedObject.cs b/Software/Visual_Studio/Tango.Core/ExtendedObject.cs index 72120dc6b..be6302a4b 100644 --- a/Software/Visual_Studio/Tango.Core/ExtendedObject.cs +++ b/Software/Visual_Studio/Tango.Core/ExtendedObject.cs @@ -19,6 +19,12 @@ namespace Tango.Core [Serializable] public class ExtendedObject : INotifyPropertyChanged { + /// + /// Occurs when after InvalidateRelayCommands is called. + /// + [field: NonSerialized] + public event EventHandler RelayCommandsInvalidated; + /// /// Gets the default log manager. /// @@ -67,6 +73,8 @@ namespace Tango.Core value.RaiseCanExecuteChanged(); } } + + RelayCommandsInvalidated?.Invoke(this, new EventArgs()); })); } diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/HARDWARE_DANCERS.cs b/Software/Visual_Studio/Tango.DAL.Remote/DB/HARDWARE_DANCERS.cs index 21f6d2e84..7341ceec9 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/HARDWARE_DANCERS.cs +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/HARDWARE_DANCERS.cs @@ -23,7 +23,10 @@ namespace Tango.DAL.Remote.DB public double K { get; set; } public double X { get; set; } public int PULSE_PER_MM_SPRING { get; set; } + public int MAXIMAL_MOVEMENT_MM { get; set; } public int ZERO_POINT { get; set; } + public int RESOLUTION_BITS { get; set; } + public int ARM_LENGTH { get; set; } public virtual HARDWARE_DANCER_TYPES HARDWARE_DANCER_TYPES { get; set; } public virtual HARDWARE_VERSIONS HARDWARE_VERSIONS { get; set; } diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/HARDWARE_MOTORS.cs b/Software/Visual_Studio/Tango.DAL.Remote/DB/HARDWARE_MOTORS.cs index 9933e8a60..2124049f6 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/HARDWARE_MOTORS.cs +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/HARDWARE_MOTORS.cs @@ -21,18 +21,15 @@ namespace Tango.DAL.Remote.DB public string HARDWARE_VERSION_GUID { get; set; } public int MIN_FREQUENCY { get; set; } public int MAX_FREQUENCY { get; set; } - public int MIN_MICRO_STEP { get; set; } - public int MAX_MICRO_STEP { get; set; } - public double LINEAR_RATIO { get; set; } - public int MEDIAN_POSITION { get; set; } - public double CORRECTION_GAIN { get; set; } - public double RATIO_TO_DRYER_SPEED { get; set; } - public double KP { get; set; } - public double KI { get; set; } - public double KD { get; set; } - public double CHANGE_SLOPE { get; set; } + public int SET_MICRO_STEP { get; set; } + public int MICRO_STEP { get; set; } + public double MAX_CHANGE_SLOPE { get; set; } public double HIGH_LENGTH_MICRO_SECOND { get; set; } public bool SPEED_MASTER { get; set; } + public int PULSE_PER_ROUND { get; set; } + public double PULLEY_RADIUS { get; set; } + public int CONFIG_WORD { get; set; } + public bool DIRECTION_THREAD_WIZE { get; set; } public virtual HARDWARE_MOTOR_TYPES HARDWARE_MOTOR_TYPES { get; set; } public virtual HARDWARE_VERSIONS HARDWARE_VERSIONS { get; set; } diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/HARDWARE_PID_CONTROLS.cs b/Software/Visual_Studio/Tango.DAL.Remote/DB/HARDWARE_PID_CONTROLS.cs index 1145cc879..50b0efa47 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/HARDWARE_PID_CONTROLS.cs +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/HARDWARE_PID_CONTROLS.cs @@ -35,6 +35,7 @@ namespace Tango.DAL.Remote.DB public double PV_INPUT_FILTER_FACTOR_MODE { get; set; } public int OUTPUT_PROPORTIONAL_CYCLE_TIME { get; set; } public int AC_HEATERS__HALF_CYCLE_TIME { get; set; } + public double PROPORTIONAL_GAIN { get; set; } public virtual HARDWARE_PID_CONTROL_TYPES HARDWARE_PID_CONTROL_TYPES { get; set; } public virtual HARDWARE_VERSIONS HARDWARE_VERSIONS { get; set; } diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx index 7246e3a09..0d889d4ae 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx @@ -351,7 +351,10 @@ + + + @@ -375,18 +378,15 @@ - - - - - - - - - - + + + + + + + @@ -424,6 +424,7 @@ + @@ -2971,7 +2972,10 @@ + + + @@ -2998,18 +3002,15 @@ - - - - - - - - - - + + + + + + + @@ -3050,6 +3051,7 @@ + @@ -4945,7 +4947,10 @@ + + + @@ -4973,18 +4978,15 @@ + + + + - - - - - - - - - - + + + @@ -5010,6 +5012,7 @@ + diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram index 6dcfacb9d..d6f37da08 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram @@ -5,72 +5,72 @@ - - - - - - + + + + + + - + - + - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + - + - + - - - - - - - - - - - + + + + + + + + + + + - + - - - - - - - + + + + + + + diff --git a/Software/Visual_Studio/Tango.PMR/Diagnostics/EventType.cs b/Software/Visual_Studio/Tango.PMR/Diagnostics/EventType.cs index 1506aef18..a6b8e1776 100644 --- a/Software/Visual_Studio/Tango.PMR/Diagnostics/EventType.cs +++ b/Software/Visual_Studio/Tango.PMR/Diagnostics/EventType.cs @@ -22,7 +22,7 @@ namespace Tango.PMR.Diagnostics { static EventTypeReflection() { byte[] descriptorData = global::System.Convert.FromBase64String( string.Concat( - "Cg9FdmVudFR5cGUucHJvdG8SFVRhbmdvLlBNUi5EaWFnbm9zdGljcyqbBwoJ", + "Cg9FdmVudFR5cGUucHJvdG8SFVRhbmdvLlBNUi5EaWFnbm9zdGljcyrHBwoJ", "RXZlbnRUeXBlEg8KC1RocmVhZEJyZWFrEAASHwobVGhyZWFkVGVuc2lvbkNv", "bnRyb2xGYWlsdXJlEAESGgoWRmVlZGVyQ29uZUluc3VmZmljaWFudBACEhYK", "EldpbmRlckdlbmVyYWxFcnJvchADEhcKE1dpbmRlckNvbmVOb3RFeGlzdHMQ", @@ -43,8 +43,9 @@ namespace Tango.PMR.Diagnostics { "dWVzdFNlbnQQHRIUChBSZXNwb25zZVJlY2VpdmVkEB4SEQoNUmVxdWVzdEZh", "aWxlZBAfEhgKFEFwcGxpY2F0aW9uRXhjZXB0aW9uECASGgoWQXBwbGljYXRp", "b25JbmZvcm1hdGlvbhAhEhYKEkFwcGxpY2F0aW9uU3RhcnRlZBAiEhkKFUFw", - "cGxpY2F0aW9uVGVybWluYXRlZBAjQiEKH2NvbS50d2luZS50YW5nby5wbXIu", - "ZGlhZ25vc3RpY3NiBnByb3RvMw==")); + "cGxpY2F0aW9uVGVybWluYXRlZBAjEhQKEFJlY29yZGluZ1N0YXJ0ZWQQJBIU", + "ChBSZWNvcmRpbmdTdG9wcGVkECVCIQofY29tLnR3aW5lLnRhbmdvLnBtci5k", + "aWFnbm9zdGljc2IGcHJvdG8z")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, new pbr::GeneratedClrTypeInfo(new[] {typeof(global::Tango.PMR.Diagnostics.EventType), }, null)); @@ -55,7 +56,7 @@ namespace Tango.PMR.Diagnostics { #region Enums public enum EventType { /// - ///Dancer overshot / Thread break sensor (Group = Thread Feeding System, Category = Error, Actions = Soft Visual Notification, Abort Running Job, Prevent Job Execution) + ///Dancer overshot / Thread break sensor (Group = Thread Feeding System, Category = Error, Actions = Abort Running Job, Prevent Job Execution, Soft Visual Notification) /// [pbr::OriginalName("ThreadBreak")] ThreadBreak = 0, /// @@ -198,6 +199,14 @@ namespace Tango.PMR.Diagnostics { ///Notifies about application termination (Group = Application, Category = Info, Actions = ) /// [pbr::OriginalName("ApplicationTerminated")] ApplicationTerminated = 35, + /// + ///Occures when a diagnostics recording has been started (Group = Application, Category = Info, Actions = ) + /// + [pbr::OriginalName("RecordingStarted")] RecordingStarted = 36, + /// + ///Occures when a diagnostics recording has been stopped (Group = Application, Category = Info, Actions = ) + /// + [pbr::OriginalName("RecordingStopped")] RecordingStopped = 37, } #endregion diff --git a/Software/Visual_Studio/Tango.PMR/ExtensionMethods.cs b/Software/Visual_Studio/Tango.PMR/ExtensionMethods.cs index 114224dea..9707399d9 100644 --- a/Software/Visual_Studio/Tango.PMR/ExtensionMethods.cs +++ b/Software/Visual_Studio/Tango.PMR/ExtensionMethods.cs @@ -20,7 +20,7 @@ namespace Tango.PMR /// /// The value. /// - public static String ToOriginalName(this MessageType value) + public static String ToOriginalName(this MessageType value) { FieldInfo fi = value.GetType().GetField(value.ToString()); diff --git a/Software/Visual_Studio/Tango.PMR/Hardware/HardwareDancer.cs b/Software/Visual_Studio/Tango.PMR/Hardware/HardwareDancer.cs index 38c04472c..bd150cb85 100644 --- a/Software/Visual_Studio/Tango.PMR/Hardware/HardwareDancer.cs +++ b/Software/Visual_Studio/Tango.PMR/Hardware/HardwareDancer.cs @@ -23,15 +23,17 @@ namespace Tango.PMR.Hardware { byte[] descriptorData = global::System.Convert.FromBase64String( string.Concat( "ChRIYXJkd2FyZURhbmNlci5wcm90bxISVGFuZ28uUE1SLkhhcmR3YXJlGhhI", - "YXJkd2FyZURhbmNlclR5cGUucHJvdG8ilQEKDkhhcmR3YXJlRGFuY2VyEkIK", + "YXJkd2FyZURhbmNlclR5cGUucHJvdG8i7gEKDkhhcmR3YXJlRGFuY2VyEkIK", "EkhhcmR3YXJlRGFuY2VyVHlwZRgBIAEoDjImLlRhbmdvLlBNUi5IYXJkd2Fy", "ZS5IYXJkd2FyZURhbmNlclR5cGUSDwoHR3JhZHVhbBgCIAEoCBIJCgFLGAMg", - "ASgBEgkKAVgYBCABKAESGAoQUHVsc2VQZXJNbVNwcmluZxgFIAEoBUIeChxj", - "b20udHdpbmUudGFuZ28ucG1yLmhhcmR3YXJlYgZwcm90bzM=")); + "ASgBEgkKAVgYBCABKAESGAoQUHVsc2VQZXJNbVNwcmluZxgFIAEoBRIZChFN", + "YXhpbWFsTW92ZW1lbnRNbRgGIAEoBRIRCglaZXJvUG9pbnQYByABKAUSFgoO", + "UmVzb2x1dGlvbkJpdHMYCCABKAUSEQoJQXJtTGVuZ3RoGAkgASgFQh4KHGNv", + "bS50d2luZS50YW5nby5wbXIuaGFyZHdhcmViBnByb3RvMw==")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { global::Tango.PMR.Hardware.HardwareDancerTypeReflection.Descriptor, }, new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.Hardware.HardwareDancer), global::Tango.PMR.Hardware.HardwareDancer.Parser, new[]{ "HardwareDancerType", "Gradual", "K", "X", "PulsePerMmSpring" }, null, null, null) + new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.Hardware.HardwareDancer), global::Tango.PMR.Hardware.HardwareDancer.Parser, new[]{ "HardwareDancerType", "Gradual", "K", "X", "PulsePerMmSpring", "MaximalMovementMm", "ZeroPoint", "ResolutionBits", "ArmLength" }, null, null, null) })); } #endregion @@ -67,6 +69,10 @@ namespace Tango.PMR.Hardware { k_ = other.k_; x_ = other.x_; pulsePerMmSpring_ = other.pulsePerMmSpring_; + maximalMovementMm_ = other.maximalMovementMm_; + zeroPoint_ = other.zeroPoint_; + resolutionBits_ = other.resolutionBits_; + armLength_ = other.armLength_; } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -129,6 +135,50 @@ namespace Tango.PMR.Hardware { } } + /// Field number for the "MaximalMovementMm" field. + public const int MaximalMovementMmFieldNumber = 6; + private int maximalMovementMm_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int MaximalMovementMm { + get { return maximalMovementMm_; } + set { + maximalMovementMm_ = value; + } + } + + /// Field number for the "ZeroPoint" field. + public const int ZeroPointFieldNumber = 7; + private int zeroPoint_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int ZeroPoint { + get { return zeroPoint_; } + set { + zeroPoint_ = value; + } + } + + /// Field number for the "ResolutionBits" field. + public const int ResolutionBitsFieldNumber = 8; + private int resolutionBits_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int ResolutionBits { + get { return resolutionBits_; } + set { + resolutionBits_ = value; + } + } + + /// Field number for the "ArmLength" field. + public const int ArmLengthFieldNumber = 9; + private int armLength_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int ArmLength { + get { return armLength_; } + set { + armLength_ = value; + } + } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as HardwareDancer); @@ -147,6 +197,10 @@ namespace Tango.PMR.Hardware { if (K != other.K) return false; if (X != other.X) return false; if (PulsePerMmSpring != other.PulsePerMmSpring) return false; + if (MaximalMovementMm != other.MaximalMovementMm) return false; + if (ZeroPoint != other.ZeroPoint) return false; + if (ResolutionBits != other.ResolutionBits) return false; + if (ArmLength != other.ArmLength) return false; return true; } @@ -158,6 +212,10 @@ namespace Tango.PMR.Hardware { if (K != 0D) hash ^= K.GetHashCode(); if (X != 0D) hash ^= X.GetHashCode(); if (PulsePerMmSpring != 0) hash ^= PulsePerMmSpring.GetHashCode(); + if (MaximalMovementMm != 0) hash ^= MaximalMovementMm.GetHashCode(); + if (ZeroPoint != 0) hash ^= ZeroPoint.GetHashCode(); + if (ResolutionBits != 0) hash ^= ResolutionBits.GetHashCode(); + if (ArmLength != 0) hash ^= ArmLength.GetHashCode(); return hash; } @@ -188,6 +246,22 @@ namespace Tango.PMR.Hardware { output.WriteRawTag(40); output.WriteInt32(PulsePerMmSpring); } + if (MaximalMovementMm != 0) { + output.WriteRawTag(48); + output.WriteInt32(MaximalMovementMm); + } + if (ZeroPoint != 0) { + output.WriteRawTag(56); + output.WriteInt32(ZeroPoint); + } + if (ResolutionBits != 0) { + output.WriteRawTag(64); + output.WriteInt32(ResolutionBits); + } + if (ArmLength != 0) { + output.WriteRawTag(72); + output.WriteInt32(ArmLength); + } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -208,6 +282,18 @@ namespace Tango.PMR.Hardware { if (PulsePerMmSpring != 0) { size += 1 + pb::CodedOutputStream.ComputeInt32Size(PulsePerMmSpring); } + if (MaximalMovementMm != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(MaximalMovementMm); + } + if (ZeroPoint != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(ZeroPoint); + } + if (ResolutionBits != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(ResolutionBits); + } + if (ArmLength != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(ArmLength); + } return size; } @@ -231,6 +317,18 @@ namespace Tango.PMR.Hardware { if (other.PulsePerMmSpring != 0) { PulsePerMmSpring = other.PulsePerMmSpring; } + if (other.MaximalMovementMm != 0) { + MaximalMovementMm = other.MaximalMovementMm; + } + if (other.ZeroPoint != 0) { + ZeroPoint = other.ZeroPoint; + } + if (other.ResolutionBits != 0) { + ResolutionBits = other.ResolutionBits; + } + if (other.ArmLength != 0) { + ArmLength = other.ArmLength; + } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -261,6 +359,22 @@ namespace Tango.PMR.Hardware { PulsePerMmSpring = input.ReadInt32(); break; } + case 48: { + MaximalMovementMm = input.ReadInt32(); + break; + } + case 56: { + ZeroPoint = input.ReadInt32(); + break; + } + case 64: { + ResolutionBits = input.ReadInt32(); + break; + } + case 72: { + ArmLength = input.ReadInt32(); + break; + } } } } diff --git a/Software/Visual_Studio/Tango.PMR/Hardware/HardwareMotor.cs b/Software/Visual_Studio/Tango.PMR/Hardware/HardwareMotor.cs index eb6743fba..093270524 100644 --- a/Software/Visual_Studio/Tango.PMR/Hardware/HardwareMotor.cs +++ b/Software/Visual_Studio/Tango.PMR/Hardware/HardwareMotor.cs @@ -23,20 +23,19 @@ namespace Tango.PMR.Hardware { byte[] descriptorData = global::System.Convert.FromBase64String( string.Concat( "ChNIYXJkd2FyZU1vdG9yLnByb3RvEhJUYW5nby5QTVIuSGFyZHdhcmUaF0hh", - "cmR3YXJlTW90b3JUeXBlLnByb3RvIvYCCg1IYXJkd2FyZU1vdG9yEkAKEUhh", + "cmR3YXJlTW90b3JUeXBlLnByb3RvItACCg1IYXJkd2FyZU1vdG9yEkAKEUhh", "cmR3YXJlTW90b3JUeXBlGAEgASgOMiUuVGFuZ28uUE1SLkhhcmR3YXJlLkhh", "cmR3YXJlTW90b3JUeXBlEhQKDE1pbkZyZXF1ZW5jeRgCIAEoBRIUCgxNYXhG", - "cmVxdWVuY3kYAyABKAUSFAoMTWluTWljcm9TdGVwGAQgASgFEhQKDE1heE1p", - "Y3JvU3RlcBgFIAEoBRITCgtMaW5lYXJSYXRpbxgGIAEoARIWCg5NZWRpYW5Q", - "b3NpdGlvbhgHIAEoBRIWCg5Db3JyZWN0aW9uR2FpbhgIIAEoARIZChFSYXRp", - "b1RvRHJ5ZXJTcGVlZBgJIAEoARIKCgJLcBgKIAEoARIKCgJLaRgLIAEoARIK", - "CgJLZBgMIAEoARITCgtDaGFuZ2VTbG9wZRgNIAEoARIdChVIaWdoTGVuZ3Ro", - "TWljcm9TZWNvbmQYDiABKAESEwoLU3BlZWRNYXN0ZXIYDyABKAhCHgocY29t", - "LnR3aW5lLnRhbmdvLnBtci5oYXJkd2FyZWIGcHJvdG8z")); + "cmVxdWVuY3kYAyABKAUSFAoMU2V0TWljcm9TdGVwGAQgASgFEhEKCU1pY3Jv", + "U3RlcBgFIAEoBRIWCg5NYXhDaGFuZ2VTbG9wZRgGIAEoARIdChVIaWdoTGVu", + "Z3RoTWljcm9TZWNvbmQYByABKAESEwoLU3BlZWRNYXN0ZXIYCCABKAgSFQoN", + "UHVsc2VQZXJSb3VuZBgJIAEoBRIUCgxQdWxsZXlSYWRpdXMYCiABKAESEgoK", + "Q29uZmlnV29yZBgLIAEoBRIbChNEaXJlY3Rpb25UaHJlYWRXaXplGAwgASgI", + "Qh4KHGNvbS50d2luZS50YW5nby5wbXIuaGFyZHdhcmViBnByb3RvMw==")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { global::Tango.PMR.Hardware.HardwareMotorTypeReflection.Descriptor, }, new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.Hardware.HardwareMotor), global::Tango.PMR.Hardware.HardwareMotor.Parser, new[]{ "HardwareMotorType", "MinFrequency", "MaxFrequency", "MinMicroStep", "MaxMicroStep", "LinearRatio", "MedianPosition", "CorrectionGain", "RatioToDryerSpeed", "Kp", "Ki", "Kd", "ChangeSlope", "HighLengthMicroSecond", "SpeedMaster" }, null, null, null) + new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.Hardware.HardwareMotor), global::Tango.PMR.Hardware.HardwareMotor.Parser, new[]{ "HardwareMotorType", "MinFrequency", "MaxFrequency", "SetMicroStep", "MicroStep", "MaxChangeSlope", "HighLengthMicroSecond", "SpeedMaster", "PulsePerRound", "PulleyRadius", "ConfigWord", "DirectionThreadWize" }, null, null, null) })); } #endregion @@ -70,18 +69,15 @@ namespace Tango.PMR.Hardware { hardwareMotorType_ = other.hardwareMotorType_; minFrequency_ = other.minFrequency_; maxFrequency_ = other.maxFrequency_; - minMicroStep_ = other.minMicroStep_; - maxMicroStep_ = other.maxMicroStep_; - linearRatio_ = other.linearRatio_; - medianPosition_ = other.medianPosition_; - correctionGain_ = other.correctionGain_; - ratioToDryerSpeed_ = other.ratioToDryerSpeed_; - kp_ = other.kp_; - ki_ = other.ki_; - kd_ = other.kd_; - changeSlope_ = other.changeSlope_; + setMicroStep_ = other.setMicroStep_; + microStep_ = other.microStep_; + maxChangeSlope_ = other.maxChangeSlope_; highLengthMicroSecond_ = other.highLengthMicroSecond_; speedMaster_ = other.speedMaster_; + pulsePerRound_ = other.pulsePerRound_; + pulleyRadius_ = other.pulleyRadius_; + configWord_ = other.configWord_; + directionThreadWize_ = other.directionThreadWize_; } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -122,135 +118,102 @@ namespace Tango.PMR.Hardware { } } - /// Field number for the "MinMicroStep" field. - public const int MinMicroStepFieldNumber = 4; - private int minMicroStep_; + /// Field number for the "SetMicroStep" field. + public const int SetMicroStepFieldNumber = 4; + private int setMicroStep_; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int MinMicroStep { - get { return minMicroStep_; } + public int SetMicroStep { + get { return setMicroStep_; } set { - minMicroStep_ = value; + setMicroStep_ = value; } } - /// Field number for the "MaxMicroStep" field. - public const int MaxMicroStepFieldNumber = 5; - private int maxMicroStep_; + /// Field number for the "MicroStep" field. + public const int MicroStepFieldNumber = 5; + private int microStep_; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int MaxMicroStep { - get { return maxMicroStep_; } + public int MicroStep { + get { return microStep_; } set { - maxMicroStep_ = value; + microStep_ = value; } } - /// Field number for the "LinearRatio" field. - public const int LinearRatioFieldNumber = 6; - private double linearRatio_; + /// Field number for the "MaxChangeSlope" field. + public const int MaxChangeSlopeFieldNumber = 6; + private double maxChangeSlope_; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double LinearRatio { - get { return linearRatio_; } + public double MaxChangeSlope { + get { return maxChangeSlope_; } set { - linearRatio_ = value; + maxChangeSlope_ = value; } } - /// Field number for the "MedianPosition" field. - public const int MedianPositionFieldNumber = 7; - private int medianPosition_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int MedianPosition { - get { return medianPosition_; } - set { - medianPosition_ = value; - } - } - - /// Field number for the "CorrectionGain" field. - public const int CorrectionGainFieldNumber = 8; - private double correctionGain_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double CorrectionGain { - get { return correctionGain_; } - set { - correctionGain_ = value; - } - } - - /// Field number for the "RatioToDryerSpeed" field. - public const int RatioToDryerSpeedFieldNumber = 9; - private double ratioToDryerSpeed_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double RatioToDryerSpeed { - get { return ratioToDryerSpeed_; } - set { - ratioToDryerSpeed_ = value; - } - } - - /// Field number for the "Kp" field. - public const int KpFieldNumber = 10; - private double kp_; + /// Field number for the "HighLengthMicroSecond" field. + public const int HighLengthMicroSecondFieldNumber = 7; + private double highLengthMicroSecond_; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double Kp { - get { return kp_; } + public double HighLengthMicroSecond { + get { return highLengthMicroSecond_; } set { - kp_ = value; + highLengthMicroSecond_ = value; } } - /// Field number for the "Ki" field. - public const int KiFieldNumber = 11; - private double ki_; + /// Field number for the "SpeedMaster" field. + public const int SpeedMasterFieldNumber = 8; + private bool speedMaster_; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double Ki { - get { return ki_; } + public bool SpeedMaster { + get { return speedMaster_; } set { - ki_ = value; + speedMaster_ = value; } } - /// Field number for the "Kd" field. - public const int KdFieldNumber = 12; - private double kd_; + /// Field number for the "PulsePerRound" field. + public const int PulsePerRoundFieldNumber = 9; + private int pulsePerRound_; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double Kd { - get { return kd_; } + public int PulsePerRound { + get { return pulsePerRound_; } set { - kd_ = value; + pulsePerRound_ = value; } } - /// Field number for the "ChangeSlope" field. - public const int ChangeSlopeFieldNumber = 13; - private double changeSlope_; + /// Field number for the "PulleyRadius" field. + public const int PulleyRadiusFieldNumber = 10; + private double pulleyRadius_; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double ChangeSlope { - get { return changeSlope_; } + public double PulleyRadius { + get { return pulleyRadius_; } set { - changeSlope_ = value; + pulleyRadius_ = value; } } - /// Field number for the "HighLengthMicroSecond" field. - public const int HighLengthMicroSecondFieldNumber = 14; - private double highLengthMicroSecond_; + /// Field number for the "ConfigWord" field. + public const int ConfigWordFieldNumber = 11; + private int configWord_; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public double HighLengthMicroSecond { - get { return highLengthMicroSecond_; } + public int ConfigWord { + get { return configWord_; } set { - highLengthMicroSecond_ = value; + configWord_ = value; } } - /// Field number for the "SpeedMaster" field. - public const int SpeedMasterFieldNumber = 15; - private bool speedMaster_; + /// Field number for the "DirectionThreadWize" field. + public const int DirectionThreadWizeFieldNumber = 12; + private bool directionThreadWize_; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public bool SpeedMaster { - get { return speedMaster_; } + public bool DirectionThreadWize { + get { return directionThreadWize_; } set { - speedMaster_ = value; + directionThreadWize_ = value; } } @@ -270,18 +233,15 @@ namespace Tango.PMR.Hardware { if (HardwareMotorType != other.HardwareMotorType) return false; if (MinFrequency != other.MinFrequency) return false; if (MaxFrequency != other.MaxFrequency) return false; - if (MinMicroStep != other.MinMicroStep) return false; - if (MaxMicroStep != other.MaxMicroStep) return false; - if (LinearRatio != other.LinearRatio) return false; - if (MedianPosition != other.MedianPosition) return false; - if (CorrectionGain != other.CorrectionGain) return false; - if (RatioToDryerSpeed != other.RatioToDryerSpeed) return false; - if (Kp != other.Kp) return false; - if (Ki != other.Ki) return false; - if (Kd != other.Kd) return false; - if (ChangeSlope != other.ChangeSlope) return false; + if (SetMicroStep != other.SetMicroStep) return false; + if (MicroStep != other.MicroStep) return false; + if (MaxChangeSlope != other.MaxChangeSlope) return false; if (HighLengthMicroSecond != other.HighLengthMicroSecond) return false; if (SpeedMaster != other.SpeedMaster) return false; + if (PulsePerRound != other.PulsePerRound) return false; + if (PulleyRadius != other.PulleyRadius) return false; + if (ConfigWord != other.ConfigWord) return false; + if (DirectionThreadWize != other.DirectionThreadWize) return false; return true; } @@ -291,18 +251,15 @@ namespace Tango.PMR.Hardware { if (HardwareMotorType != 0) hash ^= HardwareMotorType.GetHashCode(); if (MinFrequency != 0) hash ^= MinFrequency.GetHashCode(); if (MaxFrequency != 0) hash ^= MaxFrequency.GetHashCode(); - if (MinMicroStep != 0) hash ^= MinMicroStep.GetHashCode(); - if (MaxMicroStep != 0) hash ^= MaxMicroStep.GetHashCode(); - if (LinearRatio != 0D) hash ^= LinearRatio.GetHashCode(); - if (MedianPosition != 0) hash ^= MedianPosition.GetHashCode(); - if (CorrectionGain != 0D) hash ^= CorrectionGain.GetHashCode(); - if (RatioToDryerSpeed != 0D) hash ^= RatioToDryerSpeed.GetHashCode(); - if (Kp != 0D) hash ^= Kp.GetHashCode(); - if (Ki != 0D) hash ^= Ki.GetHashCode(); - if (Kd != 0D) hash ^= Kd.GetHashCode(); - if (ChangeSlope != 0D) hash ^= ChangeSlope.GetHashCode(); + if (SetMicroStep != 0) hash ^= SetMicroStep.GetHashCode(); + if (MicroStep != 0) hash ^= MicroStep.GetHashCode(); + if (MaxChangeSlope != 0D) hash ^= MaxChangeSlope.GetHashCode(); if (HighLengthMicroSecond != 0D) hash ^= HighLengthMicroSecond.GetHashCode(); if (SpeedMaster != false) hash ^= SpeedMaster.GetHashCode(); + if (PulsePerRound != 0) hash ^= PulsePerRound.GetHashCode(); + if (PulleyRadius != 0D) hash ^= PulleyRadius.GetHashCode(); + if (ConfigWord != 0) hash ^= ConfigWord.GetHashCode(); + if (DirectionThreadWize != false) hash ^= DirectionThreadWize.GetHashCode(); return hash; } @@ -325,53 +282,41 @@ namespace Tango.PMR.Hardware { output.WriteRawTag(24); output.WriteInt32(MaxFrequency); } - if (MinMicroStep != 0) { + if (SetMicroStep != 0) { output.WriteRawTag(32); - output.WriteInt32(MinMicroStep); + output.WriteInt32(SetMicroStep); } - if (MaxMicroStep != 0) { + if (MicroStep != 0) { output.WriteRawTag(40); - output.WriteInt32(MaxMicroStep); + output.WriteInt32(MicroStep); } - if (LinearRatio != 0D) { + if (MaxChangeSlope != 0D) { output.WriteRawTag(49); - output.WriteDouble(LinearRatio); + output.WriteDouble(MaxChangeSlope); } - if (MedianPosition != 0) { - output.WriteRawTag(56); - output.WriteInt32(MedianPosition); + if (HighLengthMicroSecond != 0D) { + output.WriteRawTag(57); + output.WriteDouble(HighLengthMicroSecond); } - if (CorrectionGain != 0D) { - output.WriteRawTag(65); - output.WriteDouble(CorrectionGain); + if (SpeedMaster != false) { + output.WriteRawTag(64); + output.WriteBool(SpeedMaster); } - if (RatioToDryerSpeed != 0D) { - output.WriteRawTag(73); - output.WriteDouble(RatioToDryerSpeed); + if (PulsePerRound != 0) { + output.WriteRawTag(72); + output.WriteInt32(PulsePerRound); } - if (Kp != 0D) { + if (PulleyRadius != 0D) { output.WriteRawTag(81); - output.WriteDouble(Kp); - } - if (Ki != 0D) { - output.WriteRawTag(89); - output.WriteDouble(Ki); + output.WriteDouble(PulleyRadius); } - if (Kd != 0D) { - output.WriteRawTag(97); - output.WriteDouble(Kd); + if (ConfigWord != 0) { + output.WriteRawTag(88); + output.WriteInt32(ConfigWord); } - if (ChangeSlope != 0D) { - output.WriteRawTag(105); - output.WriteDouble(ChangeSlope); - } - if (HighLengthMicroSecond != 0D) { - output.WriteRawTag(113); - output.WriteDouble(HighLengthMicroSecond); - } - if (SpeedMaster != false) { - output.WriteRawTag(120); - output.WriteBool(SpeedMaster); + if (DirectionThreadWize != false) { + output.WriteRawTag(96); + output.WriteBool(DirectionThreadWize); } } @@ -387,40 +332,31 @@ namespace Tango.PMR.Hardware { if (MaxFrequency != 0) { size += 1 + pb::CodedOutputStream.ComputeInt32Size(MaxFrequency); } - if (MinMicroStep != 0) { - size += 1 + pb::CodedOutputStream.ComputeInt32Size(MinMicroStep); - } - if (MaxMicroStep != 0) { - size += 1 + pb::CodedOutputStream.ComputeInt32Size(MaxMicroStep); - } - if (LinearRatio != 0D) { - size += 1 + 8; - } - if (MedianPosition != 0) { - size += 1 + pb::CodedOutputStream.ComputeInt32Size(MedianPosition); + if (SetMicroStep != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(SetMicroStep); } - if (CorrectionGain != 0D) { - size += 1 + 8; + if (MicroStep != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(MicroStep); } - if (RatioToDryerSpeed != 0D) { + if (MaxChangeSlope != 0D) { size += 1 + 8; } - if (Kp != 0D) { + if (HighLengthMicroSecond != 0D) { size += 1 + 8; } - if (Ki != 0D) { - size += 1 + 8; + if (SpeedMaster != false) { + size += 1 + 1; } - if (Kd != 0D) { - size += 1 + 8; + if (PulsePerRound != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(PulsePerRound); } - if (ChangeSlope != 0D) { + if (PulleyRadius != 0D) { size += 1 + 8; } - if (HighLengthMicroSecond != 0D) { - size += 1 + 8; + if (ConfigWord != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(ConfigWord); } - if (SpeedMaster != false) { + if (DirectionThreadWize != false) { size += 1 + 1; } return size; @@ -440,35 +376,14 @@ namespace Tango.PMR.Hardware { if (other.MaxFrequency != 0) { MaxFrequency = other.MaxFrequency; } - if (other.MinMicroStep != 0) { - MinMicroStep = other.MinMicroStep; - } - if (other.MaxMicroStep != 0) { - MaxMicroStep = other.MaxMicroStep; + if (other.SetMicroStep != 0) { + SetMicroStep = other.SetMicroStep; } - if (other.LinearRatio != 0D) { - LinearRatio = other.LinearRatio; + if (other.MicroStep != 0) { + MicroStep = other.MicroStep; } - if (other.MedianPosition != 0) { - MedianPosition = other.MedianPosition; - } - if (other.CorrectionGain != 0D) { - CorrectionGain = other.CorrectionGain; - } - if (other.RatioToDryerSpeed != 0D) { - RatioToDryerSpeed = other.RatioToDryerSpeed; - } - if (other.Kp != 0D) { - Kp = other.Kp; - } - if (other.Ki != 0D) { - Ki = other.Ki; - } - if (other.Kd != 0D) { - Kd = other.Kd; - } - if (other.ChangeSlope != 0D) { - ChangeSlope = other.ChangeSlope; + if (other.MaxChangeSlope != 0D) { + MaxChangeSlope = other.MaxChangeSlope; } if (other.HighLengthMicroSecond != 0D) { HighLengthMicroSecond = other.HighLengthMicroSecond; @@ -476,6 +391,18 @@ namespace Tango.PMR.Hardware { if (other.SpeedMaster != false) { SpeedMaster = other.SpeedMaster; } + if (other.PulsePerRound != 0) { + PulsePerRound = other.PulsePerRound; + } + if (other.PulleyRadius != 0D) { + PulleyRadius = other.PulleyRadius; + } + if (other.ConfigWord != 0) { + ConfigWord = other.ConfigWord; + } + if (other.DirectionThreadWize != false) { + DirectionThreadWize = other.DirectionThreadWize; + } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -499,51 +426,39 @@ namespace Tango.PMR.Hardware { break; } case 32: { - MinMicroStep = input.ReadInt32(); + SetMicroStep = input.ReadInt32(); break; } case 40: { - MaxMicroStep = input.ReadInt32(); + MicroStep = input.ReadInt32(); break; } case 49: { - LinearRatio = input.ReadDouble(); + MaxChangeSlope = input.ReadDouble(); break; } - case 56: { - MedianPosition = input.ReadInt32(); + case 57: { + HighLengthMicroSecond = input.ReadDouble(); break; } - case 65: { - CorrectionGain = input.ReadDouble(); + case 64: { + SpeedMaster = input.ReadBool(); break; } - case 73: { - RatioToDryerSpeed = input.ReadDouble(); + case 72: { + PulsePerRound = input.ReadInt32(); break; } case 81: { - Kp = input.ReadDouble(); - break; - } - case 89: { - Ki = input.ReadDouble(); - break; - } - case 97: { - Kd = input.ReadDouble(); + PulleyRadius = input.ReadDouble(); break; } - case 105: { - ChangeSlope = input.ReadDouble(); + case 88: { + ConfigWord = input.ReadInt32(); break; } - case 113: { - HighLengthMicroSecond = input.ReadDouble(); - break; - } - case 120: { - SpeedMaster = input.ReadBool(); + case 96: { + DirectionThreadWize = input.ReadBool(); break; } } diff --git a/Software/Visual_Studio/Tango.PMR/Hardware/HardwarePidControl.cs b/Software/Visual_Studio/Tango.PMR/Hardware/HardwarePidControl.cs index 658f4463c..022e0c5b9 100644 --- a/Software/Visual_Studio/Tango.PMR/Hardware/HardwarePidControl.cs +++ b/Software/Visual_Studio/Tango.PMR/Hardware/HardwarePidControl.cs @@ -23,7 +23,7 @@ namespace Tango.PMR.Hardware { byte[] descriptorData = global::System.Convert.FromBase64String( string.Concat( "ChhIYXJkd2FyZVBpZENvbnRyb2wucHJvdG8SElRhbmdvLlBNUi5IYXJkd2Fy", - "ZRocSGFyZHdhcmVQaWRDb250cm9sVHlwZS5wcm90byLcBAoSSGFyZHdhcmVQ", + "ZRocSGFyZHdhcmVQaWRDb250cm9sVHlwZS5wcm90byL2BAoSSGFyZHdhcmVQ", "aWRDb250cm9sEkoKFkhhcmR3YXJlUGlkQ29udHJvbFR5cGUYASABKA4yKi5U", "YW5nby5QTVIuSGFyZHdhcmUuSGFyZHdhcmVQaWRDb250cm9sVHlwZRIkChxP", "dXRwdXRQcm9wb3J0aW9uYWxQb3dlckxpbWl0GAIgASgBEh4KFk91dHB1dFBy", @@ -37,12 +37,12 @@ namespace Tango.PMR.Hardware { "IAEoARIjChtQcm9jZXNzVmFyaWFibGVTYW1wbGluZ1JhdGUYDiABKAESHwoX", "UHZJbnB1dEZpbHRlckZhY3Rvck1vZGUYDyABKAESIwobT3V0cHV0UHJvcG9y", "dGlvbmFsQ3ljbGVUaW1lGBAgASgFEh4KFkFjSGVhdGVyc0hhbGZDeWNsZVRp", - "bWUYESABKAVCHgocY29tLnR3aW5lLnRhbmdvLnBtci5oYXJkd2FyZWIGcHJv", - "dG8z")); + "bWUYESABKAUSGAoQUHJvcG9ydGlvbmFsR2FpbhgSIAEoAUIeChxjb20udHdp", + "bmUudGFuZ28ucG1yLmhhcmR3YXJlYgZwcm90bzM=")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { global::Tango.PMR.Hardware.HardwarePidControlTypeReflection.Descriptor, }, new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.Hardware.HardwarePidControl), global::Tango.PMR.Hardware.HardwarePidControl.Parser, new[]{ "HardwarePidControlType", "OutputProportionalPowerLimit", "OutputProportionalBand", "IntegralTime", "DerivativeTime", "SensorCorrectionAdjustment", "SensorMinValue", "SensorMaxValue", "SetPointRampRateorSoftStartRamp", "SetPointControlOutputRate", "ControlOutputType", "SsrControlOutputType", "OutputOnOffHysteresisValue", "ProcessVariableSamplingRate", "PvInputFilterFactorMode", "OutputProportionalCycleTime", "AcHeatersHalfCycleTime" }, null, null, null) + new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.Hardware.HardwarePidControl), global::Tango.PMR.Hardware.HardwarePidControl.Parser, new[]{ "HardwarePidControlType", "OutputProportionalPowerLimit", "OutputProportionalBand", "IntegralTime", "DerivativeTime", "SensorCorrectionAdjustment", "SensorMinValue", "SensorMaxValue", "SetPointRampRateorSoftStartRamp", "SetPointControlOutputRate", "ControlOutputType", "SsrControlOutputType", "OutputOnOffHysteresisValue", "ProcessVariableSamplingRate", "PvInputFilterFactorMode", "OutputProportionalCycleTime", "AcHeatersHalfCycleTime", "ProportionalGain" }, null, null, null) })); } #endregion @@ -90,6 +90,7 @@ namespace Tango.PMR.Hardware { pvInputFilterFactorMode_ = other.pvInputFilterFactorMode_; outputProportionalCycleTime_ = other.outputProportionalCycleTime_; acHeatersHalfCycleTime_ = other.acHeatersHalfCycleTime_; + proportionalGain_ = other.proportionalGain_; } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -284,6 +285,17 @@ namespace Tango.PMR.Hardware { } } + /// Field number for the "ProportionalGain" field. + public const int ProportionalGainFieldNumber = 18; + private double proportionalGain_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double ProportionalGain { + get { return proportionalGain_; } + set { + proportionalGain_ = value; + } + } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as HardwarePidControl); @@ -314,6 +326,7 @@ namespace Tango.PMR.Hardware { if (PvInputFilterFactorMode != other.PvInputFilterFactorMode) return false; if (OutputProportionalCycleTime != other.OutputProportionalCycleTime) return false; if (AcHeatersHalfCycleTime != other.AcHeatersHalfCycleTime) return false; + if (ProportionalGain != other.ProportionalGain) return false; return true; } @@ -337,6 +350,7 @@ namespace Tango.PMR.Hardware { if (PvInputFilterFactorMode != 0D) hash ^= PvInputFilterFactorMode.GetHashCode(); if (OutputProportionalCycleTime != 0) hash ^= OutputProportionalCycleTime.GetHashCode(); if (AcHeatersHalfCycleTime != 0) hash ^= AcHeatersHalfCycleTime.GetHashCode(); + if (ProportionalGain != 0D) hash ^= ProportionalGain.GetHashCode(); return hash; } @@ -415,6 +429,10 @@ namespace Tango.PMR.Hardware { output.WriteRawTag(136, 1); output.WriteInt32(AcHeatersHalfCycleTime); } + if (ProportionalGain != 0D) { + output.WriteRawTag(145, 1); + output.WriteDouble(ProportionalGain); + } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -471,6 +489,9 @@ namespace Tango.PMR.Hardware { if (AcHeatersHalfCycleTime != 0) { size += 2 + pb::CodedOutputStream.ComputeInt32Size(AcHeatersHalfCycleTime); } + if (ProportionalGain != 0D) { + size += 2 + 8; + } return size; } @@ -530,6 +551,9 @@ namespace Tango.PMR.Hardware { if (other.AcHeatersHalfCycleTime != 0) { AcHeatersHalfCycleTime = other.AcHeatersHalfCycleTime; } + if (other.ProportionalGain != 0D) { + ProportionalGain = other.ProportionalGain; + } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -608,6 +632,10 @@ namespace Tango.PMR.Hardware { AcHeatersHalfCycleTime = input.ReadInt32(); break; } + case 145: { + ProportionalGain = input.ReadDouble(); + break; + } } } } diff --git a/Software/Visual_Studio/Tango.PMR/Hardware/HardwarePidControlType.cs b/Software/Visual_Studio/Tango.PMR/Hardware/HardwarePidControlType.cs index fe6f6ab97..ec7ae44c1 100644 --- a/Software/Visual_Studio/Tango.PMR/Hardware/HardwarePidControlType.cs +++ b/Software/Visual_Studio/Tango.PMR/Hardware/HardwarePidControlType.cs @@ -23,14 +23,13 @@ namespace Tango.PMR.Hardware { byte[] descriptorData = global::System.Convert.FromBase64String( string.Concat( "ChxIYXJkd2FyZVBpZENvbnRyb2xUeXBlLnByb3RvEhJUYW5nby5QTVIuSGFy", - "ZHdhcmUqnAIKFkhhcmR3YXJlUGlkQ29udHJvbFR5cGUSFAoQRHJ5ZXJIZWF0", + "ZHdhcmUqiAIKFkhhcmR3YXJlUGlkQ29udHJvbFR5cGUSFAoQRHJ5ZXJIZWF0", "ZXIxMDAwdxAAEhQKEERyeWVySGVhdGVyMjAwdzEQARIUChBEcnllckhlYXRl", "cjIwMHcyEAISEAoMSGVhZEhlYXRlcloxEAMSEAoMSGVhZEhlYXRlcloyEAQS", "EAoMSGVhZEhlYXRlclozEAUSEAoMSGVhZEhlYXRlclo0EAYSDwoLTWl4ZXJI", "ZWF0ZXIQBxIQCgxXYXN0ZUNvbnRyb2wQCBIOCgpNb3RvckRyeWVyEAkSDwoL", "TW90b3JGZWVkZXIQChIPCgtNb3RvclBvb2xlchALEg8KC01vdG9yV2luZGVy", - "EAwSEgoORHJ5ZXJIZWF0ZXI0MDAQDUIeChxjb20udHdpbmUudGFuZ28ucG1y", - "LmhhcmR3YXJlYgZwcm90bzM=")); + "EAxCHgocY29tLnR3aW5lLnRhbmdvLnBtci5oYXJkd2FyZWIGcHJvdG8z")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, new pbr::GeneratedClrTypeInfo(new[] {typeof(global::Tango.PMR.Hardware.HardwarePidControlType), }, null)); @@ -92,10 +91,6 @@ namespace Tango.PMR.Hardware { ///Winder Motor /// [pbr::OriginalName("MotorWinder")] MotorWinder = 12, - /// - ///Dryer Heater 400 - /// - [pbr::OriginalName("DryerHeater400")] DryerHeater400 = 13, } #endregion -- cgit v1.3.1 From 9ff8293b603f72c5faa8d238b3005524c31cc5a8 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Sun, 15 Apr 2018 11:43:30 +0300 Subject: Redundant. --- Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 1572864 -> 1572864 bytes .../Tango.MachineStudio.Developer.csproj | 6 ------ .../Modules/Tango.MachineStudio.Developer/bip.wav | Bin 161420 -> 0 bytes .../Tango.MachineStudio.Developer/error.wav | Bin 146748 -> 0 bytes 5 files changed, 6 deletions(-) delete mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/bip.wav delete mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/error.wav (limited to 'Software/Visual_Studio/MachineStudio') diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index 70a049035..2f31f82ed 100644 Binary files a/Software/DB/Tango.mdf and b/Software/DB/Tango.mdf differ diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf index c563dabe9..730aa6519 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ 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 0459b3e24..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 @@ -354,14 +354,8 @@ - - - - - - \ No newline at end of file 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 Binary files a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/bip.wav and /dev/null 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 Binary files a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/error.wav and /dev/null differ -- cgit v1.3.1 From ca293b80c52a54c73251fbf3cd50741fb5653ae9 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Sun, 15 Apr 2018 19:51:07 +0300 Subject: Lots Of Work ! --- Software/DB/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/Tango_log.ldf | Bin 1572864 -> 1572864 bytes Software/Graphics/application-logs.png | Bin 0 -> 16421 bytes Software/Graphics/embedded-logs.png | Bin 0 -> 19230 bytes Software/Graphics/events.png | Bin 0 -> 32989 bytes .../Images/application-logs.png | Bin 0 -> 16421 bytes .../Images/embedded-logs.png | Bin 0 -> 19230 bytes .../Tango.MachineStudio.Logging/Images/events.png | Bin 0 -> 32989 bytes .../Navigation/LoggingNavigationView.cs | 3 + .../Parsing/ApplicationLogFileParser.cs | 64 ++++ .../Parsing/EmbeddedLogFileParser.cs | 70 ++++ .../Parsing/ILogFileParser.cs | 15 + .../Tango.MachineStudio.Logging/Parsing/LogFile.cs | 15 + .../Tango.MachineStudio.Logging.csproj | 31 +- .../ViewModelLocator.cs | 24 +- .../ViewModels/ApplicationLogsViewVM.cs | 99 +++++ .../ViewModels/EventsViewVM.cs | 195 ++++++++++ .../ViewModels/HomeViewVM.cs | 28 ++ .../ViewModels/MainViewVM.cs | 192 ---------- .../Views/ApplicationLogsView.xaml | 196 ++++++++++ .../Views/ApplicationLogsView.xaml.cs | 28 ++ .../Views/EventsView.xaml | 9 +- .../Views/HomeView.xaml | 87 +++++ .../Views/HomeView.xaml.cs | 28 ++ .../Views/MainView.xaml | 8 +- .../Views/TimelineWrapperView.xaml | 2 +- .../ViewModels/MachineTechViewVM.cs | 400 ++++++++++++--------- .../Tango.MachineStudio.UI/App.xaml.cs | 6 +- .../Modules/DefaultStudioModuleLoader.cs | 7 +- .../ViewModels/MainViewVM.cs | 6 +- .../Tango.MachineStudio.UI/Views/MainView.xaml.cs | 5 + .../Tango.Integration/Operation/EmbeddedLogItem.cs | 2 +- .../Tango.Integration/Operation/MachineOperator.cs | 2 +- .../Tango.Logging/ExceptionLogItem.cs | 11 +- Software/Visual_Studio/Tango.Logging/FileLogger.cs | 17 +- .../Visual_Studio/Tango.Logging/LogItemBase.cs | 22 +- Software/Visual_Studio/Tango.Logging/LogManager.cs | 3 + .../Visual_Studio/Tango.Logging/MessageLogItem.cs | 20 +- .../Visual_Studio/Tango.UnitTesting/Logging_TST.cs | 33 ++ .../Tango.UnitTesting/Tango.UnitTesting.csproj | 5 + .../Visual_Studio/Tango.Visuals/Fader/Fader.xaml | 64 ++-- 41 files changed, 1268 insertions(+), 429 deletions(-) create mode 100644 Software/Graphics/application-logs.png create mode 100644 Software/Graphics/embedded-logs.png create mode 100644 Software/Graphics/events.png create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Images/application-logs.png create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Images/embedded-logs.png create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Images/events.png create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Parsing/ApplicationLogFileParser.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Parsing/EmbeddedLogFileParser.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Parsing/ILogFileParser.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Parsing/LogFile.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/ApplicationLogsViewVM.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/EventsViewVM.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/HomeViewVM.cs delete mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/MainViewVM.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Views/ApplicationLogsView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Views/ApplicationLogsView.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Views/HomeView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Views/HomeView.xaml.cs create mode 100644 Software/Visual_Studio/Tango.UnitTesting/Logging_TST.cs (limited to 'Software/Visual_Studio/MachineStudio') diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf index 2f31f82ed..da2332e36 100644 Binary files a/Software/DB/Tango.mdf and b/Software/DB/Tango.mdf differ diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf index 730aa6519..081a49b7e 100644 Binary files a/Software/DB/Tango_log.ldf and b/Software/DB/Tango_log.ldf differ diff --git a/Software/Graphics/application-logs.png b/Software/Graphics/application-logs.png new file mode 100644 index 000000000..584379dc8 Binary files /dev/null and b/Software/Graphics/application-logs.png differ diff --git a/Software/Graphics/embedded-logs.png b/Software/Graphics/embedded-logs.png new file mode 100644 index 000000000..86cd56486 Binary files /dev/null and b/Software/Graphics/embedded-logs.png differ diff --git a/Software/Graphics/events.png b/Software/Graphics/events.png new file mode 100644 index 000000000..437679cd6 Binary files /dev/null and b/Software/Graphics/events.png differ 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 Binary files /dev/null and b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Images/application-logs.png 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 Binary files /dev/null and b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Images/embedded-logs.png 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 Binary files /dev/null and b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/Images/events.png 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 + { + public List GetLogFiles() + { + List logFiles = new List(); + + 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 Parse(LogFile logFile) + { + List logItems = new List(); + + 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 + { + public List GetLogFiles() + { + List logFiles = new List(); + + 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 Parse(LogFile logFile) + { + List logItems = new List(); + + 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 + { + List Parse(LogFile logFile); + + List 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 b893dcb53..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 @@ -93,17 +93,29 @@ + + + + + - + + EventDetailsView.xaml + + ApplicationLogsView.xaml + EventsView.xaml + + HomeView.xaml + MainView.xaml @@ -189,10 +201,18 @@ Designer MSBuild:Compile + + MSBuild:Compile + Designer + Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile @@ -209,5 +229,14 @@ + + + + + + + + + \ 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(); + SimpleIoc.Default.Register(); + SimpleIoc.Default.Register(); + SimpleIoc.Default.Register(); SimpleIoc.Default.Unregister(); SimpleIoc.Default.Register(() => new LoggingNavigationManager()); } - public static MainViewVM MainViewVM + public static EventsViewVM EventsViewVM { get { - return ServiceLocator.Current.GetInstance(); + return ServiceLocator.Current.GetInstance(); + } + } + + public static ApplicationLogsViewVM ApplicationLogsViewVM + { + get + { + return ServiceLocator.Current.GetInstance(); + } + } + + public static HomeViewVM HomeViewVM + { + get + { + return ServiceLocator.Current.GetInstance(); } } } 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 _logFiles; + + private ObservableCollection _logs; + public ObservableCollection Logs + { + get { return _logs; } + set { _logs = value; RaisePropertyChangedAuto(); } + } + + private ObservableCollection _dates; + public ObservableCollection 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(_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 logs = new List(); + + 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/EventsViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/EventsViewVM.cs new file mode 100644 index 000000000..361adef01 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/EventsViewVM.cs @@ -0,0 +1,195 @@ +using GalaSoft.MvvmLight.Messaging; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL; +using Tango.BL.Entities; +using Tango.Core.Commands; +using Tango.MachineStudio.Common.EventLogging; +using Tango.MachineStudio.Common.Messages; +using Tango.MachineStudio.Common.Notifications; +using Tango.MachineStudio.Common.StudioApplication; +using Tango.MachineStudio.Logging.Navigation; +using Tango.MachineStudio.Logging.Views; +using Tango.SharedUI; + +namespace Tango.MachineStudio.Logging.ViewModels +{ + public class EventsViewVM : ViewModel + { + private INotificationProvider _notification; + private IStudioApplicationManager _application; + private IEventLogger _eventLogger; + private ObservableCollection _realTimeEvents; + private Machine _connectedMachine; + private LoggingNavigationManager _navigation; + + private Machine _selectedMachine; + public Machine SelectedMachine + { + get { return _selectedMachine; } + set { _selectedMachine = value; RaisePropertyChangedAuto(); OnSelectedMachineChanged(); } + } + + private ObservableCollection _events; + public ObservableCollection Events + { + get { return _events; } + set { _events = value; RaisePropertyChangedAuto(); } + } + + private MachinesEvent _selectedEvent; + public MachinesEvent SelectedEvent + { + get { return _selectedEvent; } + set { _selectedEvent = value; RaisePropertyChangedAuto(); OnSelectedEventChanged(); } + } + + private ObservableCollection _dates; + public ObservableCollection 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(); } + } + + private TimelineViewVM _timelineViewVM; + + public TimelineViewVM TimelineViewVM + { + get { return _timelineViewVM; } + set { _timelineViewVM = value; RaisePropertyChangedAuto(); } + } + + public RelayCommand DisplayTimelineCommand { get; set; } + + public RelayCommand NavigateToEventsCommand { get; set; } + + public RelayCommand NavigateToHomeCommand { get; set; } + + public EventsViewVM(INotificationProvider notification, IEventLogger eventLogger, IStudioApplicationManager application, LoggingNavigationManager navigation) + { + TimelineViewVM = new TimelineViewVM(notification); + + _navigation = navigation; + _application = application; + _notification = notification; + _eventLogger = eventLogger; + _realTimeEvents = new ObservableCollection(); + _eventLogger.NewLog += _eventLogger_NewLog; + + RegisterMessage(OnMachineConnectionChanged); + DisplayTimelineCommand = new RelayCommand(DisplayTimeline); + NavigateToEventsCommand = new RelayCommand(() => _navigation.NavigateTo(LoggingNavigationView.EventsView)); + NavigateToHomeCommand = new RelayCommand(() => _navigation.NavigateTo(LoggingNavigationView.HomeView)); + } + + private void OnMachineConnectionChanged(MachineConnectionChangedMessage msg) + { + if (msg.Machine != null) + { + _connectedMachine = ObservablesEntitiesAdapter.Instance.Machines.SingleOrDefault(x => x.SerialNumber == msg.Machine.SerialNumber); + SelectedMachine = _connectedMachine; + } + else + { + _connectedMachine = null; + } + } + + private void _eventLogger_NewLog(object sender, MachinesEvent machineEvent) + { + InvokeUI(() => + { + _realTimeEvents.Insert(0, machineEvent); + }); + } + + private void OnSelectedMachineChanged() + { + if (SelectedMachine != null) + { + Dates = new ObservableCollection(); + + if (SelectedMachine == _connectedMachine) + { + IsRealTime = true; + } + + foreach (var day in SelectedMachine.MachinesEvents.GroupBy(x => x.DateTime.DayOfYear).Select(x => x.First().DateTime).OrderByDescending(x => x)) + { + Dates.Add(day); + } + + MinDate = Dates.Min(); + MaxDate = Dates.Max(); + + SelectedDate = Dates.FirstOrDefault(); + } + } + + private void OnSelectedDateChanged() + { + if (SelectedDate != null && SelectedMachine != null) + { + if (IsRealTime) + { + Events = _realTimeEvents; + } + else + { + Events = SelectedMachine.MachinesEvents.Where(x => x.DateTime.DayOfYear == SelectedDate.Date.DayOfYear).OrderByDescending(x => x.DateTime).ToObservableCollection(); + } + } + } + + private void OnSelectedEventChanged() + { + if (SelectedEvent != null && SelectedEvent.Type != BL.Enumerations.EventTypes.ApplicationStarted) + { + _notification.ShowModalDialog(new EventDetailsViewVM(SelectedEvent), (x) => { }, () => { }); + } + } + + private void DisplayTimeline(MachinesEvent ev) + { + var events = Events.OrderBy(x => x.DateTime).SkipWhile(x => x != ev).Skip(1).TakeWhile(x => x.DateTime > ev.DateTime && x.Type != BL.Enumerations.EventTypes.ApplicationStarted).ToObservableCollection(); + events.Insert(0, ev); + + TimelineViewVM.Initialize(events.ToList()); + + _navigation.NavigateTo(LoggingNavigationView.TimelineView); + } + } +} 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 NavigateToCommand { get; set; } + + public HomeViewVM(LoggingNavigationManager navigation) + { + _navigation = navigation; + + NavigateToCommand = new RelayCommand((view) => + { + navigation.NavigateTo((LoggingNavigationView)Enum.Parse(typeof(LoggingNavigationView), view)); + }); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/MainViewVM.cs deleted file mode 100644 index e5121e709..000000000 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/MainViewVM.cs +++ /dev/null @@ -1,192 +0,0 @@ -using GalaSoft.MvvmLight.Messaging; -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.BL; -using Tango.BL.Entities; -using Tango.Core.Commands; -using Tango.MachineStudio.Common.EventLogging; -using Tango.MachineStudio.Common.Messages; -using Tango.MachineStudio.Common.Notifications; -using Tango.MachineStudio.Common.StudioApplication; -using Tango.MachineStudio.Logging.Navigation; -using Tango.MachineStudio.Logging.Views; -using Tango.SharedUI; - -namespace Tango.MachineStudio.Logging.ViewModels -{ - public class MainViewVM : ViewModel - { - private INotificationProvider _notification; - private IStudioApplicationManager _application; - private IEventLogger _eventLogger; - private ObservableCollection _realTimeEvents; - private Machine _connectedMachine; - private LoggingNavigationManager _navigation; - - private Machine _selectedMachine; - public Machine SelectedMachine - { - get { return _selectedMachine; } - set { _selectedMachine = value; RaisePropertyChangedAuto(); OnSelectedMachineChanged(); } - } - - private ObservableCollection _events; - public ObservableCollection Events - { - get { return _events; } - set { _events = value; RaisePropertyChangedAuto(); } - } - - private MachinesEvent _selectedEvent; - public MachinesEvent SelectedEvent - { - get { return _selectedEvent; } - set { _selectedEvent = value; RaisePropertyChangedAuto(); OnSelectedEventChanged(); } - } - - private ObservableCollection _dates; - public ObservableCollection 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(); } - } - - private TimelineViewVM _timelineViewVM; - - public TimelineViewVM TimelineViewVM - { - get { return _timelineViewVM; } - set { _timelineViewVM = value; RaisePropertyChangedAuto(); } - } - - public RelayCommand DisplayTimelineCommand { get; set; } - - public RelayCommand NavigateToEventsCommand { get; set; } - - public MainViewVM(INotificationProvider notification, IEventLogger eventLogger, IStudioApplicationManager application, LoggingNavigationManager navigation) - { - TimelineViewVM = new TimelineViewVM(notification); - - _navigation = navigation; - _application = application; - _notification = notification; - _eventLogger = eventLogger; - _realTimeEvents = new ObservableCollection(); - _eventLogger.NewLog += _eventLogger_NewLog; - - RegisterMessage(OnMachineConnectionChanged); - DisplayTimelineCommand = new RelayCommand(DisplayTimeline); - NavigateToEventsCommand = new RelayCommand(() => _navigation.NavigateTo(LoggingNavigationView.EventsView)); - } - - private void OnMachineConnectionChanged(MachineConnectionChangedMessage msg) - { - if (msg.Machine != null) - { - _connectedMachine = ObservablesEntitiesAdapter.Instance.Machines.SingleOrDefault(x => x.SerialNumber == msg.Machine.SerialNumber); - SelectedMachine = _connectedMachine; - } - else - { - _connectedMachine = null; - } - } - - private void _eventLogger_NewLog(object sender, MachinesEvent machineEvent) - { - InvokeUI(() => - { - _realTimeEvents.Insert(0, machineEvent); - }); - } - - private void OnSelectedMachineChanged() - { - if (SelectedMachine != null) - { - Dates = new ObservableCollection(); - - if (SelectedMachine == _connectedMachine) - { - IsRealTime = true; - } - - foreach (var day in SelectedMachine.MachinesEvents.GroupBy(x => x.DateTime.DayOfYear).Select(x => x.First().DateTime).OrderByDescending(x => x)) - { - Dates.Add(day); - } - - MinDate = Dates.Min(); - MaxDate = Dates.Max(); - - SelectedDate = Dates.FirstOrDefault(); - } - } - - private void OnSelectedDateChanged() - { - if (SelectedDate != null && SelectedMachine != null) - { - if (IsRealTime) - { - Events = _realTimeEvents; - } - else - { - Events = SelectedMachine.MachinesEvents.Where(x => x.DateTime.DayOfYear == SelectedDate.Date.DayOfYear).OrderByDescending(x => x.DateTime).ToObservableCollection(); - } - } - } - - private void OnSelectedEventChanged() - { - if (SelectedEvent != null && SelectedEvent.Type != BL.Enumerations.EventTypes.ApplicationStarted) - { - _notification.ShowModalDialog(new EventDetailsViewVM(SelectedEvent), (x) => { }, () => { }); - } - } - - private void DisplayTimeline(MachinesEvent ev) - { - var events = Events.OrderBy(x => x.DateTime).SkipWhile(x => x != ev).Skip(1).TakeWhile(x => x.DateTime > ev.DateTime && x.Type != BL.Enumerations.EventTypes.ApplicationStarted).ToObservableCollection(); - events.Insert(0, ev); - - TimelineViewVM.Initialize(events.ToList()); - - _navigation.NavigateTo(LoggingNavigationView.TimelineView); - } - } -} 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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Real-Time + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 +{ + /// + /// Interaction logic for EventsView.xaml + /// + 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}"> @@ -56,6 +56,13 @@ + + 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 @@ + + + + + + + + + + Machine Studio logs information from multiple source. + + + + • Machine Events are predefined events that occurs only when a set of predefined actions have occurred (e.g 'Job executed', 'Thread Break'). + + + • Application Logs are the standard machine studio logs which can be used to trace issues in code. + + + • Embedded Logs are logs transmitted from the machine's embedded device software. + + + + + + + + + + + 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 +{ + /// + /// Interaction logic for HomeView.xaml + /// + 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}"> + + + + + + 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}"> 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 /// /// The application manager. /// The notification provider. - 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(); _multiControllers = new Dictionary(); 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(item); + var editor = CreateElement(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; - item.HomingMaximumProgress = response.MaxProgress; - item.HomingProgress = response.Progress; + MachineOperator.StartMotorHoming(new MotorHomingRequest() + { + Code = item.TechMotor.Code + }) + .Subscribe((response) => + { - }, () => + 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) + { + 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, - Direction = MotorDirection.Backward, - }))); + 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) => + // { + + // item.HomingMaximumProgress = response.Message.MaxProgress; + // item.HomingProgress = response.Message.Progress; + + // }, () => + // { + + // item.IsHoming = false; + // item.IsHomingCompleted = true; + + // }); + //} + //else if (action == MotorActionType.HomingStopped) + //{ + // await MachineOperator.StopMotorHoming(new MotorAbortHomingRequest() + // { + // Code = item.TechMotor.Code, + // }); + + // item.IsHoming = false; + //} } - else if (action == MotorActionType.BackwardReleased) + catch (Exception ex) { - await Task.WhenAll(item.TechMotors.Select(motor => MachineOperator.StopMotorJogging(new MotorAbortJoggingRequest() - { - Code = motor.Code, - }))); + 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)); } - //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.Message.MaxProgress; - // item.HomingProgress = response.Message.Progress; - - // }, () => - // { - - // item.IsHoming = false; - // item.IsHomingCompleted = true; - - // }); - //} - //else if (action == MotorActionType.HomingStopped) - //{ - // await MachineOperator.StopMotorHoming(new MotorAbortHomingRequest() - // { - // Code = item.TechMotor.Code, - // }); - - // item.IsHoming = false; - //} }; } @@ -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)); } }; } + /// + /// Checks the machine operator. + /// + /// No machine connected. + 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.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/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/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs index f78cc15be..8e451cdce 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs @@ -425,7 +425,7 @@ namespace Tango.MachineStudio.UI.ViewModels { 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(); @@ -455,7 +455,7 @@ namespace Tango.MachineStudio.UI.ViewModels { 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(); @@ -472,7 +472,7 @@ namespace Tango.MachineStudio.UI.ViewModels } else { - _notificationProvider.ShowModalDialog((x) => + _notificationProvider.ShowModalDialog((x) => { DisconnectFromMachine(); }); 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().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(); diff --git a/Software/Visual_Studio/Tango.Integration/Operation/EmbeddedLogItem.cs b/Software/Visual_Studio/Tango.Integration/Operation/EmbeddedLogItem.cs index 192cb576f..1e29858ea 100644 --- a/Software/Visual_Studio/Tango.Integration/Operation/EmbeddedLogItem.cs +++ b/Software/Visual_Studio/Tango.Integration/Operation/EmbeddedLogItem.cs @@ -24,7 +24,7 @@ namespace Tango.Integration.Operation public override string ToString() { - return String.Format("[{0}] [{1}] [{2}] [Line {3}] [ModuleId {4}] [Filter {5}]: {6}", TimeStamp.ToString("HH:mm:ss.ff"), DebugLogResponse.Category, Path.GetFileName(DebugLogResponse.FileName), DebugLogResponse.LineNumber, DebugLogResponse.ModuleId, DebugLogResponse.Filter, DebugLogResponse.Message); + return String.Format("[{0}] [{1}] [{2}] [{3}] [{4}] [{5}]: {6}", TimeStamp.ToString("HH:mm:ss.ff"), DebugLogResponse.Category, Path.GetFileName(DebugLogResponse.FileName), DebugLogResponse.LineNumber, DebugLogResponse.ModuleId, DebugLogResponse.Filter, DebugLogResponse.Message); } } } diff --git a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs index 88fc04090..9af0d9f49 100644 --- a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs +++ b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs @@ -136,7 +136,7 @@ namespace Tango.Integration.Operation String folder = SettingsManager.DefaultFolder + "\\embedded logs"; Directory.CreateDirectory(folder); - FileLogger fileLogger = new FileLogger(Path.Combine(folder, String.Format("{1}-{0:yyyy-MM-dd_hh-mm-ss}.log", DateTime.Now, "embedded"))) { Enabled = true }; + FileLogger fileLogger = new FileLogger(Path.Combine(folder, String.Format("{1}-{0:dd-MM-yyyy_HH-mm-ss}.log", DateTime.Now, "embedded"))) { Enabled = true }; _embeddedLogger.RegisterLogger(fileLogger); } } diff --git a/Software/Visual_Studio/Tango.Logging/ExceptionLogItem.cs b/Software/Visual_Studio/Tango.Logging/ExceptionLogItem.cs index cc8980cdc..de8485249 100644 --- a/Software/Visual_Studio/Tango.Logging/ExceptionLogItem.cs +++ b/Software/Visual_Studio/Tango.Logging/ExceptionLogItem.cs @@ -25,10 +25,13 @@ namespace Tango.Logging /// /// Gets the log message. /// - /// - public override string GetMessage() + public override string Message { - return Exception.Message; + get + { + return Exception.Message; + } + set { } } /// @@ -36,7 +39,7 @@ namespace Tango.Logging /// public override string ToString() { - return String.Format("[{0}] [{6}] [{1}] [{2}] [Line {3}]: {4}{5}", TimeStamp.ToString("HH:mm:ss.ff"), Path.GetFileNameWithoutExtension(CallerFile), CallerMethodName, CallerLineNumber, Description, Environment.NewLine + Exception.FlattenException(), Category); + return String.Format("[{0}] [{6}] [{1}] [{2}] [{3}]: {4}{5}", TimeStamp.ToString("HH:mm:ss.ff"), GetRelativeCallerFilePath(), CallerMethodName, CallerLineNumber, Description, Environment.NewLine + Exception.FlattenException(), Category); } } diff --git a/Software/Visual_Studio/Tango.Logging/FileLogger.cs b/Software/Visual_Studio/Tango.Logging/FileLogger.cs index e104b59b9..215b1d9ac 100644 --- a/Software/Visual_Studio/Tango.Logging/FileLogger.cs +++ b/Software/Visual_Studio/Tango.Logging/FileLogger.cs @@ -13,21 +13,32 @@ namespace Tango.Logging /// public class FileLogger : ILogger { + /// + /// Gets the logs folder. + /// + public static String DefaultLogsFolder { get; private set; } /// /// Gets or sets the log file. /// public String LogFile { get; private set; } + /// + /// Initializes the class. + /// + static FileLogger() + { + DefaultLogsFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Twine", "Tango", "logs"); + } + /// /// Initializes a new instance of the class. /// public FileLogger() { _isEnabled = true; - String logsFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Twine", "Tango", "logs"); - Directory.CreateDirectory(logsFolder); - LogFile = Path.Combine(logsFolder, string.Format("{1}-{0:dd-MM-yyyy_hh-mm-ss}.log", DateTime.Now, Path.GetFileNameWithoutExtension(System.AppDomain.CurrentDomain.FriendlyName))); + Directory.CreateDirectory(DefaultLogsFolder); + LogFile = Path.Combine(DefaultLogsFolder, string.Format("{1}-{0:dd-MM-yyyy_HH-mm-ss}.log", DateTime.Now, Path.GetFileNameWithoutExtension(AppDomain.CurrentDomain.FriendlyName))); } /// diff --git a/Software/Visual_Studio/Tango.Logging/LogItemBase.cs b/Software/Visual_Studio/Tango.Logging/LogItemBase.cs index 85451488a..6b282b6ab 100644 --- a/Software/Visual_Studio/Tango.Logging/LogItemBase.cs +++ b/Software/Visual_Studio/Tango.Logging/LogItemBase.cs @@ -11,6 +11,13 @@ namespace Tango.Logging /// public abstract class LogItemBase { + private static String base_path; + + /// + /// Gets or sets the assembly. + /// + public String CallerAssembly { get; set; } + /// /// Gets or sets the caller method adding the exception. /// @@ -39,12 +46,23 @@ namespace Tango.Logging /// /// Gets the log message. /// - /// - public abstract String GetMessage(); + public abstract String Message { get; set; } /// /// Returns a formatted string of the log item. /// public abstract override String ToString(); + + protected String GetRelativeCallerFilePath() + { + if (base_path == null) + { + int index = CallerFile.IndexOf("Visual_Studio") + "Visual_Studio".Length + 1; + String relative = CallerFile.Substring(index, CallerFile.Length - index); + base_path = CallerFile.Replace(relative, ""); + } + + return CallerFile.Replace(base_path, ""); + } } } diff --git a/Software/Visual_Studio/Tango.Logging/LogManager.cs b/Software/Visual_Studio/Tango.Logging/LogManager.cs index c654b646f..804fc14c5 100644 --- a/Software/Visual_Studio/Tango.Logging/LogManager.cs +++ b/Software/Visual_Studio/Tango.Logging/LogManager.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; +using System.Reflection; using System.Runtime.CompilerServices; using System.Text; using System.Threading; @@ -107,6 +108,7 @@ namespace Tango.Logging if (!Categories.Contains(category)) return e; ExceptionLogItem log = new ExceptionLogItem(); + log.CallerAssembly = Assembly.GetCallingAssembly().FullName; log.CallerMethodName = caller; log.CallerFile = file; log.CallerLineNumber = lineNumber; @@ -164,6 +166,7 @@ namespace Tango.Logging if (!Categories.Contains(category)) return message; MessageLogItem log = new MessageLogItem(); + log.CallerAssembly = Assembly.GetCallingAssembly().FullName; log.CallerMethodName = caller; log.CallerFile = file; log.CallerLineNumber = lineNumber; diff --git a/Software/Visual_Studio/Tango.Logging/MessageLogItem.cs b/Software/Visual_Studio/Tango.Logging/MessageLogItem.cs index f7d7e004c..f45aa8cea 100644 --- a/Software/Visual_Studio/Tango.Logging/MessageLogItem.cs +++ b/Software/Visual_Studio/Tango.Logging/MessageLogItem.cs @@ -12,18 +12,20 @@ namespace Tango.Logging /// public class MessageLogItem : LogItemBase { + private String _message; /// /// Gets or sets the log message. /// - public String Message { get; set; } - - /// - /// Gets the log message. - /// - /// - public override string GetMessage() + public override string Message { - return Message; + get + { + return _message; + } + set + { + _message = value; + } } /// @@ -31,7 +33,7 @@ namespace Tango.Logging /// public override string ToString() { - return String.Format("[{0}] [{5}] [{1}] [{2}] [Line {3}]: {4}", TimeStamp.ToString("HH:mm:ss.ff"), Path.GetFileNameWithoutExtension(CallerFile), CallerMethodName, CallerLineNumber, Message, Category); + return String.Format("[{0}] [{5}] [{1}] [{2}] [{3}]: {4}", TimeStamp.ToString("HH:mm:ss.ff"), GetRelativeCallerFilePath(), CallerMethodName, CallerLineNumber, Message, Category); } } } diff --git a/Software/Visual_Studio/Tango.UnitTesting/Logging_TST.cs b/Software/Visual_Studio/Tango.UnitTesting/Logging_TST.cs new file mode 100644 index 000000000..6d95674ff --- /dev/null +++ b/Software/Visual_Studio/Tango.UnitTesting/Logging_TST.cs @@ -0,0 +1,33 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.MachineStudio.Logging.Parsing; + +namespace Tango.UnitTesting +{ + [TestClass] + [TestCategory("Logging")] + public class Logging_TST + { + [TestMethod] + public void Parse_Application_Logs() + { + ApplicationLogFileParser parser = new ApplicationLogFileParser(); + var logFiles = parser.GetLogFiles(); + var logFile = logFiles.OrderByDescending(x => x.DateTime).First(); + var logs = parser.Parse(logFile); + } + + [TestMethod] + public void Parse_Embedded_Logs() + { + EmbeddedLogFileParser parser = new EmbeddedLogFileParser(); + var logFiles = parser.GetLogFiles(); + var logFile = logFiles.OrderByDescending(x => x.DateTime).First(); + var logs = parser.Parse(logFile); + } + } +} diff --git a/Software/Visual_Studio/Tango.UnitTesting/Tango.UnitTesting.csproj b/Software/Visual_Studio/Tango.UnitTesting/Tango.UnitTesting.csproj index 045e09360..6d4fb984d 100644 --- a/Software/Visual_Studio/Tango.UnitTesting/Tango.UnitTesting.csproj +++ b/Software/Visual_Studio/Tango.UnitTesting/Tango.UnitTesting.csproj @@ -79,6 +79,7 @@ GlobalVersionInfo.cs + @@ -94,6 +95,10 @@ + + {1674f726-0e66-414f-b9fd-c6f20d7f07c7} + Tango.MachineStudio.Logging + {f441feee-322a-4943-b566-110e12fd3b72} Tango.BL diff --git a/Software/Visual_Studio/Tango.Visuals/Fader/Fader.xaml b/Software/Visual_Studio/Tango.Visuals/Fader/Fader.xaml index e3313ef43..c7aac0872 100644 --- a/Software/Visual_Studio/Tango.Visuals/Fader/Fader.xaml +++ b/Software/Visual_Studio/Tango.Visuals/Fader/Fader.xaml @@ -13,7 +13,7 @@ - + @@ -28,11 +28,27 @@ + + + + + + + + + + + + + + + + - - + + @@ -41,45 +57,27 @@ - - - - - - - - - - - - + + + - - - - - - - - - - - - + + + - + - + @@ -92,10 +90,10 @@ - + - - + + @@ -120,7 +118,7 @@ - + -- cgit v1.3.1