From a777f2a24e2ba3e16cb2c3c3d6b8f7f3071c9da7 Mon Sep 17 00:00:00 2001 From: dstrande Date: Thu, 28 Sep 2023 15:32:02 +0000 Subject: [PATCH 1/6] update: Add force scalar param to RAND --- .../AI_ML/LOAD_MODEL/ONNX_MODEL/ONNX_MODEL.md | 57 ++++ .../ONNX_MODEL/a1-[autogen]/docstring.txt | 41 +++ .../ONNX_MODEL/a1-[autogen]/python_code.txt | 62 ++++ .../ONNX_MODEL/appendix/hardware.md | 1 + .../LOAD_MODEL/ONNX_MODEL/appendix/media.md | 1 + .../LOAD_MODEL/ONNX_MODEL/appendix/notes.md | 1 + .../RAND/a1-[autogen]/docstring.txt | 55 +-- .../RAND/a1-[autogen]/python_code.txt | 17 +- .../a1-[autogen]/docstring.txt | 11 +- .../a1-[autogen]/python_code.txt | 37 +- .../BURST_MODE_33510B/examples/EX1/app.json | 213 +++++++----- .../a1-[autogen]/docstring.txt | 11 +- .../a1-[autogen]/python_code.txt | 39 +-- .../examples/EX1/app.json | 148 ++++---- .../CONNECTION_33510B/CONNECTION_33510B.md | 57 ++++ .../a1-[autogen]/docstring.txt | 16 + .../a1-[autogen]/python_code.txt | 29 ++ .../CONNECTION_33510B/appendix/hardware.md | 1 + .../BASIC/CONNECTION_33510B/appendix/media.md | 1 + .../BASIC/CONNECTION_33510B/appendix/notes.md | 1 + .../CONNECTION_33510B/examples/EX1/app.json | 322 ++++++++++++++++++ .../CONNECTION_33510B/examples/EX1/example.md | 0 .../ON_OFF_33510B/a1-[autogen]/docstring.txt | 11 +- .../a1-[autogen]/python_code.txt | 39 +-- .../BASIC/ON_OFF_33510B/examples/EX1/app.json | 250 ++++++-------- .../a1-[autogen]/docstring.txt | 13 +- .../a1-[autogen]/python_code.txt | 39 +-- .../OUTPUT_SYNC_33510B/examples/EX1/app.json | 161 ++++----- .../a1-[autogen]/docstring.txt | 13 +- .../a1-[autogen]/python_code.txt | 39 +-- .../SET_WAVEFORM_33510B/examples/EX1/app.json | 254 ++++++-------- nodeSidebar.json | 1 + 32 files changed, 1152 insertions(+), 789 deletions(-) create mode 100644 docs/nodes/AI_ML/LOAD_MODEL/ONNX_MODEL/ONNX_MODEL.md create mode 100644 docs/nodes/AI_ML/LOAD_MODEL/ONNX_MODEL/a1-[autogen]/docstring.txt create mode 100644 docs/nodes/AI_ML/LOAD_MODEL/ONNX_MODEL/a1-[autogen]/python_code.txt create mode 100644 docs/nodes/AI_ML/LOAD_MODEL/ONNX_MODEL/appendix/hardware.md create mode 100644 docs/nodes/AI_ML/LOAD_MODEL/ONNX_MODEL/appendix/media.md create mode 100644 docs/nodes/AI_ML/LOAD_MODEL/ONNX_MODEL/appendix/notes.md create mode 100644 docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/CONNECTION_33510B/CONNECTION_33510B.md create mode 100644 docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/CONNECTION_33510B/a1-[autogen]/docstring.txt create mode 100644 docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/CONNECTION_33510B/a1-[autogen]/python_code.txt create mode 100644 docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/CONNECTION_33510B/appendix/hardware.md create mode 100644 docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/CONNECTION_33510B/appendix/media.md create mode 100644 docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/CONNECTION_33510B/appendix/notes.md create mode 100644 docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/CONNECTION_33510B/examples/EX1/app.json create mode 100644 docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/CONNECTION_33510B/examples/EX1/example.md diff --git a/docs/nodes/AI_ML/LOAD_MODEL/ONNX_MODEL/ONNX_MODEL.md b/docs/nodes/AI_ML/LOAD_MODEL/ONNX_MODEL/ONNX_MODEL.md new file mode 100644 index 0000000000..4ded5d315d --- /dev/null +++ b/docs/nodes/AI_ML/LOAD_MODEL/ONNX_MODEL/ONNX_MODEL.md @@ -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'; + +{DocstringSource} +{PythonSource} + + + + + +[//]: # (Examples) + +## Examples + +import Example1 from './examples/EX1/example.md'; +import App1 from '!!raw-loader!./examples/EX1/app.json'; + + + + + {App1} + + + + + + + + +[//]: # (Appendix) + +import Notes from './appendix/notes.md'; +import Hardware from './appendix/hardware.md'; +import Media from './appendix/media.md'; + +## Appendix + + + + + + diff --git a/docs/nodes/AI_ML/LOAD_MODEL/ONNX_MODEL/a1-[autogen]/docstring.txt b/docs/nodes/AI_ML/LOAD_MODEL/ONNX_MODEL/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..902772f8a6 --- /dev/null +++ b/docs/nodes/AI_ML/LOAD_MODEL/ONNX_MODEL/a1-[autogen]/docstring.txt @@ -0,0 +1,41 @@ +ONNX_MODEL loads a serialized ONNX model and uses it to make predictions using ONNX Runtime. + + This allows supporting a wide range of deep learning frameworks and hardware platforms. + + Notes + ----- + + On the one hand, ONNX is an open format to represent deep learning models. + ONNX defines a common set of operators - the building blocks of machine learning + and deep learning models - and a common file format to enable AI developers + to use models with a variety of frameworks, tools, runtimes, and compilers. + + See: https://onnx.ai/ + + On the other hand, ONNX Runtime is a high-performance inference engine for machine + learning models in the ONNX format. ONNX Runtime has proved to considerably increase + performance in inferencing for a broad range of ML models and hardware platforms. + + See: https://onnxruntime.ai/docs/ + + Moreover, the ONNX Model Zoo is a collection of pre-trained models for common + machine learning tasks. The models are stored in ONNX format and are ready to use + in different inference scenarios. + + See: https://github.com/onnx/models + + Parameters + ---------- + file_path : str + Path to a ONNX model to load and use for prediction. + + default : Vector + The input tensor to use for prediction. + For now, only a single input tensor is supported. + Note that the input tensor shape is not checked against the model's input shape. + + Returns + ------- + Vector: + The predictions made by the ONNX model. + For now, only a single output tensor is supported. diff --git a/docs/nodes/AI_ML/LOAD_MODEL/ONNX_MODEL/a1-[autogen]/python_code.txt b/docs/nodes/AI_ML/LOAD_MODEL/ONNX_MODEL/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..012554b48f --- /dev/null +++ b/docs/nodes/AI_ML/LOAD_MODEL/ONNX_MODEL/a1-[autogen]/python_code.txt @@ -0,0 +1,62 @@ +from flojoy import flojoy, run_in_venv, Vector +from flojoy.utils import FLOJOY_CACHE_DIR + + +@flojoy +@run_in_venv( + pip_dependencies=[ + "onnxruntime", + "numpy", + "onnx", + ] +) +def ONNX_MODEL( + file_path: str, + default: Vector, +) -> Vector: + + + import os + import onnx + import urllib.request + import numpy as np + import onnxruntime as rt + + model_name = os.path.basename(file_path) + + if file_path.startswith("http://") or file_path.startswith("https://"): + # Downloading the ONNX model from a URL to FLOJOY_CACHE_DIR. + onnx_model_zoo_cache = os.path.join( + FLOJOY_CACHE_DIR, "cache", "onnx", "model_zoo" + ) + + os.makedirs(onnx_model_zoo_cache, exist_ok=True) + + filename = os.path.join(onnx_model_zoo_cache, model_name) + + urllib.request.urlretrieve( + url=file_path, + filename=filename, + ) + + # Using the downloaded file. + file_path = filename + + # Pre-loading the serialized model to validate whether is well-formed or not. + model = onnx.load(file_path) + onnx.checker.check_model(model) + + # Using ONNX runtime for the ONNX model to make predictions. + sess = rt.InferenceSession(file_path, providers=["CPUExecutionProvider"]) + + # TODO(jjerphan): Assuming a single input and a single output for now. + input_name = sess.get_inputs()[0].name + label_name = sess.get_outputs()[0].name + + # TODO(jjerphan): For now NumPy is assumed to be the main backend for Flojoy. + # We might adapt it in the future so that we can use other backends + # for tensor libraries for application using Deep Learning libraries. + input_tensor = np.asarray(default.v, dtype=np.float32) + predictions = sess.run([label_name], {input_name: input_tensor})[0] + + return Vector(v=predictions) diff --git a/docs/nodes/AI_ML/LOAD_MODEL/ONNX_MODEL/appendix/hardware.md b/docs/nodes/AI_ML/LOAD_MODEL/ONNX_MODEL/appendix/hardware.md new file mode 100644 index 0000000000..7f78a555c4 --- /dev/null +++ b/docs/nodes/AI_ML/LOAD_MODEL/ONNX_MODEL/appendix/hardware.md @@ -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. \ No newline at end of file diff --git a/docs/nodes/AI_ML/LOAD_MODEL/ONNX_MODEL/appendix/media.md b/docs/nodes/AI_ML/LOAD_MODEL/ONNX_MODEL/appendix/media.md new file mode 100644 index 0000000000..8bcee9be90 --- /dev/null +++ b/docs/nodes/AI_ML/LOAD_MODEL/ONNX_MODEL/appendix/media.md @@ -0,0 +1 @@ +No supporting screenshots, photos, or videos have been added to the media.md file for this node. \ No newline at end of file diff --git a/docs/nodes/AI_ML/LOAD_MODEL/ONNX_MODEL/appendix/notes.md b/docs/nodes/AI_ML/LOAD_MODEL/ONNX_MODEL/appendix/notes.md new file mode 100644 index 0000000000..04aded2ec9 --- /dev/null +++ b/docs/nodes/AI_ML/LOAD_MODEL/ONNX_MODEL/appendix/notes.md @@ -0,0 +1 @@ +No theory or technical notes have been contributed for this node yet. \ No newline at end of file diff --git a/docs/nodes/GENERATORS/SIMULATIONS/RAND/a1-[autogen]/docstring.txt b/docs/nodes/GENERATORS/SIMULATIONS/RAND/a1-[autogen]/docstring.txt index 77fa907315..33cdae59b8 100644 --- a/docs/nodes/GENERATORS/SIMULATIONS/RAND/a1-[autogen]/docstring.txt +++ b/docs/nodes/GENERATORS/SIMULATIONS/RAND/a1-[autogen]/docstring.txt @@ -1,32 +1,33 @@ - The RAND node generates a random number or a list of random numbers, depending on the distribution selected. -Inputs ------- -default : OrderedPair|Vector - Optional input to use as the x-axis for the random samples. + Inputs + ------ + default : OrderedPair|Vector + Optional input to use as the x-axis for the random samples. -Parameters ----------- -distribution : select - the distribution over the random samples -lower_bound : float - the lower bound of the output interval -upper_bound : float - the upper bound of the output interval -normal_mean : float - the mean or "center" of the normal distribution -normal_standard_deviation : float - the spread or "width" of the normal distribution -poisson_events : float - the expected number of events occurring in a fixed time-interval when distribution is poisson + Parameters + ---------- + distribution : select + the distribution over the random samples + force_scalar : select + whether to force the output to be a Scalar + lower_bound : float + the lower bound of the output interval + upper_bound : float + the upper bound of the output interval + normal_mean : float + the mean or "center" of the normal distribution + normal_standard_deviation : float + the spread or "width" of the normal distribution + poisson_events : float + the expected number of events occurring in a fixed time-interval when distribution is poisson -Returns -------- -OrderedPair|Scalar - OrderedPair if there is an input. - x: the x-axis of the input - y: the random samples + Returns + ------- + OrderedPair|Scalar + OrderedPair if there is an input. + x: the x-axis of the input + y: the random samples - Scalar if there is no input. - c: the random number + Scalar if there is no input. + c: the random number diff --git a/docs/nodes/GENERATORS/SIMULATIONS/RAND/a1-[autogen]/python_code.txt b/docs/nodes/GENERATORS/SIMULATIONS/RAND/a1-[autogen]/python_code.txt index 05c0109177..0d13749228 100644 --- a/docs/nodes/GENERATORS/SIMULATIONS/RAND/a1-[autogen]/python_code.txt +++ b/docs/nodes/GENERATORS/SIMULATIONS/RAND/a1-[autogen]/python_code.txt @@ -8,6 +8,7 @@ from typing import Literal, Optional def RAND( default: Optional[OrderedPair | Vector] = None, distribution: Literal["normal", "uniform", "poisson"] = "normal", + force_scalar: Literal["False", "True"] = "False", lower_bound: float = 0, upper_bound: float = 1, normal_mean: float = 0, @@ -32,6 +33,9 @@ def RAND( case _: size = 1 + if eval(force_scalar): + size = 1 + match distribution: case "uniform": y = my_generator.uniform(low=lower_bound, high=upper_bound, size=size) @@ -42,16 +46,23 @@ def RAND( case "poisson": y = my_generator.poisson(lam=poisson_events, size=size) - return OrderedPair(x=x, y=y) if default else Scalar(c=y) + if not eval(force_scalar): + return OrderedPair(x=x, y=y) if default else Scalar(c=float(y)) + elif eval(force_scalar): + return Scalar(c=float(y)) + else: + raise TypeError("True/False string evaluation error.") @display -def OVERLOAD(lower_bound, upper_bound, distribution="uniform") -> None: +def OVERLOAD(force_scalar, lower_bound, upper_bound, distribution="uniform") -> None: return None @display -def OVERLOAD(normal_mean, normal_standard_deviation, distribution="normal") -> None: +def OVERLOAD( + force_scalar, normal_mean, normal_standard_deviation, distribution="normal" +) -> None: return None diff --git a/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/ADVANCED/BURST_MODE_33510B/a1-[autogen]/docstring.txt b/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/ADVANCED/BURST_MODE_33510B/a1-[autogen]/docstring.txt index bd3d501756..3962de8b6f 100644 --- a/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/ADVANCED/BURST_MODE_33510B/a1-[autogen]/docstring.txt +++ b/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/ADVANCED/BURST_MODE_33510B/a1-[autogen]/docstring.txt @@ -4,19 +4,16 @@ The BURST_MODE_33510B node is used to turn the Burst mode on or off. The burst mode is way to have signals come in "bursts" that are triggered externally or with a timer for instance. - If the "VISA_address" parameter is not specified the VISA_index will be - used to find the address. The LIST_VISA node can be used to show the - indicies of all available VISA instruments. + Requires a CONNECTION_33510B node at the start of the app to connect with + the instrument. The VISA address will then be listed under 'connection'. This node should also work with compatible Keysight 33XXX wavefunction generators (although they are untested). Parameters ---------- - VISA_address: str - The VISA address to query. - VISA_index: int - The address will be found from LIST_VISA node list with this index. + connection: VisaConnection + The VISA address (requires the CONNECTION_MDO3XXX node). on_off: str Turn the burst mode on or off. channel: str diff --git a/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/ADVANCED/BURST_MODE_33510B/a1-[autogen]/python_code.txt b/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/ADVANCED/BURST_MODE_33510B/a1-[autogen]/python_code.txt index ef67d3cf6d..7b41f8dbb6 100644 --- a/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/ADVANCED/BURST_MODE_33510B/a1-[autogen]/python_code.txt +++ b/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/ADVANCED/BURST_MODE_33510B/a1-[autogen]/python_code.txt @@ -1,22 +1,10 @@ -from flojoy import flojoy, DataContainer, TextBlob -import pyvisa +from flojoy import flojoy, DataContainer, TextBlob, VisaConnection from typing import Optional, Literal -from qcodes.instrument_drivers.Keysight import Keysight33512B -from usb.core import USBError -@flojoy( - deps={ - "pyvisa": "1.13.0", - "pyusb": "1.2.1", - "zeroconf": "0.102.0", - "pyvisa_py": "0.7.0", - "qcodes": "0.39.1", - } -) +@flojoy(inject_connection=True) def BURST_MODE_33510B( - VISA_address: Optional[str], - VISA_index: Optional[int] = 0, + connection: VisaConnection, on_off: Literal["ON", "OFF"] = "OFF", channel: Literal["ch1", "ch2"] = "ch1", trigger_source: Literal["EXT", "IMM", "TIM"] = "TIM", @@ -28,25 +16,10 @@ def BURST_MODE_33510B( burst_phase: float = 0, burst_polarity: Literal["NORM", "INV"] = "NORM", default: Optional[DataContainer] = None, -) -> Optional[DataContainer]: +) -> TextBlob: - rm = pyvisa.ResourceManager("@py") - if VISA_address == "": - VISA_addresses = rm.list_resources() - VISA_address = VISA_addresses[int(VISA_index)] - - try: - ks = Keysight33512B( - "ks", - VISA_address, - visalib="@py", - device_clear=False, - ) - except USBError as err: - raise Exception( - "USB port error. Trying unplugging+replugging the port." - ) from err + ks = connection.get_handle() channel_str = channel channel = getattr(ks, channel) diff --git a/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/ADVANCED/BURST_MODE_33510B/examples/EX1/app.json b/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/ADVANCED/BURST_MODE_33510B/examples/EX1/app.json index 376e5d1db2..d312697942 100644 --- a/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/ADVANCED/BURST_MODE_33510B/examples/EX1/app.json +++ b/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/ADVANCED/BURST_MODE_33510B/examples/EX1/app.json @@ -4,32 +4,111 @@ { "width": 192, "height": 192, - "id": "BURST_MODE_33510B-7ddc91f3-e2fa-47c8-baa4-9483b0372146", + "id": "CONNECTION_33510B-4c8ca1dd-a8ee-4ba9-ae8b-886c80a0a027", "type": "IO", "data": { - "id": "BURST_MODE_33510B-7ddc91f3-e2fa-47c8-baa4-9483b0372146", + "id": "CONNECTION_33510B-4c8ca1dd-a8ee-4ba9-ae8b-886c80a0a027", + "label": "CONNECTION 33510B", + "func": "CONNECTION_33510B", + "type": "IO", + "ctrls": { + "device": { + "type": "VisaDevice", + "default": null, + "desc": "The VISA address to connect to.", + "overload": null, + "functionName": "CONNECTION_33510B", + "param": "device", + "value": "USB0::2391::9735::MY59003244::0::INSTR" + } + }, + "initCtrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "Any", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Any", + "desc": "Optional: None" + } + ], + "path": "IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/CONNECTION_33510B/CONNECTION_33510B.py", + "selected": false + }, + "position": { + "x": -527.3533818261817, + "y": -104.51110954945591 + }, + "selected": false, + "positionAbsolute": { + "x": -527.3533818261817, + "y": -104.51110954945591 + }, + "dragging": true + }, + { + "width": 384, + "height": 288, + "id": "TEXT_VIEW-1e087237-ee3a-4db7-963d-46fbdbd7b59b", + "type": "VISUALIZERS", + "data": { + "id": "TEXT_VIEW-1e087237-ee3a-4db7-963d-46fbdbd7b59b", + "label": "TEXT VIEW", + "func": "TEXT_VIEW", + "type": "VISUALIZERS", + "ctrls": {}, + "initCtrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "TextBlob", + "multiple": false, + "desc": "the DataContainer to be visualized in text format" + } + ], + "path": "VISUALIZERS/DATA_STRUCTURE/TEXT_VIEW/TEXT_VIEW.py", + "selected": false + }, + "position": { + "x": 233.00086174633415, + "y": -124.48626608153023 + }, + "selected": false, + "positionAbsolute": { + "x": 233.00086174633415, + "y": -124.48626608153023 + }, + "dragging": true + }, + { + "width": 192, + "height": 192, + "id": "BURST_MODE_33510B-f8a40cc2-e5ec-408c-922f-6f58a235a431", + "type": "IO", + "data": { + "id": "BURST_MODE_33510B-f8a40cc2-e5ec-408c-922f-6f58a235a431", "label": "BURST MODE 33510B", "func": "BURST_MODE_33510B", "type": "IO", "ctrls": { - "VISA_address": { - "type": "str", + "connection": { + "type": "VisaConnection", "default": null, - "desc": "The VISA address to query.", + "desc": "The VISA address (requires the CONNECTION_MDO3XXX node).", "overload": null, "functionName": "BURST_MODE_33510B", - "param": "VISA_address", + "param": "connection", "value": "USB0::2391::9735::MY59003244::0::INSTR" }, - "VISA_index": { - "type": "int", - "default": 0, - "desc": "The address will be found from LIST_VISA node list with this index.", - "overload": null, - "functionName": "BURST_MODE_33510B", - "param": "VISA_index", - "value": 0 - }, "on_off": { "type": "select", "options": [ @@ -37,7 +116,7 @@ "OFF" ], "default": "OFF", - "desc": null, + "desc": "Turn the burst mode on or off.", "overload": null, "functionName": "BURST_MODE_33510B", "param": "on_off", @@ -50,7 +129,7 @@ "ch2" ], "default": "ch1", - "desc": null, + "desc": "The channel to modify the burst mode for.", "overload": null, "functionName": "BURST_MODE_33510B", "param": "channel", @@ -64,7 +143,7 @@ "TIM" ], "default": "TIM", - "desc": null, + "desc": "Set the trigger_source (e.g. externally or timed).", "overload": null, "functionName": "BURST_MODE_33510B", "param": "trigger_source", @@ -73,7 +152,7 @@ "trigger_delay": { "type": "float", "default": 0, - "desc": null, + "desc": "Delay the burst by this number of seconds after a trigger.", "overload": null, "functionName": "BURST_MODE_33510B", "param": "trigger_delay", @@ -86,7 +165,7 @@ "NEG" ], "default": "POS", - "desc": null, + "desc": "If triggering is external, trigger on a positive or negative slope.", "overload": null, "functionName": "BURST_MODE_33510B", "param": "trigger_slope", @@ -99,7 +178,7 @@ "overload": null, "functionName": "BURST_MODE_33510B", "param": "trigger_timer", - "value": 0.000001 + "value": 0.001 }, "burst_mode": { "type": "select", @@ -108,7 +187,7 @@ "Gated" ], "default": "N Cycle", - "desc": null, + "desc": "Set the burst mode for the WFG.", "overload": null, "functionName": "BURST_MODE_33510B", "param": "burst_mode", @@ -117,16 +196,16 @@ "burst_ncycles": { "type": "int", "default": 1, - "desc": null, + "desc": "How many cycles to have in one burst.", "overload": null, "functionName": "BURST_MODE_33510B", "param": "burst_ncycles", - "value": 10 + "value": 1 }, "burst_phase": { "type": "float", "default": 0, - "desc": null, + "desc": "What phase to start the burst with, in degrees.", "overload": null, "functionName": "BURST_MODE_33510B", "param": "burst_phase", @@ -139,7 +218,7 @@ "INV" ], "default": "NORM", - "desc": null, + "desc": "The polarity of the burst in Gated mode, normal or inverted.", "overload": null, "functionName": "BURST_MODE_33510B", "param": "burst_polarity", @@ -157,92 +236,42 @@ } ], "outputs": [ - { - "name": "default", - "id": "default", - "type": "Any", - "desc": "TextBlob: ON or OFF depending on on_off value." - } - ], - "pip_dependencies": [ - { - "name": "pyvisa", - "v": "1.13.0" - }, - { - "name": "pyusb", - "v": "1.2.1" - }, - { - "name": "zeroconf", - "v": "0.102.0" - }, - { - "name": "pyvisa_py", - "v": "0.7.0" - }, - { - "name": "qcodes", - "v": "0.39.1" - } - ], - "path": "IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/ADVANCED/BURST_MODE_33510B/BURST_MODE_33510B.py", - "selected": false - }, - "position": { - "x": -240.28567405069748, - "y": -107.39744698085521 - }, - "selected": false, - "positionAbsolute": { - "x": -240.28567405069748, - "y": -107.39744698085521 - }, - "dragging": true - }, - { - "width": 384, - "height": 288, - "id": "TEXT_VIEW-819c7e1c-0ff5-4c09-8a13-b65b1e1bab0e", - "type": "VISUALIZERS", - "data": { - "id": "TEXT_VIEW-819c7e1c-0ff5-4c09-8a13-b65b1e1bab0e", - "label": "TEXT VIEW", - "func": "TEXT_VIEW", - "type": "VISUALIZERS", - "ctrls": {}, - "initCtrls": {}, - "inputs": [ { "name": "default", "id": "default", "type": "TextBlob", - "multiple": false, - "desc": "the DataContainer to be visualized in text format" + "desc": "TextBlob: summary of burst mode settings." } ], - "path": "VISUALIZERS/DATA_STRUCTURE/TEXT_VIEW/TEXT_VIEW.py", + "path": "IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/ADVANCED/BURST_MODE_33510B/BURST_MODE_33510B.py", "selected": false }, "position": { - "x": 126.63251436934425, - "y": -126.35743104815421 + "x": -149.8564984407858, + "y": -110.30884513863724 }, "selected": false, "positionAbsolute": { - "x": 126.63251436934425, - "y": -126.35743104815421 + "x": -149.8564984407858, + "y": -110.30884513863724 }, "dragging": true } ], "edges": [ { - "source": "BURST_MODE_33510B-7ddc91f3-e2fa-47c8-baa4-9483b0372146", + "source": "CONNECTION_33510B-4c8ca1dd-a8ee-4ba9-ae8b-886c80a0a027", + "sourceHandle": "default", + "target": "BURST_MODE_33510B-f8a40cc2-e5ec-408c-922f-6f58a235a431", + "targetHandle": "default", + "id": "reactflow__edge-CONNECTION_33510B-4c8ca1dd-a8ee-4ba9-ae8b-886c80a0a027default-BURST_MODE_33510B-f8a40cc2-e5ec-408c-922f-6f58a235a431default" + }, + { + "source": "BURST_MODE_33510B-f8a40cc2-e5ec-408c-922f-6f58a235a431", "sourceHandle": "default", - "target": "TEXT_VIEW-819c7e1c-0ff5-4c09-8a13-b65b1e1bab0e", + "target": "TEXT_VIEW-1e087237-ee3a-4db7-963d-46fbdbd7b59b", "targetHandle": "default", - "id": "reactflow__edge-BURST_MODE_33510B-7ddc91f3-e2fa-47c8-baa4-9483b0372146default-TEXT_VIEW-819c7e1c-0ff5-4c09-8a13-b65b1e1bab0edefault" + "id": "reactflow__edge-BURST_MODE_33510B-f8a40cc2-e5ec-408c-922f-6f58a235a431default-TEXT_VIEW-1e087237-ee3a-4db7-963d-46fbdbd7b59bdefault" } ], "viewport": { diff --git a/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/ADVANCED/RETURN_ERRORS_33510B/a1-[autogen]/docstring.txt b/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/ADVANCED/RETURN_ERRORS_33510B/a1-[autogen]/docstring.txt index 28b08580c6..6335dde3e4 100644 --- a/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/ADVANCED/RETURN_ERRORS_33510B/a1-[autogen]/docstring.txt +++ b/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/ADVANCED/RETURN_ERRORS_33510B/a1-[autogen]/docstring.txt @@ -3,19 +3,16 @@ The RETURN_ERRORS_33510B node returns error messages from the WFG. Error retrival is first-in-first-out (FIFO). Returning errors clears them from the instruments queue. - If the "VISA_address" parameter is not specified the VISA_index will be - used to find the address. The LIST_VISA node can be used to show the - indicies of all available VISA instruments. + Requires a CONNECTION_33510B node at the start of the app to connect with + the instrument. The VISA address will then be listed under 'connection'. This node should also work with compatible Keysight 33XXX wavefunction generators (although they are untested). Parameters ---------- - VISA_address: str - The VISA address to query. - VISA_index: int - The address will be found from LIST_VISA node list with this index. + connection: VisaConnection + The VISA address (requires the CONNECTION_MDO3XXX node). Returns ------- diff --git a/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/ADVANCED/RETURN_ERRORS_33510B/a1-[autogen]/python_code.txt b/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/ADVANCED/RETURN_ERRORS_33510B/a1-[autogen]/python_code.txt index c1e5eb67fb..e5090be60d 100644 --- a/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/ADVANCED/RETURN_ERRORS_33510B/a1-[autogen]/python_code.txt +++ b/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/ADVANCED/RETURN_ERRORS_33510B/a1-[autogen]/python_code.txt @@ -1,42 +1,15 @@ -from flojoy import flojoy, DataContainer, TextBlob -import pyvisa -from typing import Optional, Literal -from qcodes.instrument_drivers.Keysight import Keysight33512B -from usb.core import USBError +from flojoy import flojoy, DataContainer, TextBlob, VisaConnection +from typing import Optional -@flojoy( - deps={ - "pyvisa": "1.13.0", - "pyusb": "1.2.1", - "zeroconf": "0.102.0", - "pyvisa_py": "0.7.0", - "qcodes": "0.39.1", - } -) +@flojoy(inject_connection=True) def RETURN_ERRORS_33510B( - VISA_address: Optional[str], - VISA_index: Optional[int] = 0, + connection: VisaConnection, default: Optional[DataContainer] = None, -) -> Optional[DataContainer]: +) -> TextBlob: - rm = pyvisa.ResourceManager("@py") - if VISA_address == "": - VISA_addresses = rm.list_resources() - VISA_address = VISA_addresses[int(VISA_index)] - - try: - ks = Keysight33512B( - "ks", - VISA_address, - visalib="@py", - device_clear=False, - ) - except USBError as err: - raise Exception( - "USB port error. Trying unplugging+replugging the port." - ) from err + ks = connection.get_handle() err_code, err_message = ks.error() errors = f"{err_code} {err_message}" diff --git a/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/ADVANCED/RETURN_ERRORS_33510B/examples/EX1/app.json b/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/ADVANCED/RETURN_ERRORS_33510B/examples/EX1/app.json index 3006d1ec91..5263851b66 100644 --- a/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/ADVANCED/RETURN_ERRORS_33510B/examples/EX1/app.json +++ b/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/ADVANCED/RETURN_ERRORS_33510B/examples/EX1/app.json @@ -4,31 +4,22 @@ { "width": 192, "height": 192, - "id": "RETURN_ERRORS_33510B-3a066f98-2226-43cf-b6db-c231fd651f55", + "id": "CONNECTION_33510B-4c8ca1dd-a8ee-4ba9-ae8b-886c80a0a027", "type": "IO", "data": { - "id": "RETURN_ERRORS_33510B-3a066f98-2226-43cf-b6db-c231fd651f55", - "label": "RETURN ERRORS 33510B", - "func": "RETURN_ERRORS_33510B", + "id": "CONNECTION_33510B-4c8ca1dd-a8ee-4ba9-ae8b-886c80a0a027", + "label": "CONNECTION 33510B", + "func": "CONNECTION_33510B", "type": "IO", "ctrls": { - "VISA_address": { - "type": "str", + "device": { + "type": "VisaDevice", "default": null, - "desc": "The VISA address to query.", - "overload": null, - "functionName": "RETURN_ERRORS_33510B", - "param": "VISA_address", - "value": "" - }, - "VISA_index": { - "type": "int", - "default": 0, - "desc": "The address will be found from LIST_VISA node list with this index.", + "desc": "The VISA address to connect to.", "overload": null, - "functionName": "RETURN_ERRORS_33510B", - "param": "VISA_index", - "value": 2 + "functionName": "CONNECTION_33510B", + "param": "device", + "value": "USB0::2391::9735::MY59003244::0::INSTR" } }, "initCtrls": {}, @@ -46,51 +37,30 @@ "name": "default", "id": "default", "type": "Any", - "desc": "TextBlob: Returns all errors in the WFG memory." - } - ], - "pip_dependencies": [ - { - "name": "pyvisa", - "v": "1.13.0" - }, - { - "name": "pyusb", - "v": "1.2.1" - }, - { - "name": "zeroconf", - "v": "0.102.0" - }, - { - "name": "pyvisa_py", - "v": "0.7.0" - }, - { - "name": "qcodes", - "v": "0.39.1" + "desc": "Optional: None" } ], - "path": "IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/ADVANCED/RETURN_ERRORS_33510B/RETURN_ERRORS_33510B.py", - "selected": false + "path": "IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/CONNECTION_33510B/CONNECTION_33510B.py", + "selected": true }, "position": { - "x": 193.2467834815114, - "y": 112.8639037908917 + "x": -527.3533818261817, + "y": -104.51110954945591 }, - "selected": false, + "selected": true, "positionAbsolute": { - "x": 193.2467834815114, - "y": 112.8639037908917 - } + "x": -527.3533818261817, + "y": -104.51110954945591 + }, + "dragging": true }, { "width": 384, "height": 288, - "id": "TEXT_VIEW-9ef30eb9-6f9c-4b38-bdcf-a4093e1ec2a0", + "id": "TEXT_VIEW-1e087237-ee3a-4db7-963d-46fbdbd7b59b", "type": "VISUALIZERS", "data": { - "id": "TEXT_VIEW-9ef30eb9-6f9c-4b38-bdcf-a4093e1ec2a0", + "id": "TEXT_VIEW-1e087237-ee3a-4db7-963d-46fbdbd7b59b", "label": "TEXT VIEW", "func": "TEXT_VIEW", "type": "VISUALIZERS", @@ -109,24 +79,84 @@ "selected": false }, "position": { - "x": 591.3285686884251, - "y": 101.4852722421046 + "x": 233.00086174633415, + "y": -124.48626608153023 + }, + "selected": false, + "positionAbsolute": { + "x": 233.00086174633415, + "y": -124.48626608153023 + }, + "dragging": true + }, + { + "width": 192, + "height": 192, + "id": "RETURN_ERRORS_33510B-399b56cc-0062-49f0-933c-ab01e39b6788", + "type": "IO", + "data": { + "id": "RETURN_ERRORS_33510B-399b56cc-0062-49f0-933c-ab01e39b6788", + "label": "RETURN ERRORS 33510B", + "func": "RETURN_ERRORS_33510B", + "type": "IO", + "ctrls": { + "connection": { + "type": "VisaConnection", + "default": null, + "desc": "The VISA address (requires the CONNECTION_MDO3XXX node).", + "overload": null, + "functionName": "RETURN_ERRORS_33510B", + "param": "connection", + "value": "USB0::2391::9735::MY59003244::0::INSTR" + } + }, + "initCtrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "Any", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "TextBlob", + "desc": "TextBlob: Returns all errors in the WFG memory." + } + ], + "path": "IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/ADVANCED/RETURN_ERRORS_33510B/RETURN_ERRORS_33510B.py", + "selected": false + }, + "position": { + "x": -147.83112432013039, + "y": -101.03938942263295 }, "selected": false, "positionAbsolute": { - "x": 591.3285686884251, - "y": 101.4852722421046 + "x": -147.83112432013039, + "y": -101.03938942263295 }, "dragging": true } ], "edges": [ { - "source": "RETURN_ERRORS_33510B-3a066f98-2226-43cf-b6db-c231fd651f55", + "source": "RETURN_ERRORS_33510B-399b56cc-0062-49f0-933c-ab01e39b6788", + "sourceHandle": "default", + "target": "TEXT_VIEW-1e087237-ee3a-4db7-963d-46fbdbd7b59b", + "targetHandle": "default", + "id": "reactflow__edge-RETURN_ERRORS_33510B-399b56cc-0062-49f0-933c-ab01e39b6788default-TEXT_VIEW-1e087237-ee3a-4db7-963d-46fbdbd7b59bdefault" + }, + { + "source": "CONNECTION_33510B-4c8ca1dd-a8ee-4ba9-ae8b-886c80a0a027", "sourceHandle": "default", - "target": "TEXT_VIEW-9ef30eb9-6f9c-4b38-bdcf-a4093e1ec2a0", + "target": "RETURN_ERRORS_33510B-399b56cc-0062-49f0-933c-ab01e39b6788", "targetHandle": "default", - "id": "reactflow__edge-RETURN_ERRORS_33510B-3a066f98-2226-43cf-b6db-c231fd651f55default-TEXT_VIEW-9ef30eb9-6f9c-4b38-bdcf-a4093e1ec2a0default" + "id": "reactflow__edge-CONNECTION_33510B-4c8ca1dd-a8ee-4ba9-ae8b-886c80a0a027default-RETURN_ERRORS_33510B-399b56cc-0062-49f0-933c-ab01e39b6788default" } ], "viewport": { diff --git a/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/CONNECTION_33510B/CONNECTION_33510B.md b/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/CONNECTION_33510B/CONNECTION_33510B.md new file mode 100644 index 0000000000..f1175d59f6 --- /dev/null +++ b/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/CONNECTION_33510B/CONNECTION_33510B.md @@ -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'; + +{DocstringSource} +{PythonSource} + + + + + +[//]: # (Examples) + +## Examples + +import Example1 from './examples/EX1/example.md'; +import App1 from '!!raw-loader!./examples/EX1/app.json'; + + + + + {App1} + + + + + + + + +[//]: # (Appendix) + +import Notes from './appendix/notes.md'; +import Hardware from './appendix/hardware.md'; +import Media from './appendix/media.md'; + +## Appendix + + + + + + diff --git a/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/CONNECTION_33510B/a1-[autogen]/docstring.txt b/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/CONNECTION_33510B/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..be68a2a083 --- /dev/null +++ b/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/CONNECTION_33510B/a1-[autogen]/docstring.txt @@ -0,0 +1,16 @@ +The CONNECTION_33510B node connects Flojoy to a 33510B function generator. + + The connection is made with the VISA address in the Flojoy UI. + + This node should also work with compatible Keysight 33XXX wavefunction + generators (although they are untested). + + Parameters + ---------- + device: VisaDevice + The VISA address to connect to. + + Returns + ------- + DataContainer + Optional: None diff --git a/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/CONNECTION_33510B/a1-[autogen]/python_code.txt b/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/CONNECTION_33510B/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..07f74a65cc --- /dev/null +++ b/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/CONNECTION_33510B/a1-[autogen]/python_code.txt @@ -0,0 +1,29 @@ +from flojoy import VisaDevice, flojoy, DataContainer +from flojoy.connection_manager import DeviceConnectionManager +from typing import Optional +from qcodes.instrument_drivers.Keysight import Keysight33512B +from usb.core import USBError + + +@flojoy() +def CONNECTION_33510B( + device: VisaDevice, + default: Optional[DataContainer] = None, +) -> Optional[DataContainer]: + + + try: + ks = Keysight33512B( + "ks", + device.get_id(), + visalib="@py", + device_clear=False, + ) + except USBError as err: + raise Exception( + "USB port error. Trying unplugging+replugging the port." + ) from err + + DeviceConnectionManager.register_connection(device, ks) + + return None diff --git a/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/CONNECTION_33510B/appendix/hardware.md b/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/CONNECTION_33510B/appendix/hardware.md new file mode 100644 index 0000000000..7f78a555c4 --- /dev/null +++ b/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/CONNECTION_33510B/appendix/hardware.md @@ -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. \ No newline at end of file diff --git a/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/CONNECTION_33510B/appendix/media.md b/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/CONNECTION_33510B/appendix/media.md new file mode 100644 index 0000000000..8bcee9be90 --- /dev/null +++ b/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/CONNECTION_33510B/appendix/media.md @@ -0,0 +1 @@ +No supporting screenshots, photos, or videos have been added to the media.md file for this node. \ No newline at end of file diff --git a/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/CONNECTION_33510B/appendix/notes.md b/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/CONNECTION_33510B/appendix/notes.md new file mode 100644 index 0000000000..04aded2ec9 --- /dev/null +++ b/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/CONNECTION_33510B/appendix/notes.md @@ -0,0 +1 @@ +No theory or technical notes have been contributed for this node yet. \ No newline at end of file diff --git a/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/CONNECTION_33510B/examples/EX1/app.json b/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/CONNECTION_33510B/examples/EX1/app.json new file mode 100644 index 0000000000..4f64505735 --- /dev/null +++ b/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/CONNECTION_33510B/examples/EX1/app.json @@ -0,0 +1,322 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 384, + "height": 288, + "id": "TEXT_VIEW-819c7e1c-0ff5-4c09-8a13-b65b1e1bab0e", + "type": "VISUALIZERS", + "data": { + "id": "TEXT_VIEW-819c7e1c-0ff5-4c09-8a13-b65b1e1bab0e", + "label": "TEXT VIEW", + "func": "TEXT_VIEW", + "type": "VISUALIZERS", + "ctrls": {}, + "initCtrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "TextBlob", + "multiple": false, + "desc": "the DataContainer to be visualized in text format" + } + ], + "path": "VISUALIZERS/DATA_STRUCTURE/TEXT_VIEW/TEXT_VIEW.py", + "selected": false + }, + "position": { + "x": -97.20356336156576, + "y": -314.9312497214042 + }, + "selected": false, + "positionAbsolute": { + "x": -97.20356336156576, + "y": -314.9312497214042 + }, + "dragging": true + }, + { + "width": 384, + "height": 288, + "id": "TEXT_VIEW-9b57ca0b-54cb-46c2-a71a-69bdc48fa993", + "type": "VISUALIZERS", + "data": { + "id": "TEXT_VIEW-9b57ca0b-54cb-46c2-a71a-69bdc48fa993", + "label": "TEXT VIEW 1", + "func": "TEXT_VIEW", + "type": "VISUALIZERS", + "ctrls": {}, + "initCtrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "TextBlob", + "multiple": false, + "desc": "the DataContainer to be visualized in text format" + } + ], + "path": "VISUALIZERS/DATA_STRUCTURE/TEXT_VIEW/TEXT_VIEW.py", + "selected": false + }, + "position": { + "x": -81.05571289888496, + "y": 57.102935591729135 + }, + "selected": false, + "positionAbsolute": { + "x": -81.05571289888496, + "y": 57.102935591729135 + }, + "dragging": true + }, + { + "width": 192, + "height": 192, + "id": "CONNECTION_33510B-d0efefd1-f09c-4f2c-b5d8-ca8fb95155da", + "type": "IO", + "data": { + "id": "CONNECTION_33510B-d0efefd1-f09c-4f2c-b5d8-ca8fb95155da", + "label": "CONNECTION 33510B", + "func": "CONNECTION_33510B", + "type": "IO", + "ctrls": { + "device": { + "type": "VisaDevice", + "default": null, + "desc": "The VISA address to connect to.", + "overload": null, + "functionName": "CONNECTION_33510B", + "param": "device", + "value": "USB0::2391::9735::MY59003244::0::INSTR" + } + }, + "initCtrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "Any", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Any", + "desc": "Optional: None" + } + ], + "path": "IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/CONNECTION_33510B/CONNECTION_33510B.py", + "selected": false + }, + "position": { + "x": -887.4349451815563, + "y": -64.27026427943238 + }, + "selected": false, + "positionAbsolute": { + "x": -887.4349451815563, + "y": -64.27026427943238 + }, + "dragging": true + }, + { + "width": 192, + "height": 192, + "id": "ON_OFF_33510B-b7a6b301-b085-4365-9ae4-d83fb88dfd08", + "type": "IO", + "data": { + "id": "ON_OFF_33510B-b7a6b301-b085-4365-9ae4-d83fb88dfd08", + "label": "ON OFF 33510B 2", + "func": "ON_OFF_33510B", + "type": "IO", + "ctrls": { + "connection": { + "type": "VisaConnection", + "default": null, + "desc": "The VISA address (requires the CONNECTION_MDO3XXX node).", + "overload": null, + "functionName": "ON_OFF_33510B", + "param": "connection", + "value": "USB0::2391::9735::MY59003244::0::INSTR" + }, + "on_off": { + "type": "select", + "options": [ + "ON", + "OFF" + ], + "default": "OFF", + "desc": "Whether to turn the waveform generation to on or off.", + "overload": null, + "functionName": "ON_OFF_33510B", + "param": "on_off", + "value": "ON" + }, + "channel": { + "type": "select", + "options": [ + "ch1", + "ch2" + ], + "default": "ch1", + "desc": "The channel to turn on or off.", + "overload": null, + "functionName": "ON_OFF_33510B", + "param": "channel", + "value": "ch2" + } + }, + "initCtrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "Any", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "TextBlob", + "desc": "TextBlob: ON or OFF depending on on_off value." + } + ], + "path": "IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/ON_OFF_33510B/ON_OFF_33510B.py", + "selected": false + }, + "position": { + "x": -493.6858087739779, + "y": 102.59832750990404 + }, + "selected": false, + "positionAbsolute": { + "x": -493.6858087739779, + "y": 102.59832750990404 + }, + "dragging": true + }, + { + "width": 192, + "height": 192, + "id": "ON_OFF_33510B-d19eca7b-b688-4c6d-a0b6-f70c43644790", + "type": "IO", + "data": { + "id": "ON_OFF_33510B-d19eca7b-b688-4c6d-a0b6-f70c43644790", + "label": "ON OFF 33510B 1", + "func": "ON_OFF_33510B", + "type": "IO", + "ctrls": { + "connection": { + "type": "VisaConnection", + "default": null, + "desc": "The VISA address (requires the CONNECTION_MDO3XXX node).", + "overload": null, + "functionName": "ON_OFF_33510B", + "param": "connection", + "value": "USB0::2391::9735::MY59003244::0::INSTR" + }, + "on_off": { + "type": "select", + "options": [ + "ON", + "OFF" + ], + "default": "OFF", + "desc": "Whether to turn the waveform generation to on or off.", + "overload": null, + "functionName": "ON_OFF_33510B", + "param": "on_off", + "value": "OFF" + }, + "channel": { + "type": "select", + "options": [ + "ch1", + "ch2" + ], + "default": "ch1", + "desc": "The channel to turn on or off.", + "overload": null, + "functionName": "ON_OFF_33510B", + "param": "channel", + "value": "ch1" + } + }, + "initCtrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "Any", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "TextBlob", + "desc": "TextBlob: ON or OFF depending on on_off value." + } + ], + "path": "IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/ON_OFF_33510B/ON_OFF_33510B.py", + "selected": false + }, + "position": { + "x": -487.4597221522696, + "y": -267.59982114760356 + }, + "selected": false, + "positionAbsolute": { + "x": -487.4597221522696, + "y": -267.59982114760356 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "ON_OFF_33510B-b7a6b301-b085-4365-9ae4-d83fb88dfd08", + "sourceHandle": "default", + "target": "TEXT_VIEW-9b57ca0b-54cb-46c2-a71a-69bdc48fa993", + "targetHandle": "default", + "id": "reactflow__edge-ON_OFF_33510B-b7a6b301-b085-4365-9ae4-d83fb88dfd08default-TEXT_VIEW-9b57ca0b-54cb-46c2-a71a-69bdc48fa993default" + }, + { + "source": "ON_OFF_33510B-d19eca7b-b688-4c6d-a0b6-f70c43644790", + "sourceHandle": "default", + "target": "TEXT_VIEW-819c7e1c-0ff5-4c09-8a13-b65b1e1bab0e", + "targetHandle": "default", + "id": "reactflow__edge-ON_OFF_33510B-d19eca7b-b688-4c6d-a0b6-f70c43644790default-TEXT_VIEW-819c7e1c-0ff5-4c09-8a13-b65b1e1bab0edefault" + }, + { + "source": "CONNECTION_33510B-d0efefd1-f09c-4f2c-b5d8-ca8fb95155da", + "sourceHandle": "default", + "target": "ON_OFF_33510B-d19eca7b-b688-4c6d-a0b6-f70c43644790", + "targetHandle": "default", + "id": "reactflow__edge-CONNECTION_33510B-d0efefd1-f09c-4f2c-b5d8-ca8fb95155dadefault-ON_OFF_33510B-d19eca7b-b688-4c6d-a0b6-f70c43644790default" + }, + { + "source": "CONNECTION_33510B-d0efefd1-f09c-4f2c-b5d8-ca8fb95155da", + "sourceHandle": "default", + "target": "ON_OFF_33510B-b7a6b301-b085-4365-9ae4-d83fb88dfd08", + "targetHandle": "default", + "id": "reactflow__edge-CONNECTION_33510B-d0efefd1-f09c-4f2c-b5d8-ca8fb95155dadefault-ON_OFF_33510B-b7a6b301-b085-4365-9ae4-d83fb88dfd08default" + } + ], + "viewport": { + "x": 1104.261946392206, + "y": 573.1338859553202, + "zoom": 1.2154437530123414 + } + } +} \ No newline at end of file diff --git a/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/CONNECTION_33510B/examples/EX1/example.md b/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/CONNECTION_33510B/examples/EX1/example.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/ON_OFF_33510B/a1-[autogen]/docstring.txt b/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/ON_OFF_33510B/a1-[autogen]/docstring.txt index 2304a38ef4..21a1a542bd 100644 --- a/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/ON_OFF_33510B/a1-[autogen]/docstring.txt +++ b/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/ON_OFF_33510B/a1-[autogen]/docstring.txt @@ -1,18 +1,15 @@ The ON_OFF_33510B node is used to turn the output on or off. - If the "VISA_address" parameter is not specified the VISA_index will be - used to find the address. The LIST_VISA node can be used to show the - indicies of all available VISA instruments. + Requires a CONNECTION_33510B node at the start of the app to connect with + the instrument. The VISA address will then be listed under 'connection'. This node should also work with compatible Keysight 33XXX wavefunction generators (although they are untested). Parameters ---------- - VISA_address: str - The VISA address to query. - VISA_index: int - The address will be found from LIST_VISA node list with this index. + connection: VisaConnection + The VISA address (requires the CONNECTION_MDO3XXX node). on_off: str Whether to turn the waveform generation to on or off. channel: str diff --git a/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/ON_OFF_33510B/a1-[autogen]/python_code.txt b/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/ON_OFF_33510B/a1-[autogen]/python_code.txt index 3f2a382963..d674558cfb 100644 --- a/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/ON_OFF_33510B/a1-[autogen]/python_code.txt +++ b/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/ON_OFF_33510B/a1-[autogen]/python_code.txt @@ -1,50 +1,21 @@ -from flojoy import flojoy, DataContainer, TextBlob -import pyvisa +from flojoy import flojoy, DataContainer, TextBlob, VisaConnection from typing import Optional, Literal -from qcodes.instrument_drivers.Keysight import Keysight33512B -from usb.core import USBError -@flojoy( - deps={ - "pyvisa": "1.13.0", - "pyusb": "1.2.1", - "zeroconf": "0.102.0", - "pyvisa_py": "0.7.0", - "qcodes": "0.39.1", - } -) +@flojoy(inject_connection=True) def ON_OFF_33510B( - VISA_address: Optional[str], - VISA_index: Optional[int] = 0, + connection: VisaConnection, on_off: Literal["ON", "OFF"] = "OFF", channel: Literal["ch1", "ch2"] = "ch1", default: Optional[DataContainer] = None, -) -> Optional[DataContainer]: +) -> TextBlob: - rm = pyvisa.ResourceManager("@py") - if VISA_address == "": - VISA_addresses = rm.list_resources() - VISA_address = VISA_addresses[int(VISA_index)] - - try: - ks = Keysight33512B( - "ks", - VISA_address, - visalib="@py", - device_clear=False, - ) - except USBError as err: - raise Exception( - "USB port error. Trying unplugging+replugging the port." - ) from err + ks = connection.get_handle() channel_str = channel channel = getattr(ks, channel) channel.output(on_off) - ks.close() - return TextBlob(text_blob=f"{channel_str}: {on_off}") diff --git a/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/ON_OFF_33510B/examples/EX1/app.json b/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/ON_OFF_33510B/examples/EX1/app.json index 7b891eda71..4f64505735 100644 --- a/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/ON_OFF_33510B/examples/EX1/app.json +++ b/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/ON_OFF_33510B/examples/EX1/app.json @@ -26,27 +26,72 @@ "selected": false }, "position": { - "x": -104.31280346396179, - "y": -275.1195051479864 + "x": -97.20356336156576, + "y": -314.9312497214042 }, "selected": false, "positionAbsolute": { - "x": -104.31280346396179, - "y": -275.1195051479864 + "x": -97.20356336156576, + "y": -314.9312497214042 + }, + "dragging": true + }, + { + "width": 384, + "height": 288, + "id": "TEXT_VIEW-9b57ca0b-54cb-46c2-a71a-69bdc48fa993", + "type": "VISUALIZERS", + "data": { + "id": "TEXT_VIEW-9b57ca0b-54cb-46c2-a71a-69bdc48fa993", + "label": "TEXT VIEW 1", + "func": "TEXT_VIEW", + "type": "VISUALIZERS", + "ctrls": {}, + "initCtrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "TextBlob", + "multiple": false, + "desc": "the DataContainer to be visualized in text format" + } + ], + "path": "VISUALIZERS/DATA_STRUCTURE/TEXT_VIEW/TEXT_VIEW.py", + "selected": false + }, + "position": { + "x": -81.05571289888496, + "y": 57.102935591729135 + }, + "selected": false, + "positionAbsolute": { + "x": -81.05571289888496, + "y": 57.102935591729135 }, "dragging": true }, { "width": 192, "height": 192, - "id": "CLOSE_ALL-5ce40df5-d7b2-4c4c-a350-028ed7d948d7", + "id": "CONNECTION_33510B-d0efefd1-f09c-4f2c-b5d8-ca8fb95155da", "type": "IO", "data": { - "id": "CLOSE_ALL-5ce40df5-d7b2-4c4c-a350-028ed7d948d7", - "label": "CLOSE ALL", - "func": "CLOSE_ALL", + "id": "CONNECTION_33510B-d0efefd1-f09c-4f2c-b5d8-ca8fb95155da", + "label": "CONNECTION 33510B", + "func": "CONNECTION_33510B", "type": "IO", - "ctrls": {}, + "ctrls": { + "device": { + "type": "VisaDevice", + "default": null, + "desc": "The VISA address to connect to.", + "overload": null, + "functionName": "CONNECTION_33510B", + "param": "device", + "value": "USB0::2391::9735::MY59003244::0::INSTR" + } + }, "initCtrls": {}, "inputs": [ { @@ -62,58 +107,43 @@ "name": "default", "id": "default", "type": "Any", - "desc": "optional: The input DataContainer is returned." + "desc": "Optional: None" } ], - "pip_dependencies": [ - { - "name": "qcodes", - "v": "0.39.1" - } - ], - "path": "IO/INSTRUMENTS/QCODES/CLOSE_ALL/CLOSE_ALL.py", + "path": "IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/CONNECTION_33510B/CONNECTION_33510B.py", "selected": false }, "position": { - "x": -919.3821328184661, - "y": -74.54262269929615 + "x": -887.4349451815563, + "y": -64.27026427943238 }, "selected": false, "positionAbsolute": { - "x": -919.3821328184661, - "y": -74.54262269929615 + "x": -887.4349451815563, + "y": -64.27026427943238 }, "dragging": true }, { "width": 192, "height": 192, - "id": "ON_OFF_33510B-40f04122-9a47-4ecd-8181-7b42d087a126", + "id": "ON_OFF_33510B-b7a6b301-b085-4365-9ae4-d83fb88dfd08", "type": "IO", "data": { - "id": "ON_OFF_33510B-40f04122-9a47-4ecd-8181-7b42d087a126", - "label": "ON OFF 33510B", + "id": "ON_OFF_33510B-b7a6b301-b085-4365-9ae4-d83fb88dfd08", + "label": "ON OFF 33510B 2", "func": "ON_OFF_33510B", "type": "IO", "ctrls": { - "VISA_address": { - "type": "str", + "connection": { + "type": "VisaConnection", "default": null, - "desc": "The VISA address to query.", + "desc": "The VISA address (requires the CONNECTION_MDO3XXX node).", "overload": null, "functionName": "ON_OFF_33510B", - "param": "VISA_address", + "param": "connection", "value": "USB0::2391::9735::MY59003244::0::INSTR" }, - "VISA_index": { - "type": "int", - "default": 0, - "desc": "The address will be found from LIST_VISA node list with this index.", - "overload": null, - "functionName": "ON_OFF_33510B", - "param": "VISA_index", - "value": 0 - }, "on_off": { "type": "select", "options": [ @@ -138,7 +168,7 @@ "overload": null, "functionName": "ON_OFF_33510B", "param": "channel", - "value": "ch1" + "value": "ch2" } }, "initCtrls": {}, @@ -155,75 +185,44 @@ { "name": "default", "id": "default", - "type": "Any", + "type": "TextBlob", "desc": "TextBlob: ON or OFF depending on on_off value." } ], - "pip_dependencies": [ - { - "name": "pyvisa", - "v": "1.13.0" - }, - { - "name": "pyusb", - "v": "1.2.1" - }, - { - "name": "zeroconf", - "v": "0.102.0" - }, - { - "name": "pyvisa_py", - "v": "0.7.0" - }, - { - "name": "qcodes", - "v": "0.39.1" - } - ], "path": "IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/ON_OFF_33510B/ON_OFF_33510B.py", "selected": false }, "position": { - "x": -518.9542744208309, - "y": -225.7992199828376 + "x": -493.6858087739779, + "y": 102.59832750990404 }, "selected": false, "positionAbsolute": { - "x": -518.9542744208309, - "y": -225.7992199828376 + "x": -493.6858087739779, + "y": 102.59832750990404 }, "dragging": true }, { "width": 192, "height": 192, - "id": "ON_OFF_33510B-c5638b61-e10d-48a1-b59d-835c2dfd2290", + "id": "ON_OFF_33510B-d19eca7b-b688-4c6d-a0b6-f70c43644790", "type": "IO", "data": { - "id": "ON_OFF_33510B-c5638b61-e10d-48a1-b59d-835c2dfd2290", + "id": "ON_OFF_33510B-d19eca7b-b688-4c6d-a0b6-f70c43644790", "label": "ON OFF 33510B 1", "func": "ON_OFF_33510B", "type": "IO", "ctrls": { - "VISA_address": { - "type": "str", + "connection": { + "type": "VisaConnection", "default": null, - "desc": "The VISA address to query.", + "desc": "The VISA address (requires the CONNECTION_MDO3XXX node).", "overload": null, "functionName": "ON_OFF_33510B", - "param": "VISA_address", + "param": "connection", "value": "USB0::2391::9735::MY59003244::0::INSTR" }, - "VISA_index": { - "type": "int", - "default": 0, - "desc": "The address will be found from LIST_VISA node list with this index.", - "overload": null, - "functionName": "ON_OFF_33510B", - "param": "VISA_index", - "value": 0 - }, "on_off": { "type": "select", "options": [ @@ -248,7 +247,7 @@ "overload": null, "functionName": "ON_OFF_33510B", "param": "channel", - "value": "ch2" + "value": "ch1" } }, "initCtrls": {}, @@ -265,110 +264,53 @@ { "name": "default", "id": "default", - "type": "Any", + "type": "TextBlob", "desc": "TextBlob: ON or OFF depending on on_off value." } ], - "pip_dependencies": [ - { - "name": "pyvisa", - "v": "1.13.0" - }, - { - "name": "pyusb", - "v": "1.2.1" - }, - { - "name": "zeroconf", - "v": "0.102.0" - }, - { - "name": "pyvisa_py", - "v": "0.7.0" - }, - { - "name": "qcodes", - "v": "0.39.1" - } - ], "path": "IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/ON_OFF_33510B/ON_OFF_33510B.py", "selected": false }, "position": { - "x": -527.5335653145921, - "y": 123.28418767124424 + "x": -487.4597221522696, + "y": -267.59982114760356 }, "selected": false, "positionAbsolute": { - "x": -527.5335653145921, - "y": 123.28418767124424 - }, - "dragging": true - }, - { - "width": 384, - "height": 288, - "id": "TEXT_VIEW-9b57ca0b-54cb-46c2-a71a-69bdc48fa993", - "type": "VISUALIZERS", - "data": { - "id": "TEXT_VIEW-9b57ca0b-54cb-46c2-a71a-69bdc48fa993", - "label": "TEXT VIEW 1", - "func": "TEXT_VIEW", - "type": "VISUALIZERS", - "ctrls": {}, - "initCtrls": {}, - "inputs": [ - { - "name": "default", - "id": "default", - "type": "TextBlob", - "multiple": false, - "desc": "the DataContainer to be visualized in text format" - } - ], - "path": "VISUALIZERS/DATA_STRUCTURE/TEXT_VIEW/TEXT_VIEW.py", - "selected": false - }, - "position": { - "x": -120.86745747230276, - "y": 75.58695985795885 - }, - "selected": false, - "positionAbsolute": { - "x": -120.86745747230276, - "y": 75.58695985795885 + "x": -487.4597221522696, + "y": -267.59982114760356 }, "dragging": true } ], "edges": [ { - "source": "CLOSE_ALL-5ce40df5-d7b2-4c4c-a350-028ed7d948d7", + "source": "ON_OFF_33510B-b7a6b301-b085-4365-9ae4-d83fb88dfd08", "sourceHandle": "default", - "target": "ON_OFF_33510B-40f04122-9a47-4ecd-8181-7b42d087a126", + "target": "TEXT_VIEW-9b57ca0b-54cb-46c2-a71a-69bdc48fa993", "targetHandle": "default", - "id": "reactflow__edge-CLOSE_ALL-5ce40df5-d7b2-4c4c-a350-028ed7d948d7default-ON_OFF_33510B-40f04122-9a47-4ecd-8181-7b42d087a126default" + "id": "reactflow__edge-ON_OFF_33510B-b7a6b301-b085-4365-9ae4-d83fb88dfd08default-TEXT_VIEW-9b57ca0b-54cb-46c2-a71a-69bdc48fa993default" }, { - "source": "ON_OFF_33510B-40f04122-9a47-4ecd-8181-7b42d087a126", + "source": "ON_OFF_33510B-d19eca7b-b688-4c6d-a0b6-f70c43644790", "sourceHandle": "default", "target": "TEXT_VIEW-819c7e1c-0ff5-4c09-8a13-b65b1e1bab0e", "targetHandle": "default", - "id": "reactflow__edge-ON_OFF_33510B-40f04122-9a47-4ecd-8181-7b42d087a126default-TEXT_VIEW-819c7e1c-0ff5-4c09-8a13-b65b1e1bab0edefault" + "id": "reactflow__edge-ON_OFF_33510B-d19eca7b-b688-4c6d-a0b6-f70c43644790default-TEXT_VIEW-819c7e1c-0ff5-4c09-8a13-b65b1e1bab0edefault" }, { - "source": "ON_OFF_33510B-c5638b61-e10d-48a1-b59d-835c2dfd2290", + "source": "CONNECTION_33510B-d0efefd1-f09c-4f2c-b5d8-ca8fb95155da", "sourceHandle": "default", - "target": "TEXT_VIEW-9b57ca0b-54cb-46c2-a71a-69bdc48fa993", + "target": "ON_OFF_33510B-d19eca7b-b688-4c6d-a0b6-f70c43644790", "targetHandle": "default", - "id": "reactflow__edge-ON_OFF_33510B-c5638b61-e10d-48a1-b59d-835c2dfd2290default-TEXT_VIEW-9b57ca0b-54cb-46c2-a71a-69bdc48fa993default" + "id": "reactflow__edge-CONNECTION_33510B-d0efefd1-f09c-4f2c-b5d8-ca8fb95155dadefault-ON_OFF_33510B-d19eca7b-b688-4c6d-a0b6-f70c43644790default" }, { - "source": "CLOSE_ALL-5ce40df5-d7b2-4c4c-a350-028ed7d948d7", + "source": "CONNECTION_33510B-d0efefd1-f09c-4f2c-b5d8-ca8fb95155da", "sourceHandle": "default", - "target": "ON_OFF_33510B-c5638b61-e10d-48a1-b59d-835c2dfd2290", + "target": "ON_OFF_33510B-b7a6b301-b085-4365-9ae4-d83fb88dfd08", "targetHandle": "default", - "id": "reactflow__edge-CLOSE_ALL-5ce40df5-d7b2-4c4c-a350-028ed7d948d7default-ON_OFF_33510B-c5638b61-e10d-48a1-b59d-835c2dfd2290default" + "id": "reactflow__edge-CONNECTION_33510B-d0efefd1-f09c-4f2c-b5d8-ca8fb95155dadefault-ON_OFF_33510B-b7a6b301-b085-4365-9ae4-d83fb88dfd08default" } ], "viewport": { diff --git a/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/OUTPUT_SYNC_33510B/a1-[autogen]/docstring.txt b/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/OUTPUT_SYNC_33510B/a1-[autogen]/docstring.txt index 33bc7e7230..62514066a1 100644 --- a/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/OUTPUT_SYNC_33510B/a1-[autogen]/docstring.txt +++ b/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/OUTPUT_SYNC_33510B/a1-[autogen]/docstring.txt @@ -2,19 +2,16 @@ The OUTPUT_SYNC_33510B node is used sync multiple outputs phases. Can only be turned on for one channel. - If the "VISA_address" parameter is not specified the VISA_index will be - used to find the address. The LIST_VISA node can be used to show the - indicies of all available VISA instruments. + Requires a CONNECTION_33510B node at the start of the app to connect with + the instrument. The VISA address will then be listed under 'connection'. This node should also work with compatible Keysight 33XXX wavefunction generators (although they are untested). Parameters ---------- - VISA_address: str - The VISA address to query. - VISA_index: int - The address will be found from LIST_VISA node list with this index. + connection: VisaConnection + The VISA address (requires the CONNECTION_MDO3XXX node). on_off: str Whether to turn the waveform phase syncing on or off. channel: str @@ -23,4 +20,4 @@ The OUTPUT_SYNC_33510B node is used sync multiple outputs phases. Returns ------- DataContainer - TextBlob: ON or OFF depending on on_off value. + TextBlob: The channel, and ON or OFF depending on on_off value. diff --git a/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/OUTPUT_SYNC_33510B/a1-[autogen]/python_code.txt b/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/OUTPUT_SYNC_33510B/a1-[autogen]/python_code.txt index 24fc5fd124..262b12685b 100644 --- a/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/OUTPUT_SYNC_33510B/a1-[autogen]/python_code.txt +++ b/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/OUTPUT_SYNC_33510B/a1-[autogen]/python_code.txt @@ -1,44 +1,17 @@ -from flojoy import flojoy, DataContainer, TextBlob -import pyvisa +from flojoy import flojoy, DataContainer, TextBlob, VisaConnection from typing import Optional, Literal -from qcodes.instrument_drivers.Keysight import Keysight33512B -from usb.core import USBError -@flojoy( - deps={ - "pyvisa": "1.13.0", - "pyusb": "1.2.1", - "zeroconf": "0.102.0", - "pyvisa_py": "0.7.0", - "qcodes": "0.39.1", - } -) +@flojoy(inject_connection=True) def OUTPUT_SYNC_33510B( - VISA_address: Optional[str], - VISA_index: Optional[int] = 0, + connection: VisaConnection, on_off: Literal["ON", "OFF"] = "OFF", channel: Literal["1", "2"] = "1", default: Optional[DataContainer] = None, -) -> Optional[DataContainer]: +) -> TextBlob: - rm = pyvisa.ResourceManager("@py") - if VISA_address == "": - VISA_addresses = rm.list_resources() - VISA_address = VISA_addresses[int(VISA_index)] - - try: - ks = Keysight33512B( - "ks", - VISA_address, - visalib="@py", - device_clear=False, - ) - except USBError as err: - raise Exception( - "USB port error. Trying unplugging+replugging the port." - ) from err + ks = connection.get_handle() ks.sync.source(int(channel)) match on_off: @@ -48,6 +21,4 @@ def OUTPUT_SYNC_33510B( ks.sync.output("ON") ks.write("PHAS:SYNC") - ks.close() - return TextBlob(text_blob=f"CH{channel} sync: {on_off}") diff --git a/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/OUTPUT_SYNC_33510B/examples/EX1/app.json b/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/OUTPUT_SYNC_33510B/examples/EX1/app.json index 8bc9459b0a..5eb997992c 100644 --- a/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/OUTPUT_SYNC_33510B/examples/EX1/app.json +++ b/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/OUTPUT_SYNC_33510B/examples/EX1/app.json @@ -2,118 +2,113 @@ "rfInstance": { "nodes": [ { - "width": 384, - "height": 288, - "id": "TEXT_VIEW-819c7e1c-0ff5-4c09-8a13-b65b1e1bab0e", - "type": "VISUALIZERS", + "width": 192, + "height": 192, + "id": "CONNECTION_33510B-4c8ca1dd-a8ee-4ba9-ae8b-886c80a0a027", + "type": "IO", "data": { - "id": "TEXT_VIEW-819c7e1c-0ff5-4c09-8a13-b65b1e1bab0e", - "label": "TEXT VIEW", - "func": "TEXT_VIEW", - "type": "VISUALIZERS", - "ctrls": {}, + "id": "CONNECTION_33510B-4c8ca1dd-a8ee-4ba9-ae8b-886c80a0a027", + "label": "CONNECTION 33510B", + "func": "CONNECTION_33510B", + "type": "IO", + "ctrls": { + "device": { + "type": "VisaDevice", + "default": null, + "desc": "The VISA address to connect to.", + "overload": null, + "functionName": "CONNECTION_33510B", + "param": "device", + "value": "USB0::2391::9735::MY59003244::0::INSTR" + } + }, "initCtrls": {}, "inputs": [ { "name": "default", "id": "default", - "type": "TextBlob", + "type": "Any", "multiple": false, - "desc": "the DataContainer to be visualized in text format" + "desc": null } ], - "path": "VISUALIZERS/DATA_STRUCTURE/TEXT_VIEW/TEXT_VIEW.py", + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Any", + "desc": "Optional: None" + } + ], + "path": "IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/CONNECTION_33510B/CONNECTION_33510B.py", "selected": false }, "position": { - "x": -73.10397672973124, - "y": -120.11566570130807 + "x": -886.7395156170513, + "y": -112.96725387394693 }, "selected": false, "positionAbsolute": { - "x": -73.10397672973124, - "y": -120.11566570130807 + "x": -886.7395156170513, + "y": -112.96725387394693 }, "dragging": true }, { - "width": 192, - "height": 192, - "id": "CLOSE_ALL-5ce40df5-d7b2-4c4c-a350-028ed7d948d7", - "type": "IO", + "width": 225, + "height": 226, + "id": "TEXT_VIEW-1e087237-ee3a-4db7-963d-46fbdbd7b59b", + "type": "VISUALIZERS", "data": { - "id": "CLOSE_ALL-5ce40df5-d7b2-4c4c-a350-028ed7d948d7", - "label": "CLOSE ALL", - "func": "CLOSE_ALL", - "type": "IO", + "id": "TEXT_VIEW-1e087237-ee3a-4db7-963d-46fbdbd7b59b", + "label": "TEXT VIEW", + "func": "TEXT_VIEW", + "type": "VISUALIZERS", "ctrls": {}, "initCtrls": {}, "inputs": [ { "name": "default", "id": "default", - "type": "Any", + "type": "TextBlob", "multiple": false, - "desc": null - } - ], - "outputs": [ - { - "name": "default", - "id": "default", - "type": "Any", - "desc": "optional: The input DataContainer is returned." - } - ], - "pip_dependencies": [ - { - "name": "qcodes", - "v": "0.39.1" + "desc": "the DataContainer to be visualized in text format" } ], - "path": "IO/INSTRUMENTS/QCODES/CLOSE_ALL/CLOSE_ALL.py", + "path": "VISUALIZERS/DATA_STRUCTURE/TEXT_VIEW/TEXT_VIEW.py", "selected": false }, "position": { - "x": -919.3821328184661, - "y": -74.54262269929615 + "x": -228.91602197898922, + "y": -130.8283743248985 }, "selected": false, "positionAbsolute": { - "x": -919.3821328184661, - "y": -74.54262269929615 + "x": -228.91602197898922, + "y": -130.8283743248985 }, "dragging": true }, { "width": 192, "height": 192, - "id": "OUTPUT_SYNC_33510B-3ac2323e-d6a3-44e7-b7b2-f89168e0ad16", + "id": "OUTPUT_SYNC_33510B-a889708d-f110-42a5-a7ce-67c30d4eb9c0", "type": "IO", "data": { - "id": "OUTPUT_SYNC_33510B-3ac2323e-d6a3-44e7-b7b2-f89168e0ad16", + "id": "OUTPUT_SYNC_33510B-a889708d-f110-42a5-a7ce-67c30d4eb9c0", "label": "OUTPUT SYNC 33510B", "func": "OUTPUT_SYNC_33510B", "type": "IO", "ctrls": { - "VISA_address": { - "type": "str", + "connection": { + "type": "VisaConnection", "default": null, - "desc": "The VISA address to query.", + "desc": "The VISA address (requires the CONNECTION_MDO3XXX node).", "overload": null, "functionName": "OUTPUT_SYNC_33510B", - "param": "VISA_address", + "param": "connection", "value": "USB0::2391::9735::MY59003244::0::INSTR" }, - "VISA_index": { - "type": "int", - "default": 0, - "desc": "The address will be found from LIST_VISA node list with this index.", - "overload": null, - "functionName": "OUTPUT_SYNC_33510B", - "param": "VISA_index", - "value": 0 - }, "on_off": { "type": "select", "options": [ @@ -155,61 +150,39 @@ { "name": "default", "id": "default", - "type": "Any", - "desc": "TextBlob: ON or OFF depending on on_off value." - } - ], - "pip_dependencies": [ - { - "name": "pyvisa", - "v": "1.13.0" - }, - { - "name": "pyusb", - "v": "1.2.1" - }, - { - "name": "zeroconf", - "v": "0.102.0" - }, - { - "name": "pyvisa_py", - "v": "0.7.0" - }, - { - "name": "qcodes", - "v": "0.39.1" + "type": "TextBlob", + "desc": "TextBlob: The channel, and ON or OFF depending on on_off value." } ], "path": "IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/OUTPUT_SYNC_33510B/OUTPUT_SYNC_33510B.py", "selected": false }, "position": { - "x": -510.11784179817596, - "y": -76.20285758215164 + "x": -576.8436213938844, + "y": -112.88858916855764 }, "selected": false, "positionAbsolute": { - "x": -510.11784179817596, - "y": -76.20285758215164 + "x": -576.8436213938844, + "y": -112.88858916855764 }, "dragging": true } ], "edges": [ { - "source": "CLOSE_ALL-5ce40df5-d7b2-4c4c-a350-028ed7d948d7", + "source": "CONNECTION_33510B-4c8ca1dd-a8ee-4ba9-ae8b-886c80a0a027", "sourceHandle": "default", - "target": "OUTPUT_SYNC_33510B-3ac2323e-d6a3-44e7-b7b2-f89168e0ad16", + "target": "OUTPUT_SYNC_33510B-a889708d-f110-42a5-a7ce-67c30d4eb9c0", "targetHandle": "default", - "id": "reactflow__edge-CLOSE_ALL-5ce40df5-d7b2-4c4c-a350-028ed7d948d7default-OUTPUT_SYNC_33510B-3ac2323e-d6a3-44e7-b7b2-f89168e0ad16default" + "id": "reactflow__edge-CONNECTION_33510B-4c8ca1dd-a8ee-4ba9-ae8b-886c80a0a027default-OUTPUT_SYNC_33510B-a889708d-f110-42a5-a7ce-67c30d4eb9c0default" }, { - "source": "OUTPUT_SYNC_33510B-3ac2323e-d6a3-44e7-b7b2-f89168e0ad16", + "source": "OUTPUT_SYNC_33510B-a889708d-f110-42a5-a7ce-67c30d4eb9c0", "sourceHandle": "default", - "target": "TEXT_VIEW-819c7e1c-0ff5-4c09-8a13-b65b1e1bab0e", + "target": "TEXT_VIEW-1e087237-ee3a-4db7-963d-46fbdbd7b59b", "targetHandle": "default", - "id": "reactflow__edge-OUTPUT_SYNC_33510B-3ac2323e-d6a3-44e7-b7b2-f89168e0ad16default-TEXT_VIEW-819c7e1c-0ff5-4c09-8a13-b65b1e1bab0edefault" + "id": "reactflow__edge-OUTPUT_SYNC_33510B-a889708d-f110-42a5-a7ce-67c30d4eb9c0default-TEXT_VIEW-1e087237-ee3a-4db7-963d-46fbdbd7b59bdefault" } ], "viewport": { diff --git a/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/SET_WAVEFORM_33510B/a1-[autogen]/docstring.txt b/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/SET_WAVEFORM_33510B/a1-[autogen]/docstring.txt index 2f5e0fc149..3838008c5d 100644 --- a/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/SET_WAVEFORM_33510B/a1-[autogen]/docstring.txt +++ b/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/SET_WAVEFORM_33510B/a1-[autogen]/docstring.txt @@ -2,19 +2,16 @@ The SET_WAVEFORM_33510B node is used to set waveform settings for a 33510B. The Keysight 33510B has a variety of waveform settings available. - If the "VISA_address" parameter is not specified the VISA_index will be - used to find the address. The LIST_VISA node can be used to show the - indicies of all available VISA instruments. + Requires a CONNECTION_33510B node at the start of the app to connect with + the instrument. The VISA address will then be listed under 'connection'. This node should also work with compatible Keysight 33XXX wavefunction generators (although they are untested). Parameters ---------- - VISA_address: str - The VISA address to query. - VISA_index: int - The address will be found from LIST_VISA node list with this index. + connection: VisaConnection + The VISA address (requires the CONNECTION_MDO3XXX node). on_off: str Whether to turn the waveform generation to on or off. query_set: str @@ -41,4 +38,4 @@ The SET_WAVEFORM_33510B node is used to set waveform settings for a 33510B. Returns ------- DataContainer - Scalar: The waveform measurement in the selected statistic mode. + TextBlob: Summary of waveform generator settings. diff --git a/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/SET_WAVEFORM_33510B/a1-[autogen]/python_code.txt b/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/SET_WAVEFORM_33510B/a1-[autogen]/python_code.txt index 1b02ff10e4..d446053ac5 100644 --- a/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/SET_WAVEFORM_33510B/a1-[autogen]/python_code.txt +++ b/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/SET_WAVEFORM_33510B/a1-[autogen]/python_code.txt @@ -1,22 +1,10 @@ -from flojoy import flojoy, DataContainer, TextBlob -import pyvisa +from flojoy import flojoy, DataContainer, TextBlob, VisaConnection from typing import Optional, Literal -from qcodes.instrument_drivers.Keysight import Keysight33512B -from usb.core import USBError -@flojoy( - deps={ - "pyvisa": "1.13.0", - "pyusb": "1.2.1", - "zeroconf": "0.102.0", - "pyvisa_py": "0.7.0", - "qcodes": "0.39.1", - } -) +@flojoy(inject_connection=True) def SET_WAVEFORM_33510B( - VISA_address: Optional[str], - VISA_index: Optional[int] = 0, + connection: VisaConnection, on_off: Literal["ON", "OFF"] = "OFF", query_set: Literal["query", "set"] = "query", channel: Literal["ch1", "ch2"] = "ch1", @@ -31,25 +19,10 @@ def SET_WAVEFORM_33510B( ramp_symmetry: float = 50, pulse_width: float = 20, default: Optional[DataContainer] = None, -) -> Optional[DataContainer]: +) -> TextBlob: - rm = pyvisa.ResourceManager("@py") - if VISA_address == "": - VISA_addresses = rm.list_resources() - VISA_address = VISA_addresses[int(VISA_index)] - - try: - ks = Keysight33512B( - "ks", - VISA_address, - visalib="@py", - device_clear=False, - ) - except USBError as err: - raise Exception( - "USB port error. Trying unplugging+replugging the port." - ) from err + ks = connection.get_handle() channel_str = channel channel = getattr(ks, channel) @@ -106,6 +79,4 @@ def SET_WAVEFORM_33510B( if on_off == "ON": channel.output("ON") - ks.close() - return TextBlob(text_blob=summary) diff --git a/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/SET_WAVEFORM_33510B/examples/EX1/app.json b/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/SET_WAVEFORM_33510B/examples/EX1/app.json index d287b26ea9..df59690bd7 100644 --- a/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/SET_WAVEFORM_33510B/examples/EX1/app.json +++ b/docs/nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/SET_WAVEFORM_33510B/examples/EX1/app.json @@ -1,13 +1,66 @@ { "rfInstance": { "nodes": [ + { + "width": 192, + "height": 192, + "id": "CONNECTION_33510B-4c8ca1dd-a8ee-4ba9-ae8b-886c80a0a027", + "type": "IO", + "data": { + "id": "CONNECTION_33510B-4c8ca1dd-a8ee-4ba9-ae8b-886c80a0a027", + "label": "CONNECTION 33510B", + "func": "CONNECTION_33510B", + "type": "IO", + "ctrls": { + "device": { + "type": "VisaDevice", + "default": null, + "desc": "The VISA address to connect to.", + "overload": null, + "functionName": "CONNECTION_33510B", + "param": "device", + "value": "USB0::2391::9735::MY59003244::0::INSTR" + } + }, + "initCtrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "Any", + "multiple": false, + "desc": null + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Any", + "desc": "Optional: None" + } + ], + "path": "IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/CONNECTION_33510B/CONNECTION_33510B.py", + "selected": false + }, + "position": { + "x": -979.7571031864528, + "y": -121.42339819843798 + }, + "selected": false, + "positionAbsolute": { + "x": -979.7571031864528, + "y": -121.42339819843798 + }, + "dragging": true + }, { "width": 384, "height": 288, - "id": "TEXT_VIEW-819c7e1c-0ff5-4c09-8a13-b65b1e1bab0e", + "id": "TEXT_VIEW-1e087237-ee3a-4db7-963d-46fbdbd7b59b", "type": "VISUALIZERS", "data": { - "id": "TEXT_VIEW-819c7e1c-0ff5-4c09-8a13-b65b1e1bab0e", + "id": "TEXT_VIEW-1e087237-ee3a-4db7-963d-46fbdbd7b59b", "label": "TEXT VIEW", "func": "TEXT_VIEW", "type": "VISUALIZERS", @@ -26,45 +79,36 @@ "selected": false }, "position": { - "x": 126.63251436934425, - "y": -126.35743104815421 + "x": 131.5271298524416, + "y": -142.45557277107372 }, "selected": false, "positionAbsolute": { - "x": 126.63251436934425, - "y": -126.35743104815421 + "x": 131.5271298524416, + "y": -142.45557277107372 }, "dragging": true }, { "width": 192, "height": 192, - "id": "SET_WAVEFORM_33510B-5d984289-23fd-4a07-8581-9e67f458275a", + "id": "SET_WAVEFORM_33510B-0ab66699-2865-4958-ac92-6ff441f13cf2", "type": "IO", "data": { - "id": "SET_WAVEFORM_33510B-5d984289-23fd-4a07-8581-9e67f458275a", - "label": "QUERY WAVEFORM 33510B", + "id": "SET_WAVEFORM_33510B-0ab66699-2865-4958-ac92-6ff441f13cf2", + "label": "SET WAVEFORM", "func": "SET_WAVEFORM_33510B", "type": "IO", "ctrls": { - "VISA_address": { - "type": "str", + "connection": { + "type": "VisaConnection", "default": null, - "desc": "The VISA address to query.", + "desc": "The VISA address (requires the CONNECTION_MDO3XXX node).", "overload": null, "functionName": "SET_WAVEFORM_33510B", - "param": "VISA_address", + "param": "connection", "value": "USB0::2391::9735::MY59003244::0::INSTR" }, - "VISA_index": { - "type": "int", - "default": 0, - "desc": "The address will be found from LIST_VISA node list with this index.", - "overload": null, - "functionName": "SET_WAVEFORM_33510B", - "param": "VISA_index", - "value": 0 - }, "on_off": { "type": "select", "options": [ @@ -89,7 +133,7 @@ "overload": null, "functionName": "SET_WAVEFORM_33510B", "param": "query_set", - "value": "query" + "value": "set" }, "channel": { "type": "select", @@ -207,75 +251,44 @@ { "name": "default", "id": "default", - "type": "Any", - "desc": "Scalar: The waveform measurement in the selected statistic mode." - } - ], - "pip_dependencies": [ - { - "name": "pyvisa", - "v": "1.13.0" - }, - { - "name": "pyusb", - "v": "1.2.1" - }, - { - "name": "zeroconf", - "v": "0.102.0" - }, - { - "name": "pyvisa_py", - "v": "0.7.0" - }, - { - "name": "qcodes", - "v": "0.39.1" + "type": "TextBlob", + "desc": "TextBlob: Summary of waveform generator settings." } ], "path": "IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/SET_WAVEFORM_33510B/SET_WAVEFORM_33510B.py", "selected": false }, "position": { - "x": -235.3146615647039, - "y": -80.09846489697861 + "x": -621.6271042931016, + "y": -120.43534000032497 }, "selected": false, "positionAbsolute": { - "x": -235.3146615647039, - "y": -80.09846489697861 + "x": -621.6271042931016, + "y": -120.43534000032497 }, "dragging": true }, { "width": 192, "height": 192, - "id": "SET_WAVEFORM_33510B-cff57b5b-40b6-48a6-bce1-b72039d971a5", + "id": "SET_WAVEFORM_33510B-9dc26886-d55d-4825-bb40-7f86db98083f", "type": "IO", "data": { - "id": "SET_WAVEFORM_33510B-cff57b5b-40b6-48a6-bce1-b72039d971a5", - "label": "SET WAVEFORM 33510B 1", + "id": "SET_WAVEFORM_33510B-9dc26886-d55d-4825-bb40-7f86db98083f", + "label": "QUERY WAVEFORM", "func": "SET_WAVEFORM_33510B", "type": "IO", "ctrls": { - "VISA_address": { - "type": "str", + "connection": { + "type": "VisaConnection", "default": null, - "desc": "The VISA address to query.", + "desc": "The VISA address (requires the CONNECTION_MDO3XXX node).", "overload": null, "functionName": "SET_WAVEFORM_33510B", - "param": "VISA_address", + "param": "connection", "value": "USB0::2391::9735::MY59003244::0::INSTR" }, - "VISA_index": { - "type": "int", - "default": 0, - "desc": "The address will be found from LIST_VISA node list with this index.", - "overload": null, - "functionName": "SET_WAVEFORM_33510B", - "param": "VISA_index", - "value": 0 - }, "on_off": { "type": "select", "options": [ @@ -287,7 +300,7 @@ "overload": null, "functionName": "SET_WAVEFORM_33510B", "param": "on_off", - "value": "OFF" + "value": "ON" }, "query_set": { "type": "select", @@ -300,7 +313,7 @@ "overload": null, "functionName": "SET_WAVEFORM_33510B", "param": "query_set", - "value": "set" + "value": "query" }, "channel": { "type": "select", @@ -351,7 +364,7 @@ "overload": null, "functionName": "SET_WAVEFORM_33510B", "param": "amplitude", - "value": 0.2 + "value": 0.1 }, "amplitude_unit": { "type": "select", @@ -418,117 +431,46 @@ { "name": "default", "id": "default", - "type": "Any", - "desc": "Scalar: The waveform measurement in the selected statistic mode." - } - ], - "pip_dependencies": [ - { - "name": "pyvisa", - "v": "1.13.0" - }, - { - "name": "pyusb", - "v": "1.2.1" - }, - { - "name": "zeroconf", - "v": "0.102.0" - }, - { - "name": "pyvisa_py", - "v": "0.7.0" - }, - { - "name": "qcodes", - "v": "0.39.1" + "type": "TextBlob", + "desc": "TextBlob: Summary of waveform generator settings." } ], "path": "IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/SET_WAVEFORM_33510B/SET_WAVEFORM_33510B.py", "selected": false }, "position": { - "x": -587.0980217998496, - "y": -74.46641189574345 - }, - "selected": false, - "positionAbsolute": { - "x": -587.0980217998496, - "y": -74.46641189574345 - }, - "dragging": true - }, - { - "width": 192, - "height": 192, - "id": "CLOSE_ALL-5ce40df5-d7b2-4c4c-a350-028ed7d948d7", - "type": "IO", - "data": { - "id": "CLOSE_ALL-5ce40df5-d7b2-4c4c-a350-028ed7d948d7", - "label": "CLOSE ALL", - "func": "CLOSE_ALL", - "type": "IO", - "ctrls": {}, - "initCtrls": {}, - "inputs": [ - { - "name": "default", - "id": "default", - "type": "Any", - "multiple": false, - "desc": null - } - ], - "outputs": [ - { - "name": "default", - "id": "default", - "type": "Any", - "desc": "optional: The input DataContainer is returned." - } - ], - "pip_dependencies": [ - { - "name": "qcodes", - "v": "0.39.1" - } - ], - "path": "IO/INSTRUMENTS/QCODES/CLOSE_ALL/CLOSE_ALL.py", - "selected": false - }, - "position": { - "x": -919.3821328184661, - "y": -74.54262269929615 + "x": -249.25622073246237, + "y": -118.32870369988929 }, "selected": false, "positionAbsolute": { - "x": -919.3821328184661, - "y": -74.54262269929615 + "x": -249.25622073246237, + "y": -118.32870369988929 }, "dragging": true } ], "edges": [ { - "source": "SET_WAVEFORM_33510B-5d984289-23fd-4a07-8581-9e67f458275a", + "source": "CONNECTION_33510B-4c8ca1dd-a8ee-4ba9-ae8b-886c80a0a027", "sourceHandle": "default", - "target": "TEXT_VIEW-819c7e1c-0ff5-4c09-8a13-b65b1e1bab0e", + "target": "SET_WAVEFORM_33510B-0ab66699-2865-4958-ac92-6ff441f13cf2", "targetHandle": "default", - "id": "reactflow__edge-SET_WAVEFORM_33510B-5d984289-23fd-4a07-8581-9e67f458275adefault-TEXT_VIEW-819c7e1c-0ff5-4c09-8a13-b65b1e1bab0edefault" + "id": "reactflow__edge-CONNECTION_33510B-4c8ca1dd-a8ee-4ba9-ae8b-886c80a0a027default-SET_WAVEFORM_33510B-0ab66699-2865-4958-ac92-6ff441f13cf2default" }, { - "source": "SET_WAVEFORM_33510B-cff57b5b-40b6-48a6-bce1-b72039d971a5", + "source": "SET_WAVEFORM_33510B-0ab66699-2865-4958-ac92-6ff441f13cf2", "sourceHandle": "default", - "target": "SET_WAVEFORM_33510B-5d984289-23fd-4a07-8581-9e67f458275a", + "target": "SET_WAVEFORM_33510B-9dc26886-d55d-4825-bb40-7f86db98083f", "targetHandle": "default", - "id": "reactflow__edge-SET_WAVEFORM_33510B-cff57b5b-40b6-48a6-bce1-b72039d971a5default-SET_WAVEFORM_33510B-5d984289-23fd-4a07-8581-9e67f458275adefault" + "id": "reactflow__edge-SET_WAVEFORM_33510B-0ab66699-2865-4958-ac92-6ff441f13cf2default-SET_WAVEFORM_33510B-9dc26886-d55d-4825-bb40-7f86db98083fdefault" }, { - "source": "CLOSE_ALL-5ce40df5-d7b2-4c4c-a350-028ed7d948d7", + "source": "SET_WAVEFORM_33510B-9dc26886-d55d-4825-bb40-7f86db98083f", "sourceHandle": "default", - "target": "SET_WAVEFORM_33510B-cff57b5b-40b6-48a6-bce1-b72039d971a5", + "target": "TEXT_VIEW-1e087237-ee3a-4db7-963d-46fbdbd7b59b", "targetHandle": "default", - "id": "reactflow__edge-CLOSE_ALL-5ce40df5-d7b2-4c4c-a350-028ed7d948d7default-SET_WAVEFORM_33510B-cff57b5b-40b6-48a6-bce1-b72039d971a5default" + "id": "reactflow__edge-SET_WAVEFORM_33510B-9dc26886-d55d-4825-bb40-7f86db98083fdefault-TEXT_VIEW-1e087237-ee3a-4db7-963d-46fbdbd7b59bdefault" } ], "viewport": { diff --git a/nodeSidebar.json b/nodeSidebar.json index 67bff8ce72..6b4da632bc 100644 --- a/nodeSidebar.json +++ b/nodeSidebar.json @@ -151,6 +151,7 @@ "I/O > Function Generators": [ "nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/ADVANCED/BURST_MODE_33510B/BURST_MODE_33510B", "nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/ADVANCED/RETURN_ERRORS_33510B/RETURN_ERRORS_33510B", + "nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/CONNECTION_33510B/CONNECTION_33510B", "nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/ON_OFF_33510B/ON_OFF_33510B", "nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/OUTPUT_SYNC_33510B/OUTPUT_SYNC_33510B", "nodes/IO/INSTRUMENTS/FUNCTION_GENERATORS/KEYSIGHT/33XXX/BASIC/SET_WAVEFORM_33510B/SET_WAVEFORM_33510B" From 8a541c784a10ba3d0fabd25980eaf49b23fd9534 Mon Sep 17 00:00:00 2001 From: dstrande Date: Thu, 28 Sep 2023 15:52:56 +0000 Subject: [PATCH 2/6] update: fix test --- .../GENERATORS/SIMULATIONS/RAND/a1-[autogen]/python_code.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/nodes/GENERATORS/SIMULATIONS/RAND/a1-[autogen]/python_code.txt b/docs/nodes/GENERATORS/SIMULATIONS/RAND/a1-[autogen]/python_code.txt index 0d13749228..8e2fc0ec5d 100644 --- a/docs/nodes/GENERATORS/SIMULATIONS/RAND/a1-[autogen]/python_code.txt +++ b/docs/nodes/GENERATORS/SIMULATIONS/RAND/a1-[autogen]/python_code.txt @@ -47,7 +47,7 @@ def RAND( y = my_generator.poisson(lam=poisson_events, size=size) if not eval(force_scalar): - return OrderedPair(x=x, y=y) if default else Scalar(c=float(y)) + return OrderedPair(x=x, y=y) if default else Scalar(c=float(y[0])) elif eval(force_scalar): return Scalar(c=float(y)) else: From c4294407d9622ff09ab99394c9ff46860a8ee754 Mon Sep 17 00:00:00 2001 From: dstrande Date: Thu, 28 Sep 2023 17:02:31 +0000 Subject: [PATCH 3/6] update: change param to bool --- .../SIMULATIONS/RAND/a1-[autogen]/python_code.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/nodes/GENERATORS/SIMULATIONS/RAND/a1-[autogen]/python_code.txt b/docs/nodes/GENERATORS/SIMULATIONS/RAND/a1-[autogen]/python_code.txt index 8e2fc0ec5d..b78ae5306c 100644 --- a/docs/nodes/GENERATORS/SIMULATIONS/RAND/a1-[autogen]/python_code.txt +++ b/docs/nodes/GENERATORS/SIMULATIONS/RAND/a1-[autogen]/python_code.txt @@ -8,7 +8,7 @@ from typing import Literal, Optional def RAND( default: Optional[OrderedPair | Vector] = None, distribution: Literal["normal", "uniform", "poisson"] = "normal", - force_scalar: Literal["False", "True"] = "False", + force_scalar: bool = False, lower_bound: float = 0, upper_bound: float = 1, normal_mean: float = 0, @@ -33,7 +33,7 @@ def RAND( case _: size = 1 - if eval(force_scalar): + if force_scalar: size = 1 match distribution: @@ -46,9 +46,9 @@ def RAND( case "poisson": y = my_generator.poisson(lam=poisson_events, size=size) - if not eval(force_scalar): + if not force_scalar: return OrderedPair(x=x, y=y) if default else Scalar(c=float(y[0])) - elif eval(force_scalar): + elif force_scalar: return Scalar(c=float(y)) else: raise TypeError("True/False string evaluation error.") From 07d5f500dc56f638b5c51a42cf116fd65563473f Mon Sep 17 00:00:00 2001 From: dstrande Date: Thu, 28 Sep 2023 17:22:40 +0000 Subject: [PATCH 4/6] update: Update GENERATORS/SIMULATIONS/RAND/RAND.py --- .../GENERATORS/SIMULATIONS/RAND/a1-[autogen]/docstring.txt | 2 +- .../SIMULATIONS/RAND/a1-[autogen]/python_code.txt | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/docs/nodes/GENERATORS/SIMULATIONS/RAND/a1-[autogen]/docstring.txt b/docs/nodes/GENERATORS/SIMULATIONS/RAND/a1-[autogen]/docstring.txt index 33cdae59b8..10947e80bd 100644 --- a/docs/nodes/GENERATORS/SIMULATIONS/RAND/a1-[autogen]/docstring.txt +++ b/docs/nodes/GENERATORS/SIMULATIONS/RAND/a1-[autogen]/docstring.txt @@ -9,7 +9,7 @@ The RAND node generates a random number or a list of random numbers, depending o ---------- distribution : select the distribution over the random samples - force_scalar : select + force_scalar : bool whether to force the output to be a Scalar lower_bound : float the lower bound of the output interval diff --git a/docs/nodes/GENERATORS/SIMULATIONS/RAND/a1-[autogen]/python_code.txt b/docs/nodes/GENERATORS/SIMULATIONS/RAND/a1-[autogen]/python_code.txt index b78ae5306c..6ed29ac674 100644 --- a/docs/nodes/GENERATORS/SIMULATIONS/RAND/a1-[autogen]/python_code.txt +++ b/docs/nodes/GENERATORS/SIMULATIONS/RAND/a1-[autogen]/python_code.txt @@ -48,10 +48,8 @@ def RAND( if not force_scalar: return OrderedPair(x=x, y=y) if default else Scalar(c=float(y[0])) - elif force_scalar: - return Scalar(c=float(y)) - else: - raise TypeError("True/False string evaluation error.") + + return Scalar(c=float(y)) @display From dd68e7efbe4314ae8bc248a033573221eb8ef5b4 Mon Sep 17 00:00:00 2001 From: dstrande Date: Thu, 28 Sep 2023 20:18:39 +0000 Subject: [PATCH 5/6] update: RAND changes and add POPULATE --- .../SIMULATIONS/POPULATE/POPULATE.md | 57 +++ .../POPULATE/a1-[autogen]/docstring.txt | 27 ++ .../POPULATE/a1-[autogen]/python_code.txt | 58 +++ .../SIMULATIONS/POPULATE/appendix/hardware.md | 1 + .../SIMULATIONS/POPULATE/appendix/media.md | 1 + .../SIMULATIONS/POPULATE/appendix/notes.md | 1 + .../POPULATE/examples/EX1/app.json | 444 ++++++++++++++++++ .../POPULATE/examples/EX1/example.md | 6 + .../RAND/a1-[autogen]/docstring.txt | 17 +- .../RAND/a1-[autogen]/python_code.txt | 37 +- .../SIMULATIONS/RAND/examples/EX1/app.json | 341 +++++++------- nodeSidebar.json | 1 + 12 files changed, 796 insertions(+), 195 deletions(-) create mode 100644 docs/nodes/GENERATORS/SIMULATIONS/POPULATE/POPULATE.md create mode 100644 docs/nodes/GENERATORS/SIMULATIONS/POPULATE/a1-[autogen]/docstring.txt create mode 100644 docs/nodes/GENERATORS/SIMULATIONS/POPULATE/a1-[autogen]/python_code.txt create mode 100644 docs/nodes/GENERATORS/SIMULATIONS/POPULATE/appendix/hardware.md create mode 100644 docs/nodes/GENERATORS/SIMULATIONS/POPULATE/appendix/media.md create mode 100644 docs/nodes/GENERATORS/SIMULATIONS/POPULATE/appendix/notes.md create mode 100644 docs/nodes/GENERATORS/SIMULATIONS/POPULATE/examples/EX1/app.json create mode 100644 docs/nodes/GENERATORS/SIMULATIONS/POPULATE/examples/EX1/example.md diff --git a/docs/nodes/GENERATORS/SIMULATIONS/POPULATE/POPULATE.md b/docs/nodes/GENERATORS/SIMULATIONS/POPULATE/POPULATE.md new file mode 100644 index 0000000000..3faf5d95f3 --- /dev/null +++ b/docs/nodes/GENERATORS/SIMULATIONS/POPULATE/POPULATE.md @@ -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'; + +{DocstringSource} +{PythonSource} + + + + + +[//]: # (Examples) + +## Examples + +import Example1 from './examples/EX1/example.md'; +import App1 from '!!raw-loader!./examples/EX1/app.json'; + + + + + {App1} + + + + + + + + +[//]: # (Appendix) + +import Notes from './appendix/notes.md'; +import Hardware from './appendix/hardware.md'; +import Media from './appendix/media.md'; + +## Appendix + + + + + + diff --git a/docs/nodes/GENERATORS/SIMULATIONS/POPULATE/a1-[autogen]/docstring.txt b/docs/nodes/GENERATORS/SIMULATIONS/POPULATE/a1-[autogen]/docstring.txt new file mode 100644 index 0000000000..9b3910a111 --- /dev/null +++ b/docs/nodes/GENERATORS/SIMULATIONS/POPULATE/a1-[autogen]/docstring.txt @@ -0,0 +1,27 @@ +The POPULATE node generates random numbers, depending on the distribution selected and the input data. + + Inputs + ------ + default : OrderedPair|Vector + Input to use as the x-axis for the random samples. + + Parameters + ---------- + distribution : select + the distribution over the random samples + lower_bound : float + the lower bound of the output interval + upper_bound : float + the upper bound of the output interval + normal_mean : float + the mean or "center" of the normal distribution + normal_standard_deviation : float + the spread or "width" of the normal distribution + poisson_events : float + the expected number of events occurring in a fixed time-interval when distribution is poisson + + Returns + ------- + OrderedPair + x: provided from input data + y: the random samples diff --git a/docs/nodes/GENERATORS/SIMULATIONS/POPULATE/a1-[autogen]/python_code.txt b/docs/nodes/GENERATORS/SIMULATIONS/POPULATE/a1-[autogen]/python_code.txt new file mode 100644 index 0000000000..cb65e8388e --- /dev/null +++ b/docs/nodes/GENERATORS/SIMULATIONS/POPULATE/a1-[autogen]/python_code.txt @@ -0,0 +1,58 @@ +import random +import numpy as np +from flojoy import flojoy, OrderedPair, Vector, display +from typing import Literal, Optional + + +@flojoy +def POPULATE( + default: OrderedPair | Vector, + distribution: Literal["normal", "uniform", "poisson"] = "normal", + lower_bound: float = 0, + upper_bound: float = 1, + normal_mean: float = 0, + normal_standard_deviation: float = 1, + poisson_events: float = 1, +) -> OrderedPair: + + + if upper_bound < lower_bound: + upper_bound, lower_bound = lower_bound, upper_bound + + seed = random.randint(1, 10000) + my_generator = np.random.default_rng(seed) + + match default: + case OrderedPair(): + size = len(default.x) + x = default.x + case Vector(): + size = len(default.v) + x = default.v + + match distribution: + case "uniform": + y = my_generator.uniform(low=lower_bound, high=upper_bound, size=size) + case "normal": + y = my_generator.normal( + loc=normal_mean, scale=normal_standard_deviation, size=size + ) + case "poisson": + y = my_generator.poisson(lam=poisson_events, size=size) + + return OrderedPair(x=x, y=y) + + +@display +def OVERLOAD(lower_bound, upper_bound, distribution="uniform") -> None: + return None + + +@display +def OVERLOAD(normal_mean, normal_standard_deviation, distribution="normal") -> None: + return None + + +@display +def OVERLOAD(poisson_events, distribution="poisson") -> None: + return None diff --git a/docs/nodes/GENERATORS/SIMULATIONS/POPULATE/appendix/hardware.md b/docs/nodes/GENERATORS/SIMULATIONS/POPULATE/appendix/hardware.md new file mode 100644 index 0000000000..7f78a555c4 --- /dev/null +++ b/docs/nodes/GENERATORS/SIMULATIONS/POPULATE/appendix/hardware.md @@ -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. \ No newline at end of file diff --git a/docs/nodes/GENERATORS/SIMULATIONS/POPULATE/appendix/media.md b/docs/nodes/GENERATORS/SIMULATIONS/POPULATE/appendix/media.md new file mode 100644 index 0000000000..8bcee9be90 --- /dev/null +++ b/docs/nodes/GENERATORS/SIMULATIONS/POPULATE/appendix/media.md @@ -0,0 +1 @@ +No supporting screenshots, photos, or videos have been added to the media.md file for this node. \ No newline at end of file diff --git a/docs/nodes/GENERATORS/SIMULATIONS/POPULATE/appendix/notes.md b/docs/nodes/GENERATORS/SIMULATIONS/POPULATE/appendix/notes.md new file mode 100644 index 0000000000..04aded2ec9 --- /dev/null +++ b/docs/nodes/GENERATORS/SIMULATIONS/POPULATE/appendix/notes.md @@ -0,0 +1 @@ +No theory or technical notes have been contributed for this node yet. \ No newline at end of file diff --git a/docs/nodes/GENERATORS/SIMULATIONS/POPULATE/examples/EX1/app.json b/docs/nodes/GENERATORS/SIMULATIONS/POPULATE/examples/EX1/app.json new file mode 100644 index 0000000000..786ebde992 --- /dev/null +++ b/docs/nodes/GENERATORS/SIMULATIONS/POPULATE/examples/EX1/app.json @@ -0,0 +1,444 @@ +{ + "rfInstance": { + "nodes": [ + { + "width": 380, + "height": 293, + "id": "HISTOGRAM-c5469532-dd28-4465-b8b0-524174db86e4", + "type": "VISUALIZERS", + "data": { + "id": "HISTOGRAM-c5469532-dd28-4465-b8b0-524174db86e4", + "label": "HISTOGRAM", + "func": "HISTOGRAM", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame|Matrix", + "multiple": false + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly" + } + ], + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/HISTOGRAM/HISTOGRAM.py", + "selected": false + }, + "position": { + "x": 794.6062406107221, + "y": -355.5689772430068 + }, + "selected": false, + "positionAbsolute": { + "x": 794.6062406107221, + "y": -355.5689772430068 + }, + "dragging": true + }, + { + "width": 208, + "height": 96, + "id": "LINSPACE-14e316a4-dcdb-47ac-868d-d829b0c30678", + "type": "GENERATORS", + "data": { + "id": "LINSPACE-14e316a4-dcdb-47ac-868d-d829b0c30678", + "label": "LINSPACE", + "func": "LINSPACE", + "type": "GENERATORS", + "ctrls": { + "start": { + "type": "float", + "default": 10, + "desc": "The start point of the data.", + "overload": null, + "functionName": "LINSPACE", + "param": "start", + "value": 10 + }, + "end": { + "type": "float", + "default": 0, + "desc": "The end point of the data.", + "overload": null, + "functionName": "LINSPACE", + "param": "end", + "value": 0 + }, + "step": { + "type": "int", + "default": 1000, + "desc": "The number of points in the vector.", + "overload": null, + "functionName": "LINSPACE", + "param": "step", + "value": 1000 + } + }, + "initCtrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "Vector|OrderedPair", + "multiple": false, + "desc": "Optional input in case LINSPACE is used in a loop. Not used." + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Vector", + "desc": "v: the vector between 'start' and 'end' with a 'step' number of points." + } + ], + "path": "GENERATORS/SIMULATIONS/LINSPACE/LINSPACE.py", + "selected": false + }, + "position": { + "x": 60.78604888475641, + "y": -72.26608171130152 + }, + "selected": false, + "positionAbsolute": { + "x": 60.78604888475641, + "y": -72.26608171130152 + }, + "dragging": true + }, + { + "width": 208, + "height": 96, + "id": "POPULATE-b27a1155-ccd8-4e60-a0ca-3a0744f6f19c", + "type": "GENERATORS", + "data": { + "id": "POPULATE-b27a1155-ccd8-4e60-a0ca-3a0744f6f19c", + "label": "POPULATE", + "func": "POPULATE", + "type": "GENERATORS", + "ctrls": { + "distribution": { + "type": "select", + "options": [ + "normal", + "uniform", + "poisson" + ], + "default": "normal", + "desc": "the distribution over the random samples", + "overload": { + "uniform": [ + "lower_bound", + "upper_bound" + ], + "normal": [ + "normal_mean", + "normal_standard_deviation" + ], + "poisson": [ + "poisson_events" + ] + }, + "functionName": "POPULATE", + "param": "distribution", + "value": "normal" + }, + "lower_bound": { + "type": "float", + "default": 0, + "desc": "the lower bound of the output interval", + "overload": null, + "functionName": "POPULATE", + "param": "lower_bound", + "value": 0 + }, + "upper_bound": { + "type": "float", + "default": 1, + "desc": "the upper bound of the output interval", + "overload": null, + "functionName": "POPULATE", + "param": "upper_bound", + "value": 1 + }, + "normal_mean": { + "type": "float", + "default": 0, + "desc": "the mean or \"center\" of the normal distribution", + "overload": null, + "functionName": "POPULATE", + "param": "normal_mean", + "value": 0 + }, + "normal_standard_deviation": { + "type": "float", + "default": 1, + "desc": "the spread or \"width\" of the normal distribution", + "overload": null, + "functionName": "POPULATE", + "param": "normal_standard_deviation", + "value": 1 + }, + "poisson_events": { + "type": "float", + "default": 1, + "desc": "the expected number of events occurring in a fixed time-interval when distribution is poisson", + "overload": null, + "functionName": "POPULATE", + "param": "poisson_events", + "value": 1 + } + }, + "initCtrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|Vector", + "multiple": false, + "desc": "Input to use as the x-axis for the random samples." + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair", + "desc": "x: provided from input data\ny: the random samples" + } + ], + "path": "GENERATORS/SIMULATIONS/POPULATE/POPULATE.py", + "selected": false + }, + "position": { + "x": 428.99358191180903, + "y": -258.88112365217773 + }, + "selected": false, + "positionAbsolute": { + "x": 428.99358191180903, + "y": -258.88112365217773 + }, + "dragging": true + }, + { + "width": 208, + "height": 96, + "id": "POPULATE-fb436d2a-9db1-4de7-8e25-97b7c56a9f29", + "type": "GENERATORS", + "data": { + "id": "POPULATE-fb436d2a-9db1-4de7-8e25-97b7c56a9f29", + "label": "POPULATE 1", + "func": "POPULATE", + "type": "GENERATORS", + "ctrls": { + "distribution": { + "type": "select", + "options": [ + "normal", + "uniform", + "poisson" + ], + "default": "normal", + "desc": "the distribution over the random samples", + "overload": { + "uniform": [ + "lower_bound", + "upper_bound" + ], + "normal": [ + "normal_mean", + "normal_standard_deviation" + ], + "poisson": [ + "poisson_events" + ] + }, + "functionName": "POPULATE", + "param": "distribution", + "value": "poisson" + }, + "lower_bound": { + "type": "float", + "default": 0, + "desc": "the lower bound of the output interval", + "overload": null, + "functionName": "POPULATE", + "param": "lower_bound", + "value": 0 + }, + "upper_bound": { + "type": "float", + "default": 1, + "desc": "the upper bound of the output interval", + "overload": null, + "functionName": "POPULATE", + "param": "upper_bound", + "value": 1 + }, + "normal_mean": { + "type": "float", + "default": 0, + "desc": "the mean or \"center\" of the normal distribution", + "overload": null, + "functionName": "POPULATE", + "param": "normal_mean", + "value": 0 + }, + "normal_standard_deviation": { + "type": "float", + "default": 1, + "desc": "the spread or \"width\" of the normal distribution", + "overload": null, + "functionName": "POPULATE", + "param": "normal_standard_deviation", + "value": 1 + }, + "poisson_events": { + "type": "float", + "default": 1, + "desc": "the expected number of events occurring in a fixed time-interval when distribution is poisson", + "overload": null, + "functionName": "POPULATE", + "param": "poisson_events", + "value": 1 + } + }, + "initCtrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|Vector", + "multiple": false, + "desc": "Input to use as the x-axis for the random samples." + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair", + "desc": "x: provided from input data\ny: the random samples" + } + ], + "path": "GENERATORS/SIMULATIONS/POPULATE/POPULATE.py", + "selected": false + }, + "position": { + "x": 423.735359873562, + "y": 61.2094115519848 + }, + "selected": false, + "positionAbsolute": { + "x": 423.735359873562, + "y": 61.2094115519848 + }, + "dragging": true + }, + { + "width": 380, + "height": 293, + "id": "HISTOGRAM-e426b844-934e-4b27-983f-68afc25b5659", + "type": "VISUALIZERS", + "data": { + "id": "HISTOGRAM-e426b844-934e-4b27-983f-68afc25b5659", + "label": "HISTOGRAM 1", + "func": "HISTOGRAM", + "type": "VISUALIZERS", + "ctrls": {}, + "initCtrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame|Matrix|Vector", + "multiple": false, + "desc": "the DataContainer to be visualized" + } + ], + "outputs": [ + { + "name": "default", + "id": "default", + "type": "Plotly", + "desc": "the DataContainer containing the Plotly Histogram visualization" + } + ], + "path": "VISUALIZERS/PLOTLY/HISTOGRAM/HISTOGRAM.py", + "selected": false + }, + "position": { + "x": 792.6069096920073, + "y": -29.88744351696306 + }, + "selected": false, + "positionAbsolute": { + "x": 792.6069096920073, + "y": -29.88744351696306 + }, + "dragging": true + } + ], + "edges": [ + { + "source": "LINSPACE-14e316a4-dcdb-47ac-868d-d829b0c30678", + "sourceHandle": "default", + "target": "POPULATE-b27a1155-ccd8-4e60-a0ca-3a0744f6f19c", + "targetHandle": "default", + "id": "reactflow__edge-LINSPACE-14e316a4-dcdb-47ac-868d-d829b0c30678default-POPULATE-b27a1155-ccd8-4e60-a0ca-3a0744f6f19cdefault" + }, + { + "source": "POPULATE-b27a1155-ccd8-4e60-a0ca-3a0744f6f19c", + "sourceHandle": "default", + "target": "HISTOGRAM-c5469532-dd28-4465-b8b0-524174db86e4", + "targetHandle": "default", + "id": "reactflow__edge-POPULATE-b27a1155-ccd8-4e60-a0ca-3a0744f6f19cdefault-HISTOGRAM-c5469532-dd28-4465-b8b0-524174db86e4default" + }, + { + "source": "LINSPACE-14e316a4-dcdb-47ac-868d-d829b0c30678", + "sourceHandle": "default", + "target": "POPULATE-fb436d2a-9db1-4de7-8e25-97b7c56a9f29", + "targetHandle": "default", + "id": "reactflow__edge-LINSPACE-14e316a4-dcdb-47ac-868d-d829b0c30678default-POPULATE-fb436d2a-9db1-4de7-8e25-97b7c56a9f29default" + }, + { + "source": "POPULATE-fb436d2a-9db1-4de7-8e25-97b7c56a9f29", + "sourceHandle": "default", + "target": "HISTOGRAM-e426b844-934e-4b27-983f-68afc25b5659", + "targetHandle": "default", + "id": "reactflow__edge-POPULATE-fb436d2a-9db1-4de7-8e25-97b7c56a9f29default-HISTOGRAM-e426b844-934e-4b27-983f-68afc25b5659default" + } + ], + "viewport": { + "x": -373.4542219202399, + "y": 120.20973884288571, + "zoom": 1.101977389476256 + } + }, + "ctrlsManifest": [ + { + "type": "input", + "name": "Slider", + "id": "INPUT_PLACEHOLDER", + "hidden": false, + "minHeight": 1, + "minWidth": 2, + "layout": { + "x": 0, + "y": 0, + "h": 2, + "w": 2, + "minH": 1, + "minW": 2, + "i": "INPUT_PLACEHOLDER" + } + } + ] +} \ No newline at end of file diff --git a/docs/nodes/GENERATORS/SIMULATIONS/POPULATE/examples/EX1/example.md b/docs/nodes/GENERATORS/SIMULATIONS/POPULATE/examples/EX1/example.md new file mode 100644 index 0000000000..b172aefe60 --- /dev/null +++ b/docs/nodes/GENERATORS/SIMULATIONS/POPULATE/examples/EX1/example.md @@ -0,0 +1,6 @@ +In this example, `LINSPACE` is used to generate a list of 1000 samples, it is then passed into two `POPULATE` nodes, which randomizes the values within the list with a normal (or Gaussian) distribution and a Poisson distribution. + +The distribution is then plotted with `HISTOGRAM` and as expected of a Gaussian distribution, +the output of the `HISTOGRAM` node converges towards a bell curve. The Poisson distribution results in more of a step function. + +The `POPULATE` node requires an input `Vector` or `OrderedPair` to function. diff --git a/docs/nodes/GENERATORS/SIMULATIONS/RAND/a1-[autogen]/docstring.txt b/docs/nodes/GENERATORS/SIMULATIONS/RAND/a1-[autogen]/docstring.txt index 10947e80bd..55e1ceeb71 100644 --- a/docs/nodes/GENERATORS/SIMULATIONS/RAND/a1-[autogen]/docstring.txt +++ b/docs/nodes/GENERATORS/SIMULATIONS/RAND/a1-[autogen]/docstring.txt @@ -2,15 +2,15 @@ The RAND node generates a random number or a list of random numbers, depending o Inputs ------ - default : OrderedPair|Vector - Optional input to use as the x-axis for the random samples. + default : DataContainer + unused in this node Parameters ---------- distribution : select the distribution over the random samples - force_scalar : bool - whether to force the output to be a Scalar + size : int + the size of the output. =1 outputs Scalar, >1 outputs Vector lower_bound : float the lower bound of the output interval upper_bound : float @@ -24,10 +24,9 @@ The RAND node generates a random number or a list of random numbers, depending o Returns ------- - OrderedPair|Scalar - OrderedPair if there is an input. - x: the x-axis of the input - y: the random samples + Scalar|Vector + Vector if size > 1 + v: the random samples - Scalar if there is no input. + Scalar if size = 1 c: the random number diff --git a/docs/nodes/GENERATORS/SIMULATIONS/RAND/a1-[autogen]/python_code.txt b/docs/nodes/GENERATORS/SIMULATIONS/RAND/a1-[autogen]/python_code.txt index 6ed29ac674..33ed2bd37e 100644 --- a/docs/nodes/GENERATORS/SIMULATIONS/RAND/a1-[autogen]/python_code.txt +++ b/docs/nodes/GENERATORS/SIMULATIONS/RAND/a1-[autogen]/python_code.txt @@ -1,41 +1,30 @@ import random import numpy as np -from flojoy import flojoy, OrderedPair, Scalar, Vector, display +from flojoy import flojoy, Scalar, Vector, display, DataContainer from typing import Literal, Optional @flojoy def RAND( - default: Optional[OrderedPair | Vector] = None, + default: Optional[DataContainer] = None, distribution: Literal["normal", "uniform", "poisson"] = "normal", - force_scalar: bool = False, + size: int = 1000, lower_bound: float = 0, upper_bound: float = 1, normal_mean: float = 0, normal_standard_deviation: float = 1, poisson_events: float = 1, -) -> OrderedPair | Scalar: +) -> Vector | Scalar: + assert size >= 1, "Size must be greater than or equal to than 1" + if upper_bound < lower_bound: upper_bound, lower_bound = lower_bound, upper_bound seed = random.randint(1, 10000) my_generator = np.random.default_rng(seed) - match default: - case OrderedPair(): - size = len(default.x) - x = default.x - case Vector(): - size = len(default.v) - x = default.v - case _: - size = 1 - - if force_scalar: - size = 1 - match distribution: case "uniform": y = my_generator.uniform(low=lower_bound, high=upper_bound, size=size) @@ -46,24 +35,24 @@ def RAND( case "poisson": y = my_generator.poisson(lam=poisson_events, size=size) - if not force_scalar: - return OrderedPair(x=x, y=y) if default else Scalar(c=float(y[0])) - - return Scalar(c=float(y)) + if size > 1: + return Vector(v=y) + + return Scalar(c=float(y[0])) @display -def OVERLOAD(force_scalar, lower_bound, upper_bound, distribution="uniform") -> None: +def OVERLOAD(size, lower_bound, upper_bound, distribution="uniform") -> None: return None @display def OVERLOAD( - force_scalar, normal_mean, normal_standard_deviation, distribution="normal" + size, normal_mean, normal_standard_deviation, distribution="normal" ) -> None: return None @display -def OVERLOAD(poisson_events, distribution="poisson") -> None: +def OVERLOAD(size, poisson_events, distribution="poisson") -> None: return None diff --git a/docs/nodes/GENERATORS/SIMULATIONS/RAND/examples/EX1/app.json b/docs/nodes/GENERATORS/SIMULATIONS/RAND/examples/EX1/app.json index cc4910b1e8..b4ad89dd4c 100644 --- a/docs/nodes/GENERATORS/SIMULATIONS/RAND/examples/EX1/app.json +++ b/docs/nodes/GENERATORS/SIMULATIONS/RAND/examples/EX1/app.json @@ -2,75 +2,90 @@ "rfInstance": { "nodes": [ { - "width": 150, - "height": 150, - "id": "LINSPACE-cc55781a-14c8-4405-8fd1-0157351b3486", - "type": "default", + "width": 380, + "height": 293, + "id": "HISTOGRAM-c5469532-dd28-4465-b8b0-524174db86e4", + "type": "VISUALIZERS", "data": { - "id": "LINSPACE-cc55781a-14c8-4405-8fd1-0157351b3486", - "label": "LINSPACE", - "func": "LINSPACE", - "type": "default", - "ctrls": { - "start": { - "type": "float", - "default": 10, - "functionName": "LINSPACE", - "param": "start", - "value": "0" - }, - "end": { - "type": "float", - "default": 0, - "functionName": "LINSPACE", - "param": "end", - "value": "2000" - }, - "step": { - "type": "int", - "default": 1000, - "functionName": "LINSPACE", - "param": "step", - "value": "2000" + "id": "HISTOGRAM-c5469532-dd28-4465-b8b0-524174db86e4", + "label": "HISTOGRAM", + "func": "HISTOGRAM", + "type": "VISUALIZERS", + "ctrls": {}, + "inputs": [ + { + "name": "default", + "id": "default", + "type": "OrderedPair|DataFrame|Matrix", + "multiple": false } - }, + ], "outputs": [ { "name": "default", "id": "default", - "type": "OrderedPair" + "type": "Plotly" } ], - "path": "PYTHON/nodes/GENERATORS/SIMULATIONS/LINSPACE/LINSPACE.py", + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/HISTOGRAM/HISTOGRAM.py", "selected": false }, "position": { - "x": 71.58328955005041, - "y": -121.19469825521614 + "x": 811.2928245068351, + "y": -146.0596461029216 }, "selected": false, "positionAbsolute": { - "x": 71.58328955005041, - "y": -121.19469825521614 + "x": 811.2928245068351, + "y": -146.0596461029216 }, "dragging": true }, { - "width": 250, - "height": 159, - "id": "HISTOGRAM-c5469532-dd28-4465-b8b0-524174db86e4", + "width": 380, + "height": 293, + "id": "BIG_NUMBER-59ecc8d4-f674-4af7-869f-f429f0b1c266", "type": "VISUALIZERS", "data": { - "id": "HISTOGRAM-c5469532-dd28-4465-b8b0-524174db86e4", - "label": "HISTOGRAM", - "func": "HISTOGRAM", + "id": "BIG_NUMBER-59ecc8d4-f674-4af7-869f-f429f0b1c266", + "label": "BIG NUMBER", + "func": "BIG_NUMBER", "type": "VISUALIZERS", - "ctrls": {}, + "ctrls": { + "suffix": { + "type": "str", + "default": null, + "functionName": "BIG_NUMBER", + "param": "suffix", + "value": "" + }, + "prefix": { + "type": "str", + "default": null, + "functionName": "BIG_NUMBER", + "param": "prefix", + "value": "" + }, + "title": { + "type": "str", + "default": null, + "functionName": "BIG_NUMBER", + "param": "title", + "value": "" + }, + "relative_delta": { + "type": "bool", + "default": true, + "functionName": "BIG_NUMBER", + "param": "relative_delta", + "value": true + } + }, "inputs": [ { "name": "default", "id": "default", - "type": "OrderedPair|DataFrame|Matrix", + "type": "OrderedPair", "multiple": false } ], @@ -81,134 +96,201 @@ "type": "Plotly" } ], - "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/HISTOGRAM/HISTOGRAM.py", + "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/BIG_NUMBER/BIG_NUMBER.py", "selected": false }, "position": { - "x": 807.1730016964145, - "y": -111.45313449538975 + "x": 815.0077637293098, + "y": 255.69966488030104 }, "selected": false, "positionAbsolute": { - "x": 807.1730016964145, - "y": -111.45313449538975 + "x": 815.0077637293098, + "y": 255.69966488030104 }, "dragging": true }, { - "width": 130, - "height": 130, - "id": "RAND-1fe43d0a-6b15-49d0-b6e0-35c61744a60a", + "width": 208, + "height": 96, + "id": "RAND-110a9abb-d0df-4b06-9555-6b9e38cdd237", "type": "GENERATORS", "data": { - "id": "RAND-1fe43d0a-6b15-49d0-b6e0-35c61744a60a", + "id": "RAND-110a9abb-d0df-4b06-9555-6b9e38cdd237", "label": "RAND", "func": "RAND", "type": "GENERATORS", "ctrls": { "distribution": { "type": "select", - "default": "normal", "options": [ "normal", "uniform", "poisson" ], + "default": "normal", + "desc": "the distribution over the random samples", + "overload": { + "uniform": [ + "size", + "lower_bound", + "upper_bound" + ], + "normal": [ + "size", + "normal_mean", + "normal_standard_deviation" + ], + "poisson": [ + "size", + "poisson_events" + ] + }, "functionName": "RAND", "param": "distribution", "value": "normal" }, + "size": { + "type": "int", + "default": 1000, + "desc": "the size of the output. =1 outputs Scalar, >1 outputs Vector", + "overload": null, + "functionName": "RAND", + "param": "size", + "value": 1000 + }, "lower_bound": { "type": "float", "default": 0, + "desc": "the lower bound of the output interval", + "overload": null, "functionName": "RAND", "param": "lower_bound", - "value": "0" + "value": 0 }, "upper_bound": { "type": "float", "default": 1, + "desc": "the upper bound of the output interval", + "overload": null, "functionName": "RAND", "param": "upper_bound", - "value": "1" + "value": 1 }, "normal_mean": { "type": "float", "default": 0, + "desc": "the mean or \"center\" of the normal distribution", + "overload": null, "functionName": "RAND", "param": "normal_mean", - "value": "0" + "value": 0 }, "normal_standard_deviation": { "type": "float", "default": 1, + "desc": "the spread or \"width\" of the normal distribution", + "overload": null, "functionName": "RAND", "param": "normal_standard_deviation", - "value": "5" + "value": 1 }, "poisson_events": { "type": "float", "default": 1, + "desc": "the expected number of events occurring in a fixed time-interval when distribution is poisson", + "overload": null, "functionName": "RAND", "param": "poisson_events", - "value": "1" + "value": 1 } }, + "initCtrls": {}, "inputs": [ { "name": "default", "id": "default", - "type": "OrderedPair", - "multiple": false + "type": "Any", + "multiple": false, + "desc": "unused in this node" } ], "outputs": [ { "name": "default", "id": "default", - "type": "OrderedPair|Scalar" + "type": "Vector|Scalar", + "desc": "Vector if size > 1\nv: the random samples\n\nScalar if size = 1\nc: the random number" } ], - "path": "PYTHON/nodes/GENERATORS/SIMULATIONS/RAND/RAND.py", + "path": "GENERATORS/SIMULATIONS/RAND/RAND.py", "selected": false }, "position": { - "x": 454.43802731096747, - "y": -117.22102655068787 + "x": 428.5700838695367, + "y": -49.13895270504895 }, "selected": false, "positionAbsolute": { - "x": 454.43802731096747, - "y": -117.22102655068787 + "x": 428.5700838695367, + "y": -49.13895270504895 }, "dragging": true }, { - "width": 130, - "height": 130, - "id": "RAND-e09e675f-ccaf-44b3-8842-6cea418c4b00", + "width": 208, + "height": 96, + "id": "RAND-d9a6b7da-5ef2-4bb6-bf6d-cd92baca5f7d", "type": "GENERATORS", "data": { - "id": "RAND-e09e675f-ccaf-44b3-8842-6cea418c4b00", + "id": "RAND-d9a6b7da-5ef2-4bb6-bf6d-cd92baca5f7d", "label": "RAND 1", "func": "RAND", "type": "GENERATORS", "ctrls": { "distribution": { "type": "select", - "default": "normal", "options": [ "normal", "uniform", "poisson" ], + "default": "normal", + "desc": "the distribution over the random samples", + "overload": { + "uniform": [ + "size", + "lower_bound", + "upper_bound" + ], + "normal": [ + "size", + "normal_mean", + "normal_standard_deviation" + ], + "poisson": [ + "size", + "poisson_events" + ] + }, "functionName": "RAND", "param": "distribution", "value": "normal" }, + "size": { + "type": "int", + "default": 1000, + "desc": "the size of the output. =1 outputs Scalar, >1 outputs Vector", + "overload": null, + "functionName": "RAND", + "param": "size", + "value": 1 + }, "lower_bound": { "type": "float", "default": 0, + "desc": "the lower bound of the output interval", + "overload": null, "functionName": "RAND", "param": "lower_bound", "value": 0 @@ -216,6 +298,8 @@ "upper_bound": { "type": "float", "default": 1, + "desc": "the upper bound of the output interval", + "overload": null, "functionName": "RAND", "param": "upper_bound", "value": 1 @@ -223,145 +307,78 @@ "normal_mean": { "type": "float", "default": 0, + "desc": "the mean or \"center\" of the normal distribution", + "overload": null, "functionName": "RAND", "param": "normal_mean", - "value": "30" + "value": 0 }, "normal_standard_deviation": { "type": "float", "default": 1, + "desc": "the spread or \"width\" of the normal distribution", + "overload": null, "functionName": "RAND", "param": "normal_standard_deviation", - "value": "50" + "value": 1 }, "poisson_events": { "type": "float", "default": 1, + "desc": "the expected number of events occurring in a fixed time-interval when distribution is poisson", + "overload": null, "functionName": "RAND", "param": "poisson_events", "value": 1 } }, + "initCtrls": {}, "inputs": [ { "name": "default", "id": "default", - "type": "OrderedPair|Vector", - "multiple": false + "type": "Any", + "multiple": false, + "desc": "unused in this node" } ], "outputs": [ { "name": "default", "id": "default", - "type": "OrderedPair|Scalar" + "type": "Vector|Scalar", + "desc": "Vector if size > 1\nv: the random samples\n\nScalar if size = 1\nc: the random number" } ], - "path": "PYTHON/nodes/GENERATORS/SIMULATIONS/RAND/RAND.py", + "path": "GENERATORS/SIMULATIONS/RAND/RAND.py", "selected": false }, "position": { - "x": 385.163294287524, - "y": 328.61362457174704 + "x": 424.11613231809054, + "y": 352.35894002884334 }, "selected": false, "positionAbsolute": { - "x": 385.163294287524, - "y": 328.61362457174704 - }, - "dragging": true - }, - { - "width": 225, - "height": 226, - "id": "BIG_NUMBER-59ecc8d4-f674-4af7-869f-f429f0b1c266", - "type": "VISUALIZERS", - "data": { - "id": "BIG_NUMBER-59ecc8d4-f674-4af7-869f-f429f0b1c266", - "label": "BIG NUMBER", - "func": "BIG_NUMBER", - "type": "VISUALIZERS", - "ctrls": { - "suffix": { - "type": "str", - "default": null, - "functionName": "BIG_NUMBER", - "param": "suffix", - "value": "" - }, - "prefix": { - "type": "str", - "default": null, - "functionName": "BIG_NUMBER", - "param": "prefix", - "value": "" - }, - "title": { - "type": "str", - "default": null, - "functionName": "BIG_NUMBER", - "param": "title", - "value": "" - }, - "relative_delta": { - "type": "bool", - "default": true, - "functionName": "BIG_NUMBER", - "param": "relative_delta", - "value": true - } - }, - "inputs": [ - { - "name": "default", - "id": "default", - "type": "OrderedPair", - "multiple": false - } - ], - "outputs": [ - { - "name": "default", - "id": "default", - "type": "Plotly" - } - ], - "path": "PYTHON/nodes/VISUALIZERS/PLOTLY/BIG_NUMBER/BIG_NUMBER.py", - "selected": false - }, - "position": { - "x": 818.3036219776461, - "y": 287.8342828015806 - }, - "selected": false, - "positionAbsolute": { - "x": 818.3036219776461, - "y": 287.8342828015806 + "x": 424.11613231809054, + "y": 352.35894002884334 }, "dragging": true } ], "edges": [ { - "source": "LINSPACE-cc55781a-14c8-4405-8fd1-0157351b3486", - "sourceHandle": "default", - "target": "RAND-1fe43d0a-6b15-49d0-b6e0-35c61744a60a", - "targetHandle": "default", - "id": "reactflow__edge-LINSPACE-cc55781a-14c8-4405-8fd1-0157351b3486default-RAND-1fe43d0a-6b15-49d0-b6e0-35c61744a60adefault" - }, - { - "source": "RAND-1fe43d0a-6b15-49d0-b6e0-35c61744a60a", + "source": "RAND-110a9abb-d0df-4b06-9555-6b9e38cdd237", "sourceHandle": "default", "target": "HISTOGRAM-c5469532-dd28-4465-b8b0-524174db86e4", "targetHandle": "default", - "id": "reactflow__edge-RAND-1fe43d0a-6b15-49d0-b6e0-35c61744a60adefault-HISTOGRAM-c5469532-dd28-4465-b8b0-524174db86e4default" + "id": "reactflow__edge-RAND-110a9abb-d0df-4b06-9555-6b9e38cdd237default-HISTOGRAM-c5469532-dd28-4465-b8b0-524174db86e4default" }, { - "source": "RAND-e09e675f-ccaf-44b3-8842-6cea418c4b00", + "source": "RAND-d9a6b7da-5ef2-4bb6-bf6d-cd92baca5f7d", "sourceHandle": "default", "target": "BIG_NUMBER-59ecc8d4-f674-4af7-869f-f429f0b1c266", "targetHandle": "default", - "id": "reactflow__edge-RAND-e09e675f-ccaf-44b3-8842-6cea418c4b00default-BIG_NUMBER-59ecc8d4-f674-4af7-869f-f429f0b1c266default" + "id": "reactflow__edge-RAND-d9a6b7da-5ef2-4bb6-bf6d-cd92baca5f7ddefault-BIG_NUMBER-59ecc8d4-f674-4af7-869f-f429f0b1c266default" } ], "viewport": { diff --git a/nodeSidebar.json b/nodeSidebar.json index 6b4da632bc..ad1769fa69 100644 --- a/nodeSidebar.json +++ b/nodeSidebar.json @@ -33,6 +33,7 @@ "nodes/GENERATORS/SIMULATIONS/FEEDBACK/FEEDBACK", "nodes/GENERATORS/SIMULATIONS/LINSPACE/LINSPACE", "nodes/GENERATORS/SIMULATIONS/MATRIX/MATRIX", + "nodes/GENERATORS/SIMULATIONS/POPULATE/POPULATE", "nodes/GENERATORS/SIMULATIONS/RAND/RAND", "nodes/GENERATORS/SIMULATIONS/SCALAR/SCALAR", "nodes/GENERATORS/SIMULATIONS/SECOND_ORDER_SYSTEM/SECOND_ORDER_SYSTEM", From 138bf5d57a0779b3bf276a9945a92a85a4b2fa11 Mon Sep 17 00:00:00 2001 From: dstrande Date: Thu, 28 Sep 2023 21:03:48 +0000 Subject: [PATCH 6/6] update: Merge branch 'develop' into dallas-rand-force-scalar --- .../SORT_VECTOR/a1-[autogen]/docstring.txt | 5 +++++ .../SORT_VECTOR/a1-[autogen]/python_code.txt | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/nodes/TRANSFORMERS/VECTOR_MANIPULATION/SORT_VECTOR/a1-[autogen]/docstring.txt b/docs/nodes/TRANSFORMERS/VECTOR_MANIPULATION/SORT_VECTOR/a1-[autogen]/docstring.txt index e0b1d3fc15..bb1385bc85 100644 --- a/docs/nodes/TRANSFORMERS/VECTOR_MANIPULATION/SORT_VECTOR/a1-[autogen]/docstring.txt +++ b/docs/nodes/TRANSFORMERS/VECTOR_MANIPULATION/SORT_VECTOR/a1-[autogen]/docstring.txt @@ -5,6 +5,11 @@ The SORT_VECTOR node returns the input Vector that is sorted default : Vector The input vector + Parameters + ---------- + reverse : bool + If False, sort in ascending order. If True, descending order. + Returns ------- Vector diff --git a/docs/nodes/TRANSFORMERS/VECTOR_MANIPULATION/SORT_VECTOR/a1-[autogen]/python_code.txt b/docs/nodes/TRANSFORMERS/VECTOR_MANIPULATION/SORT_VECTOR/a1-[autogen]/python_code.txt index e908201a23..147351de6d 100644 --- a/docs/nodes/TRANSFORMERS/VECTOR_MANIPULATION/SORT_VECTOR/a1-[autogen]/python_code.txt +++ b/docs/nodes/TRANSFORMERS/VECTOR_MANIPULATION/SORT_VECTOR/a1-[autogen]/python_code.txt @@ -4,7 +4,7 @@ from flojoy import flojoy, Vector @flojoy def SORT_VECTOR( default: Vector, + reverse: bool = False, ) -> Vector: - - return Vector(v=sorted(default.v)) + return Vector(v=sorted(default.v, reverse=reverse))