diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-03-26 14:21:53 +0300 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-03-26 14:21:53 +0300 |
| commit | 1061758f95b7ba633e6bcc2c3556b42f033b1a79 (patch) | |
| tree | c3cf106aa6b73fe1e0bfcd6b88399a5721990eb0 /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging | |
| parent | 761686de34252d76bda126c738d82c021ef6bf5d (diff) | |
| download | Tango-1061758f95b7ba633e6bcc2c3556b42f033b1a79.tar.gz Tango-1061758f95b7ba633e6bcc2c3556b42f033b1a79.zip | |
Working on logging module !
Modified PID Control Table.
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging')
3 files changed, 51 insertions, 7 deletions
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 d62246cf2..be3e1ef93 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 @@ -150,6 +150,10 @@ <Project>{8491d07b-c1f6-4b62-a412-41b9fd2d6538}</Project> <Name>Tango.SharedUI</Name> </ProjectReference> + <ProjectReference Include="..\..\..\Tango.Transport\Tango.Transport.csproj"> + <Project>{74e700b0-1156-4126-be40-ee450d3c3026}</Project> + <Name>Tango.Transport</Name> + </ProjectReference> <ProjectReference Include="..\..\Tango.MachineStudio.Common\Tango.MachineStudio.Common.csproj"> <Project>{cb0b0aa2-bb24-4bca-a720-45e397684e12}</Project> <Name>Tango.MachineStudio.Common</Name> 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 index 94765ccdb..2b773c1c2 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/MainViewVM.cs @@ -1,12 +1,16 @@ -using System; +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.MachineStudio.Common.EventLogging; +using Tango.MachineStudio.Common.Messages; using Tango.MachineStudio.Common.Notifications; +using Tango.MachineStudio.Common.StudioApplication; using Tango.SharedUI; namespace Tango.MachineStudio.Logging.ViewModels @@ -14,9 +18,11 @@ namespace Tango.MachineStudio.Logging.ViewModels public class MainViewVM : ViewModel { private INotificationProvider _notification; + private IStudioApplicationManager _application; private IEventLogger _eventLogger; private DateVM _realTimeDate; private ObservableCollection<MachinesEvent> _realTimeEvents; + private Machine _connectedMachine; private Machine _selectedMachine; public Machine SelectedMachine @@ -53,18 +59,37 @@ namespace Tango.MachineStudio.Logging.ViewModels set { _selectedDate = value; RaisePropertyChangedAuto(); OnSelectedDateChanged(); } } - public MainViewVM(INotificationProvider notification, IEventLogger eventLogger) + public MainViewVM(INotificationProvider notification, IEventLogger eventLogger, IStudioApplicationManager application) { + _application = application; _notification = notification; _eventLogger = eventLogger; _realTimeDate = new DateVM(DateTime.Now) { Description = "Real Time" }; _realTimeEvents = new ObservableCollection<MachinesEvent>(); _eventLogger.NewLog += _eventLogger_NewLog; + + RegisterMessage<MachineConnectionChangedMessage>(OnMachineConnectionChanged); + } + + 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) { - _realTimeEvents.Add(machineEvent); + InvokeUI(() => + { + _realTimeEvents.Add(machineEvent); + }); } private void OnSelectedMachineChanged() @@ -72,14 +97,18 @@ namespace Tango.MachineStudio.Logging.ViewModels if (SelectedMachine != null) { Dates = new ObservableCollection<DateVM>(); - Dates.Add(_realTimeDate); + + if (SelectedMachine == _connectedMachine) + { + Dates.Add(_realTimeDate); + } foreach (var day in SelectedMachine.MachinesEvents.GroupBy(x => x.DateTime.DayOfYear).Select(x => x.First().DateTime).OrderByDescending(x => x)) { Dates.Add(new DateVM(day)); } - SelectedDate = Dates.First(); + SelectedDate = Dates.FirstOrDefault(); } } 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 d4567d90f..3d59ee88e 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 @@ -74,7 +74,7 @@ </Grid> <Grid> - <DataGrid Background="Transparent" AlternatingRowBackground="#ECECEC" AutoGenerateColumns="False" SelectionMode="Single" ItemsSource="{Binding Events}" SelectedItem="{Binding SelectedEvent}" RowHeight="40" CanUserAddRows="False" CanUserDeleteRows="False" CanUserReorderColumns="True" IsReadOnly="True"> + <DataGrid Background="Transparent" AutoGenerateColumns="False" SelectionMode="Single" ItemsSource="{Binding Events}" SelectedItem="{Binding SelectedEvent}" RowHeight="40" CanUserAddRows="False" CanUserDeleteRows="False" CanUserReorderColumns="True" IsReadOnly="True"> <DataGrid.RowStyle> <Style TargetType="DataGridRow" BasedOn="{StaticResource {x:Type DataGridRow}}"> <Style.Triggers> @@ -83,6 +83,13 @@ <Setter Property="Foreground" Value="{StaticResource AccentColorBrush}" /> <Setter Property="Cursor" Value="Hand"></Setter> </Trigger> + <DataTrigger Binding="{Binding Type}" Value="ApplicationStarted"> + <Setter Property="Background" Value="{StaticResource AccentColorBrush}"></Setter> + <Setter Property="Foreground" Value="White" /> + <Setter Property="FontWeight" Value="SemiBold"></Setter> + <Setter Property="Cursor" Value="Arrow"></Setter> + <Setter Property="IsHitTestVisible" Value="False"></Setter> + </DataTrigger> </Style.Triggers> </Style> </DataGrid.RowStyle> @@ -118,6 +125,10 @@ <Setter Property="Kind" Value="BellPlus"></Setter> <Setter Property="Foreground" Value="Red"></Setter> </DataTrigger> + <DataTrigger Binding="{Binding Type}" Value="ApplicationStarted"> + <Setter Property="Kind" Value="ClockFast"></Setter> + <Setter Property="Foreground" Value="White"></Setter> + </DataTrigger> </Style.Triggers> </Style> </materialDesign:PackIcon.Style> @@ -127,7 +138,7 @@ </DataGridTemplateColumn> <DataGridTextColumn Header="DATE TIME" Binding="{Binding DateTime,Converter={StaticResource DateTimeUTCToShortDateTimeConverter}}" /> <DataGridTextColumn Header="HOST" Binding="{Binding HostName}" /> - <DataGridTextColumn Header="USER" Binding="{Binding User.Contact.FullName}" /> + <DataGridTextColumn Header="USER" Binding="{Binding User.Contact.FullName,Mode=OneTime}" /> <DataGridTextColumn Header="GROUP" Binding="{Binding EventType.EventTypesGroup.Name}" /> <DataGridTextColumn Header="EVENT" Binding="{Binding EventType.Name}" /> <DataGridTemplateColumn Header="MESSAGE" Width="1*"> |
