Skip to content

Commit

Permalink
replace fielddaq with cdaq in tests (#513)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhindes authored Feb 21, 2024
1 parent a7a3643 commit 0905e65
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 33 deletions.
4 changes: 2 additions & 2 deletions tests/component/_task_modules/test_triggers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@


@pytest.fixture()
def ai_voltage_field_daq_task(task, sim_field_daq_device):
def ai_voltage_field_daq_task(task, sim_time_aware_9215_device):
"""Gets AI voltage task."""
task.ai_channels.add_ai_voltage_chan(sim_field_daq_device.ai_physical_chans[0].name)
task.ai_channels.add_ai_voltage_chan(sim_time_aware_9215_device.ai_physical_chans[0].name)
yield task


Expand Down
4 changes: 2 additions & 2 deletions tests/component/_task_modules/test_triggers_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ def ai_voltage_task(task, sim_6363_device):


@pytest.fixture()
def ai_voltage_field_daq_task(task, sim_field_daq_device):
def ai_voltage_field_daq_task(task, sim_time_aware_9215_device):
"""Gets AI voltage task."""
task.ai_channels.add_ai_voltage_chan(sim_field_daq_device.ai_physical_chans[0].name)
task.ai_channels.add_ai_voltage_chan(sim_time_aware_9215_device.ai_physical_chans[0].name)
yield task


Expand Down
32 changes: 25 additions & 7 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,13 @@ def _x_series_device(


def _device_by_product_type(
product_type, device_type: DeviceType, system: nidaqmx.system.System
product_type: str, device_type: DeviceType, system: nidaqmx.system.System
) -> nidaqmx.system.Device:
for device in system.devices:
device_type_match = (
device_type == DeviceType.ANY
or (device_type == DeviceType.REAL and not device.is_simulated)
or (device_type == DeviceType.SIMULATED and device.is_simulated)
and len(device.ai_physical_chans) >= 1
)
if device_type_match and device.product_type == product_type:
return device
Expand All @@ -133,7 +132,20 @@ def _device_by_product_type(
f"{device_type}. Cannot proceed to run tests. Import the NI MAX configuration file located "
"at nidaqmx\\tests\\max_config\\nidaqmxMaxConfig.ini to create these devices."
)
return None


def _cdaq_module_by_product_type(
product_type: str, cdaq_chassis: nidaqmx.system.Device
) -> nidaqmx.system.Device:
for module in cdaq_chassis.chassis_module_devices:
if module.product_type == product_type:
return module

pytest.skip(
f"Could not detect a {product_type} device within {cdaq_chassis.name}. "
"Cannot proceed to run tests. Import the NI MAX configuration file located at "
"nidaqmx\\tests\\max_config\\nidaqmxMaxConfig.ini to create these devices."
)


@pytest.fixture(scope="function")
Expand All @@ -144,14 +156,20 @@ def real_x_series_device(system: nidaqmx.system.System) -> nidaqmx.system.Device

@pytest.fixture(scope="function")
def sim_6363_device(system: nidaqmx.system.System) -> nidaqmx.system.Device:
"""Gets a simulated 6363."""
"""Gets simulated 6363 device information."""
return _device_by_product_type("PCIe-6363", DeviceType.SIMULATED, system)


@pytest.fixture(scope="function")
def sim_field_daq_device(system):
"""Gets simulated Field DAQ device information."""
return _device_by_product_type("FD-11601", DeviceType.SIMULATED, system)
def sim_9185_device(system: nidaqmx.system.System) -> nidaqmx.system.Device:
"""Gets simulated 9185 device information."""
return _device_by_product_type("cDAQ-9185", DeviceType.SIMULATED, system)


@pytest.fixture(scope="function")
def sim_time_aware_9215_device(sim_9185_device: nidaqmx.system.Device) -> nidaqmx.system.Device:
"""Gets device information for a simulated 9215 device within a 9185."""
return _cdaq_module_by_product_type("NI 9215", sim_9185_device)


@pytest.fixture(scope="function")
Expand Down
26 changes: 4 additions & 22 deletions tests/max_config/nidaqmxMaxConfig.ini
Original file line number Diff line number Diff line change
Expand Up @@ -257,27 +257,9 @@ DevIsSimulated = 1
CompactDAQ.ChassisDevName = cdaqChassisTester
CompactDAQ.SlotNum = 1

[DAQmxFieldDAQ FieldDAQ1]
ProductType = FD-11601
[DAQmxCDAQModule cdaqTesterMod2]
ProductType = NI 9215
DevSerialNum = 0x0
DevIsSimulated = 1
BusType = TCP/IP
TCPIP.Hostname =
TCPIP.EthernetIP = 0.0.0.0
TCPIP.EthernetMAC = 00:00:00:00:00:00
TCPIP.EthernetMDNSServiceInstance =
TCPIP.DevIsReserved = 0

[DAQmxFieldDAQBank FieldDAQ1-Bank1]
ProductType = FD-11601
DevSerialNum = 0x0
DevIsSimulated = 1
FieldDAQ.BankNum = 1
FieldDAQ.DevName = FieldDAQ1

[DAQmxFieldDAQBank FieldDAQ1-Bank2]
ProductType = FD-11601
DevSerialNum = 0x0
DevIsSimulated = 1
FieldDAQ.BankNum = 2
FieldDAQ.DevName = FieldDAQ1
CompactDAQ.ChassisDevName = cdaqChassisTester
CompactDAQ.SlotNum = 2

0 comments on commit 0905e65

Please sign in to comment.