Skip to content

Commit

Permalink
Merge pull request #1 from ottorun/pr_1.2.4
Browse files Browse the repository at this point in the history
migration towards VortexWeb 1.2.4
  • Loading branch information
tobymcclean authored Oct 13, 2016
2 parents 7ea5480 + d9e87c3 commit 42a2807
Show file tree
Hide file tree
Showing 14 changed files with 475 additions and 145 deletions.
3 changes: 0 additions & 3 deletions lib/coffez.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// Generated by CoffeeScript 1.10.0

/*
Expand Down Expand Up @@ -404,5 +403,3 @@
module.exports = root.coffez;

}).call(this);

//# sourceMappingURL=coffez.js.map
3 changes: 0 additions & 3 deletions lib/config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// Generated by CoffeeScript 1.10.0

/*
Expand Down Expand Up @@ -44,5 +43,3 @@
module.exports = dds;

}).call(this);

//# sourceMappingURL=config.js.map
26 changes: 21 additions & 5 deletions lib/control-commands.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// Generated by CoffeeScript 1.10.0

/*
Expand All @@ -17,7 +16,7 @@
*/

(function() {
var Close, CloseCmd, CloseDataReader, CloseDataReaderCmd, CloseDataWriter, CloseDataWriterCmd, CommandId, Connect, ConnectCmd, ConnectDataReader, ConnectDataReaderCmd, ConnectDataWriter, ConnectDataWriterCmd, ConnectedDataReaderEvt, ConnectedDataWriterEvt, ConnectedRuntimeEvt, CreateDataReader, CreateDataReaderCmd, CreateDataWriter, CreateDataWriterCmd, CreateEntity, CreateTopic, CreateTopicCmd, CreatedDataReaderEvt, CreatedDataWriterEvt, CreatedTopicEvt, DataAvailableEvt, Disconnect, DisconnectCmd, DisconnectedDataReaderEvt, DisconnectedDataWriterEvt, DisconnectedRuntimeEvt, EntityKind, ErrorEvt, EventHeader, EventId, Header, OnConnectedDataReader, OnConnectedDataWriter, OnConnectedRuntime, OnCreatedDataReader, OnCreatedDataWriter, OnCreatedTopic, OnDataAvailable, OnDisconnectedDataReader, OnDisconnectedDataWriter, OnDisconnectedRuntime, OnError, WriteData, WriteDataCmd, WriteLog, WriteLogCmd, dds;
var Close, CloseCmd, CloseDataReader, CloseDataReaderCmd, CloseDataWriter, CloseDataWriterCmd, CommandId, Connect, ConnectCmd, ConnectDataReader, ConnectDataReaderCmd, ConnectDataWriter, ConnectDataWriterCmd, ConnectedDataReaderEvt, ConnectedDataWriterEvt, ConnectedRuntimeEvt, CreateDataReader, CreateDataReaderCmd, CreateDataWriter, CreateDataWriterCmd, CreateEntity, CreateTopic, CreateTopicCmd, CreatedDataReaderEvt, CreatedDataWriterEvt, CreatedTopicEvt, DataAvailableEvt, Disconnect, DisconnectCmd, DisconnectedDataReaderEvt, DisconnectedDataWriterEvt, DisconnectedRuntimeEvt, DisposeData, DisposeDataCmd, DisposeDataWriter, DisposeDataWriterCmd, EntityKind, ErrorEvt, EventHeader, EventId, Header, OnConnectedDataReader, OnConnectedDataWriter, OnConnectedRuntime, OnCreatedDataReader, OnCreatedDataWriter, OnCreatedTopic, OnDataAvailable, OnDisconnectedDataReader, OnDisconnectedDataWriter, OnDisconnectedRuntime, OnError, WriteData, WriteDataCmd, WriteLog, WriteLogCmd, dds;

dds = {};

Expand All @@ -29,7 +28,8 @@
Disconnect: 4,
Close: 5,
Write: 6,
Log: 7
Log: 7,
Dispose: 8
};

EventId = {
Expand Down Expand Up @@ -114,6 +114,10 @@

CloseDataWriter = CreateEntity(CloseDataWriterCmd);

DisposeDataWriterCmd = Header(CommandId.Dispose, EntityKind.DataWriter);

DisposeDataWriter = CreateEntity(DisposeDataWriterCmd);

dds.ConnectCmd = ConnectCmd;

dds.Connect = Connect;
Expand Down Expand Up @@ -166,6 +170,16 @@
};
};

DisposeDataCmd = Header(CommandId.Dispose, EntityKind.DataWriter);

DisposeData = function(s, id) {
return {
h: DisposeDataCmd,
data: s,
eid: id
};
};

dds.ConnectDataWriterCmd = ConnectDataWriterCmd;

dds.ConnectDataWriter = ConnectDataWriter;
Expand All @@ -174,6 +188,10 @@

dds.WriteData = WriteData;

dds.DisposeDataCmd = DisposeDataCmd;

dds.DisposeData = DisposeData;

