Skip to content

Commit

Permalink
Placeholder fixes to Skeleton Documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
TBThomas56 committed Sep 28, 2023
1 parent c314ad3 commit d06c0c1
Show file tree
Hide file tree
Showing 5 changed files with 155 additions and 22 deletions.
24 changes: 9 additions & 15 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ eiger-fastcs

|code_ci| |docs_ci| |coverage| |pypi_version| |license|

.. note::

This project contains template code only. For documentation on how to
adopt this skeleton project see
https://DiamondLightSource.github.io/python3-pip-skeleton-cli

This is where you should write a short paragraph that describes what your module does,
how it does it, and why people should use it.
The existing Odin EPICS integration and underlying code is clunky and difficult to maintain. Odin deployments are dynamic by design,
supporting multiple detectors and a scalable number of processes. EPICS database is static and inflexible. With pythonSoftIOC it is
possible to create records dynamically at runtime, so it is possible to use introspection to check what parameters it needs to create,
rather than defining them build time. FastCS will provide an abstraction layer to introspect hardware and other processes to create a
set of parameters that they expose. These parameters can then be used to implement coordination logic and serve PVs by loading a
generic EPICS backend into the application. [Placeholder].

============== ==============================================================
PyPI ``pip install eiger-fastcs``
Expand All @@ -19,18 +18,13 @@ Documentation https://DiamondLightSource.github.io/eiger-fastcs
Releases https://github.com/DiamondLightSource/eiger-fastcs/releases
============== ==============================================================

This is where you should put some images or code snippets that illustrate
some relevant examples. If it is a library then you might put some
introductory code here:
Explanation of how to run Eiger-fastcs works once project is complete

.. code-block:: python
from eiger_fastcs import __version__
print(f"Hello eiger_fastcs {__version__}")
Or if it is a commandline tool then you might put some example commands here::
print("Placeholder Print Code - To add functionality afterwards")
Command Line Placeholder
$ python -m eiger_fastcs --version

.. |code_ci| image:: https://github.com/DiamondLightSource/eiger-fastcs/actions/workflows/code.yml/badge.svg?branch=main
Expand Down
57 changes: 57 additions & 0 deletions output.bob
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<display version="2.0.0">
<name>Display</name>
<x>0</x>
<y>0</y>
<width>290</width>
<height>88</height>
<grid_step_x>4</grid_step_x>
<grid_step_y>4</grid_step_y>
<widget type="label" version="2.0.0">
<name>Title</name>
<class>TITLE</class>
<text>Simple Device - MY-DEVICE-PREFIX</text>
<x use_class="true">0</x>
<y use_class="true">0</y>
<width>290</width>
<height>26</height>
<font use_class="true">
<font name="Header 1" family="Liberation Sans" style="BOLD" size="22.0">
</font>
</font>
<foreground_color use_class="true">
<color name="Text" red="0" green="0" blue="0">
</color>
</foreground_color>
<transparent use_class="true">true</transparent>
<horizontal_alignment>1</horizontal_alignment>
</widget>
<widget type="group" version="2.0.0">
<name>Eiger Controller </name>
<x>4</x>
<y>30</y>
<width>282</width>
<height>54</height>
<transparent>true</transparent>
<widget type="label" version="2.0.0">
<name>Label</name>
<text>Temperature</text>
<x>0</x>
<y>0</y>
<width>120</width>
<height>20</height>
</widget>
<widget type="textupdate" version="2.0.0">
<name>TextUpdate</name>
<pv_name>MY-DEVICE-PREFIX:Temperature</pv_name>
<x>124</x>
<y>0</y>
<width>124</width>
<height>20</height>
<font>
<font name="Default Bold" family="Liberation Sans" style="BOLD" size="14.0">
</font>
</font>
<horizontal_alignment>1</horizontal_alignment>
</widget>
</widget>
</display>
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ classifiers = [
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
]
description = "One line description of your module"
description = "Develop a FastCS application to introspect an Eiger detector and odin-data processes to generate an EPICS IOC exposing parameters as PVs."
dependencies = [
"typing-extensions;python_version<'3.8'",
] # Add project dependencies here, e.g. ["click", "numpy"]
Expand Down
53 changes: 47 additions & 6 deletions src/eiger_fastcs/__main__.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,55 @@
from argparse import ArgumentParser
from fastcs.backends.asyncio_backend import AsyncioBackend
from fastcs.backends.epics.backend import EpicsBackend
from fastcs.connections import IPConnectionSettings
from fastcs.mapping import Mapping

from . import __version__
from eiger_fastcs.eiger_controller import EigerController

# from . import __version__

__all__ = ["main"]


def main(args=None):
parser = ArgumentParser()
parser.add_argument("-v", "--version", action="version", version=__version__)
args = parser.parse_args(args)
def get_controller() -> EigerController:
ip_settings = IPConnectionSettings("127.0.0.1", 8080)
tcont = EigerController(ip_settings)
return tcont


def create_gui() -> None:
tcont = get_controller()
m = Mapping(tcont)
backend = EpicsBackend(m)
backend.create_gui()


def test_ioc() -> None:
tcont = get_controller()
m = Mapping(tcont)
backend = EpicsBackend(m)
ioc = backend.get_ioc()

ioc.run()


def test_asyncio_backend() -> None:
tcont = get_controller()
m = Mapping(tcont)
backend = AsyncioBackend(m)
backend.run_interactive_session()


def main() -> None:
# asyncio.run(test_ip_conn())
# test_asyncio_backend()
create_gui()
test_ioc()


# def main(args=None):
# parser = ArgumentParser()
# parser.add_argument("-v", "--version", action="version", version=__version__)
# args = parser.parse_args(args)


# test with: python -m eiger_fastcs
Expand Down
41 changes: 41 additions & 0 deletions src/eiger_fastcs/eiger_controller.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
from dataclasses import dataclass
from typing import Any

from fastcs.attributes import AttrR, AttrRW, AttrW
from fastcs.connections import HTTPConnection, IPConnectionSettings
from fastcs.controller import Controller
from fastcs.datatypes import Bool, Float, Int


@dataclass
class EigerHandler:
name: str
update_period: float = 0.2

async def put(
self,
controller: "EigerController",
attr: AttrW,
value: Any,
) -> None:
await controller.connection.put(self.name, value)

async def update(
self,
controller: "EigerController",
attr: AttrR,
) -> None:
response = await controller.connection.get(self.name)
await attr.set(response)


class EigerController(Controller):
temperature = AttrR(
Float(), handler=EigerHandler("detector/api/1.8.0/status/temperature")
)

def __init__(self, settings: IPConnectionSettings) -> None:
super().__init__()
self.connection = HTTPConnection(
settings, headers={"Content-Type": "application/json"}
)

0 comments on commit d06c0c1

Please sign in to comment.