/* SEQUENCE GROUPING MANAGEMENT MODULE this module builds a representation of a sequence in values using containers It allows to create groups of keys, a group being a cue and one key per layer. In a group, all keys sync their time on cue's time, only value can be modified The sequence with grouping can then be exported and reloaded. The module checks periodicaly if timeline sequence structure (cues, layers and keys) and module values structure are in sync. If out of sync, you may either rebuild values structure from sequence or rebuild sequence from values */ var syncRate = 10; var synchronize = false ; var debug = true; var debugFile; var parametersPath = local.parameters ; var sequence ; var sequencePath = local.parameters.sequence ; var file ; var filePath = local.parameters.sequenceFile ; var newGroup = local.values.newGroup ; var groups = local.value.groups ; var cues = local.keys.cues ; var layers = local.keys.layers ; var rebuildValues = script.addTrigger("rebuild values", "adds a key at current cursor position" ); var refreshKeys = script.addTrigger("refresh keys", "truc"); var printKeys = script.addTrigger("printKeys","truc"); var clearSeq = script.addTrigger("clear Sequence","truc"); var sequence_structure = { params: {}, groups:{}, keys:{ cues:{}, layers:{} } }; //WAS tl_groups /*group0 : { inCue : {pan : "key", tilt : "key", zoom : "key", dim : "key", focus : "key"}, outCue : {pan : "key", tilt : "key", zoom : "key", dim : "key", focus : "key"} }*/ ///////////////////// SCRIPT FUNCTIONS ////////////////////////////// function init() { script.log("LOADED SEQUENCE GROUPING MANAGEMENT MODULE "); //adapt update rate updateSyncRate(); //test if a sequence is already choosen else refresh and unlock sequence enum sequence = sequencePath.getKey(); if(sequence == ""){refreshSequenceEnum();} else{sequencePath.setAttribute("readonly", true);} } function scriptParameterChanged(param){ if (param.is(printKeys) ){printKeys();} else if(param.is(rebuildValues)){rebuildValuesStructure();} else if (param.is(refreshKeys)){ script.log("refreshKeys"); refreshKeysList(); } else if (param.is(clearSeq)){seq_clearSequence();} else {script.log("scriptparamchanged" + param.name);} } var syncDelta = 0.; function update(deltaTime){ if(synchronize){ syncDelta += deltaTime ; if (syncDelta > syncRate){ syncDelta = 0. ; // if (debug ){ // // script.log(debugFile.getAbsolutePath()); // debugFile.writeFile(JSON.stringify(sequence_structure), true); // } // refreshKeysList(); struct_buildValuesFromSeq(); } } } /////////////////////////// HELPERS ///////////////////////////////// function printMethodsAndProperties(obj){ script.log(" "); // var name = obj.getControlAddress() == undefined ? "object" : obj.getControlAddress(); var name = "object"; script.log(" METHODS OF " + name); var methods = util.getObjectMethods(obj); for(var i=0 ; i> "+seq[i].name + " " + seq[i].position.get() + " " + seq[i].listSize.get() ); } } else{script.log("nothing to print");} } /////////////////////// PARAMETERS FUNCTIONS /////////////////////// // Module callback function moduleParameterChanged(param){ if (param.is(parametersPath.importExport.sequenceFile)) {} else if (param.is(parametersPath.importExport.loadSequence)){loadSequenceFile();} else if (param.is(parametersPath.importExport.exportSequence)) { exportSequenceFile();} else if (param.is(parametersPath.synchronize)){} else if (param.is(parametersPath.syncRate)){updateSyncRate();} else if (param.is(parametersPath.changeSequence)){refreshSequenceEnum();} else if (param.is(parametersPath.sequence)){ sequence = sequencePath.getKey(); script.log("watching "+ sequence); } else{script.log("received module param :" + param.name);} } function updateSyncRate(){ syncRate = parametersPath.syncRate.get(); script.log("new sync rate : " + syncRate); script.setUpdateRate(syncRate); } //refresh Enum function refreshSequenceEnum(){ script.log("refresh list of sequences"); local.parameters.sequence.setAttribute("readonly",false); if(root.sequences.getItems().length){ local.parameters.sequence.removeOptions(); for(var i=0 ; i