Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
145 changes: 145 additions & 0 deletions non_lewis_emulators/DAQmx/DAQmx Simulator.lvproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
<?xml version='1.0' encoding='UTF-8'?>
<Project Type="Project" LVVersion="18008000">
<Item Name="My Computer" Type="My Computer">
<Property Name="server.app.propertiesEnabled" Type="Bool">true</Property>
<Property Name="server.control.propertiesEnabled" Type="Bool">true</Property>
<Property Name="server.tcp.enabled" Type="Bool">false</Property>
<Property Name="server.tcp.port" Type="Int">0</Property>
<Property Name="server.tcp.serviceName" Type="Str">My Computer/VI Server</Property>
<Property Name="server.tcp.serviceName.default" Type="Str">My Computer/VI Server</Property>
<Property Name="server.vi.callsEnabled" Type="Bool">true</Property>
<Property Name="server.vi.propertiesEnabled" Type="Bool">true</Property>
<Property Name="specify.custom.address" Type="Bool">false</Property>
<Item Name="Start Simulation.vi" Type="VI" URL="../Start Simulation.vi"/>
<Item Name="Stop Simulation.vi" Type="VI" URL="../Stop Simulation.vi"/>
<Item Name="Dependencies" Type="Dependencies">
<Item Name="vi.lib" Type="Folder">
<Item Name="BuildHelpPath.vi" Type="VI" URL="/&lt;vilib&gt;/Utility/error.llb/BuildHelpPath.vi"/>
<Item Name="Check Special Tags.vi" Type="VI" URL="/&lt;vilib&gt;/Utility/error.llb/Check Special Tags.vi"/>
<Item Name="Clear Errors.vi" Type="VI" URL="/&lt;vilib&gt;/Utility/error.llb/Clear Errors.vi"/>
<Item Name="Convert property node font to graphics font.vi" Type="VI" URL="/&lt;vilib&gt;/Utility/error.llb/Convert property node font to graphics font.vi"/>
<Item Name="Details Display Dialog.vi" Type="VI" URL="/&lt;vilib&gt;/Utility/error.llb/Details Display Dialog.vi"/>
<Item Name="DialogType.ctl" Type="VI" URL="/&lt;vilib&gt;/Utility/error.llb/DialogType.ctl"/>
<Item Name="DialogTypeEnum.ctl" Type="VI" URL="/&lt;vilib&gt;/Utility/error.llb/DialogTypeEnum.ctl"/>
<Item Name="Error Cluster From Error Code.vi" Type="VI" URL="/&lt;vilib&gt;/Utility/error.llb/Error Cluster From Error Code.vi"/>
<Item Name="Error Code Database.vi" Type="VI" URL="/&lt;vilib&gt;/Utility/error.llb/Error Code Database.vi"/>
<Item Name="ErrWarn.ctl" Type="VI" URL="/&lt;vilib&gt;/Utility/error.llb/ErrWarn.ctl"/>
<Item Name="eventvkey.ctl" Type="VI" URL="/&lt;vilib&gt;/event_ctls.llb/eventvkey.ctl"/>
<Item Name="Find Tag.vi" Type="VI" URL="/&lt;vilib&gt;/Utility/error.llb/Find Tag.vi"/>
<Item Name="Format Message String.vi" Type="VI" URL="/&lt;vilib&gt;/Utility/error.llb/Format Message String.vi"/>
<Item Name="General Error Handler Core CORE.vi" Type="VI" URL="/&lt;vilib&gt;/Utility/error.llb/General Error Handler Core CORE.vi"/>
<Item Name="General Error Handler.vi" Type="VI" URL="/&lt;vilib&gt;/Utility/error.llb/General Error Handler.vi"/>
<Item Name="Get String Text Bounds.vi" Type="VI" URL="/&lt;vilib&gt;/Utility/error.llb/Get String Text Bounds.vi"/>
<Item Name="Get Text Rect.vi" Type="VI" URL="/&lt;vilib&gt;/picture/picture.llb/Get Text Rect.vi"/>
<Item Name="GetHelpDir.vi" Type="VI" URL="/&lt;vilib&gt;/Utility/error.llb/GetHelpDir.vi"/>
<Item Name="GetRTHostConnectedProp.vi" Type="VI" URL="/&lt;vilib&gt;/Utility/error.llb/GetRTHostConnectedProp.vi"/>
<Item Name="Longest Line Length in Pixels.vi" Type="VI" URL="/&lt;vilib&gt;/Utility/error.llb/Longest Line Length in Pixels.vi"/>
<Item Name="LVBoundsTypeDef.ctl" Type="VI" URL="/&lt;vilib&gt;/Utility/miscctls.llb/LVBoundsTypeDef.ctl"/>
<Item Name="LVRectTypeDef.ctl" Type="VI" URL="/&lt;vilib&gt;/Utility/miscctls.llb/LVRectTypeDef.ctl"/>
<Item Name="nisyscfg.lvlib" Type="Library" URL="/&lt;vilib&gt;/nisyscfg/nisyscfg.lvlib"/>
<Item Name="Not Found Dialog.vi" Type="VI" URL="/&lt;vilib&gt;/Utility/error.llb/Not Found Dialog.vi"/>
<Item Name="Search and Replace Pattern.vi" Type="VI" URL="/&lt;vilib&gt;/Utility/error.llb/Search and Replace Pattern.vi"/>
<Item Name="Set Bold Text.vi" Type="VI" URL="/&lt;vilib&gt;/Utility/error.llb/Set Bold Text.vi"/>
<Item Name="Set Busy.vi" Type="VI" URL="/&lt;vilib&gt;/Utility/cursorutil.llb/Set Busy.vi"/>
<Item Name="Set Cursor (Cursor ID).vi" Type="VI" URL="/&lt;vilib&gt;/Utility/cursorutil.llb/Set Cursor (Cursor ID).vi"/>
<Item Name="Set Cursor (Icon Pict).vi" Type="VI" URL="/&lt;vilib&gt;/Utility/cursorutil.llb/Set Cursor (Icon Pict).vi"/>
<Item Name="Set Cursor.vi" Type="VI" URL="/&lt;vilib&gt;/Utility/cursorutil.llb/Set Cursor.vi"/>
<Item Name="Set String Value.vi" Type="VI" URL="/&lt;vilib&gt;/Utility/error.llb/Set String Value.vi"/>
<Item Name="Simple Error Handler.vi" Type="VI" URL="/&lt;vilib&gt;/Utility/error.llb/Simple Error Handler.vi"/>
<Item Name="TagReturnType.ctl" Type="VI" URL="/&lt;vilib&gt;/Utility/error.llb/TagReturnType.ctl"/>
<Item Name="Three Button Dialog CORE.vi" Type="VI" URL="/&lt;vilib&gt;/Utility/error.llb/Three Button Dialog CORE.vi"/>
<Item Name="Three Button Dialog.vi" Type="VI" URL="/&lt;vilib&gt;/Utility/error.llb/Three Button Dialog.vi"/>
<Item Name="Trim Whitespace.vi" Type="VI" URL="/&lt;vilib&gt;/Utility/error.llb/Trim Whitespace.vi"/>
<Item Name="Unset Busy.vi" Type="VI" URL="/&lt;vilib&gt;/Utility/cursorutil.llb/Unset Busy.vi"/>
<Item Name="whitespace.ctl" Type="VI" URL="/&lt;vilib&gt;/Utility/error.llb/whitespace.ctl"/>
</Item>
<Item Name="nisyscfg.dll" Type="Document" URL="nisyscfg.dll">
<Property Name="NI.PreserveRelativePath" Type="Bool">true</Property>
</Item>
</Item>
<Item Name="Build Specifications" Type="Build">
<Item Name="start_sim" Type="EXE">
<Property Name="App_copyErrors" Type="Bool">true</Property>
<Property Name="App_INI_aliasGUID" Type="Str">{69F2EF67-3DA3-45C1-BA2E-E132CBEB4A58}</Property>
<Property Name="App_INI_GUID" Type="Str">{1D76DB6C-E20C-4B63-B069-9A5C6CDC62E2}</Property>
<Property Name="App_serverConfig.httpPort" Type="Int">8002</Property>
<Property Name="Bld_autoIncrement" Type="Bool">true</Property>
<Property Name="Bld_buildCacheID" Type="Str">{3032DD62-7160-4548-B049-55173DE6B4A9}</Property>
<Property Name="Bld_buildSpecName" Type="Str">start_sim</Property>
<Property Name="Bld_excludeInlineSubVIs" Type="Bool">true</Property>
<Property Name="Bld_excludeLibraryItems" Type="Bool">true</Property>
<Property Name="Bld_excludePolymorphicVIs" Type="Bool">true</Property>
<Property Name="Bld_localDestDir" Type="Path">..</Property>
<Property Name="Bld_localDestDirType" Type="Str">relativeToProject</Property>
<Property Name="Bld_modifyLibraryFile" Type="Bool">true</Property>
<Property Name="Bld_previewCacheID" Type="Str">{F0B1A97E-05A1-4165-8CC2-5A122E65528F}</Property>
<Property Name="Bld_version.build" Type="Int">7</Property>
<Property Name="Bld_version.major" Type="Int">1</Property>
<Property Name="Destination[0].destName" Type="Str">start_sim.exe</Property>
<Property Name="Destination[0].path" Type="Path">../start_sim.exe</Property>
<Property Name="Destination[0].path.type" Type="Str">relativeToProject</Property>
<Property Name="Destination[0].preserveHierarchy" Type="Bool">true</Property>
<Property Name="Destination[0].type" Type="Str">App</Property>
<Property Name="Destination[1].destName" Type="Str">Support Directory</Property>
<Property Name="Destination[1].path" Type="Path">../data</Property>
<Property Name="Destination[1].path.type" Type="Str">relativeToProject</Property>
<Property Name="DestinationCount" Type="Int">2</Property>
<Property Name="Source[0].itemID" Type="Str">{D10F49FF-FE2B-44E0-91F5-807434181978}</Property>
<Property Name="Source[0].type" Type="Str">Container</Property>
<Property Name="Source[1].destinationIndex" Type="Int">0</Property>
<Property Name="Source[1].itemID" Type="Ref">/My Computer/Start Simulation.vi</Property>
<Property Name="Source[1].sourceInclusion" Type="Str">TopLevel</Property>
<Property Name="Source[1].type" Type="Str">VI</Property>
<Property Name="SourceCount" Type="Int">2</Property>
<Property Name="TgtF_fileDescription" Type="Str">start_sim</Property>
<Property Name="TgtF_internalName" Type="Str">start_sim</Property>
<Property Name="TgtF_legalCopyright" Type="Str">Copyright © 2020 </Property>
<Property Name="TgtF_productName" Type="Str">start_sim</Property>
<Property Name="TgtF_targetfileGUID" Type="Str">{5D7A9BBA-CFE6-45F1-A59E-A3A2EC5EF395}</Property>
<Property Name="TgtF_targetfileName" Type="Str">start_sim.exe</Property>
<Property Name="TgtF_versionIndependent" Type="Bool">true</Property>
</Item>
<Item Name="stop_sim" Type="EXE">
<Property Name="App_copyErrors" Type="Bool">true</Property>
<Property Name="App_INI_aliasGUID" Type="Str">{751A720F-6D02-4840-B80C-6D60939D97D6}</Property>
<Property Name="App_INI_GUID" Type="Str">{63B57F8A-7612-4D44-860A-047372DA9F09}</Property>
<Property Name="App_serverConfig.httpPort" Type="Int">8002</Property>
<Property Name="Bld_autoIncrement" Type="Bool">true</Property>
<Property Name="Bld_buildCacheID" Type="Str">{0F8F3D15-0AEB-47C5-A77F-A726B09704B0}</Property>
<Property Name="Bld_buildSpecName" Type="Str">stop_sim</Property>
<Property Name="Bld_excludeInlineSubVIs" Type="Bool">true</Property>
<Property Name="Bld_excludeLibraryItems" Type="Bool">true</Property>
<Property Name="Bld_excludePolymorphicVIs" Type="Bool">true</Property>
<Property Name="Bld_localDestDir" Type="Path">..</Property>
<Property Name="Bld_localDestDirType" Type="Str">relativeToProject</Property>
<Property Name="Bld_modifyLibraryFile" Type="Bool">true</Property>
<Property Name="Bld_previewCacheID" Type="Str">{DA5770AA-28BD-4FD0-A8E9-1F88901DB54B}</Property>
<Property Name="Bld_version.build" Type="Int">5</Property>
<Property Name="Bld_version.major" Type="Int">1</Property>
<Property Name="Destination[0].destName" Type="Str">stop_sim.exe</Property>
<Property Name="Destination[0].path" Type="Path">../stop_sim.exe</Property>
<Property Name="Destination[0].path.type" Type="Str">relativeToProject</Property>
<Property Name="Destination[0].preserveHierarchy" Type="Bool">true</Property>
<Property Name="Destination[0].type" Type="Str">App</Property>
<Property Name="Destination[1].destName" Type="Str">Support Directory</Property>
<Property Name="Destination[1].path" Type="Path">../data</Property>
<Property Name="Destination[1].path.type" Type="Str">relativeToProject</Property>
<Property Name="DestinationCount" Type="Int">2</Property>
<Property Name="Source[0].itemID" Type="Str">{7A84589B-2BE2-4823-AE48-417668C448A6}</Property>
<Property Name="Source[0].type" Type="Str">Container</Property>
<Property Name="Source[1].destinationIndex" Type="Int">0</Property>
<Property Name="Source[1].itemID" Type="Ref">/My Computer/Stop Simulation.vi</Property>
<Property Name="Source[1].sourceInclusion" Type="Str">TopLevel</Property>
<Property Name="Source[1].type" Type="Str">VI</Property>
<Property Name="SourceCount" Type="Int">2</Property>
<Property Name="TgtF_fileDescription" Type="Str">stop_sim</Property>
<Property Name="TgtF_internalName" Type="Str">stop_sim</Property>
<Property Name="TgtF_legalCopyright" Type="Str">Copyright © 2020 </Property>
<Property Name="TgtF_productName" Type="Str">stop_sim</Property>
<Property Name="TgtF_targetfileGUID" Type="Str">{4E4CA661-26AA-4EA4-8C86-B7D38847B297}</Property>
<Property Name="TgtF_targetfileName" Type="Str">stop_sim.exe</Property>
<Property Name="TgtF_versionIndependent" Type="Bool">true</Property>
</Item>
</Item>
</Item>
</Project>
Binary file added non_lewis_emulators/DAQmx/SineWave.nce
Binary file not shown.
Binary file added non_lewis_emulators/DAQmx/Start Simulation.vi
Binary file not shown.
Binary file added non_lewis_emulators/DAQmx/Stop Simulation.vi
Binary file not shown.
3 changes: 3 additions & 0 deletions non_lewis_emulators/DAQmx/start_sim.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
setlocal
cd /d %~dp0
start /wait start_sim.exe
Binary file added non_lewis_emulators/DAQmx/start_sim.exe
Binary file not shown.
3 changes: 3 additions & 0 deletions non_lewis_emulators/DAQmx/stop_sim.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
setlocal
cd /d %~dp0
start /wait stop_sim.exe
Binary file added non_lewis_emulators/DAQmx/stop_sim.exe
Binary file not shown.
Empty file added non_lewis_emulators/__init__.py
Empty file.
Empty file.
98 changes: 98 additions & 0 deletions non_lewis_emulators/mezei_flipper/flipper_emulator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import argparse
import sys
import types

