Skip to content
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ dist
pid
logs
.secop-ophyd

tests/testgen/*
_api
34 changes: 34 additions & 0 deletions cfg/ophyd_secop_test_cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import os
import sys

from frappy.core import EnumType

# Get project root from environment variable
project_root = os.environ.get("FRAPPY_PROJECT_ROOT")

Expand Down Expand Up @@ -102,3 +104,35 @@
# pollinterval = Param(export=False),
# value = Param(unit = 'K', test = 'customized value'),
)


class GasEnum(EnumType):
def __init__(self, gas_names):
gas_dict = {name: idx for idx, name in enumerate(gas_names)}
super().__init__(**gas_dict)


Mod(
"enum1",
"frappy_modules.ophyd_secop_test_modules.Test_Enum",
"test module for enum codegen testing",
group="test",
value=1,
gas_type=Param(
description="gaslist of MFC",
datatype=GasEnum(["AR", "N2", "H2"]),
),
)


Mod(
"enum2",
"frappy_modules.ophyd_secop_test_modules.Test_Enum",
"test module for enum codegen testing",
group="test",
value=1,
gas_type=Param(
description="gaslist of MFC",
datatype=GasEnum(["AR", "N2", "H2", "CO2"]),
),
)
16 changes: 16 additions & 0 deletions frappy_modules/ophyd_secop_test_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,22 @@ def read_status(self):
return self.status


class Test_Enum(Readable):
value = Parameter("dummy val", IntRange())

gas_type = Parameter("gas type", EnumType(ZERO=0, ONE=1, THREE=3), readonly=False)

def read_value(self):
return random.choice([1, 2, 3])

def read_gas_type(self):
return self.gas_type

def write_gas_type(self, val):
self.gas_type = val
return val


class Test_ND_arrays(Readable):
Status = Enum(Readable.Status)

Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ dev = [
'isort',
'pytest',
'black',
'jinja2',
'autoflake',
'pep8-naming',
'mypy',
'wheel',
Expand Down
22 changes: 7 additions & 15 deletions src/secop_ophyd/AsyncFrappyClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@


class AsyncFrappyClient:
def __init__(self, host: str, port: str, loop) -> None:
def __init__(self, host: str, port: str, log=Logger) -> None:
self.host: str = host
self.port: str = port

self.client: SecopClient = None

self.loop = loop
self.loop: asyncio.AbstractEventLoop

self.external: bool = False

self.conn_timestamp: float

self.log = None
self.client: SecopClient = SecopClient(uri=host + ":" + port, log=log)

self.log = self.client.log

@property
def state(self):
Expand All @@ -46,18 +46,10 @@ def uri(self):
def nodename(self):
return self.client.nodename

@classmethod
async def create(cls, host, port, loop, log=Logger):
self = AsyncFrappyClient(host=host, port=port, loop=loop)
self.client = SecopClient(uri=host + ":" + port, log=log)

self.log = self.client.log

await self.connect(3)
async def connect(self, try_period=0):

return self
self.loop = asyncio.get_running_loop()

async def connect(self, try_period=0):
await asyncio.to_thread(self.client.connect, try_period)
self.conn_timestamp = time.time()

Expand Down
Loading