🏷️ 电源的能力¶
tongsim.entity.ability.impl.powerable ¶
tongsim.entity.ability.impl.powerable
PowerableAbility ¶
Bases: Protocol
PowerableAbility 定义了具备通电状态管理的实体能力接口。
提供是否通电状态的查询与控制接口。
Source code in src\tongsim\entity\ability\impl\powerable.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
|
async_get_power_status
async
¶
async_get_power_status() -> bool
异步获取当前实体的通电状态。
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True 表示通电,False 表示断电。 |
Source code in src\tongsim\entity\ability\impl\powerable.py
23 24 25 26 27 28 29 |
|
get_power_status ¶
get_power_status() -> bool
同步获取当前实体的通电状态。
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True 表示通电,False 表示断电。 |
Source code in src\tongsim\entity\ability\impl\powerable.py
31 32 33 34 35 36 37 |
|
async_set_power_status
async
¶
async_set_power_status(is_on: bool) -> bool
异步设置当前实体的通电状态。注意当该接口设置后,无论物体是否接通电源,都会获得 通电/断电 的状态。
Parameters:
Name | Type | Description | Default |
---|---|---|---|
is_on
|
bool
|
True 表示通电,False 表示断电。 |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
是否设置成功。 |
Source code in src\tongsim\entity\ability\impl\powerable.py
39 40 41 42 43 44 45 46 47 48 |
|
set_power_status ¶
set_power_status(is_on: bool) -> bool
同步设置当前实体的通电状态。注意当该接口设置后,无论物体是否接通电源,都会获得 通电/断电 的状态。
Parameters:
Name | Type | Description | Default |
---|---|---|---|
is_on
|
bool
|
True 表示通电,False 表示断电。 |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
是否设置成功。 |
Source code in src\tongsim\entity\ability\impl\powerable.py
50 51 52 53 54 55 56 57 58 59 |
|