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 skyglow.log
moon?* moon?*
README.html README.html
__pycache__
\ No newline at end of file
#!/usr/bin/python3 #!/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 from __future__ import print_function #python 2
import os import os, sys, array
from ola.ClientWrapper import ClientWrapper
from datetime import datetime as dt from datetime import datetime as dt
import array
import sys
# error / return codes # error / return codes
# # # # # # # # # # # # # #
...@@ -21,6 +11,7 @@ FAIL_DMX_SEND=4 ...@@ -21,6 +11,7 @@ FAIL_DMX_SEND=4
FAIL_DMX_RECEIVE=5 FAIL_DMX_RECEIVE=5
FAIL_LOG=6 FAIL_LOG=6
FAIL_MOON=7 FAIL_MOON=7
FAIL_NO_OLA=8
# either fullpath or just name (then logFile will be created in scriptdir) # either fullpath or just name (then logFile will be created in scriptdir)
# or fullpath containing '/' # or fullpath containing '/'
...@@ -36,36 +27,38 @@ dmxDataReceived = False ...@@ -36,36 +27,38 @@ dmxDataReceived = False
MAX_DMX_FRAME_SIZE = 512 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 #change according to needs
dmx_addr = [10,20,30,40,50,60,70,80,90,100,110,120] 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 sunrise = 0
sunset = 0 sunset = 0
#datetime.now(timezone.utc) #create aware! #UTC: utcfromtimestamp() / datetime.now(timezone.utc)
#utcnow() / utcfromtimestamp()
now = dt.utcnow().replace(second=0, microsecond=0) # ignore seconds and microseconds now = dt.utcnow().replace(second=0, microsecond=0) # ignore seconds and microseconds
#mlx (idx is also dmx-byte value) #mlx (idx is also dmx-byte value)
moon = [ 1.409, moon = [
1.409,
8.369, 8.369,
12.333, 12.333,
16.210, 16.210,
...@@ -126,8 +119,8 @@ moon = [ 1.409, ...@@ -126,8 +119,8 @@ moon = [ 1.409,
277.267, 277.267,
281.433, 281.433,
287.467, #60 287.467, #60
] ]
#moonFile #moonFile
DATE_COLUMN=0 DATE_COLUMN=0
...@@ -182,7 +175,7 @@ def readLux(): ...@@ -182,7 +175,7 @@ def readLux():
return moonLux return moonLux
def log(msg): 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): if not os.access(logFile, os.X_OK) or os.access(logFile, os.W_OK):
print("writing log to file ", logFile) print("writing log to file ", logFile)
...@@ -264,6 +257,11 @@ def main(args=""): ...@@ -264,6 +257,11 @@ def main(args=""):
print("welcome to skyglow!") print("welcome to skyglow!")
print(args) print(args)
try:
from ola.ClientWrapper import ClientWrapper
except Exception as e:
error(FAIL_NO_OLA, e)
global data, moonLux, moonDmx global data, moonLux, moonDmx
init() init()
...@@ -300,13 +298,14 @@ def main(args=""): ...@@ -300,13 +298,14 @@ def main(args=""):
print("DMX-Data:",data) print("DMX-Data:",data)
try: try:
global wrapper global wrapper
wrapper = ClientWrapper() wrapper = ClientWrapper()
client = wrapper.Client() client = wrapper.Client()
# send 1 dmx frame with values for channels 1-3 for all ecounits # send 1 dmx frame with values for channels 1-3 for all ecounits
client.SendDmx(UNIVERSE, data, dmxSent) client.SendDmx(UNIVERSE, data, dmxSent)
client.RegisterUniverse(UNIVERSE, client.REGISTER, dmxReceive) client.RegisterUniverse(UNIVERSE, client.REGISTER, dmxReceive)
wrapper.Run() wrapper.Run()
except Exception as e: except Exception as e:
error(FAIL_DMX,e) error(FAIL_DMX,e)
......