mirror of https://github.com/m-labs/artiq.git
Merge branch 'master' of github.com:m-labs/artiq into new-py2llvm
This commit is contained in:
commit
3e1348a084
|
@ -16,7 +16,7 @@ before_install:
|
|||
- . ./.travis/get-toolchain.sh
|
||||
- . ./.travis/get-anaconda.sh
|
||||
- source $HOME/miniconda/bin/activate py34
|
||||
- conda install -q pip coverage binstar migen cython
|
||||
- conda install -q pip coverage anaconda-client migen cython
|
||||
- pip install coveralls
|
||||
install:
|
||||
- conda build conda/artiq
|
||||
|
@ -25,9 +25,9 @@ script:
|
|||
- coverage run --source=artiq setup.py test
|
||||
- make -C doc/manual html
|
||||
after_success:
|
||||
- binstar -q login --hostname $(hostname) --username $binstar_login --password $binstar_password
|
||||
- binstar -q upload --user $binstar_login --channel dev --force $HOME/miniconda/conda-bld/linux-64/artiq-*.tar.bz2
|
||||
- binstar -q logout
|
||||
- anaconda -q login --hostname $(hostname) --username $binstar_login --password $binstar_password
|
||||
- if [ "$TRAVIS_BRANCH" == "master" ]; then anaconda -q upload --user $binstar_login --channel dev --force $HOME/miniconda/conda-bld/linux-64/artiq-*.tar.bz2; fi
|
||||
- anaconda -q logout
|
||||
- coveralls
|
||||
notifications:
|
||||
email:
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#!/bin/sh
|
||||
# Copyright (C) 2014, 2015 Robert Jordens <jordens@gmail.com>
|
||||
|
||||
export PATH=$HOME/miniconda/bin:$PATH
|
||||
wget http://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
|
||||
|
@ -9,5 +10,4 @@ conda update -q conda
|
|||
conda info -a
|
||||
conda install conda-build jinja2
|
||||
conda create -q -n py34 python=$TRAVIS_PYTHON_VERSION
|
||||
conda config --add channels fallen
|
||||
conda config --add channels https://conda.anaconda.org/fallen/channel/dev
|
||||
conda config --add channels https://conda.anaconda.org/m-labs/channel/dev
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/bin/sh
|
||||
|
||||
packages="http://us.archive.ubuntu.com/ubuntu/pool/universe/i/iverilog/iverilog_0.9.7-1_amd64.deb"
|
||||
archives="http://fehu.whitequark.org/files/binutils-or1k.tbz2 http://fehu.whitequark.org/files/llvm-or1k.tbz2"
|
||||
archives="http://fehu.whitequark.org/files/llvm-or1k.tbz2"
|
||||
|
||||
mkdir -p packages
|
||||
|
||||
|
@ -21,8 +21,8 @@ done
|
|||
export PATH=$PWD/packages/usr/local/llvm-or1k/bin:$PWD/packages/usr/local/bin:$PWD/packages/usr/bin:$PATH
|
||||
export LD_LIBRARY_PATH=$PWD/packages/usr/lib/x86_64-linux-gnu:$PWD/packages/usr/local/x86_64-unknown-linux-gnu/or1k-elf/lib:$LD_LIBRARY_PATH
|
||||
|
||||
echo "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH" >> $HOME/.mlabs/build_settings.sh
|
||||
echo "export PATH=$PWD/packages/usr/local/llvm-or1k/bin:$PATH" >> $HOME/.mlabs/build_settings.sh
|
||||
echo "export LD_LIBRARY_PATH=$PWD/packages/usr/lib/x86_64-linux-gnu:$PWD/packages/usr/local/x86_64-unknown-linux-gnu/or1k-elf/lib:\$LD_LIBRARY_PATH" >> $HOME/.mlabs/build_settings.sh
|
||||
echo "export PATH=$PWD/packages/usr/local/llvm-or1k/bin:$PWD/packages/usr/local/bin:$PWD/packages/usr/bin:\$PATH" >> $HOME/.mlabs/build_settings.sh
|
||||
|
||||
or1k-linux-as --version
|
||||
llc --version
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
#!/bin/sh
|
||||
# Copyright (C) 2014, 2015 M-Labs Limited
|
||||
# Copyright (C) 2014, 2015 Robert Jordens <jordens@gmail.com>
|
||||
|
||||
wget http://sionneau.net/artiq/Xilinx/xilinx_ise_14.7_s3_s6.tar.gz.gpg
|
||||
echo "$secret" | gpg --passphrase-fd 0 xilinx_ise_14.7_s3_s6.tar.gz.gpg
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
Authors retain copyright of their contributions to ARTIQ, but whenever possible
|
||||
should use the GNU GPL version 3 license for them to be merged.
|
||||
|
||||
Works of US government employees are not copyrighted but can also be merged.
|
||||
|
||||
We've introduced a "sign-off" procedure on patches that are being sent around.
|
||||
|
||||
The sign-off is a simple line at the end of the explanation for the
|
||||
patch, which certifies that you wrote it or otherwise have the right to
|
||||
pass it on as an open-source patch. The rules are pretty simple: if you
|
||||
can certify the below:
|
||||
|
||||
Developer's Certificate of Origin (1.1 from the Linux kernel)
|
||||
|
||||
By making a contribution to this project, I certify that:
|
||||
|
||||
(a) The contribution was created in whole or in part by me and I
|
||||
have the right to submit it under the open source license
|
||||
indicated in the file; or
|
||||
|
||||
(b) The contribution is based upon previous work that, to the best
|
||||
of my knowledge, is covered under an appropriate open source
|
||||
license and I have the right under that license to submit that
|
||||
work with modifications, whether created in whole or in part
|
||||
by me, under the same open source license (unless I am
|
||||
permitted to submit under a different license), as indicated
|
||||
in the file; or
|
||||
|
||||
(c) The contribution was provided directly to me by some other
|
||||
person who certified (a), (b) or (c) and I have not modified
|
||||
it.
|
||||
|
||||
(d) I understand and agree that this project and the contribution
|
||||
are public and that a record of the contribution (including all
|
||||
personal information I submit with it, including my sign-off) is
|
||||
maintained indefinitely and may be redistributed consistent with
|
||||
this project or the open source license(s) involved.
|
||||
|
||||
then you just add a line saying
|
||||
|
||||
Signed-off-by: Random J Developer <random@developer.example.org>
|
||||
|
||||
using your legal name (sorry, no pseudonyms or anonymous contributions.)
|
||||
|
||||
ARTIQ files that do not contain a license header are copyrighted by M-Labs Limited
|
||||
and are licensed under GNU GPL version 3.
|
|
@ -0,0 +1,674 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
|
@ -1,12 +1,10 @@
|
|||
.. image:: doc/logo/artiq.png
|
||||
.. image:: https://travis-ci.org/m-labs/artiq.svg
|
||||
:target: https://travis-ci.org/m-labs/artiq
|
||||
.. image:: https://coveralls.io/repos/m-labs/artiq/badge.svg?branch=master
|
||||
:target: https://coveralls.io/r/m-labs/artiq?branch=master
|
||||
|
||||
ARTIQ (Advanced Real-Time Infrastructure for Quantum physics) is a
|
||||
next-generation control system for quantum information experiments. It is
|
||||
being developed in partnership with the Ion Storage Group at NIST, and its
|
||||
developed in partnership with the Ion Storage Group at NIST, and its
|
||||
applicability reaches beyond ion trapping.
|
||||
|
||||
The system features a high-level programming language that helps describing
|
||||
|
@ -15,7 +13,7 @@ nanosecond timing resolution and sub-microsecond latency.
|
|||
|
||||
Technologies employed include Python, Migen, MiSoC/mor1kx, LLVM and llvmlite.
|
||||
|
||||
ARTIQ is licensed under 3-clause BSD.
|
||||
|
||||
Website:
|
||||
http://m-labs.hk/artiq
|
||||
|
||||
Copyright (C) 2014-2015 M-Labs Limited. Licensed under GNU GPL version 3.
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
from artiq import language
|
||||
from artiq.language import *
|
||||
from artiq.coredevice.dds import (PHASE_MODE_CONTINUOUS, PHASE_MODE_ABSOLUTE,
|
||||
PHASE_MODE_TRACKING)
|
||||
|
||||
__all__ = []
|
||||
__all__.extend(language.__all__)
|
||||
__all__ += ["PHASE_MODE_CONTINUOUS", "PHASE_MODE_ABSOLUTE",
|
||||
"PHASE_MODE_TRACKING"]
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import logging
|
||||
import socket
|
||||
import sys
|
||||
|
||||
from artiq.coredevice.comm_generic import CommGeneric
|
||||
|
||||
|
@ -7,6 +8,22 @@ from artiq.coredevice.comm_generic import CommGeneric
|
|||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def set_keepalive(sock, after_idle, interval, max_fails):
|
||||
if sys.platform.startswith("linux"):
|
||||
sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)
|
||||
sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_KEEPIDLE, after_idle)
|
||||
sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_KEEPINTVL, interval)
|
||||
sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_KEEPCNT, max_fails)
|
||||
elif sys.platform.startswith("win") or sys.platform.startswith("cygwin"):
|
||||
# setting max_fails is not supported, typically ends up being 5 or 10
|
||||
# depending on Windows version
|
||||
sock.ioctl(socket.SIO_KEEPALIVE_VALS,
|
||||
(1, after_idle*1000, interval*1000))
|
||||
else:
|
||||
logger.warning("TCP keepalive not supported on platform '%s', ignored",
|
||||
sys.platform)
|
||||
|
||||
|
||||
class Comm(CommGeneric):
|
||||
def __init__(self, dmgr, host, port=1381):
|
||||
super().__init__()
|
||||
|
@ -16,7 +33,9 @@ class Comm(CommGeneric):
|
|||
def open(self):
|
||||
if hasattr(self, "socket"):
|
||||
return
|
||||
self.socket = socket.create_connection((self.host, self.port))
|
||||
self.socket = socket.create_connection((self.host, self.port), 5.0)
|
||||
self.socket.settimeout(None)
|
||||
set_keepalive(self.socket, 3, 2, 3)
|
||||
logger.debug("connected to host %s on port %d", self.host, self.port)
|
||||
self.write(b"ARTIQ coredev\n")
|
||||
|
||||
|
|
|
@ -80,4 +80,6 @@ class Core:
|
|||
|
||||
@kernel
|
||||
def break_realtime(self):
|
||||
at_mu(rtio_get_counter() + 125000)
|
||||
min_now = rtio_get_counter() + 125000
|
||||
if now_mu() < min_now:
|
||||
at_mu(min_now)
|
||||
|
|
|
@ -51,13 +51,16 @@ class DDSBus:
|
|||
@kernel
|
||||
def batch_enter(self):
|
||||
"""Starts a DDS command batch. All DDS commands are buffered
|
||||
after this call, until ``batch_exit`` is called."""
|
||||
after this call, until ``batch_exit`` is called.
|
||||
|
||||
The time of execution of the DDS commands is the time of entering the
|
||||
batch (as closely as hardware permits)."""
|
||||
dds_batch_enter(now_mu())
|
||||
|
||||
@kernel
|
||||
def batch_exit(self):
|
||||
"""Ends a DDS command batch. All buffered DDS commands are issued
|
||||
on the bus, and FUD is pulsed at the time the batch started."""
|
||||
on the bus."""
|
||||
dds_batch_exit()
|
||||
|
||||
|
||||
|
@ -104,6 +107,17 @@ class _DDSGeneric:
|
|||
word."""
|
||||
return pow/2**self.pow_width
|
||||
|
||||
@portable
|
||||
def amplitude_to_asf(self, amplitude):
|
||||
"""Returns amplitude scale factor corresponding to given amplitude."""
|
||||
return round(amplitude*0x0fff)
|
||||
|
||||
@portable
|
||||
def asf_to_amplitude(self, asf):
|
||||
"""Returns the amplitude corresponding to the given amplitude scale
|
||||
factor."""
|
||||
return round(amplitude*0x0fff)
|
||||
|
||||
@kernel
|
||||
def init(self):
|
||||
"""Resets and initializes the DDS channel.
|
||||
|
@ -132,12 +146,14 @@ class _DDSGeneric:
|
|||
self.phase_mode = phase_mode
|
||||
|
||||
@kernel
|
||||
def set_mu(self, frequency, phase=0, phase_mode=_PHASE_MODE_DEFAULT):
|
||||
def set_mu(self, frequency, phase=0, phase_mode=_PHASE_MODE_DEFAULT,
|
||||
amplitude=0x0fff):
|
||||
"""Sets the DDS channel to the specified frequency and phase.
|
||||
|
||||
This uses machine units (FTW and POW). The frequency tuning word width
|
||||
is 32, whereas the phase offset word width depends on the type of DDS
|
||||
chip and can be retrieved via the ``pow_width`` attribute.
|
||||
chip and can be retrieved via the ``pow_width`` attribute. The amplitude
|
||||
width is 12.
|
||||
|
||||
:param frequency: frequency to generate.
|
||||
:param phase: adds an offset, in turns, to the phase.
|
||||
|
@ -146,14 +162,15 @@ class _DDSGeneric:
|
|||
"""
|
||||
if phase_mode == _PHASE_MODE_DEFAULT:
|
||||
phase_mode = self.phase_mode
|
||||
dds_set(now_mu(), self.channel,
|
||||
frequency, round(phase*2**self.pow_width), phase_mode)
|
||||
dds_set(now_mu(), self.channel, frequency, phase, phase_mode, amplitude)
|
||||
|
||||
@kernel
|
||||
def set(self, frequency, phase=0, phase_mode=_PHASE_MODE_DEFAULT):
|
||||
def set(self, frequency, phase=0.0, phase_mode=_PHASE_MODE_DEFAULT,
|
||||
amplitude=1.0):
|
||||
"""Like ``set_mu``, but uses Hz and turns."""
|
||||
self.set_mu(self.frequency_to_ftw(frequency),
|
||||
self.turns_to_pow(phase), phase_mode)
|
||||
self.turns_to_pow(phase), phase_mode,
|
||||
self.amplitude_to_asf(amplitude))
|
||||
|
||||
|
||||
class AD9858(_DDSGeneric):
|
||||
|
|
|
@ -28,7 +28,6 @@ class TTLOut:
|
|||
|
||||
This should be used with output-only channels.
|
||||
|
||||
:param core: core device
|
||||
:param channel: channel number
|
||||
"""
|
||||
def __init__(self, dmgr, channel):
|
||||
|
@ -92,7 +91,6 @@ class TTLInOut:
|
|||
|
||||
This should be used with bidirectional channels.
|
||||
|
||||
:param core: core device
|
||||
:param channel: channel number
|
||||
"""
|
||||
def __init__(self, dmgr, channel):
|
||||
|
@ -109,10 +107,12 @@ class TTLInOut:
|
|||
|
||||
@kernel
|
||||
def output(self):
|
||||
"""Set the direction to output."""
|
||||
self.set_oe(True)
|
||||
|
||||
@kernel
|
||||
def input(self):
|
||||
"""Set the direction to input."""
|
||||
self.set_oe(False)
|
||||
|
||||
@kernel
|
||||
|
@ -129,12 +129,16 @@ class TTLInOut:
|
|||
|
||||
@kernel
|
||||
def on(self):
|
||||
"""Set the output to a logic high state."""
|
||||
"""Set the output to a logic high state.
|
||||
|
||||
The channel must be in output mode."""
|
||||
self.set_o(True)
|
||||
|
||||
@kernel
|
||||
def off(self):
|
||||
"""Set the output to a logic low state."""
|
||||
"""Set the output to a logic low state.
|
||||
|
||||
The channel must be in output mode."""
|
||||
self.set_o(False)
|
||||
|
||||
@kernel
|
||||
|
@ -231,14 +235,12 @@ class TTLClockGen:
|
|||
This should be used with TTL channels that have a clock generator
|
||||
built into the gateware (not compatible with regular TTL channels).
|
||||
|
||||
:param core: core device
|
||||
:param channel: channel number
|
||||
"""
|
||||
def __init__(self, dmgr, channel):
|
||||
self.core = dmgr.get("core")
|
||||
self.channel = channel
|
||||
|
||||
def build(self):
|
||||
# in RTIO cycles
|
||||
self.previous_timestamp = int(0, width=64)
|
||||
self.acc_width = 24
|
||||
|
|
|
@ -210,3 +210,15 @@ class Novatech409B:
|
|||
result = [r.rstrip().decode() for r in result]
|
||||
logger.debug("got device status: %s", result)
|
||||
return result
|
||||
|
||||
def ping(self):
|
||||
try:
|
||||
stat = self.get_status()
|
||||
except:
|
||||
return False
|
||||
# check that version number matches is "21"
|
||||
if stat[4][20:] == "21":
|
||||
logger.debug("ping successful")
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Robert Jordens <jordens@gmail.com>, 2012-2015
|
||||
# Copyright (C) 2012-2015 Robert Jordens <jordens@gmail.com>
|
||||
|
||||
from math import log, sqrt
|
||||
import logging
|
||||
|
@ -213,3 +213,6 @@ class Pdq2:
|
|||
for frame_data in program:
|
||||
self.program_frame(frame_data)
|
||||
self.write_all()
|
||||
|
||||
def ping(self):
|
||||
return True
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Yann Sionneau <ys@m-labs.hk>, 2015
|
||||
|
||||
from ctypes import byref, c_ulong
|
||||
from ctypes import byref, c_ulong, create_string_buffer
|
||||
import logging
|
||||
|
||||
import numpy as np
|
||||
|
@ -50,11 +50,13 @@ class DAQmx:
|
|||
|
||||
def ping(self):
|
||||
try:
|
||||
data = (c_ulong*1)()
|
||||
self.daq.DAQmxGetDevSerialNum(self.device, data)
|
||||
data_len = 128
|
||||
data = create_string_buffer(data_len)
|
||||
self.daq.DAQmxGetSysDevNames(data, data_len)
|
||||
logger.debug("Device names: %s", data.value)
|
||||
except:
|
||||
return False
|
||||
return True
|
||||
return data.value != ""
|
||||
|
||||
def load_sample_values(self, sampling_freq, values):
|
||||
"""Load sample values into PXI 6733 device.
|
||||
|
@ -93,7 +95,7 @@ class DAQmx:
|
|||
values = values.flatten()
|
||||
t = self.daq.Task()
|
||||
t.CreateAOVoltageChan(self.channels, b"",
|
||||
min(values), max(values),
|
||||
min(values), max(values)+1,
|
||||
self.daq.DAQmx_Val_Volts, None)
|
||||
|
||||
channel_number = (c_ulong*1)()
|
||||
|
@ -115,9 +117,9 @@ class DAQmx:
|
|||
ret = t.WriteAnalogF64(samps_per_channel, False, 0,
|
||||
self.daq.DAQmx_Val_GroupByChannel, values,
|
||||
byref(num_samps_written), None)
|
||||
if num_samps_written.value != nb_values:
|
||||
raise IOError("Error: only {} sample values were written"
|
||||
.format(num_samps_written.value))
|
||||
if num_samps_written.value != samps_per_channel:
|
||||
raise IOError("Error: only {} sample values per channel were"
|
||||
"written".format(num_samps_written.value))
|
||||
if ret:
|
||||
raise IOError("Error while writing samples to the channel buffer")
|
||||
|
||||
|
|
|
@ -58,6 +58,9 @@ class _Segment:
|
|||
raise ArmError
|
||||
self.lines.append((duration, channel_data))
|
||||
|
||||
def get_sample_count(self):
|
||||
return sum(duration for duration, _ in self.lines)
|
||||
|
||||
@kernel
|
||||
def advance(self):
|
||||
if self.frame.invalidated:
|
||||
|
@ -107,13 +110,13 @@ class _Frame:
|
|||
self.invalidated = True
|
||||
|
||||
def _get_samples(self):
|
||||
program = [
|
||||
program = [[
|
||||
{
|
||||
"dac_divider": 1,
|
||||
"duration": duration,
|
||||
"channel_data": channel_data,
|
||||
} for duration, channel_data in segment.lines
|
||||
for segment in self.segments]
|
||||
} for segment in self.segments
|
||||
for duration, channel_data in segment.lines]]
|
||||
synth = Synthesizer(self.daqmx.channel_count, program)
|
||||
synth.select(0)
|
||||
# not setting any trigger flag in the program causes the whole
|
||||
|
@ -145,7 +148,7 @@ class CompoundDAQmx:
|
|||
self.daqmx = dmgr.get(daqmx_device)
|
||||
self.clock = dmgr.get(clock_device)
|
||||
self.channel_count = channel_count
|
||||
if self.sample_rate_in_mu:
|
||||
if sample_rate_in_mu:
|
||||
self.sample_rate = sample_rate
|
||||
else:
|
||||
self.sample_rate = self.clock.frequency_to_ftw(sample_rate)
|
||||
|
|
|
@ -42,6 +42,12 @@ def get_argparser():
|
|||
parser_add.add_argument("-f", "--flush", default=False, action="store_true",
|
||||
help="flush the pipeline before preparing "
|
||||
"the experiment")
|
||||
parser_add.add_argument("-R", "--repository", default=False,
|
||||
action="store_true",
|
||||
help="use the experiment repository")
|
||||
parser_add.add_argument("-r", "--revision", default=None,
|
||||
help="use a specific repository revision "
|
||||
"(defaults to head, ignored without -R)")
|
||||
parser_add.add_argument("-c", "--class-name", default=None,
|
||||
help="name of the class to run")
|
||||
parser_add.add_argument("file",
|
||||
|
@ -76,13 +82,16 @@ def get_argparser():
|
|||
parser_del_parameter.add_argument("name", help="name of the parameter")
|
||||
|
||||
parser_show = subparsers.add_parser(
|
||||
"show", help="show schedule, devices or parameters")
|
||||
"show", help="show schedule, log, devices or parameters")
|
||||
parser_show.add_argument(
|
||||
"what",
|
||||
help="select object to show: schedule/devices/parameters")
|
||||
help="select object to show: schedule/log/devices/parameters")
|
||||
|
||||
parser_scan_repository = subparsers.add_parser(
|
||||
"scan-repository", help="rescan repository")
|
||||
parser_scan = subparsers.add_parser("scan-repository",
|
||||
help="trigger a repository (re)scan")
|
||||
parser_scan.add_argument("revision", default=None, nargs="?",
|
||||
help="use a specific repository revision "
|
||||
"(defaults to head)")
|
||||
|
||||
return parser
|
||||
|
||||
|
@ -107,6 +116,8 @@ def _action_submit(remote, args):
|
|||
"class_name": args.class_name,
|
||||
"arguments": arguments,
|
||||
}
|
||||
if args.repository:
|
||||
expid["repo_rev"] = args.revision
|
||||
if args.timed is None:
|
||||
due_date = None
|
||||
else:
|
||||
|
@ -137,7 +148,7 @@ def _action_del_parameter(remote, args):
|
|||
|
||||
|
||||
def _action_scan_repository(remote, args):
|
||||
remote.scan_async()
|
||||
remote.scan_async(args.revision)
|
||||
|
||||
|
||||
def _show_schedule(schedule):
|
||||
|
@ -148,7 +159,7 @@ def _show_schedule(schedule):
|
|||
x[1]["due_date"] or 0,
|
||||
x[0]))
|
||||
table = PrettyTable(["RID", "Pipeline", " Status ", "Prio",
|
||||
"Due date", "File", "Class name"])
|
||||
"Due date", "Revision", "File", "Class name"])
|
||||
for rid, v in l:
|
||||
row = [rid, v["pipeline"], v["status"], v["priority"]]
|
||||
if v["due_date"] is None:
|
||||
|
@ -156,11 +167,16 @@ def _show_schedule(schedule):
|
|||
else:
|
||||
row.append(time.strftime("%m/%d %H:%M:%S",
|
||||
time.localtime(v["due_date"])))
|
||||
row.append(v["expid"]["file"])
|
||||
if v["expid"]["class_name"] is None:
|
||||
expid = v["expid"]
|
||||
if "repo_rev" in expid:
|
||||
row.append(expid["repo_rev"])
|
||||
else:
|
||||
row.append("Outside repo.")
|
||||
row.append(expid["file"])
|
||||
if expid["class_name"] is None:
|
||||
row.append("")
|
||||
else:
|
||||
row.append(v["expid"]["class_name"])
|
||||
row.append(expid["class_name"])
|
||||
table.add_row(row)
|
||||
print(table)
|
||||
else:
|
||||
|
@ -211,12 +227,42 @@ def _show_dict(args, notifier_name, display_fun):
|
|||
_run_subscriber(args.server, args.port, subscriber)
|
||||
|
||||
|
||||
class _LogPrinter:
|
||||
def __init__(self, init):
|
||||
for rid, msg in init:
|
||||
print(rid, msg)
|
||||
|
||||
def append(self, x):
|
||||
rid, msg = x
|
||||
print(rid, msg)
|
||||
|
||||
def insert(self, i, x):
|
||||
rid, msg = x
|
||||
print(rid, msg)
|
||||
|
||||
def pop(self, i=-1):
|
||||
pass
|
||||
|
||||
def __delitem__(self, x):
|
||||
pass
|
||||
|
||||
def __setitem__(self, k, v):
|
||||
pass
|
||||
|
||||
|
||||
def _show_log(args):
|
||||
subscriber = Subscriber("log", _LogPrinter)
|
||||
_run_subscriber(args.server, args.port, subscriber)
|
||||
|
||||
|
||||
def main():
|
||||
args = get_argparser().parse_args()
|
||||
action = args.action.replace("-", "_")
|
||||
if action == "show":
|
||||
if args.what == "schedule":
|
||||
_show_dict(args, "schedule", _show_schedule)
|
||||
elif args.what == "log":
|
||||
_show_log(args)
|
||||
elif args.what == "devices":
|
||||
_show_dict(args, "devices", _show_devices)
|
||||
elif args.what == "parameters":
|
||||
|
|
|
@ -1,16 +1,17 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import asyncio
|
||||
import atexit
|
||||
import argparse
|
||||
import os
|
||||
import logging
|
||||
import signal
|
||||
import shlex
|
||||
import socket
|
||||
|
||||
from artiq.protocols.sync_struct import Subscriber
|
||||
from artiq.protocols.pc_rpc import AsyncioClient, Server
|
||||
from artiq.tools import verbosity_args, init_logger
|
||||
from artiq.tools import asyncio_process_wait_timeout
|
||||
from artiq.tools import TaskObject, asyncio_process_wait_timeout, Condition
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
@ -29,14 +30,31 @@ def get_argparser():
|
|||
"--retry-master", default=5.0, type=float,
|
||||
help="retry timer for reconnecting to master")
|
||||
parser.add_argument(
|
||||
"--retry-command", default=5.0, type=float,
|
||||
help="retry timer for restarting a controller command")
|
||||
"--bind", default="::1",
|
||||
help="hostname or IP address to bind to")
|
||||
parser.add_argument(
|
||||
"--bind-port", default=3249, type=int,
|
||||
help="TCP port to listen to for control (default: %(default)d)")
|
||||
return parser
|
||||
|
||||
|
||||
class Controller:
|
||||
def __init__(self, name, command, retry):
|
||||
self.launch_task = asyncio.Task(self.launcher(name, command, retry))
|
||||
def __init__(self, name, ddb_entry):
|
||||
self.name = name
|
||||
self.command = ddb_entry["command"]
|
||||
self.retry_timer = ddb_entry.get("retry_timer", 5)
|
||||
self.retry_timer_backoff = ddb_entry.get("retry_timer_backoff", 1.1)
|
||||
|
||||
self.host = ddb_entry["host"]
|
||||
self.port = ddb_entry["port"]
|
||||
self.ping_timer = ddb_entry.get("ping_timer", 30)
|
||||
self.ping_timeout = ddb_entry.get("ping_timeout", 30)
|
||||
self.term_timeout = ddb_entry.get("term_timeout", 30)
|
||||
|
||||
self.retry_timer_cur = self.retry_timer
|
||||
self.retry_now = Condition()
|
||||
self.process = None
|
||||
self.launch_task = asyncio.Task(self.launcher())
|
||||
|
||||
@asyncio.coroutine
|
||||
def end(self):
|
||||
|
@ -44,33 +62,89 @@ class Controller:
|
|||
yield from asyncio.wait_for(self.launch_task, None)
|
||||
|
||||
@asyncio.coroutine
|
||||
def launcher(self, name, command, retry):
|
||||
process = None
|
||||
def _call_controller(self, method):
|
||||
remote = AsyncioClient()
|
||||
yield from remote.connect_rpc(self.host, self.port, None)
|
||||
try:
|
||||
targets, _ = remote.get_rpc_id()
|
||||
remote.select_rpc_target(targets[0])
|
||||
r = yield from getattr(remote, method)()
|
||||
finally:
|
||||
remote.close_rpc()
|
||||
return r
|
||||
|
||||
@asyncio.coroutine
|
||||
def _ping(self):
|
||||
try:
|
||||
ok = yield from asyncio.wait_for(self._call_controller("ping"),
|
||||
self.ping_timeout)
|
||||
if ok:
|
||||
self.retry_timer_cur = self.retry_timer
|
||||
return ok
|
||||
except:
|
||||
return False
|
||||
|
||||
@asyncio.coroutine
|
||||
def _wait_and_ping(self):
|
||||
while True:
|
||||
try:
|
||||
yield from asyncio_process_wait_timeout(self.process,
|
||||
self.ping_timer)
|
||||
except asyncio.TimeoutError:
|
||||
logger.debug("pinging controller %s", self.name)
|
||||
ok = yield from self._ping()
|
||||
if not ok:
|
||||
logger.warning("Controller %s ping failed", self.name)
|
||||
yield from self._terminate()
|
||||
return
|
||||
else:
|
||||
break
|
||||
|
||||
@asyncio.coroutine
|
||||
def launcher(self):
|
||||
try:
|
||||
while True:
|
||||
logger.info("Starting controller %s with command: %s",
|
||||
name, command)
|
||||
self.name, self.command)
|
||||
try:
|
||||
process = yield from asyncio.create_subprocess_exec(
|
||||
*shlex.split(command))
|
||||
yield from asyncio.shield(process.wait())
|
||||
self.process = yield from asyncio.create_subprocess_exec(
|
||||
*shlex.split(self.command))
|
||||
yield from self._wait_and_ping()
|
||||
except FileNotFoundError:
|
||||
logger.warning("Controller %s failed to start", name)
|
||||
logger.warning("Controller %s failed to start", self.name)
|
||||
else:
|
||||
logger.warning("Controller %s exited", name)
|
||||
logger.warning("Restarting in %.1f seconds", retry)
|
||||
yield from asyncio.sleep(retry)
|
||||
except asyncio.CancelledError:
|
||||
logger.info("Terminating controller %s", name)
|
||||
if process is not None and process.returncode is None:
|
||||
process.send_signal(signal.SIGTERM)
|
||||
logger.debug("Signal sent")
|
||||
logger.warning("Controller %s exited", self.name)
|
||||
logger.warning("Restarting in %.1f seconds",
|
||||
self.retry_timer_cur)
|
||||
try:
|
||||
yield from asyncio_process_wait_timeout(process, 5.0)
|
||||
yield from asyncio.wait_for(self.retry_now.wait(),
|
||||
self.retry_timer_cur)
|
||||
except asyncio.TimeoutError:
|
||||
logger.warning("Controller %s did not respond to SIGTERM",
|
||||
name)
|
||||
process.send_signal(signal.SIGKILL)
|
||||
pass
|
||||
self.retry_timer_cur *= self.retry_timer_backoff
|
||||
except asyncio.CancelledError:
|
||||
yield from self._terminate()
|
||||
|
||||
@asyncio.coroutine
|
||||
def _terminate(self):
|
||||
logger.info("Terminating controller %s", self.name)
|
||||
if self.process is not None and self.process.returncode is None:
|
||||
try:
|
||||
yield from asyncio.wait_for(self._call_controller("terminate"),
|
||||
self.term_timeout)
|
||||
except:
|
||||
logger.warning("Controller %s did not respond to terminate "
|
||||
"command, killing", self.name)
|
||||
self.process.kill()
|
||||
try:
|
||||
yield from asyncio_process_wait_timeout(self.process,
|
||||
self.term_timeout)
|
||||
except:
|
||||
logger.warning("Controller %s failed to exit, killing",
|
||||
self.name)
|
||||
self.process.kill()
|
||||
yield from self.process.wait()
|
||||
logger.debug("Controller %s terminated", self.name)
|
||||
|
||||
|
||||
def get_ip_addresses(host):
|
||||
|
@ -82,8 +156,7 @@ def get_ip_addresses(host):
|
|||
|
||||
|
||||
class Controllers:
|
||||
def __init__(self, retry_command):
|
||||
self.retry_command = retry_command
|
||||
def __init__(self):
|
||||
self.host_filter = None
|
||||
self.active_or_queued = set()
|
||||
self.queue = asyncio.Queue()
|
||||
|
@ -95,10 +168,10 @@ class Controllers:
|
|||
while True:
|
||||
action, param = yield from self.queue.get()
|
||||
if action == "set":
|
||||
k, command = param
|
||||
k, ddb_entry = param
|
||||
if k in self.active:
|
||||
yield from self.active[k].end()
|
||||
self.active[k] = Controller(k, command, self.retry_command)
|
||||
self.active[k] = Controller(k, ddb_entry)
|
||||
elif action == "del":
|
||||
yield from self.active[param].end()
|
||||
del self.active[param]
|
||||
|
@ -108,10 +181,10 @@ class Controllers:
|
|||
def __setitem__(self, k, v):
|
||||
if (isinstance(v, dict) and v["type"] == "controller"
|
||||
and self.host_filter in get_ip_addresses(v["host"])):
|
||||
command = v["command"].format(name=k,
|
||||
v["command"] = v["command"].format(name=k,
|
||||
bind=self.host_filter,
|
||||
port=v["port"])
|
||||
self.queue.put_nowait(("set", (k, command)))
|
||||
self.queue.put_nowait(("set", (k, v)))
|
||||
self.active_or_queued.add(k)
|
||||
|
||||
def __delitem__(self, k):
|
||||
|
@ -131,8 +204,8 @@ class Controllers:
|
|||
|
||||
|
||||
class ControllerDB:
|
||||
def __init__(self, retry_command):
|
||||
self.current_controllers = Controllers(retry_command)
|
||||
def __init__(self):
|
||||
self.current_controllers = Controllers()
|
||||
|
||||
def set_host_filter(self, host_filter):
|
||||
self.current_controllers.host_filter = host_filter
|
||||
|
@ -145,18 +218,26 @@ class ControllerDB:
|
|||
return self.current_controllers
|
||||
|
||||
|
||||
class ControllerManager(TaskObject):
|
||||
def __init__(self, server, port, retry_master):
|
||||
self.server = server
|
||||
self.port = port
|
||||
self.retry_master = retry_master
|
||||
self.controller_db = ControllerDB()
|
||||
|
||||
@asyncio.coroutine
|
||||
def ctlmgr(server, port, retry_master, retry_command):
|
||||
controller_db = ControllerDB(retry_command)
|
||||
def _do(self):
|
||||
try:
|
||||
subscriber = Subscriber("devices", controller_db.sync_struct_init)
|
||||
subscriber = Subscriber("devices",
|
||||
self.controller_db.sync_struct_init)
|
||||
while True:
|
||||
try:
|
||||
def set_host_filter():
|
||||
s = subscriber.writer.get_extra_info("socket")
|
||||
localhost = s.getsockname()[0]
|
||||
controller_db.set_host_filter(localhost)
|
||||
yield from subscriber.connect(server, port, set_host_filter)
|
||||
self.controller_db.set_host_filter(localhost)
|
||||
yield from subscriber.connect(self.server, self.port,
|
||||
set_host_filter)
|
||||
try:
|
||||
yield from asyncio.wait_for(subscriber.receive_task, None)
|
||||
finally:
|
||||
|
@ -167,12 +248,17 @@ def ctlmgr(server, port, retry_master, retry_command):
|
|||
e.__class__.__name__, str(e))
|
||||
else:
|
||||
logger.warning("Connection to master lost")
|
||||
logger.warning("Retrying in %.1f seconds", retry_master)
|
||||
yield from asyncio.sleep(retry_master)
|
||||
logger.warning("Retrying in %.1f seconds", self.retry_master)
|
||||
yield from asyncio.sleep(self.retry_master)
|
||||
except asyncio.CancelledError:
|
||||
pass
|
||||
finally:
|
||||
yield from controller_db.current_controllers.shutdown()
|
||||
yield from self.controller_db.current_controllers.shutdown()
|
||||
|
||||
def retry_now(self, k):
|
||||
"""If a controller is disabled and pending retry, perform that retry
|
||||
now."""
|
||||
self.controller_db.current_controllers.active[k].retry_now.notify()
|
||||
|
||||
|
||||
def main():
|
||||
|
@ -184,18 +270,22 @@ def main():
|
|||
asyncio.set_event_loop(loop)
|
||||
else:
|
||||
loop = asyncio.get_event_loop()
|
||||
atexit.register(lambda: loop.close())
|
||||
|
||||
try:
|
||||
task = asyncio.Task(ctlmgr(
|
||||
args.server, args.port, args.retry_master, args.retry_command))
|
||||
try:
|
||||
loop.run_forever()
|
||||
finally:
|
||||
task.cancel()
|
||||
loop.run_until_complete(asyncio.wait_for(task, None))
|
||||
ctlmgr = ControllerManager(args.server, args.port, args.retry_master)
|
||||
ctlmgr.start()
|
||||
atexit.register(lambda: loop.run_until_complete(ctlmgr.stop()))
|
||||
|
||||
class CtlMgrRPC:
|
||||
retry_now = ctlmgr.retry_now
|
||||
|
||||
rpc_target = CtlMgrRPC()
|
||||
rpc_server = Server({"ctlmgr": rpc_target}, builtin_terminate=True)
|
||||
loop.run_until_complete(rpc_server.start(args.bind, args.bind_port))
|
||||
atexit.register(lambda: loop.run_until_complete(rpc_server.stop()))
|
||||
|
||||
loop.run_until_complete(rpc_server.wait_terminate())
|
||||
|
||||
finally:
|
||||
loop.close()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
|
@ -9,8 +9,10 @@ ARTIQ_PREFIX=$(python3 -c "import artiq; print(artiq.__path__[0])")
|
|||
|
||||
# Default is kc705
|
||||
BOARD=kc705
|
||||
# Default mezzanine board is nist_qc1
|
||||
MEZZANINE_BOARD=nist_qc1
|
||||
|
||||
while getopts "bBrht:d:f:" opt
|
||||
while getopts "bBrht:d:f:m:" opt
|
||||
do
|
||||
case $opt in
|
||||
b)
|
||||
|
@ -53,17 +55,30 @@ do
|
|||
exit 1
|
||||
fi
|
||||
;;
|
||||
m)
|
||||
if [ "$OPTARG" == "nist_qc1" ]
|
||||
then
|
||||
MEZZANINE_BOARD=nist_qc1
|
||||
elif [ "$OPTARG" == "nist_qc2" ]
|
||||
then
|
||||
MEZZANINE_BOARD=nist_qc2
|
||||
else
|
||||
echo "KC705 mezzanine board is either nist_qc1 or nist_qc2"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo "ARTIQ flashing tool"
|
||||
echo ""
|
||||
echo "To flash everything, do not use any of the -b|-B|-r option."
|
||||
echo ""
|
||||
echo "usage: $0 [-b] [-B] [-r] [-h] [-t kc705|pipistrello] [-d path]"
|
||||
echo "usage: $0 [-b] [-B] [-r] [-h] [-m nist_qc1|nist_qc2] [-t kc705|pipistrello] [-d path] [-f path]"
|
||||
echo "-b Flash bitstream"
|
||||
echo "-B Flash BIOS"
|
||||
echo "-r Flash ARTIQ runtime"
|
||||
echo "-h Show this help message"
|
||||
echo "-t Target (kc705, pipistrello, default is: kc705)"
|
||||
echo "-m Mezzanine board (nist_qc1, nist_qc2, default is: nist_qc1)"
|
||||
echo "-f Flash storage image generated with artiq_mkfs"
|
||||
echo "-d Directory containing the binaries to be flashed"
|
||||
exit 1
|
||||
|
@ -103,13 +118,18 @@ fi
|
|||
if [ "$BOARD" == "kc705" ]
|
||||
then
|
||||
UDEV_RULES=99-kc705.rules
|
||||
BITSTREAM=artiq_kc705-nist_qc1-kc705.bit
|
||||
BITSTREAM=artiq_kc705-${MEZZANINE_BOARD}-kc705.bit
|
||||
CABLE=jtaghs1_fast
|
||||
PROXY=bscan_spi_kc705.bit
|
||||
BIOS_ADDR=0xaf0000
|
||||
RUNTIME_ADDR=0xb00000
|
||||
RUNTIME_FILE=runtime.fbi
|
||||
FS_ADDR=0xb40000
|
||||
if [ -z "$BIN_PREFIX" ]; then BIN_PREFIX=$ARTIQ_PREFIX/binaries/kc705; fi
|
||||
if [ -z "$BIN_PREFIX" ]
|
||||
then
|
||||
RUNTIME_FILE=${MEZZANINE_BOARD}/runtime.fbi
|
||||
BIN_PREFIX=$ARTIQ_PREFIX/binaries/kc705
|
||||
fi
|
||||
search_for_proxy $PROXY
|
||||
elif [ "$BOARD" == "pipistrello" ]
|
||||
then
|
||||
|
@ -119,6 +139,7 @@ then
|
|||
PROXY=bscan_spi_lx45_csg324.bit
|
||||
BIOS_ADDR=0x170000
|
||||
RUNTIME_ADDR=0x180000
|
||||
RUNTIME_FILE=runtime.fbi
|
||||
FS_ADDR=0x1c0000
|
||||
if [ -z "$BIN_PREFIX" ]; then BIN_PREFIX=$ARTIQ_PREFIX/binaries/pipistrello; fi
|
||||
search_for_proxy $PROXY
|
||||
|
@ -168,7 +189,7 @@ fi
|
|||
if [ "${FLASH_RUNTIME}" == "1" ]
|
||||
then
|
||||
echo "Flashing ARTIQ runtime..."
|
||||
xc3sprog -v -c $CABLE -I$PROXY_PATH/$PROXY $BIN_PREFIX/runtime.fbi:w:$RUNTIME_ADDR:BIN
|
||||
xc3sprog -v -c $CABLE -I$PROXY_PATH/$PROXY $BIN_PREFIX/${RUNTIME_FILE}:w:$RUNTIME_ADDR:BIN
|
||||
fi
|
||||
echo "Done."
|
||||
xc3sprog -v -c $CABLE -R > /dev/null 2>&1
|
||||
|
|
|
@ -7,11 +7,12 @@ import os
|
|||
|
||||
# Quamash must be imported first so that pyqtgraph picks up the Qt binding
|
||||
# it has chosen.
|
||||
from quamash import QEventLoop, QtGui
|
||||
from quamash import QEventLoop, QtGui, QtCore
|
||||
from pyqtgraph import dockarea
|
||||
|
||||
from artiq.protocols.file_db import FlatFileDB
|
||||
from artiq.tools import verbosity_args, init_logger
|
||||
from artiq.protocols.pc_rpc import AsyncioClient
|
||||
from artiq.gui.state import StateManager
|
||||
from artiq.gui.explorer import ExplorerDock
|
||||
from artiq.gui.moninj import MonInj
|
||||
from artiq.gui.results import ResultsDock
|
||||
|
@ -39,52 +40,65 @@ def get_argparser():
|
|||
parser.add_argument(
|
||||
"--db-file", default="artiq_gui.pyon",
|
||||
help="database file for local GUI settings")
|
||||
verbosity_args(parser)
|
||||
return parser
|
||||
|
||||
|
||||
class _MainWindow(QtGui.QMainWindow):
|
||||
def __init__(self, app):
|
||||
class MainWindow(QtGui.QMainWindow):
|
||||
def __init__(self, app, server):
|
||||
QtGui.QMainWindow.__init__(self)
|
||||
self.setWindowIcon(QtGui.QIcon(os.path.join(data_dir, "icon.png")))
|
||||
self.resize(1400, 800)
|
||||
self.setWindowTitle("ARTIQ")
|
||||
self.setWindowTitle("ARTIQ - {}".format(server))
|
||||
self.exit_request = asyncio.Event()
|
||||
|
||||
def closeEvent(self, *args):
|
||||
self.exit_request.set()
|
||||
|
||||
def save_state(self):
|
||||
return bytes(self.saveGeometry())
|
||||
|
||||
def restore_state(self, state):
|
||||
self.restoreGeometry(QtCore.QByteArray(state))
|
||||
|
||||
|
||||
def main():
|
||||
args = get_argparser().parse_args()
|
||||
|
||||
db = FlatFileDB(args.db_file, default_data=dict())
|
||||
init_logger(args)
|
||||
|
||||
app = QtGui.QApplication([])
|
||||
loop = QEventLoop(app)
|
||||
asyncio.set_event_loop(loop)
|
||||
atexit.register(lambda: loop.close())
|
||||
|
||||
smgr = StateManager(args.db_file)
|
||||
|
||||
schedule_ctl = AsyncioClient()
|
||||
loop.run_until_complete(schedule_ctl.connect_rpc(
|
||||
args.server, args.port_control, "master_schedule"))
|
||||
atexit.register(lambda: schedule_ctl.close_rpc())
|
||||
|
||||
win = _MainWindow(app)
|
||||
win = MainWindow(app, args.server)
|
||||
area = dockarea.DockArea()
|
||||
smgr.register(area)
|
||||
smgr.register(win)
|
||||
win.setCentralWidget(area)
|
||||
status_bar = QtGui.QStatusBar()
|
||||
status_bar.showMessage("Connected to {}".format(args.server))
|
||||
win.setStatusBar(status_bar)
|
||||
|
||||
d_explorer = ExplorerDock(win, status_bar, schedule_ctl)
|
||||
smgr.register(d_explorer)
|
||||
loop.run_until_complete(d_explorer.sub_connect(
|
||||
args.server, args.port_notify))
|
||||
atexit.register(lambda: loop.run_until_complete(d_explorer.sub_close()))
|
||||
|
||||
d_results = ResultsDock(win, area)
|
||||
smgr.register(d_results)
|
||||
loop.run_until_complete(d_results.sub_connect(
|
||||
args.server, args.port_notify))
|
||||
atexit.register(lambda: loop.run_until_complete(d_results.sub_close()))
|
||||
|
||||
if os.name != "nt":
|
||||
d_ttl_dds = MonInj()
|
||||
loop.run_until_complete(d_ttl_dds.start(args.server, args.port_notify))
|
||||
atexit.register(lambda: loop.run_until_complete(d_ttl_dds.stop()))
|
||||
|
@ -94,9 +108,12 @@ def main():
|
|||
args.server, args.port_notify))
|
||||
atexit.register(lambda: loop.run_until_complete(d_params.sub_close()))
|
||||
|
||||
if os.name != "nt":
|
||||
area.addDock(d_ttl_dds.dds_dock, "top")
|
||||
area.addDock(d_ttl_dds.ttl_dock, "above", d_ttl_dds.dds_dock)
|
||||
area.addDock(d_results, "above", d_ttl_dds.ttl_dock)
|
||||
else:
|
||||
area.addDock(d_results, "top")
|
||||
area.addDock(d_params, "above", d_results)
|
||||
area.addDock(d_explorer, "above", d_params)
|
||||
|
||||
|
@ -125,6 +142,9 @@ def main():
|
|||
area.addDock(d_log, "above", d_console)
|
||||
area.addDock(d_schedule, "above", d_log)
|
||||
|
||||
smgr.load()
|
||||
smgr.start()
|
||||
atexit.register(lambda: loop.run_until_complete(smgr.stop()))
|
||||
win.show()
|
||||
loop.run_until_complete(win.exit_request.wait())
|
||||
|
||||
|
|
|
@ -0,0 +1,250 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import argparse
|
||||
import logging
|
||||
import asyncio
|
||||
import atexit
|
||||
import fnmatch
|
||||
from functools import partial
|
||||
|
||||
import numpy as np
|
||||
import aiohttp
|
||||
|
||||
from artiq.tools import verbosity_args, init_logger
|
||||
from artiq.tools import TaskObject
|
||||
from artiq.protocols.sync_struct import Subscriber
|
||||
from artiq.protocols.pc_rpc import Server
|
||||
from artiq.protocols import pyon
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def get_argparser():
|
||||
parser = argparse.ArgumentParser(
|
||||
description="ARTIQ data to InfluxDB bridge")
|
||||
group = parser.add_argument_group("master")
|
||||
group.add_argument(
|
||||
"--server-master", default="::1",
|
||||
help="hostname or IP of the master to connect to")
|
||||
group.add_argument(
|
||||
"--port-master", default=3250, type=int,
|
||||
help="TCP port to use to connect to the master")
|
||||
group.add_argument(
|
||||
"--retry-master", default=5.0, type=float,
|
||||
help="retry timer for reconnecting to master")
|
||||
group = parser.add_argument_group("database")
|
||||
group.add_argument(
|
||||
"--baseurl-db", default="http://localhost:8086",
|
||||
help="base URL to access InfluxDB (default: %(default)s)")
|
||||
group.add_argument(
|
||||
"--user-db", default="", help="InfluxDB username")
|
||||
group.add_argument(
|
||||
"--password-db", default="", help="InfluxDB password")
|
||||
group.add_argument(
|
||||
"--database", default="db", help="database name to use")
|
||||
group.add_argument(
|
||||
"--table", default="lab", help="table name to use")
|
||||
group = parser.add_argument_group("filter")
|
||||
group.add_argument(
|
||||
"--bind", default="::1",
|
||||
help="hostname or IP address to bind to")
|
||||
group.add_argument(
|
||||
"--bind-port", default=3248, type=int,
|
||||
help="TCP port to listen to for control (default: %(default)d)")
|
||||
group.add_argument(
|
||||
"--pattern-file", default="influxdb_patterns.pyon",
|
||||
help="file to save the patterns in (default: %(default)s)")
|
||||
verbosity_args(parser)
|
||||
return parser
|
||||
|
||||
|
||||
def influxdb_str(s):
|
||||
return '"' + s.replace('"', '\\"') + '"'
|
||||
|
||||
|
||||
def format_influxdb(v):
|
||||
if isinstance(v, bool):
|
||||
if v:
|
||||
return "bool", "t"
|
||||
else:
|
||||
return "bool", "f"
|
||||
elif np.issubdtype(type(v), int):
|
||||
return "int", "{}i".format(v)
|
||||
elif np.issubdtype(type(v), float):
|
||||
return "float", "{}".format(v)
|
||||
elif isinstance(v, str):
|
||||
return "str", influxdb_str(v)
|
||||
else:
|
||||
return "pyon", influxdb_str(pyon.encode(v))
|
||||
|
||||
|
||||
class DBWriter(TaskObject):
|
||||
def __init__(self, base_url, user, password, database, table):
|
||||
self.base_url = base_url
|
||||
self.user = user
|
||||
self.password = password
|
||||
self.database = database
|
||||
self.table = table
|
||||
|
||||
self._queue = asyncio.Queue(100)
|
||||
|
||||
def update(self, k, v):
|
||||
try:
|
||||
self._queue.put_nowait((k, v))
|
||||
except asyncio.QueueFull:
|
||||
logger.warning("failed to update parameter '%s': "
|
||||
"too many pending updates", k)
|
||||
|
||||
@asyncio.coroutine
|
||||
def _do(self):
|
||||
while True:
|
||||
k, v = yield from self._queue.get()
|
||||
url = self.base_url + "/write"
|
||||
params = {"u": self.user, "p": self.password, "db": self.database,
|
||||
"consistency": "any", "precision": "n"}
|
||||
fmt_ty, fmt_v = format_influxdb(v)
|
||||
data = "{},parameter={} {}={}".format(self.table, k, fmt_ty, fmt_v)
|
||||
try:
|
||||
response = yield from aiohttp.request(
|
||||
"POST", url, params=params, data=data)
|
||||
except:
|
||||
logger.warning("got exception trying to update '%s'",
|
||||
k, exc_info=True)
|
||||
else:
|
||||
if response.status not in (200, 204):
|
||||
content = (yield from response.content.read()).decode()
|
||||
if content:
|
||||
content = content[:-1] # drop \n
|
||||
logger.warning("got HTTP status %d "
|
||||
"trying to update '%s': %s",
|
||||
response.status, k, content)
|
||||
response.close()
|
||||
|
||||
|
||||
class Parameters:
|
||||
def __init__(self, filter_function, writer, init):
|
||||
self.filter_function = filter_function
|
||||
self.writer = writer
|
||||
|
||||
def __setitem__(self, k, v):
|
||||
if self.filter_function(k):
|
||||
self.writer.update(k, v)
|
||||
|
||||
def __delitem__(self, k):
|
||||
pass
|
||||
|
||||
|
||||
class MasterReader(TaskObject):
|
||||
def __init__(self, server, port, retry, filter_function, writer):
|
||||
self.server = server
|
||||
self.port = port
|
||||
self.retry = retry
|
||||
|
||||
self.filter_function = filter_function
|
||||
self.writer = writer
|
||||
|
||||
@asyncio.coroutine
|
||||
def _do(self):
|
||||
subscriber = Subscriber(
|
||||
"parameters",
|
||||
partial(Parameters, self.filter_function, self.writer))
|
||||
while True:
|
||||
try:
|
||||
yield from subscriber.connect(self.server, self.port)
|
||||
try:
|
||||
yield from asyncio.wait_for(subscriber.receive_task, None)
|
||||
finally:
|
||||
yield from subscriber.close()
|
||||
except (ConnectionAbortedError, ConnectionError,
|
||||
ConnectionRefusedError, ConnectionResetError) as e:
|
||||
logger.warning("Connection to master failed (%s: %s)",
|
||||
e.__class__.__name__, str(e))
|
||||
else:
|
||||
logger.warning("Connection to master lost")
|
||||
logger.warning("Retrying in %.1f seconds", self.retry)
|
||||
yield from asyncio.sleep(self.retry)
|
||||
|
||||
|
||||
class Filter:
|
||||
def __init__(self, pattern_file):
|
||||
self.pattern_file = pattern_file
|
||||
self.patterns = []
|
||||
try:
|
||||
self.patterns = pyon.load_file(self.pattern_file)
|
||||
except FileNotFoundError:
|
||||
logger.info("no pattern file found, logging everything")
|
||||
|
||||
def _save(self):
|
||||
pyon.store_file(self.pattern_file, self.patterns)
|
||||
|
||||
# Privatize so that it is not shown in artiq_rpctool list-methods.
|
||||
def _filter(self, k):
|
||||
take = "+"
|
||||
for pattern in self.patterns:
|
||||
sign = "-"
|
||||
if pattern[0] in "+-":
|
||||
sign, pattern = pattern[0], pattern[1:]
|
||||
if fnmatch.fnmatchcase(k, pattern):
|
||||
take = sign
|
||||
return take == "+"
|
||||
|
||||
def add_pattern(self, pattern, index=None):
|
||||
"""Add a pattern.
|
||||
|
||||
Optional + and - pattern prefixes specify whether to ignore or log
|
||||
keys matching the rest of the pattern.
|
||||
Default (in the absence of prefix) is to ignore. Keys that match no
|
||||
pattern are logged. Last matched pattern takes precedence.
|
||||
|
||||
The optional index parameter specifies where to insert the pattern.
|
||||
By default, patterns are added at the end. If index is an integer, it
|
||||
specifies the index where the pattern is inserted. If it is a string,
|
||||
that string must match an existing pattern and the new pattern is
|
||||
inserted immediately after it."""
|
||||
if pattern not in self.patterns:
|
||||
if index is None:
|
||||
index = len(self.patterns)
|
||||
if isinstance(index, str):
|
||||
index = self.patterns.index(index) + 1
|
||||
self.patterns.insert(index, pattern)
|
||||
self._save()
|
||||
|
||||
def remove_pattern(self, pattern):
|
||||
"""Remove a pattern."""
|
||||
self.patterns.remove(pattern)
|
||||
self._save()
|
||||
|
||||
def get_patterns(self):
|
||||
"""Show existing patterns."""
|
||||
return self.patterns
|
||||
|
||||
|
||||
def main():
|
||||
args = get_argparser().parse_args()
|
||||
init_logger(args)
|
||||
|
||||
loop = asyncio.get_event_loop()
|
||||
atexit.register(lambda: loop.close())
|
||||
|
||||
writer = DBWriter(args.baseurl_db,
|
||||
args.user_db, args.password_db,
|
||||
args.database, args.table)
|
||||
writer.start()
|
||||
atexit.register(lambda: loop.run_until_complete(writer.stop()))
|
||||
|
||||
filter = Filter(args.pattern_file)
|
||||
rpc_server = Server({"influxdb_filter": filter}, builtin_terminate=True)
|
||||
loop.run_until_complete(rpc_server.start(args.bind, args.bind_port))
|
||||
atexit.register(lambda: loop.run_until_complete(rpc_server.stop()))
|
||||
|
||||
reader = MasterReader(args.server_master, args.port_master,
|
||||
args.retry_master, filter._filter, writer)
|
||||
reader.start()
|
||||
atexit.register(lambda: loop.run_until_complete(reader.stop()))
|
||||
|
||||
loop.run_until_complete(rpc_server.wait_terminate())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
|
@ -10,7 +10,7 @@ from artiq.protocols.sync_struct import Notifier, Publisher, process_mod
|
|||
from artiq.protocols.file_db import FlatFileDB
|
||||
from artiq.master.scheduler import Scheduler
|
||||
from artiq.master.worker_db import get_last_rid
|
||||
from artiq.master.repository import Repository
|
||||
from artiq.master.repository import FilesystemBackend, GitBackend, Repository
|
||||
from artiq.tools import verbosity_args, init_logger
|
||||
|
||||
|
||||
|
@ -26,6 +26,18 @@ def get_argparser():
|
|||
group.add_argument(
|
||||
"--port-control", default=3251, type=int,
|
||||
help="TCP port to listen to for control (default: %(default)d)")
|
||||
group = parser.add_argument_group("databases")
|
||||
group.add_argument("-d", "--ddb", default="ddb.pyon",
|
||||
help="device database file")
|
||||
group.add_argument("-p", "--pdb", default="pdb.pyon",
|
||||
help="parameter database file")
|
||||
group = parser.add_argument_group("repository")
|
||||
group.add_argument(
|
||||
"-g", "--git", default=False, action="store_true",
|
||||
help="use the Git repository backend")
|
||||
group.add_argument(
|
||||
"-r", "--repository", default="repository",
|
||||
help="path to the repository (default: '%(default)s')")
|
||||
verbosity_args(parser)
|
||||
return parser
|
||||
|
||||
|
@ -52,11 +64,19 @@ def main():
|
|||
loop = asyncio.get_event_loop()
|
||||
atexit.register(lambda: loop.close())
|
||||
|
||||
ddb = FlatFileDB("ddb.pyon")
|
||||
pdb = FlatFileDB("pdb.pyon")
|
||||
ddb = FlatFileDB(args.ddb)
|
||||
pdb = FlatFileDB(args.pdb)
|
||||
rtr = Notifier(dict())
|
||||
log = Log(1000)
|
||||
|
||||
if args.git:
|
||||
repo_backend = GitBackend(args.repository)
|
||||
else:
|
||||
repo_backend = FilesystemBackend(args.repository)
|
||||
repository = Repository(repo_backend, log.log)
|
||||
atexit.register(repository.close)
|
||||
repository.scan_async()
|
||||
|
||||
worker_handlers = {
|
||||
"get_device": ddb.get,
|
||||
"get_parameter": pdb.get,
|
||||
|
@ -64,14 +84,11 @@ def main():
|
|||
"update_rt_results": lambda mod: process_mod(rtr, mod),
|
||||
"log": log.log
|
||||
}
|
||||
scheduler = Scheduler(get_last_rid() + 1, worker_handlers)
|
||||
scheduler = Scheduler(get_last_rid() + 1, worker_handlers, repo_backend)
|
||||
worker_handlers["scheduler_submit"] = scheduler.submit
|
||||
scheduler.start()
|
||||
atexit.register(lambda: loop.run_until_complete(scheduler.stop()))
|
||||
|
||||
repository = Repository(log.log)
|
||||
repository.scan_async()
|
||||
|
||||
server_control = Server({
|
||||
"master_ddb": ddb,
|
||||
"master_pdb": pdb,
|
||||
|
|
|
@ -4,6 +4,7 @@ import argparse
|
|||
import textwrap
|
||||
import sys
|
||||
import numpy as np # Needed to use numpy in RPC call arguments on cmd line
|
||||
import pprint
|
||||
|
||||
from artiq.protocols.pc_rpc import Client
|
||||
|
||||
|
@ -29,10 +30,10 @@ def get_argparser():
|
|||
return parser
|
||||
|
||||
|
||||
def list_targets(target_names, id_parameters):
|
||||
def list_targets(target_names, description):
|
||||
print("Target(s): " + ", ".join(target_names))
|
||||
if id_parameters is not None:
|
||||
print("Parameters: " + id_parameters)
|
||||
if description is not None:
|
||||
print("Description: " + description)
|
||||
|
||||
|
||||
def list_methods(remote):
|
||||
|
@ -77,7 +78,7 @@ def call_method(remote, method_name, args):
|
|||
method = getattr(remote, method_name)
|
||||
ret = method(*[eval(arg) for arg in args])
|
||||
if ret is not None:
|
||||
print("{}".format(ret))
|
||||
pprint.pprint(ret)
|
||||
|
||||
|
||||
def main():
|
||||
|
@ -85,7 +86,7 @@ def main():
|
|||
|
||||
remote = Client(args.server, args.port, None)
|
||||
|
||||
targets, id_parameters = remote.get_rpc_id()
|
||||
targets, description = remote.get_rpc_id()
|
||||
|
||||
if args.action != "list-targets":
|
||||
# If no target specified and remote has only one, then use this one.
|
||||
|
@ -99,7 +100,7 @@ def main():
|
|||
remote.select_rpc_target(args.target)
|
||||
|
||||
if args.action == "list-targets":
|
||||
list_targets(targets, id_parameters)
|
||||
list_targets(targets, description)
|
||||
elif args.action == "list-methods":
|
||||
list_methods(remote)
|
||||
elif args.action == "call":
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
#!/usr/bin/env python3
|
||||
# Copyright (C) 2014, 2015 M-Labs Limited
|
||||
# Copyright (C) 2014, 2015 Robert Jordens <jordens@gmail.com>
|
||||
|
||||
import argparse
|
||||
import sys
|
||||
|
@ -57,6 +59,9 @@ class DummyScheduler:
|
|||
def delete(self, rid):
|
||||
logger.info("Deleting RID %s", rid)
|
||||
|
||||
def pause(self):
|
||||
pass
|
||||
|
||||
|
||||
def get_argparser(with_file=True):
|
||||
parser = argparse.ArgumentParser(
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/python
|
||||
# Robert Jordens <jordens@gmail.com>, 2012-2015
|
||||
# Copyright (C) 2012-2015 Robert Jordens <jordens@gmail.com>
|
||||
|
||||
import argparse
|
||||
import time
|
||||
|
|
|
@ -39,7 +39,7 @@ def main():
|
|||
dev = Pdq2(url=args.device, dev=port)
|
||||
try:
|
||||
simple_server_loop({"pdq2": dev}, args.bind, args.port,
|
||||
id_parameters="device=" + str(args.device))
|
||||
description="device=" + str(args.device))
|
||||
finally:
|
||||
dev.close()
|
||||
|
||||
|
|
|
@ -55,14 +55,21 @@ class AD9xxx(Module):
|
|||
dts.oe.eq(~rx)
|
||||
]
|
||||
|
||||
gpio = Signal(flen(pads.sel) + 1)
|
||||
if hasattr(pads, "sel"):
|
||||
sel_len = flen(pads.sel)
|
||||
else:
|
||||
sel_len = flen(pads.sel_n)
|
||||
gpio = Signal(sel_len + 1)
|
||||
gpio_load = Signal()
|
||||
self.sync += If(gpio_load, gpio.eq(bus.dat_w))
|
||||
if hasattr(pads, "rst"):
|
||||
self.comb += pads.rst.eq(gpio[0])
|
||||
else:
|
||||
self.comb += pads.rst_n.eq(~gpio[0])
|
||||
if hasattr(pads, "sel"):
|
||||
self.comb += pads.sel.eq(gpio[1:])
|
||||
else:
|
||||
self.comb += pads.sel_n.eq(~gpio[1:])
|
||||
|
||||
bus_r_gpio = Signal()
|
||||
self.comb += If(bus_r_gpio,
|
||||
|
|
|
@ -26,7 +26,7 @@ fmc_adapter_io = [
|
|||
"LPC:LA11_N LPC:LA12_N LPC:LA11_P LPC:LA12_P "
|
||||
"LPC:LA07_N LPC:LA08_N LPC:LA07_P LPC:LA08_P "
|
||||
"LPC:LA04_N LPC:LA03_N LPC:LA04_P LPC:LA03_P")),
|
||||
Subsignal("sel", Pins("LPC:LA24_N LPC:LA29_P LPC:LA28_P LPC:LA29_N "
|
||||
Subsignal("sel_n", Pins("LPC:LA24_N LPC:LA29_P LPC:LA28_P LPC:LA29_N "
|
||||
"LPC:LA28_N LPC:LA31_P LPC:LA30_P LPC:LA31_N "
|
||||
"LPC:LA30_N LPC:LA33_P LPC:LA33_N")),
|
||||
Subsignal("fud", Pins("LPC:LA21_N")),
|
||||
|
|
|
@ -100,6 +100,7 @@ class _OutputManager(Module):
|
|||
|
||||
self.underflow = Signal() # valid 1 cycle after we, pulsed
|
||||
self.sequence_error = Signal()
|
||||
self.collision_error = Signal()
|
||||
|
||||
# # #
|
||||
|
||||
|
@ -116,13 +117,24 @@ class _OutputManager(Module):
|
|||
# Special cases
|
||||
replace = Signal()
|
||||
sequence_error = Signal()
|
||||
collision_error = Signal()
|
||||
any_error = Signal()
|
||||
nop = Signal()
|
||||
self.sync.rsys += [
|
||||
replace.eq(self.ev.timestamp[fine_ts_width:] \
|
||||
== buf.timestamp[fine_ts_width:]),
|
||||
sequence_error.eq(self.ev.timestamp[fine_ts_width:] \
|
||||
# Note: replace does not perform any RTLink address checks,
|
||||
# i.e. a write to a different address will be silently replaced
|
||||
# as well.
|
||||
replace.eq(self.ev.timestamp == buf.timestamp),
|
||||
# Detect sequence errors on coarse timestamps only
|
||||
# so that they are mutually exclusive with collision errors.
|
||||
sequence_error.eq(self.ev.timestamp[fine_ts_width:]
|
||||
< buf.timestamp[fine_ts_width:])
|
||||
]
|
||||
if fine_ts_width:
|
||||
self.sync.rsys += collision_error.eq(
|
||||
(self.ev.timestamp[fine_ts_width:] == buf.timestamp[fine_ts_width:])
|
||||
& (self.ev.timestamp[:fine_ts_width] != buf.timestamp[:fine_ts_width]))
|
||||
self.comb += any_error.eq(sequence_error | collision_error)
|
||||
if interface.suppress_nop:
|
||||
# disable NOP at reset: do not suppress a first write with all 0s
|
||||
nop_en = Signal(reset=0)
|
||||
|
@ -134,11 +146,14 @@ class _OutputManager(Module):
|
|||
if hasattr(self.ev, a)],
|
||||
default=0)),
|
||||
# buf now contains valid data. enable NOP.
|
||||
If(self.we & ~sequence_error, nop_en.eq(1)),
|
||||
If(self.we & ~any_error, nop_en.eq(1)),
|
||||
# underflows cancel the write. allow it to be retried.
|
||||
If(self.underflow, nop_en.eq(0))
|
||||
]
|
||||
self.comb += self.sequence_error.eq(self.we & sequence_error)
|
||||
self.comb += [
|
||||
self.sequence_error.eq(self.we & sequence_error),
|
||||
self.collision_error.eq(self.we & collision_error)
|
||||
]
|
||||
|
||||
# Buffer read and FIFO write
|
||||
self.comb += fifo.din.eq(buf)
|
||||
|
@ -156,7 +171,7 @@ class _OutputManager(Module):
|
|||
fifo.we.eq(1)
|
||||
)
|
||||
),
|
||||
If(self.we & ~replace & ~nop & ~sequence_error,
|
||||
If(self.we & ~replace & ~nop & ~any_error,
|
||||
fifo.we.eq(1)
|
||||
)
|
||||
)
|
||||
|
@ -165,7 +180,7 @@ class _OutputManager(Module):
|
|||
# Must come after read to handle concurrent read+write properly
|
||||
self.sync.rsys += [
|
||||
buf_just_written.eq(0),
|
||||
If(self.we & ~nop & ~sequence_error,
|
||||
If(self.we & ~nop & ~any_error,
|
||||
buf_just_written.eq(1),
|
||||
buf_pending.eq(1),
|
||||
buf.eq(self.ev)
|
||||
|
@ -286,9 +301,10 @@ class _KernelCSRs(AutoCSR):
|
|||
self.o_address = CSRStorage(address_width)
|
||||
self.o_timestamp = CSRStorage(full_ts_width)
|
||||
self.o_we = CSR()
|
||||
self.o_status = CSRStatus(3)
|
||||
self.o_status = CSRStatus(4)
|
||||
self.o_underflow_reset = CSR()
|
||||
self.o_sequence_error_reset = CSR()
|
||||
self.o_collision_error_reset = CSR()
|
||||
|
||||
if data_width:
|
||||
self.i_data = CSRStatus(data_width)
|
||||
|
@ -369,17 +385,22 @@ class RTIO(Module):
|
|||
|
||||
underflow = Signal()
|
||||
sequence_error = Signal()
|
||||
collision_error = Signal()
|
||||
self.sync.rsys += [
|
||||
If(selected & self.kcsrs.o_underflow_reset.re,
|
||||
underflow.eq(0)),
|
||||
If(selected & self.kcsrs.o_sequence_error_reset.re,
|
||||
sequence_error.eq(0)),
|
||||
If(selected & self.kcsrs.o_collision_error_reset.re,
|
||||
collision_error.eq(0)),
|
||||
If(o_manager.underflow, underflow.eq(1)),
|
||||
If(o_manager.sequence_error, sequence_error.eq(1))
|
||||
If(o_manager.sequence_error, sequence_error.eq(1)),
|
||||
If(o_manager.collision_error, collision_error.eq(1))
|
||||
]
|
||||
o_statuses.append(Cat(~o_manager.writable,
|
||||
underflow,
|
||||
sequence_error))
|
||||
sequence_error,
|
||||
collision_error))
|
||||
|
||||
if channel.interface.i is not None:
|
||||
i_manager = _InputManager(channel.interface.i, self.counter,
|
||||
|
|
|
@ -5,7 +5,7 @@ from artiq.gateware.rtio.phy.wishbone import RT2WB
|
|||
|
||||
|
||||
class _AD9xxx(Module):
|
||||
def __init__(self, ftw_base, pads, nchannels, **kwargs):
|
||||
def __init__(self, ftw_base, pads, nchannels, onehot=False, **kwargs):
|
||||
self.submodules._ll = RenameClockDomains(
|
||||
ad9xxx.AD9xxx(pads, **kwargs), "rio")
|
||||
self.submodules._rt2wb = RT2WB(flen(pads.a)+1, self._ll.bus)
|
||||
|
@ -21,23 +21,29 @@ class _AD9xxx(Module):
|
|||
current_address.eq(self.rtlink.o.address),
|
||||
current_data.eq(self.rtlink.o.data))
|
||||
|
||||
# keep track of the currently selected channel
|
||||
current_channel = Signal(max=nchannels)
|
||||
# keep track of the currently selected channel(s)
|
||||
current_sel = Signal(flen(current_data)-1)
|
||||
self.sync.rio += If(current_address == 2**flen(pads.a) + 1,
|
||||
current_channel.eq(current_data))
|
||||
current_sel.eq(current_data[1:])) # strip reset
|
||||
|
||||
def selected(c):
|
||||
if onehot:
|
||||
return current_sel[c]
|
||||
else:
|
||||
return current_sel == c
|
||||
|
||||
# keep track of frequency tuning words, before they are FUDed
|
||||
ftws = [Signal(32) for i in range(nchannels)]
|
||||
for c, ftw in enumerate(ftws):
|
||||
if flen(pads.d) == 8:
|
||||
self.sync.rio += \
|
||||
If(current_channel == c, [
|
||||
If(selected(c), [
|
||||
If(current_address == ftw_base+i,
|
||||
ftw[i*8:(i+1)*8].eq(current_data))
|
||||
for i in range(4)])
|
||||
elif flen(pads.d) == 16:
|
||||
self.sync.rio += \
|
||||
If(current_channel == c, [
|
||||
If(selected(c), [
|
||||
If(current_address == ftw_base+2*i,
|
||||
ftw[i*16:(i+1)*16].eq(current_data))
|
||||
for i in range(2)])
|
||||
|
@ -46,15 +52,15 @@ class _AD9xxx(Module):
|
|||
|
||||
# FTW to probe on FUD
|
||||
self.sync.rio += If(current_address == 2**flen(pads.a), [
|
||||
If(current_channel == c, probe.eq(ftw))
|
||||
If(selected(c), probe.eq(ftw))
|
||||
for c, (probe, ftw) in enumerate(zip(self.probes, ftws))])
|
||||
|
||||
|
||||
class AD9858(_AD9xxx):
|
||||
def __init__(self, pads, nchannels, **kwargs):
|
||||
_AD9xxx.__init__(self, 0x0a, pads, nchannels, **kwargs)
|
||||
def __init__(self, *args, **kwargs):
|
||||
_AD9xxx.__init__(self, 0x0a, *args, **kwargs)
|
||||
|
||||
|
||||
class AD9914(_AD9xxx):
|
||||
def __init__(self, pads, nchannels, **kwargs):
|
||||
_AD9xxx.__init__(self, 0x2d, pads, nchannels, **kwargs)
|
||||
def __init__(self, *args, **kwargs):
|
||||
_AD9xxx.__init__(self, 0x2d, *args, **kwargs)
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# Copyright (C) 2014, 2015 Robert Jordens <jordens@gmail.com>
|
||||
|
||||
from migen.fhdl.std import *
|
||||
|
||||
from artiq.gateware.rtio.phy import ttl_serdes_generic
|
||||
|
|
|
@ -1,50 +1,77 @@
|
|||
from collections import OrderedDict
|
||||
import numpy as np
|
||||
|
||||
from quamash import QtGui
|
||||
import pyqtgraph as pg
|
||||
from pyqtgraph import dockarea
|
||||
|
||||
|
||||
class _SimpleSettings(QtGui.QDialog):
|
||||
def __init__(self, parent, prev_name, prev_settings,
|
||||
result_list, create_cb):
|
||||
class _BaseSettings(QtGui.QDialog):
|
||||
def __init__(self, parent, window_title, prev_name, create_cb):
|
||||
QtGui.QDialog.__init__(self, parent=parent)
|
||||
self.setWindowTitle(self._window_title)
|
||||
self.setWindowTitle(window_title)
|
||||
|
||||
grid = QtGui.QGridLayout()
|
||||
self.setLayout(grid)
|
||||
self.grid = QtGui.QGridLayout()
|
||||
self.setLayout(self.grid)
|
||||
|
||||
grid.addWidget(QtGui.QLabel("Name:"), 0, 0)
|
||||
self.name = name = QtGui.QLineEdit()
|
||||
grid.addWidget(name, 0, 1)
|
||||
self.grid.addWidget(QtGui.QLabel("Name:"), 0, 0)
|
||||
self.name = QtGui.QLineEdit()
|
||||
self.grid.addWidget(self.name, 0, 1)
|
||||
if prev_name is not None:
|
||||
name.insert(prev_name)
|
||||
self.name.setText(prev_name)
|
||||
|
||||
grid.addWidget(QtGui.QLabel("Result:"))
|
||||
self.result = result = QtGui.QComboBox()
|
||||
grid.addWidget(result, 1, 1)
|
||||
result.addItems(result_list)
|
||||
result.setEditable(True)
|
||||
if "result" in prev_settings:
|
||||
result.setEditText(prev_settings["result"])
|
||||
def on_accept():
|
||||
create_cb(self.name.text(), self.get_input())
|
||||
self.accepted.connect(on_accept)
|
||||
|
||||
def add_buttons(self):
|
||||
buttons = QtGui.QDialogButtonBox(
|
||||
QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Cancel)
|
||||
grid.addWidget(buttons, 2, 0, 1, 2)
|
||||
self.grid.addWidget(buttons, self.grid.rowCount(), 0, 1, 2)
|
||||
buttons.accepted.connect(self.accept)
|
||||
buttons.rejected.connect(self.reject)
|
||||
|
||||
def on_accept():
|
||||
create_cb(name.text(), {"result": result.currentText()})
|
||||
self.accepted.connect(on_accept)
|
||||
|
||||
def accept(self):
|
||||
if self.name.text() and self.result.currentText():
|
||||
if self.name.text() and self.validate_input():
|
||||
QtGui.QDialog.accept(self)
|
||||
|
||||
def validate_input(self):
|
||||
raise NotImplementedError
|
||||
|
||||
def get_input(self):
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
class _SimpleSettings(_BaseSettings):
|
||||
def __init__(self, parent, prev_name, prev_settings,
|
||||
result_list, create_cb):
|
||||
_BaseSettings.__init__(self, parent, self._window_title,
|
||||
prev_name, create_cb)
|
||||
|
||||
self.result_widgets = dict()
|
||||
for row, (has_none, key) in enumerate(self._result_keys):
|
||||
self.grid.addWidget(QtGui.QLabel(key.capitalize() + ":"))
|
||||
w = QtGui.QComboBox()
|
||||
self.grid.addWidget(w, row + 1, 1)
|
||||
if has_none:
|
||||
w.addItem("<None>")
|
||||
w.addItems(result_list)
|
||||
w.setEditable(True)
|
||||
if key in prev_settings:
|
||||
w.setEditText(prev_settings[key])
|
||||
self.result_widgets[key] = w
|
||||
self.add_buttons()
|
||||
|
||||
def validate_input(self):
|
||||
return all(w.currentText() for w in self.result_widgets.values())
|
||||
|
||||
def get_input(self):
|
||||
return {k: v.currentText() for k, v in self.result_widgets.items()}
|
||||
|
||||
|
||||
class NumberDisplaySettings(_SimpleSettings):
|
||||
_window_title = "Number display"
|
||||
_result_keys = [(False, "result")]
|
||||
|
||||
|
||||
class NumberDisplay(dockarea.Dock):
|
||||
|
@ -67,9 +94,16 @@ class NumberDisplay(dockarea.Dock):
|
|||
n = "---"
|
||||
self.number.display(n)
|
||||
|
||||
def save_state(self):
|
||||
return None
|
||||
|
||||
def restore_state(self, state):
|
||||
pass
|
||||
|
||||
|
||||
class XYDisplaySettings(_SimpleSettings):
|
||||
_window_title = "XY plot"
|
||||
_result_keys = [(False, "y"), (True, "x"), (True, "error"), (True, "fit")]
|
||||
|
||||
|
||||
class XYDisplay(dockarea.Dock):
|
||||
|
@ -81,22 +115,62 @@ class XYDisplay(dockarea.Dock):
|
|||
self.addWidget(self.plot)
|
||||
|
||||
def data_sources(self):
|
||||
return {self.settings["result"]}
|
||||
s = {self.settings["y"]}
|
||||
for k in "x", "error", "fit":
|
||||
if self.settings[k] != "<None>":
|
||||
s.add(self.settings[k])
|
||||
return s
|
||||
|
||||
def update_data(self, data):
|
||||
result = self.settings["result"]
|
||||
result_y = self.settings["y"]
|
||||
result_x = self.settings["x"]
|
||||
result_error = self.settings["error"]
|
||||
result_fit = self.settings["fit"]
|
||||
|
||||
try:
|
||||
y = data[result]
|
||||
y = data[result_y]
|
||||
except KeyError:
|
||||
return
|
||||
self.plot.clear()
|
||||
if not y:
|
||||
x = data.get(result_x, None)
|
||||
if x is None:
|
||||
x = list(range(len(y)))
|
||||
error = data.get(result_error, None)
|
||||
fit = data.get(result_fit, None)
|
||||
|
||||
if not y or len(y) != len(x):
|
||||
return
|
||||
self.plot.plot(y)
|
||||
if error is not None and hasattr(error, "__len__"):
|
||||
if not len(error):
|
||||
error = None
|
||||
elif len(error) != len(y):
|
||||
return
|
||||
if fit is not None:
|
||||
if not len(fit):
|
||||
fit = None
|
||||
elif len(fit) != len(y):
|
||||
return
|
||||
|
||||
self.plot.clear()
|
||||
self.plot.plot(x, y, pen=None, symbol="x")
|
||||
if error is not None:
|
||||
# See https://github.com/pyqtgraph/pyqtgraph/issues/211
|
||||
if hasattr(error, "__len__") and not isinstance(error, np.ndarray):
|
||||
error = np.array(error)
|
||||
errbars = pg.ErrorBarItem(x=np.array(x), y=np.array(y), height=error)
|
||||
self.plot.addItem(errbars)
|
||||
if fit is not None:
|
||||
self.plot.plot(x, fit)
|
||||
|
||||
def save_state(self):
|
||||
return self.plot.saveState()
|
||||
|
||||
def restore_state(self, state):
|
||||
self.plot.restoreState(state)
|
||||
|
||||
|
||||
class HistogramDisplaySettings(_SimpleSettings):
|
||||
_window_title = "Histogram"
|
||||
_result_keys = [(False, "y"), (True, "x")]
|
||||
|
||||
|
||||
class HistogramDisplay(dockarea.Dock):
|
||||
|
@ -108,19 +182,35 @@ class HistogramDisplay(dockarea.Dock):
|
|||
self.addWidget(self.plot)
|
||||
|
||||
def data_sources(self):
|
||||
return {self.settings["result"]}
|
||||
s = {self.settings["y"]}
|
||||
if self.settings["x"] != "<None>":
|
||||
s.add(self.settings["x"])
|
||||
return s
|
||||
|
||||
def update_data(self, data):
|
||||
result = self.settings["result"]
|
||||
result_y = self.settings["y"]
|
||||
result_x = self.settings["x"]
|
||||
try:
|
||||
y = data[result]
|
||||
y = data[result_y]
|
||||
if result_x == "<None>":
|
||||
x = None
|
||||
else:
|
||||
x = data[result_x]
|
||||
except KeyError:
|
||||
return
|
||||
if x is None:
|
||||
x = list(range(len(y)+1))
|
||||
|
||||
if y and len(x) == len(y) + 1:
|
||||
self.plot.clear()
|
||||
if not y:
|
||||
return
|
||||
self.plot.plot(x, y, stepMode=True, fillLevel=0, brush=(0, 0, 255, 150))
|
||||
self.plot.plot(x, y, stepMode=True, fillLevel=0,
|
||||
brush=(0, 0, 255, 150))
|
||||
|
||||
def save_state(self):
|
||||
return self.plot.saveState()
|
||||
|
||||
def restore_state(self, state):
|
||||
self.plot.restoreState(state)
|
||||
|
||||
|
||||
display_types = OrderedDict([
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import asyncio
|
||||
import traceback
|
||||
|
||||
from quamash import QtGui, QtCore
|
||||
from pyqtgraph import dockarea
|
||||
|
@ -7,12 +6,13 @@ from pyqtgraph import LayoutWidget
|
|||
|
||||
from artiq.protocols.sync_struct import Subscriber
|
||||
from artiq.protocols import pyon
|
||||
from artiq.gui.tools import DictSyncModel, force_spinbox_value
|
||||
from artiq.gui.tools import DictSyncModel
|
||||
from artiq.gui.scan import ScanController
|
||||
|
||||
|
||||
class _ExplistModel(DictSyncModel):
|
||||
def __init__(self, parent, init):
|
||||
def __init__(self, explorer, parent, init):
|
||||
self.explorer = explorer
|
||||
DictSyncModel.__init__(self,
|
||||
["Experiment"],
|
||||
parent, init)
|
||||
|
@ -23,26 +23,37 @@ class _ExplistModel(DictSyncModel):
|
|||
def convert(self, k, v, column):
|
||||
return k
|
||||
|
||||
def __setitem__(self, k, v):
|
||||
DictSyncModel.__setitem__(self, k, v)
|
||||
if k == self.explorer.selected_key:
|
||||
self.explorer.update_selection(k, k)
|
||||
|
||||
|
||||
class _FreeValueEntry(QtGui.QLineEdit):
|
||||
def __init__(self, procdesc):
|
||||
QtGui.QLineEdit.__init__(self)
|
||||
if "default" in procdesc:
|
||||
self.insert(pyon.encode(procdesc["default"]))
|
||||
self.set_argument_value(procdesc["default"])
|
||||
|
||||
def get_argument_value(self):
|
||||
return pyon.decode(self.text())
|
||||
|
||||
def set_argument_value(self, value):
|
||||
self.setText(pyon.encode(value))
|
||||
|
||||
|
||||
class _BooleanEntry(QtGui.QCheckBox):
|
||||
def __init__(self, procdesc):
|
||||
QtGui.QCheckBox.__init__(self)
|
||||
if "default" in procdesc:
|
||||
self.setChecked(procdesc["default"])
|
||||
self.set_argument_value(procdesc["default"])
|
||||
|
||||
def get_argument_value(self):
|
||||
return self.isChecked()
|
||||
|
||||
def set_argument_value(self, value):
|
||||
self.setChecked(value)
|
||||
|
||||
|
||||
class _EnumerationEntry(QtGui.QComboBox):
|
||||
def __init__(self, procdesc):
|
||||
|
@ -50,44 +61,53 @@ class _EnumerationEntry(QtGui.QComboBox):
|
|||
self.choices = procdesc["choices"]
|
||||
self.addItems(self.choices)
|
||||
if "default" in procdesc:
|
||||
try:
|
||||
idx = self.choices.index(procdesc["default"])
|
||||
except:
|
||||
pass
|
||||
else:
|
||||
self.setCurrentIndex(idx)
|
||||
self.set_argument_value(procdesc["default"])
|
||||
|
||||
def get_argument_value(self):
|
||||
return self.choices[self.currentIndex()]
|
||||
|
||||
def set_argument_value(self, value):
|
||||
idx = self.choices.index(value)
|
||||
self.setCurrentIndex(idx)
|
||||
|
||||
|
||||
class _NumberEntry(QtGui.QDoubleSpinBox):
|
||||
def __init__(self, procdesc):
|
||||
QtGui.QDoubleSpinBox.__init__(self)
|
||||
if procdesc["step"] is not None:
|
||||
self.setDecimals(procdesc["ndecimals"])
|
||||
self.setSingleStep(procdesc["step"])
|
||||
if procdesc["min"] is not None:
|
||||
self.setMinimum(procdesc["min"])
|
||||
else:
|
||||
self.setMinimum(float("-inf"))
|
||||
if procdesc["max"] is not None:
|
||||
self.setMinimum(procdesc["max"])
|
||||
self.setMaximum(procdesc["max"])
|
||||
else:
|
||||
self.setMaximum(float("inf"))
|
||||
if procdesc["unit"]:
|
||||
self.setSuffix(" " + procdesc["unit"])
|
||||
if "default" in procdesc:
|
||||
force_spinbox_value(self, procdesc["default"])
|
||||
self.set_argument_value(procdesc["default"])
|
||||
|
||||
def get_argument_value(self):
|
||||
return self.value()
|
||||
|
||||
def set_argument_value(self, value):
|
||||
self.setValue(value)
|
||||
|
||||
|
||||
class _StringEntry(QtGui.QLineEdit):
|
||||
def __init__(self, procdesc):
|
||||
QtGui.QLineEdit.__init__(self)
|
||||
if "default" in procdesc:
|
||||
self.insert(procdesc["default"])
|
||||
self.set_argument_value(procdesc["default"])
|
||||
|
||||
def get_argument_value(self):
|
||||
return self.text()
|
||||
|
||||
def set_argument_value(self, value):
|
||||
self.setText(value)
|
||||
|
||||
|
||||
_procty_to_entry = {
|
||||
"FreeValue": _FreeValueEntry,
|
||||
|
@ -99,36 +119,98 @@ _procty_to_entry = {
|
|||
}
|
||||
|
||||
|
||||
class _ArgumentSetter(LayoutWidget):
|
||||
def __init__(self, dialog_parent, arguments):
|
||||
LayoutWidget.__init__(self)
|
||||
class _ArgumentEditor(QtGui.QTreeWidget):
|
||||
def __init__(self, dialog_parent):
|
||||
QtGui.QTreeWidget.__init__(self)
|
||||
self.setColumnCount(2)
|
||||
self.header().setResizeMode(QtGui.QHeaderView.ResizeToContents)
|
||||
self.header().setVisible(False)
|
||||
self.setSelectionMode(QtGui.QAbstractItemView.NoSelection)
|
||||
|
||||
self.dialog_parent = dialog_parent
|
||||
self._groups = dict()
|
||||
self.set_arguments([])
|
||||
|
||||
def clear(self):
|
||||
QtGui.QTreeWidget.clear(self)
|
||||
self._groups.clear()
|
||||
|
||||
def _get_group(self, name):
|
||||
if name in self._groups:
|
||||
return self._groups[name]
|
||||
group = QtGui.QTreeWidgetItem([name, ""])
|
||||
for c in 0, 1:
|
||||
group.setBackground(c, QtGui.QBrush(QtGui.QColor(100, 100, 100)))
|
||||
group.setForeground(c, QtGui.QBrush(QtGui.QColor(220, 220, 255)))
|
||||
font = group.font(c)
|
||||
font.setBold(True)
|
||||
group.setFont(c, font)
|
||||
self.addTopLevelItem(group)
|
||||
self._groups[name] = group
|
||||
return group
|
||||
|
||||
def set_arguments(self, arguments):
|
||||
self.clear()
|
||||
|
||||
if not arguments:
|
||||
self.addWidget(QtGui.QLabel("No arguments"), 0, 0)
|
||||
self.addTopLevelItem(QtGui.QTreeWidgetItem(["No arguments", ""]))
|
||||
|
||||
self._args_to_entries = dict()
|
||||
for n, (name, procdesc) in enumerate(arguments):
|
||||
self.addWidget(QtGui.QLabel(name), n, 0)
|
||||
for n, (name, (procdesc, group)) in enumerate(arguments):
|
||||
entry = _procty_to_entry[procdesc["ty"]](procdesc)
|
||||
self.addWidget(entry, n, 1)
|
||||
self._args_to_entries[name] = entry
|
||||
|
||||
def get_argument_values(self):
|
||||
widget_item = QtGui.QTreeWidgetItem([name, ""])
|
||||
if group is None:
|
||||
self.addTopLevelItem(widget_item)
|
||||
else:
|
||||
self._get_group(group).addChild(widget_item)
|
||||
self.setItemWidget(widget_item, 1, entry)
|
||||
|
||||
def get_argument_values(self, show_error_message):
|
||||
r = dict()
|
||||
for arg, entry in self._args_to_entries.items():
|
||||
try:
|
||||
r[arg] = entry.get_argument_value()
|
||||
except:
|
||||
except Exception as e:
|
||||
if show_error_message:
|
||||
msgbox = QtGui.QMessageBox(self.dialog_parent)
|
||||
msgbox.setWindowTitle("Error")
|
||||
msgbox.setText("Failed to obtain value for argument '{}'.\n{}"
|
||||
.format(arg, traceback.format_exc()))
|
||||
msgbox.setText("Failed to obtain value for argument '{}':\n{}"
|
||||
.format(arg, str(e)))
|
||||
msgbox.setStandardButtons(QtGui.QMessageBox.Ok)
|
||||
msgbox.show()
|
||||
return None
|
||||
return r
|
||||
|
||||
def set_argument_values(self, arguments, ignore_errors):
|
||||
for arg, value in arguments.items():
|
||||
try:
|
||||
entry = self._args_to_entries[arg]
|
||||
entry.set_argument_value(value)
|
||||
except:
|
||||
if not ignore_errors:
|
||||
raise
|
||||
|
||||
def save_state(self):
|
||||
expanded = []
|
||||
for k, v in self._groups.items():
|
||||
if v.isExpanded():
|
||||
expanded.append(k)
|
||||
argument_values = self.get_argument_values(False)
|
||||
return {
|
||||
"expanded": expanded,
|
||||
"argument_values": argument_values
|
||||
}
|
||||
|
||||
def restore_state(self, state):
|
||||
self.set_argument_values(state["argument_values"], True)
|
||||
for e in state["expanded"]:
|
||||
try:
|
||||
self._groups[e].setExpanded(True)
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
|
||||
class ExplorerDock(dockarea.Dock):
|
||||
def __init__(self, dialog_parent, status_bar, schedule_ctl):
|
||||
|
@ -145,7 +227,8 @@ class ExplorerDock(dockarea.Dock):
|
|||
self.splitter.addWidget(grid)
|
||||
|
||||
self.el = QtGui.QListView()
|
||||
self.el.selectionChanged = self.update_argsetter
|
||||
self.el.selectionChanged = self._selection_changed
|
||||
self.selected_key = None
|
||||
grid.addWidget(self.el, 0, 0, colspan=4)
|
||||
|
||||
self.datetime = QtGui.QDateTimeEdit()
|
||||
|
@ -163,7 +246,7 @@ class ExplorerDock(dockarea.Dock):
|
|||
grid.addWidget(self.priority, 1, 3)
|
||||
|
||||
self.pipeline = QtGui.QLineEdit()
|
||||
self.pipeline.insert("main")
|
||||
self.pipeline.setText("main")
|
||||
grid.addWidget(QtGui.QLabel("Pipeline:"), 2, 0)
|
||||
grid.addWidget(self.pipeline, 2, 1)
|
||||
|
||||
|
@ -174,22 +257,45 @@ class ExplorerDock(dockarea.Dock):
|
|||
grid.addWidget(submit, 3, 0, colspan=4)
|
||||
submit.clicked.connect(self.submit_clicked)
|
||||
|
||||
self.argsetter = _ArgumentSetter(self.dialog_parent, [])
|
||||
self.splitter.addWidget(self.argsetter)
|
||||
self.argeditor = _ArgumentEditor(self.dialog_parent)
|
||||
self.splitter.addWidget(self.argeditor)
|
||||
self.splitter.setSizes([grid.minimumSizeHint().width(), 1000])
|
||||
self.state = dict()
|
||||
|
||||
def update_selection(self, selected, deselected):
|
||||
if deselected:
|
||||
self.state[deselected] = self.argeditor.save_state()
|
||||
|
||||
def update_argsetter(self, selected, deselected):
|
||||
selected = selected.indexes()
|
||||
if selected:
|
||||
row = selected[0].row()
|
||||
expinfo = self.explist_model.backing_store[selected]
|
||||
self.argeditor.set_arguments(expinfo["arguments"])
|
||||
if selected in self.state:
|
||||
self.argeditor.restore_state(self.state[selected])
|
||||
self.splitter.insertWidget(1, self.argeditor)
|
||||
self.selected_key = selected
|
||||
|
||||
def _sel_to_key(self, selection):
|
||||
selection = selection.indexes()
|
||||
if selection:
|
||||
row = selection[0].row()
|
||||
return self.explist_model.row_to_key[row]
|
||||
else:
|
||||
return None
|
||||
|
||||
def _selection_changed(self, selected, deselected):
|
||||
self.update_selection(self._sel_to_key(selected),
|
||||
self._sel_to_key(deselected))
|
||||
|
||||
def save_state(self):
|
||||
idx = self.el.selectedIndexes()
|
||||
if idx:
|
||||
row = idx[0].row()
|
||||
key = self.explist_model.row_to_key[row]
|
||||
expinfo = self.explist_model.backing_store[key]
|
||||
arguments = expinfo["arguments"]
|
||||
sizes = self.splitter.sizes()
|
||||
self.argsetter.deleteLater()
|
||||
self.argsetter = _ArgumentSetter(self.dialog_parent, arguments)
|
||||
self.splitter.insertWidget(1, self.argsetter)
|
||||
self.splitter.setSizes(sizes)
|
||||
self.state[key] = self.argeditor.save_state()
|
||||
return self.state
|
||||
|
||||
def restore_state(self, state):
|
||||
self.state = state
|
||||
|
||||
def enable_duedate(self):
|
||||
self.datetime_en.setChecked(True)
|
||||
|
@ -205,7 +311,7 @@ class ExplorerDock(dockarea.Dock):
|
|||
yield from self.explist_subscriber.close()
|
||||
|
||||
def init_explist_model(self, init):
|
||||
self.explist_model = _ExplistModel(self.el, init)
|
||||
self.explist_model = _ExplistModel(self, self.el, init)
|
||||
self.el.setModel(self.explist_model)
|
||||
return self.explist_model
|
||||
|
||||
|
@ -213,6 +319,7 @@ class ExplorerDock(dockarea.Dock):
|
|||
def submit(self, pipeline_name, file, class_name, arguments,
|
||||
priority, due_date, flush):
|
||||
expid = {
|
||||
"repo_rev": None,
|
||||
"file": file,
|
||||
"class_name": class_name,
|
||||
"arguments": arguments,
|
||||
|
@ -222,16 +329,13 @@ class ExplorerDock(dockarea.Dock):
|
|||
self.status_bar.showMessage("Submitted RID {}".format(rid))
|
||||
|
||||
def submit_clicked(self):
|
||||
idx = self.el.selectedIndexes()
|
||||
if idx:
|
||||
row = idx[0].row()
|
||||
key = self.explist_model.row_to_key[row]
|
||||
expinfo = self.explist_model.backing_store[key]
|
||||
if self.selected_key is not None:
|
||||
expinfo = self.explist_model.backing_store[self.selected_key]
|
||||
if self.datetime_en.isChecked():
|
||||
due_date = self.datetime.dateTime().toMSecsSinceEpoch()/1000
|
||||
else:
|
||||
due_date = None
|
||||
arguments = self.argsetter.get_argument_values()
|
||||
arguments = self.argeditor.get_argument_values(True)
|
||||
if arguments is None:
|
||||
return
|
||||
asyncio.async(self.submit(self.pipeline.text(),
|
||||
|
|
|
@ -23,7 +23,7 @@ _mode_enc = {
|
|||
|
||||
|
||||
class _TTLWidget(QtGui.QFrame):
|
||||
def __init__(self, send_to_device, channel, force_out, name):
|
||||
def __init__(self, send_to_device, channel, force_out, title):
|
||||
self.send_to_device = send_to_device
|
||||
self.channel = channel
|
||||
self.force_out = force_out
|
||||
|
@ -35,8 +35,9 @@ class _TTLWidget(QtGui.QFrame):
|
|||
|
||||
grid = QtGui.QGridLayout()
|
||||
self.setLayout(grid)
|
||||
label = QtGui.QLabel(name)
|
||||
label = QtGui.QLabel(title)
|
||||
label.setAlignment(QtCore.Qt.AlignCenter)
|
||||
label.setWordWrap(True)
|
||||
grid.addWidget(label, 1, 1)
|
||||
|
||||
self._direction = QtGui.QLabel()
|
||||
|
@ -77,6 +78,12 @@ class _TTLWidget(QtGui.QFrame):
|
|||
self._value.addAction(self._forcein_action)
|
||||
self._forcein_action.triggered.connect(lambda: self.set_mode("in"))
|
||||
|
||||
grid.setRowStretch(1, 1)
|
||||
grid.setRowStretch(2, 0)
|
||||
grid.setRowStretch(3, 0)
|
||||
grid.setRowStretch(4, 0)
|
||||
grid.setRowStretch(5, 1)
|
||||
|
||||
self.set_value(0, False, False)
|
||||
|
||||
def set_mode(self, mode):
|
||||
|
@ -112,11 +119,8 @@ class _TTLWidget(QtGui.QFrame):
|
|||
|
||||
|
||||
class _DDSWidget(QtGui.QFrame):
|
||||
def __init__(self, send_to_device, channel, sysclk, name):
|
||||
self.send_to_device = send_to_device
|
||||
self.channel = channel
|
||||
def __init__(self, sysclk, title):
|
||||
self.sysclk = sysclk
|
||||
self.name = name
|
||||
|
||||
QtGui.QFrame.__init__(self)
|
||||
|
||||
|
@ -125,14 +129,20 @@ class _DDSWidget(QtGui.QFrame):
|
|||
|
||||
grid = QtGui.QGridLayout()
|
||||
self.setLayout(grid)
|
||||
label = QtGui.QLabel(name)
|
||||
label = QtGui.QLabel(title)
|
||||
label.setAlignment(QtCore.Qt.AlignCenter)
|
||||
label.setWordWrap(True)
|
||||
grid.addWidget(label, 1, 1)
|
||||
|
||||
self._value = QtGui.QLabel()
|
||||
self._value.setAlignment(QtCore.Qt.AlignCenter)
|
||||
self._value.setWordWrap(True)
|
||||
grid.addWidget(self._value, 2, 1, 6, 1)
|
||||
|
||||
grid.setRowStretch(1, 1)
|
||||
grid.setRowStretch(2, 0)
|
||||
grid.setRowStretch(3, 1)
|
||||
|
||||
self.set_value(0)
|
||||
|
||||
def set_value(self, ftw):
|
||||
|
@ -160,18 +170,20 @@ class _DeviceManager:
|
|||
return
|
||||
try:
|
||||
if v["type"] == "local":
|
||||
title = k
|
||||
if "comment" in v:
|
||||
title += ": " + v["comment"]
|
||||
if v["module"] == "artiq.coredevice.ttl":
|
||||
channel = v["arguments"]["channel"]
|
||||
force_out = v["class"] == "TTLOut"
|
||||
self.ttl_widgets[channel] = _TTLWidget(
|
||||
self.send_to_device, channel, force_out, k)
|
||||
self.send_to_device, channel, force_out, title)
|
||||
self.ttl_cb()
|
||||
if (v["module"] == "artiq.coredevice.dds"
|
||||
and v["class"] in {"AD9858", "AD9914"}):
|
||||
channel = v["arguments"]["channel"]
|
||||
sysclk = v["arguments"]["sysclk"]
|
||||
self.dds_widgets[channel] = _DDSWidget(
|
||||
self.send_to_device, channel, sysclk, k)
|
||||
self.dds_widgets[channel] = _DDSWidget(sysclk, title)
|
||||
self.dds_cb()
|
||||
except KeyError:
|
||||
pass
|
||||
|
@ -208,6 +220,7 @@ class _MonInjDock(dockarea.Dock):
|
|||
w = self.grid.itemAt(0)
|
||||
for i, (_, w) in enumerate(sorted(widgets, key=itemgetter(0))):
|
||||
self.grid.addWidget(w, i // 4, i % 4)
|
||||
self.grid.setColumnStretch(i % 4, 1)
|
||||
|
||||
|
||||
class MonInj(TaskObject):
|
||||
|
|
|
@ -38,7 +38,7 @@ class ParametersDock(dockarea.Dock):
|
|||
grid.addWidget(self.search, 0, 0)
|
||||
|
||||
self.table = QtGui.QTableView()
|
||||
self.table.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows)
|
||||
self.table.setSelectionMode(QtGui.QAbstractItemView.NoSelection)
|
||||
self.table.horizontalHeader().setResizeMode(
|
||||
QtGui.QHeaderView.ResizeToContents)
|
||||
grid.addWidget(self.table, 1, 0)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import asyncio
|
||||
from collections import OrderedDict
|
||||
from functools import partial
|
||||
import logging
|
||||
|
||||
from quamash import QtGui, QtCore
|
||||
from pyqtgraph import dockarea
|
||||
|
@ -11,6 +12,9 @@ from artiq.gui.tools import DictSyncModel, short_format
|
|||
from artiq.gui.displays import *
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class ResultsModel(DictSyncModel):
|
||||
def __init__(self, parent, init):
|
||||
DictSyncModel.__init__(self, ["Result", "Value"],
|
||||
|
@ -28,6 +32,12 @@ class ResultsModel(DictSyncModel):
|
|||
raise ValueError
|
||||
|
||||
|
||||
def _get_display_type_name(display_cls):
|
||||
for name, (_, cls) in display_types.items():
|
||||
if cls is display_cls:
|
||||
return name
|
||||
|
||||
|
||||
class ResultsDock(dockarea.Dock):
|
||||
def __init__(self, dialog_parent, dock_area):
|
||||
dockarea.Dock.__init__(self, "Results", size=(1500, 500))
|
||||
|
@ -110,3 +120,28 @@ class ResultsDock(dockarea.Dock):
|
|||
dsp.sigClosed.connect(on_close)
|
||||
self.dock_area.addDock(dsp)
|
||||
self.dock_area.floatDock(dsp)
|
||||
return dsp
|
||||
|
||||
def save_state(self):
|
||||
r = dict()
|
||||
for name, display in self.displays.items():
|
||||
r[name] = {
|
||||
"ty": _get_display_type_name(type(display)),
|
||||
"settings": display.settings,
|
||||
"state": display.save_state()
|
||||
}
|
||||
return r
|
||||
|
||||
def restore_state(self, state):
|
||||
for name, desc in state.items():
|
||||
try:
|
||||
dsp = self.create_display(desc["ty"], None, name,
|
||||
desc["settings"])
|
||||
except:
|
||||
logger.warning("Failed to create display '%s'", name,
|
||||
exc_info=True)
|
||||
try:
|
||||
dsp.restore_state(desc["state"])
|
||||
except:
|
||||
logger.warning("Failed to restore display state of '%s'",
|
||||
name, exc_info=True)
|
||||
|
|
|
@ -1,18 +1,21 @@
|
|||
from quamash import QtGui
|
||||
from pyqtgraph import LayoutWidget
|
||||
|
||||
from artiq.gui.tools import force_spinbox_value
|
||||
|
||||
|
||||
class _Range(LayoutWidget):
|
||||
def __init__(self, global_min, global_max, global_step, unit):
|
||||
def __init__(self, global_min, global_max, global_step, unit, ndecimals):
|
||||
LayoutWidget.__init__(self)
|
||||
|
||||
def apply_properties(spinbox):
|
||||
spinbox.setDecimals(ndecimals)
|
||||
if global_min is not None:
|
||||
spinbox.setMinimum(global_min)
|
||||
else:
|
||||
spinbox.setMinimum(float("-inf"))
|
||||
if global_max is not None:
|
||||
spinbox.setMaximum(global_max)
|
||||
else:
|
||||
spinbox.setMaximum(float("inf"))
|
||||
if global_step is not None:
|
||||
spinbox.setSingleStep(global_step)
|
||||
if unit:
|
||||
|
@ -35,14 +38,18 @@ class _Range(LayoutWidget):
|
|||
self.addWidget(self.npoints, 0, 5)
|
||||
|
||||
def set_values(self, min, max, npoints):
|
||||
force_spinbox_value(self.min, min)
|
||||
force_spinbox_value(self.max, max)
|
||||
force_spinbox_value(self.npoints, npoints)
|
||||
self.min.setValue(min)
|
||||
self.max.setValue(max)
|
||||
self.npoints.setValue(npoints)
|
||||
|
||||
def get_values(self):
|
||||
min = self.min.value()
|
||||
max = self.max.value()
|
||||
if min > max:
|
||||
raise ValueError("Minimum scan boundary must be less than maximum")
|
||||
return {
|
||||
"min": self.min.value(),
|
||||
"max": self.max.value(),
|
||||
"min": min,
|
||||
"max": max,
|
||||
"npoints": self.npoints.value()
|
||||
}
|
||||
|
||||
|
@ -57,13 +64,18 @@ class ScanController(LayoutWidget):
|
|||
gmin, gmax = procdesc["global_min"], procdesc["global_max"]
|
||||
gstep = procdesc["global_step"]
|
||||
unit = procdesc["unit"]
|
||||
ndecimals = procdesc["ndecimals"]
|
||||
|
||||
self.v_noscan = QtGui.QDoubleSpinBox()
|
||||
self.v_noscan.setDecimals(ndecimals)
|
||||
if gmin is not None:
|
||||
self.v_noscan.setMinimum(gmin)
|
||||
else:
|
||||
self.v_noscan.setMinimum(float("-inf"))
|
||||
if gmax is not None:
|
||||
self.v_noscan.setMaximum(gmax)
|
||||
if gstep is not None:
|
||||
else:
|
||||
self.v_noscan.setMaximum(float("inf"))
|
||||
self.v_noscan.setSingleStep(gstep)
|
||||
if unit:
|
||||
self.v_noscan.setSuffix(" " + unit)
|
||||
|
@ -72,10 +84,10 @@ class ScanController(LayoutWidget):
|
|||
self.v_noscan_gr.addWidget(self.v_noscan, 0, 1)
|
||||
self.stack.addWidget(self.v_noscan_gr)
|
||||
|
||||
self.v_linear = _Range(gmin, gmax, gstep, unit)
|
||||
self.v_linear = _Range(gmin, gmax, gstep, unit, ndecimals)
|
||||
self.stack.addWidget(self.v_linear)
|
||||
|
||||
self.v_random = _Range(gmin, gmax, gstep, unit)
|
||||
self.v_random = _Range(gmin, gmax, gstep, unit, ndecimals)
|
||||
self.stack.addWidget(self.v_random)
|
||||
|
||||
self.v_explicit = QtGui.QLineEdit()
|
||||
|
@ -96,20 +108,7 @@ class ScanController(LayoutWidget):
|
|||
b.toggled.connect(self.select_page)
|
||||
|
||||
if "default" in procdesc:
|
||||
d = procdesc["default"]
|
||||
if d["ty"] == "NoScan":
|
||||
self.noscan.setChecked(True)
|
||||
force_spinbox_value(self.v_noscan, d["value"])
|
||||
elif d["ty"] == "LinearScan":
|
||||
self.linear.setChecked(True)
|
||||
self.v_linear.set_values(d["min"], d["max"], d["npoints"])
|
||||
elif d["ty"] == "RandomScan":
|
||||
self.random.setChecked(True)
|
||||
self.v_random.set_values(d["min"], d["max"], d["npoints"])
|
||||
elif d["ty"] == "ExplicitScan":
|
||||
self.explicit.setChecked(True)
|
||||
self.v_explicit.insert(" ".join(
|
||||
[str(x) for x in d["sequence"]]))
|
||||
self.set_argument_value(procdesc["default"])
|
||||
else:
|
||||
self.noscan.setChecked(True)
|
||||
|
||||
|
@ -137,3 +136,20 @@ class ScanController(LayoutWidget):
|
|||
elif self.explicit.isChecked():
|
||||
sequence = [float(x) for x in self.v_explicit.text().split()]
|
||||
return {"ty": "ExplicitScan", "sequence": sequence}
|
||||
|
||||
def set_argument_value(self, d):
|
||||
if d["ty"] == "NoScan":
|
||||
self.noscan.setChecked(True)
|
||||
self.v_noscan.setValue(d["value"])
|
||||
elif d["ty"] == "LinearScan":
|
||||
self.linear.setChecked(True)
|
||||
self.v_linear.set_values(d["min"], d["max"], d["npoints"])
|
||||
elif d["ty"] == "RandomScan":
|
||||
self.random.setChecked(True)
|
||||
self.v_random.set_values(d["min"], d["max"], d["npoints"])
|
||||
elif d["ty"] == "ExplicitScan":
|
||||
self.explicit.setChecked(True)
|
||||
self.v_explicit.insert(" ".join(
|
||||
[str(x) for x in d["sequence"]]))
|
||||
else:
|
||||
raise ValueError("Unknown scan type '{}'".format(d["ty"]))
|
||||
|
|
|
@ -5,14 +5,14 @@ from quamash import QtGui, QtCore
|
|||
from pyqtgraph import dockarea
|
||||
|
||||
from artiq.protocols.sync_struct import Subscriber
|
||||
from artiq.gui.tools import DictSyncModel
|
||||
from artiq.gui.tools import elide, DictSyncModel
|
||||
|
||||
|
||||
class _ScheduleModel(DictSyncModel):
|
||||
def __init__(self, parent, init):
|
||||
DictSyncModel.__init__(self,
|
||||
["RID", "Pipeline", "Status", "Prio", "Due date",
|
||||
"File", "Class name"],
|
||||
"Revision", "File", "Class name"],
|
||||
parent, init)
|
||||
|
||||
def sort_key(self, k, v):
|
||||
|
@ -35,8 +35,17 @@ class _ScheduleModel(DictSyncModel):
|
|||
return time.strftime("%m/%d %H:%M:%S",
|
||||
time.localtime(v["due_date"]))
|
||||
elif column == 5:
|
||||
return v["expid"]["file"]
|
||||
expid = v["expid"]
|
||||
if "repo_rev" in expid:
|
||||
r = expid["repo_rev"]
|
||||
if v["repo_msg"]:
|
||||
r += "\n" + elide(v["repo_msg"], 40)
|
||||
return r
|
||||
else:
|
||||
return "Outside repo."
|
||||
elif column == 6:
|
||||
return v["expid"]["file"]
|
||||
elif column == 7:
|
||||
if v["expid"]["class_name"] is None:
|
||||
return ""
|
||||
else:
|
||||
|
@ -57,6 +66,8 @@ class ScheduleDock(dockarea.Dock):
|
|||
self.table.setSelectionMode(QtGui.QAbstractItemView.SingleSelection)
|
||||
self.table.horizontalHeader().setResizeMode(
|
||||
QtGui.QHeaderView.ResizeToContents)
|
||||
self.table.verticalHeader().setResizeMode(
|
||||
QtGui.QHeaderView.ResizeToContents)
|
||||
self.addWidget(self.table)
|
||||
|
||||
self.table.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
import asyncio
|
||||
from collections import OrderedDict
|
||||
import logging
|
||||
|
||||
from artiq.tools import TaskObject
|
||||
from artiq.protocols import pyon
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
# support Qt CamelCase naming scheme for save/restore state
|
||||
def _save_state(obj):
|
||||
method = getattr(obj, "save_state", None)
|
||||
if method is None:
|
||||
method = obj.saveState
|
||||
return method()
|
||||
|
||||
|
||||
def _restore_state(obj, state):
|
||||
method = getattr(obj, "restore_state", None)
|
||||
if method is None:
|
||||
method = obj.restoreState
|
||||
method(state)
|
||||
|
||||
|
||||
class StateManager(TaskObject):
|
||||
def __init__(self, filename, autosave_period=30):
|
||||
self.filename = filename
|
||||
self.autosave_period = autosave_period
|
||||
self.stateful_objects = OrderedDict()
|
||||
|
||||
def register(self, obj, name=None):
|
||||
if name is None:
|
||||
name = obj.__class__.__name__
|
||||
if name in self.stateful_objects:
|
||||
raise RuntimeError("Name '{}' already exists in state"
|
||||
.format(name))
|
||||
self.stateful_objects[name] = obj
|
||||
|
||||
def load(self):
|
||||
try:
|
||||
data = pyon.load_file(self.filename)
|
||||
except FileNotFoundError:
|
||||
logger.info("State database '%s' not found, using defaults",
|
||||
self.filename)
|
||||
return
|
||||
# The state of one object may depend on the state of another,
|
||||
# e.g. the display state may create docks that are referenced in
|
||||
# the area state.
|
||||
# To help address this problem, state is restored in the opposite
|
||||
# order as the stateful objects are registered.
|
||||
for name, obj in reversed(list(self.stateful_objects.items())):
|
||||
state = data.get(name, None)
|
||||
if state is not None:
|
||||
try:
|
||||
_restore_state(obj, state)
|
||||
except:
|
||||
logger.warning("Failed to restore state for object '%s'",
|
||||
name, exc_info=True)
|
||||
|
||||
def save(self):
|
||||
data = dict()
|
||||
for k, v in self.stateful_objects.items():
|
||||
try:
|
||||
data[k] = _save_state(v)
|
||||
except:
|
||||
logger.warning("Failed to save state for object '%s'", k,
|
||||
exc_info=True)
|
||||
pyon.store_file(self.filename, data)
|
||||
|
||||
@asyncio.coroutine
|
||||
def _do(self):
|
||||
try:
|
||||
while True:
|
||||
yield from asyncio.sleep(self.autosave_period)
|
||||
self.save()
|
||||
finally:
|
||||
self.save()
|
|
@ -1,23 +1,35 @@
|
|||
from quamash import QtCore
|
||||
import numpy as np
|
||||
|
||||
|
||||
def force_spinbox_value(spinbox, value):
|
||||
if spinbox.minimum() > value:
|
||||
spinbox.setMinimum(value)
|
||||
if spinbox.maximum() < value:
|
||||
spinbox.setMaximum(value)
|
||||
spinbox.setValue(value)
|
||||
def elide(s, maxlen):
|
||||
elided = False
|
||||
if len(s) > maxlen:
|
||||
s = s[:maxlen]
|
||||
elided = True
|
||||
try:
|
||||
idx = s.index("\n")
|
||||
except ValueError:
|
||||
pass
|
||||
else:
|
||||
s = s[:idx]
|
||||
elided = True
|
||||
if elided:
|
||||
maxlen -= 3
|
||||
if len(s) > maxlen:
|
||||
s = s[:maxlen]
|
||||
s += "..."
|
||||
return s
|
||||
|
||||
|
||||
def short_format(v):
|
||||
if v is None:
|
||||
return "None"
|
||||
t = type(v)
|
||||
if t is int or t is float:
|
||||
if np.issubdtype(t, int) or np.issubdtype(t, float):
|
||||
return str(v)
|
||||
elif t is str:
|
||||
if len(v) < 15:
|
||||
return "\"" + v + "\""
|
||||
else:
|
||||
return "\"" + v[:12] + "\"..."
|
||||
return "\"" + elide(v, 15) + "\""
|
||||
else:
|
||||
r = t.__name__
|
||||
if t is list or t is dict or t is set:
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# Copyright (C) 2014, 2015 Robert Jordens <jordens@gmail.com>
|
||||
|
||||
from artiq.language import core, types, environment, units, scan
|
||||
from artiq.language.core import *
|
||||
from artiq.language.types import *
|
||||
|
|
|
@ -73,18 +73,20 @@ class NumberValue(_SimpleArgProcessor):
|
|||
|
||||
:param unit: A string representing the unit of the value, for user
|
||||
interface (UI) purposes.
|
||||
:param step: The step with with the value should be modified by up/down
|
||||
:param step: The step with which the value should be modified by up/down
|
||||
buttons in a UI.
|
||||
:param min: The minimum value of the argument.
|
||||
:param max: The maximum value of the argument.
|
||||
:param ndecimals: The number of decimals a UI should use.
|
||||
"""
|
||||
def __init__(self, default=NoDefault, unit="", step=None,
|
||||
min=None, max=None):
|
||||
def __init__(self, default=NoDefault, unit="", step=1.0,
|
||||
min=None, max=None, ndecimals=2):
|
||||
_SimpleArgProcessor.__init__(self, default)
|
||||
self.unit = unit
|
||||
self.step = step
|
||||
self.min = min
|
||||
self.max = max
|
||||
self.ndecimals = ndecimals
|
||||
|
||||
def describe(self):
|
||||
d = _SimpleArgProcessor.describe(self)
|
||||
|
@ -92,6 +94,7 @@ class NumberValue(_SimpleArgProcessor):
|
|||
d["step"] = self.step
|
||||
d["min"] = self.min
|
||||
d["max"] = self.max
|
||||
d["ndecimals"] = self.ndecimals
|
||||
return d
|
||||
|
||||
|
||||
|
@ -103,13 +106,14 @@ class StringValue(_SimpleArgProcessor):
|
|||
class HasEnvironment:
|
||||
"""Provides methods to manage the environment of an experiment (devices,
|
||||
parameters, results, arguments)."""
|
||||
def __init__(self, dmgr=None, pdb=None, rdb=None, *,
|
||||
def __init__(self, dmgr=None, pdb=None, rdb=None, *, parent=None,
|
||||
param_override=dict(), default_arg_none=False, **kwargs):
|
||||
self.requested_args = OrderedDict()
|
||||
|
||||
self.__dmgr = dmgr
|
||||
self.__pdb = pdb
|
||||
self.__rdb = rdb
|
||||
self.__parent = parent
|
||||
self.__param_override = param_override
|
||||
self.__default_arg_none = default_arg_none
|
||||
|
||||
|
@ -133,21 +137,34 @@ class HasEnvironment:
|
|||
raise NotImplementedError
|
||||
|
||||
def dbs(self):
|
||||
"""Returns the device manager, the parameter database and the result
|
||||
database, in this order.
|
||||
|
||||
This is the same order that the constructor takes them, allowing
|
||||
sub-objects to be created with this idiom to pass the environment
|
||||
around: ::
|
||||
|
||||
sub_object = SomeLibrary(*self.dbs())
|
||||
"""
|
||||
return self.__dmgr, self.__pdb, self.__rdb
|
||||
|
||||
def get_argument(self, key, processor=None):
|
||||
def get_argument(self, key, processor=None, group=None):
|
||||
"""Retrieves and returns the value of an argument.
|
||||
|
||||
:param key: Name of the argument.
|
||||
:param processor: A description of how to process the argument, such
|
||||
as instances of ``BooleanValue`` and ``NumberValue``.
|
||||
:param group: An optional string that defines what group the argument
|
||||
belongs to, for user interface purposes.
|
||||
"""
|
||||
if not self.__in_build:
|
||||
raise TypeError("get_argument() should only "
|
||||
"be called from build()")
|
||||
if self.__parent is not None and key not in self.__kwargs:
|
||||
return self.__parent.get_argument(key, processor, group)
|
||||
if processor is None:
|
||||
processor = FreeValue()
|
||||
self.requested_args[key] = processor
|
||||
self.requested_args[key] = processor, group
|
||||
try:
|
||||
argval = self.__kwargs[key]
|
||||
except KeyError:
|
||||
|
@ -160,13 +177,15 @@ class HasEnvironment:
|
|||
raise
|
||||
return processor.process(argval)
|
||||
|
||||
def attr_argument(self, key, processor=None):
|
||||
def attr_argument(self, key, processor=None, group=None):
|
||||
"""Sets an argument as attribute. The names of the argument and of the
|
||||
attribute are the same."""
|
||||
setattr(self, key, self.get_argument(key, processor))
|
||||
setattr(self, key, self.get_argument(key, processor, group))
|
||||
|
||||
def get_device(self, key):
|
||||
"""Creates and returns a device driver."""
|
||||
if self.__parent is not None:
|
||||
return self.__parent.get_device(key)
|
||||
if self.__dmgr is None:
|
||||
raise ValueError("Device manager not present")
|
||||
return self.__dmgr.get(key)
|
||||
|
@ -178,6 +197,8 @@ class HasEnvironment:
|
|||
|
||||
def get_parameter(self, key, default=NoDefault):
|
||||
"""Retrieves and returns a parameter."""
|
||||
if self.__parent is not None and key not in self.__param_override:
|
||||
return self.__parent.get_parameter(key, default)
|
||||
if self.__pdb is None:
|
||||
raise ValueError("Parameter database not present")
|
||||
if key in self.__param_override:
|
||||
|
@ -197,18 +218,26 @@ class HasEnvironment:
|
|||
|
||||
def set_parameter(self, key, value):
|
||||
"""Writes the value of a parameter into the parameter database."""
|
||||
if self.__parent is not None:
|
||||
self.__parent.set_parameter(key, value)
|
||||
return
|
||||
if self.__pdb is None:
|
||||
raise ValueError("Parameter database not present")
|
||||
self.__pdb.set(key, value)
|
||||
|
||||
def set_result(self, key, value, realtime=False):
|
||||
def set_result(self, key, value, realtime=False, store=True):
|
||||
"""Writes the value of a result.
|
||||
|
||||
:param realtime: Marks the result as real-time, making it immediately
|
||||
available to clients such as the user interface. Returns a
|
||||
``Notifier`` instance that can be used to modify mutable results
|
||||
(such as lists) and synchronize the modifications with the clients.
|
||||
:param store: Defines if the result should be stored permanently,
|
||||
e.g. in HDF5 output. Default is to store.
|
||||
"""
|
||||
if self.__parent is not None:
|
||||
self.__parent.set_result(key, value, realtime, store)
|
||||
return
|
||||
if self.__rdb is None:
|
||||
raise ValueError("Result database not present")
|
||||
if realtime:
|
||||
|
@ -217,17 +246,13 @@ class HasEnvironment:
|
|||
self.__rdb.rt[key] = value
|
||||
notifier = self.__rdb.rt[key]
|
||||
notifier.kernel_attr_init = False
|
||||
self.__rdb.set_store(key, store)
|
||||
return notifier
|
||||
else:
|
||||
if key in self.__rdb.rt.read:
|
||||
raise ValueError("Result is already realtime")
|
||||
self.__rdb.nrt[key] = value
|
||||
|
||||
def attr_rtresult(self, key, init_value):
|
||||
"""Writes the value of a real-time result and sets the corresponding
|
||||
``Notifier`` as attribute. The names of the result and of the
|
||||
attribute are the same."""
|
||||
setattr(self, key, set_result(key, init_value, True))
|
||||
self.__rdb.set_store(key, store)
|
||||
|
||||
def get_result(self, key):
|
||||
"""Retrieves the value of a result.
|
||||
|
@ -235,6 +260,8 @@ class HasEnvironment:
|
|||
There is no difference between real-time and non-real-time results
|
||||
(this function does not return ``Notifier`` instances).
|
||||
"""
|
||||
if self.__parent is not None:
|
||||
return self.__parent.get_result(key)
|
||||
if self.__rdb is None:
|
||||
raise ValueError("Result database not present")
|
||||
return self.__rdb.get(key)
|
||||
|
@ -287,6 +314,10 @@ class Experiment:
|
|||
|
||||
|
||||
class EnvExperiment(Experiment, HasEnvironment):
|
||||
"""Base class for experiments that use the ``HasEnvironment`` environment
|
||||
manager.
|
||||
|
||||
Most experiment should derive from this class."""
|
||||
pass
|
||||
|
||||
|
||||
|
|
|
@ -1,3 +1,23 @@
|
|||
"""
|
||||
Implementation and management of scan objects.
|
||||
|
||||
A scan object (e.g. :class:`artiq.language.scan.LinearScan`) represents a
|
||||
one-dimensional sweep of a numerical range. Multi-dimensional scans are
|
||||
constructed by combining several scan objects.
|
||||
|
||||
Iterate on a scan object to scan it, e.g. ::
|
||||
|
||||
for variable in self.scan:
|
||||
do_something(variable)
|
||||
|
||||
Iterating multiple times on the same scan object is possible, with the scan
|
||||
restarting at the minimum value each time. Iterating concurrently on the
|
||||
same scan object (e.g. via nested loops) is also supported, and the
|
||||
iterators are independent from each other.
|
||||
|
||||
Scan objects are supported both on the host and the core device.
|
||||
"""
|
||||
|
||||
from random import Random, shuffle
|
||||
import inspect
|
||||
|
||||
|
@ -5,10 +25,17 @@ from artiq.language.core import *
|
|||
from artiq.language.environment import NoDefault, DefaultMissing
|
||||
|
||||
|
||||
__all__ = ["NoScan", "LinearScan", "RandomScan", "ExplicitScan", "Scannable"]
|
||||
__all__ = ["ScanObject",
|
||||
"NoScan", "LinearScan", "RandomScan", "ExplicitScan",
|
||||
"Scannable"]
|
||||
|
||||
|
||||
class NoScan:
|
||||
class ScanObject:
|
||||
pass
|
||||
|
||||
|
||||
class NoScan(ScanObject):
|
||||
"""A scan object that yields a single value."""
|
||||
def __init__(self, value):
|
||||
self.value = value
|
||||
|
||||
|
@ -24,7 +51,9 @@ class NoScan:
|
|||
return {"ty": "NoScan", "value": self.value}
|
||||
|
||||
|
||||
class LinearScan:
|
||||
class LinearScan(ScanObject):
|
||||
"""A scan object that yields a fixed number of increasing evenly
|
||||
spaced values in a range."""
|
||||
def __init__(self, min, max, npoints):
|
||||
self.min = min
|
||||
self.max = max
|
||||
|
@ -46,7 +75,9 @@ class LinearScan:
|
|||
"min": self.min, "max": self.max, "npoints": self.npoints}
|
||||
|
||||
|
||||
class RandomScan:
|
||||
class RandomScan(ScanObject):
|
||||
"""A scan object that yields a fixed number of randomly ordered evenly
|
||||
spaced values in a range."""
|
||||
def __init__(self, min, max, npoints, seed=0):
|
||||
self.sequence = list(LinearScan(min, max, npoints))
|
||||
shuffle(self.sequence, Random(seed).random)
|
||||
|
@ -60,7 +91,8 @@ class RandomScan:
|
|||
"min": self.min, "max": self.max, "npoints": self.npoints}
|
||||
|
||||
|
||||
class ExplicitScan:
|
||||
class ExplicitScan(ScanObject):
|
||||
"""A scan object that yields values from an explicitly defined sequence."""
|
||||
def __init__(self, sequence):
|
||||
self.sequence = sequence
|
||||
|
||||
|
@ -81,14 +113,29 @@ _ty_to_scan = {
|
|||
|
||||
|
||||
class Scannable:
|
||||
def __init__(self, global_min=None, global_max=None, global_step=None,
|
||||
unit="", default=NoDefault):
|
||||
self.global_min = global_min
|
||||
self.global_max = global_max
|
||||
self.global_step = global_step
|
||||
self.unit = unit
|
||||
"""An argument (as defined in :class:`artiq.language.environment`) that
|
||||
takes a scan object.
|
||||
|
||||
:param global_min: The minimum value taken by the scanned variable, common
|
||||
to all scan modes. The user interface takes this value to set the
|
||||
range of its input widgets.
|
||||
:param global_max: Same as global_min, but for the maximum value.
|
||||
:param global_step: The step with which the value should be modified by
|
||||
up/down buttons in a user interface.
|
||||
:param unit: A string representing the unit of the scanned variable, for user
|
||||
interface (UI) purposes.
|
||||
:param ndecimals: The number of decimals a UI should use.
|
||||
"""
|
||||
def __init__(self, default=NoDefault, unit="",
|
||||
global_step=1.0, global_min=None, global_max=None,
|
||||
ndecimals=2):
|
||||
if default is not NoDefault:
|
||||
self.default_value = default
|
||||
self.unit = unit
|
||||
self.global_step = global_step
|
||||
self.global_min = global_min
|
||||
self.global_max = global_max
|
||||
self.ndecimals = ndecimals
|
||||
|
||||
def default(self):
|
||||
if not hasattr(self, "default_value"):
|
||||
|
@ -105,10 +152,11 @@ class Scannable:
|
|||
|
||||
def describe(self):
|
||||
d = {"ty": "Scannable"}
|
||||
d["global_min"] = self.global_min
|
||||
d["global_max"] = self.global_max
|
||||
d["global_step"] = self.global_step
|
||||
d["unit"] = self.unit
|
||||
if hasattr(self, "default_value"):
|
||||
d["default"] = self.default_value.describe()
|
||||
d["unit"] = self.unit
|
||||
d["global_step"] = self.global_step
|
||||
d["global_min"] = self.global_min
|
||||
d["global_max"] = self.global_max
|
||||
d["ndecimals"] = self.ndecimals
|
||||
return d
|
||||
|
|
|
@ -1,24 +1,26 @@
|
|||
import os
|
||||
import logging
|
||||
import asyncio
|
||||
import os
|
||||
import tempfile
|
||||
import shutil
|
||||
import logging
|
||||
|
||||
from artiq.protocols.sync_struct import Notifier
|
||||
from artiq.master.worker import Worker
|
||||
from artiq.tools import exc_to_warning
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def _scan_experiments(log):
|
||||
def _scan_experiments(wd, log):
|
||||
r = dict()
|
||||
for f in os.listdir("repository"):
|
||||
for f in os.listdir(wd):
|
||||
if f.endswith(".py"):
|
||||
try:
|
||||
full_name = os.path.join("repository", f)
|
||||
worker = Worker({"log": lambda message: log("scan", message)})
|
||||
try:
|
||||
description = yield from worker.examine(full_name)
|
||||
description = yield from worker.examine(os.path.join(wd, f))
|
||||
finally:
|
||||
yield from worker.close()
|
||||
for class_name, class_desc in description.items():
|
||||
|
@ -32,7 +34,7 @@ def _scan_experiments(log):
|
|||
name = basename + str(i)
|
||||
i += 1
|
||||
entry = {
|
||||
"file": full_name,
|
||||
"file": f,
|
||||
"class_name": class_name,
|
||||
"arguments": arguments
|
||||
}
|
||||
|
@ -52,19 +54,92 @@ def _sync_explist(target, source):
|
|||
|
||||
|
||||
class Repository:
|
||||
def __init__(self, log_fn):
|
||||
self.explist = Notifier(dict())
|
||||
self._scanning = False
|
||||
def __init__(self, backend, log_fn):
|
||||
self.backend = backend
|
||||
self.log_fn = log_fn
|
||||
|
||||
self.cur_rev = self.backend.get_head_rev()
|
||||
self.backend.request_rev(self.cur_rev)
|
||||
self.explist = Notifier(dict())
|
||||
|
||||
self._scanning = False
|
||||
|
||||
def close(self):
|
||||
# The object cannot be used anymore after calling this method.
|
||||
self.backend.release_rev(self.cur_rev)
|
||||
|
||||
@asyncio.coroutine
|
||||
def scan(self):
|
||||
def scan(self, new_cur_rev=None):
|
||||
if self._scanning:
|
||||
return
|
||||
self._scanning = True
|
||||
new_explist = yield from _scan_experiments(self.log_fn)
|
||||
try:
|
||||
if new_cur_rev is None:
|
||||
new_cur_rev = self.backend.get_head_rev()
|
||||
wd, _ = self.backend.request_rev(new_cur_rev)
|
||||
self.backend.release_rev(self.cur_rev)
|
||||
self.cur_rev = new_cur_rev
|
||||
new_explist = yield from _scan_experiments(wd, self.log_fn)
|
||||
|
||||
_sync_explist(self.explist, new_explist)
|
||||
finally:
|
||||
self._scanning = False
|
||||
|
||||
def scan_async(self):
|
||||
asyncio.async(self.scan())
|
||||
def scan_async(self, new_cur_rev=None):
|
||||
asyncio.async(exc_to_warning(self.scan(new_cur_rev)))
|
||||
|
||||
|
||||
class FilesystemBackend:
|
||||
def __init__(self, root):
|
||||
self.root = os.path.abspath(root)
|
||||
|
||||
def get_head_rev(self):
|
||||
return "N/A"
|
||||
|
||||
def request_rev(self, rev):
|
||||
return self.root, None
|
||||
|
||||
def release_rev(self, rev):
|
||||
pass
|
||||
|
||||
|
||||
class _GitCheckout:
|
||||
def __init__(self, git, rev):
|
||||
self.path = tempfile.mkdtemp()
|
||||
commit = git.get(rev)
|
||||
git.checkout_tree(commit, directory=self.path)
|
||||
self.message = commit.message.strip()
|
||||
self.ref_count = 1
|
||||
logger.info("checked out revision %s into %s", rev, self.path)
|
||||
|
||||
def dispose(self):
|
||||
logger.info("disposing of checkout in folder %s", self.path)
|
||||
shutil.rmtree(self.path)
|
||||
|
||||
|
||||
class GitBackend:
|
||||
def __init__(self, root):
|
||||
# lazy import - make dependency optional
|
||||
import pygit2
|
||||
|
||||
self.git = pygit2.Repository(root)
|
||||
self.checkouts = dict()
|
||||
|
||||
def get_head_rev(self):
|
||||
return str(self.git.head.target)
|
||||
|
||||
def request_rev(self, rev):
|
||||
if rev in self.checkouts:
|
||||
co = self.checkouts[rev]
|
||||
co.ref_count += 1
|
||||
else:
|
||||
co = _GitCheckout(self.git, rev)
|
||||
self.checkouts[rev] = co
|
||||
return co.path, co.message
|
||||
|
||||
def release_rev(self, rev):
|
||||
co = self.checkouts[rev]
|
||||
co.ref_count -= 1
|
||||
if not co.ref_count:
|
||||
co.dispose()
|
||||
del self.checkouts[rev]
|
||||
|
|
|
@ -4,8 +4,7 @@ from enum import Enum
|
|||
from time import time
|
||||
|
||||
from artiq.master.worker import Worker
|
||||
from artiq.tools import (asyncio_wait_or_cancel, asyncio_queue_peek,
|
||||
TaskObject, WaitSet)
|
||||
from artiq.tools import asyncio_wait_or_cancel, TaskObject, Condition
|
||||
from artiq.protocols.sync_struct import Notifier
|
||||
|
||||
|
||||
|
@ -20,7 +19,7 @@ class RunStatus(Enum):
|
|||
running = 4
|
||||
run_done = 5
|
||||
analyzing = 6
|
||||
analyze_done = 7
|
||||
deleting = 7
|
||||
paused = 8
|
||||
|
||||
|
||||
|
@ -47,22 +46,22 @@ def _mk_worker_method(name):
|
|||
|
||||
class Run:
|
||||
def __init__(self, rid, pipeline_name,
|
||||
expid, priority, due_date, flush,
|
||||
worker_handlers, notifier):
|
||||
wd, expid, priority, due_date, flush,
|
||||
pool, **kwargs):
|
||||
# called through pool
|
||||
self.rid = rid
|
||||
self.pipeline_name = pipeline_name
|
||||
self.wd = wd
|
||||
self.expid = expid
|
||||
self.priority = priority
|
||||
self.due_date = due_date
|
||||
self.flush = flush
|
||||
|
||||
self.worker = Worker(worker_handlers)
|
||||
self.worker = Worker(pool.worker_handlers)
|
||||
|
||||
self._status = RunStatus.pending
|
||||
|
||||
self._notifier = notifier
|
||||
self._notifier[self.rid] = {
|
||||
notification = {
|
||||
"pipeline": self.pipeline_name,
|
||||
"expid": self.expid,
|
||||
"priority": self.priority,
|
||||
|
@ -70,6 +69,10 @@ class Run:
|
|||
"flush": self.flush,
|
||||
"status": self._status.name
|
||||
}
|
||||
notification.update(kwargs)
|
||||
self._notifier = pool.notifier
|
||||
self._notifier[self.rid] = notification
|
||||
self._state_changed = pool.state_changed
|
||||
|
||||
@property
|
||||
def status(self):
|
||||
|
@ -80,6 +83,7 @@ class Run:
|
|||
self._status = value
|
||||
if not self.worker.closed.is_set():
|
||||
self._notifier[self.rid]["status"] = self._status.name
|
||||
self._state_changed.notify()
|
||||
|
||||
# The run with the largest priority_key is to be scheduled first
|
||||
def priority_key(self, now=None):
|
||||
|
@ -103,7 +107,8 @@ class Run:
|
|||
|
||||
@asyncio.coroutine
|
||||
def build(self):
|
||||
yield from self._build(self.rid, self.pipeline_name, self.expid,
|
||||
yield from self._build(self.rid, self.pipeline_name,
|
||||
self.wd, self.expid,
|
||||
self.priority)
|
||||
|
||||
prepare = _mk_worker_method("prepare")
|
||||
|
@ -124,22 +129,29 @@ class RIDCounter:
|
|||
|
||||
|
||||
class RunPool:
|
||||
def __init__(self, ridc, worker_handlers, notifier):
|
||||
def __init__(self, ridc, worker_handlers, notifier, repo_backend):
|
||||
self.runs = dict()
|
||||
self.submitted_cb = None
|
||||
self.state_changed = Condition()
|
||||
|
||||
self._ridc = ridc
|
||||
self._worker_handlers = worker_handlers
|
||||
self._notifier = notifier
|
||||
self.ridc = ridc
|
||||
self.worker_handlers = worker_handlers
|
||||
self.notifier = notifier
|
||||
self.repo_backend = repo_backend
|
||||
|
||||
def submit(self, expid, priority, due_date, flush, pipeline_name):
|
||||
# called through scheduler
|
||||
rid = self._ridc.get()
|
||||
run = Run(rid, pipeline_name, expid, priority, due_date, flush,
|
||||
self._worker_handlers, self._notifier)
|
||||
# mutates expid to insert head repository revision if None.
|
||||
# called through scheduler.
|
||||
rid = self.ridc.get()
|
||||
if "repo_rev" in expid:
|
||||
if expid["repo_rev"] is None:
|
||||
expid["repo_rev"] = self.repo_backend.get_head_rev()
|
||||
wd, repo_msg = self.repo_backend.request_rev(expid["repo_rev"])
|
||||
else:
|
||||
wd, repo_msg = None, None
|
||||
run = Run(rid, pipeline_name, wd, expid, priority, due_date, flush,
|
||||
self, repo_msg=repo_msg)
|
||||
self.runs[rid] = run
|
||||
if self.submitted_cb is not None:
|
||||
self.submitted_cb()
|
||||
self.state_changed.notify()
|
||||
return rid
|
||||
|
||||
@asyncio.coroutine
|
||||
|
@ -147,47 +159,75 @@ class RunPool:
|
|||
# called through deleter
|
||||
if rid not in self.runs:
|
||||
return
|
||||
yield from self.runs[rid].close()
|
||||
run = self.runs[rid]
|
||||
yield from run.close()
|
||||
if "repo_rev" in run.expid:
|
||||
self.repo_backend.release_rev(run.expid["repo_rev"])
|
||||
del self.runs[rid]
|
||||
|
||||
|
||||
class PrepareStage(TaskObject):
|
||||
def __init__(self, flush_tracker, delete_cb, pool, outq):
|
||||
self.flush_tracker = flush_tracker
|
||||
self.delete_cb = delete_cb
|
||||
def __init__(self, pool, delete_cb):
|
||||
self.pool = pool
|
||||
self.outq = outq
|
||||
self.delete_cb = delete_cb
|
||||
|
||||
self.pool_submitted = asyncio.Event()
|
||||
self.pool.submitted_cb = lambda: self.pool_submitted.set()
|
||||
|
||||
@asyncio.coroutine
|
||||
def _push_runs(self):
|
||||
"""Pushes all runs that have no due date of have a due date in the
|
||||
past.
|
||||
|
||||
Returns the time before the next schedulable run, or None if the
|
||||
pool is empty."""
|
||||
while True:
|
||||
def _get_run(self):
|
||||
"""If a run should get prepared now, return it.
|
||||
Otherwise, return a float representing the time before the next timed
|
||||
run becomes due, or None if there is no such run."""
|
||||
now = time()
|
||||
pending_runs = filter(lambda r: r.status == RunStatus.pending,
|
||||
self.pool.runs.values())
|
||||
try:
|
||||
run = max(pending_runs, key=lambda r: r.priority_key(now))
|
||||
candidate = max(pending_runs, key=lambda r: r.priority_key(now))
|
||||
except ValueError:
|
||||
# pending_runs is an empty sequence
|
||||
return None
|
||||
if run.due_date is None or run.due_date < now:
|
||||
|
||||
prepared_runs = filter(lambda r: r.status == RunStatus.prepare_done,
|
||||
self.pool.runs.values())
|
||||
try:
|
||||
top_prepared_run = max(prepared_runs,
|
||||
key=lambda r: r.priority_key())
|
||||
except ValueError:
|
||||
# there are no existing prepared runs - go ahead with <candidate>
|
||||
pass
|
||||
else:
|
||||
# prepare <candidate> (as well) only if it has higher priority than
|
||||
# the highest priority prepared run
|
||||
if top_prepared_run.priority_key() >= candidate.priority_key():
|
||||
return None
|
||||
|
||||
if candidate.due_date is None or candidate.due_date < now:
|
||||
return candidate
|
||||
else:
|
||||
return candidate.due_date - now
|
||||
|
||||
@asyncio.coroutine
|
||||
def _do(self):
|
||||
while True:
|
||||
run = self._get_run()
|
||||
if run is None:
|
||||
yield from self.pool.state_changed.wait()
|
||||
elif isinstance(run, float):
|
||||
yield from asyncio_wait_or_cancel([self.pool.state_changed.wait()],
|
||||
timeout=run)
|
||||
else:
|
||||
if run.flush:
|
||||
run.status = RunStatus.flushing
|
||||
while not all(r.status in (RunStatus.pending,
|
||||
RunStatus.deleting)
|
||||
or r is run
|
||||
for r in self.pool.runs.values()):
|
||||
ev = [self.pool.state_changed.wait(),
|
||||
run.worker.closed.wait()]
|
||||
yield from asyncio_wait_or_cancel(
|
||||
[self.flush_tracker.wait_empty(),
|
||||
run.worker.closed.wait()],
|
||||
return_when=asyncio.FIRST_COMPLETED)
|
||||
ev, return_when=asyncio.FIRST_COMPLETED)
|
||||
if run.worker.closed.is_set():
|
||||
break
|
||||
if run.worker.closed.is_set():
|
||||
continue
|
||||
run.status = RunStatus.preparing
|
||||
self.flush_tracker.add(run.rid)
|
||||
try:
|
||||
yield from run.build()
|
||||
yield from run.prepare()
|
||||
|
@ -196,44 +236,38 @@ class PrepareStage(TaskObject):
|
|||
"deleting RID %d",
|
||||
run.rid, exc_info=True)
|
||||
self.delete_cb(run.rid)
|
||||
else:
|
||||
run.status = RunStatus.prepare_done
|
||||
yield from self.outq.put(run)
|
||||
else:
|
||||
return run.due_date - now
|
||||
|
||||
@asyncio.coroutine
|
||||
def _do(self):
|
||||
while True:
|
||||
next_timed_in = yield from self._push_runs()
|
||||
if next_timed_in is None:
|
||||
# pool is empty - wait for something to be added to it
|
||||
yield from self.pool_submitted.wait()
|
||||
else:
|
||||
# wait for next_timed_in seconds, or until the pool is modified
|
||||
yield from asyncio_wait_or_cancel([self.pool_submitted.wait()],
|
||||
timeout=next_timed_in)
|
||||
self.pool_submitted.clear()
|
||||
|
||||
|
||||
class RunStage(TaskObject):
|
||||
def __init__(self, delete_cb, inq, outq):
|
||||
def __init__(self, pool, delete_cb):
|
||||
self.pool = pool
|
||||
self.delete_cb = delete_cb
|
||||
self.inq = inq
|
||||
self.outq = outq
|
||||
|
||||
def _get_run(self):
|
||||
prepared_runs = filter(lambda r: r.status == RunStatus.prepare_done,
|
||||
self.pool.runs.values())
|
||||
try:
|
||||
r = max(prepared_runs, key=lambda r: r.priority_key())
|
||||
except ValueError:
|
||||
# prepared_runs is an empty sequence
|
||||
r = None
|
||||
return r
|
||||
|
||||
@asyncio.coroutine
|
||||
def _do(self):
|
||||
stack = []
|
||||
|
||||
while True:
|
||||
try:
|
||||
next_irun = asyncio_queue_peek(self.inq)
|
||||
except asyncio.QueueEmpty:
|
||||
next_irun = None
|
||||
next_irun = self._get_run()
|
||||
if not stack or (
|
||||
next_irun is not None and
|
||||
next_irun.priority_key() > stack[-1].priority_key()):
|
||||
stack.append((yield from self.inq.get()))
|
||||
while next_irun is None:
|
||||
yield from self.pool.state_changed.wait()
|
||||
next_irun = self._get_run()
|
||||
stack.append(next_irun)
|
||||
|
||||
run = stack.pop()
|
||||
try:
|
||||
|
@ -251,21 +285,33 @@ class RunStage(TaskObject):
|
|||
else:
|
||||
if completed:
|
||||
run.status = RunStatus.run_done
|
||||
yield from self.outq.put(run)
|
||||
else:
|
||||
run.status = RunStatus.paused
|
||||
stack.append(run)
|
||||
|
||||
|
||||
class AnalyzeStage(TaskObject):
|
||||
def __init__(self, delete_cb, inq):
|
||||
def __init__(self, pool, delete_cb):
|
||||
self.pool = pool
|
||||
self.delete_cb = delete_cb
|
||||
self.inq = inq
|
||||
|
||||
def _get_run(self):
|
||||
run_runs = filter(lambda r: r.status == RunStatus.run_done,
|
||||
self.pool.runs.values())
|
||||
try:
|
||||
r = max(run_runs, key=lambda r: r.priority_key())
|
||||
except ValueError:
|
||||
# run_runs is an empty sequence
|
||||
r = None
|
||||
return r
|
||||
|
||||
@asyncio.coroutine
|
||||
def _do(self):
|
||||
while True:
|
||||
run = yield from self.inq.get()
|
||||
run = self._get_run()
|
||||
while run is None:
|
||||
yield from self.pool.state_changed.wait()
|
||||
run = self._get_run()
|
||||
run.status = RunStatus.analyzing
|
||||
try:
|
||||
yield from run.analyze()
|
||||
|
@ -275,22 +321,16 @@ class AnalyzeStage(TaskObject):
|
|||
"deleting RID %d",
|
||||
run.rid, exc_info=True)
|
||||
self.delete_cb(run.rid)
|
||||
run.status = RunStatus.analyze_done
|
||||
else:
|
||||
self.delete_cb(run.rid)
|
||||
|
||||
|
||||
class Pipeline:
|
||||
def __init__(self, ridc, deleter, worker_handlers, notifier):
|
||||
flush_tracker = WaitSet()
|
||||
def delete_cb(rid):
|
||||
deleter.delete(rid)
|
||||
flush_tracker.discard(rid)
|
||||
self.pool = RunPool(ridc, worker_handlers, notifier)
|
||||
self._prepare = PrepareStage(flush_tracker, delete_cb,
|
||||
self.pool, asyncio.Queue(maxsize=1))
|
||||
self._run = RunStage(delete_cb,
|
||||
self._prepare.outq, asyncio.Queue(maxsize=1))
|
||||
self._analyze = AnalyzeStage(delete_cb, self._run.outq)
|
||||
def __init__(self, ridc, deleter, worker_handlers, notifier, repo_backend):
|
||||
self.pool = RunPool(ridc, worker_handlers, notifier, repo_backend)
|
||||
self._prepare = PrepareStage(self.pool, deleter.delete)
|
||||
self._run = RunStage(self.pool, deleter.delete)
|
||||
self._analyze = AnalyzeStage(self.pool, deleter.delete)
|
||||
|
||||
def start(self):
|
||||
self._prepare.start()
|
||||
|
@ -312,6 +352,10 @@ class Deleter(TaskObject):
|
|||
|
||||
def delete(self, rid):
|
||||
logger.debug("delete request for RID %d", rid)
|
||||
for pipeline in self._pipelines.values():
|
||||
if rid in pipeline.pool.runs:
|
||||
pipeline.pool.runs[rid].status = RunStatus.deleting
|
||||
break
|
||||
self._queue.put_nowait(rid)
|
||||
|
||||
@asyncio.coroutine
|
||||
|
@ -348,11 +392,12 @@ class Deleter(TaskObject):
|
|||
|
||||
|
||||
class Scheduler:
|
||||
def __init__(self, next_rid, worker_handlers):
|
||||
def __init__(self, next_rid, worker_handlers, repo_backend):
|
||||
self.notifier = Notifier(dict())
|
||||
|
||||
self._pipelines = dict()
|
||||
self._worker_handlers = worker_handlers
|
||||
self._repo_backend = repo_backend
|
||||
self._terminated = False
|
||||
|
||||
self._ridc = RIDCounter(next_rid)
|
||||
|
@ -374,6 +419,7 @@ class Scheduler:
|
|||
logger.warning("some pipelines were not garbage-collected")
|
||||
|
||||
def submit(self, pipeline_name, expid, priority, due_date, flush):
|
||||
# mutates expid to insert head repository revision if None
|
||||
if self._terminated:
|
||||
return
|
||||
try:
|
||||
|
@ -381,7 +427,8 @@ class Scheduler:
|
|||
except KeyError:
|
||||
logger.debug("creating pipeline '%s'", pipeline_name)
|
||||
pipeline = Pipeline(self._ridc, self._deleter,
|
||||
self._worker_handlers, self.notifier)
|
||||
self._worker_handlers, self.notifier,
|
||||
self._repo_backend)
|
||||
self._pipelines[pipeline_name] = pipeline
|
||||
pipeline.start()
|
||||
return pipeline.pool.submit(expid, priority, due_date, flush, pipeline_name)
|
||||
|
|
|
@ -209,13 +209,14 @@ class Worker:
|
|||
return completed
|
||||
|
||||
@asyncio.coroutine
|
||||
def build(self, rid, pipeline_name, expid, priority, timeout=15.0):
|
||||
def build(self, rid, pipeline_name, wd, expid, priority, timeout=15.0):
|
||||
self.rid = rid
|
||||
yield from self._create_process()
|
||||
yield from self._worker_action(
|
||||
{"action": "build",
|
||||
"rid": rid,
|
||||
"pipeline_name": pipeline_name,
|
||||
"wd": wd,
|
||||
"expid": expid,
|
||||
"priority": priority},
|
||||
timeout)
|
||||
|
|
|
@ -91,6 +91,7 @@ class ResultDB:
|
|||
def __init__(self):
|
||||
self.rt = Notifier(dict())
|
||||
self.nrt = dict()
|
||||
self.store = set()
|
||||
|
||||
def get(self, key):
|
||||
try:
|
||||
|
@ -98,9 +99,17 @@ class ResultDB:
|
|||
except KeyError:
|
||||
return self.rt[key].read
|
||||
|
||||
def set_store(self, key, store):
|
||||
if store:
|
||||
self.store.add(key)
|
||||
else:
|
||||
self.store.discard(key)
|
||||
|
||||
def write_hdf5(self, f):
|
||||
result_dict_to_hdf5(f, self.rt.read)
|
||||
result_dict_to_hdf5(f, self.nrt)
|
||||
result_dict_to_hdf5(
|
||||
f, {k: v for k, v in self.rt.read.items() if k in self.store})
|
||||
result_dict_to_hdf5(
|
||||
f, {k: v for k, v in self.nrt.items() if k in self.store})
|
||||
|
||||
|
||||
def _create_device(desc, dmgr):
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import sys
|
||||
import time
|
||||
import os
|
||||
|
||||
from artiq.protocols import pyon
|
||||
from artiq.tools import file_import
|
||||
|
@ -44,8 +45,6 @@ def make_parent_action(action, argnames, exception=ParentActionError):
|
|||
return parent_action
|
||||
|
||||
|
||||
|
||||
|
||||
class LogForwarder:
|
||||
def __init__(self):
|
||||
self.buffer = ""
|
||||
|
@ -138,6 +137,8 @@ class DummyPDB:
|
|||
def examine(dmgr, pdb, rdb, file):
|
||||
module = file_import(file)
|
||||
for class_name, exp_class in module.__dict__.items():
|
||||
if class_name[0] == "_":
|
||||
continue
|
||||
if is_experiment(exp_class):
|
||||
if exp_class.__doc__ is None:
|
||||
name = class_name
|
||||
|
@ -146,8 +147,8 @@ def examine(dmgr, pdb, rdb, file):
|
|||
if name[-1] == ".":
|
||||
name = name[:-1]
|
||||
exp_inst = exp_class(dmgr, pdb, rdb, default_arg_none=True)
|
||||
arguments = [(k, v.describe())
|
||||
for k, v in exp_inst.requested_args.items()]
|
||||
arguments = [(k, (proc.describe(), group))
|
||||
for k, (proc, group) in exp_inst.requested_args.items()]
|
||||
register_experiment(class_name, name, arguments)
|
||||
|
||||
|
||||
|
@ -173,7 +174,12 @@ def main():
|
|||
start_time = time.localtime()
|
||||
rid = obj["rid"]
|
||||
expid = obj["expid"]
|
||||
exp = get_exp(expid["file"], expid["class_name"])
|
||||
if obj["wd"] is not None:
|
||||
# Using repository
|
||||
expf = os.path.join(obj["wd"], expid["file"])
|
||||
else:
|
||||
expf = expid["file"]
|
||||
exp = get_exp(expf, expid["class_name"])
|
||||
dmgr.virtual_devices["scheduler"].set_run_info(
|
||||
obj["pipeline_name"], expid, obj["priority"])
|
||||
exp_inst = exp(dmgr, ParentPDB, rdb,
|
||||
|
@ -192,6 +198,11 @@ def main():
|
|||
f = get_hdf5_output(start_time, rid, exp.__name__)
|
||||
try:
|
||||
rdb.write_hdf5(f)
|
||||
if "repo_rev" in expid:
|
||||
rr = expid["repo_rev"]
|
||||
dtype = "S{}".format(len(rr))
|
||||
dataset = f.create_dataset("repo_rev", (), dtype)
|
||||
dataset[()] = rr.encode()
|
||||
finally:
|
||||
f.close()
|
||||
put_object({"action": "completed"})
|
||||
|
|
|
@ -5,16 +5,9 @@ from artiq.protocols.sync_struct import Notifier
|
|||
|
||||
|
||||
class FlatFileDB:
|
||||
def __init__(self, filename, default_data=None):
|
||||
def __init__(self, filename):
|
||||
self.filename = filename
|
||||
try:
|
||||
data = pyon.load_file(self.filename)
|
||||
except FileNotFoundError:
|
||||
if default_data is None:
|
||||
raise
|
||||
else:
|
||||
data = default_data
|
||||
self.data = Notifier(data)
|
||||
self.data = Notifier(pyon.load_file(self.filename))
|
||||
self.hooks = []
|
||||
|
||||
def save(self):
|
||||
|
|
|
@ -18,6 +18,7 @@ import threading
|
|||
import time
|
||||
import logging
|
||||
import inspect
|
||||
from operator import itemgetter
|
||||
|
||||
from artiq.protocols import pyon
|
||||
from artiq.protocols.asyncio_server import AsyncioServer as _AsyncioServer
|
||||
|
@ -78,7 +79,7 @@ class Client:
|
|||
|
||||
server_identification = self.__recv()
|
||||
self.__target_names = server_identification["targets"]
|
||||
self.__id_parameters = server_identification["parameters"]
|
||||
self.__description = server_identification["description"]
|
||||
if target_name is not None:
|
||||
self.select_rpc_target(target_name)
|
||||
except:
|
||||
|
@ -93,9 +94,9 @@ class Client:
|
|||
self.__socket.sendall((target_name + "\n").encode())
|
||||
|
||||
def get_rpc_id(self):
|
||||
"""Returns a tuple (target_names, id_parameters) containing the
|
||||
"""Returns a tuple (target_names, description) containing the
|
||||
identification information of the server."""
|
||||
return (self.__target_names, self.__id_parameters)
|
||||
return (self.__target_names, self.__description)
|
||||
|
||||
def close_rpc(self):
|
||||
"""Closes the connection to the RPC server.
|
||||
|
@ -156,7 +157,7 @@ class AsyncioClient:
|
|||
self.__reader = None
|
||||
self.__writer = None
|
||||
self.__target_names = None
|
||||
self.__id_parameters = None
|
||||
self.__description = None
|
||||
|
||||
@asyncio.coroutine
|
||||
def connect_rpc(self, host, port, target_name):
|
||||
|
@ -169,7 +170,7 @@ class AsyncioClient:
|
|||
self.__writer.write(_init_string)
|
||||
server_identification = yield from self.__recv()
|
||||
self.__target_names = server_identification["targets"]
|
||||
self.__id_parameters = server_identification["parameters"]
|
||||
self.__description = server_identification["description"]
|
||||
if target_name is not None:
|
||||
self.select_rpc_target(target_name)
|
||||
except:
|
||||
|
@ -185,9 +186,9 @@ class AsyncioClient:
|
|||
self.__writer.write((target_name + "\n").encode())
|
||||
|
||||
def get_rpc_id(self):
|
||||
"""Returns a tuple (target_names, id_parameters) containing the
|
||||
"""Returns a tuple (target_names, description) containing the
|
||||
identification information of the server."""
|
||||
return (self.__target_names, self.__id_parameters)
|
||||
return (self.__target_names, self.__description)
|
||||
|
||||
def close_rpc(self):
|
||||
"""Closes the connection to the RPC server.
|
||||
|
@ -198,7 +199,7 @@ class AsyncioClient:
|
|||
self.__reader = None
|
||||
self.__writer = None
|
||||
self.__target_names = None
|
||||
self.__id_parameters = None
|
||||
self.__description = None
|
||||
|
||||
def __send(self, obj):
|
||||
line = pyon.encode(obj) + "\n"
|
||||
|
@ -240,7 +241,8 @@ class BestEffortClient:
|
|||
network errors are suppressed and connections are retried in the
|
||||
background.
|
||||
|
||||
RPC calls that failed because of network errors return ``None``.
|
||||
RPC calls that failed because of network errors return ``None``. Other RPC
|
||||
calls are blocking and return the correct value.
|
||||
|
||||
:param firstcon_timeout: Timeout to use during the first (blocking)
|
||||
connection attempt at object initialization.
|
||||
|
@ -396,13 +398,20 @@ class Server(_AsyncioServer):
|
|||
:param targets: A dictionary of objects providing the RPC methods to be
|
||||
exposed to the client. Keys are names identifying each object.
|
||||
Clients select one of these objects using its name upon connection.
|
||||
:param id_parameters: An optional human-readable string giving more
|
||||
information about the parameters of the server.
|
||||
:param description: An optional human-readable string giving more
|
||||
information about the server.
|
||||
:param builtin_terminate: If set, the server provides a built-in
|
||||
``terminate`` method that unblocks any tasks waiting on
|
||||
``wait_terminate``. This is useful to handle server termination
|
||||
requests from clients.
|
||||
"""
|
||||
def __init__(self, targets, id_parameters=None):
|
||||
def __init__(self, targets, description=None, builtin_terminate=False):
|
||||
_AsyncioServer.__init__(self)
|
||||
self.targets = targets
|
||||
self.id_parameters = id_parameters
|
||||
self.description = description
|
||||
self.builtin_terminate = builtin_terminate
|
||||
if builtin_terminate:
|
||||
self._terminate_request = asyncio.Event()
|
||||
|
||||
@asyncio.coroutine
|
||||
def _handle_connection_cr(self, reader, writer):
|
||||
|
@ -413,7 +422,7 @@ class Server(_AsyncioServer):
|
|||
|
||||
obj = {
|
||||
"targets": sorted(self.targets.keys()),
|
||||
"parameters": self.id_parameters
|
||||
"description": self.description
|
||||
}
|
||||
line = pyon.encode(obj) + "\n"
|
||||
writer.write(line.encode())
|
||||
|
@ -445,9 +454,24 @@ class Server(_AsyncioServer):
|
|||
argspec = inspect.getfullargspec(method)
|
||||
doc["methods"][name] = (dict(argspec.__dict__),
|
||||
inspect.getdoc(method))
|
||||
if self.builtin_terminate:
|
||||
doc["methods"]["terminate"] = (
|
||||
{
|
||||
"args": ["self"],
|
||||
"defaults": None,
|
||||
"varargs": None,
|
||||
"varkw": None,
|
||||
"kwonlyargs": [],
|
||||
"kwonlydefaults": [],
|
||||
},
|
||||
"Terminate the server.")
|
||||
obj = {"status": "ok", "ret": doc}
|
||||
elif obj["action"] == "call":
|
||||
logger.debug("calling %s", _PrettyPrintCall(obj))
|
||||
if self.builtin_terminate and obj["name"] == "terminate":
|
||||
self._terminate_request.set()
|
||||
obj = {"status": "ok", "ret": None}
|
||||
else:
|
||||
method = getattr(target, obj["name"])
|
||||
ret = method(*obj["args"], **obj["kwargs"])
|
||||
obj = {"status": "ok", "ret": ret}
|
||||
|
@ -462,18 +486,23 @@ class Server(_AsyncioServer):
|
|||
finally:
|
||||
writer.close()
|
||||
|
||||
@asyncio.coroutine
|
||||
def wait_terminate(self):
|
||||
yield from self._terminate_request.wait()
|
||||
|
||||
def simple_server_loop(targets, host, port, id_parameters=None):
|
||||
"""Runs a server until an exception is raised (e.g. the user hits Ctrl-C).
|
||||
|
||||
def simple_server_loop(targets, host, port, description=None):
|
||||
"""Runs a server until an exception is raised (e.g. the user hits Ctrl-C)
|
||||
or termination is requested by a client.
|
||||
|
||||
See ``Server`` for a description of the parameters.
|
||||
"""
|
||||
loop = asyncio.get_event_loop()
|
||||
try:
|
||||
server = Server(targets, id_parameters)
|
||||
server = Server(targets, description, True)
|
||||
loop.run_until_complete(server.start(host, port))
|
||||
try:
|
||||
loop.run_forever()
|
||||
loop.run_until_complete(server.wait_terminate())
|
||||
finally:
|
||||
loop.run_until_complete(server.stop())
|
||||
finally:
|
||||
|
|
|
@ -153,7 +153,7 @@ def _npscalar(ty, data):
|
|||
|
||||
|
||||
_eval_dict = {
|
||||
"__builtins__": None,
|
||||
"__builtins__": {},
|
||||
|
||||
"null": None,
|
||||
"false": False,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import inspect
|
||||
from pythonparser import parse, ast
|
||||
|
||||
import llvmlite_or1k.ir as ll
|
||||
import llvmlite_artiq.ir as ll
|
||||
|
||||
from artiq.py2llvm.values import VGeneric, operators
|
||||
from artiq.py2llvm.base_types import VBool, VInt, VFloat
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# Copyright (C) 2014, 2015 Robert Jordens <jordens@gmail.com>
|
||||
|
||||
import unittest
|
||||
|
||||
import numpy as np
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
# Copyright (C) 2014, 2015 M-Labs Limited
|
||||
# Copyright (C) 2014, 2015 Robert Jordens <jordens@gmail.com>
|
||||
|
||||
from math import sqrt
|
||||
|
||||
from artiq.language import *
|
||||
|
@ -66,7 +69,7 @@ class ClockGeneratorLoopback(EnvExperiment):
|
|||
class PulseRate(EnvExperiment):
|
||||
def build(self):
|
||||
self.attr_device("core")
|
||||
self.attr_device("loop_out")
|
||||
self.attr_device("ttl_out")
|
||||
|
||||
@kernel
|
||||
def run(self):
|
||||
|
@ -74,7 +77,7 @@ class PulseRate(EnvExperiment):
|
|||
while True:
|
||||
try:
|
||||
for i in range(1000):
|
||||
self.loop_out.pulse_mu(dt)
|
||||
self.ttl_out.pulse_mu(dt)
|
||||
delay_mu(dt)
|
||||
except RTIOUnderflow:
|
||||
dt += 1
|
||||
|
@ -139,6 +142,19 @@ class SequenceError(EnvExperiment):
|
|||
self.ttl_out.pulse(25*us)
|
||||
|
||||
|
||||
class CollisionError(EnvExperiment):
|
||||
def build(self):
|
||||
self.attr_device("core")
|
||||
self.attr_device("ttl_out_serdes")
|
||||
|
||||
@kernel
|
||||
def run(self):
|
||||
delay(5*ms) # make sure we won't get underflow
|
||||
for i in range(16):
|
||||
self.ttl_out_serdes.pulse_mu(1)
|
||||
delay_mu(1)
|
||||
|
||||
|
||||
class TimeKeepsRunning(EnvExperiment):
|
||||
def build(self):
|
||||
self.attr_device("core")
|
||||
|
@ -190,7 +206,7 @@ class CoredeviceTest(ExperimentCase):
|
|||
|
||||
def test_loopback_count(self):
|
||||
npulses = 2
|
||||
r = self.execute(LoopbackCount, npulses=npulses)
|
||||
self.execute(LoopbackCount, npulses=npulses)
|
||||
count = self.rdb.get("count")
|
||||
self.assertEqual(count, npulses)
|
||||
|
||||
|
@ -202,6 +218,10 @@ class CoredeviceTest(ExperimentCase):
|
|||
with self.assertRaises(RTIOSequenceError):
|
||||
self.execute(SequenceError)
|
||||
|
||||
def test_collision_error(self):
|
||||
with self.assertRaises(runtime_exceptions.RTIOCollisionError):
|
||||
self.execute(CollisionError)
|
||||
|
||||
def test_watchdog(self):
|
||||
# watchdog only works on the device
|
||||
with self.assertRaises(IOError):
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
import os, sys, unittest, logging
|
||||
# Copyright (C) 2014, 2015 Robert Jordens <jordens@gmail.com>
|
||||
|
||||
import os
|
||||
import sys
|
||||
import unittest
|
||||
import logging
|
||||
|
||||
from artiq.language import *
|
||||
from artiq.coredevice.core import CompileError
|
||||
|
|
|
@ -45,7 +45,7 @@ class RPCCase(unittest.TestCase):
|
|||
self.assertEqual(test_object, test_object_back)
|
||||
with self.assertRaises(pc_rpc.RemoteError):
|
||||
remote.non_existing_method()
|
||||
remote.quit()
|
||||
remote.terminate()
|
||||
finally:
|
||||
remote.close_rpc()
|
||||
|
||||
|
@ -68,7 +68,7 @@ class RPCCase(unittest.TestCase):
|
|||
self.assertEqual(test_object, test_object_back)
|
||||
with self.assertRaises(pc_rpc.RemoteError):
|
||||
yield from remote.non_existing_method()
|
||||
yield from remote.quit()
|
||||
yield from remote.terminate()
|
||||
finally:
|
||||
remote.close_rpc()
|
||||
|
||||
|
@ -97,16 +97,6 @@ class FireAndForgetCase(unittest.TestCase):
|
|||
|
||||
|
||||
class Echo:
|
||||
def __init__(self):
|
||||
self.terminate_notify = asyncio.Semaphore(0)
|
||||
|
||||
@asyncio.coroutine
|
||||
def wait_quit(self):
|
||||
yield from self.terminate_notify.acquire()
|
||||
|
||||
def quit(self):
|
||||
self.terminate_notify.release()
|
||||
|
||||
def echo(self, x):
|
||||
return x
|
||||
|
||||
|
@ -116,10 +106,10 @@ def run_server():
|
|||
asyncio.set_event_loop(loop)
|
||||
try:
|
||||
echo = Echo()
|
||||
server = pc_rpc.Server({"test": echo})
|
||||
server = pc_rpc.Server({"test": echo}, builtin_terminate=True)
|
||||
loop.run_until_complete(server.start(test_address, test_port))
|
||||
try:
|
||||
loop.run_until_complete(echo.wait_quit())
|
||||
loop.run_until_complete(server.wait_terminate())
|
||||
finally:
|
||||
loop.run_until_complete(server.stop())
|
||||
finally:
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# Copyright (C) 2014, 2015 Robert Jordens <jordens@gmail.com>
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import io
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import unittest
|
||||
import asyncio
|
||||
import sys
|
||||
import os
|
||||
from time import time, sleep
|
||||
|
||||
from artiq import *
|
||||
|
@ -37,7 +38,8 @@ def _get_basic_steps(rid, expid, priority=0, flush=False):
|
|||
return [
|
||||
{"action": "setitem", "key": rid, "value":
|
||||
{"pipeline": "main", "status": "pending", "priority": priority,
|
||||
"expid": expid, "due_date": None, "flush": flush},
|
||||
"expid": expid, "due_date": None, "flush": flush,
|
||||
"repo_msg": None},
|
||||
"path": []},
|
||||
{"action": "setitem", "key": "status", "value": "preparing",
|
||||
"path": [rid]},
|
||||
|
@ -49,7 +51,7 @@ def _get_basic_steps(rid, expid, priority=0, flush=False):
|
|||
"path": [rid]},
|
||||
{"action": "setitem", "key": "status", "value": "analyzing",
|
||||
"path": [rid]},
|
||||
{"action": "setitem", "key": "status", "value": "analyze_done",
|
||||
{"action": "setitem", "key": "status", "value": "deleting",
|
||||
"path": [rid]},
|
||||
{"action": "delitem", "key": rid, "path": []}
|
||||
]
|
||||
|
@ -62,12 +64,15 @@ _handlers = {
|
|||
|
||||
class SchedulerCase(unittest.TestCase):
|
||||
def setUp(self):
|
||||
if os.name == "nt":
|
||||
self.loop = asyncio.ProactorEventLoop()
|
||||
else:
|
||||
self.loop = asyncio.new_event_loop()
|
||||
asyncio.set_event_loop(self.loop)
|
||||
|
||||
def test_steps(self):
|
||||
loop = self.loop
|
||||
scheduler = Scheduler(0, _handlers)
|
||||
scheduler = Scheduler(0, _handlers, None)
|
||||
expid = _get_expid("EmptyExperiment")
|
||||
|
||||
expect = _get_basic_steps(1, expid)
|
||||
|
@ -89,7 +94,8 @@ class SchedulerCase(unittest.TestCase):
|
|||
expect.insert(0,
|
||||
{"action": "setitem", "key": 0, "value":
|
||||
{"pipeline": "main", "status": "pending", "priority": 99,
|
||||
"expid": expid, "due_date": late, "flush": False},
|
||||
"expid": expid, "due_date": late, "flush": False,
|
||||
"repo_msg": None},
|
||||
"path": []})
|
||||
scheduler.submit("main", expid, 99, late, False)
|
||||
|
||||
|
@ -102,7 +108,7 @@ class SchedulerCase(unittest.TestCase):
|
|||
|
||||
def test_pause(self):
|
||||
loop = self.loop
|
||||
scheduler = Scheduler(0, _handlers)
|
||||
scheduler = Scheduler(0, _handlers, None)
|
||||
expid_bg = _get_expid("BackgroundExperiment")
|
||||
expid = _get_expid("EmptyExperiment")
|
||||
|
||||
|
@ -133,7 +139,7 @@ class SchedulerCase(unittest.TestCase):
|
|||
|
||||
def test_flush(self):
|
||||
loop = self.loop
|
||||
scheduler = Scheduler(0, _handlers)
|
||||
scheduler = Scheduler(0, _handlers, None)
|
||||
expid = _get_expid("EmptyExperiment")
|
||||
|
||||
expect = _get_basic_steps(1, expid, 1, True)
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# Copyright (C) 2014, 2015 Robert Jordens <jordens@gmail.com>
|
||||
|
||||
import unittest
|
||||
|
||||
from artiq.wavesynth import compute_samples
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import unittest
|
||||
import asyncio
|
||||
import sys
|
||||
import os
|
||||
from time import sleep
|
||||
|
||||
from artiq import *
|
||||
|
@ -38,7 +39,7 @@ class WatchdogTimeoutInBuild(EnvExperiment):
|
|||
@asyncio.coroutine
|
||||
def _call_worker(worker, expid):
|
||||
try:
|
||||
yield from worker.build(0, "main", expid, 0)
|
||||
yield from worker.build(0, "main", None, expid, 0)
|
||||
yield from worker.prepare()
|
||||
yield from worker.run()
|
||||
yield from worker.analyze()
|
||||
|
@ -59,6 +60,9 @@ def _run_experiment(class_name):
|
|||
|
||||
class WatchdogCase(unittest.TestCase):
|
||||
def setUp(self):
|
||||
if os.name == "nt":
|
||||
self.loop = asyncio.ProactorEventLoop()
|
||||
else:
|
||||
self.loop = asyncio.new_event_loop()
|
||||
asyncio.set_event_loop(self.loop)
|
||||
|
||||
|
|
|
@ -5,12 +5,16 @@ import logging
|
|||
import sys
|
||||
import asyncio
|
||||
import time
|
||||
import collections
|
||||
import os.path
|
||||
|
||||
from artiq.language.environment import is_experiment
|
||||
from artiq.protocols import pyon
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def parse_arguments(arguments):
|
||||
d = {}
|
||||
for argument in arguments:
|
||||
|
@ -47,7 +51,7 @@ def get_experiment(module, experiment=None):
|
|||
return getattr(module, experiment)
|
||||
|
||||
exps = [(k, v) for k, v in module.__dict__.items()
|
||||
if is_experiment(v)]
|
||||
if k[0] != "_" and is_experiment(v)]
|
||||
if not exps:
|
||||
raise ValueError("No experiments in module")
|
||||
if len(exps) > 1:
|
||||
|
@ -75,6 +79,15 @@ def init_logger(args):
|
|||
logging.basicConfig(level=logging.WARNING + args.quiet*10 - args.verbose*10)
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def exc_to_warning(coro):
|
||||
try:
|
||||
yield from coro
|
||||
except:
|
||||
logger.warning("asyncio coroutine terminated with exception",
|
||||
exc_info=True)
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def asyncio_process_wait_timeout(process, timeout):
|
||||
# In Python < 3.5, asyncio.wait_for(process.wait(), ...
|
||||
|
@ -113,14 +126,6 @@ def asyncio_wait_or_cancel(fs, **kwargs):
|
|||
return fs
|
||||
|
||||
|
||||
def asyncio_queue_peek(q):
|
||||
"""Like q.get_nowait(), but does not remove the item from the queue."""
|
||||
if q._queue:
|
||||
return q._queue[0]
|
||||
else:
|
||||
raise asyncio.QueueEmpty
|
||||
|
||||
|
||||
class TaskObject:
|
||||
def start(self):
|
||||
self.task = asyncio.async(self._do())
|
||||
|
@ -128,7 +133,10 @@ class TaskObject:
|
|||
@asyncio.coroutine
|
||||
def stop(self):
|
||||
self.task.cancel()
|
||||
yield from asyncio.wait([self.task])
|
||||
try:
|
||||
yield from asyncio.wait_for(self.task, None)
|
||||
except asyncio.CancelledError:
|
||||
pass
|
||||
del self.task
|
||||
|
||||
@asyncio.coroutine
|
||||
|
@ -136,25 +144,25 @@ class TaskObject:
|
|||
raise NotImplementedError
|
||||
|
||||
|
||||
class WaitSet:
|
||||
def __init__(self):
|
||||
self._s = set()
|
||||
self._ev = asyncio.Event()
|
||||
|
||||
def _update_ev(self):
|
||||
if self._s:
|
||||
self._ev.clear()
|
||||
class Condition:
|
||||
def __init__(self, *, loop=None):
|
||||
if loop is not None:
|
||||
self._loop = loop
|
||||
else:
|
||||
self._ev.set()
|
||||
|
||||
def add(self, e):
|
||||
self._s.add(e)
|
||||
self._update_ev()
|
||||
|
||||
def discard(self, e):
|
||||
self._s.discard(e)
|
||||
self._update_ev()
|
||||
self._loop = asyncio.get_event_loop()
|
||||
self._waiters = collections.deque()
|
||||
|
||||
@asyncio.coroutine
|
||||
def wait_empty(self):
|
||||
yield from self._ev.wait()
|
||||
def wait(self):
|
||||
"""Wait until notified."""
|
||||
fut = asyncio.Future(loop=self._loop)
|
||||
self._waiters.append(fut)
|
||||
try:
|
||||
yield from fut
|
||||
finally:
|
||||
self._waiters.remove(fut)
|
||||
|
||||
def notify(self):
|
||||
for fut in self._waiters:
|
||||
if not fut.done():
|
||||
fut.set_result(False)
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# Copyright (C) 2014, 2015 Robert Jordens <jordens@gmail.com>
|
||||
|
||||
import numpy as np
|
||||
from scipy.interpolate import splrep, splev, spalde
|
||||
from scipy.special import binom
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
# Copyright (C) 2014, 2015 M-Labs Limited
|
||||
# Copyright (C) 2014, 2015 Robert Jordens <jordens@gmail.com>
|
||||
|
||||
from copy import copy
|
||||
from math import cos, pi
|
||||
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
"%PYTHON%" setup.py install
|
||||
if errorlevel 1 exit 1
|
|
@ -0,0 +1,3 @@
|
|||
#!/bin/bash
|
||||
|
||||
$PYTHON setup.py install
|
|
@ -0,0 +1,36 @@
|
|||
package:
|
||||
name: aiohttp
|
||||
version: "0.17.2"
|
||||
|
||||
source:
|
||||
fn: aiohttp-0.17.2.tar.gz
|
||||
url: https://pypi.python.org/packages/source/a/aiohttp/aiohttp-0.17.2.tar.gz
|
||||
md5: 7640928fd4b5c1ccf1f8bcad276d39d6
|
||||
|
||||
build:
|
||||
number: 0
|
||||
|
||||
requirements:
|
||||
build:
|
||||
- python
|
||||
- setuptools
|
||||
- chardet
|
||||
|
||||
run:
|
||||
- python
|
||||
- chardet
|
||||
|
||||
test:
|
||||
# Python imports
|
||||
imports:
|
||||
- aiohttp
|
||||
|
||||
requires:
|
||||
- chardet
|
||||
- gunicorn # [not win]
|
||||
- nose
|
||||
|
||||
about:
|
||||
home: https://github.com/KeepSafe/aiohttp/
|
||||
license: Apache Software License
|
||||
summary: 'http client/server for asyncio'
|
|
@ -1,2 +1 @@
|
|||
set ARTIQ_GUI=0
|
||||
"%PYTHON%" setup.py install --single-version-externally-managed --record=record.txt
|
||||
|
|
|
@ -7,7 +7,7 @@ then
|
|||
source $BUILD_SETTINGS_FILE
|
||||
fi
|
||||
|
||||
ARTIQ_GUI=1 $PYTHON setup.py install --single-version-externally-managed --record=record.txt
|
||||
$PYTHON setup.py install --single-version-externally-managed --record=record.txt
|
||||
git clone --recursive https://github.com/m-labs/misoc
|
||||
export MSCDIR=$SRC_DIR/misoc
|
||||
|
||||
|
@ -16,15 +16,16 @@ BIN_PREFIX=$ARTIQ_PREFIX/binaries/
|
|||
mkdir -p $ARTIQ_PREFIX/misc
|
||||
mkdir -p $BIN_PREFIX/kc705 $BIN_PREFIX/pipistrello
|
||||
|
||||
# build for KC705
|
||||
# build for KC705 NIST_QC1
|
||||
|
||||
cd $SRC_DIR/misoc; python make.py -X ../soc -t artiq_kc705 build-headers build-bios; cd -
|
||||
cd $SRC_DIR/misoc; $PYTHON make.py -X ../soc -t artiq_kc705 build-headers build-bios; cd -
|
||||
make -C soc/runtime clean runtime.fbi
|
||||
cd $SRC_DIR/misoc; python make.py -X ../soc -t artiq_kc705 $MISOC_EXTRA_VIVADO_CMDLINE build-bitstream; cd -
|
||||
cd $SRC_DIR/misoc; $PYTHON make.py -X ../soc -t artiq_kc705 $MISOC_EXTRA_VIVADO_CMDLINE build-bitstream; cd -
|
||||
|
||||
# install KC705 binaries
|
||||
# install KC705 NIST_QC1 binaries
|
||||
|
||||
cp soc/runtime/runtime.fbi $BIN_PREFIX/kc705/
|
||||
mkdir -p $BIN_PREFIX/kc705/nist_qc1
|
||||
cp soc/runtime/runtime.fbi $BIN_PREFIX/kc705/nist_qc1/
|
||||
cp $SRC_DIR/misoc/software/bios/bios.bin $BIN_PREFIX/kc705/
|
||||
cp $SRC_DIR/misoc/build/artiq_kc705-nist_qc1-kc705.bit $BIN_PREFIX/kc705/
|
||||
wget http://sionneau.net/artiq/binaries/kc705/flash_proxy/bscan_spi_kc705.bit
|
||||
|
@ -32,18 +33,30 @@ mv bscan_spi_kc705.bit $BIN_PREFIX/kc705/
|
|||
|
||||
# build for Pipistrello
|
||||
|
||||
cd $SRC_DIR/misoc; python make.py -X ../soc -t artiq_pipistrello build-headers build-bios; cd -
|
||||
cd $SRC_DIR/misoc; $PYTHON make.py -X ../soc -t artiq_pipistrello build-headers build-bios; cd -
|
||||
make -C soc/runtime clean runtime.fbi
|
||||
cd $SRC_DIR/misoc; python make.py -X ../soc -t artiq_pipistrello $MISOC_EXTRA_ISE_CMDLINE build-bitstream; cd -
|
||||
cd $SRC_DIR/misoc; $PYTHON make.py -X ../soc -t artiq_pipistrello $MISOC_EXTRA_ISE_CMDLINE build-bitstream; cd -
|
||||
|
||||
# install Pipistrello binaries
|
||||
|
||||
cp soc/runtime/runtime.fbi $BIN_PREFIX/pipistrello/
|
||||
cp $SRC_DIR/misoc/software/bios/bios.bin $BIN_PREFIX/pipistrello/
|
||||
cp $SRC_DIR/misoc/build/artiq_pipistrello-nist_qc1-pipistrello.bit $BIN_PREFIX/pipistrello/
|
||||
wget http://www.phys.ethz.ch/~robertjo/bscan_spi_lx45_csg324.bit
|
||||
wget https://people.phys.ethz.ch/~robertjo/bscan_spi_lx45_csg324.bit
|
||||
mv bscan_spi_lx45_csg324.bit $BIN_PREFIX/pipistrello/
|
||||
|
||||
# build for KC705 NIST_QC2
|
||||
|
||||
cd $SRC_DIR/misoc; $PYTHON make.py -X ../soc -t artiq_kc705 -s NIST_QC2 build-headers; cd -
|
||||
make -C soc/runtime clean runtime.fbi
|
||||
cd $SRC_DIR/misoc; $PYTHON make.py -X ../soc -t artiq_kc705 -s NIST_QC2 $MISOC_EXTRA_VIVADO_CMDLINE build-bitstream; cd -
|
||||
|
||||
# install KC705 NIST_QC2 binaries
|
||||
|
||||
mkdir -p $BIN_PREFIX/kc705/nist_qc2
|
||||
cp soc/runtime/runtime.fbi $BIN_PREFIX/kc705/nist_qc2/
|
||||
cp $SRC_DIR/misoc/build/artiq_kc705-nist_qc2-kc705.bit $BIN_PREFIX/kc705/
|
||||
|
||||
cp artiq/frontend/artiq_flash.sh $PREFIX/bin
|
||||
|
||||
# misc
|
||||
|
|
|
@ -11,9 +11,10 @@ build:
|
|||
entry_points:
|
||||
- artiq_client = artiq.frontend.artiq_client:main
|
||||
- artiq_compile = artiq.frontend.artiq_compile:main
|
||||
- artiq_coreconfig = artiq.frontend.artiq_coreconfig:main
|
||||
- artiq_coretool = artiq.frontend.artiq_coretool:main
|
||||
- artiq_ctlmgr = artiq.frontend.artiq_ctlmgr:main
|
||||
- artiq_gui = artiq.frontend.artiq_gui:main
|
||||
- artiq_influxdb = artiq.frontend.artiq_influxdb:main
|
||||
- artiq_master = artiq.frontend.artiq_master:main
|
||||
- artiq_mkfs = artiq.frontend.artiq_mkfs:main
|
||||
- artiq_rpctool = artiq.frontend.artiq_rpctool:main
|
||||
|
@ -32,9 +33,10 @@ requirements:
|
|||
- numpy
|
||||
- migen
|
||||
- pyelftools
|
||||
- binutils-or1k-linux
|
||||
run:
|
||||
- python >=3.4.3
|
||||
- llvmlite-or1k
|
||||
- llvmlite-artiq
|
||||
- scipy
|
||||
- numpy
|
||||
- prettytable
|
||||
|
@ -48,6 +50,9 @@ requirements:
|
|||
- quamash
|
||||
- pyqtgraph
|
||||
- flterm # [linux]
|
||||
- pygit2
|
||||
- aiohttp
|
||||
- binutils-or1k-linux
|
||||
|
||||
test:
|
||||
imports:
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
binutils-or1k-linux
|
||||
===================
|
||||
|
||||
To build this package on Windows:
|
||||
|
||||
* Install cygwin
|
||||
* Install the following packages: gcc-core g++-core make texinfo patch
|
||||
* Run cygwin terminal and execute $ conda build binutils-or1k-linux
|
|
@ -0,0 +1,10 @@
|
|||
FOR /F "tokens=* USEBACKQ" %%F IN (`cygpath -u %PREFIX%`) DO (
|
||||
SET var=%%F
|
||||
)
|
||||
set PREFIX=%var%
|
||||
FOR /F "tokens=* USEBACKQ" %%F IN (`cygpath -u %RECIPE_DIR%`) DO (
|
||||
SET var=%%F
|
||||
)
|
||||
set RECIPE_DIR=%var%
|
||||
sh %RECIPE_DIR%/build.sh
|
||||
if errorlevel 1 exit 1
|
|
@ -0,0 +1,6 @@
|
|||
patch -p1 < $RECIPE_DIR/../../misc/binutils-2.25.1-or1k-R_PCREL-pcrel_offset.patch
|
||||
mkdir build
|
||||
cd build
|
||||
../configure --target=or1k-linux --prefix=$PREFIX
|
||||
make -j2
|
||||
make install
|
|
@ -0,0 +1,20 @@
|
|||
package:
|
||||
name: binutils-or1k-linux
|
||||
version: 2.25.1
|
||||
|
||||
source:
|
||||
fn: binutils-2.25.1.tar.bz2
|
||||
url: https://ftp.gnu.org/gnu/binutils/binutils-2.25.1.tar.bz2
|
||||
sha256: b5b14added7d78a8d1ca70b5cb75fef57ce2197264f4f5835326b0df22ac9f22
|
||||
|
||||
build:
|
||||
number: 0
|
||||
|
||||
requirements:
|
||||
build:
|
||||
- system # [not win]
|
||||
|
||||
about:
|
||||
home: https://www.gnu.org/software/binutils/
|
||||
license: GPL
|
||||
summary: 'A set of programming tools for creating and managing binary programs, object files, libraries, profile data, and assembly source code.'
|
|
@ -0,0 +1,20 @@
|
|||
mkdir build
|
||||
cd build
|
||||
REM Configure step
|
||||
if "%ARCH%"=="32" (
|
||||
set CMAKE_GENERATOR=Visual Studio 12 2013
|
||||
) else (
|
||||
set CMAKE_GENERATOR=Visual Studio 12 2013 Win64
|
||||
)
|
||||
set CMAKE_GENERATOR_TOOLSET=v120_xp
|
||||
cmake -G "%CMAKE_GENERATOR%" -DCMAKE_INSTALL_PREFIX=%PREFIX% -DSTDCALL=OFF -DCMAKE_PREFIX_PATH=$PREFIX %SRC_DIR%
|
||||
if errorlevel 1 exit 1
|
||||
REM Build step
|
||||
cmake --build .
|
||||
if errorlevel 1 exit 1
|
||||
REM Install step
|
||||
cmake --build . --target install
|
||||
if errorlevel 1 exit 1
|
||||
REM Hack to help pygit2 to find libgit2
|
||||
mkdir %PREFIX%\Scripts
|
||||
copy "%PREFIX%\bin\git2.dll" "%PREFIX%\Scripts\"
|
|
@ -0,0 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. -DCMAKE_INSTALL_PREFIX=$PREFIX -DCMAKE_PREFIX_PATH=$PREFIX
|
||||
make -j2
|
||||
make install
|
|
@ -0,0 +1,27 @@
|
|||
package:
|
||||
name: libgit2
|
||||
version: 0.22.3
|
||||
|
||||
source:
|
||||
git_url: https://github.com/libgit2/libgit2
|
||||
git_tag: v0.22.3
|
||||
|
||||
build:
|
||||
number: 1
|
||||
|
||||
requirements:
|
||||
build:
|
||||
- system # [linux]
|
||||
- cmake # [linux]
|
||||
- openssl
|
||||
- libssh2
|
||||
- zlib
|
||||
run:
|
||||
- openssl
|
||||
- zlib
|
||||
- libssh2
|
||||
|
||||
about:
|
||||
home: https://libgit2.github.com/
|
||||
license: GPLv2 with a special Linking Exception
|
||||
summary: 'libgit2 is a portable, pure C implementation of the Git core methods provided as a re-entrant linkable library with a solid API, allowing you to write native speed custom Git applications in any language with bindings.'
|
|
@ -0,0 +1,17 @@
|
|||
mkdir build
|
||||
cd build
|
||||
REM Configure step
|
||||
if "%ARCH%"=="32" (
|
||||
set CMAKE_GENERATOR=Visual Studio 12 2013
|
||||
) else (
|
||||
set CMAKE_GENERATOR=Visual Studio 12 2013 Win64
|
||||
)
|
||||
set CMAKE_GENERATOR_TOOLSET=v120_xp
|
||||
cmake -G "%CMAKE_GENERATOR%" -DCMAKE_INSTALL_PREFIX=%PREFIX% -DOPENSSL_ROOT_DIR=%PREFIX%\Library -DBUILD_SHARED_LIBS=ON -DBUILD_TESTING=OFF -DBUILD_EXAMPLES=OFF -DCMAKE_PREFIX_PATH=$PREFIX %SRC_DIR%
|
||||
if errorlevel 1 exit 1
|
||||
REM Build step
|
||||
cmake --build .
|
||||
if errorlevel 1 exit 1
|
||||
REM Install step
|
||||
cmake --build . --target install
|
||||
if errorlevel 1 exit 1
|
|
@ -0,0 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. -DCMAKE_INSTALL_PREFIX=$PREFIX -DOPENSSL_ROOT_DIR=$PREFIX -DBUILD_SHARED_LIBS=ON -DBUILD_TESTING=OFF -DBUILD_EXAMPLES=OFF -DCMAKE_PREFIX_PATH=$PREFIX
|
||||
make -j2
|
||||
make install
|
|
@ -0,0 +1,23 @@
|
|||
package:
|
||||
name: libssh2
|
||||
version: 1.6.0
|
||||
|
||||
source:
|
||||
git_url: https://github.com/libssh2/libssh2
|
||||
git_tag: libssh2-1.6.0
|
||||
|
||||
build:
|
||||
number: 1
|
||||
|
||||
requirements:
|
||||
build:
|
||||
- system # [linux]
|
||||
- cmake # [linux]
|
||||
- openssl
|
||||
run:
|
||||
- openssl
|
||||
|
||||
about:
|
||||
home: http://www.libssh2.org/
|
||||
license: BSD
|
||||
summary: 'libssh2 is a client-side C library implementing the SSH2 protocol'
|
|
@ -9,9 +9,10 @@ set CMAKE_GENERATOR=Visual Studio 12 2013 Win64
|
|||
)
|
||||
set CMAKE_GENERATOR_TOOLSET=v120_xp
|
||||
@rem Reduce build times and package size by removing unused stuff
|
||||
set CMAKE_CUSTOM=-DLLVM_TARGETS_TO_BUILD=OR1K -DLLVM_INCLUDE_TESTS=OFF ^
|
||||
set CMAKE_CUSTOM=-DLLVM_TARGETS_TO_BUILD="OR1K;X86" -DLLVM_INCLUDE_TESTS=OFF ^
|
||||
-DLLVM_INCLUDE_TOOLS=OFF -DLLVM_INCLUDE_UTILS=OFF ^
|
||||
-DLLVM_INCLUDE_DOCS=OFF -DLLVM_INCLUDE_EXAMPLES=OFF
|
||||
-DLLVM_INCLUDE_DOCS=OFF -DLLVM_INCLUDE_EXAMPLES=OFF ^
|
||||
-DLLVM_ENABLE_ASSERTIONS=ON
|
||||
cmake -G "%CMAKE_GENERATOR%" -T "%CMAKE_GENERATOR_TOOLSET%" ^
|
||||
-DCMAKE_BUILD_TYPE="%BUILD_CONFIG%" -DCMAKE_PREFIX_PATH=%LIBRARY_PREFIX% ^
|
||||
-DCMAKE_INSTALL_PREFIX:PATH=%LIBRARY_PREFIX% %CMAKE_CUSTOM% %SRC_DIR%
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
#!/bin/bash
|
||||
|
||||
cd tools
|
||||
git clone https://github.com/openrisc/clang-or1k clang
|
||||
cd ..
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. -DCMAKE_INSTALL_PREFIX=$PREFIX -DLLVM_TARGETS_TO_BUILD="OR1K;X86" -DCMAKE_BUILD_TYPE=Rel -DLLVM_ENABLE_ASSERTIONS=ON
|
||||
make -j2
|
||||
make install
|
|
@ -1,26 +1,22 @@
|
|||
package:
|
||||
name: llvmdev-or1k
|
||||
version: "3.4"
|
||||
version: "3.5.0"
|
||||
|
||||
source:
|
||||
git_url: https://github.com/openrisc/llvm-or1k
|
||||
git_tag: master
|
||||
|
||||
build:
|
||||
number: 2
|
||||
number: 4
|
||||
|
||||
requirements:
|
||||
build:
|
||||
- system [linux and not armv6]
|
||||
- system [linux]
|
||||
- cmake [linux]
|
||||
run:
|
||||
- system [linux and not armv6]
|
||||
|
||||
#test:
|
||||
#commands:
|
||||
#- clang --help [linux and not armv6]
|
||||
- system [linux]
|
||||
|
||||
about:
|
||||
home: http://llvm.org/
|
||||
license: Open Source (http://llvm.org/releases/3.4/LICENSE.TXT)
|
||||
license: Open Source (http://llvm.org/releases/3.5.0/LICENSE.TXT)
|
||||
summary: Development headers and libraries for LLVM
|
||||
|
|
|
@ -4,5 +4,5 @@ set CMAKE_PREFIX_PATH=%LIBRARY_PREFIX%
|
|||
@rem Ensure there are no build leftovers (CMake can complain)
|
||||
if exist ffi\build rmdir /S /Q ffi\build
|
||||
|
||||
%PYTHON% -S setup.py install
|
||||
%PYTHON% setup.py install
|
||||
if errorlevel 1 exit 1
|
|
@ -1,10 +1,10 @@
|
|||
package:
|
||||
name: llvmlite-or1k
|
||||
version: "0.2.1"
|
||||
name: llvmlite-artiq
|
||||
version: "0.5.1"
|
||||
|
||||
source:
|
||||
git_url: https://github.com/numba/llvmlite
|
||||
git_tag: 11a8303d02e3d6dd2d1e0e9065701795cd8a979f
|
||||
git_url: https://github.com/m-labs/llvmlite
|
||||
git_tag: artiq
|
||||
|
||||
requirements:
|
||||
build:
|
||||
|
@ -15,12 +15,12 @@ requirements:
|
|||
- python
|
||||
|
||||
build:
|
||||
number: 1
|
||||
number: 4
|
||||
|
||||
test:
|
||||
imports:
|
||||
- llvmlite_or1k
|
||||
- llvmlite_or1k.llvmpy
|
||||
- llvmlite_artiq
|
||||
- llvmlite_artiq.llvmpy
|
||||
|
||||
about:
|
||||
home: https://pypi.python.org/pypi/llvmlite/
|
|
@ -1,4 +0,0 @@
|
|||
#!/bin/bash
|
||||
./configure --prefix=$PREFIX
|
||||
make -j
|
||||
make install
|
|
@ -1,16 +0,0 @@
|
|||
# This conda recipe comes from https://github.com/sandialabs/pixman-conda-recipe
|
||||
|
||||
package:
|
||||
name: pixman
|
||||
version: "0.32.6"
|
||||
|
||||
source:
|
||||
fn: pixman-0.32.6.tar.gz
|
||||
url: http://cairographics.org/releases/pixman-0.32.6.tar.gz
|
||||
|
||||
build:
|
||||
number: 0
|
||||
|
||||
about:
|
||||
home: http://cairographics.org
|
||||
license: GNU Lesser General Public License (LGPL) version 2.1 or the Mozilla Public License (MPL) version 1.1 at your option.
|
|
@ -0,0 +1,3 @@
|
|||
set LIBGIT2=%PREFIX%
|
||||
set VS100COMNTOOLS=%VS120COMNTOOLS%
|
||||
%PYTHON% setup.py install
|
|
@ -0,0 +1,2 @@
|
|||
export LIBGIT2=$PREFIX
|
||||
$PYTHON setup.py install
|
|
@ -0,0 +1,28 @@
|
|||
package:
|
||||
name: pygit2
|
||||
version: 0.22.1
|
||||
|
||||
source:
|
||||
git_url: https://github.com/libgit2/pygit2
|
||||
git_tag: v0.22.1
|
||||
|
||||
build:
|
||||
number: 1
|
||||
|
||||
requirements:
|
||||
build:
|
||||
- system # [linux]
|
||||
- python
|
||||
- libgit2
|
||||
- cffi >=0.8.1
|
||||
- pkgconfig # [linux]
|
||||
run:
|
||||
- system # [linux]
|
||||
- python
|
||||
- libgit2
|
||||
- cffi >=0.8.1
|
||||
|
||||
about:
|
||||
home: http://www.pygit2.org/
|
||||
license: GPLv2 with a special Linking Exception
|
||||
summary: 'Pygit2 is a set of Python bindings to the libgit2 shared library, libgit2 implements the core of Git.'
|
|
@ -0,0 +1,2 @@
|
|||
pip install regex
|
||||
%PYTHON% setup.py install
|
|
@ -0,0 +1,2 @@
|
|||
pip install regex
|
||||
$PYTHON setup.py install
|
|
@ -0,0 +1,24 @@
|
|||
package:
|
||||
name: pythonparser
|
||||
version: 0.0
|
||||
|
||||
source:
|
||||
git_url: https://github.com/m-labs/pythonparser
|
||||
git_tag: master
|
||||
|
||||
build:
|
||||
number: 0
|
||||
|
||||
requirements:
|
||||
build:
|
||||
- python
|
||||
- setuptools
|
||||
|
||||
test:
|
||||
imports:
|
||||
- pythonparser
|
||||
|
||||
about:
|
||||
home: http://m-labs.hk/pythonparser/
|
||||
license: BSD
|
||||
summary: 'PythonParser is a Python parser written specifically for use in tooling. It parses source code into an AST that is a superset of Python’s built-in ast module, but returns precise location information for every token.'
|
|
@ -66,7 +66,7 @@ master_doc = 'index'
|
|||
|
||||
# General information about the project.
|
||||
project = 'ARTIQ'
|
||||
copyright = '2014-2015, M-Labs / NIST Ion Storage Group'
|
||||
copyright = '2014-2015, M-Labs Limited'
|
||||
|
||||
# The version info for the project you're documenting, acts as replacement for
|
||||
# |version| and |release|, also used in various other places throughout the
|
||||
|
|
|
@ -0,0 +1,77 @@
|
|||
Core device
|
||||
===========
|
||||
|
||||
The core device is a FPGA-based hardware component that contains a softcore CPU tightly coupled with the so-called RTIO core that provides precision timing. The CPU executes Python code that is statically compiled by the ARTIQ compiler, and communicates with the core device peripherals (TTL, DDS, etc.) over the RTIO core. This architecture provides high timing resolution, low latency, low jitter, high level programming capabilities, and good integration with the rest of the Python experiment code.
|
||||
|
||||
While it is possible to use all the other parts of ARTIQ (controllers, master, GUI, result management, etc.) without a core device, many experiments require it.
|
||||
|
||||
|
||||
.. _core-device-flash-storage:
|
||||
|
||||
Flash storage
|
||||
*************
|
||||
|
||||
The core device contains some flash space that can be used to store configuration data.
|
||||
|
||||
This storage area is used to store the core device MAC address, IP address and even the idle kernel.
|
||||
|
||||
The flash storage area is one sector (typically 64 kB) large and is organized as a list of key-value records.
|
||||
|
||||
This flash storage space can be accessed by using ``artiq_coretool`` (see: :ref:`core-device-access-tool`).
|
||||
|
||||
.. _board-ports:
|
||||
|
||||
FPGA board ports
|
||||
****************
|
||||
|
||||
KC705
|
||||
-----
|
||||
|
||||
The main target board for the ARTIQ core device is the KC705 development board from Xilinx. It supports the NIST QC1 hardware via an adapter, and the NIST QC2 hardware (FMC).
|
||||
|
||||
With the QC1 hardware, the TTL lines are mapped as follows:
|
||||
|
||||
+--------------+------------+--------------+
|
||||
| RTIO channel | TTL line | Capability |
|
||||
+==============+============+==============+
|
||||
| 0 | PMT0 | Input |
|
||||
+--------------+------------+--------------+
|
||||
| 1 | PMT1 | Input |
|
||||
+--------------+------------+--------------+
|
||||
| 2-16 | TTL0-14 | Output |
|
||||
+--------------+------------+--------------+
|
||||
| 17 | SMA_GPIO_N | Input+Output |
|
||||
+--------------+------------+--------------+
|
||||
| 18 | LED | Output |
|
||||
+--------------+------------+--------------+
|
||||
| 19 | TTL15 | Clock |
|
||||
+--------------+------------+--------------+
|
||||
|
||||
Pipistrello
|
||||
-----------
|
||||
|
||||
The low-cost Pipistrello FPGA board can be used as a lower-cost but slower alternative. The current USB over serial protocol also suffers from limitations (no monitoring/injection, no idle experiment, no kernel interruptions, lack of robustness).
|
||||
|
||||
When plugged to an adapter, the NIST QC1 hardware can be used. The TTL lines are mapped to RTIO channels as follows:
|
||||
|
||||
+--------------+----------+------------+
|
||||
| RTIO channel | TTL line | Capability |
|
||||
+==============+==========+============+
|
||||
| 0 | PMT0 | Input |
|
||||
+--------------+----------+------------+
|
||||
| 1 | PMT1 | Input |
|
||||
+--------------+----------+------------+
|
||||
| 2-16 | TTL0-14 | Output |
|
||||
+--------------+----------+------------+
|
||||
| 17 | EXT_LED | Output |
|
||||
+--------------+----------+------------+
|
||||
| 18 | USER_LED | Output |
|
||||
+--------------+----------+------------+
|
||||
| 19 | TTL15 | Clock |
|
||||
+--------------+----------+------------+
|
||||
|
||||
The input only limitation on channels 0 and 1 comes from the QC-DAQ adapter. When the adapter is not used (and physically unplugged from the Pipistrello board), the corresponding pins on the Pipistrello can be used as outputs. Do not configure these channels as outputs when the adapter is plugged, as this would cause electrical contention.
|
||||
|
||||
The board can accept an external RTIO clock connected to PMT2. If the DDS box
|
||||
does not drive the PMT2 pair, use XTRIG and patch the XTRIG transceiver output
|
||||
on the adapter board onto C:15 disconnecting PMT2.
|
|
@ -1,14 +0,0 @@
|
|||
.. _core-device-flash-storage:
|
||||
|
||||
Core device flash storage
|
||||
=========================
|
||||
|
||||
The core device contains some flash space that can be used to store
|
||||
some configuration data.
|
||||
|
||||
This storage area is used to store the core device MAC address, IP address and even the idle kernel.
|
||||
|
||||
The flash storage area is one sector (64 kB) large and is organized as a list
|
||||
of key-value records.
|
||||
|
||||
This flash storage space can be accessed by using the artiq_coretool.py :ref:`core-device-access-tool`.
|
|
@ -15,8 +15,14 @@ The most commonly used features from those modules can be imported with ``from a
|
|||
.. automodule:: artiq.language.environment
|
||||
:members:
|
||||
|
||||
:mod:`artiq.language.scan` module
|
||||
----------------------------------------
|
||||
|
||||
.. automodule:: artiq.language.scan
|
||||
:members:
|
||||
|
||||
:mod:`artiq.language.units` module
|
||||
----------------------------------
|
||||
|
||||
.. automodule:: artiq.language.units
|
||||
:members:
|
||||
This module contains floating point constants that correspond to common physical units (ns, MHz, ...).
|
||||
They are provided for convenience (e.g write ``MHz`` instead of ``1000000.0``) and code clarity purposes.
|
||||
|
|
|
@ -8,6 +8,10 @@ Default network ports
|
|||
+--------------------------+--------------+
|
||||
| Core device (mon/inj) | 3250 (UDP) |
|
||||
+--------------------------+--------------+
|
||||
| InfluxDB bridge | 3248 |
|
||||
+--------------------------+--------------+
|
||||
| Controller manager | 3249 |
|
||||
+--------------------------+--------------+
|
||||
| Master (notifications) | 3250 |
|
||||
+--------------------------+--------------+
|
||||
| Master (control) | 3251 |
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
The environment
|
||||
===============
|
||||
|
||||
Experiments interact with an environment that consists of devices, parameters, arguments and results. Access to the environment is handled by the class :class:`artiq.language.environment.EnvExperiment` that experiments should derive from.
|
||||
|
||||
.. _ddb:
|
||||
|
||||
The device database
|
||||
-------------------
|
||||
|
||||
The device database contains information about the devices available in a ARTIQ installation, what drivers to use, what controllers to use and on what machine, and where the devices are connected.
|
||||
|
||||
The master (or ``artiq_run``) instantiates the device drivers (and the RPC clients in the case of controllers) for the experiments based on the contents of the device database.
|
||||
|
||||
The device database is stored in the memory of the master and is backed by a PYON file typically called ``ddb.pyon``.
|
||||
|
||||
The device database is a Python dictionary whose keys are the device names, and values can have several types.
|
||||
|
||||
Local devices
|
||||
+++++++++++++
|
||||
|
||||
Local device entries are dictionaries that contain a ``type`` field set to ``local``. They correspond to device drivers that are created locally on the master (as opposed to going through the controller mechanism). The fields ``module`` and ``class`` determine the location of the Python class that the driver consists of. The ``arguments`` field is another (possibly empty) dictionary that contains arguments to pass to the device driver constructor.
|
||||
|
||||
Controllers
|
||||
+++++++++++
|
||||
|
||||
Controller entries are dictionaries whose ``type`` field is set to ``controller``. When an experiment requests such a device, a RPC client (see :class:`artiq.protocols.pc_rpc`) is created and connected to the appropriate controller. Controller entries are also used by controller managers to determine what controllers to run.
|
||||
|
||||
The ``best_effort`` field is a boolean that determines whether to use :class:`artiq.protocols.pc_rpc.Client` or :class:`artiq.protocols.pc_rpc.BestEffortClient`. The ``host`` and ``port`` fields configure the TCP connection. The ``target`` field contains the name of the RPC target to use (you may use ``artiq_rpctool`` on a controller to list its targets). Controller managers run the ``command`` field in a shell to launch the controller, after replacing ``{port}`` and ``{bind}`` by respectively the TCP port the controller should listen to (matches the ``port`` field) and an appropriate bind address for the controller's listening socket.
|
||||
|
||||
Aliases
|
||||
+++++++
|
||||
|
||||
If an entry is a string, that string is used as a key for another lookup in the device database.
|
||||
|
||||
The parameter database
|
||||
----------------------
|
||||
|
||||
The parameter database is a key-value store that is global to all experiments. It is stored in the memory of the master and is backed by a PYON file typically called ``pdb.pyon``. It may be used to communicate values across experiments; for example, a periodic calibration experiment may update a parameter read by payload experiments.
|
||||
|
||||
Arguments
|
||||
---------
|
||||
|
||||
Arguments are values that parameterize the behavior of an experiment and are set before the experiment is executed.
|
||||
|
||||
Requesting the values of arguments can only be done in the build phase of an experiment. The value requests are also used to define the GUI widgets shown in the explorer when the experiment is selected.
|
||||
|
||||
Results
|
||||
-------
|
||||
|
||||
Results are the output of an experiment. They are archived after in the HDF5 format after the experiment is run. Experiments may define real-time results that are (additionally) distributed to all clients connected to the master; for example, the ARTIQ GUI may plot them while the experiment is in progress to give rapid feedback to the user. Real-time results are a global key-value store (similar to the parameter database); experiments should use distinctive real-time result names in order to avoid conflicts.
|
|
@ -1,3 +1,5 @@
|
|||
.. Copyright (C) 2014, 2015 Robert Jordens <jordens@gmail.com>
|
||||
|
||||
FAQ
|
||||
###
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue