class WeatherForecastContainer(DeclarativeContainer):
    weather_forecast_repository = Dependency()
    weather_forecast_loader = Dependency()

    timestamp_round_algorithm = Factory(CeilTimestampRoundAlgorithm,
                                        round_step=TIME_TICK)
    weather_forecast_preprocessor = Factory(
        SoftMWeatherProcessor,
        timestamp_round_algorithm=timestamp_round_algorithm,
        timestamp_interpolation_algorithm=Factory(
            TimestampInterpolationAlgorithm, timestamp_round_algorithm,
            TIME_TICK),
        timestamp_filter_algorithm=Factory(FullClosedTimestampFilterAlgorithm),
        border_values_interpolation_algorithm=Factory(
            LinearInsideValueInterpolationAlgorithm),
        internal_values_interpolation_algorithm=Factory(
            LinearOutsideValueInterpolationAlgorithm))

    weather_forecast_service = Factory(
        SimpleWeatherForecastService,
        weather_forecast_loader=weather_forecast_loader,
        weather_forecast_processor=weather_forecast_preprocessor,
        weather_forecast_repository=weather_forecast_repository,
        preload_timedelta=Object(pd.Timedelta(hours=3)),
        executor=None)
class TempGraphContainer(DeclarativeContainer):
    temp_graph_repository = Dependency()
    temp_graph_loader = Dependency()

    temp_graph_update_service = Factory(
        SimpleTempGraphUpdateService,
        temp_graph_loader=temp_graph_loader,
        temp_graph_dumper=temp_graph_repository
    )
Beispiel #3
0
class ControlActionReportContainer(DeclarativeContainer):
    config = Configuration(strict=True)

    control_action_repository = Dependency()

    control_action_report_service = Factory(
        ControlActionReportService,
        timestamp_report_pattern_v1=config.timestamp_report_pattern_v1,
        control_action_repository=control_action_repository)
class UpdateContainer(DeclarativeContainer):
    config = Configuration(strict=True)

    control_actions_predictor = Dependency()
    temp_graph_updater = Dependency()
    weather_forecast_updater = Dependency()

    control_actions_predictor.enable_async_mode()
    temp_graph_updater.enable_async_mode()
    weather_forecast_updater.enable_async_mode()

    temp_graph_updatable_item = Singleton(
        TempGraphUpdatableItem,
        provider=temp_graph_updater.provider,
        update_interval=Callable(
            pd.Timedelta,
            seconds=config.update_intervals.temp_graph
        )
    )

    weather_forecast_updatable_item = Singleton(
        WeatherForecastUpdatableItem,
        provider=weather_forecast_updater.provider,
        update_interval=Callable(
            pd.Timedelta,
            seconds=config.update_intervals.weather_forecast
        )
    )

    control_action_updatable_item = Singleton(
        ControlActionUpdatableItem,
        provider=control_actions_predictor.provider,
        dependencies=List(
            temp_graph_updatable_item,
            weather_forecast_updatable_item
        )
    )

    updater_service = Singleton(
        SimpleUpdaterService,
        item_to_update=control_action_updatable_item
    )
Beispiel #5
0
class UIContainer(DeclarativeContainer):

    application: Dependency[QApplication] = Dependency()
    library_manager: Dependency[LibraryManager] = Dependency()

    settings_window = Factory(SettingsWindow)
    window_controller = Singleton(WindowController, application,
                                  library_manager)

    libraries_model = Factory(LibrariesModel, library_manager=library_manager)
    libraries_window = Factory(
        LibrariesWindow,
        library_manager=library_manager,
        libraries_model=libraries_model,
    )
    main_window = Factory(
        MainWindow,
        library_manager=library_manager,
        window_controller=window_controller,
        libraries_window_factory=libraries_window.provider,
        settings_window_factory=settings_window.provider,
    )
