Addingm manual Event fireing, Universe as event property, and event when loading track
This commit is contained in:
parent
218834c175
commit
7a67a0e436
51
lib/index.js
51
lib/index.js
@ -1,5 +1,6 @@
|
||||
//DATABASE
|
||||
"use strict";
|
||||
//DATABASE
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const low = require("lowdb");
|
||||
var db = low("db.json");
|
||||
const sid = require("short-id");
|
||||
@ -9,7 +10,8 @@ db.defaults({}).write();
|
||||
const httpp = require("http");
|
||||
var http = httpp.createServer();
|
||||
const io = require("socket.io");
|
||||
var ioClient = require("socket.io-client")("http://192.168.1.142:5000", { reconect: true });
|
||||
//var ioClient = require("socket.io-client")("http://192.168.1.142:5000", {reconnect:true});
|
||||
var ioClient = require("socket.io-client")("http://localhost:5000", { reconnect: true });
|
||||
ioClient.on("connect", () => {
|
||||
console.log("connected");
|
||||
});
|
||||
@ -105,13 +107,14 @@ class Timecode {
|
||||
else {
|
||||
this.startTime = new Date().getTime() - vlc.time;
|
||||
this.filePlaying = vlc.file;
|
||||
//console.log("vlc_update", vlc);
|
||||
}
|
||||
var d = vlc.time;
|
||||
this.toTrigger.forEach(e => {
|
||||
if (e.time.milliseconds <= d) {
|
||||
console.log("v", e);
|
||||
ios.emit("artnet", e.art);
|
||||
artnet.set(universe, Number(e.art.subnet), Number(e.art.value));
|
||||
artnet.set(e.art.universe, Number(e.art.subnet), Number(e.art.value));
|
||||
var i = this.toTrigger.indexOf(e);
|
||||
this.toTrigger.splice(i, 1);
|
||||
}
|
||||
@ -121,10 +124,10 @@ class Timecode {
|
||||
data.track = this.activeTrack.id;
|
||||
data.filePlaying = this.filePlaying;
|
||||
data.playing = this.playing;
|
||||
data.paused = vlc.paused;
|
||||
ios.emit("update", data);
|
||||
}
|
||||
update() {
|
||||
var d = new Date().getTime() - this.startTime;
|
||||
this.toTrigger.forEach(e => {
|
||||
if (e.time.milliseconds <= d) {
|
||||
console.log("u", e);
|
||||
@ -135,10 +138,18 @@ class Timecode {
|
||||
}
|
||||
});
|
||||
var data = {};
|
||||
var d;
|
||||
if (this.passedTime) {
|
||||
d = this.passedTime;
|
||||
}
|
||||
else {
|
||||
d = new Date().getTime() - this.startTime;
|
||||
}
|
||||
data.time = new FrameTime(d);
|
||||
data.track = this.activeTrack.id;
|
||||
data.filePlaying = this.filePlaying;
|
||||
data.playing = this.playing;
|
||||
data.paused = this.passedTime !== undefined ? true : false;
|
||||
ios.emit("update", data);
|
||||
}
|
||||
loadTrack(trackid) {
|
||||
@ -156,8 +167,22 @@ class Timecode {
|
||||
this.toTrigger = tr;
|
||||
this.filePlaying = track.file;
|
||||
this.startTime = 0;
|
||||
if (this.activeTrack.load) {
|
||||
artnet(this.activeTrack.load.universe, this.activeTrack.load.subnet, this.activeTrack.load.value);
|
||||
}
|
||||
}
|
||||
pause() {
|
||||
this.passedTime = new Date().getTime() - this.startTime;
|
||||
}
|
||||
play() {
|
||||
if (this.passedTime) {
|
||||
this.startTime = new Date().getTime() - this.passedTime;
|
||||
if (this.filePlaying) {
|
||||
}
|
||||
else {
|
||||
}
|
||||
this.passedTime = undefined;
|
||||
}
|
||||
if (!this.activeTrack)
|
||||
return;
|
||||
if (this.filePlaying) {
|
||||
@ -222,6 +247,14 @@ ios.on("connection", socket => {
|
||||
}
|
||||
timecode.play();
|
||||
});
|
||||
socket.on("pause", () => {
|
||||
if (timecode.filePlaying) {
|
||||
ioClient.emit("pause");
|
||||
}
|
||||
else {
|
||||
timecode.pause();
|
||||
}
|
||||
});
|
||||
socket.on("stop", () => {
|
||||
timecode.stop();
|
||||
if (timecode.activeTrack)
|
||||
@ -262,6 +295,16 @@ ios.on("connection", socket => {
|
||||
db.get(data.track + ".triggers").remove({ id: data.id }).write();
|
||||
senddata();
|
||||
});
|
||||
socket.on("fire", (data) => {
|
||||
artnet.set(data.universe, data.subnet, data.value);
|
||||
});
|
||||
socket.on("load_event", (data) => {
|
||||
console.log(data);
|
||||
db.get(data.id).assign({
|
||||
load: data.art
|
||||
}).write();
|
||||
senddata();
|
||||
});
|
||||
});
|
||||
http.listen(5001);
|
||||
//# sourceMappingURL=index.js.map
|
File diff suppressed because one or more lines are too long
61
src/index.ts
61
src/index.ts
@ -10,7 +10,8 @@ db.defaults({}).write();
|
||||
import * as httpp from "http";
|
||||
var http = httpp.createServer();
|
||||
import io = require("socket.io");
|
||||
var ioClient = require("socket.io-client")("http://192.168.1.142:5000", {reconect:true});
|
||||
//var ioClient = require("socket.io-client")("http://192.168.1.142:5000", {reconnect:true});
|
||||
var ioClient = require("socket.io-client")("http://localhost:5000", {reconnect:true});
|
||||
ioClient.on("connect", ()=>{
|
||||
console.log("connected");
|
||||
});
|
||||
@ -18,7 +19,7 @@ var ios = io(http);
|
||||
const artnetp = require("artnet");
|
||||
const universe = 21;
|
||||
var artnet = artnetp({host:"192.168.1.255"});
|
||||
function reset(){
|
||||
function reset(){ //ToDO nachfragen bei Marvin / Alex
|
||||
for(var i = 1; i <= 512; i++){
|
||||
artnet.set(universe, i, 0);
|
||||
}
|
||||
@ -116,6 +117,7 @@ class Timecode {
|
||||
filePlaying:string;
|
||||
startTime:number;
|
||||
toTrigger:Array<TrackEvent>;
|
||||
passedTime:number;
|
||||
|
||||
vlcUpdate(vlc:VlcUpdate) {
|
||||
if(!vlc.is_playing){
|
||||
@ -131,7 +133,7 @@ class Timecode {
|
||||
if(e.time.milliseconds <= d) {
|
||||
console.log("v",e);
|
||||
ios.emit("artnet", e.art);
|
||||
artnet.set(universe, Number(e.art.subnet), Number(e.art.value));
|
||||
artnet.set(e.art.universe, Number(e.art.subnet), Number(e.art.value));
|
||||
var i = this.toTrigger.indexOf(e);
|
||||
this.toTrigger.splice(i, 1);
|
||||
}
|
||||
@ -141,11 +143,11 @@ class Timecode {
|
||||
data.track = this.activeTrack.id;
|
||||
data.filePlaying = this.filePlaying;
|
||||
data.playing = this.playing;
|
||||
data.paused = vlc.paused;
|
||||
ios.emit("update", data);
|
||||
}
|
||||
|
||||
update() {
|
||||
var d = new Date().getTime() - this.startTime;
|
||||
this.toTrigger.forEach(e=>{
|
||||
if(e.time.milliseconds <= d) {
|
||||
console.log("u", e);
|
||||
@ -156,10 +158,17 @@ class Timecode {
|
||||
}
|
||||
});
|
||||
var data:any = {};
|
||||
var d:number;
|
||||
if(this.passedTime){
|
||||
d = this.passedTime;
|
||||
} else {
|
||||
d = new Date().getTime() - this.startTime;
|
||||
}
|
||||
data.time = new FrameTime(d);
|
||||
data.track = this.activeTrack.id;
|
||||
data.filePlaying = this.filePlaying;
|
||||
data.playing = this.playing;
|
||||
data.paused = this.passedTime !== undefined ? true : false;
|
||||
ios.emit("update", data);
|
||||
}
|
||||
|
||||
@ -178,9 +187,25 @@ class Timecode {
|
||||
this.toTrigger = tr;
|
||||
this.filePlaying = track.file;
|
||||
this.startTime = 0;
|
||||
if(this.activeTrack.load){
|
||||
artnet(this.activeTrack.load.universe, this.activeTrack.load.subnet, this.activeTrack.load.value)
|
||||
}
|
||||
}
|
||||
|
||||
pause() {
|
||||
this.passedTime = new Date().getTime() - this.startTime;
|
||||
}
|
||||
|
||||
play() {
|
||||
if(this.passedTime){
|
||||
this.startTime = new Date().getTime() - this.passedTime;
|
||||
if(this.filePlaying){
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
this.passedTime = undefined;
|
||||
}
|
||||
if(!this.activeTrack)return;
|
||||
if(this.filePlaying){
|
||||
ioClient.emit("play", {file:this.filePlaying});
|
||||
@ -221,7 +246,8 @@ class TrackEvent {
|
||||
id:string;
|
||||
art: {
|
||||
subnet:number,
|
||||
value:number
|
||||
value:number,
|
||||
universe:number
|
||||
}
|
||||
time:FrameTime;
|
||||
}
|
||||
@ -231,12 +257,18 @@ class Track {
|
||||
displayName:string;
|
||||
triggers:Array<TrackEvent>;
|
||||
file:string;
|
||||
load: {
|
||||
subnet:number,
|
||||
value:number,
|
||||
universe:number
|
||||
}
|
||||
}
|
||||
|
||||
interface VlcUpdate {
|
||||
file:string,
|
||||
time:number,
|
||||
is_playing:boolean;
|
||||
paused:boolean;
|
||||
}
|
||||
|
||||
var timecode = new Timecode();
|
||||
@ -264,6 +296,13 @@ ios.on("connection", socket=>{
|
||||
}
|
||||
timecode.play();
|
||||
});
|
||||
socket.on("pause", ()=>{
|
||||
if(timecode.filePlaying){
|
||||
ioClient.emit("pause");
|
||||
} else {
|
||||
timecode.pause();
|
||||
}
|
||||
});
|
||||
socket.on("stop", ()=>{
|
||||
timecode.stop();
|
||||
if(timecode.activeTrack)
|
||||
@ -305,6 +344,18 @@ ios.on("connection", socket=>{
|
||||
db.get(data.track + ".triggers").remove({id:data.id}).write();
|
||||
senddata();
|
||||
});
|
||||
|
||||
socket.on("fire", (data)=>{
|
||||
artnet.set(data.universe, data.subnet, data.value);
|
||||
});
|
||||
|
||||
socket.on("load_event", (data)=>{
|
||||
console.log(data);
|
||||
db.get(data.id).assign({
|
||||
load:data.art
|
||||
}).write();
|
||||
senddata();
|
||||
});
|
||||
});
|
||||
|
||||
http.listen(5001);
|
||||
|
@ -10,9 +10,6 @@
|
||||
"node_modules/@types"
|
||||
]
|
||||
},
|
||||
"files": [
|
||||
"src/custom.d.ts"
|
||||
],
|
||||
"exclude": [
|
||||
"node_modules"
|
||||
],"include": [
|
||||
|
@ -14,6 +14,7 @@
|
||||
<div>
|
||||
<button onclick="stopSequence()">Stop</button>
|
||||
<button onclick="startSequence()" id="playbutton">Play</button>
|
||||
<button onclick="pauseSequence()" id="pausebutton" style="display:none;">Pause</button>
|
||||
<label >Loaded: </label>
|
||||
<label id="loaded"></label>
|
||||
<label >File playing: </label>
|
||||
@ -35,6 +36,12 @@
|
||||
<center><h2 id="trackname"></h1></center>
|
||||
<center><h2 id="trackfile"></h2></center>
|
||||
<button onclick="loadSequence()">Load</button>
|
||||
<form onsubmit="f()">
|
||||
<input type="text" id="universe" placeholder="universe"></input>
|
||||
<input type="text" id="channel" placeholder="channel"></input>
|
||||
<input type="text" id="value" placeholder="value"></input>
|
||||
<button onclick="saveLoad()">speichern</button>
|
||||
</form>
|
||||
<div>
|
||||
<canvas id="canvas" height="50">
|
||||
</canvas>
|
||||
@ -47,6 +54,7 @@
|
||||
<input type="text" id="em" placeholder="minute"/>
|
||||
<input type="text" id="es" placeholder="second"/>
|
||||
<input type="text" id="ef" placeholder="frame"/>
|
||||
<input type="text" id="eu" placeholder="universe"/>
|
||||
<input type="text" id="esu" placeholder="channel"/>
|
||||
<input type="text" id="eval" placeholder="value"/>
|
||||
<button onclick="saveEvent()">Speichern</button>
|
||||
@ -98,6 +106,11 @@
|
||||
$("#fplay").html(data.filePlaying);
|
||||
if(data.playing){
|
||||
$("#playbutton").css("color", "greenyellow");
|
||||
if(data.paused) {
|
||||
$("#pausebutton").css("display", "none");
|
||||
} else {
|
||||
$("#pausebutton").css("display", "inline-block");
|
||||
}
|
||||
} else {
|
||||
$("#playbutton").css("color", "white");
|
||||
}
|
||||
@ -138,9 +151,14 @@
|
||||
$("#trdv").css("display","none");
|
||||
return;
|
||||
}
|
||||
if(selected.load){
|
||||
$("#universe").val(selected.load.universe);
|
||||
$("#channel").val(selected.load.subnet);
|
||||
$("#value").val(selected.load.value);
|
||||
}
|
||||
$("#trackname").html(selected.displayName);
|
||||
$("#trackfile").html(selected.file !==undefined ? selected.file : "");
|
||||
var t = "<tr><th>ID</th><th>Stunde</th><th>Minute</th><th>Sekunde</th><th>Frame</th><th>ArtNet-Kanal</th><th>Art-Net Value</th><th>Copy</th><th>Edit</th><th>Del</th></tr>";
|
||||
var t = "<tr><th>ID</th><th>Stunde</th><th>Minute</th><th>Sekunde</th><th>Frame</th><th>Universe</th><th>ArtNet-Kanal</th><th>Art-Net Value</th><th>Run</th><th>Copy</th><th>Edit</th><th>Del</th></tr>";
|
||||
var sorted = selected.triggers.sort((a, b)=>{
|
||||
if(a.time.lmilliseconds < b.time.lmilliseconds) return -1;
|
||||
if(a.time.lmilliseconds > b.time.lmilliseconds) return 1;
|
||||
@ -153,8 +171,10 @@
|
||||
t += "<td>" + e.time.lminutes + "</td>"
|
||||
t += "<td>" + e.time.lseconds + "</td>"
|
||||
t += "<td>" + e.time.lframe + "</td>"
|
||||
t += "<td>" + e.art.universe + "</td>"
|
||||
t += "<td>" + e.art.subnet + "</td>"
|
||||
t += "<td>" + e.art.value + "</td>"
|
||||
t += "<td><button onclick='fire(\"" + e.id + "\")'><i class='fa fa-play' aria-hidden='true'></i></button></td>"
|
||||
t += "<td><button onclick='copy(\"" + e.id + "\")'><i class='fa fa-clone' aria-hidden='true'></i></button></td>"
|
||||
t += "<td><button onclick='edit(\"" + e.id + "\")'><i class='fa fa-pencil-square-o' aria-hidden='true'></i></button></td>"
|
||||
t += "<td><button onclick='remove(\"" + e.id + "\")'><i class='fa fa-trash-o' aria-hidden='true'></i></button></td>"
|
||||
@ -177,6 +197,7 @@
|
||||
$("#em").val(el.time.lminutes);
|
||||
$("#es").val(el.time.lseconds);
|
||||
$("#ef").val(el.time.lframe);
|
||||
$("#eu").val(el.art.universe);
|
||||
$("#esu").val(el.art.subnet);
|
||||
$("#eval").val(el.art.value);
|
||||
}
|
||||
@ -194,6 +215,7 @@
|
||||
$("#em").val(el.time.lminutes);
|
||||
$("#es").val(el.time.lseconds);
|
||||
$("#ef").val(el.time.lframe);
|
||||
$("#eu").val(el.art.universe);
|
||||
$("#esu").val(el.art.subnet);
|
||||
$("#eval").val(el.art.value);
|
||||
}
|
||||
@ -201,7 +223,13 @@
|
||||
function remove(id) {
|
||||
socket.emit("delete", {track:selected.id, id:id})
|
||||
console.log("remove with id", id)
|
||||
//throw new Error("not implemented");
|
||||
}
|
||||
|
||||
function fire(id){
|
||||
if(!selected) return;
|
||||
selected.triggers.forEach(e=>{
|
||||
if(e.id == id) socket.emit("fire", e.art);
|
||||
});
|
||||
}
|
||||
|
||||
function saveEvent() {
|
||||
@ -214,6 +242,7 @@
|
||||
el.time.seconds = $("#es").val();
|
||||
el.time.frame = $("#ef").val();
|
||||
el.art = {};
|
||||
el.art.universe = $("#eu").val();
|
||||
el.art.subnet = $("#esu").val();
|
||||
el.art.value = $("#eval").val();
|
||||
socket.emit("set", el);
|
||||
@ -222,6 +251,7 @@
|
||||
$("#em").val("");
|
||||
$("#es").val("");
|
||||
$("#ef").val("");
|
||||
$("#eu").val("");
|
||||
$("#esu").val("");
|
||||
$("#eval").val("");
|
||||
}
|
||||
@ -238,6 +268,10 @@
|
||||
socket.emit("stop");
|
||||
}
|
||||
|
||||
function pauseSequence(){
|
||||
socket.emit("pause");
|
||||
}
|
||||
|
||||
$(document).keyup(function(e) {
|
||||
if (e.keyCode === 27) {
|
||||
$("#eid").val("");
|
||||
@ -245,10 +279,22 @@
|
||||
$("#em").val("");
|
||||
$("#es").val("");
|
||||
$("#ef").val("");
|
||||
$("#eu").val("");
|
||||
$("#esu").val("");
|
||||
$("#eval").val("");
|
||||
} // esc
|
||||
}
|
||||
});
|
||||
|
||||
function saveLoad(){
|
||||
var data = {};
|
||||
data.id = selected.id;
|
||||
data.art = {};
|
||||
data.art.universe = $("#universe").val();
|
||||
data.art.subnet = $("#channel").val();
|
||||
data.art.value = $("#value").val();
|
||||
console.log(data);
|
||||
socket.emit("event", data);
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
Loading…
Reference in New Issue
Block a user