Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Organized the project #329

Merged
merged 5 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 2 additions & 16 deletions bin/cbj_hub.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,8 @@ import 'dart:io';
import 'package:cbj_hub/application/boot_up/boot_up.dart';
import 'package:cbj_hub/infrastructure/cbj_web_server/cbj_web_server_repository.dart';
import 'package:cbj_hub/infrastructure/mqtt_server/mqtt_server_repository.dart';
import 'package:cbj_integrations_controller/infrastructure/bindings/binding_repository.dart';
import 'package:cbj_integrations_controller/infrastructure/local_db/local_db_hive_repository.dart';
import 'package:cbj_integrations_controller/infrastructure/node_red/node_red_repository.dart';
import 'package:cbj_integrations_controller/infrastructure/room/saved_rooms_repo.dart';
import 'package:cbj_integrations_controller/infrastructure/routines/routine_repository.dart';
import 'package:cbj_integrations_controller/infrastructure/saved_devices/saved_devices_repo.dart';
import 'package:cbj_integrations_controller/infrastructure/scenes/scene_repository.dart';
import 'package:cbj_integrations_controller/infrastructure/shared_variables.dart';
import 'package:cbj_integrations_controller/infrastructure/system_commands/system_commands_manager_d.dart';
import 'package:cbj_integrations_controller/initialize_integrations_controller.dart';
import 'package:cbj_integrations_controller/injection.dart';
import 'package:network_tools/network_tools.dart';
Expand All @@ -26,20 +19,13 @@ Future<void> main(List<String> arguments) async {
env: Env.devPc,
);

await BootUp.setup();
BootUp();
}

/// All instances of Repos
void setInstancesOfRepos(String projectRootDirectoryPath) {
SystemCommandsManager();
MqttServerRepository();
CbjWebServerRepository();
SavedRoomsRepo();
SavedDevicesRepo();
RoutineCbjRepository();
HiveRepository();
NodeRedRepository();
BindingCbjRepository();
SceneCbjRepository();
SharedVariables(projectRootDirectoryPath);
SharedVariables().projectRootDirectoryPath = projectRootDirectoryPath;
}
10 changes: 1 addition & 9 deletions lib/application/boot_up/boot_up.dart
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
import 'package:cbj_hub/application/connector/connector.dart';
import 'package:cbj_integrations_controller/domain/rooms/i_saved_rooms_repo.dart';
import 'package:cbj_integrations_controller/domain/scene/i_scene_cbj_repository.dart';
import 'package:cbj_integrations_controller/initialize_integrations_controller.dart';

class BootUp {
BootUp() {
setup();
}

static Future<void> setup() async {
// Return all saved rooms
await ISavedRoomsRepo.instance.getAllRooms();

await ISceneCbjRepository.instance.getAllScenesAsMap();

Future<void> setup() async {
await setupIntegrationsController();

Connector.startConnector();
}
}
24 changes: 4 additions & 20 deletions lib/application/connector/connector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import 'package:cbj_integrations_controller/domain/room/room_entity.dart';
import 'package:cbj_integrations_controller/domain/room/value_objects_room.dart';
import 'package:cbj_integrations_controller/domain/rooms/i_saved_rooms_repo.dart';
import 'package:cbj_integrations_controller/domain/saved_devices/i_saved_devices_repo.dart';
import 'package:cbj_integrations_controller/infrastructure/devices/companies_connector_conjector.dart';
import 'package:cbj_integrations_controller/infrastructure/devices/companies_connector_conjecture.dart';
import 'package:cbj_integrations_controller/infrastructure/gen/cbj_hub_server/protoc_as_dart/cbj_hub_server.pbgrpc.dart';
import 'package:cbj_integrations_controller/infrastructure/generic_devices/abstract_device/device_entity_abstract.dart';
import 'package:cbj_integrations_controller/infrastructure/generic_devices/abstract_device/device_entity_dto_abstract.dart';
import 'package:cbj_integrations_controller/infrastructure/hub_client/hub_client.dart';
import 'package:cbj_integrations_controller/utils.dart';
import 'package:mqtt_client/mqtt_client.dart';
import 'package:rxdart/rxdart.dart';

class Connector {
static Future<void> startConnector() async {
Expand All @@ -35,7 +35,7 @@ class Connector {
final ISavedDevicesRepo savedDevicesRepo = ISavedDevicesRepo.instance;

final Map<String, DeviceEntityAbstract> allDevices =
await savedDevicesRepo.getAllDevices();
await savedDevicesRepo.getAllDevicesAfterInitialize();

for (final String deviceId in allDevices.keys) {
ConnectorStreamToMqtt.toMqttController.add(
Expand All @@ -53,7 +53,7 @@ class Connector {

IMqttServerRepository.instance.sendToApp();

CompaniesConnectorConjector.updateAllDevicesReposWithDeviceChanges(
CompaniesConnectorConjecture().updateAllDevicesReposWithDeviceChanges(
ConnectorDevicesStreamFromMqtt.fromMqttStream,
);

Expand Down Expand Up @@ -135,19 +135,3 @@ class Connector {
}
}
}

/// Connect all streams from the internet devices into one stream that will be
/// send to mqtt broker to update devices states
class ConnectorStreamToMqtt {
static StreamController<MapEntry<String, dynamic>> toMqttController =
StreamController();

static Stream<MapEntry<String, dynamic>> get toMqttStream =>
toMqttController.stream.asBroadcastStream();
}

/// Connect all streams from the mqtt devices changes into one stream that will
/// be sent to whoever need to be notify of changes
class ConnectorDevicesStreamFromMqtt {
static BehaviorSubject<dynamic> fromMqttStream = BehaviorSubject<dynamic>();
}
20 changes: 0 additions & 20 deletions lib/domain/app_communication/i_app_communication_repository.dart

This file was deleted.

9 changes: 0 additions & 9 deletions lib/domain/remote_pipes/i_remote_pipes_repository.dart

This file was deleted.

30 changes: 0 additions & 30 deletions lib/domain/remote_pipes/remote_pipes_entity.dart

This file was deleted.

16 changes: 0 additions & 16 deletions lib/domain/remote_pipes/remote_pipes_errors.dart

This file was deleted.

17 changes: 0 additions & 17 deletions lib/domain/remote_pipes/remote_pipes_failures.dart

This file was deleted.

16 changes: 0 additions & 16 deletions lib/domain/remote_pipes/remote_pipes_validators.dart

This file was deleted.

50 changes: 0 additions & 50 deletions lib/domain/remote_pipes/remote_pipes_value_objects.dart

This file was deleted.

Loading