LJ/libs3/settings.py
2023-06-03 14:43:53 +02:00

94 lines
3.3 KiB
Python

#!/usr/bin/python3
# -*- coding: utf-8 -*-
# -*- mode: Python -*-
'''
LJ
v0.7.0
Settings Handler
LICENCE : CC
'''
import configparser
from libs3 import gstt
import ast
import numpy as np
def Write():
config.set('General', 'lasernumber', str(gstt.LaserNumber))
config.set('General', 'rediserverip', str(gstt.RediServerIP))
config.set('General', 'wwwip', str(gstt.wwwIP))
config.set('General', 'oscserverip', str(gstt.oscIPin))
config.set('General', 'nozoscip', str(gstt.nozoscIP))
config.set('General', 'wsport', str(gstt.wsPORT))
config.set('General', 'debug', str(gstt.debug))
config.set('General', 'autostart', gstt.autostart)
for i in range(gstt.LaserNumber):
laser = 'laser' + str(i)
config.set(laser, 'ip', str(gstt.lasersIPS[i]))
config.set(laser, 'type', str(gstt.lasertype[i]))
config.set(laser, 'dac_family', str(gstt.dacfamily[i]))
config.set(laser, 'kpps', str(gstt.kpps[i]))
config.set(laser, 'intens', str(gstt.intens[i]))
config.set(laser, 'red', str(gstt.red[i]))
config.set(laser, 'green', str(gstt.green[i]))
config.set(laser, 'blue', str(gstt.blue[i]))
config.set(laser, 'centerx', str(gstt.centerX[i]))
config.set(laser, 'centery', str(gstt.centerY[i]))
config.set(laser, 'zoomx', str(gstt.zoomX[i]))
config.set(laser, 'zoomy', str(gstt.zoomY[i]))
config.set(laser, 'sizex', str(gstt.sizeX[i]))
config.set(laser, 'sizey', str(gstt.sizeY[i]))
config.set(laser, 'finangle', str(gstt.finANGLE[i]))
config.set(laser, 'swapx', str(gstt.swapX[i]))
config.set(laser, 'swapy', str(gstt.swapY[i]))
config.set(laser, 'warpdest', np.array2string(gstt.warpdest[i], precision=2, separator=',',suppress_small=True))
config.write(open(gstt.ConfigName,'w'))
def Read():
gstt.LaserNumber = config.getint('General', 'lasernumber')
gstt.RediServerIP= config.get('General', 'rediserverip')
gstt.wwwIP= config.get('General', 'wwwip')
gstt.oscIPin = config.get('General', 'oscserverip')
gstt.nozoscIP = config.get('General', 'nozoscip')
gstt.debug = config.get('General', 'debug')
gstt.wsPORT = config.getint('General', 'wsport')
gstt.plugins = ast.literal_eval(config.get('plugins', 'plugins'))
gstt.autostart = config.get('General', 'autostart')
for i in range(4):
laser = 'laser' + str(i)
gstt.lasersIPS[i]= config.get(laser, 'ip')
gstt.lasertype[i]= config.get(laser, 'type')
gstt.dacfamily[i] = config.get(laser, 'dac_family')
gstt.kpps[i] = config.getint(laser, 'kpps')
gstt.intens[i] = config.getfloat(laser, 'intens')
gstt.red[i] = config.getint(laser, 'red')
gstt.green[i] = config.getint(laser, 'green')
gstt.blue[i] = config.getint(laser, 'blue')
#gstt.lasersPLcolor[i] = config.getint(laser, 'color')
gstt.centerX[i]= config.getfloat(laser, 'centerx')
gstt.centerY[i] = config.getfloat(laser, 'centery')
gstt.zoomX[i] = config.getfloat(laser, 'zoomx')
gstt.zoomY[i] = config.getfloat(laser, 'zoomy')
gstt.sizeX[i] = config.getfloat(laser, 'sizex')
gstt.sizeY[i] = config.getfloat(laser, 'sizey')
gstt.finANGLE[i] = config.getfloat(laser, 'finangle')
gstt.swapX[i] = config.getint(laser, 'swapx')
gstt.swapY[i] = config.getint(laser, 'swapy')
gstt.lsteps[i] = ast.literal_eval(config.get(laser, 'lsteps'))
gstt.warpdest[i]= np.array(ast.literal_eval(config.get(laser, 'warpdest')))
config = configparser.ConfigParser()
config.read(gstt.ConfigName)