from mock import MagicMock


class _FakeQtCore(object):
@classmethod
def pyqtSignal(cls, *a, **k):

Check failure on line 10 in non_lewis_emulators/mezei_flipper/flipper_emulator.py

View workflow job for this annotation

GitHub Actions / call-workflow / ruff

Ruff (ANN003)

non_lewis_emulators/mezei_flipper/flipper_emulator.py:10:29: ANN003 Missing type annotation for `**k`

Check failure on line 10 in non_lewis_emulators/mezei_flipper/flipper_emulator.py

View workflow job for this annotation

GitHub Actions / call-workflow / ruff

Ruff (ANN002)

non_lewis_emulators/mezei_flipper/flipper_emulator.py:10:25: ANN002 Missing type annotation for `*a`

Check failure on line 10 in non_lewis_emulators/mezei_flipper/flipper_emulator.py

View workflow job for this annotation

GitHub Actions / call-workflow / ruff

Ruff (ANN206)

non_lewis_emulators/mezei_flipper/flipper_emulator.py:10:9: ANN206 Missing return type annotation for classmethod `pyqtSignal`

Check failure on line 10 in non_lewis_emulators/mezei_flipper/flipper_emulator.py

View workflow job for this annotation

GitHub Actions / call-workflow / ruff

Ruff (N802)

