changeset 2433:ffa69645e9dc

refactor
author drewp@bigasterisk.com
date Tue, 28 May 2024 15:41:53 -0700
parents b8a408caf115
children 9b101d8bd7ea
files src/light9/blender/time_sync/time_from_graph.py
diffstat 1 files changed, 6 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/light9/blender/time_sync/time_from_graph.py	Tue May 28 15:35:12 2024 -0700
+++ b/src/light9/blender/time_sync/time_from_graph.py	Tue May 28 15:41:53 2024 -0700
@@ -17,10 +17,6 @@
     return max(lo, min(hi, x))
 
 
-def floatValue(graph: SyncedGraph, s: URIRef, p: URIRef) -> float | None:
-    return typedValue(float | None, graph, s, p)
-
-
 UPDATE_PERIOD = 1 / 20
 
 
@@ -29,19 +25,18 @@
     duration: float = 1
     wallStartTime: float | None = None
     pausedSongTime: float | None = None
-    playing=False
+    playing = False
     latestTime: float
 
     def __init__(self):
         # main thread
         self.lastSetFrame = -1
         self.lastGraphFrame = -1
-        self.frameSetBy = 'init'
         startLoopInThread(self.task())
         bpy.app.timers.register(self.update)
         bpy.app.handlers.frame_change_post.append(self.on_frame_change_post)
 
-    ## read from graph
+    ## updates from graph -> self
 
     async def task(self):
         # bg thread with asyncio loop
@@ -52,9 +47,9 @@
         # bg thread
         with self.lock:
             asco = L9['ascoltami']
-            self.wallStartTime = floatValue(self.graph, asco, L9['wallStartTime'])
-            self.pausedSongTime = floatValue(self.graph, asco, L9['pausedSongTime'])
-            self.duration = floatValue(self.graph, asco, L9['duration']) or 1.0
+            self.wallStartTime = typedValue(float | None, self.graph, asco, L9['wallStartTime'])
+            self.pausedSongTime = typedValue(float | None, self.graph, asco, L9['pausedSongTime'])
+            self.duration = typedValue(float | None, self.graph, asco, L9['duration']) or 1.0
             self.playing = typedValue(bool, self.graph, asco, L9['playing'])
 
     def currentTime(self) -> float | None:
@@ -97,4 +92,4 @@
             self.setInGraph(t)
 
     def setInGraph(self, t: float):
-        log.warning(f'todo: set graph to {t}')
\ No newline at end of file
+        log.warning(f'todo: set graph to {t}')