Exemplo n.º 1
0
 /// <summary>
 ///     Ctor
 /// </summary>
 /// <param name="logger"></param>
 /// <param name="fileSystemManager"></param>
 /// <param name="config"></param>
 public IoTService(ILogger <IIoTService> logger, IFileSystemManager fileSystemManager,
                   NeonConfig config,
                   IEventDatabaseService eventDatabaseService,
                   IMqttService mqttService
                   )
 {
     _logger               = logger;
     _mqttService          = mqttService;
     _eventDatabaseService = eventDatabaseService;
     _fileSystemManager    = fileSystemManager;
     _config               = config;
 }
Exemplo n.º 2
0
 public ScriptEngineService(ILogger <ScriptEngineService> logger,
                            INeonManager neonManager,
                            IFileSystemManager fileSystemManager,
                            NeonConfig neonConfig)
 {
     _logger            = logger;
     _neonManager       = neonManager;
     _fileSystemManager = fileSystemManager;
     _neonConfig        = neonConfig;
     _config            = neonConfig.ServicesConfig.ScriptEngineConfig;
     Functions          = new List <ScriptFunctionData>();
     Variables          = new List <ScriptEngineVariable>();
 }
Exemplo n.º 3
0
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            _config = Program.NeonManager.Config;

            services.AddControllers();

            services.AddOpenApiDocument();

            services.AddWebSockets(options =>
            {
                options.KeepAliveInterval = TimeSpan.FromSeconds(120);
                options.ReceiveBufferSize = 4 * 1024;
            });

            services.AddCors(c =>
            {
                c.AddPolicy("AllowOrigin", options =>
                {
                    options
                    .AllowAnyHeader()
                    .AllowAnyOrigin();
                });
            });


            services.AddMetrics();

            services.AddSingleton(typeof(ILogger <>), typeof(LoggerEx <>));

            services.AddMediatR(AssemblyUtils.GetAppAssemblies().ToArray());
            services.AddHttpClient();
            services.AddWebSocketManager();

            services.AddMvc().AddNewtonsoftJson(jo =>
            {
                jo.SerializerSettings.ContractResolver = new DefaultContractResolver()
                {
                    NamingStrategy = new SnakeCaseNamingStrategy()
                };
            });


            Program.NeonManager.ContainerBuilder.Populate(services);

            Program.NeonManager.Init();

            ApplicationContainer = Program.NeonManager.Build();

            return(new AutofacServiceProvider(ApplicationContainer));
        }
Exemplo n.º 4
0
        public ScriptService(ILogger <ScriptService> logger, NeonConfig neonConfig, IServicesManager servicesManager,
                             IFileSystemManager fileSystemManager)
        {
            GlobalFunctions    = new List <ScriptFunctionData>();
            _logger            = logger;
            _neonConfig        = neonConfig;
            _fileSystemManager = fileSystemManager;
            _servicesManager   = servicesManager;

            AssemblyUtils.ScanAllAssembliesFromAttribute(typeof(ScriptEngineAttribute)).ForEach(se =>
            {
                var attr = se.GetCustomAttribute <ScriptEngineAttribute>();
                _scriptsEngines.Add(attr.Name, se);
            });
        }
Exemplo n.º 5
0
 public ComponentsService(ILogger <ComponentsService> logger,
                          ITaskExecutorService taskExecutorService,
                          IServicesManager servicesManager,
                          NeonConfig config,
                          IFileSystemManager fileSystemManager)
 {
     _logger              = logger;
     _config              = config;
     _servicesManager     = servicesManager;
     _taskExecutorService = taskExecutorService;
     _fileSystemManager   = fileSystemManager;
     AvailableComponents  = new List <ComponentInfo>();
     RunningComponents    = new ObservableCollection <RunningComponentInfo>();
     _componentsTypes     = new Dictionary <ComponentInfo, Type>();
 }