non_lewis_emulators/mezei_flipper/flipper_emulator.py:10:9: N802 Function name `pyqtSignal` should be lowercase
return None


class _fake_ui_flipper:

Check failure on line 14 in non_lewis_emulators/mezei_flipper/flipper_emulator.py

View workflow job for this annotation

GitHub Actions / call-workflow / ruff

Ruff (N801)

non_lewis_emulators/mezei_flipper/flipper_emulator.py:14:7: N801 Class name `_fake_ui_flipper` should use CapWords convention
def setupUi(self, *a, **k):

Check failure on line 15 in non_lewis_emulators/mezei_flipper/flipper_emulator.py

View workflow job for this annotation

GitHub Actions / call-workflow / ruff

Ruff (ANN003)

non_lewis_emulators/mezei_flipper/flipper_emulator.py:15:27: ANN003 Missing type annotation for `**k`

Check failure on line 15 in non_lewis_emulators/mezei_flipper/flipper_emulator.py

View workflow job for this annotation

GitHub Actions / call-workflow / ruff

Ruff (ANN002)

non_lewis_emulators/mezei_flipper/flipper_emulator.py:15:23: ANN002 Missing type annotation for `*a`

Check failure on line 15 in non_lewis_emulators/mezei_flipper/flipper_emulator.py

