Skip to content

Commit

Permalink
Merge pull request #202 from CyBear-Jinni/Changing_grpc
Browse files Browse the repository at this point in the history
Changing grpc
  • Loading branch information
guyluz11 authored Jan 27, 2024
2 parents 1700859 + bd9777b commit 05198ba
Show file tree
Hide file tree
Showing 21 changed files with 220 additions and 527 deletions.
1 change: 0 additions & 1 deletion bin/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import 'dart:io';

import 'package:cbj_integrations_controller/integrations_controller.dart';
import 'package:cbj_smart_device/application/usecases/core_u/smart_device_manager_u.dart';
import 'package:cbj_smart_device/infrastructure/datasources/core_d/manage_physical_components/device_pin_manager.dart';
import 'package:cbj_smart_device/utils.dart';

void main(List<String> arguments) async {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ abstract class ButtonObjectLocalAbstract {
);

/// Logic of two buttons
Future<void> changeBlindsPinsOutput(
Future changeBlindsPinsOutput(
BlindsObject blindsObject,
PinInformation firstLightPin,
PinInformation secondLightPin,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'package:cbj_smart_device/utils.dart';

class ButtonObjectLocalU extends ButtonObjectLocalAbstract {
@override
Future<void> buttonPressed(
Future buttonPressed(
SmartDeviceBase smartDevice,
PinInformation buttonPinNumber,
PinInformation lightPin,
Expand Down Expand Up @@ -50,7 +50,7 @@ class ButtonObjectLocalU extends ButtonObjectLocalAbstract {
}

@override
Future<void> buttonPressedForBoiler(
Future buttonPressedForBoiler(
BoilerObject boilerObject,
PinInformation buttonPinNumber,
PinInformation boiler,
Expand Down Expand Up @@ -94,7 +94,7 @@ class ButtonObjectLocalU extends ButtonObjectLocalAbstract {

/// Listen to two buttons but work only if one is pressed.
@override
Future<void> listenToTwoButtonPressedButtOnlyOneCanBePressedAtATime(
Future listenToTwoButtonPressedButtOnlyOneCanBePressedAtATime(
BlindsObject smartDevice,
PinInformation firstButtonPinNumber,
PinInformation firstBlindsPin,
Expand All @@ -119,7 +119,7 @@ class ButtonObjectLocalU extends ButtonObjectLocalAbstract {
}

@override
Future<void> listenToButtonPressAndChangeBlindStateAccordingly(
Future listenToButtonPressAndChangeBlindStateAccordingly(
BlindsObject blindsObject,
PinInformation buttonPinNumber,
PinInformation firstLightPin,
Expand All @@ -143,7 +143,7 @@ class ButtonObjectLocalU extends ButtonObjectLocalAbstract {

/// Logic of two buttons that cannot be pressed together
@override
Future<void> changeBlindsPinsOutput(
Future changeBlindsPinsOutput(
BlindsObject blindsObject,
PinInformation firstBlindsPin,
PinInformation secondBlindsPin,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import 'package:cbj_smart_device/application/usecases/button_object_u/simple_but
import 'package:cbj_smart_device/application/usecases/devices_pin_configuration_u/pin_information.dart';
import 'package:cbj_smart_device/application/usecases/wish_classes_u/off_wish_u.dart';
import 'package:cbj_smart_device/application/usecases/wish_classes_u/on_wish_u.dart';
import 'package:cbj_smart_device/infrastructure/datasources/core_d/manage_physical_components/device_pin_manager.dart';
import 'package:cbj_smart_device/infrastructure/repositories/button_object_r/button_object_r.dart';
import 'package:cbj_smart_device/utils.dart';

Expand All @@ -12,11 +11,12 @@ class ButtonWithLightObject extends ButtonObject {
ButtonWithLightObject(
super.id,
super.deviceName,
super.buttonPinInt,
int? buttonLightInt, {
// super.buttonPinInt,
// int? buttonLightInt,
{
super.buttonStatesAction,
}) {
buttonLight = DevicePinListManager().getGpioPin(buttonLightInt);
// buttonLight = DevicePinListManager().getGpioPin(buttonLightInt);

buttonObjectRepository = ButtonObjectR();
listenToButtonPress();
Expand All @@ -42,7 +42,7 @@ class ButtonWithLightObject extends ButtonObject {

/// Listen to the button press and execute actions from buttonStateActions
@override
Future<void> listenToButtonPress() async {
Future listenToButtonPress() async {
if (buttonPin == null) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import 'package:cbj_smart_device/application/usecases/devices_pin_configuration_
import 'package:cbj_smart_device/application/usecases/smart_device_objects_u/abstracts_devices/smart_device_base.dart';
import 'package:cbj_smart_device/application/usecases/smart_device_objects_u/abstracts_devices/smart_device_base_abstract.dart';
import 'package:cbj_smart_device/core/my_singleton.dart';
import 'package:cbj_smart_device/infrastructure/datasources/core_d/manage_physical_components/device_pin_manager.dart';
import 'package:cbj_smart_device/infrastructure/repositories/button_object_r/button_object_r.dart';
import 'package:cbj_smart_device/utils.dart';

Expand All @@ -12,10 +11,11 @@ class ButtonObject extends SmartDeviceBaseAbstract {
ButtonObject(
super.id,
super.deviceName,
int? buttonPinInt, {
// int? buttonPinInt,
{
this.buttonStatesAction,
}) {
buttonPin = DevicePinListManager().getGpioPin(buttonPinInt);
// buttonPin = DevicePinListManager().getGpioPin(buttonPinInt);

buttonObjectRepository = ButtonObjectR();
listenToButtonPress();
Expand Down Expand Up @@ -52,7 +52,7 @@ class ButtonObject extends SmartDeviceBaseAbstract {
static List<String> neededPinTypesList() => <String>['gpio'];

/// Listen to the button press and execute actions from buttonStateActions
Future<void> listenToButtonPress() async {
Future listenToButtonPress() async {
if (buttonPin == null) {
return;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/application/usecases/set_devices_u/set_devices_u.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class SetDevicesU {
late SetDevicesE _setDevicesE;

/// Setting all the devices from saved data
Future<void> setAllDevices({
Future setAllDevices({
List<SmartDeviceBaseAbstract>? deviceList,
}) async {
if (deviceList != null) {
Expand Down Expand Up @@ -49,7 +49,7 @@ class SetDevicesU {
// manualSetup();
}

Future<void> manualSetup() async {
Future manualSetup() async {
final String uuid = await _setDevicesE.getCurrentDeviceUUid();

MySingleton().smartDevicesList = <SmartDeviceBaseAbstract>[
Expand Down
2 changes: 1 addition & 1 deletion lib/application/usecases/smart_client/smart_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class SmartClient {
}

/// Turn smart device on
static Future<void> createStreamWithClients(String addressToHub) async {
static Future createStreamWithClients(String addressToHub) async {
channel = await createCbjSmartDeviceServerClient(addressToHub);
stub = CbjSmartDeviceConnectionsClient(channel!);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import 'package:cbj_smart_device/application/usecases/wish_classes_u/on_wish_u.d
import 'package:cbj_smart_device/application/usecases/wish_classes_u/smart_computer_wish_u.dart';
import 'package:cbj_smart_device/core/helper_methods.dart';
import 'package:cbj_smart_device/domain/entities/core_e/enums_e.dart';
import 'package:cbj_smart_device/infrastructure/datasources/core_d/manage_physical_components/device_pin_manager.dart';
import 'package:cbj_smart_device/infrastructure/repositories/smart_device_objects_r/smart_device_objects_r.dart';
import 'package:cbj_smart_device/utils.dart';

Expand Down Expand Up @@ -124,10 +123,11 @@ abstract class SmartDeviceBase extends SmartDeviceBaseAbstract {
PinInformation? addPinToGpioPinList(int pinNumber) {
// Check if pin is free to be taken,
// if not return negative number with error number
final PinInformation gpioPin =
DevicePinListManager().getGpioPin(pinNumber)!;
_gpioPinList.add(gpioPin);
return gpioPin;
// final PinInformation gpioPin =
// DevicePinListManager().getGpioPin(pinNumber)!;
// _gpioPinList.add(gpioPin);
// return gpioPin;
return null;
}

/// Return PossibleWishes object if
Expand Down Expand Up @@ -227,7 +227,7 @@ abstract class SmartDeviceBase extends SmartDeviceBaseAbstract {
}

/// Listen to button press
Future<void> listenToButtonPressed() async {
Future listenToButtonPressed() async {
ButtonObjectLocalU().buttonPressed(this, onOffButtonPin!, onOffPin!);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import 'package:cbj_smart_device/application/usecases/devices_pin_configuration_
import 'package:cbj_smart_device/application/usecases/smart_device_objects_u/abstracts_devices/smart_device_simple_abstract.dart';
import 'package:cbj_smart_device/application/usecases/wish_classes_u/off_wish_u.dart';
import 'package:cbj_smart_device/application/usecases/wish_classes_u/on_wish_u.dart';
import 'package:cbj_smart_device/infrastructure/datasources/core_d/manage_physical_components/device_pin_manager.dart';
import 'package:cbj_smart_device/utils.dart';

class BoilerObject extends SmartDeviceSimpleAbstract {
BoilerObject(
String? uuid,
String? smartInstanceName,
int? boilerPinNUmber,
int? boilerButtonPinNumber, {
// int? boilerPinNUmber,
// int? boilerButtonPinNumber,
{
int? onOffPinNumber,
int? onOffButtonPinNumber,
}) : super(
Expand All @@ -22,8 +22,8 @@ class BoilerObject extends SmartDeviceSimpleAbstract {
onOffButtonPinNumber: onOffButtonPinNumber,
) {
logger.i('New boiler object');
boilerPin = DevicePinListManager().getGpioPin(boilerPinNUmber);
boilerButtonPin = DevicePinListManager().getGpioPin(boilerButtonPinNumber);
// boilerPin = DevicePinListManager().getGpioPin(boilerPinNUmber);
// boilerButtonPin = DevicePinListManager().getGpioPin(boilerButtonPinNumber);
listenButtonsPress();
deviceType = CbjDeviceTypes.boiler;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import 'package:cbj_smart_device/application/usecases/button_object_u/button_obj
import 'package:cbj_smart_device/application/usecases/devices_pin_configuration_u/pin_information.dart';
import 'package:cbj_smart_device/application/usecases/smart_device_objects_u/abstracts_devices/smart_device_static_abstract.dart';
import 'package:cbj_smart_device/application/usecases/wish_classes_u/blinds_wish_u.dart';
import 'package:cbj_smart_device/infrastructure/datasources/core_d/manage_physical_components/device_pin_manager.dart';
import 'package:cbj_smart_device/utils.dart';

/// Object to control blinds
Expand All @@ -14,18 +13,18 @@ class BlindsObject extends SmartDeviceStaticAbstract {
String? super.smartInstanceName,
super.onOffPinNumber,
onOffButtonPinNumber,
int? blindsUpPin,
int? upButtonPinNumber,
int? blindsDownPin,
int? downButtonPinNumber,
// int? blindsUpPin,
// int? upButtonPinNumber,
// int? blindsDownPin,
// int? downButtonPinNumber,
) : super(
onOffButtonPinNumber: onOffButtonPinNumber,
) {
buttonPinUp = DevicePinListManager().getGpioPin(upButtonPinNumber);
buttonPinDown = DevicePinListManager().getGpioPin(downButtonPinNumber);
// buttonPinUp = DevicePinListManager().getGpioPin(upButtonPinNumber);
// buttonPinDown = DevicePinListManager().getGpioPin(downButtonPinNumber);

this.blindsUpPin = DevicePinListManager().getGpioPin(blindsUpPin);
this.blindsDownPin = DevicePinListManager().getGpioPin(blindsDownPin);
// this.blindsUpPin = DevicePinListManager().getGpioPin(blindsUpPin);
// this.blindsDownPin = DevicePinListManager().getGpioPin(blindsDownPin);
listenToTwoButtonsPress();

deviceType = CbjDeviceTypes.blinds;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ class CbjSmartDeviceServerU extends CbjSmartDeviceConnectionsServiceBase {
}
}

Future<void> exitTheApp() async {
Future exitTheApp() async {
const int secondsToExistTheProgram = 15;
logger.i('$secondsToExistTheProgram seconds to exit the program');
await Future.delayed(const Duration(seconds: secondsToExistTheProgram));
Expand Down
4 changes: 2 additions & 2 deletions lib/application/usecases/wish_classes_u/blinds_wish_u.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class BlindsWishU {
blindsInformation.blindsDownPin,
);

await Future<void>.delayed(const Duration(seconds: 1));
await Future.delayed(const Duration(seconds: 1));

blindsInformation.blindsUpPin?.onDuration = -1;

Expand Down Expand Up @@ -54,7 +54,7 @@ class BlindsWishU {
blindsInformation.blindsUpPin,
);

await Future<void>.delayed(const Duration(seconds: 1));
await Future.delayed(const Duration(seconds: 1));

blindsInformation.blindsDownPin?.onDuration = -1;
status +=
Expand Down
11 changes: 7 additions & 4 deletions lib/domain/entities/core_e/enums_e.dart
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,16 @@ class EnumHelper {
case CbjDeviceTypes.light:
return LightObject(null, null, null);
case CbjDeviceTypes.blinds:
return BlindsObject(null, null, null, null, null, null, null, null);
return BlindsObject(null, null, null, null);
case CbjDeviceTypes.boiler:
return BoilerObject(null, null, null, null);
return BoilerObject(null, null);
case CbjDeviceTypes.button:
return ButtonObject(null, null, null);
return ButtonObject(null, null);
case CbjDeviceTypes.buttonWithLight:
return ButtonWithLightObject(null, null, null, null);
return ButtonWithLightObject(
null,
null,
);
default:
logger.i('Type $deviceType is not supported');
}
Expand Down
2 changes: 1 addition & 1 deletion lib/domain/entities/local_db_e/local_db_e.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class LocalDbE {
return firebaseAccountsInformationD;
}

Future<void> saveAllDevices(
Future saveAllDevices(
List<SmartDeviceBaseAbstract> smartDevicesList,
) async {
await _localDbR.saveAllDevices(smartDevicesList);
Expand Down
Loading

0 comments on commit 05198ba

Please sign in to comment.