Skip to content
This repository has been archived by the owner on Oct 26, 2022. It is now read-only.

Commit

Permalink
fix function overloading
Browse files Browse the repository at this point in the history
  • Loading branch information
henrypinkard committed Feb 6, 2020
1 parent 786eba1 commit 1d72670
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
9 changes: 5 additions & 4 deletions examples/micro-manager_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
bridge = PygellanBridge()
mm = bridge.get_studio()
mmc = bridge.get_core()
mmc.set_exposure(100)

while True:
mm.live().snap(True)
mmc.set_exposure("Camera", 100)
mmc.set_exposure(120)
pass
# while True:
# mm.live().snap(True)
10 changes: 5 additions & 5 deletions pygellan/acquire.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def __init__(self, port=_DEFAULT_PORT, convert_camel_case=True):
self._socket = self._context.socket(zmq.REQ)
self._socket.connect("tcp://127.0.0.1:{}".format(port))
self._send({'command': 'connect', 'classpath': 'master'})
reply_json = self._recieve()
reply_json = self._receive()
if reply_json['type'] == 'exception':
raise Exception(reply_json['message'])
if 'version' not in reply_json:
Expand All @@ -35,7 +35,7 @@ def __init__(self, port=_DEFAULT_PORT, convert_camel_case=True):
def _send(self, message):
self._socket.send(bytes(json.dumps(message), 'utf-8'))

def _recieve(self):
def _receive(self):
reply = self._socket.recv()
return json.loads(reply.decode('utf-8'))

Expand All @@ -49,7 +49,7 @@ def construct_java_object(self, classpath):
if not hasattr(self, name):
# request reply socket
self._send({'command': 'connect', 'classpath': classpath, 'port': self._next_port})
response = self._recieve()
response = self._receive()
if ('type' in response and response['type'] == 'exception'):
raise Exception(response['value'])
if response['type'] == 'exception':
Expand Down Expand Up @@ -129,7 +129,7 @@ def __init__(self, socket, response, convert_camel_case=True, **kwargs):
i += 1
hint += str(i)
unique_argument_names.append(hint)
#this is how polymorphism is handled for now, by making default arguments as none, but
#this is how overloading is handled for now, by making default arguments as none, but
#it might be better to explicitly compare argument types
if arg_index >= min_required_args:
class_arg_names.append(hint + '=' + hint)
Expand Down Expand Up @@ -194,7 +194,7 @@ def _translate_call(self, *args):
message = {'command': 'run-method', 'hash-code': self._hash_code, 'name': valid_method_spec['name'],
'arguments': [self._serialize_arg(
self._CLASS_TYPE_MAPPING[arg_type](arg_val)) for
arg_type, arg_val in zip(method_spec['arguments'], fn_args)]}
arg_type, arg_val in zip(valid_method_spec['arguments'], fn_args)]}
self._socket.send(bytes(json.dumps(message), 'utf-8'))
reply = self._socket.recv()
return self._deserialize_return(reply)
Expand Down

0 comments on commit 1d72670

Please sign in to comment.