def __init__(self, prefix, driver): super(PcasServer, self).__init__() logger.info("Initialize PCAServer") self.server = pcaspy.SimpleServer() self.server.createPV(prefix, pvdb) self.driver = driver driver_ = PcasDriver(driver, prefix)
def __init__(self, *, prefix, port): self.prefix = prefix self.device = self.implement(name=port) self.pvdb = self.device.get_pvdb() self.server = pcaspy.SimpleServer() self.server.createPV(self.prefix + ':', self.pvdb) self.server_thread = pcaspy.tools.ServerThread(self.server) driver = self.implement_driver(name=port, pvdb=self.pvdb) self.device.set_driver(driver)
def __init__(self, name, mot_names): self.name = name self.motors = {} for motor_name in mot_names: motor = Motor(motor_name) self.motors[motor_name] = motor self._pvdb.update(motor.get_pvdb()) self.server = pcaspy.SimpleServer() self.server.createPV(self.name + ':', self._pvdb) self.server_thread = pcaspy.tools.ServerThread(self.server) self.driver = MotorEpicsDriver(self, self._pvdb) for _, motor in self.motors.items(): motor.set_driver(self.driver)
def __init__(self, chopper_name, no_discs, chopper_freq_max_hz, pickup_update_interval_seconds): self.chopper_name = chopper_name self.chopper_freq_max_hz = chopper_freq_max_hz self.pickup_update_interval_seconds = pickup_update_interval_seconds self.tdce_array_size = int(1.0 * self.chopper_freq_max_hz * self.pickup_update_interval_seconds) pvdb = { 'CmdS': { 'type': 'string', 'description': 'CmdS | String field to accept commands. | - | Read/Write', }, 'CmdL': { 'type': 'string', 'description': 'CmdL | String field with last command. | - | Read', }, 'TDCE': { # TODO: Does Epics guarantee a bit width of its long type? 'type': 'int', 'count': self.tdce_array_size, }, } self.discs = [] for d in range(no_discs): disc = ChopperDisc(d + 1) self.discs.append(disc) pvdb.update(disc.get_pvdb()) self.server = pcaspy.SimpleServer() self.server.createPV(self.chopper_name + ':', pvdb) self.driver = FacadeEpicsDriver(self, pvdb) for d in self.discs: d.set_driver(self.driver)
def run(index=None, debug=False): """Start the IOC.""" _util.configure_log_file(debug=debug) _log.info('Starting...') # define abort function _signal.signal(_signal.SIGINT, _stop_now) _signal.signal(_signal.SIGTERM, _stop_now) # Creates App object _log.debug('Creating SOFB Object.') # create a new simple pcaspy server and driver to respond client's requests _log.info('Creating Server.') server = _pcaspy.SimpleServer() pvsdb = get_pvsdb(index) _attribute_access_security_group(server, pvsdb) _log.info('Setting Server Database.') server.createPV('', pvsdb) _log.info('Creating Driver.') driver = _PCASDriver(index=index) # initiate a new thread responsible for listening for client connections server_thread = _pcaspy_tools.ServerThread(server) server_thread.setDaemon(True) _log.info('Starting Server Thread.') server_thread.start() # driver.start_thread() # main loop while not STOP_EVENT: _time.sleep(5) _log.info('Stoping Server Thread...') # sends stop signal to server thread server_thread.stop() server_thread.join() _log.info('Server Thread stopped.') _log.info('Good Bye.')
def __init__(self, prefix, driver): super(PcasServer, self).__init__() logging.info("initializing server...") self.server = pcaspy.SimpleServer() self.server.createPV(prefix, pvdb) driver = PcasDriver(driver, prefix)
elif mod4 == 2: name = "EDC-{0}--gpssmd100koff1p--{1}--2--16".format(i, offset) db[name] = {'type': 'int'} datatypes[name] = 2 elif mod4 == 3: name = "EDC-{0}--gpssmd30koff1p--{1}--1--16".format(i, offset) db[name] = {'type': 'int'} datatypes[name] = 1 db[name] = {'type': 'int'} offsets[name] = offset return db for i in range(2000): db = add_entry(db, i, i % 33) write_ini_file(prefix, db, 'edcu.ini', datatypes) server = pcaspy.SimpleServer() server.createPV(prefix, db) driver = myDriver(offsets, datatypes) driver.update_vals(read_time()) last_sec = read_time() while True: server.process(0.2) cur_sec = read_time() if cur_sec != last_sec: driver.update_vals(cur_sec) last_sec = cur_sec
def ioc(prefix: str): PVs = { f"{prefix}:ACP:OnOff": { "type": "float" }, f"{prefix}:ACP:SpeedRPM": { "type": "float" }, f"{prefix}:BBB:Relay1-SW": { "type": "float" }, f"{prefix}:BBB:Relay1-UI": { "type": "int" }, f"{prefix}:BBB:Relay1-UI.RVAL": { "type": "int" }, f"{prefix}:BBB:Relay2-SW": { "type": "float" }, f"{prefix}:BBB:Relay2-UI": { "type": "int" }, f"{prefix}:BBB:Relay2-UI.RVAL": { "type": "int" }, f"{prefix}:BBB:Relay3-UI": { "type": "int" }, f"{prefix}:BBB:Relay3-UI.RVAL": { "type": "int" }, f"{prefix}:BBB:Relay4-UI": { "type": "int" }, f"{prefix}:BBB:Relay4-UI.RVAL": { "type": "int" }, f"{prefix}:BBB:Relay5-UI": { "type": "int" }, f"{prefix}:BBB:Relay5-UI.RVAL": { "type": "int" }, f"{prefix}:BBB:Torr": { "type": "float" }, f"{prefix}:BBB:TorrBase": { "type": "float" }, f"{prefix}:BBB:TorrBaseMsg": { "type": "float" }, f"{prefix}:BBB:TorrExpMsg": { "type": "int" }, f"{prefix}:BBB:ValveClosed": { "type": "float" }, f"{prefix}:BBB:ValveOpen": { "type": "float" }, f"{prefix}:BBB:mbarBase": { "type": "string" }, f"{prefix}:Process:TriggerOn": { "type": "int" }, f"{prefix}:Process:TriggerPressurized": { "type": "int" }, f"{prefix}:ProcessOff:Bool": { "type": "float" }, f"{prefix}:ProcessOff:Bool": { "type": "int" }, f"{prefix}:ProcessOffFV:Status1": { "type": "int" }, f"{prefix}:ProcessOffFV:Status2": { "type": "int" }, f"{prefix}:ProcessOffFV:Status3": { "type": "int" }, f"{prefix}:ProcessOffFV:Status4": { "type": "int" }, f"{prefix}:ProcessOffFV:Status5": { "type": "int" }, f"{prefix}:ProcessOffFV:Status6": { "type": "int" }, f"{prefix}:ProcessOn:Bool": { "type": "int" }, f"{prefix}:ProcessOn:Status1": { "type": "int" }, f"{prefix}:ProcessOn:Status2": { "type": "int" }, f"{prefix}:ProcessOn:Status3": { "type": "int" }, f"{prefix}:ProcessOn:Status4": { "type": "int" }, f"{prefix}:ProcessOn:Status5": { "type": "int" }, f"{prefix}:ProcessRec:Bool": { "type": "int" }, f"{prefix}:ProcessRecovery:Status1": { "type": "int" }, f"{prefix}:ProcessRecovery:Status2": { "type": "int" }, f"{prefix}:ProcessRecovery:Status3": { "type": "int" }, f"{prefix}:ProcessRecovery:Status4": { "type": "int" }, f"{prefix}:ProcessRecovery:Status5": { "type": "int" }, f"{prefix}:SYSTEM:Location": { "type": "str", "value": "test-ioc" }, f"{prefix}:SYSTEM:OffFrequency": { "type": "float" }, f"{prefix}:SYSTEM:OffPressureBase": { "type": "float" }, f"{prefix}:SYSTEM:OffPressureExp": { "type": "float" }, f"{prefix}:SYSTEM:OnPressureBase": { "type": "float" }, f"{prefix}:SYSTEM:OnPressureExp": { "type": "float" }, f"{prefix}:TURBOVAC:AK-SP": { "type": "float" }, f"{prefix}:TURBOVAC:IND-SP": { "type": "float" }, f"{prefix}:TURBOVAC:PNU-SP": { "type": "float" }, f"{prefix}:TURBOVAC:PWE-SP": { "type": "float" }, f"{prefix}:TURBOVAC:PZD1-SP.SXVL": { "type": "float" }, f"{prefix}:TURBOVAC:PZD1-SP.TEVL": { "type": "float" }, f"{prefix}:TURBOVAC:PZD1-SP.ZRVL": { "type": "float" }, f"{prefix}:TURBOVAC:PZD2-RB": { "type": "float" }, f"{prefix}:TURBOVAC:PZD2-SP": { "type": "float" }, f"{prefix}:TURBOVAC:VentingValve-SW": { "type": "float" }, f"{prefix}:TURBOVAC:VentingValve-UI": { "type": "int" }, f"{prefix}:TURBOVAC:VentingValve-UI.RVAL": { "type": "float" }, } # start EPICS server CAserver = pcaspy.SimpleServer() CAserver.createPV("", PVs) for k in PVs.keys(): print(k) PSDriver() logger.info("IOC Started") while True: CAserver.process(0.1)