2018-10-27 14:27:41 +03:00
|
|
|
part of '../main.dart';
|
|
|
|
|
|
|
|
class CoverEntity extends Entity {
|
|
|
|
|
|
|
|
static const SUPPORT_OPEN = 1;
|
|
|
|
static const SUPPORT_CLOSE = 2;
|
|
|
|
static const SUPPORT_SET_POSITION = 4;
|
|
|
|
static const SUPPORT_STOP = 8;
|
|
|
|
static const SUPPORT_OPEN_TILT = 16;
|
|
|
|
static const SUPPORT_CLOSE_TILT = 32;
|
|
|
|
static const SUPPORT_STOP_TILT = 64;
|
|
|
|
static const SUPPORT_SET_TILT_POSITION = 128;
|
|
|
|
|
2019-02-17 13:52:24 +02:00
|
|
|
bool get supportOpen => ((supportedFeatures &
|
2018-10-27 14:27:41 +03:00
|
|
|
CoverEntity.SUPPORT_OPEN) ==
|
|
|
|
CoverEntity.SUPPORT_OPEN);
|
2019-02-17 13:52:24 +02:00
|
|
|
bool get supportClose => ((supportedFeatures &
|
2018-10-27 14:27:41 +03:00
|
|
|
CoverEntity.SUPPORT_CLOSE) ==
|
|
|
|
CoverEntity.SUPPORT_CLOSE);
|
2019-02-17 13:52:24 +02:00
|
|
|
bool get supportSetPosition => ((supportedFeatures &
|
2018-10-27 14:27:41 +03:00
|
|
|
CoverEntity.SUPPORT_SET_POSITION) ==
|
|
|
|
CoverEntity.SUPPORT_SET_POSITION);
|
2019-02-17 13:52:24 +02:00
|
|
|
bool get supportStop => ((supportedFeatures &
|
2018-10-27 14:27:41 +03:00
|
|
|
CoverEntity.SUPPORT_STOP) ==
|
|
|
|
CoverEntity.SUPPORT_STOP);
|
|
|
|
|
2019-02-17 13:52:24 +02:00
|
|
|
bool get supportOpenTilt => ((supportedFeatures &
|
2018-10-27 14:27:41 +03:00
|
|
|
CoverEntity.SUPPORT_OPEN_TILT) ==
|
|
|
|
CoverEntity.SUPPORT_OPEN_TILT);
|
2019-02-17 13:52:24 +02:00
|
|
|
bool get supportCloseTilt => ((supportedFeatures &
|
2018-10-27 14:27:41 +03:00
|
|
|
CoverEntity.SUPPORT_CLOSE_TILT) ==
|
|
|
|
CoverEntity.SUPPORT_CLOSE_TILT);
|
2019-02-17 13:52:24 +02:00
|
|
|
bool get supportStopTilt => ((supportedFeatures &
|
2018-10-27 14:27:41 +03:00
|
|
|
CoverEntity.SUPPORT_STOP_TILT) ==
|
|
|
|
CoverEntity.SUPPORT_STOP_TILT);
|
2019-02-17 13:52:24 +02:00
|
|
|
bool get supportSetTiltPosition => ((supportedFeatures &
|
2018-10-27 14:27:41 +03:00
|
|
|
CoverEntity.SUPPORT_SET_TILT_POSITION) ==
|
|
|
|
CoverEntity.SUPPORT_SET_TILT_POSITION);
|
|
|
|
|
|
|
|
|
|
|
|
double get currentPosition => _getDoubleAttributeValue('current_position');
|
|
|
|
double get currentTiltPosition => _getDoubleAttributeValue('current_tilt_position');
|
2018-11-14 15:14:46 +02:00
|
|
|
bool get canBeOpened => ((state != EntityState.opening) && (state != EntityState.open)) || (state == EntityState.open && currentPosition != null && currentPosition > 0.0 && currentPosition < 100.0);
|
|
|
|
bool get canBeClosed => ((state != EntityState.closing) && (state != EntityState.closed));
|
2018-11-04 21:40:41 +02:00
|
|
|
bool get canTiltBeOpened => currentTiltPosition < 100;
|
|
|
|
bool get canTiltBeClosed => currentTiltPosition > 0;
|
2018-10-27 14:27:41 +03:00
|
|
|
|
|
|
|
CoverEntity(Map rawData) : super(rawData);
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget _buildStatePart(BuildContext context) {
|
|
|
|
return CoverStateWidget();
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget _buildAdditionalControlsForPage(BuildContext context) {
|
|
|
|
return CoverControlWidget();
|
|
|
|
}
|
|
|
|
|
2018-11-06 14:10:34 +02:00
|
|
|
}
|