ConnectDataReaderCmd = Header(CommandId.Connect, EntityKind.DataWriter);

ConnectDataReader = function(addr, id) {
Expand Down Expand Up @@ -364,5 +382,3 @@
module.exports = dds;

}).call(this);

//# sourceMappingURL=control-commands.js.map
14 changes: 10 additions & 4 deletions lib/control-link.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// Generated by CoffeeScript 1.10.0

/*
Expand Down Expand Up @@ -162,6 +161,7 @@
if (this.connected) {
this.connected = false;
this.ctrlSock.map(function(s) {
console.log("[control-link] closing socket");
return s.close();
});
return this.crtSock = z_._None;
Expand All @@ -170,6 +170,7 @@

ControlLink.prototype.createTopic = function(topic, qos, eid) {
var cmd, scmd;
console.log("[control-link] Creating Topic for eid = " + eid);
cmd = CreateTopicMsg(this.sn, topic);
this.tmap[this.sn] = eid;
this.sn = this.sn + 1;
Expand Down Expand Up @@ -212,6 +213,7 @@
}):
guid = msg.b.eid;
url = Config.runtime.readerPrefixURL(this.server) + '/' + guid;
console.log("[control-link] sn = " + msg.h.sn + ", eid = " + this.drmap[msg.h.sn]);
evt = drt.OnCreatedDataReader(url, this.drmap[msg.h.sn]);
delete this.drmap[msg.h.sn];
return this.emit('postMessage', evt);
Expand All @@ -221,13 +223,15 @@
}):
guid = msg.b.eid;
url = Config.runtime.writerPrefixURL(this.server) + '/' + guid;
console.log("[control-link] sn = " + msg.h.sn + ", eid = " + this.dwmap[msg.h.sn]);
evt = drt.OnCreatedDataWriter(url, this.dwmap[msg.h.sn]);
delete this.dwmap[msg.h.sn];
return this.emit('postMessage', evt);
case !z_.match(msg.h, {
cid: drt.CommandId.OK,
ek: drt.EntityKind.Topic
}):
console.log("[control-link] Topic sn = " + msg.h.sn + " eid = " + this.tmap[msg.h.sn]);
evt = drt.OnCreatedTopic(this.tmap[msg.h.sn]);
delete this.tmap[msg.h.sn];
return this.emit('postMessage', evt);
Expand Down Expand Up @@ -260,19 +264,23 @@
util.inherits(ControlLinkWorker, EventEmitter);

ControlLinkWorker.prototype.postMessage = function(cmd) {
console.log("[control-link] CtrlWorker received cmd: " + JSON.stringify(cmd));
switch (false) {
case !z_.match(cmd.h, drt.ConnectCmd):
console.log("[control-link]: cmd = Connect (" + cmd.url + ")");
return this.ctrlLink.connect(cmd.url, cmd.authToken);
case !z_.match(cmd.h, drt.CreateTopicCmd):
return this.ctrlLink.createTopic(cmd.topic, cmd.qos, cmd.eid);
case !z_.match(cmd.h, drt.CreateDataReaderCmd):
console.log("[control-link] CreateDataReader: " + cmd.eid);
return this.ctrlLink.createDataReader(cmd.topic, cmd.qos, cmd.eid);
case !z_.match(cmd.h, drt.CreateDataWriterCmd):
console.log("[control-link] CreateDataWriter: " + cmd.eid);
return this.ctrlLink.createDataWriter(cmd.topic, cmd.qos, cmd.eid);
case !z_.match(cmd.h, drt.Disconnect):
return this.ctrlLink.disconnect();
default:
return console.log("[control-worker] Worker Received Unknown Command!");
return console.log("[control-link] Worker Received Unknown Command!");
}
};

Expand All @@ -283,5 +291,3 @@
module.exports = ControlLinkWorker;

}).call(this);

//# sourceMappingURL=control-link.js.map
62 changes: 49 additions & 13 deletions lib/dds-runtime.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// Generated by CoffeeScript 1.10.0

/*
Expand Down Expand Up @@ -78,14 +77,13 @@
this.onRcvWorkerMessage = bind(this.onRcvWorkerMessage, this);
this.onSendWorkerMessage = bind(this.onSendWorkerMessage, this);
this.onCtrlWorkerMessage = bind(this.onCtrlWorkerMessage, this);
this.disposeData = bind(this.disposeData, this);
this.writeData = bind(this.writeData, this);
this.sn = 0;
this.eidCount = 0;
this.drmap = {};
this.dwmap = {};
this.tmap = {};
this.connected = false;
this.closed = false;
this.onconnect = function(evt) {
console.log("[dds-runtime]: onconnect");
return this.connected = true;
Expand All @@ -99,6 +97,8 @@
console.log("[dds-runtime]: ondisconnect");
return this.connected = false;
};
this.connected = false;
this.closed = false;
this.needToReEstablishConnections = false;
this.ctrlLink = new ControlLink();
console.log("[dds-runtime]: ctrlLink (" + this.ctrlLink + ")");
Expand Down Expand Up @@ -183,7 +183,7 @@

Runtime.prototype.registerTopic = function(t) {
var ct, eid;
console.log("[[dds-runtime]: Defining topic " + t.tinfo.tname);
console.log("[dds-runtime]: Defining topic " + t.tinfo.tname);
eid = this.generateEntityId();
t.eid = eid;
this.tmap[eid] = t;
Expand All @@ -193,23 +193,49 @@

Runtime.prototype.unregisterTopic = function(t) {};

Runtime.prototype.closeDataReader = function(dr) {};
Runtime.prototype.closeDataReader = function(dr) {
console.log("[dds-runtime]: Cleaning up DR with eid = " + dr.eid);
return delete this.drmap[dr.eid];
};

Runtime.prototype.closeDataWriter = function(dw) {};
Runtime.prototype.closeDataWriter = function(dw) {
console.log("[dds-runtime]: Cleaning up DW with eid = " + dw.eid);
return delete this.dwmap[dw.eid];
};

Runtime.prototype.writeData = function(dw, s) {
var cmd, data, sdata;
data = Array.isArray(s) ? s : [s];
sdata = JSON.stringify(data);
sdata = JSON.stringify(data, function(key, value) {
if (value !== value) {
return 'NaN';
}
return value;
});
cmd = drt.WriteData(sdata, dw.eid);
return this.sendWorker.postMessage(cmd);
};

Runtime.prototype.disposeData = function(dw, s) {
var cmd, data, sdata;
data = Array.isArray(s) ? s : [s];
sdata = JSON.stringify(data, function(key, value) {
if (value !== value) {
return 'NaN';
}
return value;
});
cmd = drt.DisposeData(sdata, dw.eid);
return this.sendWorker.postMessage(cmd);
};

Runtime.prototype.onCtrlWorkerMessage = function(evt) {
var cmd, dr, dw, e, eid, ref, ref1;
e = evt;
switch (false) {
case !z_.match(e.h, drt.ConnectedRuntimeEvt):
this.connected = true;
console.log("[dds-runtime]: Runtime Connected.");
if (this.needToReEstablishConnections) {
console.log("[dds-runtime]: Re-establishing DataReaders and DataWriters connections");
ref = this.dwmap;
Expand All @@ -228,7 +254,7 @@
return this.onconnect(e);
case !z_.match(e.h, drt.DisconnectedRuntimeEvt):
console.log("[dds-runtime]: Runtime Disconnected.");
return this.ondisconnect(e);
return this.disconnect();
case !z_.match(e.h, drt.CreatedTopicEvt):
console.log("[dds-runtime]: Topic created with eid = " + e.eid);
return this.tmap[e.eid].onregistered(e);
Expand All @@ -242,6 +268,8 @@
return this.sendWorker.postMessage(cmd);
case !z_.match(e.h, drt.WriteLogCmd):
return console.log("[dds-runtime]: " + e.kind + "]: " + e.msg);
case !z_.match(e.h.eid, drt.EventId.Error):
return console.log("[dds-runtime]: " + e.h.kind + "]: " + e.msg);
default:
return console.log("[dds-runtime]: Driver received invalid command from CtrlWorker");
}
Expand All @@ -254,7 +282,10 @@
case !z_.match(e.h, drt.ConnectedDataWriterEvt):
return this.dwmap[e.eid].onconnect(e);
case !z_.match(e.h, drt.DisconnectedDataWriterEvt):
return this.dwmap[e.eid].ondisconnect(e);
if (this.dwmap[e.eid]) {
return this.dwmap[e.eid].ondisconnect(e);
}
break;
case !z_.match(e.h, drt.WriteLogCmd):
return console.log("[dds-runtime]: [Log: " + e.kind + "]: " + e.msg);
default:
Expand All @@ -269,9 +300,15 @@
case !z_.match(e.h, drt.ConnectedDataReaderEvt):
return this.drmap[e.eid].onconnect(e);
case !z_.match(e.h, drt.DisconnectedDataReaderEvt):
return this.drmap[e.eid].ondisconnect(e);
if (this.drmap[e.eid]) {
return this.drmap[e.eid].ondisconnect(e);
}
break;
case !z_.match(e.h, drt.DataAvailableEvt):
return this.drmap[e.eid].onDataAvailable(e.data);
if (this.drmap[e.eid]) {
return this.drmap[e.eid].onDataAvailable(e.data);
}
break;
case !z_.match(e.h, drt.WriteLogCmd):
return console.log("[dds-runtime]: [Log: " + e.kind + "]: " + e.msg);
default:
Expand All @@ -296,6 +333,7 @@
this.rcvWorker.postMessage(drt.Disconnect);
this.drmap = {};
this.dwmap = {};
console.log("[dds-runtime]: calling close...");
return this.onclose();
}
};
Expand Down Expand Up @@ -333,5 +371,3 @@
module.exports = dds;

}).call(this);

//# sourceMappingURL=dds-runtime.js.map
Loading

0 comments on commit 42a2807

Please sign in to comment.