/// <summary>
        /// Initializes a new instance of the <see cref="CpuLoadStatusType"/> class.
        /// </summary>
        /// <param name="accessor">GraphQL data loader context accessor.</param>
        /// <param name="cpuService">The application layer CpuService.</param>
        /// <param name="logger">The NLog logger instance.</param>
        public CpuLoadStatusType(
            IDataLoaderContextAccessor accessor,
            ICpuService cpuService,
            ILogger logger)
        {
            this.Field <DateTimeGraphType>("dateTime");

            this.Field(x => x.Processes, false, typeof(ListGraphType <CpuProcessType>)).Resolve(context => context.Source.Processes);

            this.Field(x => x.LastMinuteAverage);

            this.Field(x => x.Last5MinutesAverage);

            this.Field(x => x.Last15MinutesAverage);

            this.Field(x => x.KernelRealTime);

            this.Field(x => x.UserRealTime);

            this.Field <FloatGraphType, double>()
            .Name("TotalRealTime")
            .ResolveAsync(context =>
            {
                logger.Debug("TotalRealTime field");

                var cpuRealTimeLoad = context.Source;
                var loader          = accessor.Context.GetOrAddBatchLoader <DateTime, double>(
                    "GetTotalRealTimeLoadAsync",
                    cpuService.GetTotalRealTimeLoadsAsync);

                return(loader.LoadAsync(cpuRealTimeLoad.DateTime));
            });
        }
        public SqlServerGridController
            (ICpuService cpuBaseService, ISqlServerDataService sqlServerDataService)

        {
            _sqlServerDataService = sqlServerDataService;
            _cpuBaseService       = cpuBaseService;
        }
Пример #3
0
        public MainIndicatorsModel(CoreData coreData,
                                   StreamSettingsModel streamSettings,
                                   ICpuService cpuService // for precreation
                                   )
        {
            _coreData       = coreData;
            _streamSettings = streamSettings;

            _coreData.Subscriptions.SubscribeForProperties <IIndicatorCpu>(s => s.Load, (o, c, p) => Refresh(o, (d, i) => d.Cpu.ChartModel.AddValue(i.Load, 100)));
            _coreData.Subscriptions.SubscribeForAnyProperty <IIndicatorCpu>((o, c, p, _) => Refresh(o, RefreshCpu));

            _coreData.Subscriptions.SubscribeForProperties <IIndicatorCloudOut>(s => s.Bitrate, (o, c, p) => Refresh(o, (d, i) => d.CloudOut.ChartModel.AddValue(i.Bitrate / 1000.0, _coreData.Settings.Bitrate / 1000.0)));
            _coreData.Subscriptions.SubscribeForAnyProperty <IIndicatorCloudOut>((o, c, p, _) => Refresh(o, RefreshCloudOut));


            _coreData.Subscriptions.SubscribeForProperties <IIndicatorCloudIn>(s => s.Bitrate, (o, c, p) => Refresh(o, (d, i) => d.CloudIn.ChartModel.AddValue(i.Bitrate / 1000.0, _coreData.Settings.Bitrate / 1000.0)));
            _coreData.Subscriptions.SubscribeForAnyProperty <IIndicatorCloudIn>((o, c, p, _) => Refresh(o, RefreshCloudIn));

            _coreData.Subscriptions.SubscribeForProperties <IIndicatorEncoder>(s => s.State, (o, c, p) => Refresh(o, RefreshEncoderState));
            _coreData.Subscriptions.SubscribeForProperties <IIndicatorEncoder>(s => s.Data, (o, c, p) => Refresh(o, RefreshEncoderData));

            _coreData.Subscriptions.SubscribeForProperties <IChannel>(s => s.Bitrate, (o, c, p) => RefreshChannel(o));
            _coreData.Subscriptions.SubscribeForProperties <IChannel>(s => s.State, (o, c, p) => RefreshChannel(o));

            _coreData.Subscriptions.SubscribeForProperties <IDevice>(s => s.State, (o, c, p) => RefreshDevicesStates(o));

            _coreData.Subscriptions.SubscribeForProperties <IIndicatorVpn>(s => s.Sent, (o, c, p) => Refresh(o, (m, i) => m.Vpn.ChartModel.AddValue(i.Sent / 1000.0, 10)));
            _coreData.Subscriptions.SubscribeForProperties <IIndicatorVpn>(s => s.Received, (o, c, p) => Refresh(o, (m, i) => m.Vpn.Received.AddValue(i.Received / 1000.0, 10)));
            _coreData.Subscriptions.SubscribeForProperties <IIndicatorVpn>(s => s.State, (o, c, p) => Refresh(o, RefreshVpnState));
        }
