Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • dev
  • master
  • 20200721_ecolux
  • live_in_ecotron_hall
4 results

Target

Select target project
  • sugu/skyglow
1 result
Select Git revision
  • dev
  • master
  • 20200721_ecolux
  • live_in_ecotron_hall
4 results
Show changes
Commits on Source (2)
skyglow.log
moon?*
README.html
__pycache__
\ No newline at end of file
#!/usr/bin/python3
#TODO catch if no ola is installed
# Traceback (most recent call last):
# File "./skyglow.py", line 5, in <module>
# from ola.ClientWrapper import ClientWrapper
# ImportError: No module named ola.ClientWrapper
from __future__ import print_function #python 2
import os
from ola.ClientWrapper import ClientWrapper
import os, sys, array
from datetime import datetime as dt
import array
import sys
# error / return codes
# # # # # # #
......@@ -21,6 +11,7 @@ FAIL_DMX_SEND=4
FAIL_DMX_RECEIVE=5
FAIL_LOG=6
FAIL_MOON=7
FAIL_NO_OLA=8
# either fullpath or just name (then logFile will be created in scriptdir)
# or fullpath containing '/'
......@@ -36,36 +27,38 @@ dmxDataReceived = False
MAX_DMX_FRAME_SIZE = 512
skyglowDict = {
15: 0.08, # one
54: 0.3, # one
4: 1, # all
19: 0.1, # one
0: 0, # none
1: 0.01, # one
5: 0.03, # one
0: 0, # none
40: 10, # all
12: 3, # all
123: 30, # all
123: 30, # all
}
skyglow = list( skyglowDict.keys() )
skyglow.insert(7,0) #exit twice
skyglow.append(123) #exit twice
assert len(skyglow)==12, "skyglow len doesn't fit number pf ecounits!"
#change according to needs
dmx_addr = [10,20,30,40,50,60,70,80,90,100,110,120]
NUM_ECO_UNITS = len(dmx_addr)
# assert len(dmx_addr) == NUM_ECO_UNITS
# assert len(skyglow) == NUM_ECO_UNITS
#Mapping byte to lux
skyglow = [ 15, # one 0.08
54, # one 0.3
4, # all 1
19, # one 0.1
0, # none 0
1, # one 0.01
5, # one 0.03
0, # none 0
40, # all 10
12, # all 3
123, # all 30
123, # all 30
]
NUM_ECO_UNITS = len(skyglow)
sunrise = 0
sunset = 0
#datetime.now(timezone.utc) #create aware!
#utcnow() / utcfromtimestamp()
#UTC: utcfromtimestamp() / datetime.now(timezone.utc)
now = dt.utcnow().replace(second=0, microsecond=0) # ignore seconds and microseconds
#mlx (idx is also dmx-byte value)
moon = [ 1.409,
moon = [
1.409,
8.369,
12.333,
16.210,
......@@ -126,8 +119,8 @@ moon = [ 1.409,
277.267,
281.433,
287.467, #60
]
]
#moonFile
DATE_COLUMN=0
......@@ -182,7 +175,7 @@ def readLux():
return moonLux
def log(msg):
msg = str(now) + msg + "\n"
msg = str(now) + "\t" + msg + "\n"
if not os.access(logFile, os.X_OK) or os.access(logFile, os.W_OK):
print("writing log to file ", logFile)
......@@ -264,6 +257,11 @@ def main(args=""):
print("welcome to skyglow!")
print(args)
try:
from ola.ClientWrapper import ClientWrapper
except Exception as e:
error(FAIL_NO_OLA, e)
global data, moonLux, moonDmx
init()
......@@ -300,13 +298,14 @@ def main(args=""):
print("DMX-Data:",data)
try:
global wrapper
wrapper = ClientWrapper()
client = wrapper.Client()
# send 1 dmx frame with values for channels 1-3 for all ecounits
client.SendDmx(UNIVERSE, data, dmxSent)
client.RegisterUniverse(UNIVERSE, client.REGISTER, dmxReceive)
client.RegisterUniverse(UNIVERSE, client.REGISTER, dmxReceive)
wrapper.Run()
except Exception as e:
error(FAIL_DMX,e)
......