Skip to content

Commit

Permalink
Typos and other minor
Browse files Browse the repository at this point in the history
  • Loading branch information
Dario Cambie committed Jul 10, 2019
1 parent fc5c91e commit fbee395
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1036,7 +1036,7 @@ <h1>Source code for pycont.controller</h1><div class="highlight"><pre>
<span class="bp">self</span><span class="o">.</span><span class="n">go_to_volume</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">total_volume</span><span class="p">,</span> <span class="n">speed</span><span class="o">=</span><span class="n">speed</span><span class="p">,</span> <span class="n">wait</span><span class="o">=</span><span class="n">wait</span><span class="p">)</span></div>

<span class="c"># valve</span>
<div class="viewcode-block" id="C3000Controller.get_raw_valve_postion"><a class="viewcode-back" href="../../pycont.html#pycont.controller.C3000Controller.get_raw_valve_postion">[docs]</a> <span class="k">def</span> <span class="nf">get_raw_valve_postion</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<div class="viewcode-block" id="C3000Controller.get_raw_valve_position"><a class="viewcode-back" href="../../pycont.html#pycont.controller.C3000Controller.get_raw_valve_position">[docs]</a> <span class="k">def</span> <span class="nf">get_raw_valve_position</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Gets the raw value of the valve&#39;s position.</span>

Expand All @@ -1063,7 +1063,7 @@ <h1>Source code for pycont.controller</h1><div class="highlight"><pre>

<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">max_repeat</span><span class="p">):</span>
<span class="n">raw_valve_position</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_raw_valve_postion</span><span class="p">()</span>
<span class="n">raw_valve_position</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_raw_valve_position</span><span class="p">()</span>
<span class="k">if</span> <span class="n">raw_valve_position</span> <span class="o">==</span> <span class="s">&#39;i&#39;</span><span class="p">:</span>
<span class="k">return</span> <span class="n">VALVE_INPUT</span>
<span class="k">elif</span> <span class="n">raw_valve_position</span> <span class="o">==</span> <span class="s">&#39;o&#39;</span><span class="p">:</span>
Expand Down
2 changes: 1 addition & 1 deletion docs/code_documentation/_build/html/genindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ <h2 id="G">G</h2>
</dt>


<dt><a href="pycont.html#pycont.controller.C3000Controller.get_raw_valve_postion">get_raw_valve_postion() (pycont.controller.C3000Controller method)</a>
<dt><a href="pycont.html#pycont.controller.C3000Controller.get_raw_valve_position">get_raw_valve_position() (pycont.controller.C3000Controller method)</a>
</dt>

</dl></td>
Expand Down
4 changes: 2 additions & 2 deletions docs/code_documentation/_build/html/pycont.html
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,8 @@ <h1>Pycont Package<a class="headerlink" href="#pycont-package" title="Permalink
</dd></dl>

<dl class="method">
<dt id="pycont.controller.C3000Controller.get_raw_valve_postion">
<code class="descname">get_raw_valve_postion</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/pycont/controller.html#C3000Controller.get_raw_valve_postion"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pycont.controller.C3000Controller.get_raw_valve_postion" title="Permalink to this definition"></a></dt>
<dt id="pycont.controller.C3000Controller.get_raw_valve_position">
<code class="descname">get_raw_valve_position</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/pycont/controller.html#C3000Controller.get_raw_valve_position"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pycont.controller.C3000Controller.get_raw_valve_position" title="Permalink to this definition"></a></dt>
<dd><p>Gets the raw value of the valve&#8217;s position.</p>
<dl class="docutils">
<dt>Returns:</dt>
Expand Down
8 changes: 5 additions & 3 deletions docs/code_documentation/createsphinxproject.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os


def main():
print("Please enter the details of the Sphinx project you wish to create.\n")
projectName = input("Project name: ")
Expand All @@ -9,12 +10,13 @@ def main():
sourceDir = input("Source code directory: ")

