{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "### Notebook setup for the pydoocs introduction:" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Populating the interactive namespace from numpy and matplotlib\n" ] } ], "source": [ "%pylab inline" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Setting the search path for modules to get the local path for the latest build (just for the demo here), and\n", "assert that the latest pydoocs actually gets imported:" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": true }, "outputs": [], "source": [ "import sys\n", "import os\n", "import time\n", "\n", "LOCAL_BUILD_PATH = \"/home/cbehrens/doocs/Darwin-x86_64/obj/library/python/pydoocs\"\n", "sys.path.insert(0, LOCAL_BUILD_PATH) \n", "\n", "import pydoocs \n", "\n", "assert os.path.dirname(pydoocs.__file__) == LOCAL_BUILD_PATH" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Setting the test server base address being used throughout this demo:" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": true }, "outputs": [], "source": [ "TEST_SERVER_BASE_ADDRESS = \"TEST.DOOCS/UNIT_TEST_SUPPORT/PY_DOOCS/\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Introduction to pydoocs\n", "#### Table of contents (with internal links):\n", "- [pydoocs module](#module)\n", "- [read function](#read)\n", " - [wildcard operation](#wildcard)\n", "- [write function](#write)\n", " - [write with output](#write-output)\n", "- [names function](#names)\n", "- [exceptions](#exceptions)\n", "- [synchronized readout](#synchronized-readout)\n", " - [via wildcard](#via-wildcard)\n", " - [via macropulse](#via-macropulse)\n", "- [supported data types](#data-types)\n", "- [api breaking differences](#diff-previous)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "## The pydoocs module:" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The pydoocs' module docstring:" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'Python3 bindings to the standard DOOCS client API written in C/C++.'" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "pydoocs.__doc__" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The current pydoocs version:" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'2.0.0'" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "pydoocs.__version__ " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The definitions (functions and exception classes) provided by the pydoocs module:" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['DoocsException', 'PyDoocsException', 'names', 'read', 'write']" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "[element for element in dir(pydoocs) if not element.startswith(\"__\")]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "## The read function:\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The pydoocs' read function docstring:" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'Function to read data from a given DOOCS address.'" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "pydoocs.read.__doc__" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true }, "source": [ "The read function takes at least 1 argument (the DOOCS address to read from) and at most 3 arguments, where the two optional keyword parameters are additional doocs parameters (keyword: parameters) and macropulse number (keyword: macropulse) for synchronization (see [via macropulse](#via-macropulse) below):" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Required argument 'address' (pos 1) not found\n" ] } ], "source": [ "try:\n", " pydoocs.read()\n", "except Exception as err:\n", " print(err)" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "function takes at most 3 arguments (4 given)\n" ] } ], "source": [ "try:\n", " pydoocs.read(\"\", \"\", \"\", \"\")\n", "except Exception as err:\n", " print(err)" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true }, "source": [ "The output of the read function is a python dict with 5 key-value pairs, where the pair 'miscellaneous' is a dict itself and may be used to return additional information (see an example with a non-empty 'miscellaneous' further below):" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'data': 0,\n", " 'macropulse': 17281873,\n", " 'miscellaneous': {},\n", " 'timestamp': 1528723309.669095,\n", " 'type': 'BOOL'}" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "output = pydoocs.read(TEST_SERVER_BASE_ADDRESS + \"BOOL\")\n", "output" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "dict" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "type(output)" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "dict_keys(['data', 'type', 'timestamp', 'macropulse', 'miscellaneous'])" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "output.keys()" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true }, "source": [ "The 'data' key-value pair contains data according to the requested type and can either be a scalar type (e.g. float, int, bool, ...) as shown above, or a list or a numpy array whenever appropriate as demonstrated in the cases below:" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'data': array([[ 0. , 0. ],\n", " [ 0.1 , 1. ],\n", " [ 0.2 , 4. ],\n", " [ 0.30000001, 9. ],\n", " [ 0.40000001, 16. ],\n", " [ 0.5 , 25. ],\n", " [ 0.60000002, 36. ],\n", " [ 0.69999999, 49. ],\n", " [ 0.80000001, 64. ],\n", " [ 0.90000004, 81. ]], dtype=float32),\n", " 'macropulse': 0,\n", " 'miscellaneous': {'comment': '', 'status': 0, 'timestamp': 1526992495},\n", " 'timestamp': 1528724476.295571,\n", " 'type': 'SPECTRUM'}" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "output = pydoocs.read(TEST_SERVER_BASE_ADDRESS + \"SPECTRUM\")\n", "output" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "numpy.ndarray" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "type(output[\"data\"])" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'data': [2, 1.2000000476837158, 2.299999952316284, 3.4000000953674316],\n", " 'macropulse': 0,\n", " 'miscellaneous': {},\n", " 'timestamp': 1528713006.849212,\n", " 'type': 'IFFF'}" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "output = pydoocs.read(TEST_SERVER_BASE_ADDRESS + \"IFFF_ARRAY\")\n", "output" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "list" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "type(output[\"data\"])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "### wildcard (*) operation:" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The wildcard '*' can be utilized to match all possible cases for a readout call, e.g. for reading a property for all locations:" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "data type: A_USTR\n", "first 5 of 54 data elements, each with [-, beam position, -, timestamp, location]: \n", "[[0, 1.61899995803833, 0.0, 1528724476, '1GUN'],\n", " [0, 2.0260000228881836, 0.0, 1528724476, '3GUN'],\n", " [0, 0.0, 0.0, 1528724476, 'IDUMP'],\n", " [0, 0.574999988079071, 0.0, 1528724476, '2UBC2'],\n", " [0, 0.4066508710384369, 0.0, 1528724477, '9ACC1']]\n" ] } ], "source": [ "import pprint # for prettier printing\n", "\n", "output = pydoocs.read(\"FLASH.DIAG/BPM/*/X.FLASH1\") # with wildcard (*) for the DOOCS location\n", "\n", "print(\"data type: \", output[\"type\"])\n", "print(\"first 5 of\", len(output[\"data\"]), \"data elements, each with [-, beam position, -, timestamp, location]: \")\n", "pprint.pprint(output[\"data\"][:5])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "## The write function:" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The pydoocs' write function docstring:" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'Function to write data to a given DOOCS address.'" ] }, "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ "pydoocs.write.__doc__" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true }, "source": [ "The write function takes at least 2 argument (the DOOCS address to write to and the data to write) and at most 3 arguments, where the optional keyword parameter is for additional doocs parameters (keyword: parameters):" ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Required argument 'address' (pos 1) not found\n" ] } ], "source": [ "try:\n", " pydoocs.write()\n", "except Exception as err:\n", " print(err)" ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Required argument 'data' (pos 2) not found\n" ] } ], "source": [ "try:\n", " pydoocs.write(\"\")\n", "except Exception as err:\n", " print(err)" ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "function takes at most 3 arguments (4 given)\n" ] } ], "source": [ "try:\n", " pydoocs.write(\"\", \"\", \"\", \"\")\n", "except Exception as err:\n", " print(err)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Writing to scalar-like data type: " ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "2\n", "3\n" ] } ], "source": [ "output = pydoocs.read(TEST_SERVER_BASE_ADDRESS + \"INTEGER\")\n", "print(output[\"data\"])\n", "\n", "pydoocs.write(TEST_SERVER_BASE_ADDRESS + \"INTEGER\", output[\"data\"] + 1) # increment the data by one\n", "\n", "output = pydoocs.read(TEST_SERVER_BASE_ADDRESS + \"INTEGER\")\n", "print(output[\"data\"])" ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0\n", "1\n" ] } ], "source": [ "output = pydoocs.read(TEST_SERVER_BASE_ADDRESS + \"BOOL\")\n", "print(output[\"data\"])\n", "\n", "pydoocs.write(TEST_SERVER_BASE_ADDRESS + \"BOOL\", False if output['data'] else True) # negation\n", "\n", "output = pydoocs.read(TEST_SERVER_BASE_ADDRESS + \"BOOL\")\n", "print(output[\"data\"])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Writing to array-like data type: " ] }, { "cell_type": "code", "execution_count": 24, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[1, 2, 3, 4]\n", "[4, 3, 2, 1]\n" ] } ], "source": [ "output = pydoocs.read(TEST_SERVER_BASE_ADDRESS + \"IIII_ARRAY\")\n", "print(output[\"data\"])\n", "\n", "pydoocs.write(TEST_SERVER_BASE_ADDRESS +\"IIII_ARRAY\", output[\"data\"][::-1]) # reverse the data\n", "\n", "output = pydoocs.read(TEST_SERVER_BASE_ADDRESS +\"IIII_ARRAY\")\n", "print(output[\"data\"])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Currently, writing to array-like data types requires a list for the input type, whereas numpy arrays might be returned as data type:" ] }, { "cell_type": "code", "execution_count": 25, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[[ 0. 0. ]\n", " [ 0.1 1. ]\n", " [ 0.2 4. ]\n", " [ 0.30000001 9. ]\n", " [ 0.40000001 16. ]\n", " [ 0.5 25. ]\n", " [ 0.60000002 36. ]\n", " [ 0.69999999 49. ]\n", " [ 0.80000001 64. ]\n", " [ 0.90000004 81. ]]\n", "[[ 0. -0. ]\n", " [ 0.1 -1. ]\n", " [ 0.2 -4. ]\n", " [ 0.30000001 -9. ]\n", " [ 0.40000001 -16. ]\n", " [ 0.5 -25. ]\n", " [ 0.60000002 -36. ]\n", " [ 0.69999999 -49. ]\n", " [ 0.80000001 -64. ]\n", " [ 0.90000004 -81. ]]\n" ] } ], "source": [ "output = pydoocs.read(TEST_SERVER_BASE_ADDRESS + \"SPECTRUM\")\n", "print(output[\"data\"])\n", "\n", "pydoocs.write(TEST_SERVER_BASE_ADDRESS + \"SPECTRUM\", list(-output[\"data\"][:,1])) # inverting sign of the data\n", "\n", "output = pydoocs.read(TEST_SERVER_BASE_ADDRESS + \"SPECTRUM\")\n", "print(output[\"data\"])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "### write call with output (remote procedure call like):" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true }, "source": [ "When implemented in the DOOCS server, remote procedure call like write calls with output can be realized:" ] }, { "cell_type": "code", "execution_count": 26, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "False\n" ] }, { "data": { "text/plain": [ "{'data': 65,\n", " 'macropulse': 0,\n", " 'miscellaneous': {},\n", " 'timestamp': 1528724478.0,\n", " 'type': 'INT'}" ] }, "execution_count": 26, "metadata": {}, "output_type": "execute_result" } ], "source": [ "output = pydoocs.write(TEST_SERVER_BASE_ADDRESS + \"STRING\", \"A\") # standard address without RPC functionality\n", "\n", "output = pydoocs.write(TEST_SERVER_BASE_ADDRESS + \"D_INT_FROM_STRING_SET\", \"A\") # address which return the ASCII code\n", "print(output is None) # for the given input character\n", "output" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "## The names function:" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The pydoocs' names function docstring:" ] }, { "cell_type": "code", "execution_count": 27, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'Function to query names from a given DOOCS name domain.'" ] }, "execution_count": 27, "metadata": {}, "output_type": "execute_result" } ], "source": [ "pydoocs.names.__doc__" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true }, "source": [ "The names function uses the wildcard (*) on each of the four parts of a DOOCS given by Facility/Device/Location/Property. It takes exactly 1 argument:" ] }, { "cell_type": "code", "execution_count": 28, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "function takes exactly 1 argument (0 given)\n" ] } ], "source": [ "try:\n", " pydoocs.names()\n", "except Exception as err:\n", " print(err)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Find all available facilities and print the first 4 of them:" ] }, { "cell_type": "code", "execution_count": 29, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "first 4 of 153 facilities found:\n", "['TTF2.VAC', 'TTF2.RF', 'TTF2.DIAG', 'TTF2.DAQ']\n" ] } ], "source": [ "facilities = pydoocs.names(\"*\")\n", "\n", "print(\"first 4 of \", len(facilities), \" facilities found:\\n\", facilities[:4], sep='')" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true }, "source": [ "Find all available devices for the FLASH.DIAG facility and print the first 4 of them:" ] }, { "cell_type": "code", "execution_count": 30, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "first 4 of 119 devices found in FLASH.DIAG:\n", "['TIMER', 'BUNCHINFO', 'BEAMLINES', 'MCP.HV']\n" ] } ], "source": [ "devices = pydoocs.names(\"FLASH.DIAG/*\")\n", "\n", "print(\"first 4 of \", len(devices), \" devices found in FLASH.DIAG:\\n\", devices[:4], sep='')" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true }, "source": [ "Find all available location for the FLASH.DIAG/BPM device and print the first 4 of them:" ] }, { "cell_type": "code", "execution_count": 31, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "first 4 of 126 locations found in FLASH.DIAG/BPM:\n", "['FLASHCPUDIAG2._SVR', '1GUN', '3GUN', 'IDUMP']\n" ] } ], "source": [ "locations = pydoocs.names(\"FLASH.DIAG/BPM/*\")\n", "\n", "print(\"first 4 of \", len(locations), \" locations found in FLASH.DIAG/BPM:\\n\", locations[:4], sep='')" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true }, "source": [ "Find all available properties for the FLASH.DIAG/BPM/1GUN location and print the first 4 of them:" ] }, { "cell_type": "code", "execution_count": 32, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "first 4 of 328 properties found in FLASH.DIAG/BPM/1GUN:\n", "['NAME = location', 'STS gen.Status word', 'STS.ERROR pending error status', 'STS.NEWERROR new error detected']\n" ] } ], "source": [ "properties = pydoocs.names(\"FLASH.DIAG/BPM/1GUN/*\")\n", "\n", "print(\"first 4 of \", len(properties), \" properties found in FLASH.DIAG/BPM/1GUN:\\n\", properties[:4], sep='')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "## Exceptions:\n", "Pydoocs comes with two custom exceptions, DoocsException and PyDoocsException. The former is related to DOOCS specific exceptions and errors, and the latter for pydoocs specific ones. Both are definitions (classes) of the pydoocs module, and they can be raised by any pydoocs function." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The pydoocs' DoocsException exception docstring:" ] }, { "cell_type": "code", "execution_count": 33, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "\"Custom DOOCS exception with dict_keys(['code', 'message']) in its first argument.\"" ] }, "execution_count": 33, "metadata": {}, "output_type": "execute_result" } ], "source": [ "pydoocs.DoocsException.__doc__" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The pydoocs' PyDoocsException exception docstring:" ] }, { "cell_type": "code", "execution_count": 34, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'Custom pydoocs exception with specific message.'" ] }, "execution_count": 34, "metadata": {}, "output_type": "execute_result" } ], "source": [ "pydoocs.PyDoocsException.__doc__" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true }, "source": [ "Here we read an incomplete DOOCS address (the property part is missing), and the read function raises a DoocsException:" ] }, { "cell_type": "code", "execution_count": 35, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "{'code': 101, 'message': 'illegal service'}\n", "({'code': 101, 'message': 'illegal service'},)\n", "101\n", "illegal service\n" ] } ], "source": [ "try:\n", " pydoocs.read(TEST_SERVER_BASE_ADDRESS)\n", "except pydoocs.DoocsException as err:\n", " print(err)\n", " print(err.args) # the err.args attribute is a list with a dict in its first element\n", " print(err.args[0]['code']) # the DOOCS specific error code\n", " print(err.args[0]['message']) # the DOOCS specific error message" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Here we write an argument with the wrong format (float instead of bool or int), and the write function raises a PyDoocsException:" ] }, { "cell_type": "code", "execution_count": 36, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "wrong input data format\n", "('wrong input data format',)\n", "wrong input data format\n" ] } ], "source": [ "try:\n", " pydoocs.write(TEST_SERVER_BASE_ADDRESS + \"BOOL\", 1.5)\n", "except pydoocs.PyDoocsException as err:\n", " print(err)\n", " print(err.args) # the err.args attribute is a list with a str in its first element\n", " print(err.args[0]) # the pydoocs specific exception message" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Both custom exceptions in the pydoocs module are subclasses of Exception:" ] }, { "cell_type": "code", "execution_count": 37, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 37, "metadata": {}, "output_type": "execute_result" } ], "source": [ "issubclass(pydoocs.DoocsException, Exception) and issubclass(pydoocs.PyDoocsException, Exception)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The exception 'Exception' can thus be catched in both cases:" ] }, { "cell_type": "code", "execution_count": 38, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "{'code': 101, 'message': 'illegal service'}\n", "\n" ] } ], "source": [ "try:\n", " pydoocs.read(TEST_SERVER_BASE_ADDRESS)\n", "except Exception as err:\n", " print(err)\n", " print(type(err)) # the actual (dynamic) exception type" ] }, { "cell_type": "code", "execution_count": 39, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "wrong input data format\n", "\n" ] } ], "source": [ "try:\n", " pydoocs.write(TEST_SERVER_BASE_ADDRESS + \"BOOL\", 1.5)\n", "except Exception as err:\n", " print(err)\n", " print(type(err)) # the actual (dynamic) exception type" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "## Synchronized readout" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Pydoocs has two way to get synchronized data, one of them is very limited (via wildcard) and the other one (via macropulse) is only party supported on the DOOCS server side and buggy (see also information below). The latter will certainly improve over time and with usage. " ] }, { "cell_type": "markdown", "metadata": { "collapsed": true }, "source": [ "\n", "### via wildcard:" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Synchronized readout via wildcard (see also [wildcard operation](#wildcard) above) can be achieved in the following way:" ] }, { "cell_type": "code", "execution_count": 40, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'10DBC2': {'charge': 0.34880000352859497, 'macropulse': 1528724478},\n", " '11SMATCH': {'charge': 0.3465000092983246, 'macropulse': 1528724478},\n", " '12EXP': {'charge': 0.34404999017715454, 'macropulse': 1528724478},\n", " '18ACC7': {'charge': 0.34599998593330383, 'macropulse': 1528724478},\n", " '1UBC3': {'charge': 0.34825000166893005, 'macropulse': 1528724478},\n", " '2SDUMP': {'charge': nan, 'macropulse': 1528711230},\n", " '2UBC2': {'charge': 0.34325000643730164, 'macropulse': 1528724478},\n", " '3GUN': {'charge': 0.34850001335144043, 'macropulse': 1528724478},\n", " '4TCOL': {'charge': 0.34860000014305115, 'macropulse': 1528724478},\n", " '5DBC3': {'charge': 0.3497999906539917, 'macropulse': 1528724478},\n", " '7ORS': {'charge': 0.3458999991416931, 'macropulse': 1528724478},\n", " '9DUMP': {'charge': 0.34244999289512634, 'macropulse': 1528724478}}" ] }, "execution_count": 40, "metadata": {}, "output_type": "execute_result" } ], "source": [ "output = pydoocs.read(\"FLASH.DIAG/TOROID.ML/*/CHARGE.FLASH1\")\n", "toroids = {element[4]: {\"charge\": element[1], \n", " \"macropulse\": element[3]} for element in output['data']} # create a dict for improved output\n", "toroids" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Each device (when implemented and running properly) has the same macropulse number. A demonstration would be to show an existing correlation, which only shows up when the readout is synchronized:" ] }, { "cell_type": "code", "execution_count": 41, "metadata": {}, "outputs": [ { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYcAAAD8CAYAAACcjGjIAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3X+Q3HWd5/HnK8OAQ1QGLoGDCQjh52JhEpwF7kAPUQk/\nUiTAIsTlsIotWTyxgNVQyRbn4eJVItESbotalmXZ8oqSH7smOTSUUeGUkjswk0sgRoiEVCAZXBLB\n8Q4cYTJ53x/97cl3+ue3e7oz3T2vRxXV3Z/vj/58SNLv7+e3IgIzM7O0aZOdATMzaz0ODmZmVsTB\nwczMijg4mJlZEQcHMzMr4uBgZmZFMgUHSRdJ2ippm6SlJY4vlPSCpE2SBiSdlzq2Q9Lm/LFU+lWS\ntkjaJ6m/McUxM7NGULV5DpK6gF8DnwZ2AeuBxRHxq9Q57wfeiYiQ9BHgsYg4LTm2A+iPiN8W3PdP\ngH3A3wNfiYgBzMysJRyU4ZyzgG0RsR1A0iPAQmAsOETE26nzpwNVZ9ZFxIvJ/WrJr5mZHQBZgkMf\nsDP1eRdwduFJki4HlgNHApemDgXwE0mjwN9HxP31ZnbGjBlx/PHH13u5mdmUtGHDht9GxMxarskS\nHDKJiNXAakkfB+4EPpUcOi8iBiUdCfxY0ksR8XTW+0q6AbgB4LjjjmNgwK1PZma1kPRqrddk6ZAe\nBI5NfZ6VpJWU/PDPljQj+TyYvO4GVpNrpsosIu6PiP6I6J85s6bAZ2ZmdcoSHNYDJ0s6QdLBwDXA\n4+kTJJ2kpPNA0pnAIcCbkqZL+kCSPh24EPhlIwtgZmaNV7VZKSL2SroJWAd0AQ9GxBZJNybH7wOu\nBK6TNAIMA1cnI5eOItfUlP+u70bED2Gsj+JvgZnAWkmbImJ+44toZma1qjqUtZX09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A3LcCPwN8n7U8hVc9VOZUjSLgJ+1sZ/\nl14Ezk/efxLY0IZlODJ5nQb8d+D6ViwDubb7DyTp04H/BVyUfF7J+A7pu9qtDKlrf0rGDulMayt1\nomjegoJ3SZpLruq5A/jLNizDg8CDkn5JrhngcxmuabUyAFzDAWhSamIZPg/ck9SA/ghMqA15ksqw\nWNIXk/ergH9qTgkmVgZJRwGrk9bTg4DvRsQPk1uvINe0+hfkVoX+TLuVQdLlwN8CM4G1kjZFxPxK\nefEMaTMzKzKV+xzMzKwMBwczMyvi4GBmZkUcHMzMrIiDg5mZFXFwMDOzIg4OZmZWxMHBzMyK/H+f\nxGbGZIn+BwAAAABJRU5ErkJggg==\n", "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "samples = []\n", "for _ in range(100): # 100 samples\n", " samples.append(pydoocs.read(\"FLASH.DIAG/TOROID.ML/*/CHARGE.FLASH1\")['data'])\n", " time.sleep(0.1) # read-out with repetition rate of ~10Hz\n", " \n", "toroids = {element[4]: [] for element in samples[0]} # generate output dict with all toroids\n", "for sample in samples: # fill output dict\n", " for element in sample:\n", " toroids[element[4]].append(element[1])\n", " \n", "plot(toroids[\"3GUN\"], toroids[\"1UBC3\"], 'o'); # just print two of them against each other" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The downside of this approach is that only works for one device. Synchronizing several devices would require memorizing and post-sorting the data utilizing the macropulse number. A better approach is to directly synchronize via the macropulse number as described below." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "### via macropulse number:" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Synchronized readout via macropulse number can be achieved in the following way:" ] }, { "cell_type": "code", "execution_count": 42, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "1717296712 1717296712 0\n" ] } ], "source": [ "output1 = pydoocs.read(\"FLASH.DIAG/TOROID.ML/3GUN/CHARGE.FLASH1\")\n", "time.sleep(2) # to simulate time lag between read calls in order to prevent intrinsic synchronization\n", "output2 = pydoocs.read(\"FLASH.DIAG/TOROID.ML/3GUN/CHARGE.FLASH1\", \n", " macropulse=output1[\"macropulse\"]) # providing the macropulse from the first call\n", "\n", "print(output2[\"macropulse\"], output1[\"macropulse\"], output2[\"macropulse\"] - output1[\"macropulse\"])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Without providing the macropulse from the first call, one would see a macropulse difference unequal 0 between the two calls:" ] }, { "cell_type": "code", "execution_count": 43, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "1717296752 1717296732 20\n" ] } ], "source": [ "output1 = pydoocs.read(\"FLASH.DIAG/TOROID.ML/3GUN/CHARGE.FLASH1\")\n", "time.sleep(2)\n", "output2 = pydoocs.read(\"FLASH.DIAG/TOROID.ML/3GUN/CHARGE.FLASH1\")\n", "\n", "print(output2[\"macropulse\"], output1[\"macropulse\"], output2[\"macropulse\"] - output1[\"macropulse\"])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Of course, synchronized readout via macropulse number works for different locations, which is also demonstrated by the correlation plot (cf. the plot from the wildcard method above)." ] }, { "cell_type": "code", "execution_count": 44, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "1717296752 1717296752 0\n" ] } ], "source": [ "output1 = pydoocs.read(\"FLASH.DIAG/TOROID.ML/3GUN/CHARGE.FLASH1\")\n", "time.sleep(2)\n", "output2 = pydoocs.read(\"FLASH.DIAG/TOROID.ML/1UBC3/CHARGE.FLASH1\", macropulse=output1[\"macropulse\"])\n", "\n", "print(output2[\"macropulse\"], output1[\"macropulse\"], output2[\"macropulse\"] - output1[\"macropulse\"])" ] }, { "cell_type": "code", "execution_count": 45, "metadata": {}, "outputs": [ { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYsAAAD8CAYAAACGsIhGAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3X+wXGWd5/H3h5uAlygGKoGVGyIBhKxTS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Lz+G7rz76Zb/+Y3R8RHI+K91IL0iz3WdiJiPPlzO7CS/X+/r0p6B0DyZzeG\nXaF77W9NOwmXTvyP2m+hL1F7uNeTNr/XcM1J7E/anJH8BanhmnPIT1RupTsJ7q60HXhH6vVNwINV\n+rsHbgD+a/L6ZGpdZ1Wh7cmxC4AfVe3fPPA8cE7y+sPA+gq1/ejkz0OA/wlc10ttpzb+/7bk+Czg\n/wIXJO/v5MAE9x299u+mWftTn32cEgnuaduDOyJ2S7qRWtXSEHB/RGySdENy/h5qya5PStoFTABX\nRvLtplMX236HpEXUurNbgT+sWPvvB+6X9By14YRrO/3/V5f/3VxFF4egutj2TwHfTHpGvwXaHpee\nhrZfLemJwVJMAAAAc0lEQVQzyeuHgb/qpbZLOgZYmYymzgC+ExF/m9x6ObWh1j+gVnl5Rafb3s32\nS7oU+O/AXGCNpI0RcX5eOzyD28zMCvV8gtvMzKafg4WZmRVysDAzs0IOFmZmVsjBwszMCjlYmJlZ\nIQcLMzMr5GBhZmaF/j/TBPAIu3UCywAAAABJRU5ErkJggg==\n", "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "toroids = {\"3GUN\": [], \"1UBC3\": []}\n", "for _ in range(100): # 100 samples\n", " output = pydoocs.read(\"FLASH.DIAG/TOROID.ML/3GUN/CHARGE.FLASH1\")\n", " toroids[\"3GUN\"].append(output[\"data\"])\n", " \n", " time.sleep(0.2) # to simulate time lag between read calls to prevent intrinsic synchronization\n", " \n", " output = pydoocs.read(\"FLASH.DIAG/TOROID.ML/1UBC3/CHARGE.FLASH1\", macropulse=output[\"macropulse\"])\n", " toroids[\"1UBC3\"].append(output[\"data\"])\n", " \n", "plot(toroids[\"3GUN\"], toroids[\"1UBC3\"], 'o');" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In contrast to the wildcard approach, we can also synchronize different device:" ] }, { "cell_type": "code", "execution_count": 53, "metadata": { "scrolled": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "1717297167 1717297167 0\n" ] } ], "source": [ "output1 = pydoocs.read(\"FLASH.DIAG/TOROID.ML/3GUN/CHARGE.FLASH1\")\n", "time.sleep(2)\n", "try:\n", " output2 = pydoocs.read(\"FLASH.DIAG/ORBIT/3GUN/X.FLASH1\", macropulse=output1[\"macropulse\"])\n", " \n", " print(output2[\"macropulse\"], output1[\"macropulse\"], output2[\"macropulse\"] - output1[\"macropulse\"])\n", "except pydoocs.PyDoocsException as err:\n", " print(err) " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "However, when the synchronization in the DOOCS server is not working properly or the time lag between calls is too large, differences in the requested and actual macropulse can occur, which in turn leads to a 'macropulse mismatch' PyDoocsException." ] }, { "cell_type": "code", "execution_count": 47, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "macropulse mismatch: (requested - actual) is -1\n" ] } ], "source": [ "output = pydoocs.read(\"FLASH.DIAG/TOROID.ML/3GUN/CHARGE.FLASH1\")\n", "time.sleep(2)\n", "try:\n", " pydoocs.read(\"FLASH.DIAG/ORBIT/3GUN/X.FLASH1\", macropulse=output[\"macropulse\"])\n", "except pydoocs.PyDoocsException as err:\n", " print(err)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The DOOCS server support for synchronization via macropulse is currently very limited (see also [supported data types](#data-types) below), but this will certainly improve over time and with usage. " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "## Supported data types:" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The data types and operations on them, as discussed throughout this introduction, currently supported:" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true }, "source": [ "| Data type | Read Support | Synchronization | Write Support | Write with Output |\n", "|:----------:|:------------:|:---------------:|:-------------:|:-----------------:|\n", "| BOOL | yes | no | yes | no |\n", "| INT | yes | no | yes | no |\n", "| LONG | yes | no | yes | no |\n", "| FLOAT | yes | yes | yes | no |\n", "| DOUBLE | yes | no | yes | no |\n", "| STRING | yes | no | yes | yes |\n", "| TEXT | yes | no | yes | no |\n", "| IFFF | yes | no | yes | no |\n", "| IIII | yes | no | yes | no |\n", "| A_INT | yes | no | yes | no |\n", "| A_LONG | yes | no | yes | no |\n", "| A_FLOAT | yes | no | yes | no |\n", "| A_DOUBLE | yes | no | yes | no |\n", "| A_BYTE | yes | no | no | no |\n", "| A_TS_FLOAT | yes | no | no | no |\n", "| A_XYZS | yes | no | no | no |\n", "| A_XY | yes | no | no | no |\n", "| A_USTR | yes | no | no | no |\n", "| A_TDS | yes | no | no | no |\n", "| SPECTRUM | yes | yes | yes | no |\n", "| GSPECTRUM | yes | no | no | no |\n", "| IMAGE | yes | no | no | no |\n", "| | | | | |\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "## The API breaking differences compared to the previous pydoocs version:" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### The old version has a 'channel' key, which has been removed in this new version, and the new version has an additional 'miscellaneous' key to store optional data in a dict (see also [read function](#read) above):" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "old version: \n", "```\n", "pydoocs.read(TEST_SERVER_BASE_ADDRESS + \"BOOL\").keys()\n", "dict_keys(['data', 'type', 'channel', 'timestamp', 'macropulse'])\n", "```" ] }, { "cell_type": "code", "execution_count": 48, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "dict_keys(['data', 'type', 'timestamp', 'macropulse', 'miscellaneous'])" ] }, "execution_count": 48, "metadata": {}, "output_type": "execute_result" } ], "source": [ "pydoocs.read(TEST_SERVER_BASE_ADDRESS + \"BOOL\").keys()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### The new version has no explicit 'numpy' keyword anymore, as it returns numpy array as a default whenever reasonable, e.g. for array types (see also [read function](#read) above):" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "old version:\n", "```\n", "output = pydoocs.read(TEST_SERVER_BASE_ADDRESS + \"IMAGE\", numpy=True); type(output['data'])\n", "numpy.ndarray\n", "```" ] }, { "cell_type": "code", "execution_count": 49, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "numpy.ndarray" ] }, "execution_count": 49, "metadata": {}, "output_type": "execute_result" } ], "source": [ "output = pydoocs.read(TEST_SERVER_BASE_ADDRESS + \"IMAGE\"); type(output['data'])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### The new version either returns 'lists' or 'numpy.ndarrays' for non-skalar types as opposed to the old version, which returns 'tuples' or 'dicts' (see also [read function](#read) above):" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "old version: \n", "```\n", "output = pydoocs.read(TEST_SERVER_BASE_ADDRESS + \"INTEGER_ARRAY\"); type(output['data'])\n", "tuple\n", "```" ] }, { "cell_type": "code", "execution_count": 50, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "numpy.ndarray" ] }, "execution_count": 50, "metadata": {}, "output_type": "execute_result" } ], "source": [ "output = pydoocs.read(TEST_SERVER_BASE_ADDRESS + \"INTEGER_ARRAY\"); type(output['data'])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "old version: \n", "```\n", "output = pydoocs.read(TEST_SERVER_BASE_ADDRESS + \"IFFF_ARRAY\"); type(output['data'])\n", "dict\n", "```" ] }, { "cell_type": "code", "execution_count": 51, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "list" ] }, "execution_count": 51, "metadata": {}, "output_type": "execute_result" } ], "source": [ "output = pydoocs.read(TEST_SERVER_BASE_ADDRESS + \"IFFF_ARRAY\"); type(output['data'])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### The 'OSError' exception in the old version has been replaced by the two custom exceptions DoocsException and PyDoocsException (see also [exceptions](#exceptions) above):" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "old version:
\n", "```\n", "try:\n", " pydoocs.read(TEST_SERVER_BASE_ADDRESS)\n", "except OSError as err:\n", " print(err)\n", "{'code': 101, 'message': 'illegal service'}\n", "\n", "```" ] }, { "cell_type": "code", "execution_count": 52, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "{'code': 101, 'message': 'illegal service'}\n" ] } ], "source": [ "try:\n", " pydoocs.read(TEST_SERVER_BASE_ADDRESS)\n", "except pydoocs.DoocsException as err:\n", " print(err)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.1" } }, "nbformat": 4, "nbformat_minor": 2 }