LJ/libs3/settings.py

83 lines
2.7 KiB
Python
Raw 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
def Write():
config.set('General', 'lasernumber', str(gstt.LaserNumber))
config.set('General', 'ljayserverip', str(gstt.LjayServerIP))
2020-09-19 12:28:56 +00:00
config.set('General', 'wwwip', str(gstt.wwwIP))
2018-12-13 11:05:32 +00:00
config.set('General', 'bhoroscip', str(gstt.oscIPin))
config.set('General', 'nozoscip', str(gstt.nozoscIP))
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]))
2018-12-13 11:05:32 +00:00
config.set(laser, 'kpps', str(gstt.kpps[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.LjayServerIP= config.get('General', 'ljayserverip')
2020-09-19 12:28:56 +00:00
gstt.wwwIP= config.get('General', 'wwwip')
2018-12-13 11:05:32 +00:00
gstt.oscIPin = config.get('General', 'bhoroscip')
gstt.nozoscip = config.get('General', 'nozoscip')
gstt.debug = config.get('General', 'debug')
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')
2018-12-13 11:05:32 +00:00
gstt.kpps[i] = config.getint(laser, 'kpps')
#gstt.lasersPLcolor[i] = config.getint(laser, 'color')
gstt.centerX[i]= config.getint(laser, 'centerx')
gstt.centerY[i] = config.getint(laser, 'centery')
gstt.zoomX[i] = config.getfloat(laser, 'zoomx')
gstt.zoomY[i] = config.getfloat(laser, 'zoomy')
gstt.sizeX[i] = config.getint(laser, 'sizex')
gstt.sizeY[i] = config.getint(laser, 'sizey')
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)
2020-09-19 12:28:56 +00:00