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

Delete OreSatId, NodeId #43

Merged
merged 2 commits into from
Nov 9, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 3 additions & 6 deletions oresat_configs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,24 @@
from .base import FW_COMMON_CONFIG_PATH
from .beacon_config import BeaconConfig
from .card_info import Card, cards_from_csv
from .constants import Consts, NodeId, OreSatId, __version__
from .constants import Consts, __version__

__all__ = ["Card", "Consts", "NodeId", "OreSatId", "__version__"]
__all__ = ["Card", "Consts", "__version__"]


class OreSatConfig:
"""All the configs for an OreSat mission."""

def __init__(self, mission: Union[OreSatId, Consts, str]):
def __init__(self, mission: Union[Consts, str]):
"""The parameter mission may be:
- a string, either short or long mission name ('0', 'OreSat0.5', ...)
- an OreSatId (ORESAT0, ...)
- a Consts (ORESAT0, ...)

It will be used to derive the appropriate Consts, the collection of
constants associated with a specific oresat mission.
"""
if isinstance(mission, str):
mission = Consts.from_string(mission)
elif isinstance(mission, OreSatId):
mission = Consts.from_id(mission)
elif not isinstance(mission, Consts):
raise TypeError(f"Unsupported mission type: '{type(mission)}'")

Expand Down
52 changes: 7 additions & 45 deletions oresat_configs/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@
from __future__ import annotations

from dataclasses import dataclass
from enum import Enum, IntEnum, unique
from enum import Enum, unique

from . import oresat0, oresat0_5, oresat1
from .base import ConfigPaths

__all__ = [
"__version__",
"OreSatId",
"NodeId",
"Mission",
"Consts",
]
Expand Down Expand Up @@ -73,49 +71,13 @@ def from_string(cls, val: str) -> Consts:
raise ValueError(f"invalid oresat mission: {val}")

@classmethod
def from_id(cls, val: OreSatId | int) -> Consts:
"""Fetches the Mission associated with an integer ID"""
if isinstance(val, OreSatId):
val = val.value
elif not isinstance(val, int):
raise TypeError(f"Unsupported val type: '{type(val)}'")
def from_id(cls, val: int) -> Consts:
"""Fetches the Mission associated with an appropriate ID

Appropriate IDs are integers 1, 2, ... that corespond to the specific
mission. Note that these are not the number in the Satellite name.
"""
for m in cls:
if m.id == val:
return m
raise ValueError(f"invalid OreSatId: {val}")


@unique
class OreSatId(IntEnum):
"""Unique ID for each OreSat."""

ORESAT0 = 1
ORESAT0_5 = 2
ORESAT1 = 3


class NodeId(IntEnum):
"""All the CANopen Node ID for OreSat cards."""

C3 = 0x01
BATTERY_1 = 0x04
BATTERY_2 = 0x08
SOLAR_MODULE_1 = 0x0C
SOLAR_MODULE_2 = 0x10
SOLAR_MODULE_3 = 0x14
SOLAR_MODULE_4 = 0x18
SOLAR_MODULE_5 = 0x1C
SOLAR_MODULE_6 = 0x20
SOLAR_MODULE_7 = 0x24
SOLAR_MODULE_8 = 0x28
STAR_TRACKER_1 = 0x2C
STAR_TRACKER_2 = 0x30
GPS = 0x34
ADCS = 0x38
REACTION_WHEEL_1 = 0x3C
REACTION_WHEEL_2 = 0x40
REACTION_WHEEL_3 = 0x44
REACTION_WHEEL_4 = 0x48
DXWIFI = 0x4C
CFC = 0x50
raise ValueError(f"invalid oresat mission ID: {val}")