diff --git a/CBSVisualizer/CBSVisualizer.Common/Enums/SchedulerType.cs b/CBSVisualizer/CBSVisualizer.Common/Enums/SchedulerType.cs new file mode 100644 index 0000000000000000000000000000000000000000..779f043bd7ccecd1e616d2ab081ef74daf2cf589 --- /dev/null +++ b/CBSVisualizer/CBSVisualizer.Common/Enums/SchedulerType.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CBSVisualizer.Common.Enums +{ + public enum SchedulerType + { + /// <summary> + /// A scheduler with random GateOpen times. + /// </summary> + Random, + + /// <summary> + /// A flow-based scheduler that can be configured using a JSON file. + /// </summary> + FlowBased + } +} diff --git a/CBSVisualizer/CBSVisualizer.Common/SynchronizationExtensions.cs b/CBSVisualizer/CBSVisualizer.Common/Extensions/SynchronizationExtensions.cs similarity index 91% rename from CBSVisualizer/CBSVisualizer.Common/SynchronizationExtensions.cs rename to CBSVisualizer/CBSVisualizer.Common/Extensions/SynchronizationExtensions.cs index fe8c7e15c7bcdd4f6d4722959237400ed495a5d7..127733cb2d16193caa8679f067271d487b8f9f4b 100644 --- a/CBSVisualizer/CBSVisualizer.Common/SynchronizationExtensions.cs +++ b/CBSVisualizer/CBSVisualizer.Common/Extensions/SynchronizationExtensions.cs @@ -1,9 +1,8 @@ -using CBSVisualizer.Messaging; -using System.Collections.ObjectModel; +using System.Collections.ObjectModel; using System.Linq; using CBSVisualizer.Messaging.Models; -namespace CBSVisualizer.Common +namespace CBSVisualizer.Common.Extensions { public static class SynchronizationExtensions { diff --git a/CBSVisualizer/CBSVisualizer.Common/Interfaces/IPacketService.cs b/CBSVisualizer/CBSVisualizer.Common/Interfaces/IPacketService.cs new file mode 100644 index 0000000000000000000000000000000000000000..dcd3644ceb3365f394e762f533357ffa299d6db5 --- /dev/null +++ b/CBSVisualizer/CBSVisualizer.Common/Interfaces/IPacketService.cs @@ -0,0 +1,12 @@ +using System.Threading.Tasks; +using CBSVisualizer.Messaging.Models; + +namespace CBSVisualizer.Common.Interfaces +{ + public interface IPacketService + { + public Task StartLoadGeneration(); + + public void StopLoadGeneration(); + } +} diff --git a/CBSVisualizer/CBSVisualizer.Services.SchedulingService/Interface/ISchedulingService.cs b/CBSVisualizer/CBSVisualizer.Common/Interfaces/ISchedulingService.cs similarity index 70% rename from CBSVisualizer/CBSVisualizer.Services.SchedulingService/Interface/ISchedulingService.cs rename to CBSVisualizer/CBSVisualizer.Common/Interfaces/ISchedulingService.cs index e5bb1a1e9b32956a371eeffd6a5e514c62f92637..db9c95036c0985228c1c537ff2f3c81b5aa1ffb1 100644 --- a/CBSVisualizer/CBSVisualizer.Services.SchedulingService/Interface/ISchedulingService.cs +++ b/CBSVisualizer/CBSVisualizer.Common/Interfaces/ISchedulingService.cs @@ -1,6 +1,6 @@ using System.Threading.Tasks; -namespace CBSVisualizer.Services.SchedulingService.Interface +namespace CBSVisualizer.Common.Interfaces { public interface ISchedulingService { diff --git a/CBSVisualizer/CBSVisualizer.Common/ValueContainer.cs b/CBSVisualizer/CBSVisualizer.Common/Types/ValueContainer.cs similarity index 85% rename from CBSVisualizer/CBSVisualizer.Common/ValueContainer.cs rename to CBSVisualizer/CBSVisualizer.Common/Types/ValueContainer.cs index 107917b7f84df802ccb8f165a5826d7b407d4599..97f9447a28886351fd532916aa4055a12fa6dcba 100644 --- a/CBSVisualizer/CBSVisualizer.Common/ValueContainer.cs +++ b/CBSVisualizer/CBSVisualizer.Common/Types/ValueContainer.cs @@ -1,7 +1,6 @@ using Prism.Mvvm; -using System; -namespace CBSVisualizer.Common +namespace CBSVisualizer.Common.Types { public class ValueContainer<T> : BindableBase where T : struct { diff --git a/CBSVisualizer/CBSVisualizer.MessagingCore/Events/Queue/GlobalGateOpenedEvent.cs b/CBSVisualizer/CBSVisualizer.MessagingCore/Events/Queue/GlobalGateOpenedEvent.cs index f222ec28f0d67f4c0c9eac3ef6be7b6f8e43e498..df37d778aa574d7b46316494fc61c5c3dc2c03f1 100644 --- a/CBSVisualizer/CBSVisualizer.MessagingCore/Events/Queue/GlobalGateOpenedEvent.cs +++ b/CBSVisualizer/CBSVisualizer.MessagingCore/Events/Queue/GlobalGateOpenedEvent.cs @@ -3,7 +3,7 @@ using Prism.Events; namespace CBSVisualizer.Messaging.Events.Queue { - public class GlobalGateOpenedEvent : PubSubEvent<(int OpenedTime, ISet<int> OpenedGates)> + public class GlobalGateOpenedEvent : PubSubEvent<(double OpenedTime, ISet<int> OpenedGates)> { } } diff --git a/CBSVisualizer/CBSVisualizer.MessagingCore/Models/PriorityPacket.cs b/CBSVisualizer/CBSVisualizer.MessagingCore/Models/PriorityPacket.cs index 0ab7fdbfa4e054a07c0282b6accd2a99177e9071..1acac44222eeba123e2443c58c2ca03b7e689813 100644 --- a/CBSVisualizer/CBSVisualizer.MessagingCore/Models/PriorityPacket.cs +++ b/CBSVisualizer/CBSVisualizer.MessagingCore/Models/PriorityPacket.cs @@ -2,10 +2,6 @@ { public class PriorityPacket { - private static readonly int PREEMPTION_HEADER_SIZE_BYTES = 12; - - - private static readonly int PREEMPTION_TRAILER_SIZE_BYTES = 12; public static PriorityPacket NoPacket { get; } = new PriorityPacket(-1, int.MaxValue) { UniqueId = -1 }; @@ -60,7 +56,7 @@ /// <param name="prio"></param> /// <param name="payloadBytes"></param> public PriorityPacket(int prio, int payloadBytes) - : this(prio, payloadBytes, PREEMPTION_HEADER_SIZE_BYTES, PREEMPTION_TRAILER_SIZE_BYTES) + : this(prio, 0, payloadBytes, 0) { } diff --git a/CBSVisualizer/CBSVisualizer.Modules.Link/ViewModels/LinkViewModel.cs b/CBSVisualizer/CBSVisualizer.Modules.Link/ViewModels/LinkViewModel.cs index b6f746e1ae369743d00a7a008cf1aa56348b7e55..dabb999980739382b8a7525c862f9fd4901e1441 100644 --- a/CBSVisualizer/CBSVisualizer.Modules.Link/ViewModels/LinkViewModel.cs +++ b/CBSVisualizer/CBSVisualizer.Modules.Link/ViewModels/LinkViewModel.cs @@ -9,13 +9,13 @@ using System.Threading.Tasks; using CBSVisualizer.Common; using CBSVisualizer.Common.Enums; using CBSVisualizer.Common.Interfaces; +using CBSVisualizer.Common.Types; using CBSVisualizer.Core.Mvvm; using CBSVisualizer.Messaging.Events.Queue; using CBSVisualizer.Messaging.Events.Simulation; using CBSVisualizer.Messaging.Models; using CBSVisualizer.Modules.Link.Preemption; -using CBSVisualizer.Services.SchedulingService.Interface; -using CBSVisualizer.Services.SettingService.Implementation; +using CBSVisualizer.Services.SettingService; using log4net; using Prism.Events; using Prism.Regions; @@ -119,11 +119,11 @@ namespace CBSVisualizer.Modules.Link.ViewModels gateOpenedTokenSrc = new CancellationTokenSource(); // Calculate transmittable bytes. - var transmittableBytes = settingService.GetSettingValue<long>(BitrateSettingKey) * tuple.OpenedTime / 1000; + var transmittableBytes = settingService.GetSettingValue<double>(BitrateSettingKey) * tuple.OpenedTime / 1000; eventAggregator.GetEvent<QueueGateOpenedEvent>().Publish(tuple.OpenedGates); - gateThread = new Thread(() => HandleGateOpened(tuple.OpenedGates, transmittableBytes)); + gateThread = new Thread(() => HandleGateOpened(tuple.OpenedGates, (long) transmittableBytes)); gateThread.Start(); }); diff --git a/CBSVisualizer/CBSVisualizer.Modules.MenuBar/ViewModels/MenuBarViewModel.LoadGeneration.cs b/CBSVisualizer/CBSVisualizer.Modules.MenuBar/ViewModels/MenuBarViewModel.LoadGeneration.cs deleted file mode 100644 index 51033fb23fbdd61e12bad61d9b684c84533bf842..0000000000000000000000000000000000000000 --- a/CBSVisualizer/CBSVisualizer.Modules.MenuBar/ViewModels/MenuBarViewModel.LoadGeneration.cs +++ /dev/null @@ -1,61 +0,0 @@ -using CBSVisualizer.Messaging; -using CBSVisualizer.Messaging.Events; -using log4net; -using Prism.Commands; -using System.Threading; -using System.Threading.Tasks; -using CBSVisualizer.Messaging.Events.Queue; -using CBSVisualizer.Messaging.Models; - -namespace CBSVisualizer.Modules.MenuBar.ViewModels -{ - public partial class MenuBarViewModel - { - public DelegateCommand StartLoadGeneration { get; } - - public DelegateCommand StopLoadGeneration { get; } - - private bool loadGenerationInProgress = false; - private bool LoadGenerationInProgress - { - get => loadGenerationInProgress; - - set => SetProperty(ref loadGenerationInProgress, value); - } - - private CancellationTokenSource tokenSource = new CancellationTokenSource(); - - private bool CanStartLoadGeneration() - { - return !LoadGenerationInProgress; - } - - private async Task StartLoadThread() - { - tokenSource = new CancellationTokenSource(); - LoadGenerationInProgress = true; - await GenerateLoad(); - } - - private void StopLoadThread() - { - tokenSource.Cancel(); - LoadGenerationInProgress = false; - } - - private async Task GenerateLoad() - { - while (!tokenSource.IsCancellationRequested) - { - eventAggregator.GetEvent<PacketArrivedEvent>().Publish(GenerateRandomPacket()); - await Task.Delay(settings.GetSettingValue<int>("interarrival_time")); - } - } - - private PriorityPacket GenerateRandomPacket() - { - PriorityPacket ret = packetService.GeneratePacket(); - return ret; - } - } -} diff --git a/CBSVisualizer/CBSVisualizer.Modules.MenuBar/ViewModels/MenuBarViewModel.cs b/CBSVisualizer/CBSVisualizer.Modules.MenuBar/ViewModels/MenuBarViewModel.cs index 880c210236aef8720c3d12cc07b8fe0d3505aba6..2c4195d2a90ca1458e7afb29b51306cf6480ef71 100644 --- a/CBSVisualizer/CBSVisualizer.Modules.MenuBar/ViewModels/MenuBarViewModel.cs +++ b/CBSVisualizer/CBSVisualizer.Modules.MenuBar/ViewModels/MenuBarViewModel.cs @@ -1,53 +1,54 @@ -using CBSVisualizer.Core.Mvvm; -using CBSVisualizer.Messaging.Events; +using Prism.Commands; +using System.Threading.Tasks; +using CBSVisualizer.Common.Interfaces; +using CBSVisualizer.Core.Mvvm; using CBSVisualizer.Messaging.Events.Simulation; -using CBSVisualizer.Services.PacketService.Interface; -using CBSVisualizer.Services.SettingService.Implementation; -using Prism.Commands; +using CBSVisualizer.Services.SettingService; using Prism.Events; using Prism.Regions; using Prism.Services.Dialogs; - namespace CBSVisualizer.Modules.MenuBar.ViewModels { - public partial class MenuBarViewModel : RegionViewModelBase + public class MenuBarViewModel : RegionViewModelBase { - private bool simulationRunning = false; + private bool loadGenerationInProgress; + private bool LoadGenerationInProgress + { + get => loadGenerationInProgress; + + set => SetProperty(ref loadGenerationInProgress, value); + } + + private bool simulationRunning; private bool SimulationRunning { - get - { - return simulationRunning; - } + get => simulationRunning; - set - { - SetProperty(ref simulationRunning, value); - } + set => SetProperty(ref simulationRunning, value); } - public DelegateCommand StartSimulationCommand { get; private set; } + public DelegateCommand StartLoadGeneration { get; } - public DelegateCommand StopSimulationCommand { get; private set; } + public DelegateCommand StopLoadGeneration { get; } - public DelegateCommand OpenSettingsCommand { get; private set; } + public DelegateCommand StartSimulationCommand { get; } - private readonly IEventAggregator eventAggregator; + public DelegateCommand StopSimulationCommand { get; } - private readonly SettingService settings; + public DelegateCommand OpenSettingsCommand { get; } - private readonly IPacketService packetService; + private readonly IEventAggregator eventAggregator; + private readonly IPacketService packetService; public MenuBarViewModel(IRegionManager regionManager, IEventAggregator eventAggregator, IDialogService dialogService, SettingService settingService, IPacketService packetServ) : base(regionManager) { this.eventAggregator = eventAggregator; - settings = settingService; packetService = packetServ; - StartSimulationCommand = new DelegateCommand(SignalSimulationStart, () => !SimulationRunning).ObservesProperty(() => SimulationRunning); + StartSimulationCommand = new DelegateCommand(SignalSimulationStart, () => !SimulationRunning).ObservesProperty<bool>(() => SimulationRunning); StopSimulationCommand = new DelegateCommand(SignalSimulationStop).ObservesCanExecute(() => SimulationRunning); OpenSettingsCommand = new DelegateCommand(() => dialogService.Show("SettingsDialog", new DialogParameters(), result => { })); @@ -65,5 +66,28 @@ namespace CBSVisualizer.Modules.MenuBar.ViewModels eventAggregator.GetEvent<SimulationStoppedEvent>().Publish(); SimulationRunning = false; } + + private bool CanStartLoadGeneration() + { + return !LoadGenerationInProgress; + } + + private async Task StartLoadThread() + { + LoadGenerationInProgress = true; + try + { + await packetService.StartLoadGeneration(); + } + catch (TaskCanceledException) + { + } + } + + private void StopLoadThread() + { + LoadGenerationInProgress = false; + packetService.StopLoadGeneration(); + } } } diff --git a/CBSVisualizer/CBSVisualizer.Modules.Queue.QueueGroup/Views/QueueGroup.xaml.cs b/CBSVisualizer/CBSVisualizer.Modules.Queue.QueueGroup/Views/QueueGroup.xaml.cs index 72b4c92eec965491512a3a7d4034ef444a5c04a2..b58103c810f462516a7ae12adfaebb146e72e328 100644 --- a/CBSVisualizer/CBSVisualizer.Modules.Queue.QueueGroup/Views/QueueGroup.xaml.cs +++ b/CBSVisualizer/CBSVisualizer.Modules.Queue.QueueGroup/Views/QueueGroup.xaml.cs @@ -1,7 +1,7 @@ using System.Windows.Controls; +using CBSVisualizer.Common.Interfaces; using CBSVisualizer.Modules.Queue.ViewModels; -using CBSVisualizer.Services.PacketService.Interface; -using CBSVisualizer.Services.SettingService.Implementation; +using CBSVisualizer.Services.SettingService; using Prism.Events; using Prism.Regions; diff --git a/CBSVisualizer/CBSVisualizer.Modules.Queue/ViewModels/QueueViewModel.cs b/CBSVisualizer/CBSVisualizer.Modules.Queue/ViewModels/QueueViewModel.cs index ffff6fe65965459114d58f7db5ee3fcdac59645f..08d5601b1915789bc678bea9e2d1b3c69d394695 100644 --- a/CBSVisualizer/CBSVisualizer.Modules.Queue/ViewModels/QueueViewModel.cs +++ b/CBSVisualizer/CBSVisualizer.Modules.Queue/ViewModels/QueueViewModel.cs @@ -4,6 +4,7 @@ using System.ComponentModel; using System.Reflection; using System.Threading.Tasks; using CBSVisualizer.Common; +using CBSVisualizer.Common.Extensions; using CBSVisualizer.Common.Interfaces; using CBSVisualizer.Core.Mvvm; using CBSVisualizer.Messaging.Events.Charts; @@ -11,8 +12,7 @@ using CBSVisualizer.Messaging.Events.Queue; using CBSVisualizer.Messaging.Events.Simulation; using CBSVisualizer.Messaging.Models; using CBSVisualizer.Modules.Queue.QueueImplementations; -using CBSVisualizer.Services.PacketService.Interface; -using CBSVisualizer.Services.SettingService.Implementation; +using CBSVisualizer.Services.SettingService; using log4net; using Prism.Commands; using Prism.Events; @@ -92,7 +92,6 @@ namespace CBSVisualizer.Modules.Queue.ViewModels public string PrioLabel { get; private set; } public string PacketLabel { get; private set; } public ObservableCollection<PriorityPacket> Queue { get; } = new ObservableCollection<PriorityPacket>(); - public DelegateCommand GeneratePacketOnClick { get; private set; } private void RegisterSimulationStartedEventHandlers() { @@ -258,11 +257,6 @@ namespace CBSVisualizer.Modules.Queue.ViewModels Queue.AddSynchronized(packet); }); - - GeneratePacketOnClick = new DelegateCommand(async () => - { - await Task.Run(() => Queue.AddSynchronized(packetService.GeneratePacket(Priority))); - }); } } } \ No newline at end of file diff --git a/CBSVisualizer/CBSVisualizer.Modules.Queue/Views/Queue.xaml b/CBSVisualizer/CBSVisualizer.Modules.Queue/Views/Queue.xaml index 0ab958531a191fb80d44a1e630b538adbac83576..ebdc93f00850f40eb8b9e783021ca9d0e2efbb23 100644 --- a/CBSVisualizer/CBSVisualizer.Modules.Queue/Views/Queue.xaml +++ b/CBSVisualizer/CBSVisualizer.Modules.Queue/Views/Queue.xaml @@ -23,11 +23,8 @@ <TextBlock Text="{Binding Priority}" Grid.Column="0" Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Center"/> <TextBlock Text="{Binding PacketLabel}" Grid.Column="1" Grid.Row="0" VerticalAlignment="Center" HorizontalAlignment="Center"/> - <TextBlock Text="{Binding Queue.Count}" Grid.Column="1" Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Center"> - <TextBlock.InputBindings> - <MouseBinding MouseAction="RightClick" Command="{Binding GeneratePacketOnClick}"/> - </TextBlock.InputBindings> - </TextBlock> + <TextBlock Text="{Binding Queue.Count}" Grid.Column="1" Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Center"/> + <TextBox materialDesign:HintAssist.Hint="Idle Slope [byte/s]" Style="{StaticResource MaterialDesignFloatingHintTextBox}" diff --git a/CBSVisualizer/CBSVisualizer.Modules.SettingsDialog/ViewModels/SettingsDialogViewModel.cs b/CBSVisualizer/CBSVisualizer.Modules.SettingsDialog/ViewModels/SettingsDialogViewModel.cs index 90d59d4b4c050d3b8a19ac55dcb2878abed8ca0d..85ea84e5458774ab682aa7de12571d98972ca0c8 100644 --- a/CBSVisualizer/CBSVisualizer.Modules.SettingsDialog/ViewModels/SettingsDialogViewModel.cs +++ b/CBSVisualizer/CBSVisualizer.Modules.SettingsDialog/ViewModels/SettingsDialogViewModel.cs @@ -2,7 +2,7 @@ using Prism.Regions; using Prism.Services.Dialogs; using System; -using CBSVisualizer.Services.SettingService.Implementation; +using CBSVisualizer.Services.SettingService; namespace CBSVisualizer.Modules.SettingsDialog.ViewModels { diff --git a/CBSVisualizer/CBSVisualizer.Services.JsonService/CBSVisualizer.Services.JsonService.csproj b/CBSVisualizer/CBSVisualizer.Services.JsonService/CBSVisualizer.Services.JsonService.csproj new file mode 100644 index 0000000000000000000000000000000000000000..268ce8bda8dcd58e299e546f9395e9d44fad6f9c --- /dev/null +++ b/CBSVisualizer/CBSVisualizer.Services.JsonService/CBSVisualizer.Services.JsonService.csproj @@ -0,0 +1,11 @@ +<Project Sdk="Microsoft.NET.Sdk"> + + <PropertyGroup> + <TargetFramework>net5.0</TargetFramework> + </PropertyGroup> + + <ItemGroup> + <PackageReference Include="Newtonsoft.Json" Version="12.0.3" /> + </ItemGroup> + +</Project> diff --git a/CBSVisualizer/CBSVisualizer.Services.JsonService/JsonService.cs b/CBSVisualizer/CBSVisualizer.Services.JsonService/JsonService.cs new file mode 100644 index 0000000000000000000000000000000000000000..482706ec1573f8ca493c248e6a837703244f6d52 --- /dev/null +++ b/CBSVisualizer/CBSVisualizer.Services.JsonService/JsonService.cs @@ -0,0 +1,26 @@ +using System; +using System.IO; +using Newtonsoft.Json; + +namespace CBSVisualizer.Services.JsonService +{ + public static class JsonService + { + /// <summary> + /// The JsonSerializer used for (de-)serializing. + /// </summary> + private static readonly JsonSerializer Serializer = new JsonSerializer(); + + /// <summary> + /// Tries to de-serialize an object from the specified file. + /// </summary> + /// <typeparam name="T">the type of the object</typeparam> + /// <param name="path">the path to the file containing the object</param> + /// <returns>the deserialized object.</returns> + public static T DeserializeFromFile<T> (string path) + { + using StreamReader reader = File.OpenText(path); + return Serializer.Deserialize<T>(new JsonTextReader(reader)); + } + } +} diff --git a/CBSVisualizer/CBSVisualizer.Services.JsonService/JsonTypes/FlowConfiguration.cs b/CBSVisualizer/CBSVisualizer.Services.JsonService/JsonTypes/FlowConfiguration.cs new file mode 100644 index 0000000000000000000000000000000000000000..3dc7c757978c2bf55e5eaa5c5c96accedb9401ca --- /dev/null +++ b/CBSVisualizer/CBSVisualizer.Services.JsonService/JsonTypes/FlowConfiguration.cs @@ -0,0 +1,26 @@ +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace CBSVisualizer.Services.JsonService.JsonTypes +{ + public class FlowConfiguration + { + [JsonProperty("flow_count")] + public int FlowCount { get; set; } + + [JsonProperty("total_cycle_duration_ms")] + public double TotalCycleDuration { get; set; } + + [JsonProperty("cycles")] + public int Cycles { get; set; } + + [JsonProperty("active_cbs_queues")] + public ISet<int> ActiveCbsQueues { get; set; } + + [JsonProperty("flow_periods_sizes")] + public IDictionary<double, int> FlowPeriodsAndSizes { get; set; } + + [JsonProperty("closing_events_counts_durations")] + public IDictionary<int, double> ClosingEventsCountsAndDurations { get; set; } + } +} diff --git a/CBSVisualizer/CBSVisualizer.Services.PacketService/CBSVisualizer.Services.PacketService.csproj b/CBSVisualizer/CBSVisualizer.Services.PacketService/CBSVisualizer.Services.PacketService.csproj index 2d123f6ff3a84a396d7504bfe89fae9a7e79ae19..1ace85c0c60fabf9e13cf6e8fbda9eeb5c710b59 100644 --- a/CBSVisualizer/CBSVisualizer.Services.PacketService/CBSVisualizer.Services.PacketService.csproj +++ b/CBSVisualizer/CBSVisualizer.Services.PacketService/CBSVisualizer.Services.PacketService.csproj @@ -5,7 +5,10 @@ </PropertyGroup> <ItemGroup> + <ProjectReference Include="..\CBSVisualizer.Common\CBSVisualizer.Common.csproj" /> <ProjectReference Include="..\CBSVisualizer.MessagingCore\CBSVisualizer.Messaging.csproj" /> + <ProjectReference Include="..\CBSVisualizer.Services.JsonService\CBSVisualizer.Services.JsonService.csproj" /> + <ProjectReference Include="..\CBSVisualizer.Services.SettingsService\CBSVisualizer.Services.SettingService.csproj" /> </ItemGroup> </Project> diff --git a/CBSVisualizer/CBSVisualizer.Services.PacketService/FlowBasedPacketService.cs b/CBSVisualizer/CBSVisualizer.Services.PacketService/FlowBasedPacketService.cs new file mode 100644 index 0000000000000000000000000000000000000000..cc2a4906b4c9c81ca78f9fea7f477fce8a48149c --- /dev/null +++ b/CBSVisualizer/CBSVisualizer.Services.PacketService/FlowBasedPacketService.cs @@ -0,0 +1,95 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using CBSVisualizer.Common.Interfaces; +using CBSVisualizer.Messaging.Events.Queue; +using CBSVisualizer.Messaging.Models; +using CBSVisualizer.Services.JsonService.JsonTypes; +using log4net; +using Prism.Events; + +namespace CBSVisualizer.Services.PacketService +{ + public class FlowBasedPacketService : IPacketService + { + private readonly IEventAggregator eventAggregator; + private readonly SettingService.SettingService settingService; + private static readonly ILog Log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private readonly Random random = new Random(); + private CancellationTokenSource tokenSrc; + + + public FlowBasedPacketService(IEventAggregator eventAggregator, SettingService.SettingService settingService) + { + this.eventAggregator = eventAggregator; + this.settingService = settingService; + } + + private FlowConfiguration ParseConfiguration() + { + try + { + return JsonService.JsonService.DeserializeFromFile<FlowConfiguration>( + settingService.GetSettingValue<string>("flow_based_scheduler_config")); + } + catch (Exception e) + { + Log.Error($"Unable to deserialize configuration from {settingService.GetSettingValue<string>("flow_based_scheduler_config")}: {e}"); + return new FlowConfiguration(); + } + } + + public async Task StartLoadGeneration() + { + var config = ParseConfiguration(); + var packetSchedule = InitializeFlows(config); + var queues = config.ActiveCbsQueues.Append(0).Append(7).ToImmutableList(); + + tokenSrc = new CancellationTokenSource(); + + var tasks = new List<Task>(); + foreach (var (period, size) in packetSchedule) + { + tasks.Add(GenerateFlowTask(queues, period, size)); + } + + await Task.WhenAll(tasks); + } + + private async Task GenerateFlowTask(IList<int> queues, double period, int size) + { + while (!tokenSrc.IsCancellationRequested) + { + // Generate a packet for one of the queues. + eventAggregator.GetEvent<PacketArrivedEvent>().Publish(new PriorityPacket(queues[random.Next(0, queues.Count)], size)); + + // Sleep. + await Task.Delay(TimeSpan.FromMilliseconds(period), tokenSrc.Token); + } + } + + private IEnumerable<Tuple<double, int>> InitializeFlows(FlowConfiguration config) + { + var flowList = new List<Tuple<double, int>>(); + for (var i = 0; i < config.FlowCount; i++) + { + var selectedIndex = random.Next(0, config.FlowPeriodsAndSizes.Keys.Count); + var selectedKey = config.FlowPeriodsAndSizes.Keys.ElementAt(selectedIndex); + + // Randomly decide for one of the configurations. + flowList.Add(new Tuple<double, int>(selectedKey, config.FlowPeriodsAndSizes[selectedKey])); + } + + return flowList; + } + + public void StopLoadGeneration() + { + tokenSrc?.Cancel(); + } + } +} diff --git a/CBSVisualizer/CBSVisualizer.Services.PacketService/Implementation/RandomPacketService.cs b/CBSVisualizer/CBSVisualizer.Services.PacketService/Implementation/RandomPacketService.cs deleted file mode 100644 index 6d9d3741fef760212aa989388a25fa5c7b26497b..0000000000000000000000000000000000000000 --- a/CBSVisualizer/CBSVisualizer.Services.PacketService/Implementation/RandomPacketService.cs +++ /dev/null @@ -1,38 +0,0 @@ -using CBSVisualizer.Messaging; -using CBSVisualizer.Services.PacketService.Interface; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using CBSVisualizer.Messaging.Models; - -namespace CBSVisualizer.Services.PacketService.Implementation -{ - public class RandomPacketService : IPacketService - { - private const int HEADER_BYTES = 100; - - private const int TRAILER_BYTES = 100; - - private readonly Random random = new Random(); - - public PriorityPacket GeneratePacket(int priority) - { - return new PriorityPacket( - priority, // Priority between 0 and 7 - HEADER_BYTES, - random.Next(2000), // Random value between 0 and 1999. - TRAILER_BYTES); - } - - public PriorityPacket GeneratePacket() - { - return new PriorityPacket( - random.Next(0, 8), // Priority between 0 and 7 - HEADER_BYTES, - random.Next(2000), // Random value between 0 and 1999. - TRAILER_BYTES); - } - } -} diff --git a/CBSVisualizer/CBSVisualizer.Services.PacketService/Interface/IPacketService.cs b/CBSVisualizer/CBSVisualizer.Services.PacketService/Interface/IPacketService.cs deleted file mode 100644 index 89c925b7c683fc298dca958f1941bf30f824daf2..0000000000000000000000000000000000000000 --- a/CBSVisualizer/CBSVisualizer.Services.PacketService/Interface/IPacketService.cs +++ /dev/null @@ -1,23 +0,0 @@ -using CBSVisualizer.Messaging; -using System; -using System.Net.Mail; -using CBSVisualizer.Messaging.Models; - -namespace CBSVisualizer.Services.PacketService.Interface -{ - public interface IPacketService - { - /// <summary> - /// Generates a packet with the specified priority. - /// </summary> - /// <param name="priority"></param> - /// <returns></returns> - PriorityPacket GeneratePacket(int priority); - - /// <summary> - /// Generates a packet with a random priority. - /// </summary> - /// <returns></returns> - PriorityPacket GeneratePacket(); - } -} diff --git a/CBSVisualizer/CBSVisualizer.Services.PacketService/PacketServiceProxy.cs b/CBSVisualizer/CBSVisualizer.Services.PacketService/PacketServiceProxy.cs new file mode 100644 index 0000000000000000000000000000000000000000..c0ec6bed0cc5a7f9f9edaceda7b6a79196f7f618 --- /dev/null +++ b/CBSVisualizer/CBSVisualizer.Services.PacketService/PacketServiceProxy.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using CBSVisualizer.Common.Enums; +using CBSVisualizer.Common.Interfaces; +using Prism.Events; + +namespace CBSVisualizer.Services.PacketService +{ + public class PacketServiceProxy : IPacketService + { + private readonly SettingService.SettingService settingService; + private readonly IEventAggregator eventAggregator; + private IPacketService internalPacketService; + + public PacketServiceProxy(IEventAggregator eventAggregator, SettingService.SettingService settingService) + { + this.eventAggregator = eventAggregator; + this.settingService = settingService; + } + + public async Task StartLoadGeneration() + { + SetInternalService(); + await internalPacketService.StartLoadGeneration(); + } + + private void SetInternalService() + { + internalPacketService = + Enum.Parse(typeof(SchedulerType), settingService.GetSettingValue<string>("scheduler")) switch + { + SchedulerType.FlowBased => new FlowBasedPacketService(eventAggregator, settingService), + _ => new RandomPacketService(eventAggregator, settingService) + }; + } + + public void StopLoadGeneration() + { + internalPacketService.StopLoadGeneration(); + } + } +} diff --git a/CBSVisualizer/CBSVisualizer.Services.PacketService/RandomPacketService.cs b/CBSVisualizer/CBSVisualizer.Services.PacketService/RandomPacketService.cs new file mode 100644 index 0000000000000000000000000000000000000000..d201234967c82584a16ec2382b6e3277a6bffe80 --- /dev/null +++ b/CBSVisualizer/CBSVisualizer.Services.PacketService/RandomPacketService.cs @@ -0,0 +1,53 @@ +using System; +using System.Threading; +using System.Threading.Tasks; +using CBSVisualizer.Common.Interfaces; +using CBSVisualizer.Messaging.Events.Queue; +using CBSVisualizer.Messaging.Models; +using Prism.Events; + +namespace CBSVisualizer.Services.PacketService +{ + public class RandomPacketService : IPacketService + { + private const int HEADER_BYTES = 100; + + private const int TRAILER_BYTES = 100; + + private CancellationTokenSource tokenSource = new CancellationTokenSource(); + + private readonly Random random = new Random(); + private readonly IEventAggregator eventAggregator; + private readonly SettingService.SettingService settingService; + + public RandomPacketService(IEventAggregator eventAggregator, SettingService.SettingService settingService) + { + this.eventAggregator = eventAggregator; + this.settingService = settingService; + } + + public PriorityPacket GeneratePacket() + { + return new PriorityPacket( + random.Next(0, 8), // Priority between 0 and 7 + HEADER_BYTES, + random.Next(2000), // Random value between 0 and 1999. + TRAILER_BYTES); + } + + public async Task StartLoadGeneration() + { + tokenSource = new CancellationTokenSource(); + while (!tokenSource.IsCancellationRequested) + { + eventAggregator.GetEvent<PacketArrivedEvent>().Publish(GeneratePacket()); + await Task.Delay(settingService.GetSettingValue<int>("interarrival_time")); + } + } + + public void StopLoadGeneration() + { + tokenSource.Cancel(); + } + } +} diff --git a/CBSVisualizer/CBSVisualizer.Services.SchedulingService/CBSVisualizer.Services.SchedulingService.csproj b/CBSVisualizer/CBSVisualizer.Services.SchedulingService/CBSVisualizer.Services.SchedulingService.csproj index 13ebb9059a91f1e78b5ef81e096896cfe67189c9..210af7dad6db787f4cc02d6e2ad3e057c6ccc9cd 100644 --- a/CBSVisualizer/CBSVisualizer.Services.SchedulingService/CBSVisualizer.Services.SchedulingService.csproj +++ b/CBSVisualizer/CBSVisualizer.Services.SchedulingService/CBSVisualizer.Services.SchedulingService.csproj @@ -11,6 +11,7 @@ <ItemGroup> <ProjectReference Include="..\CBSVisualizer.MessagingCore\CBSVisualizer.Messaging.csproj" /> + <ProjectReference Include="..\CBSVisualizer.Services.JsonService\CBSVisualizer.Services.JsonService.csproj" /> <ProjectReference Include="..\CBSVisualizer.Services.SettingsService\CBSVisualizer.Services.SettingService.csproj" /> </ItemGroup> diff --git a/CBSVisualizer/CBSVisualizer.Services.SchedulingService/FlowBasedSchedulingService.cs b/CBSVisualizer/CBSVisualizer.Services.SchedulingService/FlowBasedSchedulingService.cs new file mode 100644 index 0000000000000000000000000000000000000000..a0b76de2ef40f2ecc093f2e605c897391593e241 --- /dev/null +++ b/CBSVisualizer/CBSVisualizer.Services.SchedulingService/FlowBasedSchedulingService.cs @@ -0,0 +1,103 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using CBSVisualizer.Common.Interfaces; +using CBSVisualizer.Messaging.Events.Queue; +using CBSVisualizer.Services.JsonService.JsonTypes; +using log4net; +using Prism.Events; + +namespace CBSVisualizer.Services.SchedulingService +{ + public class FlowBasedSchedulingService : ISchedulingService + { + private static readonly ILog Log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private readonly IEventAggregator eventAggregator; + private readonly SettingService.SettingService settingService; + private readonly ISet<int> highPrioQueue = new HashSet<int>{7}; + private readonly Random random = new Random(); + private CancellationTokenSource tokenSrc; + + public FlowBasedSchedulingService(IEventAggregator eventAggregator, SettingService.SettingService settingService) + { + this.eventAggregator = eventAggregator; + this.settingService = settingService; + } + + public async Task StartScheduling() + { + var config = ParseConfiguration(); + var schedule = ConstructSchedule(config); + var cycles = 0; + + tokenSrc = new CancellationTokenSource(); + + while (!tokenSrc.IsCancellationRequested && cycles < config.Cycles) + { + await PerformSchedule(config, schedule).ConfigureAwait(false); + cycles++; + } + } + + private async Task PerformSchedule(FlowConfiguration config, IList<TimeSpan> schedule) + { + foreach (var timespan in schedule) + { + // Fire the GateOpenedEvent for the High Prio Queue. + eventAggregator.GetEvent<GlobalGateOpenedEvent>().Publish((OpenedTime: timespan.TotalMilliseconds, OpenedGates: highPrioQueue)); + + // Sleep. + await Task.Delay(timespan, tokenSrc.Token); + + // Fire the GateOpenedEvent for the Low Prio Queues. + var lowPrioGateOpenedTime = TimeSpan.FromMilliseconds(config.TotalCycleDuration - timespan.TotalMilliseconds); + eventAggregator.GetEvent<GlobalGateOpenedEvent>().Publish((OpenedTime: lowPrioGateOpenedTime.TotalMilliseconds, OpenedGates: new HashSet<int>(config.ActiveCbsQueues.Append(0)))); + + // Sleep. + await Task.Delay(lowPrioGateOpenedTime, tokenSrc.Token); + } + } + + private FlowConfiguration ParseConfiguration() + { + try + { + return JsonService.JsonService.DeserializeFromFile<FlowConfiguration>( + settingService.GetSettingValue<string>("flow_based_scheduler_config")); + } + catch (Exception e) + { + Log.Error($"Unable to deserialize configuration from {settingService.GetSettingValue<string>("flow_based_scheduler_config")}: {e}"); + return new FlowConfiguration(); + } + } + + /// <summary> + /// Constructs a Schedule for the Gate Openings and Closings, derived from the given configuration. + /// </summary> + /// <returns></returns> + private IList<TimeSpan> ConstructSchedule(FlowConfiguration config) + { + // Initialize empty schedule. + var schedule = new List<TimeSpan>(); + + // Generate some Open Events for the TT queue and some Open Events for the CBS + BE queues. + foreach (var (count, duration) in config.ClosingEventsCountsAndDurations) + { + schedule.AddRange(Enumerable.Repeat(TimeSpan.FromMilliseconds(duration), count)); + } + + // Shuffle everything and return. + return schedule.OrderBy(x => random.Next()).ToList(); + } + + public void StopScheduling() + { + tokenSrc?.Cancel(); + } + } +} diff --git a/CBSVisualizer/CBSVisualizer.Services.SchedulingService/Implementation/RandomSchedulingService.cs b/CBSVisualizer/CBSVisualizer.Services.SchedulingService/RandomSchedulingService.cs similarity index 86% rename from CBSVisualizer/CBSVisualizer.Services.SchedulingService/Implementation/RandomSchedulingService.cs rename to CBSVisualizer/CBSVisualizer.Services.SchedulingService/RandomSchedulingService.cs index 1d325fda668be6c352bae7dd3c325a79eec804bb..3498b5086e06c24480831c1af5a7a37cf3bcbb5d 100644 --- a/CBSVisualizer/CBSVisualizer.Services.SchedulingService/Implementation/RandomSchedulingService.cs +++ b/CBSVisualizer/CBSVisualizer.Services.SchedulingService/RandomSchedulingService.cs @@ -1,14 +1,13 @@ -using CBSVisualizer.Messaging.Events; -using CBSVisualizer.Services.SchedulingService.Interface; -using log4net; -using Prism.Events; -using System; +using System; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; +using CBSVisualizer.Common.Interfaces; using CBSVisualizer.Messaging.Events.Queue; +using log4net; +using Prism.Events; -namespace CBSVisualizer.Services.SchedulingService.Implementation +namespace CBSVisualizer.Services.SchedulingService { public class RandomSchedulingService : ISchedulingService { @@ -17,10 +16,10 @@ namespace CBSVisualizer.Services.SchedulingService.Implementation private const string MaxDelaySettingKey = "random_scheduler_max_delay"; private CancellationTokenSource tokenSource; private readonly Random random = new Random(); - private readonly SettingService.Implementation.SettingService settings; + private readonly SettingService.SettingService settings; private readonly IEventAggregator eventAggregator; - public RandomSchedulingService(IEventAggregator aggregator, SettingService.Implementation.SettingService settingService) + public RandomSchedulingService(IEventAggregator aggregator, SettingService.SettingService settingService) { settings = settingService; eventAggregator = aggregator; diff --git a/CBSVisualizer/CBSVisualizer.Services.SchedulingService/SchedulingServiceProxy.cs b/CBSVisualizer/CBSVisualizer.Services.SchedulingService/SchedulingServiceProxy.cs new file mode 100644 index 0000000000000000000000000000000000000000..f71c292af754d1524099ebf2e05b131dcf317c05 --- /dev/null +++ b/CBSVisualizer/CBSVisualizer.Services.SchedulingService/SchedulingServiceProxy.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using CBSVisualizer.Common.Enums; +using CBSVisualizer.Common.Interfaces; +using Prism.Events; + +namespace CBSVisualizer.Services.SchedulingService +{ + /// <summary> + /// Instantiates the correct SchedulingService depending on the setting value. + /// </summary> + public class SchedulingServiceProxy : ISchedulingService + { + private readonly IEventAggregator eventAggregator; + private readonly SettingService.SettingService settingService; + private ISchedulingService internalSchedulingService; + + public SchedulingServiceProxy(IEventAggregator eventAggregator, SettingService.SettingService settingService) + { + this.eventAggregator = eventAggregator; + this.settingService = settingService; + } + + public async Task StartScheduling() + { + SetInternalService(); + await internalSchedulingService.StartScheduling(); + } + + private void SetInternalService() + { + internalSchedulingService = Enum.Parse(typeof(SchedulerType), settingService.GetSettingValue<string>("scheduler")) switch + { + SchedulerType.FlowBased => new FlowBasedSchedulingService(eventAggregator, settingService), + _ => new RandomSchedulingService(eventAggregator, settingService), + }; + } + + public void StopScheduling() + { + internalSchedulingService.StopScheduling(); + } + } +} diff --git a/CBSVisualizer/CBSVisualizer.Services.SettingsService/Implementation/SettingService.cs b/CBSVisualizer/CBSVisualizer.Services.SettingsService/SettingService.cs similarity index 63% rename from CBSVisualizer/CBSVisualizer.Services.SettingsService/Implementation/SettingService.cs rename to CBSVisualizer/CBSVisualizer.Services.SettingsService/SettingService.cs index f2d660fae87e7808c4753af824958853da2ff7e7..e7be406064ced24b9849bb52813a4db2e0e49c70 100644 --- a/CBSVisualizer/CBSVisualizer.Services.SettingsService/Implementation/SettingService.cs +++ b/CBSVisualizer/CBSVisualizer.Services.SettingsService/SettingService.cs @@ -6,7 +6,7 @@ using CBSVisualizer.Common.Enums; using CBSVisualizer.Services.SettingService.Types; using CBSVisualizer.Services.SettingService.Types.Abstract; -namespace CBSVisualizer.Services.SettingService.Implementation +namespace CBSVisualizer.Services.SettingService { public class SettingService { @@ -47,13 +47,16 @@ namespace CBSVisualizer.Services.SettingService.Implementation var schedulersGroupMembers = new ObservableCollection<Setting>(); // Used scheduler. - ISet<string> schedulers = new HashSet<string> { "Random" }; + ISet<string> schedulers = new HashSet<string> { Enum.GetName(typeof(SchedulerType), SchedulerType.Random), Enum.GetName(typeof(SchedulerType), SchedulerType.FlowBased) }; schedulersGroupMembers.Add(new SelectionSetting("scheduler", "Used Scheduler", schedulers.First(), schedulers)); // Random Scheduler: Max & Min delays. schedulersGroupMembers.Add(new StringSetting("random_scheduler_min_delay", "Random Scheduler: Minimum Gate Opened Time [ms]", "500")); schedulersGroupMembers.Add(new StringSetting("random_scheduler_max_delay", "Random Scheduler: Maximum Gate Opened Time [ms]", "5000")); + // Flow-based: path to the Flow Configuration. + schedulersGroupMembers.Add(new PathSetting("flow_based_scheduler_config", "Flow-Based Scheduler: Flow Configuration", "flowcfg.json", SelectionMode.File)); + settingGroups.Add(new SettingGroup("Schedulers", schedulersGroupMembers)); } @@ -75,21 +78,16 @@ namespace CBSVisualizer.Services.SettingService.Implementation { if (setting.Key.Equals(key)) { - if (setting is StringSetting stringSetting) - { - return (T)Convert.ChangeType(stringSetting.SettingValue, typeof(T)); - } - else if (setting is SelectionSetting selectionSetting) - { - return (T)Convert.ChangeType(selectionSetting.SettingValue, typeof(T)); - } - else if (setting is PathSetting pathSetting) - { - return (T)Convert.ChangeType(pathSetting.SettingValue, typeof(T)); - } - else if (setting is BooleanSetting booleanSetting) + switch (setting) { - return (T)Convert.ChangeType(booleanSetting.SettingValue, typeof(T)); + case StringSetting stringSetting: + return (T)Convert.ChangeType(stringSetting.SettingValue, typeof(T)); + case SelectionSetting selectionSetting: + return (T)Convert.ChangeType(selectionSetting.SettingValue, typeof(T)); + case PathSetting pathSetting: + return (T)Convert.ChangeType(pathSetting.SettingValue, typeof(T)); + case BooleanSetting booleanSetting: + return (T)Convert.ChangeType(booleanSetting.SettingValue, typeof(T)); } } } @@ -106,21 +104,20 @@ namespace CBSVisualizer.Services.SettingService.Implementation { if (setting.Key.Equals(key)) { - if (setting is StringSetting stringSetting) - { - stringSetting.SettingValue = (string) Convert.ChangeType(newValue, typeof(string)); - } - else if (setting is SelectionSetting selectionSetting) - { - selectionSetting.SettingValue = (string)Convert.ChangeType(newValue, typeof(string)); - } - else if (setting is PathSetting pathSetting) - { - pathSetting.SettingValue = (string)Convert.ChangeType(newValue, typeof(string)); - } - else if (setting is BooleanSetting booleanSetting) + switch (setting) { - booleanSetting.SettingValue = (bool)Convert.ChangeType(newValue, typeof(bool)); + case StringSetting stringSetting: + stringSetting.SettingValue = (string) Convert.ChangeType(newValue, typeof(string)); + break; + case SelectionSetting selectionSetting: + selectionSetting.SettingValue = (string)Convert.ChangeType(newValue, typeof(string)); + break; + case PathSetting pathSetting: + pathSetting.SettingValue = (string)Convert.ChangeType(newValue, typeof(string)); + break; + case BooleanSetting booleanSetting: + booleanSetting.SettingValue = (bool)Convert.ChangeType(newValue, typeof(bool)); + break; } } } diff --git a/CBSVisualizer/CBSVisualizer.sln b/CBSVisualizer/CBSVisualizer.sln index 0c15cbf088b841d4cb61a3f932cce2ae55b5990c..d8c9c6863beaeb7647f41e4ab056a47a6683648d 100644 --- a/CBSVisualizer/CBSVisualizer.sln +++ b/CBSVisualizer/CBSVisualizer.sln @@ -40,6 +40,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CBSVisualizer.Services.Pack EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CBSVisualizer.Modules.Charts", "CBSVisualizer.Modules.Charts\CBSVisualizer.Modules.Charts.csproj", "{FD3FDABD-9C06-4AC7-A348-68D39929A038}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CBSVisualizer.Services.JsonService", "CBSVisualizer.Services.JsonService\CBSVisualizer.Services.JsonService.csproj", "{97D76788-9F72-4031-AF3C-BAF5E1F53A69}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -98,6 +100,10 @@ Global {FD3FDABD-9C06-4AC7-A348-68D39929A038}.Debug|Any CPU.Build.0 = Debug|Any CPU {FD3FDABD-9C06-4AC7-A348-68D39929A038}.Release|Any CPU.ActiveCfg = Release|Any CPU {FD3FDABD-9C06-4AC7-A348-68D39929A038}.Release|Any CPU.Build.0 = Release|Any CPU + {97D76788-9F72-4031-AF3C-BAF5E1F53A69}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {97D76788-9F72-4031-AF3C-BAF5E1F53A69}.Debug|Any CPU.Build.0 = Debug|Any CPU + {97D76788-9F72-4031-AF3C-BAF5E1F53A69}.Release|Any CPU.ActiveCfg = Release|Any CPU + {97D76788-9F72-4031-AF3C-BAF5E1F53A69}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -113,6 +119,7 @@ Global {61B7FF00-1B9D-4ABF-B3BF-667A1505415F} = {BFDCC6CE-CAA6-45AA-832F-0CBAB9A3C8BA} {274C0DC3-C59C-4C91-8130-6DEF2BDBD0A1} = {BFDCC6CE-CAA6-45AA-832F-0CBAB9A3C8BA} {FD3FDABD-9C06-4AC7-A348-68D39929A038} = {6D2194E0-E17B-44D6-AD8C-F3699549D259} + {97D76788-9F72-4031-AF3C-BAF5E1F53A69} = {BFDCC6CE-CAA6-45AA-832F-0CBAB9A3C8BA} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {EE8EFE44-67AF-451F-9DFD-7B458AA3B3B3} diff --git a/CBSVisualizer/CBSVisualizer/App.xaml.cs b/CBSVisualizer/CBSVisualizer/App.xaml.cs index 6b3c9e03a17f239339242535bde5a65122ab8260..aced66513c3d014ef12ff855c3fbcd34fd4e7b69 100644 --- a/CBSVisualizer/CBSVisualizer/App.xaml.cs +++ b/CBSVisualizer/CBSVisualizer/App.xaml.cs @@ -1,17 +1,16 @@ using Prism.Ioc; using CBSVisualizer.Views; using System.Windows; +using CBSVisualizer.Common.Interfaces; using Prism.Modularity; -using CBSVisualizer.Services.SchedulingService.Implementation; using CBSVisualizer.Modules.Link; using CBSVisualizer.Modules.SettingsDialog; using CBSVisualizer.Modules.MenuBar; using CBSVisualizer.Modules.Charts; using CBSVisualizer.Modules.QueueGroup; -using CBSVisualizer.Services.PacketService.Implementation; -using CBSVisualizer.Services.PacketService.Interface; -using CBSVisualizer.Services.SchedulingService.Interface; -using CBSVisualizer.Services.SettingService.Implementation; +using CBSVisualizer.Services.PacketService; +using CBSVisualizer.Services.SchedulingService; +using CBSVisualizer.Services.SettingService; using SciChart.Charting.Visuals; namespace CBSVisualizer @@ -35,8 +34,8 @@ namespace CBSVisualizer { // containerRegistry.RegisterSingleton<IMessageService, MessageService>(); containerRegistry.RegisterSingleton<SettingService>(); - containerRegistry.RegisterSingleton<ISchedulingService, RandomSchedulingService>(); - containerRegistry.RegisterSingleton<IPacketService, RandomPacketService>(); + containerRegistry.RegisterSingleton<ISchedulingService, SchedulingServiceProxy>(); + containerRegistry.RegisterSingleton<IPacketService, PacketServiceProxy>(); } protected override void ConfigureModuleCatalog(IModuleCatalog moduleCatalog)