-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from davidraker/driver_service_work
Updates for modular RC.
- Loading branch information
Showing
9 changed files
with
441 additions
and
475 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,7 +32,7 @@ ignore_missing_imports = true | |
|
||
[tool.poetry] | ||
name = "volttron-lib-base-driver" | ||
version = "0.2.1rc0" | ||
version = "2.0.0rc0" | ||
description = "Volttron Driver libraries used to support development within the Volttron Driver Framework." | ||
authors = ["Mark Bonicillo <[email protected]>"] | ||
license = "Apache License 2.0" | ||
|
@@ -52,8 +52,7 @@ classifiers = [ | |
|
||
[tool.poetry.dependencies] | ||
python = ">=3.10,<4.0" | ||
volttron = ">=10.0.1a43,<11.0" | ||
|
||
volttron-core = ">=2.0.0rc0" | ||
|
||
[tool.poetry.group.dev.dependencies] | ||
pytest = "^6.2.5" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
from datetime import timedelta | ||
from enum import Enum | ||
from pydantic import BaseModel, computed_field, ConfigDict, Field, field_validator | ||
|
||
# TODO: Wire up the data_source field to poll scheduling (everything is currently short-poll because this isn't used). | ||
# TODO: Should NEVER actually be an option? Could it just be None? | ||
class DataSource(Enum): | ||
SHORT_POLL = "short_poll" | ||
LONG_POLL = "long_poll" | ||
NEVER = "never" | ||
POLL_ONCE = "poll_once" | ||
STATIC = "static" | ||
|
||
|
||
class EquipmentConfig(BaseModel): | ||
model_config = ConfigDict(validate_assignment=True, populate_by_name=True) | ||
active: bool | None = None | ||
group: str | None = None | ||
# TODO: If this needs to be an int, we may need to use milliseconds someplace. | ||
polling_interval: int | None = Field(default=None, alias='interval') | ||
publish_single_depth: bool | None = Field(default=None, alias='publish_depth_first_single') | ||
publish_single_breadth: bool | None = Field(default=None, alias='publish_breadth_first_single') | ||
publish_multi_depth: bool | None = Field(default=None, alias='publish_depth_first_multi') | ||
publish_multi_breadth: bool | None = Field(default=None, alias='publish_breadth_first_multi') | ||
publish_all_depth: bool | None = Field(default=None, alias='publish_depth_first_all') | ||
publish_all_breadth: bool | None = Field(default=None, alias='publish_breadth_first_all') | ||
reservation_required_for_write: bool = False | ||
|
||
@field_validator('polling_interval', mode='before') | ||
@classmethod | ||
def _normalize_polling_interval(cls, v): | ||
# TODO: This does not match int above, but we may need to convert to ms in calculations. | ||
return None if v == '' or v is None else float(v) | ||
|
||
class PointConfig(EquipmentConfig): | ||
data_source: DataSource = Field(default='short_poll', alias='Data Source') | ||
notes: str = Field(default='', alias='Notes') | ||
reference_point_name: str = Field(default='', alias='Reference Point Name') | ||
stale_timeout_configured: float | None = Field(default=None, alias='stale_timeout') | ||
stale_timeout_multiplier: float = Field(default=3) | ||
units: str = Field(default='', alias='Units') | ||
units_details: str = Field(default='', alias='Unit Details') | ||
volttron_point_name: str = Field(alias='Volttron Point Name') | ||
writable: bool = Field(default=False, alias='Writable') | ||
|
||
@field_validator('data_source', mode='before') | ||
@classmethod | ||
def _normalize_data_source(cls, v): | ||
# TODO: This never converts to DataSource. | ||
# TODO: Data Source enum needs something to tell Data Point how to serialize it, otherwise enable/disable will fail. | ||
return v.lower() | ||
|
||
@computed_field | ||
@property | ||
def stale_timeout(self) -> timedelta | None: | ||
if self.stale_timeout_configured is None and self.polling_interval is None: | ||
return None | ||
else: | ||
return timedelta(seconds=(self.stale_timeout_configured | ||
if self.stale_timeout_configured is not None | ||
else self.polling_interval * self.stale_timeout_multiplier)) | ||
|
||
@stale_timeout.setter | ||
def stale_timeout(self, value): | ||
self.stale_timeout_configured = value | ||
|
||
|
||
class DeviceConfig(EquipmentConfig): | ||
all_publish_interval: float = 0.0 | ||
allow_duplicate_remotes: bool = False | ||
equipment_specific_fields: dict = {} | ||
registry_config: list[PointConfig] = [] | ||
|
||
|
||
class RemoteConfig(BaseModel): | ||
model_config = ConfigDict(extra='allow', validate_assignment=True) | ||
debug: bool = False | ||
driver_type: str | ||
heart_beat_point: str | None = None | ||
module: str | None = None |
Oops, something went wrong.