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

Refactor: Types/**/* -> Types.py #1045

Merged
merged 1 commit into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 0 additions & 1 deletion exporter/SynthesisFusionAddin/Synthesis.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

from .src.general_imports import APP_NAME, DESCRIPTION, INTERNAL_ID, gm
from .src.Logging import getLogger, logFailure, setupLogger
from .src.Types.OString import OString
from .src.UI import (
HUI,
Camera,
Expand Down
38 changes: 0 additions & 38 deletions exporter/SynthesisFusionAddin/src/FLAGS.py

This file was deleted.

79 changes: 12 additions & 67 deletions exporter/SynthesisFusionAddin/src/Parser/ExporterOptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,72 +15,17 @@

from ..Logging import logFailure, timed
from ..strings import INTERNAL_ID

# Not 100% sure what this is for - Brandon
JointParentType = Enum("JointParentType", ["ROOT", "END"])

WheelType = Enum("WheelType", ["STANDARD", "OMNI", "MECANUM"])
SignalType = Enum("SignalType", ["PWM", "CAN", "PASSIVE"])
ExportMode = Enum("ExportMode", ["ROBOT", "FIELD"]) # Dynamic / Static export
PreferredUnits = Enum("PreferredUnits", ["METRIC", "IMPERIAL"])
ExportLocation = Enum("ExportLocation", ["UPLOAD", "DOWNLOAD"])


@dataclass
class Wheel:
jointToken: str = field(default=None)
wheelType: WheelType = field(default=None)
signalType: SignalType = field(default=None)


@dataclass
class Joint:
jointToken: str = field(default=None)
parent: JointParentType = field(default=None)
signalType: SignalType = field(default=None)
speed: float = field(default=None)
force: float = field(default=None)

# Transition: AARD-1865
# Should consider changing how the parser handles wheels and joints as there is overlap between
# `Joint` and `Wheel` that should be avoided
# This overlap also presents itself in 'ConfigCommand.py' and 'JointConfigTab.py'
isWheel: bool = field(default=False)


@dataclass
class Gamepiece:
occurrenceToken: str = field(default=None)
weight: float = field(default=None)
friction: float = field(default=None)


class PhysicalDepth(Enum):
# No Physical Properties are generated
NoPhysical = 0

# Only Body Physical Objects are generated
Body = 1

# Only Occurrence that contain Bodies and Bodies have Physical Properties
SurfaceOccurrence = 2

# Every Single Occurrence has Physical Properties even if empty
AllOccurrence = 3


class ModelHierarchy(Enum):
# Model exactly as it is shown in Fusion in the model view tree
FusionAssembly = 0

# Flattened Assembly with all bodies as children of the root object
FlatAssembly = 1

# A Model represented with parented objects that are part of a jointed tree
PhysicalAssembly = 2

# Generates the root assembly as a single mesh and stores the associated data
SingleMesh = 3
from ..Types import (
KG,
ExportLocation,
ExportMode,
Gamepiece,
Joint,
ModelHierarchy,
PhysicalDepth,
PreferredUnits,
Wheel,
)


@dataclass
Expand All @@ -101,7 +46,7 @@ class ExporterOptions:
preferredUnits: PreferredUnits = field(default=PreferredUnits.IMPERIAL)

# Always stored in kg regardless of 'preferredUnits'
robotWeight: float = field(default=0.0)
robotWeight: KG = field(default=0.0)

compressOutput: bool = field(default=True)
exportAsPart: bool = field(default=False)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
from proto.proto_out import assembly_pb2, joint_pb2, material_pb2, types_pb2

from ...Logging import logFailure, timed
from ..ExporterOptions import ExporterOptions, ExportMode
from ...Types import ExportMode
from ..ExporterOptions import ExporterOptions
from . import PhysicalProperties
from .PDMessage import PDMessage
from .Utilities import *
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@

from ...general_imports import *
from ...Logging import getLogger
from ..ExporterOptions import ExporterOptions, JointParentType, SignalType
from ...Types import JointParentType, SignalType
from ..ExporterOptions import ExporterOptions
from .PDMessage import PDMessage
from .Utilities import construct_info, fill_info, guid_occurrence

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from ...general_imports import INTERNAL_ID
from ...Logging import logFailure, timed
from .. import ExporterOptions
from ..ExporterOptions import ExporterOptions
from .PDMessage import PDMessage
from .Utilities import *

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
from ...APS.APS import upload_mirabuf # This line causes everything to break
from ...general_imports import *
from ...Logging import getLogger, logFailure, timed
from ...Types import ExportLocation, ExportMode
from ...UI.Camera import captureThumbnail, clearIconCache
from ..ExporterOptions import ExporterOptions, ExportLocation, ExportMode
from ..ExporterOptions import ExporterOptions
from . import Components, JointHierarchy, Joints, Materials, PDMessage
from .Utilities import *

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,92 @@
import os
import pathlib
import platform
from dataclasses import dataclass, field
from enum import Enum
from typing import Union

# Not 100% sure what this is for - Brandon
JointParentType = Enum("JointParentType", ["ROOT", "END"])

WheelType = Enum("WheelType", ["STANDARD", "OMNI", "MECANUM"])
SignalType = Enum("SignalType", ["PWM", "CAN", "PASSIVE"])
ExportMode = Enum("ExportMode", ["ROBOT", "FIELD"]) # Dynamic / Static export
PreferredUnits = Enum("PreferredUnits", ["METRIC", "IMPERIAL"])
ExportLocation = Enum("ExportLocation", ["UPLOAD", "DOWNLOAD"])


@dataclass
class Wheel:
jointToken: str = field(default=None)
wheelType: WheelType = field(default=None)
signalType: SignalType = field(default=None)


@dataclass
class Joint:
jointToken: str = field(default=None)
parent: JointParentType = field(default=None)
signalType: SignalType = field(default=None)
speed: float = field(default=None)
force: float = field(default=None)

# Transition: AARD-1865
# Should consider changing how the parser handles wheels and joints as there is overlap between
# `Joint` and `Wheel` that should be avoided
# This overlap also presents itself in 'ConfigCommand.py' and 'JointConfigTab.py'
isWheel: bool = field(default=False)


@dataclass
class Gamepiece:
occurrenceToken: str = field(default=None)
weight: float = field(default=None)
friction: float = field(default=None)


class PhysicalDepth(Enum):
# No Physical Properties are generated
NoPhysical = 0

# Only Body Physical Objects are generated
Body = 1

# Only Occurrence that contain Bodies and Bodies have Physical Properties
SurfaceOccurrence = 2

# Every Single Occurrence has Physical Properties even if empty
AllOccurrence = 3


class ModelHierarchy(Enum):
# Model exactly as it is shown in Fusion in the model view tree
FusionAssembly = 0

# Flattened Assembly with all bodies as children of the root object
FlatAssembly = 1

# A Model represented with parented objects that are part of a jointed tree
PhysicalAssembly = 2

# Generates the root assembly as a single mesh and stores the associated data
SingleMesh = 3


class LBS(float):
"""Mass Unit in Pounds."""


class KG(float):
"""Mass Unit in Kilograms."""


def toLbs(kgs: float) -> LBS:
return LBS(round(kgs * 2.2062, 2))


def toKg(pounds: float) -> KG:
return KG(round(pounds / 2.2062, 2))


class OString:
def __init__(self, path: object, fileName: str):
Expand Down Expand Up @@ -62,7 +146,6 @@ def _os() -> str:
return "Linux"
else:
raise OSError(2, "No Operating System Recognized", f"{osName}")
return None

def AssertEquals(self, comparing: object):
"""Compares the two OString objects
Expand Down
2 changes: 1 addition & 1 deletion exporter/SynthesisFusionAddin/src/UI/Camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from ..general_imports import *
from ..Logging import logFailure, timed
from ..Types.OString import OString
from ..Types import OString
from . import Helper


Expand Down
9 changes: 2 additions & 7 deletions exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,10 @@
from ..APS.APS import getAuth, getUserInfo, refreshAuthToken
from ..general_imports import *
from ..Logging import getLogger, logFailure
from ..Parser.ExporterOptions import (
ExporterOptions,
ExportLocation,
ExportMode,
Gamepiece,
PreferredUnits,
)
from ..Parser.ExporterOptions import ExporterOptions
from ..Parser.SynthesisParser.Parser import Parser
from ..Parser.SynthesisParser.Utilities import guid_occurrence
from ..Types import ExportLocation, ExportMode, Gamepiece, PreferredUnits
from . import CustomGraphics, FileDialogConfig, Helper, IconPaths
from .Configuration.SerialCommand import SerialCommand

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import json

from ...Types.OString import OString
from ...Types import OString


def generateFilePath() -> str:
Expand Down
2 changes: 1 addition & 1 deletion exporter/SynthesisFusionAddin/src/UI/FileDialogConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from ..general_imports import *

# from ..proto_out import Configuration_pb2
from ..Types.OString import OString
from ..Types import OString


def saveFileDialog(defaultPath: str | None = None, defaultName: str | None = None) -> str | bool:
Expand Down
8 changes: 1 addition & 7 deletions exporter/SynthesisFusionAddin/src/UI/JointConfigTab.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,7 @@

from ..general_imports import INTERNAL_ID
from ..Logging import logFailure
from ..Parser.ExporterOptions import (
Joint,
JointParentType,
SignalType,
Wheel,
WheelType,
)
from ..Types import Joint, JointParentType, SignalType, Wheel, WheelType
from . import IconPaths
from .CreateCommandInputsHelper import (
createBooleanInput,
Expand Down
4 changes: 1 addition & 3 deletions exporter/SynthesisFusionAddin/src/configure.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
""" Stores data and fields from config.ini """

import logging.handlers
import traceback
import uuid
from configparser import ConfigParser

from .Logging import getLogger
from .strings import INTERNAL_ID
from .Types.OString import OString
from .Types import OString

logger = getLogger()

Expand Down
Loading