From 366faf039c770726f58c9358aa050a87f01952eb Mon Sep 17 00:00:00 2001 From: "Hood, Jonathan D" Date: Mon, 8 Feb 2021 17:18:11 -0500 Subject: [PATCH] tested picomotor artiq driver --- Andor/andorv1.0/andor/aqctl_andor.py | 3 +- .../picomotor_driver.cpython-38.pyc | Bin 3616 -> 0 bytes Picomotor/picomotor-master/.gitignore | 2 - .../Picomotor Control-GUI.ipynb | 380 ------------------ .../picomotor-master/Picomotor Control.ipynb | 379 ----------------- Picomotor/picomotor-master/README.md | 6 - Picomotor/picomotor-master/picomotor.py | 116 ------ .../build/lib/picomotor/__init__.py | 0 .../build/lib/picomotor/aqctl_picomotor.py | 52 +++ .../build/lib/picomotor}/picomotor_driver.py | 0 picomotor_repo/dist/picomotor-0.0.0-py3.8.egg | Bin 0 -> 7282 bytes picomotor_repo/doc/Makefile | 19 + picomotor_repo/doc/conf.py | 176 ++++++++ picomotor_repo/doc/index.rst | 24 ++ picomotor_repo/picomotor.egg-info/PKG-INFO | 10 + picomotor_repo/picomotor.egg-info/SOURCES.txt | 9 + .../picomotor.egg-info/dependency_links.txt | 1 + .../picomotor.egg-info/entry_points.txt | 3 + .../picomotor.egg-info/top_level.txt | 1 + picomotor_repo/picomotor/__init__.py | 2 + .../__pycache__/__init__.cpython-38.pyc | Bin 0 -> 259 bytes .../aqctl_picomotor.cpython-38.pyc | Bin 0 -> 1688 bytes .../picomotor_driver.cpython-38.pyc | Bin 0 -> 3684 bytes picomotor_repo/picomotor/aqctl_picomotor.py | 52 +++ picomotor_repo/picomotor/picomotor_driver.py | 134 ++++++ picomotor_repo/setup.py | 12 + .../testing}/test_driver.py | 0 .../testing}/testing.py | 0 28 files changed, 496 insertions(+), 885 deletions(-) delete mode 100644 Picomotor/__pycache__/picomotor_driver.cpython-38.pyc delete mode 100644 Picomotor/picomotor-master/.gitignore delete mode 100644 Picomotor/picomotor-master/Picomotor Control-GUI.ipynb delete mode 100644 Picomotor/picomotor-master/Picomotor Control.ipynb delete mode 100644 Picomotor/picomotor-master/README.md delete mode 100644 Picomotor/picomotor-master/picomotor.py create mode 100644 picomotor_repo/build/lib/picomotor/__init__.py create mode 100644 picomotor_repo/build/lib/picomotor/aqctl_picomotor.py rename {Picomotor => picomotor_repo/build/lib/picomotor}/picomotor_driver.py (100%) create mode 100644 picomotor_repo/dist/picomotor-0.0.0-py3.8.egg create mode 100644 picomotor_repo/doc/Makefile create mode 100644 picomotor_repo/doc/conf.py create mode 100644 picomotor_repo/doc/index.rst create mode 100644 picomotor_repo/picomotor.egg-info/PKG-INFO create mode 100644 picomotor_repo/picomotor.egg-info/SOURCES.txt create mode 100644 picomotor_repo/picomotor.egg-info/dependency_links.txt create mode 100644 picomotor_repo/picomotor.egg-info/entry_points.txt create mode 100644 picomotor_repo/picomotor.egg-info/top_level.txt create mode 100644 picomotor_repo/picomotor/__init__.py create mode 100644 picomotor_repo/picomotor/__pycache__/__init__.cpython-38.pyc create mode 100644 picomotor_repo/picomotor/__pycache__/aqctl_picomotor.cpython-38.pyc create mode 100644 picomotor_repo/picomotor/__pycache__/picomotor_driver.cpython-38.pyc create mode 100644 picomotor_repo/picomotor/aqctl_picomotor.py create mode 100644 picomotor_repo/picomotor/picomotor_driver.py create mode 100644 picomotor_repo/setup.py rename {Picomotor => picomotor_repo/testing}/test_driver.py (100%) rename {Picomotor => picomotor_repo/testing}/testing.py (100%) diff --git a/Andor/andorv1.0/andor/aqctl_andor.py b/Andor/andorv1.0/andor/aqctl_andor.py index d516a79..4c3a96e 100644 --- a/Andor/andorv1.0/andor/aqctl_andor.py +++ b/Andor/andorv1.0/andor/aqctl_andor.py @@ -8,8 +8,7 @@ import os import asyncio -#from andor.driver import andor -from driver import andor +from andor.driver import andor from sipyco.pc_rpc import simple_server_loop from sipyco import common_args diff --git a/Picomotor/__pycache__/picomotor_driver.cpython-38.pyc b/Picomotor/__pycache__/picomotor_driver.cpython-38.pyc deleted file mode 100644 index 72d62ab466ffb9245c6ea9a60b103245cdb765ed..0000000000000000000000000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g- zJFG}u(|r}{L(L^8$tgIantduB#Loi&-D#(YbP@Ht+kq1C4!D^1d&#^I56eInD;rn9 z#oa=2Wo09qUb@#>d%VoCT))4zbm!6SFN7vsRxi45-FqZxO6^#4 zV`9$A>Uv9L{8O>}hnaue{Wg2K+-gp#^8hS25&OBV;(jD^v%Q_DGw9W>$t~i2ZYP}} z=;igjHUb|h!|UQun5{i+5i6mR2E8PAp9h`T57R+zApovwxuE5ume7ZOc|rU%8o5!U(!4?(j6^>Pz)OX!mkNLHW8dEsGE91HFe(fZ?N21Lx}Jk1-Mjj51>CjNA`M<6L0L36 zafPCnIH^uhhf}Nq4hQ?`TPUcXLE{;IB>x(45eD$2c-jqe=e^jL3snF|s-F2zP~wM9Jkbl0rQoGl*?(xi_!v21lHy7wE{I zGe>A0S9!;|V{^zoWX_?XAD;Sc@)W_0D~^$Q4IuULK{pdkUx?SAzb5>an^8{^Mhl#=iGYrT(w@U zyH(e6ZP!+$i+>|3o+o49^9oQF(V5%0_3?7#QBNx!+eBbk=>T_c6i52ZKv&{ISSCFx GUF&}qs%Jj{ diff --git a/Picomotor/picomotor-master/.gitignore b/Picomotor/picomotor-master/.gitignore deleted file mode 100644 index eeb514c..0000000 --- a/Picomotor/picomotor-master/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -__pycache__ -.ipynb_checkpoints diff --git a/Picomotor/picomotor-master/Picomotor Control-GUI.ipynb b/Picomotor/picomotor-master/Picomotor Control-GUI.ipynb deleted file mode 100644 index 717e2db..0000000 --- a/Picomotor/picomotor-master/Picomotor Control-GUI.ipynb +++ /dev/null @@ -1,380 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Control Motor" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "ExecuteTime": { - "end_time": "2017-04-05T09:16:26.120393Z", - "start_time": "2017-04-05T09:16:26.063809" - }, - "collapsed": true - }, - "outputs": [], - "source": [ - "from picomotor import MSerial" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "m = MSerial('COM11', echo=True, wait=0.1)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "ExecuteTime": { - "end_time": "2017-04-05T00:11:32.689144Z", - "start_time": "2017-04-05T00:11:32.679622" - }, - "collapsed": true - }, - "outputs": [], - "source": [ - "m.echo = False" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print(m.status_msg())" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "m.unit" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "donor_unit = dict(x=787, y=588, detector='donor')\n", - "accept_unit = dict(x=625, y=641, detector='acceptor')" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "m.unit = donor_unit" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "m.unit" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "m.unit = accept_unit" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "m.unit" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "vel, acc = 500, 10000\n", - "settings = [\n", - " 'acc a1 0=%d' % acc,\n", - " 'acc a1 1=%d' % acc,\n", - " 'vel a1 0=%d' % vel,\n", - " 'vel a1 1=%d' % vel, \n", - "]\n", - "for s in settings:\n", - " m.serial.flush()\n", - " print(m.sendrecv(s))" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "m.sendrecv('vel')\n", - "m.sendrecv('acc')" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "collapsed": true - }, - "source": [ - "# GUI" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "ExecuteTime": { - "end_time": "2017-04-04T22:36:26.442756Z", - "start_time": "2017-04-04T22:36:26.435364" - } - }, - "outputs": [], - "source": [ - "from IPython.display import display, Javascript\n", - "from ipywidgets import interact, interactive, fixed, interact_manual, Layout, HBox, VBox, Box, Label\n", - "import ipywidgets as widgets\n", - "widgets.__version__" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "ExecuteTime": { - "end_time": "2017-04-05T00:10:23.067393Z", - "start_time": "2017-04-05T00:10:22.857938" - } - }, - "outputs": [], - "source": [ - "items_base = dict(width='auto', height='40px', margin='6px')\n", - "items_layout = Layout(flex='1 1 auto', **items_base)\n", - "\n", - "detector = widgets.ToggleButton(description=\"Donor\", value=True, button_style='success',\n", - " layout=items_layout)\n", - "axis = widgets.ToggleButtons(\n", - " options=['X', 'Y'],\n", - " value='X',\n", - " description='Axis:',\n", - " disabled=False,\n", - " layout=Layout(flex='1 0 auto', height='auto', margin='5px'),\n", - ")\n", - "delta_wid = widgets.BoundedFloatText(description='Delta:', layout=items_layout)\n", - "movebutton = widgets.Button(description=\"Move!\", layout=items_layout)\n", - "out = widgets.Textarea(\n", - " value='',\n", - " description='Received:',\n", - " layout=Layout(flex='1 1 auto'),\n", - ")\n", - "\n", - "port = HBox([Label('Port:',\n", - " layout=Layout(flex='1 1 auto', width='6em', height='auto', margin='5px')), \n", - " widgets.Text(\n", - " value='COM11',\n", - " description='',\n", - " disabled=False,\n", - " layout=Layout(flex='1 1 auto', width='6em', height='auto', margin='5px'))]\n", - " )\n", - "connect = widgets.Button(description=\"Connect\", layout=items_layout)\n", - "status = widgets.Button(description=\"Check Status\", layout=items_layout)\n", - "status.button_style = 'info'\n", - "\n", - "vb_layout = Layout(flex='1 1 auto')\n", - "vbox = VBox([detector, axis, delta_wid, movebutton], layout=vb_layout)\n", - "\n", - "vba_layout = Layout(flex='1 1 auto', justify_content='space-between')\n", - "vboxa = VBox([port, connect, status], layout=vba_layout)\n", - "\n", - "ctrls = HBox([vboxa, vbox], layout=Layout(flex='1 0 auto'))\n", - "recv = widgets.Text(\n", - " value='',\n", - " description='Received:',\n", - " layout=Layout(flex='1 1 auto', width='95%'),\n", - ")\n", - "sent = widgets.Text(\n", - " value='',\n", - " description='Sent:',\n", - " layout=Layout(flex='1 1 auto', width='95%'),\n", - ")\n", - "sentrecv = VBox([sent, recv])\n", - "main = VBox([ctrls, recv])\n", - "tab = widgets.Tab(children=[vboxa, vbox])\n", - "tab.set_title(0, 'Configure')\n", - "tab.set_title(1, 'Move')\n", - "VBox([tab, sentrecv],\n", - " layout=Layout(overflow_x='scroll', max_width='45em', \n", - " flex='1 1 auto', ))#border='solid'))" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "ExecuteTime": { - "end_time": "2017-04-05T00:10:23.505156Z", - "start_time": "2017-04-05T00:10:23.501027" - }, - "collapsed": true - }, - "outputs": [], - "source": [ - "js_dialog_code = \"\"\"require(\n", - " [\"base/js/dialog\"], \n", - " function(dialog) {\n", - " dialog.modal({\n", - " title: 'Driver Connection',\n", - " body: 'Please check that driver is connected to the %s detector!',\n", - " buttons: {\n", - " 'OK': {}\n", - " }\n", - " });\n", - " }\n", - ");\"\"\"" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "ExecuteTime": { - "end_time": "2017-04-05T00:10:24.236336Z", - "start_time": "2017-04-05T00:10:24.227961" - } - }, - "outputs": [], - "source": [ - "def on_button_clicked(b):\n", - " if b['new']:\n", - " b['owner'].button_style = 'success'\n", - " b['owner'].description = 'Donor'\n", - " m.unit = donor_unit\n", - " else:\n", - " b['owner'].button_style = 'danger'\n", - " b['owner'].description = 'Acceptor'\n", - " m.unit = accept_unit\n", - " display(Javascript(js_dialog_code % b['owner'].description))\n", - "detector.observe(on_button_clicked, names='value')\n", - "\n", - "def on_move(b):\n", - " m.move(delta_wid.value, axis=axis.value.lower(), vel=200, acc=1000)\n", - "movebutton.on_click(on_move)\n", - "\n", - "def on_checkstatus(b):\n", - " m.status_msg()\n", - "status.on_click(on_checkstatus)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "m.sendwidget = sent\n", - "m.recvwidget = recv\n", - "m.echo = True" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "m.move(1, axis='x', vel=200, acc=1000)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [] - } - ], - "metadata": { - "anaconda-cloud": {}, - "hide_input": false, - "kernelspec": { - "display_name": "Python [default]", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.5.1" - }, - "nav_menu": {}, - "toc": { - "navigate_menu": true, - "number_sections": false, - "sideBar": true, - "threshold": 4, - "toc_cell": false, - "toc_section_display": "block", - "toc_window_display": false - }, - "widgets": { - "state": { - "e2e0008a58f84eec8ff65e7a4b08c54c": { - "views": [ - { - "cell_index": 1 - } - ] - } - }, - "version": "1.2.0" - } - }, - "nbformat": 4, - "nbformat_minor": 1 -} diff --git a/Picomotor/picomotor-master/Picomotor Control.ipynb b/Picomotor/picomotor-master/Picomotor Control.ipynb deleted file mode 100644 index 46d0729..0000000 --- a/Picomotor/picomotor-master/Picomotor Control.ipynb +++ /dev/null @@ -1,379 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "ExecuteTime": { - "end_time": "2017-04-05T09:16:26.120393Z", - "start_time": "2017-04-05T09:16:26.063809" - } - }, - "outputs": [], - "source": [ - "from picomotor import MSerial" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "m = MSerial('COM11', echo=True, wait=0.1)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "m.echo = True" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "r = m.status()\n", - "r" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "m.unit" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "donor_unit = dict(x=787, y=588, detector='donor')\n", - "accept_unit = dict(x=625, y=641, detector='acceptor')" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "m.unit = donor_unit" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "m.unit" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "m.unit = accept_unit" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "m.unit" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "# m.serial.close()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "# m.echo = True\n", - "# m.wait = 0.1" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "vel, acc = 500, 10000\n", - "settings = [\n", - " 'acc a1 0=%d' % acc,\n", - " 'acc a1 1=%d' % acc,\n", - " 'vel a1 0=%d' % vel,\n", - " 'vel a1 1=%d' % vel, \n", - "]\n", - "for s in settings:\n", - " m.serial.flush()\n", - " print(m.sendrecv(s))" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "m.sendrecv('vel')\n", - "m.sendrecv('acc')" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "m.joystick_enable(True)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "m.joystick_enable(False)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "m.unit = donor_unit" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "m.unit = accept_unit" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "scrolled": false - }, - "outputs": [], - "source": [ - "m.move(0.04, axis='x', vel=200, acc=1000)\n", - "m.unit" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "scrolled": false - }, - "outputs": [], - "source": [ - "m.move(0.21, axis='y', vel=200, acc=1000)\n", - "m.unit" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "m.halt()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true, - "scrolled": false - }, - "outputs": [], - "source": [ - "steps, vel, acc = 1000, 1000, 10000\n", - "for ax in ('x', 'y'):\n", - " for s in (steps, -steps):\n", - " m.move(s, axis=ax, vel=vel, acc=acc)\n", - " while m.is_moving():\n", - " time.sleep(0.05)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true, - "scrolled": false - }, - "outputs": [], - "source": [ - "m.move(1000, axis='x', vel=200, acc=1000)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "m.halt()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "m.sendrecv('POS')" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "m.sendrecv('SAV')" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "m.sendrecv('INI')" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [] - } - ], - "metadata": { - "anaconda-cloud": {}, - "hide_input": false, - "kernelspec": { - "display_name": "Python [default]", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.5.2" - }, - "nav_menu": {}, - "toc": { - "colors": { - "hover_highlight": "#DAA520", - "running_highlight": "#FF0000", - "selected_highlight": "#FFD700" - }, - "moveMenuLeft": true, - "nav_menu": { - "height": "12px", - "width": "252px" - }, - "navigate_menu": true, - "number_sections": true, - "sideBar": true, - "threshold": 4, - "toc_cell": false, - "toc_section_display": "block", - "toc_window_display": false, - "widenNotebook": false - } - }, - "nbformat": 4, - "nbformat_minor": 1 -} diff --git a/Picomotor/picomotor-master/README.md b/Picomotor/picomotor-master/README.md deleted file mode 100644 index 22825af..0000000 --- a/Picomotor/picomotor-master/README.md +++ /dev/null @@ -1,6 +0,0 @@ -# picomotor - -Software to control, via a serial port, one or more [Newport actuators 8302](https://www.newport.com/p/8302) (micropositioners) -using the open-loop controller 8752 and the ethernet controller 8753. - -Reference: [87XX_Manual_RevC.pdf](https://github.com/tritemio/picomotor/files/1039338/87XX_Manual_RevC.pdf) diff --git a/Picomotor/picomotor-master/picomotor.py b/Picomotor/picomotor-master/picomotor.py deleted file mode 100644 index 60a3a1d..0000000 --- a/Picomotor/picomotor-master/picomotor.py +++ /dev/null @@ -1,116 +0,0 @@ -""" -Library to control the picomotor driver. -""" - -import serial, time - - -class MSerial: - axis_names = dict(x=0, y=1) - unit = dict(x=1, y=1) - - def __init__(self, port, echo=True, max_retry=2, wait=0.1, sendwidget=None, recvwidget=None, **serial_kws): - kws = dict(baudrate=19200, bytesize=serial.EIGHTBITS, - parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, - timeout=0, xonxoff=True, rtscts=False, dsrdtr=False) - kws.update(serial_kws) - self.serial = serial.Serial(port, **kws) - self.echo = echo - self.wait = wait - self.sendwidget = sendwidget - self.recvwidget = recvwidget - - def send(self, cmd): - """Send a command to the picomotor driver.""" - line = cmd + '\r\n' - retval = self.serial.write(bytes(line, encoding='ascii')) - self.serial.flush() - if self.echo: - self.log(cmd, widget=self.sendwidget) - return retval - - def readlines(self): - """Read response from picomotor driver.""" - return ''.join([l.decode('ASCII') for l in self.serial.readlines()]) - - def log(self, msg, widget=None): - if widget is None: - print(msg, flush=True) - else: - widget.value = msg - - def sendrecv(self, cmd): - """Send a command and (optionally) printing the picomotor driver's response.""" - res = self.send(cmd) - if self.echo: - time.sleep(self.wait) - ret_str = self.readlines() - self.log(ret_str, widget=self.recvwidget) - return res - - def set_axis(self, axis, vel=None, acc=None, driver='a1'): - """Set current axis ('x' or 'y') and (optionally) its velocity.""" - assert axis in self.axis_names - fmt = dict(driver=driver, axis=self.axis_names[axis]) - basecmd = '{cmd} {driver} {axis}={value}' - if acc is not None: - assert 0 < acc <= 32000, 'Acceleration out of range (1..32000).' - cmd = basecmd.format(cmd='ACC', value=acc, **fmt) - self.sendrecv(cmd) - if vel is not None: - assert 0 < vel <= 2000, 'Velocity out of range (1..2000).' - cmd = basecmd.format(cmd='VEL', value=vel, **fmt) - self.sendrecv(cmd) - cmd = 'chl {driver}={axis}'.format(**fmt) - return self.sendrecv(cmd) - - def move_steps(self, steps, axis, vel=None, acc=None, driver='a1', go=True): - """Send command to move `axis` of the given `steps`.""" - self.set_axis(axis, vel=vel, acc=acc, driver=driver) - cmd = 'rel {driver}={steps}'.format(driver=driver, steps=steps) - if go: - cmd = cmd + ' g' - return self.sendrecv(cmd) - - def move(self, units, axis, vel=None, acc=None, driver='a1', go=True): - """Send command to move `axis` of the given `units`. - Uses self.unit for conversion. - """ - steps = round(units * self.unit[axis]) - return self.move_steps(steps, axis, vel=None, acc=None, driver='a1', go=True) - - def go(self): - """Send 'go' command to execute all previously sent move commands.""" - return self.sendrecv('go') - - def halt(self): - """Send 'HAL' command to stop motion with deceleration.""" - return self.sendrecv('hal') - - def joystick_enable(self, enable=True): - """Enable or disable the joystick.""" - cmd = 'JON' if enable else 'JOF' - return self.sendrecv(cmd) - - def status_msg(self): - """Return the driver status byte as an integer (see manual pag. 185).""" - self.send('STA') - time.sleep(self.wait) - ret_str = self.readlines() - if self.echo: - self.log(repr(ret_str), widget=self.recvwidget) - return ret_str - - def status(self): - ret_str = self.status_msg() - i = ret_str.find('A1=') - if i >= 0: - status = int(ret_str[i+5:i+7], 16) - else: - raise IOError("Received: '%s'" % ret_str) - return status - - def is_moving(self): - """Return True if motor is moving, else False.""" - status = self.status() - return status & 0x01 \ No newline at end of file diff --git a/picomotor_repo/build/lib/picomotor/__init__.py b/picomotor_repo/build/lib/picomotor/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/picomotor_repo/build/lib/picomotor/aqctl_picomotor.py b/picomotor_repo/build/lib/picomotor/aqctl_picomotor.py new file mode 100644 index 0000000..c571b62 --- /dev/null +++ b/picomotor_repo/build/lib/picomotor/aqctl_picomotor.py @@ -0,0 +1,52 @@ +import argparse +import logging +import sys +import os +import asyncio + +from picomotor_driver import picomotor +from sipyco.pc_rpc import simple_server_loop +from sipyco import common_args + +logger = logging.getLogger(__name__) + +def get_argparser(): + parser = argparse.ArgumentParser( + description="ARTIQ controller for the picomotor") + common_args.simple_network_args(parser, 3210) + parser.add_argument( + "-d", "--device", default=None, + help="serial port.") + parser.add_argument( + "--softtrig", default=False, action="store_true", + help="Sets trigger to software. Default is hardware") + parser.add_argument( + "--num", default=1, + help="Sets number of images. Default is hardware") + parser.add_argument( + "--simulation", action="store_true", + help="Put the driver in simulation mode, even if --device is used.") + common_args.verbosity_args(parser) + return parser + +def main(): + args = get_argparser().parse_args() + common_args.init_logger_from_args(args) + if os.name == "nt": + asyncio.set_event_loop(asyncio.ProactorEventLoop()) + # if args.device is None: + # print("Starting in Simulation mode...") + # dev = andor(args.device if not args.simulation else None) + dev = picomotor("COM4") + #asyncio.get_event_loop().run_until_complete(dev.setup()) + try: + print("picomotor server startup on port",args.port,"successful...") + simple_server_loop( + {"picomotor": dev}, common_args.bind_address_from_args(args), args.port) + truthcounter=1 + finally: + print("Closing picomotor and server...") + dev.close() + +if __name__ == "__main__": + main() diff --git a/Picomotor/picomotor_driver.py b/picomotor_repo/build/lib/picomotor/picomotor_driver.py similarity index 100% rename from Picomotor/picomotor_driver.py rename to picomotor_repo/build/lib/picomotor/picomotor_driver.py diff --git a/picomotor_repo/dist/picomotor-0.0.0-py3.8.egg b/picomotor_repo/dist/picomotor-0.0.0-py3.8.egg new file mode 100644 index 0000000000000000000000000000000000000000..a319f9629f970ae19ef37a007af9726992ca56ad GIT binary patch literal 7282 zcma)h1yCH@*7e{TY|sP(!QI{6Jy>vp1s^1n;BLVQaM2*a9Rdsv1HoZ%XMo^A6Cg-} zeBAr$MfmTl`e$lacUSdVdv({TK6~$_se*(|2mk=k0cGBb+S18%>t1(P(7V9D3poV^ zHYIg=4Gv9}|D0Hl)LF&teCc9V=l6p`Q4HoyjMSw z8W^IbFF~cEM`G+4g+S2v*j?MGXbr1%!n-x`JM!C2MyCtJUK-83it~2g&+>JOLSlB4 zJR_t2DtPp=KZUy(Z_(K@56=~Pf$R6D(6^|w+(>^5y$g!pg<4sItevf_oh?1h9POMP z-2Ya*jtKY@jeaHflIsp7dlzKCqph7i+&s-dE_Tiy{~)8(VWTXtQKc9Tb@oA4MyA+J zWmZ-8fk=*iRoLhV#{h?RwQj(NZ(|$fZa|)s#>RVjKAmRpVBhg$-UadRc|2S|W{%ci zYsbIkvHX{8?Y_?P&^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cmV?d00001 diff --git a/picomotor_repo/doc/Makefile b/picomotor_repo/doc/Makefile new file mode 100644 index 0000000..298ea9e --- /dev/null +++ b/picomotor_repo/doc/Makefile @@ -0,0 +1,19 @@ +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line. +SPHINXOPTS = +SPHINXBUILD = sphinx-build +SOURCEDIR = . +BUILDDIR = _build + +# Put it first so that "make" without argument is like "make help". +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.PHONY: help Makefile + +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: Makefile + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) \ No newline at end of file diff --git a/picomotor_repo/doc/conf.py b/picomotor_repo/doc/conf.py new file mode 100644 index 0000000..116bf77 --- /dev/null +++ b/picomotor_repo/doc/conf.py @@ -0,0 +1,176 @@ +# -*- coding: utf-8 -*- +# +# Configuration file for the Sphinx documentation builder. +# +# This file does only contain a selection of the most common options. For a +# full list see the documentation: +# http://www.sphinx-doc.org/en/master/config + + +import os +import sys +from unittest.mock import Mock + +sys.path.insert(0, os.path.abspath('..')) + +mock_modules = ["asyncserial"] + +for module in mock_modules: + sys.modules[module] = Mock() + +# -- Project information ----------------------------------------------------- + +project = 'picomotor' +copyright = '2019, M-Labs' +author = 'M-Labs' + +# The short X.Y version +version = '1.0' +# The full version, including alpha/beta/rc tags +release = '1.0' + + +# -- General configuration --------------------------------------------------- + +# If your documentation needs a minimal Sphinx version, state it here. +# +# needs_sphinx = '1.0' + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [ + 'sphinx.ext.autodoc', + 'sphinxarg.ext' +] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The suffix(es) of source filenames. +# You can specify multiple suffix as a list of string: +# +# source_suffix = ['.rst', '.md'] +source_suffix = '.rst' + +# The master toctree document. +master_doc = 'index' + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +# +# This is also used if you do content translation via gettext catalogs. +# Usually you set "language" from the command line for these cases. +language = None + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +# This pattern also affects html_static_path and html_extra_path. +exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = None + + +# -- Options for HTML output ------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +# +html_theme = 'alabaster' + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +# +# html_theme_options = {} + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['_static'] + +# Custom sidebar templates, must be a dictionary that maps document names +# to template names. +# +# The default sidebars (for documents that don't match any pattern) are +# defined by theme itself. Builtin themes are using these templates by +# default: ``['localtoc.html', 'relations.html', 'sourcelink.html', +# 'searchbox.html']``. +# +# html_sidebars = {} + + +# -- Options for HTMLHelp output --------------------------------------------- + +# Output file base name for HTML help builder. +htmlhelp_basename = 'picomotordoc' + + +# -- Options for LaTeX output ------------------------------------------------ + +latex_elements = { + # The paper size ('letterpaper' or 'a4paper'). + # + # 'papersize': 'letterpaper', + + # The font size ('10pt', '11pt' or '12pt'). + # + # 'pointsize': '10pt', + + # Additional stuff for the LaTeX preamble. + # + # 'preamble': '', + + # Latex figure (float) alignment + # + # 'figure_align': 'htbp', +} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, +# author, documentclass [howto, manual, or own class]). +latex_documents = [ + (master_doc, 'picomotor.tex', 'picomotor Documentation', + 'M-Labs', 'manual'), +] + + +# -- Options for manual page output ------------------------------------------ + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + (master_doc, 'picomotor', 'picomotor Documentation', + [author], 1) +] + + +# -- Options for Texinfo output ---------------------------------------------- + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + (master_doc, 'picomotor', 'picomotor Documentation', + author, 'picomotor', 'One line description of project.', + 'Miscellaneous'), +] + + +# -- Options for Epub output ------------------------------------------------- + +# Bibliographic Dublin Core info. +epub_title = project + +# The unique identifier of the text. This can be a ISBN number +# or the project homepage. +# +# epub_identifier = '' + +# A unique identification for the text. +# +# epub_uid = '' + +# A list of files that should not be packed into the epub file. +epub_exclude_files = ['search.html'] diff --git a/picomotor_repo/doc/index.rst b/picomotor_repo/doc/index.rst new file mode 100644 index 0000000..6516bdc --- /dev/null +++ b/picomotor_repo/doc/index.rst @@ -0,0 +1,24 @@ +Welcome to picomotor's documentation! +======================================== + +API +--- + +.. automodule:: picomotor.driver + :members: + + +ARTIQ controller +---------------- + +.. argparse:: + :ref: picomotor.aqctl_picomotor.get_argparser + :prog: aqctl_picomotor + + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` diff --git a/picomotor_repo/picomotor.egg-info/PKG-INFO b/picomotor_repo/picomotor.egg-info/PKG-INFO new file mode 100644 index 0000000..191b946 --- /dev/null +++ b/picomotor_repo/picomotor.egg-info/PKG-INFO @@ -0,0 +1,10 @@ +Metadata-Version: 1.0 +Name: picomotor +Version: 0.0.0 +Summary: UNKNOWN +Home-page: UNKNOWN +Author: UNKNOWN +Author-email: UNKNOWN +License: UNKNOWN +Description: UNKNOWN +Platform: UNKNOWN diff --git a/picomotor_repo/picomotor.egg-info/SOURCES.txt b/picomotor_repo/picomotor.egg-info/SOURCES.txt new file mode 100644 index 0000000..e9f4fd4 --- /dev/null +++ b/picomotor_repo/picomotor.egg-info/SOURCES.txt @@ -0,0 +1,9 @@ +setup.py +picomotor/__init__.py +picomotor/aqctl_picomotor.py +picomotor/picomotor_driver.py +picomotor.egg-info/PKG-INFO +picomotor.egg-info/SOURCES.txt +picomotor.egg-info/dependency_links.txt +picomotor.egg-info/entry_points.txt +picomotor.egg-info/top_level.txt \ No newline at end of file diff --git a/picomotor_repo/picomotor.egg-info/dependency_links.txt b/picomotor_repo/picomotor.egg-info/dependency_links.txt new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/picomotor_repo/picomotor.egg-info/dependency_links.txt @@ -0,0 +1 @@ + diff --git a/picomotor_repo/picomotor.egg-info/entry_points.txt b/picomotor_repo/picomotor.egg-info/entry_points.txt new file mode 100644 index 0000000..0a7b59a --- /dev/null +++ b/picomotor_repo/picomotor.egg-info/entry_points.txt @@ -0,0 +1,3 @@ +[console_scripts] +aqctl_picomotor = picomotor.aqctl_picomotor:main + diff --git a/picomotor_repo/picomotor.egg-info/top_level.txt b/picomotor_repo/picomotor.egg-info/top_level.txt new file mode 100644 index 0000000..444fc08 --- /dev/null +++ b/picomotor_repo/picomotor.egg-info/top_level.txt @@ -0,0 +1 @@ +picomotor diff --git a/picomotor_repo/picomotor/__init__.py b/picomotor_repo/picomotor/__init__.py new file mode 100644 index 0000000..c8183ba --- /dev/null +++ b/picomotor_repo/picomotor/__init__.py @@ -0,0 +1,2 @@ +from picomotor import aqctl_picomotor +from picomotor import picomotor_driver \ No newline at end of file diff --git a/picomotor_repo/picomotor/__pycache__/__init__.cpython-38.pyc b/picomotor_repo/picomotor/__pycache__/__init__.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..a1dc5e21507a2da613a33cd071abe5d164c336dd GIT binary patch literal 259 zcmWIL<>g`kf=vq*6MTX6V-N=!FabFZKwK;XBvKes7;_kM8KW2(L2M=KR3T5zX&KK0O!P~6lIpB7Wrv1-{OP|7J+OjVg?c` z8H!jzY!LA)z}YG$v^ce>I3^=MKP4x|B|o_|H#M)MIL1A*#G^DR#xt+DqzEbmH!Qv= owIDwR&W(wW&&!g+bygRLJ)Wxv@=g2A+$oQx?EOTN?}M=C#3xkok#w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JS9N$wm{43T8yv))78 zC^GQ|j2|KC$ve=MKPPd{pxSnLni+lvg&|s(PtiK7@{)5$=3E}4tJbS^cha?7+qEU>Hk_j3`*^1MehClpwXpF@ fz?+jN9j$Z*pV3Z*d#60o2gEVuLRcm}M_uc`@h@*R literal 0 HcmV?d00001 diff --git a/picomotor_repo/picomotor/aqctl_picomotor.py b/picomotor_repo/picomotor/aqctl_picomotor.py new file mode 100644 index 0000000..dbfa2c1 --- /dev/null +++ b/picomotor_repo/picomotor/aqctl_picomotor.py @@ -0,0 +1,52 @@ +import argparse +import logging +import sys +import os +import asyncio + +from picomotor.picomotor_driver import picomotor +from sipyco.pc_rpc import simple_server_loop +from sipyco import common_args + +logger = logging.getLogger(__name__) + +def get_argparser(): + parser = argparse.ArgumentParser( + description="ARTIQ controller for the picomotor") + common_args.simple_network_args(parser, 3210) + parser.add_argument( + "-d", "--device", default=None, + help="serial port.") + parser.add_argument( + "--softtrig", default=False, action="store_true", + help="Sets trigger to software. Default is hardware") + parser.add_argument( + "--num", default=1, + help="Sets number of images. Default is hardware") + parser.add_argument( + "--simulation", action="store_true", + help="Put the driver in simulation mode, even if --device is used.") + common_args.verbosity_args(parser) + return parser + +def main(): + args = get_argparser().parse_args() + common_args.init_logger_from_args(args) + if os.name == "nt": + asyncio.set_event_loop(asyncio.ProactorEventLoop()) + # if args.device is None: + # print("Starting in Simulation mode...") + # dev = andor(args.device if not args.simulation else None) + dev = picomotor("COM4") + #asyncio.get_event_loop().run_until_complete(dev.setup()) + try: + print("picomotor server startup on port",args.port,"successful...") + simple_server_loop( + {"picomotor": dev}, common_args.bind_address_from_args(args), args.port) + truthcounter=1 + finally: + print("Closing picomotor and server...") + dev.close() + +if __name__ == "__main__": + main() diff --git a/picomotor_repo/picomotor/picomotor_driver.py b/picomotor_repo/picomotor/picomotor_driver.py new file mode 100644 index 0000000..12008e9 --- /dev/null +++ b/picomotor_repo/picomotor/picomotor_driver.py @@ -0,0 +1,134 @@ +""" +Library to control the NewFocus 8732 picomotor driver. +""" +import serial +import time +import numpy as np +#import os + + +class picomotor: + axis_names = { "MOTz_x": "112", "MOTz_y": "122", "MOTy_x": "232", "MOTy_y": "242", "MOTx_x": "212", "MOTx_y": "222"} + steps_in_turn = { "MOTz_x": [15000, 16000], "MOTz_y":[16000, 16000], "MOTy_x": [16000, 16000], "MOTy_y": [16000, 16000], + "MOTx_x": [16000, 16000], "MOTx_y": [16000, 16000]} # [CW, CCW] number of steps for 1 turn + + + def __init__(self, COM_port): + """Open serial connection for NewFocus 8732 controller""" + """COM_port: ie 'COM3' (check device manager) """ + + self.serial = serial.Serial(timeout = 0.5) #19200 baud didn't work. 8 bits, no parity, 1 stop bit. + self.serial.baudrate = 9600 + self.serial.port = COM_port #'COM3' + try: + self.serial.open() + #print("Serial connection open: ", self.serial.open()) + response = self.sendreceive("*IDN?") + print(response) + #print(self.serial.is_open) + except: + self.serial.close() # don't know if this will help + print(self.serial.is_open) + print('Cannot open.') + + # Initialize positions + self.positions = dict.fromkeys(self.axis_names, 0) #{'MOTz_x': 0, 'MOTz_y': 0, ...} #units steps + + # Turn on the slots? + #self.sendreceive(':INST 1') #? not sure if I need this? + #INST:NSEL 1 + + + def sendreceive(self, cmd): + """Send command to the picomotor driver, and readlines""" + """ Send multiple commands with ;""" + """ 8732 ends with carriage return \r. Does not echo command, but always responds. """ + line = cmd + '\r' + retval = self.serial.write(bytes(line, encoding='ascii')) + self.serial.flush() # wait for outgoing serial data to complete + #time.sleep(0.01) #not sure if needed + response = self.serial.read_until(b'\r') + response = response[:-1] # get rid of \r + return response + + + def move(self, axis="MOTx_x", steps=1000, velocity=1500): + """ Move relative number of setups. Position CW, Negative CCW""" + """ Returns before finished moving. """ + + cmd1 = ":INST:NSEL " + self.axis_names[axis] + + cmd2 = ":SOUR:PULS:FREQ "+ str(round(velocity)) # integer divider of 1500 + + if steps < 0: + cmd3 = ":SOUR:DIR CCW" + else: + cmd3 = ":SOUR:DIR CW" + + cmd4 = ":SOUR:PULS:COUN " + str(round(abs(steps))) + + cmd = cmd1 + "; " + cmd2 + "; " + cmd3 #+ "; " + cmd4 + print(cmd) + self.sendreceive(cmd) + time.sleep(0.01) + self.sendreceive(cmd4) + + self.wait_for_move() + # Update position in move_abs and move_rel + #self.positions[axis] = self.positions[axis] + steps + + + def move_abs(self, axis, position, velocity=1500, ccw_correction=True): + """ Move to absolute position, and if CCW (negative steps), then use correct cw/ccw disparities""" + cw, ccw = self.steps_in_turn[axis] #number steps in turn + current_position = self.positions[axis] #get current position + steps = position - current_position + + if steps < 0: + steps = steps*(ccw/cw) + + self.move(axis, steps, velocity) + self.positions[axis] = position + return position + + def move_rel(self, axis, steps, velocity=1500, ccw_correction=True): + """ Move to absolute position, and if CCW (negative steps), then use correct cw/ccw disparities""" + cw, ccw = self.steps_in_turn[axis] #number steps in turn + + if steps < 0: + steps = steps*(ccw/cw) + + self.move(axis, steps, velocity) + self.positions[axis] = self.positions[axis] + steps #get current position + return self.positions[axis] + + + + def wait_for_move(self): + """ Wait for picomotor to finish moving """ + timeout = 120 # timeout seconds + moving = 0 + print("ran wait successfully") + while moving==0: #OPC returns 1 if all channels are finished + time.sleep(0.2) + text = self.sendreceive("*OPC?") + moving = int(text)# get 1 or 0 from text + + + def zero_positions(self): + """ Zero all positions """ + self.positions = dict.fromkeys(self.axis_names, 0) + + def zero_position(self, axis): + """ Zero single axis """ + self.positions[axis] = 0 + + + def get_position(self, axis): + """ Return current position """ + return self.positions[axis] + + + def close(self): + self.serial.close() + print(self.serial.is_open) \ No newline at end of file diff --git a/picomotor_repo/setup.py b/picomotor_repo/setup.py new file mode 100644 index 0000000..6e0e5c7 --- /dev/null +++ b/picomotor_repo/setup.py @@ -0,0 +1,12 @@ +from setuptools import setup, find_packages + +setup( + name="picomotor", + install_requires=[],#"sipyco", "asyncserial"], #I disabled these because the installs were messed up! + packages=find_packages(), + entry_points={ + "console_scripts": [ + "aqctl_picomotor = picomotor.aqctl_picomotor:main", + ], + }, +) diff --git a/Picomotor/test_driver.py b/picomotor_repo/testing/test_driver.py similarity index 100% rename from Picomotor/test_driver.py rename to picomotor_repo/testing/test_driver.py diff --git a/Picomotor/testing.py b/picomotor_repo/testing/testing.py similarity index 100% rename from Picomotor/testing.py rename to picomotor_repo/testing/testing.py