aboutsummaryrefslogtreecommitdiff
path: root/src/NeoRuntimeManager/IPC.js
diff options
context:
space:
mode:
authorJakob Stendahl <jakobste@uio.no>2021-10-21 19:28:20 +0200
committerJakob Stendahl <jakobste@uio.no>2021-10-21 19:28:20 +0200
commit6e53fd0dfd830d6d96206419c530c71fa4b3f4e6 (patch)
tree9034a4c9adf3a41c6eb492f2fe6ac06e434275dd /src/NeoRuntimeManager/IPC.js
parentf243dc8d7527cde3d5b5a4f6e659cf7604f5ae2a (diff)
downloadLuxcena-Neo-6e53fd0dfd830d6d96206419c530c71fa4b3f4e6.tar.gz
Luxcena-Neo-6e53fd0dfd830d6d96206419c530c71fa4b3f4e6.zip
:sparkles: Add attempt at the "simulation"
Diffstat (limited to 'src/NeoRuntimeManager/IPC.js')
-rw-r--r--src/NeoRuntimeManager/IPC.js19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/NeoRuntimeManager/IPC.js b/src/NeoRuntimeManager/IPC.js
index 79ce7ea..6428a13 100644
--- a/src/NeoRuntimeManager/IPC.js
+++ b/src/NeoRuntimeManager/IPC.js
@@ -19,7 +19,8 @@ const GLOBVAR = Object.freeze({POWER_ON : 0,
BRIGHTNESS: 1});
/** @type {Object} ENUM-ish for what type of data neoruntime sends */
const DATATYPE = Object.freeze({STATES : 1,
- STRIP_BUF: 2});
+ STRIP_BUF: 2,
+ MATRIX: 3});
/**
* class that will keep a active connection to a socket if possible, and
@@ -66,9 +67,9 @@ class IPC {
this.connected = true;
})
.on('data', (data) => {
+ let json_data;
switch (data[0]) {
case DATATYPE.STATES:
- let json_data;
try {
json_data = JSON.parse(data.toString("ascii", 1));
} catch (e) {
@@ -89,6 +90,20 @@ class IPC {
this.variables = json_data["variables"];
}
break;
+
+ case DATATYPE.MATRIX:
+ try {
+ json_data = JSON.parse(data.toString("ascii", 1));
+ } catch (e) {
+ logger.warning("Could not parse json data from neoruntime");
+ console.log(e);
+ }
+ this.eventEmitter.emit("matrix", json_data);
+ break;
+
+ case DATATYPE.STRIP_BUF:
+ this.eventEmitter.emit("strip_buffer", Array.from(data.values()).slice(1));
+ break;
default:
logger.info(data);