View workflow job for this annotation

GitHub Actions / call-workflow / ruff

Ruff (ANN202)

non_lewis_emulators/mezei_flipper/flipper_emulator.py:15:9: ANN202 Missing return type annotation for private function `setupUi`

Check failure on line 15 in non_lewis_emulators/mezei_flipper/flipper_emulator.py

View workflow job for this annotation

GitHub Actions / call-workflow / ruff

Ruff (N802)

non_lewis_emulators/mezei_flipper/flipper_emulator.py:15:9: N802 Function name `setupUi` should be lowercase
pass


fake_qt_module = types.ModuleType("PyQt5")
fake_qt_module.QtWidgets = MagicMock()
fake_qt_module.QtCore = _FakeQtCore
fake_qt_module.QtNetwork = MagicMock()
sys.modules["PyQt5"] = fake_qt_module

fake_qplot_module = types.ModuleType("QPlot")
fake_qplot_module.QPlot = MagicMock()
sys.modules["QPlot"] = fake_qplot_module

sys.modules["DAQTasks_2flippers"] = MagicMock()

fake_flippr_module = types.ModuleType("flippr_3")
fake_flippr_module.Ui_Flippr = _fake_ui_flipper
sys.modules["flippr_3"] = fake_flippr_module


class _UpdatedValue(object):
"""This class fake-implements the interface of pyqtsignal (emit()) and the "parent" object (value())"""

