Commit 144b6b6c authored by Olivier Kaufmann's avatar Olivier Kaufmann
Browse files

Merge branch 'code_refactor' of gitlab-ssh.irstea.fr:reversaal/OhmPi into code_refactor

Showing with 32 additions and 28 deletions
+32 -28
...@@ -7,9 +7,9 @@ import time ...@@ -7,9 +7,9 @@ import time
import logging import logging
from ohmpi.config import HARDWARE_CONFIG from ohmpi.config import HARDWARE_CONFIG
stand_alone = False stand_alone = True
part_of_hardware_system = False part_of_hardware_system = False
within_ohmpi = True within_ohmpi = False
# Stand alone # Stand alone
if stand_alone: if stand_alone:
...@@ -40,32 +40,36 @@ if stand_alone: ...@@ -40,32 +40,36 @@ if stand_alone:
rx = rx_module.Rx(**HARDWARE_CONFIG['rx']) rx = rx_module.Rx(**HARDWARE_CONFIG['rx'])
tx = tx_module.Tx(**HARDWARE_CONFIG['tx']) tx = tx_module.Tx(**HARDWARE_CONFIG['tx'])
pwr = pwr_module.Pwr(**HARDWARE_CONFIG['pwr']) pwr = pwr_module.Pwr(**HARDWARE_CONFIG['pwr'])
mux_ids = ['mux_02', 'mux_05'] # mux_ids = ['mux_02', 'mux_05']
for m,mux_id in enumerate(mux_ids): # for m,mux_id in enumerate(mux_ids):
mux_module = importlib.import_module( # mux_module = importlib.import_module(
f'ohmpi.hardware_components.{HARDWARE_CONFIG["mux"]["boards"][mux_id].pop("model")}') # f'ohmpi.hardware_components.{HARDWARE_CONFIG["mux"]["boards"][mux_id].pop("model")}')
#
MUX_CONFIG = HARDWARE_CONFIG['mux']['boards'][mux_id] # MUX_CONFIG = HARDWARE_CONFIG['mux']['boards'][mux_id]
#
MUX_CONFIG.update({'ctl': ctl, 'connection': MUX_CONFIG.pop('connection', ctl.interfaces[ # MUX_CONFIG.update({'ctl': ctl, 'connection': MUX_CONFIG.pop('connection', ctl.interfaces[
MUX_CONFIG.pop('interface_name', 'i2c_ext')]), 'exec_logger': ctl.exec_logger, # MUX_CONFIG.pop('interface_name', 'i2c_ext')]), 'exec_logger': ctl.exec_logger,
'soh_logger': ctl.soh_logger}) # 'soh_logger': ctl.soh_logger})
MUX_CONFIG.update({'id': mux_id}) # MUX_CONFIG.update({'id': mux_id})
mux = mux_module.Mux(**MUX_CONFIG) # mux = mux_module.Mux(**MUX_CONFIG)
#
# tx.polarity = 1 # # tx.polarity = 1
# time.sleep(1) # # time.sleep(1)
# tx.polarity = 0 # # tx.polarity = 0
# mux.switch(elec_dict={'A': [1], 'B': [4], 'M': [2], 'N': [3]}, state='on') # # mux.switch(elec_dict={'A': [1], 'B': [4], 'M': [2], 'N': [3]}, state='on')
# time.sleep(1) # # time.sleep(1)
# voltage = rx.voltage # # voltage = rx.voltage
# current = tx.current # # current = tx.current
# mux.switch(elec_dict={'A': [1], 'B': [4], 'M': [2], 'N': [3]}, state='off') # # mux.switch(elec_dict={'A': [1], 'B': [4], 'M': [2], 'N': [3]}, state='off')
# print(f'Resistance: {voltage / current :.2f} ohm, voltage: {voltage:.2f} mV, current: {current:.2f} mA') # # print(f'Resistance: {voltage / current :.2f} ohm, voltage: {voltage:.2f} mV, current: {current:.2f} mA')
mux.reset() # mux.reset()
mux.test({'A': [i+8*m for i in range(1, 9)], 'B': [i+8*m for i in range(1, 9)], # mux.test({'A': [i+8*m for i in range(1, 9)], 'B': [i+8*m for i in range(1, 9)],
'M': [i+8*m for i in range(1, 9)], 'N': [i+8*m for i in range(1, 9)]}, activation_time=.1) # 'M': [i+8*m for i in range(1, 9)], 'N': [i+8*m for i in range(1, 9)]}, activation_time=.1)
mux.reset() # mux.reset()
for pol in [1,0,-1,0]:
tx.polarity = pol
print(pol)
time.sleep(5)
# mux as part of a OhmPiHardware system # mux as part of a OhmPiHardware system
if part_of_hardware_system: if part_of_hardware_system:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment