...
 
Commits (2)
......@@ -10,6 +10,8 @@ tqdm = "*"
sacada = {editable = true,path = "."}
pyserial = "*"
click = "*"
thermocouples-reference = "*"
scipy = "*"
[requires]
python_version = "3.5"
python_version = "3.7"
......@@ -3,10 +3,13 @@
from time import sleep
import click
from tqdm import tqdm
from thermocouples_reference import thermocouples
from sacada.SACADA import SACADA
typeR = thermocouples['R']
@click.group()
@click.option('--port', default="/dev/ttyACM0", help='serial port location eg.: /dev/ttyACM0 (default)')
@click.option('--port', default="/dev/ttyACM1", help='serial port location eg.: /dev/ttyACM0 (default)')
@click.pass_context
def cli(ctx, port):
ctx.obj['s'] = SACADA(port)
......@@ -25,13 +28,68 @@ def read(ctx, channel):
@cli.command()
@click.argument('channel')
@click.option('--interval', default=1000, help='interval bewteen readings (ms)')
@click.option('--save', default='', help='file to save readings')
@click.pass_context
def monitor(ctx, channel, interval, save):
#with tqdm(total=256, desc="Channel {}".format(channel), bar_format="{desc}|{bar}|{n_fmt}mV") as bar:
#while True:
# bar.n = int(ctx.obj['s'].readVoltage(channel) * 1000)
# bar.refresh()
# sleep(interval/1000.0)
if not save:
while True:
click.echo(ctx.obj['s'].readVoltage(channel))
sleep(interval/1000.0)
else:
f = open(save, 'w')
try:
while True:
voltage = ctx.obj['s'].readVoltage(channel)
click.echo(voltage)
f.write(str(voltage) + '\n')
sleep(interval/1000.0)
except KeyboardInterrupt:
f.close()
@cli.command()
@click.option('--interval', default=1000, help='interval bewteen readings (ms)')
@click.option('--save', default='', help='file to save readings')
@click.pass_context
def monitor(ctx, channel, interval):
with tqdm(total=18, desc="Channel {}".format(channel), bar_format="{desc}|{bar}|{n_fmt}V") as bar:
def lapma(ctx, interval, save):
#with tqdm(total=256, desc="Channel {}".format(channel), bar_format="{desc}|{bar}|{n_fmt}mV") as bar:
#while True:
# bar.n = int(ctx.obj['s'].readVoltage(channel) * 1000)
# bar.refresh()
# sleep(interval/1000.0)
if not save:
while True:
bar.n = ctx.obj['s'].readVoltage(channel)
bar.refresh()
click.echo(ctx.obj['s'].readVoltage(channel))
sleep(interval/1000.0)
else:
f = open(save, 'w')
try:
while True:
voltage = ctx.obj['s'].readVoltage("A3")
current = ctx.obj['s'].readVoltage("A4")
thermocouple = ctx.obj['s'].readVoltage("TC")
try:
temperature = typeR.inverse_CmV((thermocouple + 0.001453125034) * -1000, Tref=25)
except ValueError:
temperature = "Error"
click.echo("Voltage: {}".format(voltage))
click.echo("Current: {}".format(current))
click.echo("Power: {}".format(voltage * current))
click.echo("TC (mV): {}".format(thermocouple))
click.echo("TC (celsius): {}".format(temperature))
click.echo("-----------------")
f.write(str(voltage) + '\t')
f.write(str(current) + '\t')
f.write(str(thermocouple) + '\t')
f.write(str(temperature) + '\n')
sleep(interval/1000.0)
except KeyboardInterrupt:
f.close()
if __name__ == '__main__':
cli(obj={})
......@@ -14,7 +14,7 @@ class SACADA(object):
with all SACADA boards.
"""
IN_CHANNELS = ["A0", "A1", "A2", "A3", "A4", "INSTR"]
IN_CHANNELS = ["A0", "A1", "A2", "A3", "A4", "INSTR", "TC"]
OUT_CHANNELS = ["CH1", "CH2"]
def __init__(self, location):
......
This diff is collapsed.
......@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
setuptools.setup(
name="sacada-python",
version="0.0.1",
version="0.0.3",
author="Pedro Henrique Capp Kopper",
author_email="pedro.kopper@ufrgs.br",
description="Python API for the SACADA data acquisition system",
......@@ -13,6 +13,7 @@ setuptools.setup(
long_description_content_type="text/markdown",
url="https://git.cta.if.ufrgs.br/SACADA/sacada-python",
packages=['sacada'],
scripts=['bin/sacada'],
classifiers=[
"Programming Language :: Python :: 3",
"Development Status :: 3 - Alpha",
......@@ -21,5 +22,12 @@ setuptools.setup(
"Topic :: Scientific/Engineering",
"Operating System :: OS Independent",
],
python_requires='>=3.5',
install_requires=[
'pyserial',
'tdqm',
'click',
'thermocouples-reference',
'scipy'
],
python_requires='>=3.6',
)