Пример #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CpuWorker"/> class.
 /// </summary>
 /// <param name="cpuService">The application layer CpuService.</param>
 /// <param name="configuration">The IConfiguration instance.</param>
 /// <param name="logger">The NLog logger instance.</param>
 public CpuWorker(
     ICpuService cpuService,
     IConfiguration configuration,
     ILogger logger)
     : base(cpuService, configuration, logger)
 {
 }
        public WidgetGridController
            (ICpuService cpuBaseService, IWidgetService widgetService, ISqlServerDataService sqlServerDataService)

        {
            _sqlServerDataService = sqlServerDataService;
            _widgetService        = widgetService;
            _cpuBaseService       = cpuBaseService;
        }
Пример #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CpuFrequencyWorker"/> class.
 /// </summary>
 /// <param name="cpuService">The application layer CpuService.</param>
 /// <param name="configuration">The IConfiguration instance.</param>
 /// <param name="logger">The NLog logger instance.</param>
 public CpuFrequencyWorker(
     ICpuService cpuService,
     IConfiguration configuration,
     ILogger logger)
 {
     this.cpuService    = cpuService;
     this.configuration = configuration;
     this.logger        = logger;
 }
 public SimuladorPresenter(ISimuladorView simuladorView, TipoEscalonamento tipoEscalonamento)
 {
     _simuladorView = simuladorView;
     _ssdService    = new SsdService();
     _ramService    = new RamService(MmuService.TAMANHO_PAGINA_MB, ESPACO_RESERVADO_SO_MB);
     _mmuSerivce    = new MmuService(_ramService, _ssdService);
     _cpuService    = new CpuService(_mmuSerivce, FREQUENCIA_CLOCK_SEGUNDOS);
     ConfigurarTimer();
     ConfigurarDispatcher(tipoEscalonamento);
     _simuladorView.ExibirEspacoReservadoSo(_ramService.RetornarEspacoReservadoSoMB());
 }
Пример #8
0
        private void SetUp()
        {
            var services = new ServiceCollection();

            services.AddDbContext <PcPartPickerDbContext>(options =>
                                                          options.UseInMemoryDatabase(Guid.NewGuid().ToString()));

            services.AddScoped <ICpuService, CpuService>();

            services.AddScoped <IUnitOfWork, UnitOfWork>();

            services.AddScoped <IRepository <Cpu>, Repository <Cpu> >();
            IServiceProvider provider = services.BuildServiceProvider();

            _context    = provider.GetService <PcPartPickerDbContext>();
            _cpuService = provider.GetService <ICpuService>();

            _testCpus = GetCpus();
        }
Пример #9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CpuType"/> class.
        /// </summary>
        /// <param name="cpuService">The application layer CpuService.</param>
        /// <param name="logger">The NLog logger instance.</param>
        public CpuType(ICpuService cpuService, ILogger logger)
        {
            this.Field(x => x.Cores);
            this.Field(x => x.Model);
            this.Field(x => x.ScalingGovernor, true);
            this.Field("maxFrequency", x => x.MaximumFrequency);

            this.Field <CpuLoadStatusType>()
            .Name("LoadStatus")
            .ResolveAsync(async context =>
            {
                logger.Debug("LoadStatus field");

                return(await cpuService.GetLastLoadStatusAsync());
            });

            this.Connection <CpuLoadStatusType>()
            .Name("LoadStatuses")
            .Bidirectional()
            .ResolveAsync(async context =>
            {
                logger.Debug("LoadStatuses connection");

                var pagingInput  = context.GetPagingInput();
                var averageLoads = await cpuService.GetLoadStatusesAsync(pagingInput);

                return(averageLoads.ToConnection());
            });

            this.Field <CpuSensorsStatusType>()
            .Name("SensorsStatus")
            .ResolveAsync(async context =>
            {
                logger.Debug("SensorsStatus field");

                return(await cpuService.GetLastSensorsStatusAsync());
            });

            this.Connection <CpuSensorsStatusType>()
            .Name("SensorsStatuses")
            .Bidirectional()
            .ResolveAsync(async context =>
            {
                logger.Debug("SensorsStatuses connection");

                var pagingInput  = context.GetPagingInput();
                var temperatures = await cpuService.GetSensorsStatusesAsync(pagingInput);

                return(temperatures.ToConnection());
            });

            this.Field <CpuFrequencyType>()
            .Name("Frequency")
            .ResolveAsync(async context =>
            {
                logger.Debug("Frequency field");

                return(await cpuService.GetLastFrequencyAsync());
            });

            this.Connection <CpuFrequencyType>()
            .Name("Frequencies")
            .Bidirectional()
            .ResolveAsync(async context =>
            {
                logger.Debug("Frequencies connection");

                var pagingInput = context.GetPagingInput();
                var frequencies = await cpuService.GetFrequenciesAsync(pagingInput);

                return(frequencies.ToConnection());
            });
        }
