From 4eb862408081a48bf127a0eb251266592c1cf9c2 Mon Sep 17 00:00:00 2001 From: NI-velmurugan Date: Wed, 7 Oct 2026 19:45:14 +0530 Subject: [PATCH 1/3] Add @Avinash2Suresh as a code owner --- .github/CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 17a4e6de4d..dac883d426 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1 +1 @@ -* @marcoskirsch @ni-jfitzger @vnktshr21 +* @marcoskirsch @ni-jfitzger @vnktshr21 @Avinash2Suresh From 8305ba26e923b280a766b480f52f77b1170c6fcd Mon Sep 17 00:00:00 2001 From: Divakar Date: Thu, 8 Oct 2026 16:17:45 +0530 Subject: [PATCH 2/3] Remove @Avinash2Suresh from CODEOWNERS --- .github/CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index dac883d426..17a4e6de4d 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1 +1 @@ -* @marcoskirsch @ni-jfitzger @vnktshr21 @Avinash2Suresh +* @marcoskirsch @ni-jfitzger @vnktshr21 From 5ef93fcbe6068f776b0a5e7b29decda5be74c03c Mon Sep 17 00:00:00 2001 From: "Selvam, Divakar" Date: Tue, 27 Oct 2026 15:18:58 +0530 Subject: [PATCH 3/3] add: add Function Generator example in FGEN --- CHANGELOG.md | 1 + docs/nifgen/examples.rst | 9 ++++ .../examples/nifgen_function_generator.py | 50 +++++++++++++++++++ 3 files changed, 60 insertions(+) create mode 100644 src/nifgen/examples/nifgen_function_generator.py diff --git a/CHANGELOG.md b/CHANGELOG.md index cfa7540d47..7f704467a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1128,6 +1128,7 @@ #### [nifgen] Unreleased - Added - (Common) Added `nitlsconfig[grpc]>=1.0.0a2` to the optional gRPC dependencies. + - Added the `nifgen_function_generator.py` example. - Changed - Removed diff --git a/docs/nifgen/examples.rst b/docs/nifgen/examples.rst index 3731f4bea5..f23a0aa548 100644 --- a/docs/nifgen/examples.rst +++ b/docs/nifgen/examples.rst @@ -12,6 +12,15 @@ nifgen_arb_waveform.py :encoding: utf8 :caption: `(nifgen_arb_waveform.py) `_ +nifgen_function_generator.py +---------------------------- + +.. literalinclude:: ../../src/nifgen/examples/nifgen_function_generator.py + :language: python + :linenos: + :encoding: utf8 + :caption: `(nifgen_function_generator.py) `_ + nifgen_script.py ---------------- diff --git a/src/nifgen/examples/nifgen_function_generator.py b/src/nifgen/examples/nifgen_function_generator.py new file mode 100644 index 0000000000..1f9e84331c --- /dev/null +++ b/src/nifgen/examples/nifgen_function_generator.py @@ -0,0 +1,50 @@ +#!/usr/bin/python + +import argparse +import nifgen +import sys +import time + + +def example(resource_name, options, waveform, amplitude, frequency, offset, phase, gen_time): + with nifgen.Session(resource_name=resource_name, channel_name='0', options=options) as session: + session.output_mode = nifgen.OutputMode.FUNC + session.configure_standard_waveform(waveform=nifgen.Waveform[waveform], amplitude=amplitude, frequency=frequency, dc_offset=offset, start_phase=phase) + session.output_enabled = True + with session.initiate(): + print('Generating {} waveform for {} seconds:'.format(waveform, gen_time)) + print(' Frequency: {} Hz, amplitude: {} Vpk-pk, DC offset: {} V, start phase: {} degrees'.format(frequency, amplitude, offset, phase)) + time.sleep(gen_time) + + +def _main(argsv): + supported_waveforms = list(nifgen.Waveform.__members__.keys())[:-1] # no support for user-defined waveforms in example + parser = argparse.ArgumentParser(description='Generates a standard function waveform.', formatter_class=argparse.ArgumentDefaultsHelpFormatter) + parser.add_argument('-n', '--resource-name', default='PXI1Slot2', help='Specifies the NI-FGEN resource name or alias to initialize.') + parser.add_argument('-w', '--waveform', default=supported_waveforms[0], choices=supported_waveforms, type=str.upper, help='Specifies the standard waveform shape to generate, such as SINE or SQUARE.') + parser.add_argument('-a', '--amplitude', default=1.0, type=float, help='Specifies the peak-to-peak output amplitude in volts.') + parser.add_argument('-f', '--frequency', default=1000000, type=float, help='Specifies the output frequency of the waveform in hertz.') + parser.add_argument('-o', '--offset', default=0.0, type=float, help='Specifies the DC voltage offset applied to the waveform.') + parser.add_argument('-p', '--phase', default=0.0, type=float, help='Specifies the starting phase angle of the waveform in degrees.') + parser.add_argument('-t', '--time', default=5.0, type=float, help='Specifies how long to generate the waveform before stopping, in seconds.') + parser.add_argument('-op', '--option-string', default='', type=str, help='Specifies NI-FGEN initialization options, such as simulation and driver setup.') + args = parser.parse_args(argsv) + example(args.resource_name, args.option_string, args.waveform, args.amplitude, args.frequency, args.offset, args.phase, args.time) + + +def main(): + _main(sys.argv[1:]) + + +def test_example(): + options = {'simulate': True, 'driver_setup': {'Model': '5433 (2CH)', 'BoardType': 'PXIe', }, } + example('PXI1Slot2', options, 'SINE', 1.0, 1000000, 0.0, 0.0, 0.1) + + +def test_main(): + cmd_line = ['--option-string', 'Simulate=1, DriverSetup=Model:5433 (2CH);BoardType:PXIe', '--time', '0.1', ] + _main(cmd_line) + + +if __name__ == '__main__': + main()