@@ -941,14 +941,26 @@ def process_channels(self, dmx_mode_channels, channels):
941
941
942
942
# create a link from channel function to a mode_master channel:
943
943
for dmx_channel in channels :
944
+ modemasters_exist = False
944
945
for ch_function in dmx_channel .channel_functions :
945
946
if ch_function .mode_master != "" :
946
947
for ch in channels :
947
- # we might have to search in both dmx and virtual
948
948
if ch .name_ == ch_function .mode_master :
949
+ modemasters_exist = True
949
950
ch_function .mm_dmx_break = ch .dmx_break
950
951
ch_function .mm_offsets = ch .offsets
951
952
ch_function .mm_offsets_bytes = ch .offsets_bytes
953
+ if not modemasters_exist :
954
+ # create some caching of dmx channel data
955
+ # we ignore channels with mode dependencies
956
+ # as checking for the cache and then finding that we need
957
+ # to re-calculate the value anyways is probably more expensive
958
+ dmx_channel ["cached_channel" ] = {
959
+ "dmx_value" : - 1 ,
960
+ "attribute" : None ,
961
+ "value" : - 1 ,
962
+ "index" : - 1 ,
963
+ }
952
964
953
965
# Interface Methods #
954
966
@@ -1282,20 +1294,53 @@ def render(self, skip_cache=False, current_frame=None):
1282
1294
dmx_value_fine = dmx_data [channel .dmx_break ][channel .offsets [1 ]]
1283
1295
dmx_value_final = (dmx_value_coarse << 8 ) | dmx_value_fine
1284
1296
1285
- DMX_Log .log .debug (
1286
- (
1287
- "start function search" ,
1288
- channel .name_ ,
1289
- channel .offsets ,
1290
- channel .offsets_bytes ,
1297
+ skip_attr_search = False
1298
+ if "cached_channel" in channel :
1299
+ cached_dmx = channel ["cached_channel" ].get ("dmx_value" )
1300
+ cached_attr = channel ["cached_channel" ].get ("attribute" , None )
1301
+ cached_value = channel ["cached_channel" ].get ("value" )
1302
+ cached_slot = channel ["cached_channel" ].get ("index" )
1303
+
1304
+ if dmx_value_final == int (cached_dmx ) and cached_attr is not None :
1305
+ skip_attr_search = True
1306
+ channel_function_attribute = cached_attr
1307
+ channel_function_physical_value = cached_value
1308
+ channel_set_wheel_slot = cached_slot
1309
+ DMX_Log .log .debug (
1310
+ (
1311
+ "use cached data" ,
1312
+ channel .name_ ,
1313
+ channel_function_attribute ,
1314
+ channel_function_physical_value ,
1315
+ channel_set_wheel_slot ,
1316
+ )
1317
+ )
1318
+
1319
+ if not skip_attr_search and self .use_fixtures_channel_functions :
1320
+ DMX_Log .log .debug (
1321
+ ("search for fresh attribute data" , channel .attribute )
1291
1322
)
1292
- )
1323
+ DMX_Log .log .debug (
1324
+ (
1325
+ "start function search" ,
1326
+ channel .name_ ,
1327
+ channel .offsets ,
1328
+ channel .offsets_bytes ,
1329
+ )
1330
+ )
1331
+
1332
+ (
1333
+ channel_function_attribute ,
1334
+ channel_function_physical_value ,
1335
+ channel_set_wheel_slot ,
1336
+ ) = channel .get_function_attribute_data (dmx_value_final , dmx_data )
1293
1337
1294
- (
1295
- channel_function_attribute ,
1296
- channel_function_physical_value ,
1297
- channel_set_wheel_slot ,
1298
- ) = channel .get_function_attribute_data (dmx_value_final , dmx_data )
1338
+ if "cached_channel" in channel :
1339
+ DMX_Log .log .debug (("set cached data" , channel .attribute ))
1340
+ channel ["cached_channel" ]["dmx_value" ] = dmx_value_final
1341
+ channel ["cached_channel" ]["attribute" ] = channel_function_attribute
1342
+ channel ["cached_channel" ]["value" ] = channel_function_physical_value
1343
+ channel ["cached_channel" ]["index" ] = channel_set_wheel_slot or - 1
1299
1344
1300
1345
if not self .use_fixtures_channel_functions :
1301
1346
channel_function = dmx .get_default_channel_function_by_attribute (
@@ -2121,7 +2166,7 @@ def updateRotation(self, geometry=None, x=None, y=None, z=None, current_frame=No
2121
2166
)
2122
2167
2123
2168
def updatePanTiltViaTarget (self , pan , tilt , current_frame ):
2124
- DMX_Log .log .info ("Updating pan tilt" )
2169
+ DMX_Log .log .info (( "Updating pan tilt" , pan , tilt ) )
2125
2170
2126
2171
base = self .objects ["Root" ].object
2127
2172
pan = pan + base .rotation_euler [2 ] # take base z rotation into consideration
0 commit comments