try:
print ("Creating sphinx project...")
print("Creating sphinx project...")
command = "sphinx-apidoc -F -H {0} -A {1} -V {2} -o {3} {4}".format(projectName, author, version, outputDir, sourceDir)
print(command)
#os.system(command)
except Exception as e:
# os.system(command)
except Exception:
print("Error when creating project.")


if __name__=='__main__':
main()
2 changes: 2 additions & 0 deletions docs/code_documentation/makehtmldocs.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import os


def main():
os.system("make clean")
os.system("make html")


if __name__=='__main__':
main()
29 changes: 15 additions & 14 deletions pycont/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@

#: Microstep Mode 0
MICRO_STEP_MODE_0 = 0
#:Microstep Mode 2
#: Microstep Mode 2
MICRO_STEP_MODE_2 = 2

#: Number of steps in Microstep Mode 0
Expand Down Expand Up @@ -100,6 +100,7 @@ def __init__(self, port, baudrate=DEFAULT_IO_BAUDRATE, timeout=DEFAULT_IO_TIMEOU
self.port = port
self.baudrate = baudrate
self.timeout = timeout
self._serial = None

self.open(port, baudrate, timeout)

Expand Down Expand Up @@ -163,7 +164,7 @@ def __exit__(self, exc_type, exc_value, traceback):
exc_value (Exception): The value associated with the Exception.
traceback (str): Location of where the exception occured.
traceback (str): Location of where the exception occurred.
"""
self.close()
Expand Down Expand Up @@ -318,7 +319,7 @@ class C3000Controller(object):
address (str): Address of the controller.
total_volume (int): Total volume of the pump.
total_volume (float): Total volume of the pump.
micro_step_mode (int): The mode which the microstep will use, default set to MICRO_STEP_MODE_2 (2)
Expand Down Expand Up @@ -504,7 +505,7 @@ def is_initialized(self):

def smart_initialize(self, valve_position=None, secure=True):
"""
Initialises the pump and sets all pump parammeters.
Initialises the pump and sets all pump parameters.
Args:
valve_position (int): Position of the valve, default set None.
Expand Down Expand Up @@ -733,8 +734,8 @@ def set_top_velocity(self, top_velocity, max_repeat=MAX_REPEAT_OPERATION, secure
if secure is False:
return True

self.logger.debug("[PUMP {}] Too many failed attempts in set_top_velocity!".format(self.name))
raise ControllerRepeatedError('Repeated Error from pump {}'.format(self.name))
self.logger.debug(f"[PUMP {self.name}] Too many failed attempts in set_top_velocity!")
raise ControllerRepeatedError(f'Repeated Error from pump {self.name}')

def get_top_velocity(self):
"""
Expand Down Expand Up @@ -943,11 +944,11 @@ def transfer(self, volume_in_ml, from_valve, to_valve, speed_in=None, speed_out=
speed_out (int): The speed of transfer from the valve, default set to None.
"""
volume_transfered = min(volume_in_ml, self.remaining_volume)
self.pump(volume_transfered, from_valve, speed_in=speed_in, wait=True)
self.deliver(volume_transfered, to_valve, speed_out=speed_out, wait=True)
volume_transferred = min(volume_in_ml, self.remaining_volume)
self.pump(volume_transferred, from_valve, speed_in=speed_in, wait=True)
self.deliver(volume_transferred, to_valve, speed_out=speed_out, wait=True)

remaining_volume_to_transfer = volume_in_ml - volume_transfered
remaining_volume_to_transfer = volume_in_ml - volume_transferred
if remaining_volume_to_transfer > 0:
self.transfer(remaining_volume_to_transfer, from_valve, to_valve, speed_in, speed_out)

Expand Down Expand Up @@ -977,9 +978,9 @@ def go_to_volume(self, volume_in_ml, speed=None, wait=False, secure=True):
speed (int): The speed of movement, default set to None.
wait (bool): Waits for the pump to be idle, defualt set to False.
wait (bool): Waits for the pump to be idle, default set to False.
secure (bool): Ensures that everything is corect, default set to True.
secure (bool): Ensures that everything is correct, default set to True.
Returns:
True (bool): The supplied volume is valid.
Expand Down Expand Up @@ -1022,7 +1023,7 @@ def go_to_max_volume(self, speed=None, wait=False):
"""
self.go_to_volume(self.total_volume, speed=speed, wait=wait)

def get_raw_valve_postion(self):
def get_raw_valve_position(self):
"""
Gets the raw value of the valve's position.
Expand All @@ -1049,7 +1050,7 @@ def get_valve_position(self, max_repeat=MAX_REPEAT_OPERATION):
"""
for i in range(max_repeat):
raw_valve_position = self.get_raw_valve_postion()
raw_valve_position = self.get_raw_valve_position()
if raw_valve_position == 'i':
return VALVE_INPUT
elif raw_valve_position == 'o':
Expand Down
9 changes: 3 additions & 6 deletions pycont/pump_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def forge_initialize_valve_left_packet(self, operand_value=0):
Creates a packet for initialising the left valve.
Args:
operand_value (int): The value of the supplied operand, 0 by defualt.
operand_value (int): The value of the supplied operand, 0 by default.
Returns:
DTInstructionPacket: The packet created for initialising the left valve.
Expand Down Expand Up @@ -328,7 +328,7 @@ def forge_eeprom_lowlevel_config_packet(self, sub_command=20, operand_value="pyc
dtcommand = dtprotocol.DTCommand(CMD_EEPROM_LOWLEVEL_CONFIG, str(sub_command) + "_" + str(operand_value))
return self.forge_packet(dtcommand, execute=False)

def forge_valve_input_packet(self, operand_value=None):
def forge_valve_input_packet(self):
"""
Creates a packet for the input into a valve on the device.
Expand Down Expand Up @@ -368,13 +368,10 @@ def forge_valve_extra_packet(self):
"""
return self.forge_packet(dtprotocol.DTCommand(CMD_VALVE_EXTRA))

def forge_valve_6way_packet(self, valve_position, operand_value=None):
def forge_valve_6way_packet(self, valve_position):
"""
Creates a packet for the 6way valve on the device.
Args:
operand_value (int): The value of the supplied operand, None by default.
Returns:
DTInstructionPacket: The packet created for the input into a valve on the device.
Expand Down
5 changes: 3 additions & 2 deletions tests/pycont_6way_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
import time

import logging
logging.basicConfig(level=logging.INFO)

# simply import the module
import pycont.controller

logging.basicConfig(level=logging.INFO)

# link to your config file
SETUP_CONFIG_FILE = './pump_setup_config_6way.json'

Expand Down Expand Up @@ -96,7 +97,7 @@
# They are '1', '2', '3', '4', '5', '6', all are in the list pycont.controller.VALVE_6WAY_LIST
for valve_position in pycont.controller.VALVE_6WAY_LIST:
controller.pumps['water'].set_valve_position(valve_position)
controller.acetone.set_valve_position(valve_position) ## this is another way to call the pump
controller.acetone.set_valve_position(valve_position) # This is another way to call the pump
time.sleep(1) # just to pause so that you can hear the sound of valve movements

# of course you can change all the valve position at once
Expand Down
5 changes: 3 additions & 2 deletions tests/pycont_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@
import time

import logging
logging.basicConfig(level=logging.INFO)

# simply import the module
import pycont.controller

logging.basicConfig(level=logging.INFO)

# link to your config file
SETUP_CONFIG_FILE = './pump_setup_config.json'

# and load the config file in a MultiPumpController
controller = pycont.controller.MultiPumpController.from_configfile(SETUP_CONFIG_FILE)

# initialize the pumps in a smart way, if they are already initialized we do not want to reinitialize them because they got back to zero position
# Initialize the pumps in a smart way, if they are already initialized we do not want to reinitialize them because they got back to zero position
controller.smart_initialize()

# individual pumps can be accessed in two ways:
Expand Down

0 comments on commit fbee395

Please sign in to comment.