Beispiel #6
0
class Services(DeclarativeContainer):
    config = Configuration(strict=True)

    temp_graph_loader = Dependency()
    weather_forecast_loader = Dependency()

    dynamic_settings_repository = Dependency()
    temp_graph_repository = Dependency()
    time_delta_loader = Dependency()
    weather_forecast_repository = Dependency()
    control_actions_repository = Dependency()

    dynamic_settings_pkg = Container(
        DynamicSettingsContainer,
        config=config.dynamic_settings,
        settings_repository=dynamic_settings_repository)
    temp_graph_pkg = Container(TempGraphContainer,
                               temp_graph_loader=temp_graph_loader,
                               temp_graph_repository=temp_graph_repository)
    weather_forecast_pkg = Container(
        WeatherForecastContainer,
        weather_forecast_loader=weather_forecast_loader,
        weather_forecast_repository=weather_forecast_repository)
    control_action_pkg = Container(
        ControlActionContainer,
        config=config.control_action_predictor,
        time_delta_loader=time_delta_loader,
        temp_graph_repository=temp_graph_repository,
        weather_forecast_repository=weather_forecast_repository,
        control_actions_repository=control_actions_repository,
        dynamic_settings_repository=dynamic_settings_repository)
    control_action_report_pkg = Container(
        ControlActionReportContainer,
        config=config.control_action_reporter,
        control_action_repository=control_actions_repository)
    updater_pkg = Container(
        UpdateContainer,
        config=config.updater,
        control_actions_predictor=control_action_pkg.temp_prediction_service,
        temp_graph_updater=temp_graph_pkg.temp_graph_update_service,
        weather_forecast_updater=weather_forecast_pkg.weather_forecast_service)
Beispiel #7
0
class ControlActionContainer(DeclarativeContainer):
    config = Configuration(strict=True)

    temp_graph_repository = Dependency()
    weather_forecast_repository = Dependency()
    control_actions_repository = Dependency()
    dynamic_settings_repository = Dependency()
    time_delta_loader = Dependency()

    # TODO: перевести на репозиторий
    temp_correlation_table = Resource(
        TempCorrelationTable,
        config.temp_correlation_table_path
    )

    # TODO: перевести на репозиторий
    time_delta_df = Resource(
        HeatingObjTimedeltaResource,
        loader=time_delta_loader
    )

    model_requirements = Factory(
        TimedeltaModelRequirementsWithoutHistory,
        time_delta_df
    )

    timestamp_round_algo = Factory(
        CeilTimestampRoundAlgorithm,
        round_step=TIME_TICK
    )

    temp_constrains = Factory(
        SingleTypeHeatingObjOnWeatherConstraint,
        temp_requirements_predictor=Factory(
            TempGraphRequirementsPredictor,
            temp_graph=temp_graph_repository.provided.load_temp_graph.call(),
            weather_temp_round_algorithm=Factory(ArithmeticFloatRoundAlgorithm)
        ),
        timestamp_round_algo=timestamp_round_algo,
        temp_requirements_coefficient=Coroutine(
            get_one_setting,
            dynamic_settings_repository,
            config_names.APARTMENT_HOUSE_MIN_TEMP_COEFFICIENT
        ),
        min_model_error=Coroutine(
            get_one_setting,
            dynamic_settings_repository,
            config_names.MODEL_ERROR_SIZE
        )
    )

    heating_system_model = Factory(
        CorrTableHeatingSystemModel,
        temp_correlation_df=temp_correlation_table,
        timedelta_df=time_delta_df,
    )

    control_action_predictor = Factory(
        SingleCircuitControlActionPredictor,
        heating_system_model=heating_system_model,
        temp_requirements_constraint=temp_constrains,
        min_boiler_temp=Coroutine(
            get_one_setting,
            dynamic_settings_repository,
            config_names.MIN_BOILER_TEMP
        ),
        max_boiler_temp=Coroutine(
            get_one_setting,
            dynamic_settings_repository,
            config_names.MAX_BOILER_TEMP
        ),
        min_regulation_step=0.3
    )

    temp_prediction_service = Factory(
        ControlActionPredictionService,
        weather_forecast_repository=weather_forecast_repository,
        control_actions_repository=control_actions_repository,
        control_action_predictor=control_action_predictor,
        model_requirements=model_requirements,
        timestamp_round_algo=timestamp_round_algo,
        timedelta=TIME_TICK,
        timedelta_predict_forward=pd.Timedelta(seconds=3600),
        executor=None
    )