forked from zietzm/Helmholtz_Test_Bench
started on config file
renamed settings.py to globals.py
This commit is contained in:
+1
-1
@@ -1,7 +1,7 @@
|
||||
# import platform
|
||||
import time as t
|
||||
import numpy as np
|
||||
import settings as g
|
||||
import globals as g
|
||||
import cage_func as func
|
||||
from pyps2000b import PS2000B
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
from tkinter import *
|
||||
from tkinter import ttk
|
||||
import settings as g
|
||||
import globals as g
|
||||
import cage_func as func
|
||||
import numpy as np
|
||||
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
from pyps2000b import PS2000B
|
||||
from Arduino import Arduino
|
||||
import settings as g
|
||||
import globals as g
|
||||
import pandas
|
||||
import time
|
||||
import numpy as np
|
||||
@@ -75,7 +75,7 @@ class Axis:
|
||||
else:
|
||||
self.connected = "Connected"
|
||||
|
||||
def print_status(self): # axis = axis control variable, stored in settings.py
|
||||
def print_status(self): # axis = axis control variable, stored in globals.py
|
||||
ui_print("%s, %0.2f V, %0.2f A"
|
||||
% (self.device.get_device_status_information(self.channel),
|
||||
self.device.get_voltage(self.channel), self.device.get_current(self.channel)))
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
import numpy as np
|
||||
from configparser import ConfigParser
|
||||
|
||||
# global variables set in other files
|
||||
XY_DEVICE = None
|
||||
Z_DEVICE = None
|
||||
ARDUINO = None
|
||||
|
||||
X_AXIS = None # object structure: (device, channel, arduino pin, axis index)
|
||||
Y_AXIS = None
|
||||
@@ -9,6 +12,26 @@ Z_AXIS = None
|
||||
|
||||
AXES = None # list containing [X_AXIS, Y_AXIS, Z_AXIS]
|
||||
|
||||
app = None
|
||||
|
||||
|
||||
def read_config(file): # attempt to read config file
|
||||
config_object = ConfigParser()
|
||||
config_object.read(file)
|
||||
print(config_object["X-Axis"]["coil_consthhh"])
|
||||
|
||||
|
||||
def create_config(file):
|
||||
config = ConfigParser()
|
||||
|
||||
config["X-Axis"] = {
|
||||
"coil_const": str(38.6 * 1e-6)
|
||||
}
|
||||
|
||||
with open(file, 'w') as conf:
|
||||
config.write(conf)
|
||||
|
||||
|
||||
# Constants:
|
||||
COIL_CONST = np.array([38.6, 38.45, 37.9]) * 1e-6 # Coil constants [x,y,z] in T/A
|
||||
AMBIENT_FIELD = np.array([30, 30, 30]) * 1e-6 # ambient magnetic field in measurement area, to be cancelled out
|
||||
@@ -23,10 +46,4 @@ Z_PORT = "COM11"
|
||||
AXIS_NAMES = ["X-Axis", "Y-Axis", "Z-Axis"]
|
||||
ports = [XY_PORT, XY_PORT, Z_PORT]
|
||||
|
||||
ARDUINO = None
|
||||
|
||||
RELAY_PINS = [15, 16, 17] # pin on the Arduino for switching relay of each axis [x,y,z]
|
||||
|
||||
app = None
|
||||
|
||||
# ToDo: make proper settings file to read from and write to
|
||||
@@ -1,10 +1,18 @@
|
||||
from User_Interface import HelmholtzGUI
|
||||
import cage_func as func
|
||||
import traceback
|
||||
import settings as g
|
||||
import globals as g
|
||||
|
||||
try: # start normal operations
|
||||
|
||||
print("Reading config file...")
|
||||
config_file = 'config.ini'
|
||||
try:
|
||||
g.read_config(config_file)
|
||||
except KeyError:
|
||||
print("Error when reading config file, creating new.")
|
||||
g.create_config(config_file)
|
||||
|
||||
print("Starting setup...")
|
||||
func.setup_axes() # initiate communication, set handles
|
||||
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
import numpy as np
|
||||
import settings as g
|
||||
import globals as g
|
||||
import cage_func as func
|
||||
# from pyps2000b import PS2000B
|
||||
from Arduino import Arduino
|
||||
|
||||
Reference in New Issue
Block a user