Skip to content

Commit fc9cf36

Browse files
rickwierengaclaude
andcommitted
Move Spark enums to dedicated enums.py module
Extracts SparkDevice, SparkEndpoint, and VENDOR_ID from spark_reader_async.py to a separate enums.py file for better organization. These are USB protocol constants, not control logic. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent b56ffdd commit fc9cf36

4 files changed

Lines changed: 28 additions & 24 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from enum import Enum
2+
3+
4+
# Tecan Spark USB Vendor ID
5+
VENDOR_ID = 0x0C47
6+
7+
8+
class SparkDevice(Enum):
9+
"""USB product IDs for Spark device modules."""
10+
11+
FLUORESCENCE = 0x8027
12+
ABSORPTION = 0x8026
13+
LUMINESCENCE = 0x8022
14+
PLATE_TRANSPORT = 0x8028
15+
16+
17+
class SparkEndpoint(Enum):
18+
"""USB endpoint addresses for Spark communication."""
19+
20+
BULK_IN = 0x82
21+
BULK_IN1 = 0x81
22+
BULK_OUT = 0x01
23+
INTERRUPT_IN = 0x83

pylabrobot/plate_reading/tecan/spark20m/spark_backend.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@
1414
from .controls.plate_transport_control import MovementSpeed, PlateControl, PlatePosition
1515
from .controls.sensor_control import InstrumentMessageType, SensorControl
1616
from .controls.system_control import SystemControl
17+
from .enums import SparkDevice, SparkEndpoint
1718
from .spark_processor import AbsorbanceProcessor, FluorescenceProcessor
18-
from .spark_reader_async import SparkDevice, SparkEndpoint, SparkReaderAsync
19+
from .spark_reader_async import SparkReaderAsync
1920

2021
logger = logging.getLogger(__name__)
2122

pylabrobot/plate_reading/tecan/spark20m/spark_reader_async.py

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,14 @@
11
import asyncio
22
import logging
3-
from enum import Enum
43
from typing import Optional
54

65
import usb.core
76

87
from pylabrobot.io.usb import USB
98

9+
from .enums import VENDOR_ID, SparkDevice, SparkEndpoint
1010
from .spark_packet_parser import parse_single_spark_packet
1111

12-
# Tecan Spark
13-
VENDOR_ID = 0x0C47
14-
15-
16-
class SparkDevice(Enum):
17-
FLUORESCENCE = 0x8027
18-
ABSORPTION = 0x8026
19-
LUMINESCENCE = 0x8022
20-
PLATE_TRANSPORT = 0x8028
21-
22-
23-
class SparkEndpoint(Enum):
24-
BULK_IN = 0x82
25-
BULK_IN1 = 0x81
26-
BULK_OUT = 0x01
27-
INTERRUPT_IN = 0x83
28-
2912

3013
class SparkReaderAsync:
3114
def __init__(self, vid=VENDOR_ID):

pylabrobot/plate_reading/tecan/spark20m/spark_reader_async_tests.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,8 @@
33
from unittest.mock import AsyncMock, patch
44

55
# Import the module under test
6-
from pylabrobot.plate_reading.tecan.spark20m.spark_reader_async import (
7-
SparkDevice,
8-
SparkEndpoint,
9-
SparkReaderAsync,
10-
)
6+
from pylabrobot.plate_reading.tecan.spark20m.enums import SparkDevice, SparkEndpoint
7+
from pylabrobot.plate_reading.tecan.spark20m.spark_reader_async import SparkReaderAsync
118

129

1310
class TestSparkReaderAsync(unittest.IsolatedAsyncioTestCase):

0 commit comments

Comments
 (0)