Changeset - e69661cca1cb
[Not reviewed]
default
0 4 0
drewp@bigasterisk.com - 20 months ago 2023-05-18 18:56:28
drewp@bigasterisk.com
cleanup
4 files changed with 9 insertions and 8 deletions:
0 comments (0 inline, 0 general)
light9/collector/collector.py
Show inline comments
 
import logging
 
import time
 
from typing import Dict, List, Set, Tuple, Type, TypeVar, cast
 
from typing import Dict, List, Set, Tuple, cast
 

	
 
from rdfdb.syncedgraph.syncedgraph import SyncedGraph
 
from rdflib import Literal, URIRef
 
from rdflib import Literal
 

	
 
from light9.collector.device import resolve, toOutputAttrs
 
from light9.collector.output import Output as OutputInstance
 
from light9.collector.weblisteners import WebListeners
 
from light9.namespaces import L9, RDF
 
from light9.newtypes import (ClientSessionType, ClientType, DeviceAttr, DeviceClass, DeviceUri, DmxIndex, DmxMessageIndex, OutputAttr, OutputRange, OutputUri,
 
@@ -16,14 +16,12 @@ log = logging.getLogger('collector')
 

	
 

	
 
def makeDmxMessageIndex(base: DmxIndex, offset: DmxIndex) -> DmxMessageIndex:
 
    return DmxMessageIndex(base + offset - 1)
 

	
 

	
 

	
 

	
 
def outputMap(graph: SyncedGraph, outputs: List[OutputInstance]) -> Dict[Tuple[DeviceUri, OutputAttr], Tuple[OutputInstance, DmxMessageIndex]]:
 
    """From rdf config graph, compute a map of
 
       (device, outputattr) : (output, index)
 
    that explains which output index to set for any device update.
 
    """
 
    ret = {}
light9/fade/web/Light9FadeUi.ts
Show inline comments
 
@@ -2,13 +2,13 @@ import { fastSlider, fastSliderLabel, pr
 
import debug from "debug";
 
import { css, html, LitElement } from "lit";
 
import { customElement, property } from "lit/decorators.js";
 
import { NamedNode } from "n3";
 
import { getTopGraph } from "../../web/RdfdbSyncedGraph";
 
import { SyncedGraph } from "../../web/SyncedGraph";
 
import { shortShow, showRoot } from "light9/web/show_specific";
 
import { shortShow, showRoot } from "../../web/show_specific";
 
export { EditChoice } from "../../web/EditChoice";
 

	
 
provideFASTDesignSystem().register(fastSlider(), fastSliderLabel());
 

	
 
debug.enable("*");
 
const log = debug("fade");
 
@@ -57,12 +57,14 @@ export class Light9FadeUi extends LitEle
 
@customElement("light9-fader")
 
export class Light9Fader extends LitElement {
 
  static styles = [
 
    css`
 
      :host {
 
        display: inline-block;
 
        border: 2px gray outset;
 
        background: #272727;
 
      }
 
      fast-slider {
 
        height: 256px;
 
      }
 
      fast-slider > .track {
 
        background: #e3bbc0;
light9/fade/web/index.html
Show inline comments
 
<!doctype html>
 
<html>
 
  <head>
 
    <title>fade</title>
 
    <meta charset="utf-8" />
 
    <link rel="stylesheet" href="./style.css">    
 
    <link rel="stylesheet" href="../style.css">    
 
    <script type="module" src="../fade/Light9FadeUi"></script>
 
  </head>
 
  <body>
 
    <light9-fade-ui></light9-fade-ui>
 
  </body>
 
</html>
light9/newtypes.py
Show inline comments
 
@@ -21,20 +21,21 @@ UnixTime = NewType('UnixTime', float)
 
# 1.0, you can map that range into, say, 0.2 to 0.7
 
OutputRange = NewType('OutputRange', Tuple[float, float])
 

	
 
_ObjType = TypeVar('_ObjType')
 

	
 

	
 
def _isSubclass2(t1: Type, t2: type) -> bool:
 
def _isSubclass2(t1: Type, t2: Type) -> bool:
 
    """same as issubclass but t1 can be a NewType"""
 
    if hasattr(t1, '__supertype__'):
 
        t1 = t1.__superType__
 
    return issubclass(t1, t2)
 

	
 

	
 
def typedValue(objType: Type[_ObjType], graph, subj, pred) -> _ObjType:
 
    """graph.value(subj, pred) with a given return type. If objType is """
 
    """graph.value(subj, pred) with a given return type. 
 
    If objType is not an rdflib.Node, we toPython() the value."""
 
    obj = graph.value(subj, pred)
 
    if obj is None:
 
        raise ValueError()
 
    conv = obj if _isSubclass2(objType, Node) else obj.toPython()
 
    return cast(objType, conv)
 
\ No newline at end of file
0 comments (0 inline, 0 general)