diff --git a/.gitignore b/.gitignore index a819e33815ef5594cde4f4585d3266d75150fa5c..52746f7bcc884e3fba1bb87887b6735d03e75ae6 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ paver-minilib.zip dist setup.py *.egg-info +last_params diff --git a/dstat_interface/main.py b/dstat_interface/main.py index 930fdc28e7176436be463911b191f3f94365c8c9..08881ec17bb4903fbc71343d2205623c769bd1b9 100755 --- a/dstat_interface/main.py +++ b/dstat_interface/main.py @@ -44,6 +44,7 @@ except ImportError: sys.exit(1) from serial import SerialException from datetime import datetime +import yaml os.chdir(os.path.dirname(os.path.abspath(sys.argv[0]))) @@ -54,6 +55,7 @@ import interface.exp_window as exp_window import interface.adc_pot as adc_pot import plot import microdrop +import params import parameter_test from errors import InputError, VarError, ErrorLogger _logger = ErrorLogger(sender="dstat-interface-main") @@ -169,6 +171,11 @@ class Main(object): def quit(self): """Disconnect and save parameters on quit.""" + output = params.get_params(self) + + with open('last_params', 'w') as f: + yaml.dump(output, f) + self.on_serial_disconnect_clicked() gtk.main_quit() diff --git a/dstat_interface/params.py b/dstat_interface/params.py new file mode 100755 index 0000000000000000000000000000000000000000..62426c87df327ea911e123f358ca0ea77eb8ce07 --- /dev/null +++ b/dstat_interface/params.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# DStat Interface - An interface for the open hardware DStat potentiostat +# Copyright (C) 2014 Michael D. M. Dryden - +# Wheeler Microfluidics Laboratory +# +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +from errors import ErrorLogger, InputError +_logger = ErrorLogger(sender="dstat-interface-params") + +def get_params(window): + """Fetches and returns dict of all parameters for saving.""" + + selection = window.exp_window.select_to_key[window.expcombobox.get_active()] + + parameters = {} + parameters['version'] = window.version + parameters.update(window.adc_pot.params) + parameters.update(window.exp_window.get_params(selection)) + + return parameters \ No newline at end of file