本文整理汇总了Python中zerorpc.Client方法的典型用法代码示例。如果您正苦于以下问题:Python zerorpc.Client方法的具体用法?Python zerorpc.Client怎么用?Python zerorpc.Client使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类zerorpc
的用法示例。
在下文中一共展示了zerorpc.Client方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: start_ric
# 需要导入模块: import zerorpc [as 别名]
# 或者: from zerorpc import Client [as 别名]
def start_ric(host = None,port = None):
import zerorpc
"""
starts a remote interface client (ric)
to a
host = host (default = localhost)
at a
port = port (default = 5700)
ric is based on zerorpc, so every zerorpc server should be accessible
"""
ric = zerorpc.Client();
if not host:
host = qkit.cfg.get("ris_host","127.0.0.1")
if not port:
port = qkit.cfg.get("ris_port",5700)
print("starting ric client on host %s and port %s" % (host,port))
ric.connect("tcp://" + host + ":" + str(port))
qkit.ric = ric
__update_tab(ric)
return ric
示例2: runClient
# 需要导入模块: import zerorpc [as 别名]
# 或者: from zerorpc import Client [as 别名]
def runClient(self, endpoint):
# TODO: check that client might be connected otherwise kill server
client = zerorpc.Client(heartbeat=None, timeout=MESSAGE_TIMEOUT)
logging.debug("Pyscard RPC client: %r" %endpoint)
client.connect(endpoint)
return client
示例3: init_connection
# 需要导入模块: import zerorpc [as 别名]
# 或者: from zerorpc import Client [as 别名]
def init_connection(self):
'''
initiate connection to zerorpc server
'''
logging.debug(__name__ + ': initiating connection to DAC server {:s} on port {:d}'.format(self.HOST, self.PORT))
self.c = zerorpc.Client()
self.c.connect("tcp://{:s}:{:d}".format(self.HOST, self.PORT))
示例4: __init__
# 需要导入模块: import zerorpc [as 别名]
# 或者: from zerorpc import Client [as 别名]
def __init__(self, name, address, reset=True):
"""
Initializes the Lmx2595, and communicates with the wrapper.
Input:
name (string) : name of the instrument
address (string) : Ethernet address
Output:
True if initialization was successful
"""
logging.info(__name__ + ' : Initializing instrument Lmx2595')
Instrument.__init__(self, name, tags=['physical'])
self.c = zerorpc.Client()
self.c.connect(address)
self.r = 2
self.params = {
'StA': [44, 6, 1],
'StB': [44, 7, 1],
'Vco_calib_st': [0, 3, 1],
'Reset_St': [0, 1, 1],
'PowerA': [44, 8, 6],
'PowerB': [45, 0, 6],
'Num_b1': [43, 0, 16],
'Num_b0': [42, 0, 16],
'N_dev': [36, 0, 16],
'ChDevA_st': [45, 11, 2],
'ChDevB_st': [46, 0, 2]
} # Dict contains address of register, start bit and length
self.vco_max = 15e9 # default values according to manual
self.vco_min = 7.5e9
self.add_parameter('frequency', type=float, flags=Instrument.FLAG_GETSET, minval=200e6, maxval=14.9e9)
if reset:
self.reset()
示例5: __init__
# 需要导入模块: import zerorpc [as 别名]
# 或者: from zerorpc import Client [as 别名]
def __init__(self, name, address="tcp://10.22.197.112:4242", initial_position=0):
self.c = zerorpc.Client()
self.c.connect(address)
if self.c.get_connection():
print 'connected to Raspberry Pi'
else:
logging.error('No connection to Raspberry Pi')
if initial_position == 0:
logging.warning("You didn't provide an inital position. Please make sure that the phase shifter "
"is in its lowest position, since the rotation is tracked to prevent the damage of "
"either motor or phase shifter. Or alternatively change the rotations."
"Please also think of that when manually changing the phase shifter")
logging.info(__name__ + ' : Initializing instrument')
Instrument.__init__(self, name, tags=['physical'])
self.angle = initial_position * 360
self.min_angle = 0
self.max_angle = 17.5 * 360
self.rotations = initial_position
self.show_progress_bar = True
self.add_parameter('angle', type=int, flags=Instrument.FLAG_GETSET, minval=0, maxval=17.5 * 360)
self.add_parameter('waiting_time', type=float, flags=Instrument.FLAG_GETSET,
minval=0.0001, maxval=0.01)
self.add_parameter('rotations', type=float, flags=Instrument.FLAG_GETSET, minval=0, maxval=17.5 * 360)
self.add_function('turn')
示例6: call
# 需要导入模块: import zerorpc [as 别名]
# 或者: from zerorpc import Client [as 别名]
def call():
import zerorpc
client = zerorpc.Client()
client.connect("tcp://127.0.0.1:6000")
start = time.time()
[client.sum(1, 2) for _ in range(NUM_CALLS)]
print('call: %d qps' % (NUM_CALLS / (time.time() - start)))
示例7: rpcconn_check
# 需要导入模块: import zerorpc [as 别名]
# 或者: from zerorpc import Client [as 别名]
def rpcconn_check(self, ip):
try:
rpc = zerorpc.Client(timeout=3, heartbeat=3)
rpc.connect("tcp://{ip}:{port}".format(ip=ip, port=RPC_PORT))
ping = rpc.ping()
rpc.close()
return ping
except Exception as e:
return False
示例8: __init__
# 需要导入模块: import zerorpc [as 别名]
# 或者: from zerorpc import Client [as 别名]
def __init__(self, ip):
self.rpc = zerorpc.Client(timeout=3, heartbeat=3)
self.rpc.connect("tcp://{ip}:{port}".format(ip=ip, port=RPC_PORT))
示例9: _create_service
# 需要导入模块: import zerorpc [as 别名]
# 或者: from zerorpc import Client [as 别名]
def _create_service(self):
logger.info('Connecting to node %s', self.get_id())
c = zerorpc.Client()
c.connect('tcp://%s:%s' % (self.host, self.port))
logger.info('Connected.')
return c
示例10: __init__
# 需要导入模块: import zerorpc [as 别名]
# 或者: from zerorpc import Client [as 别名]
def __init__(self, name, address, reference='external', model='ERASynth'):
logging.info(__name__ + ' : Initializing instrument')
Instrument.__init__(self, name)
self._address = "tcp://" + address
self._model = model
self._statusdict = {}
self._reference = reference
self._rpc = zerorpc.Client()
self._rpc.connect(self._address)
# Implement parameters
self.add_parameter('frequency', type=float,
flags=Instrument.FLAG_GETSET,
minval=250e3, maxval=15e9,
units='Hz')
self.add_parameter('power', type=float,
flags=Instrument.FLAG_GETSET,
minval=-60, maxval=20, # 15 dBm Typ, up to 20 depending on F
units='dBm')
self.add_parameter('status', type=bool,
flags=Instrument.FLAG_GETSET)
# Initialize parameter values
self.get_all(True)
# Set 10MHz reference and check for lock if external
# (if no reference is attached or quality is bad, it will switch to internal OCXO)
lockcount = 0
reference = _reference_class_conversion(reference)
self.set_reference(ReferenceSource.OCXO)
sleep(1)
self.set_reference(reference)
if reference == ReferenceSource.EXTERNAL:
# Check if PLL has stable lock on external reference
for _ in range(10):
if self.get_diag()["lock_xtal"] == "1":
lockcount += 1
if lockcount == 0:
warnings.warn(
"No Lock possible. Check your reference. Defaulted to OCXO.")
self.set_reference(ReferenceSource.OCXO)
elif lockcount < 10:
warnings.warn(
"External reference unstable. Check for sufficient amplitude & accuracy. Defaulted to OCXO.")
self.set_reference(ReferenceSource.OCXO)
示例11: __init__
# 需要导入模块: import zerorpc [as 别名]
# 或者: from zerorpc import Client [as 别名]
def __init__(self, host, port):
client = zerorpc.Client()
client.connect('tcp://{}:{}'.format(host, port))
self.motors = []
for name in client.get_motors_list():
class Register(object):
def __init__(self, motorname, regname):
self.motorname = motorname
self.regname = regname
def __get__(self, instance, owner):
return client.get_register_value(self.motorname, self.regname)
def __set__(self, instance, value):
client.set_register_value(self.motorname, self.regname, value)
class Motor(object):
def __repr__(self):
return ('<Motor name={self.name} '
'id={self.id} '
'pos={self.present_position}>').format(self=self)
for reg in client.get_registers_list(name):
setattr(Motor, reg.decode(), Register(name, reg))
m = Motor()
setattr(self, m.name, m)
self.motors.append(m)
for alias in client.get_motors_alias():
motors = [getattr(self, name) for name in client.get_motors_list(alias)]
setattr(self, alias, motors)
class Primitive(object):
def __init__(self, name):
self.name = name
def start(self):
client.start_primitive(self.name)
def stop(self):
client.stop_primitive(self.name)
self.primitives = []
for p in client.get_primitives_list():
prim = Primitive(p)
setattr(self, p.decode(), prim)
self.primitives.append(prim)