LJ/libs3/settings.py

97 lines
3.5 KiB
Python
Raw Permalink Normal View History

2020-09-19 12:28:56 +00:00
#!/usr/bin/python3
2018-12-13 11:05:32 +00:00
# -*- coding: utf-8 -*-
# -*- mode: Python -*-
'''
2020-09-22 22:44:08 +00:00
LJ
2018-12-13 11:05:32 +00:00
v0.7.0
Settings Handler
LICENCE : CC
'''
2020-09-19 12:28:56 +00:00
import configparser
from libs3 import gstt
2018-12-13 11:05:32 +00:00
import ast
import numpy as np
2024-08-19 19:22:38 +00:00
def Write():
2018-12-13 11:05:32 +00:00
config.set('General', 'lasernumber', str(gstt.LaserNumber))
2023-06-03 12:43:53 +00:00
config.set('General', 'rediserverip', str(gstt.RediServerIP))
2020-09-19 12:28:56 +00:00
config.set('General', 'wwwip', str(gstt.wwwIP))
2023-06-03 12:43:53 +00:00
config.set('General', 'oscserverip', str(gstt.oscIPin))
2018-12-13 11:05:32 +00:00
config.set('General', 'nozoscip', str(gstt.nozoscIP))
2023-06-03 12:43:53 +00:00
config.set('General', 'wsport', str(gstt.wsPORT))
config.set('General', 'debug', str(gstt.debug))
2020-09-19 12:28:56 +00:00
config.set('General', 'autostart', gstt.autostart)
2019-03-10 22:06:04 +00:00
2018-12-13 11:05:32 +00:00
for i in range(gstt.LaserNumber):
laser = 'laser' + str(i)
config.set(laser, 'ip', str(gstt.lasersIPS[i]))
2020-09-19 12:28:56 +00:00
config.set(laser, 'type', str(gstt.lasertype[i]))
2023-06-03 12:43:53 +00:00
config.set(laser, 'dac_family', str(gstt.dacfamily[i]))
2024-08-19 20:47:42 +00:00
if gstt.dacfamily[i] == "extern_cmd":
config.set(laser, 'cmd', str(gstt.cmd[i]))
2018-12-13 11:05:32 +00:00
config.set(laser, 'kpps', str(gstt.kpps[i]))
2023-06-03 12:43:53 +00:00
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]))
2018-12-13 11:05:32 +00:00
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'))
2024-08-19 19:22:38 +00:00
def Read():
2018-12-13 11:05:32 +00:00
gstt.LaserNumber = config.getint('General', 'lasernumber')
2023-06-03 12:43:53 +00:00
gstt.RediServerIP= config.get('General', 'rediserverip')
2020-09-19 12:28:56 +00:00
gstt.wwwIP= config.get('General', 'wwwip')
2023-06-03 12:43:53 +00:00
gstt.oscIPin = config.get('General', 'oscserverip')
gstt.nozoscIP = config.get('General', 'nozoscip')
gstt.debug = config.get('General', 'debug')
2023-06-03 12:43:53 +00:00
gstt.wsPORT = config.getint('General', 'wsport')
2020-09-19 12:28:56 +00:00
gstt.plugins = ast.literal_eval(config.get('plugins', 'plugins'))
gstt.autostart = config.get('General', 'autostart')
2019-03-10 22:06:04 +00:00
2018-12-13 11:05:32 +00:00
for i in range(4):
laser = 'laser' + str(i)
gstt.lasersIPS[i]= config.get(laser, 'ip')
2020-09-19 12:28:56 +00:00
gstt.lasertype[i]= config.get(laser, 'type')
2023-06-03 12:43:53 +00:00
gstt.dacfamily[i] = config.get(laser, 'dac_family')
2024-08-19 19:22:38 +00:00
if gstt.dacfamily[i] == "extern_cmd":
gstt.cmd[i] = config.get(laser, 'cmd')
2018-12-13 11:05:32 +00:00
gstt.kpps[i] = config.getint(laser, 'kpps')
2023-06-03 12:43:53 +00:00
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')
2018-12-13 11:05:32 +00:00
#gstt.lasersPLcolor[i] = config.getint(laser, 'color')
2023-06-03 12:43:53 +00:00
gstt.centerX[i]= config.getfloat(laser, 'centerx')
gstt.centerY[i] = config.getfloat(laser, 'centery')
2018-12-13 11:05:32 +00:00
gstt.zoomX[i] = config.getfloat(laser, 'zoomx')
gstt.zoomY[i] = config.getfloat(laser, 'zoomy')
2023-06-03 12:43:53 +00:00
gstt.sizeX[i] = config.getfloat(laser, 'sizex')
gstt.sizeY[i] = config.getfloat(laser, 'sizey')
2018-12-13 11:05:32 +00:00
gstt.finANGLE[i] = config.getfloat(laser, 'finangle')
gstt.swapX[i] = config.getint(laser, 'swapx')
gstt.swapY[i] = config.getint(laser, 'swapy')
2020-09-19 12:28:56 +00:00
gstt.lsteps[i] = ast.literal_eval(config.get(laser, 'lsteps'))
2018-12-13 11:05:32 +00:00
gstt.warpdest[i]= np.array(ast.literal_eval(config.get(laser, 'warpdest')))
2020-09-19 12:28:56 +00:00
config = configparser.ConfigParser()
2018-12-13 11:05:32 +00:00
config.read(gstt.ConfigName)