Пример #10
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RaspberryPiType"/> class.
        /// </summary>
        /// <param name="chipsetService">The application layer ChipsetService.</param>
        /// <param name="cpuService">The application layer CpuService.</param>
        /// <param name="randomAccessMemoryService">The application layer RandomAccessMemoryService.</param>
        /// <param name="swapMemoryService">The application layer SwapMemoryService.</param>
        /// <param name="gpuService">The application layer GpuService.</param>
        /// <param name="diskService">The application layer DiskService.</param>
        /// <param name="operatingSystemService">The application layer OsService.</param>
        /// <param name="networkService">The application layer NetworkService.</param>
        /// <param name="logger">The NLog logger instance.</param>
        public RaspberryPiType(
            IChipsetService chipsetService,
            ICpuService cpuService,
            IMemoryService <RandomAccessMemory, RandomAccessMemoryStatus> randomAccessMemoryService,
            IMemoryService <SwapMemory, SwapMemoryStatus> swapMemoryService,
            IGpuService gpuService,
            IDiskService diskService,
            IOsService operatingSystemService,
            INetworkService networkService,
            ILogger logger)
        {
            this.Field <ChipsetType>()
            .Name("Chipset")
            .ResolveAsync(async context =>
            {
                logger.Debug("Chipset field");

                return(await chipsetService.GetAsync());
            });

            this.Field <Cpu.CpuType>()
            .Name("Cpu")
            .ResolveAsync(async context =>
            {
                logger.Debug("Cpu field");

                return(await cpuService.GetAsync());
            });

            this.Field <MemoryType <RandomAccessMemory, RandomAccessMemoryStatus> >()
            .Name("Ram")
            .ResolveAsync(async context =>
            {
                logger.Debug("Ram field");

                return(await randomAccessMemoryService.GetAsync());
            });

            this.Field <MemoryType <SwapMemory, SwapMemoryStatus> >()
            .Name("swapMemory")
            .ResolveAsync(async context =>
            {
                logger.Debug("Swap Memory field");

                return(await swapMemoryService.GetAsync());
            });

            this.Field <GpuType>()
            .Name("Gpu")
            .ResolveAsync(async context =>
            {
                logger.Debug("Gpu field");

                return(await gpuService.GetAsync());
            });

            this.Field <Disk.DiskType>()
            .Name("Disk")
            .ResolveAsync(async context =>
            {
                logger.Debug("Disk field");

                return(await diskService.GetAsync());
            });

            this.Field <Os.OsType>()
            .Name("Os")
            .ResolveAsync(async context =>
            {
                logger.Debug("Os field");

                return(await operatingSystemService.GetAsync());
            });

            this.Field <Network.NetworkType>()
            .Name("Network")
            .ResolveAsync(async context =>
            {
                logger.Debug("Network field");

                return(await networkService.GetAsync());
            });
        }
Пример #11
0
 public CpusController(ICpuService service, IGoogleDriveService driveService)
 {
     _service      = service;
     _driveService = driveService;
 }