Exemplo n.º 6
0
 public ComponentsService(ILogger <ComponentsService> logger,
                          NeonConfig neonConfig,
                          INeonManager neonManager,
                          IFileSystemManager fileSystemManager,
                          ISchedulerService schedulerService)
 {
     _logger             = logger;
     _neonConfig         = neonConfig;
     _fileSystemManager  = fileSystemManager;
     _neonManager        = neonManager;
     _config             = _neonConfig.ComponentsConfig;
     _schedulerService   = schedulerService;
     ComponentsData      = new ObservableCollection <ComponentData>();
     AvailableComponents = new List <AvailableComponent>();
 }
Exemplo n.º 7
0
        public ScriptService(ILogger <ScriptService> logger, NeonConfig neonConfig, IServicesManager servicesManager,
                             IFileSystemManager fileSystemManager)
        {
            GlobalFunctions           = new List <LuaScriptFunctionData>();
            _logger                   = logger;
            _neonConfig               = neonConfig;
            _fileSystemManager        = fileSystemManager;
            _servicesManager          = servicesManager;
            _luaEngine                = new Lua();
            _luaEngine.State.Encoding = Encoding.UTF8;

            _luaEngine.HookException += (sender, args) =>
            {
                _logger.LogError($"Error during execute LUA =>\n {args.Exception.FlattenException()}");
            };
        }
Exemplo n.º 8
0
 public PluginsManager(ILogger logger, IFileSystemManager fileSystemManager, NeonConfig neonConfig)
 {
     _logger            = logger.ForContext <PluginsManager>();
     _fileSystemManager = fileSystemManager;
     _pluginsDirectory  = neonConfig.ServicesConfig.PluginsConfig.Directory.DirectoryName;
 }
Exemplo n.º 9
0
 public FileSystemManager(NeonConfig config, ILogger logger)
 {
     _logger = logger;
     _config = config;
 }
Exemplo n.º 10
0
 public DarkSkyComponent(ILoggerFactory loggerFactory, IIoTService ioTService, NeonConfig neonConfig, IComponentsService componentsService) : base(loggerFactory, ioTService, componentsService)
 {
     _homeConfig = neonConfig.HomeConfig;
 }
Exemplo n.º 11
0
 public AuthenticationManager(NeonConfig neonConfig, IDataAccess <UserEntity> dataAccess)
 {
     _neonConfig = neonConfig;
     _dataAccess = dataAccess;
 }
Exemplo n.º 12
0
 public CommonScriptModule(IIoTService ioTService, IScriptEngineService scriptEngineService, IFileSystemManager fileSystemManager, NeonConfig neonConfig, ILogger <ScriptEngineService> logger, IHttpClientFactory httpClientFactory)
 {
     _httpClientFactory   = httpClientFactory;
     _logger              = logger;
     _ioTService          = ioTService;
     _fileSystemManager   = fileSystemManager;
     _scriptEngineService = scriptEngineService;
     _scriptEngineConfig  = neonConfig.ServicesConfig.ScriptEngineConfig;
 }
Exemplo n.º 13
0
        public LuaScriptEngine(ILogger <LuaScriptEngine> logger, IFileSystemManager fileSystemManager, NeonConfig neonConfig)
        {
            _logger                   = logger;
            _fileSystemManager        = fileSystemManager;
            _neonConfig               = neonConfig;
            _luaEngine                = new Lua();
            _luaEngine.State.Encoding = Encoding.UTF8;
            _luaEngine.LoadCLRPackage();

            CheckModulesDirectory();

            _luaEngine.HookException += (sender, args) =>
            {
                if (args.Exception is LuaException luaException)
                {
                    _logger.LogError($"Error during execute LUA =>\n {FormatException(luaException)}");
                }
                else
                {
                    _logger.LogError($"Error during execute LUA =>\n {args.Exception.FlattenException()}");
                }
            };

            _logger.LogInformation($"LUA script engine ready");
        }
Exemplo n.º 14
0
 public void AddConfiguration(NeonConfig config)
 {
     _neonConfig = config;
 }
Exemplo n.º 15
0
 public TaskExecutorService(NeonConfig neonConfig, ILogger <TaskExecutorService> logger)
 {
     _logger     = logger;
     _neonConfig = neonConfig;
     _taskPool   = new TaskPool(_neonConfig.Tasks.MaxNumThreads);
 }
