#!/usr/bin/env python from pcaspy import Driver, SimpleServer prefix = 'MTEST:' pvdb = { 'LEVEL': { }, 'FILL' : { 'prec' : 3, 'asg' : 'fill', }, } class myDriver(Driver): def __init__(self): super(myDriver, self).__init__() if __name__ == '__main__': server = SimpleServer() server.initAccessSecurityFile('test.as', P=prefix) server.createPV(prefix, pvdb) driver = myDriver() # process CA transactions while True: server.process(0.1)
data = NUM_DIVISIONS/2.0 + yScale * (data + voltOffset) cos_data = NUM_DIVISIONS/2.0 + yScale * (cos_data + voltOffset) self.setParam('Waveform', data) self.setParam('Cosine', cos_data) #Generate the image data x0 = 0.5*(numpy.random.rand()-0.5) + self.getParam('XPos') y0 = 0.5*(numpy.random.rand()-0.5) - self.getParam('YPos') xsig = 0.8 - 0.2*numpy.random.rand() ysig = 0.8 - 0.2*numpy.random.rand() z = gaussian_2d(xgrid,ygrid, x0, y0, xsig, ysig) image_data = numpy.abs(256.0*(z)).flatten(order='C').astype(numpy.uint8, copy=False) self.setParam('Image', image_data) two_spots = double_gaussian_2d(xgrid, ygrid, x0, y0, xsig, ysig) two_spot_image = numpy.abs(256.0*(two_spots)).flatten(order='C').astype(numpy.uint8, copy=False) self.setParam('TwoSpotImage', two_spot_image) # do updates so clients see the changes self.updatePVs() if __name__ == '__main__': server = SimpleServer() server.initAccessSecurityFile('access_rules.as', P=prefix) server.createPV(prefix, pvdb) driver = myDriver() #Manually set the ReadOnly PV to force access rule calculation. #You can set ReadOnly to 1 to disable write access on all PVs. driver.setParam('ReadOnly', 0) # process CA transactions while True: server.process(0.1)
logger.info("Reflectometry Server processing requests") while True: try: SERVER.process(0.1) ChannelAccess.poll() except Exception as err: break logger.info("Initialising...") logger.info("Prefix: {}".format(REFLECTOMETRY_PREFIX)) SERVER = SimpleServer() # Add security access to pvs. NB this is only for local rules because we have not substituted in the correct macros for # remote host access to the pvs SERVER.initAccessSecurityFile(DEFAULT_ASG_RULES, P=MYPVPREFIX) logger.info("Starting Reflectometry Driver") # Create server status PVs only pv_manager = PVManager() SERVER.createPV(REFLECTOMETRY_PREFIX, pv_manager.PVDB) # Run heartbeat IOC, this is done with a different prefix SERVER.createPV(prefix="{pv_prefix}CS:IOC:{ioc_name}:DEVIOS:".format( pv_prefix=MYPVPREFIX, ioc_name=REFL_IOC_NAME), pvdb={"HEARTBEAT": { "type": "int", "value": 0 }})
#!/usr/bin/env python from pcaspy import Driver, SimpleServer prefix = 'MTEST:' pvdb = { 'LEVEL': {}, 'FILL': { 'prec': 3, 'asg': 'fill', }, } class myDriver(Driver): def __init__(self): super(myDriver, self).__init__() if __name__ == '__main__': server = SimpleServer() server.initAccessSecurityFile('test.as', P=prefix) server.createPV(prefix, pvdb) driver = myDriver() # process CA transactions while True: server.process(0.1)