main
Jan Beníček 2024-12-09 08:27:10 +01:00
parent 4dd870f755
commit c32640deab
7 changed files with 28 additions and 34 deletions

View File

@ -1 +0,0 @@
/home/jbenicek/Programovani/SequentMicrosystems_API/.venv/bin/python

View File

@ -4,11 +4,8 @@
[metadata]
groups = ["default"]
strategy = ["cross_platform", "inherit_metadata"]
lock_version = "4.5.0"
content_hash = "sha256:b833a7bb8997b54c2b61879638963fef2bf4d8265bc9f0cd0d381cb8af3dd6b1"
[[metadata.targets]]
requires_python = ">=3.12"
lock_version = "4.4.1"
content_hash = "sha256:3e08a1de12505708e4539230fe7dc372f7fe295cf966f3097b3e2a12fac77e49"
[[package]]
name = "annotated-types"
@ -16,9 +13,6 @@ version = "0.7.0"
requires_python = ">=3.8"
summary = "Reusable constraint types to use with typing.Annotated"
groups = ["default"]
dependencies = [
"typing-extensions>=4.0.0; python_version < \"3.9\"",
]
files = [
{file = "annotated_types-0.7.0-py3-none-any.whl", hash = "sha256:1f02e8b43a8fbbc3f3e0d4f0f4bfc8131bcb4eebe8849b8e5c773f3a1c582a53"},
{file = "annotated_types-0.7.0.tar.gz", hash = "sha256:aff07c09a53a08bc8cfccb9c85b05f1aa9a2a6f23728d790723543408344ce89"},
@ -31,10 +25,8 @@ requires_python = ">=3.9"
summary = "High level compatibility layer for multiple asynchronous event loop implementations"
groups = ["default"]
dependencies = [
"exceptiongroup>=1.0.2; python_version < \"3.11\"",
"idna>=2.8",
"sniffio>=1.1",
"typing-extensions>=4.1; python_version < \"3.11\"",
]
files = [
{file = "anyio-4.6.2.post1-py3-none-any.whl", hash = "sha256:6d170c36fba3bdd840c73d3868c1e777e33676a69c3a72cf0a0d5d6d8009b61d"},
@ -49,7 +41,6 @@ summary = "Composable command line interface toolkit"
groups = ["default"]
dependencies = [
"colorama; platform_system == \"Windows\"",
"importlib-metadata; python_version < \"3.8\"",
]
files = [
{file = "click-8.1.7-py3-none-any.whl", hash = "sha256:ae74fb96c20a0277a1d615f1e4d73c8414f5a98db8b799a7931d1582f3390c28"},
@ -90,9 +81,6 @@ version = "0.14.0"
requires_python = ">=3.7"
summary = "A pure-Python, bring-your-own-I/O implementation of HTTP/1.1"
groups = ["default"]
dependencies = [
"typing-extensions; python_version < \"3.8\"",
]
files = [
{file = "h11-0.14.0-py3-none-any.whl", hash = "sha256:e3fe4ac4b851c468cc8363d500db52c2ead036020723024a109d37346efaa761"},
{file = "h11-0.14.0.tar.gz", hash = "sha256:8f19fbbe99e72420ff35c00b27a34cb9937e902a8b810e2c88300c6f0a3b699d"},
@ -263,7 +251,6 @@ summary = "The little ASGI library that shines."
groups = ["default"]
dependencies = [
"anyio<5,>=3.4.0",
"typing-extensions>=3.10.0; python_version < \"3.10\"",
]
files = [
{file = "starlette-0.41.3-py3-none-any.whl", hash = "sha256:44cedb2b7c77a9de33a8b74b2b90e9f50d11fcf25d8270ea525ad71a25374ff7"},
@ -290,7 +277,6 @@ groups = ["default"]
dependencies = [
"click>=7.0",
"h11>=0.8",
"typing-extensions>=4.0; python_version < \"3.11\"",
]
files = [
{file = "uvicorn-0.32.1-py3-none-any.whl", hash = "sha256:82ad92fd58da0d12af7482ecdb5f2470a04c9c9a53ced65b9bbb4a205377602e"},

View File

@ -53,13 +53,15 @@ def set_0_10_out_stack(stack: int, value: float):
"""
Set output voltage of 0-10V output on specified card
"""
(set_0_10_out(stack=stack, channel=channel, value=value) for channel in range(1, 5))
for channel in range(1, 5):
set_0_10_out(stack=stack, channel=channel, value=value)
def set_0_10_out_all(value: float):
"""
Set output voltage of 0-10V output on all card
"""
(set_0_10_out_stack(stack=stack, value=value) for stack in stacks)
for stack in stacks:
set_0_10_out_stack(stack=stack, value=value)
@ -156,11 +158,13 @@ def set_4_20_out_stack(stack: int, value: float):
"""
Set output value to all 4-20mA on specified card
"""
(set_4_20_out(stack=stack, channel=channel, value=value) for channel in range(1, 5))
for channel in range(1, 5):
set_4_20_out(stack=stack, channel=channel, value=value)
def set_4_20_out_all(value: float):
"""
Set output value to all for 4-20mA outputs
"""
(set_4_20_out_stack(stack=stack, value=value) for stack in stacks)
for stack in stacks:
set_4_20_out_stack(stack=stack, value=value)

View File

@ -9,28 +9,28 @@ router = APIRouter(prefix="/RTD8", tags=["Modules --> RTD8 card"])
@router.get("/all", summary="Read all RTD8 cards values in Celsius", response_model=Dict[int, Dict[int, float]])
@router.get("/temp/all", summary="Read all RTD8 cards values in Celsius", response_model=Dict[int, Dict[int, float]])
def get_all_celsius():
return service.read_temp_all()
@router.get("/{stack}", summary="Read specified RTD8 card values in Celsius", response_model=Dict[int, float])
@router.get("/temp/{stack}", summary="Read specified RTD8 card values in Celsius", response_model=Dict[int, float])
def get_stack_celsius(stack: int):
return service.read_temp_stack(stack)
@router.get("/{stack}/{channel}", summary="Read specified RTD8 card value of specified channel in Celsius", response_model=float)
@router.get("/temp/{stack}/{channel}", summary="Read specified RTD8 card value of specified channel in Celsius", response_model=float)
def get_channel_celsius(stack: int, channel: int):
return FloatValueModel(service=service.read_temp(stack, channel))
@router.get("/all/resistance", summary="Read all RTD8 cards values in Ohm", response_model=Dict[int, Dict[int, float]])
@router.get("/res/all", summary="Read all RTD8 cards values in Ohm", response_model=Dict[int, Dict[int, float]])
def get_all_celsius():
return service.read_resistance_all()
@router.get("/{stack}/resistance", summary="Read specified RTD8 card values in Ohm", response_model=Dict[int, float])
@router.get("/res/{stack}", summary="Read specified RTD8 card values in Ohm", response_model=Dict[int, float])
def get_stack_celsius(stack: int):
return service.read_resistance_stack(stack)
@router.get("/{stack}/{channel}/resistance", summary="Read specified RTD8 card value of specified channel in Ohm", response_model=FloatValueModel)
@router.get("/res/{stack}/{channel}", summary="Read specified RTD8 card value of specified channel in Ohm", response_model=FloatValueModel)
def get_channel_celsius(stack: int, channel: int):
return FloatValueModel(value=service.read_resistance(stack, channel))

View File

@ -32,7 +32,7 @@ def read_temp_all() -> dict:
"""
Read all RTD8 cards inputs in Celsius
"""
return {stack: read_resistance_stack(stack=stack) for stack in stacks}
return {stack: read_temp_stack(stack=stack) for stack in stacks}

View File

@ -9,17 +9,20 @@ router = APIRouter(prefix="/rel4hvi4", tags=["Modules --> Rel4HVI4"])
@router.post("/relay/all", description="Set all relays to required state (1/0)")
@router.post("/relay/all", description="Set all relays to required state (1/0)", response_model=Dict[int, Dict[int, bool]])
def post_relay_all(state: BoolValueModel):
service.set_relay_all(value=state.value)
return service.read_relay_all()
@router.post("/relay/{stack}", description="Set all relays on specified card to required state (1/0)")
@router.post("/relay/{stack}", description="Set all relays on specified card to required state (1/0)", response_model=Dict[int, float])
def post_relay_stack(stack: int, state: BoolValueModel):
service.set_relay_stack(stack=stack, value=state.value)
return service.read_opto_stack(stack=stack)
@router.post("/relay/{stack}/{channel}", description="Set all relays on specified card to required state (1/0)")
def post_relay_stack(stack: int, channel, state: BoolValueModel):
@router.post("/relay/{stack}/{channel}", description="Set all relays on specified card to required state (1/0)", response_model=BoolValueModel)
def post_relay_stack(stack: int, channel: int, state: BoolValueModel):
service.set_relay(stack=stack, relay=channel, value=state.value)
return BoolValueModel(value=service.read_relay(stack=stack, relay=channel))
@router.get("/relay/all", description="Get state of all relays", response_model=Dict[int, Dict[int, bool]])

View File

@ -21,13 +21,15 @@ def set_relay_stack(stack: int, value: bool):
"""
Set all relays to requested state on specified stack/card
"""
(set_relay(stack=stack, relay=ch, value=value) for ch in range(1, 5))
for ch in range(1, 5):
set_relay(stack=stack, relay=ch, value=value)
def set_relay_all(value: bool):
"""
Set all relays to requested state
"""
(set_relay_stack(stack=stack, value=value) for stack in stacks)
for stack in stacks:
set_relay_stack(stack=stack, value=value)
def read_relay(stack: int, relay: int):