private void _service_Connected(object sender, PviEventArgs e)
        {
            string serviceName = String.Empty;

            if (sender is Service service)
            {
                serviceName = service.FullName;
            }

            var cpuWrapper      = new CpuWrapper(_service, _eventNotifier);
            var variableWrapper = new VariableWrapper(_service, _eventNotifier);

            var fw         = new FileWrapper();
            var cpuManager = new CpuManager(cpuWrapper);

            var variableInfo = new VariableInfoCollection(fw);

            var variableManager = new VariableManager(variableWrapper, variableInfo);

            var pviEventMsg = Utils.FormatPviEventMessage($"ServiceWrapper._service_Connected; ServiceName={serviceName}", e);

            _eventNotifier.OnPviServiceConnected(sender, new PviApplicationEventArgs()
            {
                Message         = pviEventMsg,
                ServiceWrapper  = this,
                CpuManager      = cpuManager,
                CpuWrapper      = cpuWrapper,
                VariableManager = variableManager,
                VariableWrapper = variableWrapper
            });

            _pollingService = new PollingService(_service, cpuManager);
            _pollingService.Start();
        }
Exemplo n.º 2
0
        private void SetupPolling()
        {
            _logger.Info("Setting up polling service");
            var pollingClients = RetrieveJobs(Settings.ConfigServiceUrl).ToList();

            _logger.Info("{0} clients configured".Fmt(pollingClients.Count()));

            // retrieve configured clients
            foreach (var clientSettings in pollingClients)
            {
                _logger.Info("Setting up polling service");

                // create service
                var pollingSvc = new PollingService(Program.Container.GetInstance <IScheduler>(), Program.Container.GetInstance <ILogger>());
                _pollingJobs.Add(pollingSvc);

                // start the service
                pollingSvc.Start(clientSettings);
            }
        }