Skip to content
This repository has been archived by the owner on Nov 24, 2023. It is now read-only.

[WIP] Dallas/nod 77 lda 602 attenuator nodes - nodes PR:316 #422

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@

[//]: # (Custom component imports)

import DocString from '@site/src/components/DocString';
import PythonCode from '@site/src/components/PythonCode';
import AppDisplay from '@site/src/components/AppDisplay';
import SectionBreak from '@site/src/components/SectionBreak';
import AppendixSection from '@site/src/components/AppendixSection';

[//]: # (Docstring)

import DocstringSource from '!!raw-loader!./a1-[autogen]/docstring.txt';
import PythonSource from '!!raw-loader!./a1-[autogen]/python_code.txt';

<DocString>{DocstringSource}</DocString>
<PythonCode GLink='IO/INSTRUMENTS/ATTENUATORS/LDA/LDA602/ATTENUATION_LDA602/ATTENUATION_LDA602.py'>{PythonSource}</PythonCode>

<SectionBreak />



[//]: # (Examples)

## Examples

import Example1 from './examples/EX1/example.md';
import App1 from '!!raw-loader!./examples/EX1/app.json';



<AppDisplay
nodeLabel='ATTENUATION_LDA602'
appImg={''}
outputImg={''}
>
{App1}
</AppDisplay>

<Example1 />

<SectionBreak />



[//]: # (Appendix)

import Notes from './appendix/notes.md';
import Hardware from './appendix/hardware.md';
import Media from './appendix/media.md';

## Appendix

<AppendixSection index={0} folderPath='nodes/IO/INSTRUMENTS/ATTENUATORS/LDA/LDA602/ATTENUATION_LDA602/appendix/'><Notes /></AppendixSection>
<AppendixSection index={1} folderPath='nodes/IO/INSTRUMENTS/ATTENUATORS/LDA/LDA602/ATTENUATION_LDA602/appendix/'><Hardware /></AppendixSection>
<AppendixSection index={2} folderPath='nodes/IO/INSTRUMENTS/ATTENUATORS/LDA/LDA602/ATTENUATION_LDA602/appendix/'><Media /></AppendixSection>


Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The ATTENUATION_LDA602 node sets or queries the attenuation for the LDA-602 Digital Attenuator.

When setting the attenuation, the attenuation is then queried to ensure
the attenuation was set correctly.
The attenuation is rounded to the nearest 0.5 dB.

This node should also work with compatible LDA attenuators (untested).

Parameters
----------
serial_number: str
The serial number (not model number) to connect to.
query_set: str
Query or set the attenuation?
attenuation: str
The attenuation to set the LDA to, in dB.

Returns
-------
DataContainer
TextBlob: The current attenuation value.
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
from flojoy import flojoy, DataContainer, TextBlob
from typing import Optional, Literal
from qcodes_contrib_drivers.drivers.Vaunix.LDA import Vaunix_LDA
import platform
from numpy import allclose
from os import path


@flojoy(deps={"qcodes-contrib-drivers": "0.18.0"})
def ATTENUATION_LDA602(
serial_number: int = 839,
query_set: Literal["query", "set"] = "query",
attenuation: float = 10.0,
default: Optional[DataContainer] = None,
) -> TextBlob:


assert (
platform.system() == "Windows" and platform.architecture()[0] == "64bit"
), "This node currently supports only 64bit Windows."

driver_path = path.dirname(__file__)

assert path.isfile(
path.join(driver_path, "VNX_atten64.dll")
), f"Ensure the dll file is placed here: {driver_path}"

if query_set == "set":
assert (
0.0 <= attenuation <= 63.0
), f"The attenuation must be between 0 and 63 (set point: {attenuation})."

attenuator = Vaunix_LDA("LDA", serial_number, dll_path=driver_path)

match query_set:
case "query":
result = round(attenuator.attenuation() * 5, 2)
s = f"Set to {round(attenuator.attenuation() * 5, 2)} dB"
case "set":
attenuator.attenuation(attenuation)
result = round(attenuator.attenuation() * 5, 2)

assert allclose(
result, attenuation, rtol=0.1
), f"Resulting attenuation {result} is far from the set point {attenuation}"

s = f"Set to {result} dB"

attenuator.close()

return TextBlob(text_blob=s)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This node does not require any peripheral hardware to operate. Please see INSTRUMENTS for nodes that interact with the physical world through connected hardware.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
No supporting screenshots, photos, or videos have been added to the media.md file for this node.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
No theory or technical notes have been contributed for this node yet.
Loading