Check failure on line 37 in non_lewis_emulators/mezei_flipper/flipper_emulator.py

View workflow job for this annotation

GitHub Actions / call-workflow / ruff

Ruff (E501)

non_lewis_emulators/mezei_flipper/flipper_emulator.py:37:101: E501 Line too long (107 > 100)

def __init__(self, init_val):
self._val = init_val

def value(self):
return self._val

def emit(self, value):
self._val = value

def __str__(self):
return str(self._val)


class _Parent(object):
"""Fake "parent" object. I don't know what type this is meant to have, but all that it actually requires is some
member attributes which have a .value() method.
"""

def __init__(self):
self.comp_spin_P = _UpdatedValue(0)
self.comp_spin_A = _UpdatedValue(0)
self.amplitude_spin_P = _UpdatedValue(0)
self.amplitude_spin_A = _UpdatedValue(0)
self.decay_spin_P = _UpdatedValue(0)
self.decay_spin_A = _UpdatedValue(0)
self.DeltaT_P = _UpdatedValue(0)
self.DeltaT_A = _UpdatedValue(0)
self.filename_P = _UpdatedValue("C:\\file_p.txt")
self.filename_A = _UpdatedValue("C:\\file_a.txt")
self.running = _UpdatedValue(0)


from main_andy_2flippers import SignalServer

if __name__ == "__main__":
parser = argparse.ArgumentParser(
description="Test an IOC under emulation by running tests against it"
)
parser.add_argument("-p", "--port", type=int, help="The TCP port to run the server on.")
arguments = parser.parse_args()

parent = _Parent()

# We don't know what these objects are under the hood (we don't have that piece of code), so monkey-patch
# the mapping here.
SignalServer.toggle = parent.running
SignalServer.comp_p = parent.comp_spin_P
SignalServer.comp_a = parent.comp_spin_A
SignalServer.amp_p = parent.amplitude_spin_P
SignalServer.amp_a = parent.amplitude_spin_A
SignalServer.const_p = parent.decay_spin_P
SignalServer.const_a = parent.decay_spin_A
SignalServer.dt_a = parent.DeltaT_A
SignalServer.dt_p = parent.DeltaT_P
SignalServer.fn_p = parent.filename_P
SignalServer.fn_a = parent.filename_A

server = SignalServer("localhost", arguments.port, parent)

server.listen()
Loading
Loading