Пример #12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ControlPanelSubscription"/> class.
        /// </summary>
        /// <param name="cpuService">The application layer CpuService.</param>
        /// <param name="diskService">The application layer DiskService.</param>
        /// <param name="randomAccessMemoryService">The application layer RandomAccessMemoryService.</param>
        /// <param name="swapMemoryService">The application layer SwapMemoryService.</param>
        /// <param name="operatingSystemService">The application layer OsService.</param>
        /// <param name="networkService">The application layer NetworkService.</param>
        /// <param name="logger">The NLog logger instance.</param>
        public ControlPanelSubscription(
            ICpuService cpuService,
            IDiskService diskService,
            IMemoryService <RandomAccessMemory, RandomAccessMemoryStatus> randomAccessMemoryService,
            IMemoryService <SwapMemory, SwapMemoryStatus> swapMemoryService,
            IOsService operatingSystemService,
            INetworkService networkService,
            ILogger logger)
        {
            this.FieldSubscribe <CpuLoadStatusType>(
                "CpuLoadStatus",
                resolve: context =>
            {
                return(context.Source);
            },
                subscribe: context =>
            {
                logger.Info("CpuAverageLoad subscription");

                var messageHandlingContext = context.UserContext.As <MessageHandlingContext>();
                var graphQLUserContext     = messageHandlingContext.Get <GraphQLUserContext>("GraphQLUserContext");
                var userContext            = graphQLUserContext.GetUserContext();

                return(cpuService.GetLoadStatusObservable());
            });

            this.FieldSubscribe <CpuSensorsStatusType>(
                "CpuSensorsStatus",
                resolve: context =>
            {
                return(context.Source);
            },
                subscribe: context =>
            {
                logger.Info("CpuSensorsStatus subscription");

                var messageHandlingContext = context.UserContext.As <MessageHandlingContext>();
                var graphQLUserContext     = messageHandlingContext.Get <GraphQLUserContext>("GraphQLUserContext");
                var userContext            = graphQLUserContext.GetUserContext();

                return(cpuService.GetSensorsStatusObservable());
            });

            this.FieldSubscribe <CpuFrequencyType>(
                "CpuFrequency",
                resolve: context =>
            {
                return(context.Source);
            },
                subscribe: context =>
            {
                logger.Info("CpuFrequency subscription");

                var messageHandlingContext = context.UserContext.As <MessageHandlingContext>();
                var graphQLUserContext     = messageHandlingContext.Get <GraphQLUserContext>("GraphQLUserContext");
                var userContext            = graphQLUserContext.GetUserContext();

                return(cpuService.GetFrequencyObservable());
            });

            this.FieldSubscribe <MemoryStatusType <RandomAccessMemoryStatus> >(
                "RamStatus",
                resolve: context =>
            {
                return(context.Source);
            },
                subscribe: context =>
            {
                logger.Info("RamStatus subscription");

                var messageHandlingContext = context.UserContext.As <MessageHandlingContext>();
                var graphQLUserContext     = messageHandlingContext.Get <GraphQLUserContext>("GraphQLUserContext");
                var userContext            = graphQLUserContext.GetUserContext();

                return(randomAccessMemoryService.GetStatusObservable());
            });

            this.FieldSubscribe <MemoryStatusType <SwapMemoryStatus> >(
                "SwapMemoryStatus",
                resolve: context =>
            {
                return(context.Source);
            },
                subscribe: context =>
            {
                logger.Info("SwapMemoryStatus subscription");

                var messageHandlingContext = context.UserContext.As <MessageHandlingContext>();
                var graphQLUserContext     = messageHandlingContext.Get <GraphQLUserContext>("GraphQLUserContext");
                var userContext            = graphQLUserContext.GetUserContext();

                return(swapMemoryService.GetStatusObservable());
            });

            this.FieldSubscribe <FileSystemStatusType>(
                "FileSystemStatus",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <StringGraphType> > {
                Name = "FileSystemName"
            }),
                resolve: context =>
            {
                return(context.Source);
            },
                subscribe: context =>
            {
                logger.Info("FileSystemStatus subscription");

                var messageHandlingContext = context.UserContext.As <MessageHandlingContext>();
                var graphQLUserContext     = messageHandlingContext.Get <GraphQLUserContext>("GraphQLUserContext");
                var userContext            = graphQLUserContext.GetUserContext();

                var fileSystemName = context.GetArgument <string>("fileSystemName");

                return(diskService.GetFileSystemStatusObservable(fileSystemName));
            });

            this.FieldSubscribe <OsStatusType>(
                "OsStatus",
                resolve: context =>
            {
                return(context.Source);
            },
                subscribe: context =>
            {
                logger.Info("OsStatus subscription");

                var messageHandlingContext = context.UserContext.As <MessageHandlingContext>();
                var graphQLUserContext     = messageHandlingContext.Get <GraphQLUserContext>("GraphQLUserContext");
                var userContext            = graphQLUserContext.GetUserContext();

                return(operatingSystemService.GetStatusObservable());
            });

            this.FieldSubscribe <NetworkInterfaceStatusType>(
                "NetworkInterfaceStatus",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <StringGraphType> > {
                Name = "NetworkInterfaceName"
            }),
                resolve: context =>
            {
                return(context.Source);
            },
                subscribe: context =>
            {
                logger.Info("NetworkInterfaceStatus subscription");

                var messageHandlingContext = context.UserContext.As <MessageHandlingContext>();
                var graphQLUserContext     = messageHandlingContext.Get <GraphQLUserContext>("GraphQLUserContext");
                var userContext            = graphQLUserContext.GetUserContext();

                var networkInterfaceName = context.GetArgument <string>("networkInterfaceName");

                return(networkService.GetNetworkInterfaceStatusObservable(networkInterfaceName));
            });
        }