Exemplo n.º 16
0
 public NotificationService(ILogger <NotificationService> logger, IMediator mediator, IFileSystemManager fileSystemManager, INeonManager neonManager, List <NotifierData> notifierData, NeonConfig neonConfig)
 {
     _logger                  = logger;
     _fileSystemManager       = fileSystemManager;
     _mediator                = mediator;
     _neonManager             = neonManager;
     _notifierData            = notifierData;
     _notifierConfigDirectory = neonConfig.NotifierConfig.DirectoryConfig.DirectoryName;
 }
Exemplo n.º 17
0
 public LogScriptModule(ILogger <ScriptEngineService> logger, NeonConfig neonConfig)
 {
     _logger = logger;
     _config = neonConfig.ServicesConfig.ScriptEngineConfig;
 }
Exemplo n.º 18
0
 public TelegramNotifier(ILogger <TelegramNotifier> logger, INoSqlService noSqlService, NeonConfig neonConfig, IScriptEngineService scriptEngineService, IUserInteractionService userInteractionService)
 {
     _logger = logger;
     _scriptEngineService    = scriptEngineService;
     _userInteractionService = userInteractionService;
     _neonConfig             = neonConfig;
     _noSqlService           = noSqlService;
     _httpClient             = new HttpClient();
 }
Exemplo n.º 19
0
 public FileSystemManager(ILogger logger, NeonConfig neonConfig, ISecretKeyManager secretKeyManager)
 {
     _logger           = logger.ForContext <FileSystemManager>();
     _rootDirectory    = neonConfig.EngineConfig.HomeDirectory;
     _secretKeyManager = secretKeyManager;
 }
Exemplo n.º 20
0
 public FileSystemController(IFileSystemManager fileSystemManager, NeonConfig neonConfig)
 {
     _fileSystemManager = fileSystemManager;
     _neonConfig        = neonConfig;
 }
Exemplo n.º 21
0
 public OwnTracksComponent(ILoggerFactory loggerFactory, IIoTService ioTService, IMqttService mqttService, NeonConfig neonConfig, IComponentsService componentsService) : base(loggerFactory, ioTService, componentsService)
 {
     _mqttService = mqttService;
     _config      = neonConfig;
 }
Exemplo n.º 22
0
 public ServicesManager(ILogger <IServicesManager> logger, NeonConfig neonConfig)
 {
     _logger     = logger;
     _neonConfig = neonConfig;
 }
Exemplo n.º 23
0
 private void DeserializeConfig()
 {
     _config = File.ReadAllText(_configFullPath).FromYaml <NeonConfig>();
 }
Exemplo n.º 24
0
 public IoTService(ILogger <IoTService> logger, INoSqlService noSqlService, NeonConfig neonConfig)
 {
     _logger       = logger;
     _noSqlService = noSqlService;
     _config       = neonConfig.ServicesConfig.IoTConfig;
 }
Exemplo n.º 25
0
 public MqttService(ILogger <MqttService> logger, NeonConfig neonConfig)
 {
     _logger = logger;
     _config = neonConfig.ServicesConfig.MqttConfig;
     MqttMessageObservable = new ReplaySubject <MqttMessage>();
 }
Exemplo n.º 26
0
 public SunComponent(ILoggerFactory loggerFactory, IIoTService ioTService, NeonConfig neonConfig, IComponentsService componentsService, IHttpClientFactory httpClientFactory) : base(loggerFactory, ioTService, componentsService)
 {
     _homeConfig = neonConfig.HomeConfig;
     _httpClient = httpClientFactory.CreateClient();
 }
Exemplo n.º 27
0
 public OwnTracksComponent(ILogger <OwnTracksComponent> logger, IMqttService mqttService,
                           IEventDatabaseService eventDatabaseService, IIoTService ioTService, NeonConfig neonConfig)
 {
     _logger               = logger;
     _mqttService          = mqttService;
     _eventDatabaseService = eventDatabaseService;
     _ioTService           = ioTService;
     _neonConfig           = neonConfig;
 }