class EnergyUsageLight(object):
    def __init__(self, db_path, pence_per_hour):
        self._comms = DBComms(db_path)
        self._light = Lighting()
        self._pence_per_hour = pence_per_hour

    def update(self):
        if not self._comms.check_comms_status():
            self._light.set_error()
        else:
            kw = self._comms.get_current_kw()
            rgb_dict = kw_to_rgb(kw, self._pence_per_hour)
            self._light.set_light(rgb_dict)
Example #2
0
def room():

    filename = request.args.get('filename', None)
    layers = int(request.args.get('layers', 0))

    if not filename:
        flash('Missing filename argument')
        return redirect('/')

    file_path = os.path.join(app.config['UPLOAD_FOLDER'], filename)
    if not os.path.exists(file_path):
        flash('File not exists')
        return redirect('/')
    matrix = []
    lines = open(file_path, 'r')
    for line in lines:
        row = []
        for char in line:
            if char in ['0', '1']:
                row.append(int(char))
        matrix.append(row)

    max_layers = 0
    layers_color = {}
    try:
        l = Lighting(matrix)
        l.v1()
        matrix, max_layers, layers_color = l.light_on(layers=layers)
    except Exception as e:
        flash(str(e))
        return redirect('/')

    rt = render_template('room.html',
                         matrix=matrix,
                         layers=layers,
                         max_layers=max_layers,
                         layers_color=layers_color,
                         filename=filename)
    return rt
Example #3
0
    def __init__(self, image_size=100, background_color=[0,0,0], near=1, far=100, anti_aliasing=True, 
                fill_back=True, eps=1e-3, sigma_val=1e-5, dist_eps=1e-4, gamma_val=1e-4,
                P=None, dist_coeffs=None, orig_size=512, perspective=True, viewing_angle=30, 
                viewing_scale=1.0, eye=None, camera_direction=[0,0,1],
                light_intensity_ambient=0.5, light_color_ambient=[1,1,1],
                light_intensity_directionals=0.5, light_color_directionals=[1,1,1],
                light_directions=[0,1,0]):
        super(SoftRenderer, self).__init__()

        # light
        self.lighting = Lighting(light_intensity_ambient, light_color_ambient, light_intensity_directionals, 
                                light_color_directionals, light_directions)

        # camera
        self.transform = Transform(P, dist_coeffs, orig_size, perspective, viewing_angle, viewing_scale, 
                                    eye, camera_direction)

        # rasterization
        self.rasterizer = SoftRasterizer(image_size, background_color, near, far, anti_aliasing, 
                                        fill_back, eps, sigma_val, dist_eps, gamma_val)
 def __init__(self, db_path, pence_per_hour):
     self._comms = DBComms(db_path)
     self._light = Lighting()
     self._pence_per_hour = pence_per_hour
Example #5
0
# Import of own classes
from tracks import Tracks
from playlist import Playlist
from hardware import Hardware
from lighting import Lighting, Section
try:
    from led import Leds
except:
    from led_nohw import Leds

# Initializations
tracks = Tracks("tracks")
playlist = Playlist()
hardware = Hardware(tracks, playlist)
ledHw = Leds(64)
ledConfig = Lighting(ledHw)

event_start = threading.Event()
event_stop = threading.Event()
event_shutdown = threading.Event()

# Creating the web server
app = Flask(__name__, template_folder=".", static_folder="assets")
app.config.from_object('config.Config')
log = logging.getLogger('werkzeug')
log.setLevel(logging.ERROR)

# Definition of all the server routings


@app.route('/', methods=['GET', 'POST'])
Example #6
0
  elif kw_in_pence < 8 and kw_in_pence > 0:
    print("< 8 = BLUE")
    rgb_dict=Lighting.BLUE
  elif kw_in_pence == 0:
    print("==0 = PURPLE (No value yet)")
    rgb_dict=Lighting.PURPLE

  return rgb_dict


try:
  signal.signal(signal.SIGTERM, signal_term_handler)

  #Create comms and lighting instances
  comms=db_comms.db_comms(DB_PATH)
  light=Lighting()

  while True:
    if comms.check_comms_status() == False:
      light.set_error()
    else:
      kw=comms.get_current_kw() #Get current kw
      rgb_dict=kw_to_rgb(kw) #Get the dictionary for colouring
      light.set_light(rgb_dict) #Set the light value

    #Flush the stdout each time round the loop
    sys.stdout.flush()

    #Sleep for a bit before the next update
    time.sleep(SLEEP_TIME_IN_SECS)