forked from M-Labs/artiq
reorganize files as per discussion with Robert
This commit is contained in:
parent
6cc3a9d973
commit
3e22fe86b5
|
@ -8,10 +8,14 @@ from operator import itemgetter
|
|||
|
||||
from prettytable import PrettyTable
|
||||
|
||||
from artiq.management.pc_rpc import Client
|
||||
from artiq.management.sync_struct import Subscriber
|
||||
from artiq.management.tools import clear_screen, format_run_arguments
|
||||
from artiq.management import pyon
|
||||
from artiq.protocols.pc_rpc import Client
|
||||
from artiq.protocols.sync_struct import Subscriber
|
||||
from artiq.protocols import pyon
|
||||
from artiq.tools import format_run_arguments
|
||||
|
||||
|
||||
def clear_screen():
|
||||
sys.stdout.write("\x1b[2J\x1b[H")
|
||||
|
||||
|
||||
def _get_args():
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
import argparse
|
||||
|
||||
from artiq.management.pc_rpc import Client
|
||||
from artiq.protocols.pc_rpc import Client
|
||||
|
||||
|
||||
def _get_args():
|
||||
|
|
|
@ -7,7 +7,7 @@ import atexit
|
|||
import gbulb
|
||||
from gi.repository import Gtk
|
||||
|
||||
from artiq.management.pc_rpc import AsyncioClient
|
||||
from artiq.protocols.pc_rpc import AsyncioClient
|
||||
from artiq.gui.scheduler import SchedulerWindow
|
||||
from artiq.gui.parameters import ParametersWindow
|
||||
from artiq.gui.rt_results import RTResults
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
import argparse
|
||||
|
||||
from artiq.management.pc_rpc import Client
|
||||
from artiq.protocols.pc_rpc import Client
|
||||
|
||||
|
||||
def main():
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
import argparse
|
||||
|
||||
from artiq.devices.lda.driver import Lda, Ldasim
|
||||
from artiq.management.pc_rpc import simple_server_loop
|
||||
from artiq.protocols.pc_rpc import simple_server_loop
|
||||
|
||||
|
||||
def main():
|
||||
|
|
|
@ -4,9 +4,9 @@ import asyncio
|
|||
import argparse
|
||||
import atexit
|
||||
|
||||
from artiq.management.pc_rpc import Server
|
||||
from artiq.management.sync_struct import Publisher
|
||||
from artiq.management.db import FlatFileDB, SimpleHistory
|
||||
from artiq.protocols.pc_rpc import Server
|
||||
from artiq.protocols.sync_struct import Publisher
|
||||
from artiq.protocols.file_db import FlatFileDB, SimpleHistory
|
||||
from artiq.master.scheduler import Scheduler
|
||||
from artiq.master.rt_results import RTResults
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ import time
|
|||
from scipy import interpolate
|
||||
import numpy as np
|
||||
|
||||
from artiq.management.pc_rpc import Client
|
||||
from artiq.protocols.pc_rpc import Client
|
||||
|
||||
|
||||
def _get_args():
|
||||
|
|
|
@ -4,7 +4,7 @@ import argparse
|
|||
import logging
|
||||
|
||||
from artiq.devices.pdq2.driver import Pdq2
|
||||
from artiq.management.pc_rpc import simple_server_loop
|
||||
from artiq.protocols.pc_rpc import simple_server_loop
|
||||
|
||||
|
||||
def _get_args():
|
||||
|
|
|
@ -6,10 +6,11 @@ from inspect import isclass
|
|||
from operator import itemgetter
|
||||
from itertools import chain
|
||||
|
||||
from artiq.management.file_import import file_import
|
||||
from artiq.language.db import *
|
||||
from artiq.management import pyon
|
||||
from artiq.management.db import *
|
||||
from artiq.protocols import pyon
|
||||
from artiq.protocols.file_db import FlatFileDB
|
||||
from artiq.master.db import DBHub, ResultDB
|
||||
from artiq.tools import file_import
|
||||
|
||||
|
||||
class ELFRunner(AutoDB):
|
||||
|
|
|
@ -5,7 +5,7 @@ import time
|
|||
from gi.repository import Gtk
|
||||
|
||||
from artiq.gui.tools import Window, ListSyncer, DictSyncer
|
||||
from artiq.management.sync_struct import Subscriber
|
||||
from artiq.protocols.sync_struct import Subscriber
|
||||
|
||||
|
||||
class _ParameterStoreSyncer(DictSyncer):
|
||||
|
|
|
@ -4,7 +4,7 @@ from collections import defaultdict
|
|||
from gi.repository import Gtk
|
||||
import cairoplot
|
||||
|
||||
from artiq.management.sync_struct import Subscriber
|
||||
from artiq.protocols.sync_struct import Subscriber
|
||||
from artiq.gui.tools import Window
|
||||
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@ import asyncio
|
|||
from gi.repository import Gtk
|
||||
|
||||
from artiq.gui.tools import Window, ListSyncer, DictSyncer
|
||||
from artiq.management.sync_struct import Subscriber
|
||||
from artiq.management.tools import format_run_arguments
|
||||
from artiq.protocols.sync_struct import Subscriber
|
||||
from artiq.tools import format_run_arguments
|
||||
|
||||
|
||||
class _QueueStoreSyncer(ListSyncer):
|
||||
|
|
|
@ -1,53 +1,7 @@
|
|||
from collections import OrderedDict
|
||||
import importlib
|
||||
from time import time
|
||||
|
||||
from artiq.language.db import *
|
||||
from artiq.management import pyon
|
||||
from artiq.management.sync_struct import Notifier
|
||||
|
||||
|
||||
class FlatFileDB:
|
||||
def __init__(self, filename):
|
||||
self.filename = filename
|
||||
self.data = Notifier(pyon.load_file(self.filename))
|
||||
self.hooks = []
|
||||
|
||||
def save(self):
|
||||
pyon.store_file(self.filename, self.data.read)
|
||||
|
||||
def request(self, name):
|
||||
return self.data.read[name]
|
||||
|
||||
def set(self, name, value):
|
||||
self.data[name] = value
|
||||
self.save()
|
||||
timestamp = time()
|
||||
for hook in self.hooks:
|
||||
hook.set(timestamp, name, value)
|
||||
|
||||
def delete(self, name):
|
||||
del self.data[name]
|
||||
self.save()
|
||||
timestamp = time()
|
||||
for hook in self.hooks:
|
||||
hook.delete(timestamp, name)
|
||||
|
||||
|
||||
class SimpleHistory:
|
||||
def __init__(self, depth):
|
||||
self.depth = depth
|
||||
self.history = Notifier([])
|
||||
|
||||
def set(self, timestamp, name, value):
|
||||
if len(self.history.read) >= self.depth:
|
||||
del self.history[0]
|
||||
self.history.append((timestamp, name, value))
|
||||
|
||||
def delete(self, timestamp, name):
|
||||
if len(self.history.read) >= self.depth:
|
||||
del self.history[0]
|
||||
self.history.append((timestamp, name))
|
||||
from artiq.protocols.sync_struct import Notifier
|
||||
|
||||
|
||||
class ResultDB:
|
|
@ -1,4 +1,4 @@
|
|||
from artiq.management.sync_struct import Notifier, process_mod
|
||||
from artiq.protocols.sync_struct import Notifier, process_mod
|
||||
|
||||
|
||||
class RTResults:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import asyncio
|
||||
from time import time
|
||||
|
||||
from artiq.management.sync_struct import Notifier
|
||||
from artiq.protocols.sync_struct import Notifier
|
||||
from artiq.master.worker import Worker
|
||||
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import subprocess
|
|||
import signal
|
||||
import traceback
|
||||
|
||||
from artiq.management import pyon
|
||||
from artiq.protocols import pyon
|
||||
|
||||
|
||||
class WorkerFailed(Exception):
|
||||
|
|
|
@ -2,10 +2,10 @@ import sys
|
|||
from inspect import isclass
|
||||
import traceback
|
||||
|
||||
from artiq.management import pyon
|
||||
from artiq.management.file_import import file_import
|
||||
from artiq.protocols import pyon
|
||||
from artiq.tools import file_import
|
||||
from artiq.language.db import AutoDB
|
||||
from artiq.management.db import DBHub, ResultDB
|
||||
from artiq.master.db import DBHub, ResultDB
|
||||
|
||||
|
||||
def get_object():
|
||||
|
|
|
@ -1,21 +1,5 @@
|
|||
import asyncio
|
||||
import sys
|
||||
from copy import copy
|
||||
from operator import itemgetter
|
||||
|
||||
|
||||
def clear_screen():
|
||||
sys.stdout.write("\x1b[2J\x1b[H")
|
||||
|
||||
|
||||
def format_run_arguments(arguments):
|
||||
fmtargs = []
|
||||
for k, v in sorted(arguments.items(), key=itemgetter(0)):
|
||||
fmtargs.append(k + "=" + str(v))
|
||||
if fmtargs:
|
||||
return " ".join(fmtargs)
|
||||
else:
|
||||
return "-"
|
||||
|
||||
|
||||
class AsyncioServer:
|
|
@ -0,0 +1,47 @@
|
|||
from time import time
|
||||
|
||||
from artiq.protocols import pyon
|
||||
from artiq.protocols.sync_struct import Notifier
|
||||
|
||||
|
||||
class FlatFileDB:
|
||||
def __init__(self, filename):
|
||||
self.filename = filename
|
||||
self.data = Notifier(pyon.load_file(self.filename))
|
||||
self.hooks = []
|
||||
|
||||
def save(self):
|
||||
pyon.store_file(self.filename, self.data.read)
|
||||
|
||||
def request(self, name):
|
||||
return self.data.read[name]
|
||||
|
||||
def set(self, name, value):
|
||||
self.data[name] = value
|
||||
self.save()
|
||||
timestamp = time()
|
||||
for hook in self.hooks:
|
||||
hook.set(timestamp, name, value)
|
||||
|
||||
def delete(self, name):
|
||||
del self.data[name]
|
||||
self.save()
|
||||
timestamp = time()
|
||||
for hook in self.hooks:
|
||||
hook.delete(timestamp, name)
|
||||
|
||||
|
||||
class SimpleHistory:
|
||||
def __init__(self, depth):
|
||||
self.depth = depth
|
||||
self.history = Notifier([])
|
||||
|
||||
def set(self, timestamp, name, value):
|
||||
if len(self.history.read) >= self.depth:
|
||||
del self.history[0]
|
||||
self.history.append((timestamp, name, value))
|
||||
|
||||
def delete(self, timestamp, name):
|
||||
if len(self.history.read) >= self.depth:
|
||||
del self.history[0]
|
||||
self.history.append((timestamp, name))
|
|
@ -1,7 +1,7 @@
|
|||
"""
|
||||
This module provides a remote procedure call (RPC) mechanism over sockets
|
||||
between conventional computers (PCs) running Python. It strives to be
|
||||
transparent and uses ``artiq.management.pyon`` internally so that e.g. Numpy
|
||||
transparent and uses ``artiq.protocols.pyon`` internally so that e.g. Numpy
|
||||
arrays can be easily used.
|
||||
|
||||
Note that the server operates on copies of objects provided by the client,
|
||||
|
@ -16,8 +16,8 @@ import socket
|
|||
import asyncio
|
||||
import traceback
|
||||
|
||||
from artiq.management import pyon
|
||||
from artiq.management.tools import AsyncioServer as _AsyncioServer
|
||||
from artiq.protocols import pyon
|
||||
from artiq.protocols.asyncio_server import AsyncioServer as _AsyncioServer
|
||||
|
||||
|
||||
class RemoteError(Exception):
|
||||
|
@ -140,7 +140,7 @@ class Client:
|
|||
|
||||
|
||||
class AsyncioClient:
|
||||
"""This class is similar to :class:`artiq.management.pc_rpc.Client`, but
|
||||
"""This class is similar to :class:`artiq.protocols.pc_rpc.Client`, but
|
||||
uses ``asyncio`` instead of blocking calls.
|
||||
|
||||
All RPC methods are coroutines.
|
|
@ -1,8 +1,8 @@
|
|||
import asyncio
|
||||
from operator import getitem
|
||||
|
||||
from artiq.management import pyon
|
||||
from artiq.management.tools import AsyncioServer
|
||||
from artiq.protocols import pyon
|
||||
from artiq.protocols.asyncio_server import AsyncioServer
|
||||
|
||||
|
||||
_init_string = b"ARTIQ sync_struct\n"
|
|
@ -6,7 +6,7 @@ import time
|
|||
|
||||
import numpy as np
|
||||
|
||||
from artiq.management import pc_rpc
|
||||
from artiq.protocols import pc_rpc
|
||||
|
||||
|
||||
test_address = "::1"
|
||||
|
|
|
@ -5,7 +5,7 @@ from fractions import Fraction
|
|||
import numpy as np
|
||||
|
||||
from artiq.language.units import *
|
||||
from artiq.management import pyon
|
||||
from artiq.protocols import pyon
|
||||
|
||||
|
||||
_pyon_test_object = {
|
||||
|
|
|
@ -1,7 +1,18 @@
|
|||
from operator import itemgetter
|
||||
import importlib.machinery
|
||||
import linecache
|
||||
|
||||
|
||||
def format_run_arguments(arguments):
|
||||
fmtargs = []
|
||||
for k, v in sorted(arguments.items(), key=itemgetter(0)):
|
||||
fmtargs.append(k + "=" + str(v))
|
||||
if fmtargs:
|
||||
return " ".join(fmtargs)
|
||||
else:
|
||||
return "-"
|
||||
|
||||
|
||||
def file_import(filename):
|
||||
linecache.checkcache(filename)
|
||||
|
|
@ -5,7 +5,7 @@ These drivers are for "slow" devices that are directly controlled by a PC, typic
|
|||
|
||||
Certain devices (such as the PDQ2) may still perform real-time operations by having certain controls physically connected to the core device (for example, the trigger and frame selection signals on the PDQ2). For handling such cases, parts of the drivers may be kernels executed on the core device.
|
||||
|
||||
Each driver is run in a separate "controller" that exposes a RPC interface (based on :class:`artiq.management.pc_rpc`) to its functions. The master never does direct I/O to the devices, but issues RPCs to the controllers when needed. As opposed to running everything on the master, this architecture has those main advantages:
|
||||
Each driver is run in a separate "controller" that exposes a RPC interface (based on :class:`artiq.protocols.pc_rpc`) to its functions. The master never does direct I/O to the devices, but issues RPCs to the controllers when needed. As opposed to running everything on the master, this architecture has those main advantages:
|
||||
|
||||
* Each driver can be run on a different machine, which alleviates cabling issues and OS compatibility problems.
|
||||
* Reduces the impact of driver crashes.
|
||||
|
|
|
@ -11,6 +11,6 @@ Contents:
|
|||
writing_a_driver
|
||||
core_language_reference
|
||||
core_drivers_reference
|
||||
management_reference
|
||||
protocols_reference
|
||||
drivers_reference
|
||||
fpga_board_ports
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
Management reference
|
||||
====================
|
||||
|
||||
:mod:`artiq.management.pyon` module
|
||||
-----------------------------------
|
||||
|
||||
.. automodule:: artiq.management.pyon
|
||||
:members:
|
||||
|
||||
:mod:`artiq.management.tools` module
|
||||
------------------------------------
|
||||
|
||||
.. automodule:: artiq.management.tools
|
||||
:members:
|
||||
|
||||
|
||||
:mod:`artiq.management.pc_rpc` module
|
||||
-------------------------------------
|
||||
|
||||
.. automodule:: artiq.management.pc_rpc
|
||||
:members:
|
||||
|
||||
:mod:`artiq.management.sync_struct` module
|
||||
------------------------------------------
|
||||
|
||||
.. automodule:: artiq.management.sync_struct
|
||||
:members:
|
|
@ -0,0 +1,27 @@
|
|||
Management reference
|
||||
====================
|
||||
|
||||
:mod:`artiq.protocols.pyon` module
|
||||
----------------------------------
|
||||
|
||||
.. automodule:: artiq.protocols.pyon
|
||||
:members:
|
||||
|
||||
:mod:`artiq.protocols.tools` module
|
||||
-----------------------------------
|
||||
|
||||
.. automodule:: artiq.protocols.tools
|
||||
:members:
|
||||
|
||||
|
||||
:mod:`artiq.protocols.pc_rpc` module
|
||||
------------------------------------
|
||||
|
||||
.. automodule:: artiq.protocols.pc_rpc
|
||||
:members:
|
||||
|
||||
:mod:`artiq.protocols.sync_struct` module
|
||||
-----------------------------------------
|
||||
|
||||
.. automodule:: artiq.protocols.sync_struct
|
||||
:members:
|
|
@ -6,7 +6,7 @@ These instructions cover writing a simple driver for a "slow" device, that uses
|
|||
The controller
|
||||
--------------
|
||||
|
||||
A controller is a piece of software that receives commands from a client over the network (or the ``localhost`` interface), drives a device, and returns information about the device to the client. The mechanism used is remote procedure calls (RPCs) using :class:`artiq.management.pc_rpc`, which makes the network layers transparent for the driver's user.
|
||||
A controller is a piece of software that receives commands from a client over the network (or the ``localhost`` interface), drives a device, and returns information about the device to the client. The mechanism used is remote procedure calls (RPCs) using :class:`artiq.protocols.pc_rpc`, which makes the network layers transparent for the driver's user.
|
||||
|
||||
The controller we will develop is for a "device" that is very easy to work with: the console from which the controller is run. The operation that the driver will implement is writing a message to that console.
|
||||
|
||||
|
@ -16,9 +16,9 @@ For using RPC, the functions that a driver provides must be the methods of a sin
|
|||
def message(self, msg):
|
||||
print("message: " + msg)
|
||||
|
||||
To turn it into a server, we use :class:`artiq.management.pc_rpc`. Import the function we will use: ::
|
||||
To turn it into a server, we use :class:`artiq.protocols.pc_rpc`. Import the function we will use: ::
|
||||
|
||||
from artiq.management.pc_rpc import simple_server_loop
|
||||
from artiq.protocols.pc_rpc import simple_server_loop
|
||||
|
||||
and add a ``main`` function that is run when the program is executed: ::
|
||||
|
||||
|
@ -63,7 +63,7 @@ Create a ``hello_client.py`` file with the following contents: ::
|
|||
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from artiq.management.pc_rpc import Client
|
||||
from artiq.protocols.pc_rpc import Client
|
||||
|
||||
|
||||
def main():
|
||||
|
|
Loading…
Reference in New Issue