Skip to content
Snippets Groups Projects
pyDevSBL.py 1.57 KiB
Newer Older
mwyman's avatar
mwyman committed
import numpy as np
import os
from beamline_29 import beamline_29

IMAGE = False

class surrogateBL():
    
    def __init__(self, beamline):
        '''
        beamline : Shadow-based beamline
        '''
           
        #create necessary inputs/output; initialize to zero/empty
        print(80*'#')
        print('Initializing pyDevice surrogate beamline object')
        self.beamline = beamline
        print(80*'#')
        self.motorPositions = []   

    def setupMotorLimits(self, subsFile):
        '''
        Go through shadow beamline and get DOF limits and set them as the motor
        limits
        
        Don't have a good way to do this; will manually update simulated motor
        substitutions file with limits
        '''
        pass
        
       
    def elementUpdate(self, element, dof, position):
		'''
		Update element position array but do not trigger detector
		'''
		self.beamline.pos[element, dof]=position
     
        
    def detectorUpdate(self):
		'''
		Update detector(s)
		'''
		
		# Update optical element positions
		self.beamline.adjust() 
		
		# Trigger ray tracing
        results = self.beamline.run() 
        pydev.iointr('new_intensity', int(results))		
		     
		if IMAGE:
			image_data = np.zeros(128,128) # need to add screen to shadow simulation
			flattened_data = image_date.flatten() # need to flatten for waveform
			pydev.iointr('raw_image', flattened_data)
        
    def updateVerbosity(self, verbosity):
        '''
        Turn on minor printing
        '''
        print(f'Verbosity set to {verbosity}')
        self.verbose = verbosity