Skip to content

Canadian-Light-Source/SpecClient

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

70 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SpecClient

Tools for handling a connection to SPEC server, implimented in asyncio. Largely borrowed from BLISS's comms.

Starting the client

from specc import Client

sc = Client('127.0.0.1', 6510) #Or set server & port in config.py, and simply execute Client()

Sending Spec commands

sc.send_command("umeg; umv en 900; optimize_counts")

Subscribe to channel with Callback

from ipywidgets import Text
from Ipython.display import display

txt = Text(disabled=True)

def disp_mot_position(name, value, epoch):
    if isinstance(value, str):
        txt.value = f"{name}: {value} @ {epoch}"

sc.register_channel("motor/en/position", callback=disp_mot_position)
display(txt)

Grabbing data with Callback

import matplotlib.pyplot as plt
import numpy as np

async def plotMCA(reply):
    plt.plot(np.linspace(10, 2560, 256), reply.data, label=str(reply.cmd))

sc.channel_read('var/MCA1_DATA', callback=plotMCA)

Grabbing data on demand

arr = await sc.get_data('var/MCA2_DATA')

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages