Commit e5705510 authored by Claes Sjofors's avatar Claes Sjofors

Merge branch 'master'

parents d79e489a 673feb15
include $(pwre_dir_symbols)
-include $(pwre_kroot)/tools/bld/src/$(type_name)_generic.mk
exe : $(doc_dir)/sv_se/orm/pwr_basecomponentclasses_h.html \
$(doc_dir)/en_us/orm/pwr_basecomponentclasses_h.html \
$(doc_dir)/sv_se/orm/pwr_basecomponentclasses_hpp.html \
$(doc_dir)/en_us/orm/pwr_basecomponentclasses_hpp.html
$(doc_dir)/sv_se/orm/pwr_basecomponentclasses_h.html : $(inc_dir)/pwr_basecomponentclasses.h
@ echo "Generating html files for struct sv_se..."
@ $(co_convert) -c -d $(doc_dir)/sv_se/orm "$(source)"
$(doc_dir)/en_us/orm/pwr_basecomponentclasses_h.html : $(inc_dir)/pwr_basecomponentclasses.h
@ echo "Generating html files for struct en_us..."
@ $(co_convert) -c -d $(doc_dir)/en_us/orm "$(source)"
$(doc_dir)/sv_se/orm/pwr_basecomponentclasses_hpp.html : $(inc_dir)/pwr_basecomponentclasses.hpp
@ echo "Generating html files for struct sv_se..."
@ $(co_convert) -c -d $(doc_dir)/sv_se/orm "$(source)"
$(doc_dir)/en_us/orm/pwr_basecomponentclasses_hpp.html : $(inc_dir)/pwr_basecomponentclasses.hpp
@ echo "Generating html files for struct en_us..."
@ $(co_convert) -c -d $(doc_dir)/en_us/orm "$(source)"
......@@ -222,36 +222,6 @@ enum Msg {
GET_OBJECT_FROM_AREF
}
class Uint8ArrayHelper {
buf: Uint8Array;
idx: number;
constructor(size, tag) {
this.buf = new Uint8Array(size);
this.buf[0] = tag;
this.idx = 2;
}
pack16Bit(value) {
this.buf[this.idx++] = value & 0xFF;
this.buf[this.idx++] = (value >> 8) & 0xFF;
}
pack32Bit(value) {
this.buf[this.idx++] = value & 0xFF;
this.buf[this.idx++] = (value >> 8) & 0xFF;
this.buf[this.idx++] = (value >> 16) & 0xFF;
this.buf[this.idx++] = (value >> 24) & 0xFF;
}
packString(string) {
this.pack16Bit(string.length);
for (let i = 0; i < string.length; i++) {
this.buf[this.idx++] = string.charCodeAt(i);
}
}
}
class DataViewHelper {
dv: DataView;
offset = 0;
......@@ -296,21 +266,19 @@ class DataViewHelper {
}
class Gdh {
debug = false;
pending: Array = [];
sub: Array<Sub> = [];
static PORT = 4448;
ws: WebSocket = null;
return_cb: () => void = null;
next_id = 1234;
subscriptionCount = 1;
listSent = false;
pending = [];
constructor(open_cb, close_cb = null) {
if (window.location.hostname === "") {
this.ws = new WebSocket("ws:127.0.0.1:4448");
this.ws = new WebSocket("ws:127.0.0.1:" + String(Gdh.PORT));
} else {
this.ws = new WebSocket("ws://" + window.location.hostname + ":4448");
this.ws = new WebSocket("ws://" + window.location.hostname + ":" + String(Gdh.PORT));
}
this.ws.binaryType = "arraybuffer";
......@@ -321,217 +289,50 @@ class Gdh {
};
this.ws.onclose = function () {
if (this.debug) {
console.log("Socket closed");
}
if (close_cb !== null) {
close_cb();
}
};
this.ws.onmessage = function (e) {
if (typeof e.data === "string") {
console.log("String message received", e, e.data);
} else {
if (e.data instanceof ArrayBuffer) {
let dv = new DataViewHelper(e.data);
let type = dv.getUint8();
let id = dv.getUint32();
let resolve = this.pending[id];
if (type === Msg.GET_OBJECT_REF_INFO_ALL) {
resolve(new DataViewHelper(e.data));
delete this.pending[id];
} else {
let sts = dv.getUint32();
let value = this.unpackType(dv, sts, type);
resolve({
"sts": sts,
"value": value
});
delete this.pending[id];
}
};
}
unpackType(dv, sts, type) {
switch (type) {
case Msg.GET_OBJECT_INFO_BOOLEAN:
if (this.gdh.debug) {
console.log("GetObjectInfoBoolean received");
}
let value = dv.getUint8();
let func_cb = this.gdh.pending[id].func_cb;
func_cb(id, sts, value);
delete this.gdh.pending[id];
break;
return dv.getUint8();
case Msg.GET_OBJECT_INFO_INT:
if (this.gdh.debug) {
console.log("GetObjectInfoInt received");
}
let value = dv.getUint32();
let pending_data = this.gdh.pending[id];
pending_data.func_cb(id, pending_data.data, sts, value);
delete this.gdh.pending[id];
break;
return dv.getUint32();
case Msg.GET_OBJECT_INFO_FLOAT:
if (this.gdh.debug) {
console.log("GetObjectInfoFloat received");
}
let value = dv.getFloat32();
let pending_data = this.gdh.pending[id];
pending_data.func_cb(id, pending_data.data, sts, value);
delete this.gdh.pending[id];
break;
return dv.getFloat32();
case Msg.GET_OBJECT_INFO_FLOAT_ARRAY:
if (this.gdh.debug) {
console.log("GetObjectInfoFloatArray received");
}
let asize = dv.getInt32();
let value = new Array(asize);
for (let i = 0; i < asize; i++) {
value[i] = dv.getFloat32();
}
let pending_data = this.gdh.pending[id];
pending_data.func_cb(id, pending_data.data, sts, value);
delete this.gdh.pending[id];
break;
case Msg.SET_OBJECT_INFO_BOOLEAN:
if (this.gdh.debug) {
console.log("SetObjectInfoBoolean received", id, sts);
}
break;
case Msg.SET_OBJECT_INFO_INT:
if (this.gdh.debug) {
console.log("SetObjectInfoInt received", id, sts);
}
break;
case Msg.SET_OBJECT_INFO_FLOAT:
if (this.gdh.debug) {
console.log("SetObjectInfoFloat received", id, sts);
}
break;
case Msg.SET_OBJECT_INFO_STRING:
if (this.gdh.debug) {
console.log("SetObjectInfoString received", id, sts);
}
break;
case Msg.TOGGLE_OBJECT_INFO:
if (this.gdh.debug) {
console.log("ToggleObjectInfo received", id, sts);
}
break;
case Msg.REF_OBJECT_INFO:
if (this.gdh.debug) {
console.log("RefObjectInfo received", id, sts);
}
delete this.gdh.pending[id];
break;
case Msg.UNREF_OBJECT_INFO:
if (this.gdh.debug) {
console.log("UnrefObjectInfo received", id, sts);
}
delete this.gdh.pending[id];
break;
case Msg.REF_OBJECT_INFO_LIST:
if (this.gdh.debug) {
console.log("RefObjectInfoList received", id, sts);
}
let func_cb = this.gdh.pending[id].func_cb;
func_cb(id, sts);
delete this.gdh.pending[id];
break;
case Msg.GET_OBJECT_REF_INFO_ALL:
let size = dv.getUint32();
if (this.gdh.debug) {
console.log("GetObjectRefInfoAll received", id, size);
}
for (let i = 0; i < size; i++) {
let eid = dv.getUint32();
let esize = dv.getUint32();
let sub = this.gdh.sub[eid];
if (typeof sub !== 'undefined') {
let value;
switch (sub.type) {
case Type.Boolean:
if (sub.elements <= 1) {
value = dv.getUint8();
} else {
let elements = esize;
if (elements !== sub.elements) {
console.log("Subscription size error", elements,
sub.elements, eid);
}
value = new Array(elements);
for (let k = 0; k < elements; k++) {
value[k] = dv.getUint8();
}
}
break;
case Type.Float32:
if (sub.elements <= 1) {
value = dv.getFloat32();
} else {
let elements = esize / 4;
if (elements !== sub.elements) {
console.log("Subscription size error", elements,
sub.elements, eid);
}
value = new Array(elements);
for (let k = 0; k < elements; k++) {
value[k] = dv.getFloat32();
}
}
break;
case Type.Int8:
case Type.Int16:
case Type.Int32:
case Type.UInt8:
case Type.UInt16:
case Type.UInt32:
case Type.Status:
case Type.NetStatus:
case Type.Mask:
case Type.Enum:
case Type.Bit:
if (sub.elements <= 1) {
value = dv.getInt32();
} else {
let elements = esize / 4;
if (elements !== sub.elements) {
console.log("Subscription size error", elements,
sub.elements, eid);
}
value = new Array(elements);
for (let k = 0; k < elements; k++) {
value[k] = dv.getInt32();
}
}
break;
case Type.String:
case Type.Time:
case Type.DeltaTime:
case Type.AttrRef:
case Type.Objid:
if (sub.elements <= 1) {
value = dv.getString();
} else {
let elements = sub.elements;
if (elements !== sub.elements) {
console.log("Subscription size error", elements,
sub.elements, eid);
}
value = new Array(elements);
for (let l = 0; l < elements; l++) {
value[l] = dv.getString();
}
}
break;
default:
break;
}
this.gdh.sub[eid].value = value;
}
}
if (typeof this.gdh.pending[id] === 'undefined') {
console.log("** GetObjectRefInfoAll received removed", id);
break;
}
let func_cb = this.gdh.pending[id].func_cb;
func_cb(id, sts);
delete this.gdh.pending[id];
break;
return value;
case Msg.GET_ALL_XTT_CHILDREN:
let result = [];
let size = dv.getUint32();
if (this.gdh.debug) {
console.log("GetAllXttChildren received", id, size);
}
console.log("GetAllXttChildren received", sts, id, size);
for (let i = 0; i < size; i++) {
let info = new ObjectInfo();
let vid = dv.getUint32();
......@@ -544,16 +345,10 @@ class Gdh {
info.classname = dv.getString();
result.push(info);
}
let pending_data = this.gdh.pending[id];
pending_data.func_cb(id, pending_data.data, sts, result);
delete this.gdh.pending[id];
break;
return result;
case Msg.GET_ALL_CLASS_ATTRIBUTES:
let result = [];
let size = dv.getUint32();
if (this.gdh.debug) {
console.log("GetAllClassAttributes received", id, size);
}
for (let i = 0; i < size; i++) {
let info = new AttributeInfo();
info.type = dv.getUint32();
......@@ -564,16 +359,10 @@ class Gdh {
info.classname = dv.getString();
result.push(info);
}
let pending_data = this.gdh.pending[id];
pending_data.func_cb(id, pending_data.data, sts, result);
delete this.gdh.pending[id];
break;
return result;
case Msg.GET_OBJECT:
case Msg.GET_OBJECT_FROM_AREF:
case Msg.GET_OBJECT_FROM_NAME:
if (this.gdh.debug) {
console.log("GetObject received", id, sts);
}
let info = null;
if (odd(sts)) {
info = new ObjectInfo();
......@@ -588,18 +377,12 @@ class Gdh {
info.description = dv.getString();
info.param1 = dv.getString();
}
let pending_data = this.gdh.pending[id];
pending_data.func_cb(id, pending_data.data, sts, info);
delete this.gdh.pending[id];
break;
return info;
case Msg.CRR_SIGNAL:
let crrtext = null;
let result = [];
if (odd(sts)) {
let size = dv.getUint16();
if (this.gdh.debug) {
console.log("CrrSignal received", id, size);
}
for (let i = 0; i < size; i++) {
let info = new CrrInfo();
info.type = dv.getUint16();
......@@ -611,16 +394,9 @@ class Gdh {
result.push(info);
}
}
let pending_data = this.gdh.pending[id];
pending_data.func_cb(id, pending_data.data, sts, result);
delete this.gdh.pending[id];
break;
return result;
case Msg.GET_OPWIND_MENU:
let result = new OpwindMenuInfo();
if (this.gdh.debug) {
console.log("GetOpwindMenu received", id);
}
console.log("GetOpwindMenu received", sts, id);
if (odd(sts)) {
result.title = dv.getString();
......@@ -646,39 +422,22 @@ class Gdh {
result.buttons.push(button);
}
}
let pending_data = this.gdh.pending[id];
pending_data.func_cb(id, pending_data.data, sts, result);
delete this.gdh.pending[id];
break;
return result;
case Msg.CHECK_USER:
if (this.gdh.debug) {
console.log("Check user received", id);
}
console.log("Check user received", sts, id);
let priv = 0;
if (odd(sts)) {
priv = dv.getUint32();
}
let pending_data = this.gdh.pending[id];
pending_data.func_cb(id, pending_data.data, sts, priv);
delete this.gdh.pending[id];
break;
return priv;
case Msg.GET_MSG:
let msg = "";
if (odd(sts)) {
msg = dv.getString();
}
let pending_data = this.gdh.pending[id];
pending_data.func_cb(id, pending_data.data, sts, msg);
delete this.gdh.pending[id];
break;
return msg;
case Msg.MH_SYNC:
let result = [];
let size = dv.getUint32();
if (this.gdh.debug) {
console.log("MhSync received", id, size);
}
for (let i = 0; i < size; i++) {
let e = new MhEvent();
e.eventTime = dv.getString();
......@@ -723,66 +482,66 @@ class Gdh {
e.syncIdx = dv.getUint32();
result.push(e);
}
let pending_data = this.gdh.pending[id];
pending_data.func_cb(id, pending_data.data, sts, result);
delete this.gdh.pending[id];
break;
case Msg.MH_ACK:
let pending_data = this.gdh.pending[id];
pending_data.func_cb(id, pending_data.data, sts);
delete this.gdh.pending[id];
break;
return result;
default:
console.log("Unknown message type");
}
return null;
}
}
Uint8ArrayHelper(tag) {
let obj = {
buf: [tag, 0],
pack16Bit: function(value) {
this.buf.push(value & 0xFF);
this.buf.push((value >> 8) & 0xFF);
},
pack32Bit: function(value) {
this.buf.push(value & 0xFF);
this.buf.push((value >> 8) & 0xFF);
this.buf.push((value >> 16) & 0xFF);
this.buf.push((value >> 24) & 0xFF);
},
packString: function(string) {
this.pack16Bit(string.length);
for (let i = 0; i < string.length; i++) {
this.buf.push(string.charCodeAt(i));
}
}
};
obj.pack32Bit(this.next_id);
return obj;
}
getObjectInfoBoolean(name, return_cb) {
this.return_cb = return_cb;
let helper = new Uint8ArrayHelper(name.length + 6, Msg.GET_OBJECT_INFO_BOOLEAN);
helper.pack32Bit(this.next_id);
getObjectInfoBoolean(name) {
let helper = this.Uint8ArrayHelper(Msg.GET_OBJECT_INFO_BOOLEAN);
helper.packString(name);
this.pending[this.next_id] = new PendingData(return_cb, null);
this.ws.send(helper.buf);
this.next_id++;
return this.sendRequest(helper);
}
getObjectInfoInt(name, return_cb, data) {
this.return_cb = return_cb;
let helper = new Uint8ArrayHelper(name.length + 6, Msg.GET_OBJECT_INFO_INT);
helper.pack32Bit(this.next_id);
getObjectInfoInt(name) {
let helper = this.Uint8ArrayHelper(Msg.GET_OBJECT_INFO_INT);
helper.packString(name);
this.pending[this.next_id] = new PendingData(return_cb, data);
this.ws.send(helper.buf);
this.next_id++;
return this.sendRequest(helper);
}
getObjectInfoFloat(name, return_cb, data) {
this.return_cb = return_cb;
let helper = new Uint8ArrayHelper(name.length + 6, Msg.GET_OBJECT_INFO_FLOAT);
helper.pack32Bit(this.next_id);
getObjectInfoIntArray(name, asize) {
let helper = this.Uint8ArrayHelper(Msg.GET_OBJECT_INFO_INT_ARRAY);
helper.pack32Bit(asize);
helper.packString(name);
this.pending[this.next_id] = new PendingData(return_cb, data);
this.ws.send(helper.buf);
this.next_id++;
return this.sendRequest(helper);
}
getObjectInfoFloatArray(name, asize, return_cb, data) {
this.return_cb = return_cb;
getObjectInfoFloat(name) {
let helper = this.Uint8ArrayHelper(Msg.GET_OBJECT_INFO_FLOAT);
helper.packString(name);
return this.sendRequest(helper);
}
let helper = new Uint8ArrayHelper(name.length + 10, Msg.GET_OBJECT_INFO_FLOAT_ARRAY);
helper.pack32Bit(this.next_id);
getObjectInfoFloatArray(name, asize) {
let helper = this.Uint8ArrayHelper(Msg.GET_OBJECT_INFO_FLOAT_ARRAY);
helper.pack32Bit(asize);
helper.packString(name);
this.pending[this.next_id] = new PendingData(return_cb, data);
this.ws.send(helper.buf);
this.next_id++;
return this.sendRequest(helper);
}
refObjectInfo(name, type, elements) {
......@@ -794,248 +553,227 @@ class Gdh {
this.sub[this.subscriptionCount] = sub;
this.subscriptionCount++;
if (this.listSent) {
let size = 12 + sub.name.length;
let helper = new Uint8ArrayHelper(size + 10, Msg.REF_OBJECT_INFO);
helper.pack32Bit(this.next_id);
if (this.debug) {
console.log("RefObjectInfo: ", sub.refid);
}
let helper = this.Uint8ArrayHelper(Msg.REF_OBJECT_INFO);
helper.pack32Bit(sub.refid);
helper.pack32Bit(sub.elements);
helper.packString(sub.name);
this.pending[this.next_id] =
new PendingData(this.refObjectInfoReply, null);
if (this.debug) {
console.log("Sending RefObjectInfo", this.next_id, size);
}
this.ws.send(helper.buf);
this.next_id++;
}
return sub.refid;
}
refObjectInfoReply(id, sts) {
if (this.debug) {
console.log("refObjectInfoReply", id, sts);
}
}
unrefObjectInfo(refid) {
let size = 4;
let helper = new Uint8ArrayHelper(size + 10, Msg.UNREF_OBJECT_INFO);
helper.pack32Bit(this.next_id);
if (this.debug) {
console.log("UnrefObjectInfo: ", refid);
}
let helper = this.Uint8ArrayHelper(Msg.UNREF_OBJECT_INFO);
helper.pack32Bit(refid);
this.pending[this.next_id] =
new PendingData(this.unrefObjectInfoReply, null);
if (this.debug) {
console.log("Sending UnrefObjectInfo", this.next_id, size, refid);
}
this.ws.send(helper.buf);
this.next_id++;
delete this.sub[refid];
return this.sendRequest(helper);
}
unrefObjectInfoReply(id, sts) {
if (this.debug) {
console.log("unrefObjectInfoReply", id, sts);
}
}
refObjectInfoList(return_cb) {
refObjectInfoList() {
let size = 0;
let len = 0;
this.return_cb = return_cb;
for (let i in this.sub) {
size += 12 + this.sub[i].name.length;
len++;
}
let helper = new Uint8ArrayHelper(size + 10, Msg.REF_OBJECT_INFO_LIST);
helper.pack32Bit(this.next_id);
let helper = this.Uint8ArrayHelper(Msg.REF_OBJECT_INFO_LIST);
helper.pack32Bit(len);
this.sub.slice(1).forEach(function (s) {
if (this.debug) {
console.log("RefObjectInfoList: ", s.refid);
}
helper.pack32Bit(s.refid);
helper.pack32Bit(s.elements);
helper.packString(s.name);
});
this.pending[this.next_id] = new PendingData(return_cb, null);
if (this.debug) {
console.log("Sending RefObjectInfoList", this.next_id, size, this.next_id);
}
this.ws.send(helper.buf);
this.next_id++;
this.listSent = true;
return this.sendRequest(helper);
}
refObjectInfoListReply(id, sts) {
if (this.debug) {
console.log("refObjectInfoListReply", id, sts);
getRefObjectInfoAll(return_cb) {
let helper = this.Uint8ArrayHelper(Msg.GET_OBJECT_REF_INFO_ALL);
this.sendRequest(helper).then(function (dv) {
let type = dv.getUint8();
let id = dv.getUint32();
let sts = dv.getUint32();
let size = dv.getUint32();
for (let i = 0; i < size; i++) {
let eid = dv.getUint32();
let esize = dv.getUint32();
let sub = this.gdh.sub[eid];
if (typeof sub !== 'undefined') {
let value;
switch (sub.type) {
case Type.Boolean:
if (sub.elements <= 1) {
value = dv.getUint8();
} else {
let elements = esize;
if (elements !== sub.elements) {
console.log("Subscription size error", elements,
sub.elements, eid);
}
value = new Array(elements);
for (let k = 0; k < elements; k++) {
value[k] = dv.getUint8();
}
getRefObjectInfoAll(return_cb) {
let helper = new Uint8ArrayHelper(6, Msg.GET_OBJECT_REF_INFO_ALL);
helper.pack32Bit(this.next_id);
this.pending[this.next_id] = new PendingData(return_cb, null);
if (this.debug) {
console.log("Sending getRefObjectInfoAll", this.next_id);
}
this.ws.send(helper.buf);
this.next_id++;
break;
case Type.Float32:
if (sub.elements <= 1) {
value = dv.getFloat32();
} else {
let elements = esize / 4;
if (elements !== sub.elements) {
console.log("Subscription size error", elements,
sub.elements, eid);
}
value = new Array(elements);
for (let k = 0; k < elements; k++) {
value[k] = dv.getFloat32();
}
getRefObjectInfoAllReply(id, sts) {
if (this.debug) {
console.log("getRefObjectInfoAllReply", id, sts);
}
break;
case Type.Int8:
case Type.Int16:
case Type.Int32:
case Type.UInt8:
case Type.UInt16:
case Type.UInt32:
case Type.Status:
case Type.NetStatus:
case Type.Mask:
case Type.Enum:
case Type.Bit:
if (sub.elements <= 1) {
value = dv.getInt32();
} else {
let elements = esize / 4;
if (elements !== sub.elements) {
console.log("Subscription size error", elements,
sub.elements, eid);
}
value = new Array(elements);
for (let k = 0; k < elements; k++) {
value[k] = dv.getInt32();
}
}
break;
case Type.String:
case Type.Time:
case Type.DeltaTime:
case Type.AttrRef:
case Type.Objid:
if (sub.elements <= 1) {
value = dv.getString();
} else {
let elements = sub.elements;
if (elements !== sub.elements) {
console.log("Subscription size error", elements,
sub.elements, eid);
}
value = new Array(elements);
for (let l = 0; l < elements; l++) {
value[l] = dv.getString();
}
}
break;
default:
break;
}
this.gdh.sub[eid].value = value;
}
}
if (typeof this.gdh.pending[id] === 'undefined') {
console.log("** GetObjectRefInfoAll received removed", id);
return;
}
return_cb();
});
}
getObjectRefInfo(id) {
if (this.debug) {
console.log("getObjectRefInfo", id, this.sub[id].value);
}
return this.sub[id].value;
}
setObjectInfoBoolean(name, value) {
let helper = new Uint8ArrayHelper(12 + name.length, Msg.SET_OBJECT_INFO_BOOLEAN);
helper.pack32Bit(this.next_id);
let helper = this.Uint8ArrayHelper(Msg.SET_OBJECT_INFO_BOOLEAN);
helper.pack32Bit(value);
helper.packString(name);
this.ws.send(helper.buf);
if (this.debug) {
console.log("Sending setObjectInfoBoolean", this.next_id, name, value);
}
this.next_id++;
return 1;
return this.sendRequest(helper);
}
setObjectInfoInt(name, value) {
let helper = new Uint8ArrayHelper(12 + name.length, Msg.SET_OBJECT_INFO_INT);
helper.pack32Bit(this.next_id);
let helper = this.Uint8ArrayHelper(Msg.SET_OBJECT_INFO_INT);
helper.pack32Bit(value);
helper.packString(name);
// this.pending[this.next_id] = new PendingData( return_cb, null);
this.ws.send(helper.buf);
if (this.debug) {
console.log("Sending setObjectInfoInt", this.next_id, name, value);
}
this.next_id++;
return 1;
return this.sendRequest(helper);
}
setObjectInfoFloat(name, value) {
let helper = new Uint8ArrayHelper(12 + name.length, Msg.SET_OBJECT_INFO_FLOAT);
helper.pack32Bit(this.next_id);
let helper = this.Uint8ArrayHelper(Msg.SET_OBJECT_INFO_FLOAT);
let fbuf = new ArrayBuffer(4);
let fa = new Float32Array(fbuf);
fa[0] = value;
let ba = new Uint8Array(fbuf);
helper.buf[helper.idx++] = ba[0];
helper.buf[helper.idx++] = ba[1];
helper.buf[helper.idx++] = ba[2];
helper.buf[helper.idx++] = ba[3];
helper.buf.push(ba[0]);
helper.buf.push(ba[1]);
helper.buf.push(ba[2]);
helper.buf.push(ba[3]);
helper.packString(name);
// this.pending[this.next_id] = new PendingData( return_cb, null);
this.ws.send(helper.buf);
if (this.debug) {
console.log("Sending setObjectInfoFloat", this.next_id, name, value);
}
this.next_id++;
return 1;
return this.sendRequest(helper);
}
setObjectInfoString(name, value) {
let helper = new Uint8ArrayHelper(10 + value.length + name.length, Msg.SET_OBJECT_INFO_STRING);
helper.pack32Bit(this.next_id);
let helper = this.Uint8ArrayHelper(Msg.SET_OBJECT_INFO_STRING);
helper.packString(value);
helper.packString(name);
// this.pending[this.next_id] = new PendingData( return_cb, null);
this.ws.send(helper.buf);
if (this.debug) {
console.log("Sending setObjectInfoString", this.next_id, name, value);
return this.sendRequest(helper);
}
this.next_id++;
return 1;
setObjectInfo(name, value, type) {
if (type === Type.Boolean) {
return this.setObjectInfoBoolean(name, value);
} else if (type === Type.Float32 || type === Type.Float64) {
return this.setObjectInfoFloat(name, value);
} else if (type === Type.String) {
return this.setObjectInfoString(name, value);
} else {
return this.setObjectInfoInt(name, value);
}
}
toggleObjectInfo(name) {
let helper = new Uint8ArrayHelper(8 + name.length, Msg.TOGGLE_OBJECT_INFO);
helper.pack32Bit(this.next_id);
let helper = this.Uint8ArrayHelper(Msg.TOGGLE_OBJECT_INFO);
helper.packString(name);
// this.pending[this.next_id] = new PendingData( return_cb, null);
this.ws.send(helper.buf);
if (this.debug) {
console.log("Sending toggleObjectInfo", this.next_id, name);
return this.sendRequest(helper);
}
this.next_id++;
return 1;
}
getAllXttChildren(oid, return_cb, data) {
let helper = new Uint8ArrayHelper(14, Msg.GET_ALL_XTT_CHILDREN);
helper.pack32Bit(this.next_id);
getAllXttChildren(oid) {
let helper = this.Uint8ArrayHelper(Msg.GET_ALL_XTT_CHILDREN);
helper.pack32Bit(oid.vid);
helper.pack32Bit(oid.oix);
this.pending[this.next_id] = new PendingData(return_cb, data);
if (this.debug) {
console.log("Sending getAllXttChildren", this.next_id);
}
this.ws.send(helper.buf);
this.next_id++;
return this.sendRequest(helper);
}
getAllClassAttributes(cid, oid, return_cb, data) {
let helper = new Uint8ArrayHelper(18, Msg.GET_ALL_CLASS_ATTRIBUTES);
helper.pack32Bit(this.next_id);
getAllClassAttributes(cid, oid) {
let helper = this.Uint8ArrayHelper(Msg.GET_ALL_CLASS_ATTRIBUTES);
helper.pack32Bit(cid);
helper.pack32Bit(oid.vid);
helper.pack32Bit(oid.oix);
this.pending[this.next_id] = new PendingData(return_cb, data);
if (this.debug) {
console.log("Sending getAllClassAttributes", this.next_id, cid, oid.vid,
oid.oix);
}
this.ws.send(helper.buf);
this.next_id++;
return this.sendRequest(helper);
}
getObject(oid, op, return_cb, data) {
let helper = new Uint8ArrayHelper(16, Msg.GET_OBJECT);
helper.pack32Bit(this.next_id);
getObject(oid, op) {
let helper = this.Uint8ArrayHelper(Msg.GET_OBJECT);
helper.pack16Bit(op);
helper.pack32Bit(oid.vid);
helper.pack32Bit(oid.oix);
this.pending[this.next_id] = new PendingData(return_cb, data);
if (this.debug) {
console.log("Sending getObject", this.next_id, oid.vid, oid.oix);
}
this.ws.send(helper.buf);
this.next_id++;
return this.sendRequest(helper);
}
getObjectFromAref(aref, op, return_cb, data) {
let helper = new Uint8ArrayHelper(32, Msg.GET_OBJECT_FROM_AREF);
helper.pack32Bit(this.next_id);
getObjectFromAref(aref, op) {
let helper = this.Uint8ArrayHelper(Msg.GET_OBJECT_FROM_AREF);
helper.pack16Bit(op);
helper.pack32Bit(aref.objid.vid);
helper.pack32Bit(aref.objid.oix);
......@@ -1043,101 +781,61 @@ class Gdh {
helper.pack32Bit(aref.body);
helper.pack32Bit(aref.size);
helper.pack32Bit(aref.flags);
this.pending[this.next_id] = new PendingData(return_cb, data);
if (this.debug) {
console.log("Sending getObject", this.next_id, aref.objid.vid, aref.objid.oix);
}
this.ws.send(helper.buf);
this.next_id++;
return this.sendRequest(helper);
}
getObjectFromName(name, op, return_cb, data) {
let helper = new Uint8ArrayHelper(10 + name.length, Msg.GET_OBJECT_FROM_NAME);
helper.pack32Bit(this.next_id);
getObjectFromName(name, op) {
let helper = this.Uint8ArrayHelper(Msg.GET_OBJECT_FROM_NAME);
helper.pack16Bit(op);
helper.packString(name);
this.pending[this.next_id] = new PendingData(return_cb, data);
if (this.debug) {
console.log("Sending getObjectFromName", this.next_id, name);
}
this.ws.send(helper.buf);
this.next_id++;
return this.sendRequest(helper);
}
crrSignal(oid, return_cb, data) {
let helper = new Uint8ArrayHelper(14, Msg.CRR_SIGNAL);
helper.pack32Bit(this.next_id);
crrSignal(oid) {
let helper = this.Uint8ArrayHelper(Msg.CRR_SIGNAL);
helper.pack32Bit(oid.vid);
helper.pack32Bit(oid.oix);
this.pending[this.next_id] = new PendingData(return_cb, data);
if (this.debug) {
console.log("Sending crrObject", this.next_id, oid.vid, oid.oix);
}
this.ws.send(helper.buf);
this.next_id++;
return this.sendRequest(helper);
}
getOpwindMenu(name, return_cb, data) {
let helper = new Uint8ArrayHelper(8 + name.length, Msg.GET_OPWIND_MENU);
helper.pack32Bit(this.next_id);
getOpwindMenu(name) {
let helper = this.Uint8ArrayHelper(Msg.GET_OPWIND_MENU);
helper.packString(name);
this.pending[this.next_id] = new PendingData(return_cb, data);
if (this.debug) {
console.log("Sending getOpwindMenu", this.next_id);
}
this.ws.send(helper.buf);
this.next_id++;
return this.sendRequest(helper);
}
login(user, passwd, return_cb, data) {
let helper = new Uint8ArrayHelper(6 + 2 + user.length + 2 + passwd.length, Msg.CHECK_USER);
helper.pack32Bit(this.next_id);
login(user, passwd) {
let helper = this.Uint8ArrayHelper(Msg.CHECK_USER);
helper.packString(user);
helper.packString(passwd);
this.pending[this.next_id] = new PendingData(return_cb, data);
if (this.debug) {
console.log("Sending login", this.next_id);
}
this.ws.send(helper.buf);
this.next_id++;
return this.sendRequest(helper);
}
getMsg(value, return_cb, data) {
let helper = new Uint8ArrayHelper(10, Msg.GET_MSG);
helper.pack32Bit(this.next_id);
getMsg(value) {
let helper = this.Uint8ArrayHelper(Msg.GET_MSG);
helper.pack32Bit(value);
this.pending[this.next_id] = new PendingData(return_cb, data);
this.ws.send(helper.buf);
if (this.debug) {
console.log("Sending getMsg", this.next_id, value);
}
this.next_id++;
return this.sendRequest(helper);
}
mhSync(sync, return_cb, data) {
let helper = new Uint8ArrayHelper(10, Msg.MH_SYNC);
helper.pack32Bit(this.next_id);
mhSync(sync) {
let helper = this.Uint8ArrayHelper(Msg.MH_SYNC);
helper.pack32Bit(sync);
this.pending[this.next_id] = new PendingData(return_cb, data);
if (this.debug) {
console.log("Sending mhSync", this.next_id);
}
this.ws.send(helper.buf);
this.next_id++;
return this.sendRequest(helper);
}
mhAcknowledge(event_id, return_cb, data) {
let helper = new Uint8ArrayHelper(16 + event_id.birthTime.length, Msg.MH_ACK);
helper.pack32Bit(this.next_id);
mhAcknowledge(event_id) {
let helper = this.Uint8ArrayHelper(Msg.MH_ACK);
helper.pack32Bit(event_id.nix);
helper.pack32Bit(event_id.idx);
helper.packString(event_id.birthTime);
this.pending[this.next_id] = new PendingData(return_cb, data);
if (this.debug) {
console.log("Sending mhAcknowledge", this.next_id);
return this.sendRequest(helper);
}
console.log("Sending mhAcknowledge", this.next_id);
this.ws.send(helper.buf);
sendRequest(data) {
return new Promise((resolve, reject) => {
this.pending[this.next_id] = resolve;
this.next_id++;
this.ws.send(Uint8Array.from(data.buf));
});
}
}
\ No newline at end of file
......@@ -707,7 +707,6 @@ class GDraw {
class PlowCtx {
gdh: Gdh = null;
debug = false;
nodraw = 0;
zoom_factor = 20.0;
base_zoom_factor = 20.0;
......
......@@ -95,7 +95,7 @@ class Ev {
console.log("toolitem2", o.userdata.e.supObject.vid,
o.userdata.e.supObject.oix);
this.ctx.gdh.getObjectFromAref(o.userdata.e.supObject,
GdhOp.GET_OP_SELF, this.open_navigator_cb, null);
GdhOp.GET_OP_SELF).then(this.open_navigator_cb);
console.log("toolitem2 event");
});
// Trace sup object
......@@ -106,18 +106,16 @@ class Ev {
if (o === null) {
return;
}
let newwindow = window.open("", "_blank");
this.ctx.gdh.getObjectFromAref(o.userdata.e.supObject,
GdhOp.GET_OP_METHOD_PLC, this.open_plc_cb, newwindow);
GdhOp.GET_OP_METHOD_PLC).then(this.open_plc_cb);
});
// Graph event name
document.getElementById("toolitem4")
.addEventListener("click", function (event) {
let o = this.ctx.get_select();
if (o.userdata instanceof EvItemAlarm) {
let newwindow = window.open("", "_blank");
this.ctx.gdh.getObjectFromName(o.userdata.e.eventName,
GdhOp.GET_OP_METHOD_GRAPH, this.open_graph_cb, newwindow);
GdhOp.GET_OP_METHOD_GRAPH).then(this.open_graph_cb);
}
});
// Object raph event name
......@@ -125,9 +123,8 @@ class Ev {
.addEventListener("click", function (event) {
let o = this.ctx.get_select();
if (o.userdata instanceof EvItemAlarm) {
let newwindow = window.open("", "_blank");
this.ctx.gdh.getObjectFromName(o.userdata.e.eventName,
GdhOp.GET_OP_METHOD_OBJECTGRAPH, this.open_graph_cb, newwindow);
GdhOp.GET_OP_METHOD_OBJECTGRAPH).then(this.open_graph_cb);
}
});
// Navigator event name
......@@ -147,9 +144,8 @@ class Ev {
if (o === null) {
return;
}
let newwindow = window.open("", "_blank");
this.ctx.gdh.getObjectFromName(o.userdata.e.eventName,
GdhOp.GET_OP_METHOD_PLC, this.open_plc_cb, newwindow);
GdhOp.GET_OP_METHOD_PLC).then(this.open_plc_cb);
console.log("toolitem7 event");
});
// History event name
......@@ -175,7 +171,7 @@ class Ev {
if (o === null) {
return;
}
this.ctx.gdh.crrSignal(o.userdata.e.eventName, this.open_crr_cb, o);
this.ctx.gdh.crrSignal(o.userdata.e.eventName).then(this.open_crr_cb(o));
console.log("toolitem10 event");
});
// Help event name
......@@ -192,12 +188,10 @@ class Ev {
return;
}
if (o.userdata instanceof EvItemAlarm) {
let newwindow = window.open("", "_blank");
this.ctx.gdh.getObjectFromName(o.userdata.e.eventName,
GdhOp.GET_OP_METHOD_HELPCLASS, this.open_helpclass_cb, newwindow);
GdhOp.GET_OP_METHOD_HELPCLASS).then(this.open_helpclass_cb);
}
});
}
is_authorized(access) {
......@@ -206,25 +200,26 @@ class Ev {
gdh_init_cb() {
if (!this.priv) {
this.ctx.gdh.login("", "", this.login_cb, this);
this.ctx.gdh.login("", "").then(this.login_cb);
}
//this.ctx.gdh.mhSync( this.mhSyncIdx, this.sync_cb, this);
//this.ctx.gdh.mhSync(this.mhSyncIdx).then(this.sync_cb);
this.ctx.gdh.listSent = true;
this.trace_cyclic();
}
login_cb(id, data, sts, result) {
console.log("Login:", sts, result);
this.priv = (sts & 1) ? result : 0;
login_cb(res) {
console.log("Login:", res.sts, res.value);
this.priv = (res.sts & 1) ? res.value : 0;
}
sync_cb(id, data, sts, result) {
if (!(sts & 1)) {
sync_cb(res) {
if (!(res.sts & 1)) {
return;
}
let result = res.value;
if (result.length === 0) {
return;
}
......@@ -326,7 +321,7 @@ class Ev {
let item = node.get_userdata();
console.log("Ack", item.e.eventText);
this.ctx.gdh.mhAcknowledge(item.e.eventId, this.ack_cb, this);
this.ctx.gdh.mhAcknowledge(item.e.eventId).then(this.ack_cb);
if (item.e.eventStatus & EventStatus.NotRet) {
item.e.eventStatus &= ~EventStatus.NotAck;
......@@ -338,24 +333,28 @@ class Ev {
this.ctx.draw();
}
ack_cb(id, data, sts) {
console.log("ack sts", sts);
ack_cb(res) {
console.log("ack sts", res.sts);
}
open_objectgraph_cb(id, data, sts, result) {
if ((sts & 1) === 0) {
data.document.write("Error status " + sts);
open_objectgraph_cb(res) {
let w = window.open("", "_blank");
if ((res.sts & 1) === 0) {
w.document.write("Error status " + res.sts);
} else {
data.location.href =
let result = res.value;
w.location.href =
"ge.html?graph=" + result.param1 + "&instance=" + result.fullname;
data.document.title = result.fullname;
w.document.title = result.fullname;
}
}
open_graph_cb(id, data, sts, result) {
if ((sts & 1) === 0) {
data.document.write("Error status " + sts);
open_graph_cb(res) {
let w = window.open("", "_blank");
if ((res.sts & 1) === 0) {
w.document.write("Error status " + res.sts);
} else {
let result = res.value;
let idx = result.param1.indexOf('.');
if (idx !== -1) {
result.param1 = result.param1.substring(0, idx);
......@@ -366,62 +365,61 @@ class Ev {
instancestr = "&instance=" + result.fullname;
}
data.location.href = "ge.html?graph=" + result.param1 + instancestr;
data.document.title = result.param1;
w.location.href = "ge.html?graph=" + result.param1 + instancestr;
w.document.title = result.param1;
}
}
open_plc_cb(id, data, sts, result) {
if ((sts & 1) === 0) {
data.document.write("Error status " + sts);
} else {
let param1;
if (result.param1 === "") {
param1 = "";
open_plc_cb(res) {
let w = window.open("", "_blank");
if ((res.sts & 1) === 0) {
w.document.write("Error status " + res.sts);
} else {
param1 = "&obj=" + result.param1;
}
let result = res.value;
let param1 = result.param1 ? ("&obj=" + result.param1) : "";
console.log("flow.html?vid=" + result.objid.vid + "&oix=" +
result.objid.oix + param1);
data.location.href =
w.location.href =
"flow.html?vid=" + result.objid.vid + "&oix=" + result.objid.oix +
param1;
data.document.title = "Trace " + result.fullname;
w.document.title = "Trace " + result.fullname;
}
}
open_navigator_cb(id, data, sts, result) {
console.log("Open navigator", sts);
if ((sts & 1) === 0) {
console.log("Error status " + sts);
open_navigator_cb(res) {
console.log("Open navigator", res.sts);
if ((res.sts & 1) === 0) {
console.log("Error status " + res.sts);
} else {
localStorage.setItem("XttMethodNavigator", result.fullname);
localStorage.setItem("XttMethodNavigator", res.value.fullname);
console.log("storage", localStorage.getItem("XttMethodNavigator"));
}
}
open_objectgraph_cb(id, data, sts, result) {
if ((sts & 1) === 0) {
data.document.write("Error status " + sts);
open_objectgraph_cb(res) {
let w = window.open("", "_blank");
if ((res.sts & 1) === 0) {
w.document.write("Error status " + res.sts);
} else {
let classname = result.classname.toLowerCase();
let classname = res.value.classname.toLowerCase();
if (classname.substring(0, 1) === "$") {
classname = classname.substring(1);
}
let graphname = "pwr_c_" + classname;
data.location.href =
"ge.html?graph=" + graphname + "&instance=" + result.fullname;
data.document.title = graphname + " " + result.fullname;
w.location.href =
"ge.html?graph=" + graphname + "&instance=" + res.value.fullname;
w.document.title = graphname + " " + res.value.fullname;
}
}
open_helpclass_cb(id, data, sts, result) {
if ((sts & 1) === 0) {
data.document.write("Error status " + sts);
open_helpclass_cb(res) {
let w = window.open("", "_blank");
if ((res.sts & 1) === 0) {
w.document.write("Error status " + res.sts);
} else {
console.log("open_helpclass", result.param1);
data.location.href =
location.protocol + "//" + location.host + result.param1;
console.log("open_helpclass", res.value.param1);
w.location.href =
location.protocol + "//" + location.host + res.value.param1;
}
}
......@@ -442,12 +440,12 @@ class Ev {
}
trace_cyclic() {
this.ctx.gdh.mhSync(this.mhSyncIdx, this.sync_cb, this);
this.ctx.gdh.mhSync(this.mhSyncIdx).then(this.sync_cb);
this.timer = setTimeout(this.trace_cyclic, 1000);
}
trace_scan(id, sts) {
trace_scan(res) {
this.scan_update = false;
if (this.scan_update) {
this.ctx.draw();
......@@ -581,17 +579,13 @@ class Ev {
case Event.Key_CtrlL:
let o = this.ctx.get_select();
if (o.userdata instanceof EvItemAlarm) {
let newwindow = window.open("", "_blank");
this.ctx.gdh.getObject(o.userdata.objid, GdhOp.GET_OP_METHOD_PLC,
this.open_plc_cb, newwindow);
this.ctx.gdh.getObject(o.userdata.objid, GdhOp.GET_OP_METHOD_PLC).then(this.open_plc_cb);
}
break;
case Event.Key_CtrlG:
let o = this.ctx.get_select();
if (o.userdata instanceof EvItemAlarm) {
let newwindow = window.open("", "_blank");
this.ctx.gdh.getObject(o.userdata.objid, GdhOp.GET_OP_METHOD_PLC,
this.open_objectgraph_cb, newwindow);
this.ctx.gdh.getObject(o.userdata.objid, GdhOp.GET_OP_METHOD_PLC).then(this.open_objectgraph_cb);
}
break;
default:
......
......@@ -1551,7 +1551,6 @@ class FlowCtx extends Rect {
gdraw: GDraw;
display_level = DisplayLevel.One;
gdh: Gdh = null;
debug = false;
zoom_factor = 20.0;
base_zoom_factor = 20.0;
offset_x = 0;
......@@ -1776,10 +1775,8 @@ class FlowFrame {
}
flow_open() {
console.log("flow_open");
console.log("ctx.gdh", this.ctx.gdh);
this.ctx.connect();
this.ctx.gdh.refObjectInfoList(this.ctx.gdh.refObjectInfoListReply);
this.ctx.gdh.refObjectInfoList();
this.timer = setTimeout(this.flow_cyclic, 1000);
}
......@@ -1794,7 +1791,6 @@ class FlowFrame {
}
flow_close() {
console.log("Close function", this.timer);
clearTimeout(this.timer);
for (let i in this.ctx.gdh.pending) {
delete this.ctx.gdh.pending[i];
......
......@@ -20,6 +20,7 @@
<script type="text/babel" src="glow_annot.ts"></script>
<script type="text/babel" src="glow_arc.ts"></script>
<script type="text/babel" src="glow_array.ts"></script>
<script type="text/babel" src="glow_arrow.ts"></script>
<script type="text/babel" src="glow_cformat.ts"></script>
<script type="text/babel" src="glow_con.ts"></script>
<script type="text/babel" src="glow_conclass.ts"></script>
......
......@@ -74,10 +74,8 @@ class Appl {
}
if (classGraph) {
console.log("Cmd classGraph");
let newwindow = window.open("", "_blank");
this.graph.gdh.getObjectFromName(instanceValue,
GdhOp.GET_OP_METHOD_OBJECTGRAPH, this.open_objectgraph_cb,
newwindow);
GdhOp.GET_OP_METHOD_OBJECTGRAPH).then(this.open_objectgraph_cb);
} else {
let graphName = cli.getQualValue("cli_arg2").toLowerCase();
if (!graphName) {
......@@ -86,7 +84,7 @@ class Appl {
}
graphName = graphName.toLowerCase();
if (graphName.charAt(".pwg") === -1) {
if (!graphName.endsWith(".pwg")) {
graphName += ".pwg";
}
......@@ -266,14 +264,16 @@ class Appl {
}
}
open_objectgraph_cb(id, data, sts, result) {
if ((sts & 1) === 0) {
data.document.write("Error status " + sts);
open_objectgraph_cb(res) {
let w = window.open("", "_blank");
if ((res.sts & 1) === 0) {
w.document.write("Error status " + res.sts);
} else {
let result = res.value;
console.log("param1", result.param1);
data.location.href =
w.location.href =
"ge.html?graph=" + result.param1 + "&instance=" + result.fullname;
data.document.title = result.param1 + " " + result.fullname;
w.document.title = result.param1 + " " + result.fullname;
}
}
}
......
......@@ -10,8 +10,7 @@ class DynParsedAttrName {
}
class Dyn {
debug = false;
elements = [];
elements: Array<DynElem> = [];
graph: Graph;
object = null;
dyn_type1: DynType1 = 0;
......@@ -57,7 +56,7 @@ class Dyn {
(elem.instance !== undefined && elem.instance !== xelem.instance));
});
// Insert copy of x element
let e = Object.assign({}, xelem);
let e = <DynElem>Object.assign({}, xelem);
if (e) {
e.dyn = this;
this.elements.push(e);
......@@ -71,10 +70,6 @@ class Dyn {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.debug) {
console.log("Dyn : " + lines[i]);
}
let elem = null;
switch (key) {
......@@ -417,7 +412,7 @@ class Dyn {
}
getHostObject() {
let elem = this.elements.find(e => (e.dyn_type1 & DynType1.HostObject) !== 0);
let elem = <DynHostObject>this.elements.find(e => (e.dyn_type1 & DynType1.HostObject) !== 0);
return elem ? elem.hostobject : "";
}
......@@ -531,10 +526,10 @@ class Dyn {
}
}
let setObjectInfo = function(func, pname, inputValue) {
let setObjectInfo = function(pname, inputValue, type: Type) {
let sts = 0;
if (pname.database === Database.Gdh) {
sts = e.dyn.graph.getGdh()["setObjectInfo" + func](pname.name, inputValue);
sts = e.dyn.graph.getGdh().setObjectInfo(pname.name, inputValue, type);
} else if (pname.database === Database.Local) {
sts = e.dyn.graph.getLdb().setObjectInfo(this.graph, pname.name, inputValue);
}
......@@ -569,7 +564,7 @@ class Dyn {
break;
}
sts = setObjectInfo("Float", pname, inputValue);
sts = setObjectInfo(pname, inputValue, e.a_typeid);
break;
case Type.Int32:
case Type.UInt32:
......@@ -596,14 +591,13 @@ class Dyn {
break;
}
sts = setObjectInfo("Int", pname, inputValue);
sts = setObjectInfo(pname, inputValue, e.a_typeid);
break;
case Type.Boolean:
let inputValueInt = parseInt(str.trim(), 10);
if (inputValueInt !== 0 && inputValueInt !== 1) {
break;
}
let inputValue = Boolean(inputValueInt);
// valueElement.oldValueB = inputValue;
......@@ -612,7 +606,7 @@ class Dyn {
break;
}
sts = setObjectInfo("Boolean", pname, inputValue);
sts = setObjectInfo(pname, Boolean(inputValueInt), e.a_typeid);
break;
case Type.String:
// valueElement.oldValueS = str;
......@@ -622,7 +616,7 @@ class Dyn {
break;
}
sts = setObjectInfo("String", pname, inputValue);
sts = setObjectInfo(pname, inputValue, e.a_typeid);
break;
}
if (ctx_popped) {
......@@ -746,6 +740,7 @@ class DynElem {
dyn_type2: DynType2 = 0;
action_type1: ActionType1 = 0;
action_type2: ActionType2 = 0;
attribute;
prio: DynPrio;
instance_mask = 0;
instance: Instance = 0;
......@@ -772,7 +767,6 @@ class DynElem {
class DynDigLowColor extends DynElem {
a = null;
attribute;
color;
firstScan = true;
......@@ -852,10 +846,6 @@ class DynDigLowColor extends DynElem {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.dyn.debug) {
console.log("DynDigLowColor : " + lines[i]);
}
switch (key) {
case DynSave.DigLowColor:
break;
......@@ -881,7 +871,6 @@ class DynDigLowColor extends DynElem {
class DynDigColor extends DynElem {
a = null;
attribute;
color;
firstScan = true;
......@@ -971,10 +960,6 @@ class DynDigColor extends DynElem {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.dyn.debug) {
console.log("DynDigColor : " + lines[i]);
}
switch (key) {
case DynSave.DigColor:
break;
......@@ -1006,7 +991,6 @@ class DynDigColor extends DynElem {
class DynDigWarning extends DynElem {
a;
attribute;
use_colortheme;
firstScan = true;
......@@ -1082,10 +1066,6 @@ class DynDigWarning extends DynElem {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.dyn.debug) {
console.log("DynDigWarning : " + lines[i]);
}
switch (key) {
case DynSave.DigWarning:
break;
......@@ -1111,7 +1091,6 @@ class DynDigWarning extends DynElem {
class DynDigError extends DynElem {
a;
attribute;
use_colortheme;
firstScan = true;
......@@ -1187,10 +1166,6 @@ class DynDigError extends DynElem {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.dyn.debug) {
console.log("DynDigError : " + lines[i]);
}
switch (key) {
case DynSave.DigError:
break;
......@@ -1216,7 +1191,6 @@ class DynDigError extends DynElem {
class DynDigFlash extends DynElem {
a;
attribute;
color;
color2;
firstScan = true;
......@@ -1312,10 +1286,6 @@ class DynDigFlash extends DynElem {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.dyn.debug) {
console.log("DynDigError : " + lines[i]);
}
switch (key) {
case DynSave.DigFlash:
break;
......@@ -1344,7 +1314,6 @@ class DynDigFlash extends DynElem {
class DynInvisible extends DynElem {
a;
attribute;
dimmed;
firstScan = true;
cmd;
......@@ -1441,10 +1410,6 @@ class DynInvisible extends DynElem {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.dyn.debug) {
console.log("DynInvisible : " + lines[i]);
}
switch (key) {
case DynSave.Invisible:
break;
......@@ -1476,7 +1441,6 @@ class DynInvisible extends DynElem {
class DynDigTextColor extends DynElem {
a = null;
attribute;
color;
firstScan = true;
......@@ -1539,10 +1503,6 @@ class DynDigTextColor extends DynElem {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.dyn.debug) {
console.log("DigTextColor : " + lines[i]);
}
switch (key) {
case DynSave.DigTextColor:
break;
......@@ -1568,7 +1528,6 @@ class DynDigTextColor extends DynElem {
class DynDigText extends DynElem {
a;
attribute;
low_text;
high_text;
firstScan = true;
......@@ -1633,10 +1592,6 @@ class DynDigText extends DynElem {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.dyn.debug) {
console.log("DigText : " + lines[i]);
}
switch (key) {
case DynSave.DigText:
break;
......@@ -1670,7 +1625,6 @@ class DynDigText extends DynElem {
class DynDigBorder extends DynElem {
a;
attribute;
color;
firstScan = true;
......@@ -1727,10 +1681,6 @@ class DynDigBorder extends DynElem {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.dyn.debug) {
console.log("DynBorder : " + lines[i]);
}
switch (key) {
case DynSave.DigBorder:
break;
......@@ -1756,7 +1706,6 @@ class DynDigBorder extends DynElem {
class DynValue extends DynElem {
a;
attribute;
format = null;
zero_blank;
decimals_attr;
......@@ -1791,22 +1740,17 @@ class DynValue extends DynElem {
return format;
}
// TODO
return format; // TODO
let ret = this.dyn.graph.getGdh().getObjectInfoInt(pname.name);
if (even(ret)) {
let sts = this.dyn.graph.getGdh().getObjectInfoInt(pname.name);
if (even(sts)) {
return format;
}
decimals = ret.value - decr;
if (decimals < 0) {
decimals = 0;
}
decimals = Math.max(sts - decr, 0);
if (decimals >= 10) {
return format;
}
if (format === null) {
if (!format) {
return "%." + decimals + "f";
}
......@@ -1818,7 +1762,7 @@ class DynValue extends DynElem {
if (s < 2 || format.charAt(s - 2) !== '.') {
return "%." + decimals + "f";
} else {
return format.substring(0, s - 1) + decimals + format.substring(s);
return format.substring(0, format.indexOf('.') + 1) + decimals + "f";
}
}
}
......@@ -1901,7 +1845,7 @@ class DynValue extends DynElem {
case Type.DeltaTime:
if (this.firstScan || !(value0 === this.oldValueS)) {
if (this.cFormat) {
if (this.a_typeid === Type.String) {
if (this.a.typeid === Type.String) {
let sb = this.cFormat.format(value0);
object.setAnnotation(annot_num, sb);
} else { // TODO time format
......@@ -1920,10 +1864,7 @@ class DynValue extends DynElem {
this.dyn.repaintNow = true;
} else {
if (this.a.database === Database.Gdh) {
let data = new Array(2);
data[0] = this;
data[1] = object;
this.dyn.graph.getGdh().getMsg(value0, DynValue.scan2, data);
this.dyn.graph.getGdh().getMsg(value0).then(this.scan2(object));
}
}
}
......@@ -1951,16 +1892,16 @@ class DynValue extends DynElem {
}
}
static scan2(id, data, sts, value) {
let self = data[0];
let object = data[1];
let annot_num = Dyn.instance_to_number(self.instance);
if (sts & 1 !== 0) {
object.setAnnotation(annot_num, value);
scan2(object) {
return function(res) {
let annot_num = Dyn.instance_to_number(this.instance);
if (res.sts & 1 !== 0) {
object.setAnnotation(annot_num, res.value);
} else {
object.setAnnotation(annot_num, "Unknown message");
}
self.dyn.repaintNow = true;
this.dyn.repaintNow = true;
}
}
open(lines, row) {
......@@ -2019,7 +1960,6 @@ class DynValue extends DynElem {
}
class DynValueInput extends DynElem {
attribute;
min_value;
max_value;
clear;
......@@ -2071,10 +2011,6 @@ class DynValueInput extends DynElem {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.dyn.debug) {
console.log("DynValueInput : " + lines[i]);
}
switch (key) {
case DynSave.ValueInput:
break;
......@@ -2133,7 +2069,6 @@ class DynValueInput extends DynElem {
class DynAnalogColor extends DynElem {
a = null;
attribute;
limit;
limit_type;
color;
......@@ -2332,10 +2267,6 @@ class DynAnalogColor extends DynElem {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.dyn.debug) {
console.log("DynAnalogColor : " + lines[i]);
}
switch (key) {
case DynSave.AnalogColor:
break;
......@@ -2379,7 +2310,6 @@ class DynAnalogColor extends DynElem {
class DynRotate extends DynElem {
a;
attribute;
x0;
y0;
factor;
......@@ -2436,10 +2366,6 @@ class DynRotate extends DynElem {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.dyn.debug) {
console.log("DynRotate : " + lines[i]);
}
switch (key) {
case DynSave.Rotate:
break;
......@@ -2704,10 +2630,6 @@ class DynMove extends DynElem {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.dyn.debug) {
console.log("DynMove : " + lines[i]);
}
switch (key) {
case DynSave.Move:
break;
......@@ -2766,7 +2688,6 @@ class DynMove extends DynElem {
class DynAnalogShift extends DynElem {
a;
attribute;
firstScan = true;
oldValueF;
oldValueI;
......@@ -2839,10 +2760,6 @@ class DynAnalogShift extends DynElem {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.dyn.debug) {
console.log("DynAnalogShift : " + lines[i]);
}
switch (key) {
case DynSave.AnalogShift:
break;
......@@ -2865,7 +2782,6 @@ class DynAnalogShift extends DynElem {
class DynDigShift extends DynElem {
a;
attribute;
firstScan = true;
constructor(dyn) {
......@@ -2919,10 +2835,6 @@ class DynDigShift extends DynElem {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.dyn.debug) {
console.log("DynDigShift : " + lines[i]);
}
switch (key) {
case DynSave.DigShift:
break;
......@@ -3032,10 +2944,6 @@ class DynDigFourShift extends DynElem {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.dyn.debug) {
console.log("DynDigFourShift : " + lines[i]);
}
switch (key) {
case DynSave.DigFourShift:
break;
......@@ -3068,7 +2976,6 @@ class DynDigFourShift extends DynElem {
class DynScrollingText extends DynElem {
a;
attribute;
direction;
speed;
bounce;
......@@ -3207,10 +3114,6 @@ class DynScrollingText extends DynElem {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.dyn.debug) {
console.log("DynScrollingText : " + lines[i]);
}
switch (key) {
case DynSave.ScrollingText:
break;
......@@ -3257,10 +3160,6 @@ class DynColorThemeLightness extends DynElem {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.dyn.debug) {
console.log("DynColorThemeLightness : " + lines[i]);
}
switch (key) {
case DynSave.ColorThemeLightness:
break;
......@@ -3278,7 +3177,6 @@ class DynColorThemeLightness extends DynElem {
class DynDigBackgroundColor extends DynElem {
a = null;
attribute;
color;
firstScan = true;
......@@ -3346,10 +3244,6 @@ class DynDigBackgroundColor extends DynElem {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.dyn.debug) {
console.log("DynDigBackgroundColor : " + lines[i]);
}
switch (key) {
case DynSave.DigBackgroundColor:
break;
......@@ -3381,7 +3275,6 @@ class DynDigBackgroundColor extends DynElem {
class DynDigSwap extends DynElem {
a;
attribute;
reset_value;
firstScan = true;
......@@ -3439,10 +3332,6 @@ class DynDigSwap extends DynElem {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.dyn.debug) {
console.log("DynDigSwap : " + lines[i]);
}
switch (key) {
case DynSave.DigSwap:
break;
......@@ -3468,7 +3357,6 @@ class DynDigSwap extends DynElem {
class DynAnimation extends DynElem {
a;
attribute;
sequence;
firstScan = true;
animation_count;
......@@ -3613,10 +3501,6 @@ class DynAnimation extends DynElem {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.dyn.debug) {
console.log("Animation : " + lines[i]);
}
switch (key) {
case DynSave.Animation:
break;
......@@ -3652,10 +3536,6 @@ class DynVideo extends DynElem {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.dyn.debug) {
console.log("Video : " + lines[i]);
}
switch (key) {
case DynSave.Video:
break;
......@@ -3770,10 +3650,6 @@ class DynBar extends DynElem {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.dyn.debug) {
console.log("DynBar : " + lines[i]);
}
switch (key) {
case DynSave.Bar:
break;
......@@ -3979,7 +3855,7 @@ class DynTrend extends DynElem {
if (dt >= 0.001) {
object.set_scan_time(dt);
this.scan_time = dt;
if (this.cycle === Cycle.Slow) {
if (this.dyn.cycle === Cycle.Slow) {
let current_graph_scan_time = this.dyn.graph.getScanTime();
if (current_graph_scan_time > this.scan_time || this.scan_time <= this.orig_graph_scan_time) {
this.dyn.graph.setScanTime(this.scan_time);
......@@ -4051,13 +3927,13 @@ class DynTrend extends DynElem {
this.firstScan = false;
}
if (this.cycle === Cycle.Slow) {
if (this.dyn.cycle === Cycle.Slow) {
this.acc_time += this.dyn.graph.getScanTime();
} else {
this.acc_time += this.dyn.graph.getFastScanTime();
}
if (this.acc_time + Number.MIN_VALUE >= this.scan_time) {
if (this.p1 !== 0) {
if (this.a1 !== 0) {
switch (this.a1.typeid) {
case Type.Boolean:
object.add_value(Boolean(this.a1.get_ref_value(this.dyn)), 0);
......@@ -4095,10 +3971,6 @@ class DynTrend extends DynElem {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.dyn.debug) {
console.log("DynTrend : " + lines[i]);
}
switch (key) {
case DynSave.Trend:
break;
......@@ -4226,10 +4098,6 @@ class DynXY_Curve extends DynElem {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.dyn.debug) {
console.log("DynXYCurve : " + lines[i]);
}
switch (key) {
case DynSave.XY_Curve:
break;
......@@ -4558,7 +4426,7 @@ class DynXY_Curve extends DynElem {
switch (this.xAttrType) {
case Type.Float32:
this.dyn.graph.getGdh()
.getObjectInfoFloatArray(pname.name, size, DynXY_Curve.scan2, this);
.getObjectInfoFloatArray(pname.name, size).then(this.scan2);
break;
case Type.Int32:
case Type.Int16:
......@@ -4567,7 +4435,7 @@ class DynXY_Curve extends DynElem {
case Type.UInt16:
case Type.UInt8:
this.dyn.graph.getGdh()
.getObjectInfoIntArray(pname.name, size, DynXY_Curve.scan2, this);
.getObjectInfoIntArray(pname.name, size).then(this.scan2);
break;
default:
return;
......@@ -4576,75 +4444,40 @@ class DynXY_Curve extends DynElem {
this.firstScan = false;
}
static scan2(id, self, sts, value) {
switch (self.xAttrType) {
scan2(res) {
switch (this.xAttrType) {
case Type.Float32:
if (!(sts & 1)) {
return;
}
switch (self.datatype) {
case CurveDataType.XYArrays:
self.curveX = value.slice(0, self.noOfPoints);
break;
case CurveDataType.PointArray:
self.curveX = new Array(self.noOfPoints);
self.curveY = new Array(self.noOfPoints);
for (let i = 0; i < self.noOfPoints; i++) {
self.curveX[i] = value[2 * i];
self.curveY[i] = value[2 * i + 1];
}
self.dyn.repaintNow = true;
break;
case CurveDataType.TableObject:
self.noOfPoints = Math.min(Math.floor(value[0]), self.noofpoints);
if (attrSize < self.noOfPoints) {
self.noOfPoints = attrSize;
}
self.curveY = new Array(self.noOfPoints);
self.curveX = new Array(self.noOfPoints);
for (let i = 0; i < self.noOfPoints; i++) {
self.curveX[i] = value[2 * i + 1];
self.curveY[i] = value[2 * i + 2];
}
self.dyn.repaintNow = true;
break;
}
break;
case Type.Int32:
case Type.Int16:
case Type.Int8:
case Type.UInt32:
case Type.UInt16:
case Type.UInt8:
if (!(sts & 1)) {
if (!(res.sts & 1)) {
return;
}
switch (self.datatype) {
switch (this.datatype) {
case CurveDataType.XYArrays:
self.curveX = value.slice(0, self.noOfPoints);
this.curveX = res.value.slice(0, this.noOfPoints);
break;
case CurveDataType.PointArray:
self.curveX = new Array(self.noOfPoints);
self.curveY = new Array(self.noOfPoints);
for (let i = 0; i < self.noOfPoints; i++) {
self.curveX[i] = value[2 * i];
self.curveY[i] = value[2 * i + 1];
this.curveX = new Array(this.noOfPoints);
this.curveY = new Array(this.noOfPoints);
for (let i = 0; i < this.noOfPoints; i++) {
this.curveX[i] = res.value[2 * i];
this.curveY[i] = res.value[2 * i + 1];
}
self.dyn.repaintNow = true;
this.dyn.repaintNow = true;
break;
case CurveDataType.TableObject:
self.noOfPoints = Math.min(Math.floor(value[0]), self.noofpoints);
if (attrSize < self.noOfPoints) {
self.noOfPoints = attrSize;
this.noOfPoints = Math.min(Math.floor(res.value[0]), this.noofpoints);
this.curveY = new Array(this.noOfPoints);
this.curveX = new Array(this.noOfPoints);
for (let i = 0; i < this.noOfPoints; i++) {
this.curveX[i] = res.value[2 * i + 1];
this.curveY[i] = res.value[2 * i + 2];
}
self.curveY = new Array(self.noOfPoints);
self.curveX = new Array(self.noOfPoints);
for (let i = 0; i < self.noOfPoints; i++) {
self.curveX[i] = value[2 * i + 1];
self.curveY[i] = value[2 * i + 2];
}
self.dyn.repaintNow = true;
this.dyn.repaintNow = true;
break;
}
break;
......@@ -4653,18 +4486,17 @@ class DynXY_Curve extends DynElem {
}
// Read y-array
switch (self.datatype) {
switch (this.datatype) {
case CurveDataType.XYArrays:
let pname = self.dyn.parseAttrName(self.y_attr);
self.noOfPoints = Math.min(self.noOfPoints, pname.elements);
self.yAttrType = pname.type;
self.curveY = new Array(self.noOfPoints);
let pname = this.dyn.parseAttrName(this.y_attr);
this.noOfPoints = Math.min(this.noOfPoints, pname.elements);
this.yAttrType = pname.type;
this.curveY = new Array(this.noOfPoints);
switch (self.yAttrType) {
switch (this.yAttrType) {
case Type.Float32:
self.dyn.graph.getGdh()
.getObjectInfoFloatArray(pname.name, self.noOfPoints, self.scan3,
self);
this.dyn.graph.getGdh()
.getObjectInfoFloatArray(pname.name, this.noOfPoints).then(this.scan3);
break;
case Type.Int32:
case Type.Int16:
......@@ -4672,9 +4504,8 @@ class DynXY_Curve extends DynElem {
case Type.UInt32:
case Type.UInt16:
case Type.UInt8:
self.dyn.graph.getGdh()
.getObjectInfoIntArray(pname.name, self.noOfPoints, self.scan3,
self);
this.dyn.graph.getGdh()
.getObjectInfoIntArray(pname.name, this.noOfPoints).then(this.scan3);
break;
default:
return;
......@@ -4683,14 +4514,14 @@ class DynXY_Curve extends DynElem {
}
}
static scan3(id, self, sts, value) {
if (!(sts & 1)) {
scan3(res) {
if (!(res.sts & 1)) {
return;
}
switch (self.datatype) {
switch (this.datatype) {
case CurveDataType.XYArrays:
switch (self.yAttrType) {
switch (this.yAttrType) {
case Type.Float32:
case Type.Int32:
case Type.Int16:
......@@ -4698,8 +4529,8 @@ class DynXY_Curve extends DynElem {
case Type.UInt32:
case Type.UInt16:
case Type.UInt8:
self.curveY = value.slice(0, self.noOfPoints);
self.dyn.repaintNow = true;
this.curveY = res.value.slice(0, this.noOfPoints);
this.dyn.repaintNow = true;
break;
default:
return;
......@@ -4707,8 +4538,8 @@ class DynXY_Curve extends DynElem {
break;
}
self.object.set_xy_data(self.curveY, self.curveX, self.curve_number - 1,
self.noOfPoints);
this.object.set_xy_data(this.curveY, this.curveX, this.curve_number - 1,
this.noOfPoints);
}
}
......@@ -4734,10 +4565,6 @@ class DynPie extends DynElem {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.dyn.debug) {
console.log("DynPie : " + lines[i]);
}
switch (key) {
case DynSave.Pie:
break;
......@@ -4945,10 +4772,6 @@ class DynBarChart extends DynElem {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.dyn.debug) {
console.log("DynBarChart : " + lines[i]);
}
if (key === DynSave.End) {
return i;
} else if (key === DynSave.BarChart_fix_range) {
......@@ -5109,10 +4932,6 @@ class DynTable extends DynElem {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.dyn.debug) {
console.log("DynTable : " + lines[i]);
}
if (key === DynSave.End) {
return i;
} else if (key >= DynSave.Table_attribute1 && key <= DynSave.Table_attribute12) {
......@@ -5268,7 +5087,7 @@ class DynTable extends DynElem {
this.sel_p[i] = this.dyn.graph.getGdh()
.refObjectInfo(pname.tname, pname.type, pname.elements);
if (this.sel_p[i] !== 0) {
if (ret.getElements() === 0) {
if (pname.elements === 0) {
break;
}
this.sel_elements[i] = Math.min(pname.elements, this.elements[i]);
......@@ -5367,7 +5186,6 @@ class DynTable extends DynElem {
} else {
object.setValue("0", i, j);
}
object.setValue(sb, i, j);
this.oldValueB[i][j] = val;
}
break;
......@@ -5587,7 +5405,6 @@ class DynTable extends DynElem {
class DynStatusColor extends DynElem {
a;
attribute;
nostatus_color;
use_colortheme;
firstScan = true;
......@@ -5721,10 +5538,6 @@ class DynStatusColor extends DynElem {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.dyn.debug) {
console.log("DynStatusColor : " + lines[i]);
}
switch (key) {
case DynSave.StatusColor:
break;
......@@ -5771,10 +5584,6 @@ class DynAxis extends DynElem {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.dyn.debug) {
console.log("DynAxis : " + lines[i]);
}
switch (key) {
case DynSave.Axis:
break;
......@@ -5896,10 +5705,6 @@ class DynTimeoutColor extends DynElem {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.dyn.debug) {
console.log("DynTimeoutColor : " + lines[i]);
}
switch (key) {
case DynSave.TimeoutColor:
break;
......@@ -5935,10 +5740,6 @@ class DynHostObject extends DynElem {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.dyn.debug) {
console.log("DynHostObject : " + lines[i]);
}
switch (key) {
case DynSave.HostObject:
break;
......@@ -5960,7 +5761,6 @@ class DynHostObject extends DynElem {
}
class DynDigSound extends DynElem {
attribute;
soundobject;
level;
interval;
......@@ -5976,10 +5776,6 @@ class DynDigSound extends DynElem {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.dyn.debug) {
console.log("DynDigSound : " + lines[i]);
}
switch (key) {
case DynSave.DigSound:
break;
......@@ -6021,7 +5817,6 @@ class DynFillLevel extends DynElem {
a = null;
minvalue_a;
maxvalue_a;
attribute;
color;
direction;
max_value;
......@@ -6155,10 +5950,6 @@ class DynFillLevel extends DynElem {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.dyn.debug) {
console.log("DynFillLevel : " + lines[i]);
}
switch (key) {
case DynSave.FillLevel:
break;
......@@ -6202,8 +5993,6 @@ class DynFillLevel extends DynElem {
}
class DynSetDig extends DynElem {
attribute;
constructor(dyn) {
super(dyn, DynPrio.SetDig);
this.action_type1 = ActionType1.SetDig;
......@@ -6259,10 +6048,6 @@ class DynSetDig extends DynElem {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.dyn.debug) {
console.log("DynSetDig : " + lines[i]);
}
switch (key) {
case DynSave.SetDig:
break;
......@@ -6290,8 +6075,6 @@ class DynSetDig extends DynElem {
}
class DynResetDig extends DynElem {
attribute;
constructor(dyn) {
super(dyn, DynPrio.ResetDig);
this.action_type1 = ActionType1.ResetDig;
......@@ -6347,10 +6130,6 @@ class DynResetDig extends DynElem {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.dyn.debug) {
console.log("DynResetDig : " + lines[i]);
}
switch (key) {
case DynSave.ResetDig:
break;
......@@ -6378,8 +6157,6 @@ class DynResetDig extends DynElem {
}
class DynToggleDig extends DynElem {
attribute;
constructor(dyn) {
super(dyn, DynPrio.ToggleDig);
this.action_type1 = ActionType1.ToggleDig;
......@@ -6431,10 +6208,6 @@ class DynToggleDig extends DynElem {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.dyn.debug) {
console.log("DynToggleDig : " + lines[i]);
}
switch (key) {
case DynSave.ToggleDig:
break;
......@@ -6456,8 +6229,6 @@ class DynToggleDig extends DynElem {
}
class DynStoDig extends DynElem {
attribute;
constructor(dyn) {
super(dyn, DynPrio.StoDig);
this.action_type1 = ActionType1.StoDig;
......@@ -6505,10 +6276,6 @@ class DynStoDig extends DynElem {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.dyn.debug) {
console.log("DynToggleDig : " + lines[i]);
}
switch (key) {
case DynSave.StoDig:
break;
......@@ -6582,10 +6349,6 @@ class DynCommand extends DynElem {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.dyn.debug) {
console.log("DynCommand : " + lines[i]);
}
switch (key) {
case DynSave.Command:
break;
......@@ -6648,10 +6411,6 @@ class DynScript extends DynElem {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.dyn.debug) {
console.log("DynScript : " + lines[i]);
}
switch (key) {
case DynSave.Script:
break;
......@@ -6724,7 +6483,7 @@ class DynCommandDoubleClick extends DynElem {
object.setColorInverse(e.event === Event.MB1Down);
this.dyn.repaintNow = true;
break;
case Event.MB1ClickDoubleClick:
case Event.MB1DoubleClick:
if ((this.dyn.action_type1 & ActionType1.Confirm) !== 0) {
break;
}
......@@ -6748,10 +6507,6 @@ class DynCommandDoubleClick extends DynElem {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.dyn.debug) {
console.log("DynCommandDoubleClick : " + lines[i]);
}
switch (key) {
case DynSave.CommandDC:
break;
......@@ -6794,20 +6549,17 @@ class DynConfirm extends DynElem {
switch (e.event) {
case Event.MB1Down:
break;
case Event.Key_Return:
case Event.MB1Click:
case Event.ValueChanged:
let skip = 0;
if (((this.on_set !== 0 && this.on_reset === 0) ||
(this.on_reset !== 0 && this.on_set === 0)) &&
(this.dyn.total_action_type1 & ActionType1.ToggleDig) !== 0) {
for (let j = 0; j < this.dyn.elements.length; j++) {
if (this.dyn.elements.get(j).action_type1 ===
ActionType1.ToggleDig) {
let pname = this.dyn.parseAttrName(
this.dyn.elements.get(j).attribute);
if (this.dyn.elements[j].action_type1 === ActionType1.ToggleDig) {
let pname = this.dyn.parseAttrName(this.dyn.elements[j].attribute);
if (pname.name.substring(0, 1) === "&") {
pname.name = this.dyn.graph.get_reference_name(pname.name);
pname.name = this.dyn.graph.getReferenceName(pname.name);
}
switch (pname.database) {
......@@ -6851,10 +6603,6 @@ class DynConfirm extends DynElem {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.dyn.debug) {
console.log("DynConfirm : " + lines[i]);
}
switch (key) {
case DynSave.Confirm:
break;
......@@ -6882,7 +6630,6 @@ class DynConfirm extends DynElem {
}
class DynIncrAnalog extends DynElem {
attribute;
increment;
min_value;
max_value;
......@@ -6920,16 +6667,16 @@ class DynIncrAnalog extends DynElem {
case Database.Gdh:
if (typeId === Type.Int32) {
this.dyn.graph.getGdh()
.getObjectInfoInt(pname.name, DynIncrAnalog.action2, this);
.getObjectInfoInt(pname.name).then(this.action2);
} else {
this.dyn.graph.getGdh()
.getObjectInfoFloat(pname.name, DynIncrAnalog.action2, this);
.getObjectInfoFloat(pname.name).then(this.action2);
}
break;
case Database.Local:
let ret = this.dyn.graph.getLdb()
.getObjectInfo(this.dyn.graph, pname.name);
DynIncrAnalog.action2(0, this, 1, ret.value);
this.action2({id: 0, sts: 1, value: ret.value});
break;
}
break;
......@@ -6938,33 +6685,34 @@ class DynIncrAnalog extends DynElem {
return 1;
}
static action2(id, self, sts, value) {
if (!(sts & 1)) {
action2(res) {
if (!(res.sts & 1)) {
return;
}
let pname = self.dyn.parseAttrName(self.attribute);
let pname = this.dyn.parseAttrName(this.attribute);
if (pname === null) {
return 1;
}
let typeId = (pname.type < 0) ? Type.Float32 : pname.type;
value += self.increment;
if (!(self.min_value === 0 && self.max_value === 0)) {
let sts = res.sts;
let value = res.value + this.increment;
if (!(this.min_value === 0 && this.max_value === 0)) {
if (typeId === Type.Int32) {
value = clamp(value, Math.floor(self.min_value), Math.floor(self.max_value));
value = clamp(value, Math.floor(this.min_value), Math.floor(this.max_value));
} else {
value = clamp(value, self.min_value, self.max_value);
value = clamp(value, this.min_value, this.max_value);
}
}
if (pname.database === Database.Gdh) {
if (typeId === Type.Int32) {
sts = self.dyn.graph.getGdh().setObjectInfoInt(pname.name, value);
sts = this.dyn.graph.getGdh().setObjectInfoInt(pname.name, value);
} else {
sts = self.dyn.graph.getGdh().setObjectInfoFloat(pname.name, value);
sts = this.dyn.graph.getGdh().setObjectInfoFloat(pname.name, value);
}
} else if (pname.database === Database.Local) {
sts = self.dyn.graph.getLdb().setObjectInfo(self.dyn.graph, pname.name, value);
sts = this.dyn.graph.getLdb().setObjectInfo(this.dyn.graph, pname.name, value);
}
if (even(sts)) {
console.log("IncrAnalog " + pname.name);
......@@ -6979,10 +6727,6 @@ class DynIncrAnalog extends DynElem {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.dyn.debug) {
console.log("DynConfirm : " + lines[i]);
}
switch (key) {
case DynSave.IncrAnalog:
break;
......@@ -7014,7 +6758,6 @@ class DynIncrAnalog extends DynElem {
class DynRadioButton extends DynElem {
a;
attribute;
firstScan = true;
constructor(dyn) {
......@@ -7109,7 +6852,7 @@ class DynRadioButton extends DynElem {
let pname = this.dyn.parseAttrName(
gm_dyn.elements[j].attribute);
if (pname.name.substring(0, 1) === "&") {
pname.name = this.dyn.graph.get_reference_name(pname.name);
pname.name = this.dyn.graph.getReferenceName(pname.name);
}
setObjectInfo(pname, value);
}
......@@ -7120,7 +6863,7 @@ class DynRadioButton extends DynElem {
let pname = this.dyn.parseAttrName(this.attribute);
if (pname.name.substring(0, 1) === "&") {
pname.name = this.dyn.graph.get_reference_name(pname.name);
pname.name = this.dyn.graph.getReferenceName(pname.name);
}
value = true;
......@@ -7137,10 +6880,6 @@ class DynRadioButton extends DynElem {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.dyn.debug) {
console.log("DynRadioButton : " + lines[i]);
}
switch (key) {
case DynSave.RadioButton:
break;
......@@ -7175,10 +6914,6 @@ class DynTipText extends DynElem {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.dyn.debug) {
console.log("DynTipText : " + lines[i]);
}
switch (key) {
case DynSave.TipText:
break;
......@@ -7242,10 +6977,6 @@ class DynHelp extends DynElem {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.dyn.debug) {
console.log("DynHelp : " + lines[i]);
}
switch (key) {
case DynSave.Help:
break;
......@@ -7297,12 +7028,12 @@ class DynOpenGraph extends DynElem {
if (this.graph_object === null || this.graph_object === "") {
// Open classgraph for popup menu object
if ((this.dyn.total_action_type1 & ActionType1.PopupMenu) !== 0) {
let obj = this.dyn.elements.find(e => e.action_type1 === ActionType1.PopupMenu);
let obj = <DynPopupMenu>this.dyn.elements.find(e => e.action_type1 === ActionType1.PopupMenu);
if (obj) {
this.dyn.graph.command("open graph/class/instance=" + obj.ref_object);
}
} else if ((this.dyn.total_dyn_type1 & DynType1.HostObject) !== 0) {
let obj = this.dyn.elements.find(e => e.dyn_type1 === DynType1.HostObject);
let obj = <DynHostObject>this.dyn.elements.find(e => e.dyn_type1 === DynType1.HostObject);
if (obj) {
this.dyn.graph.command("open graph/class/instance=" + obj.hostobject);
}
......@@ -7322,10 +7053,6 @@ class DynOpenGraph extends DynElem {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.dyn.debug) {
console.log("DynOpenGraph : " + lines[i]);
}
switch (key) {
case DynSave.OpenGraph:
break;
......@@ -7383,10 +7110,6 @@ class DynOpenURL extends DynElem {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.dyn.debug) {
console.log("DynOpenURL : " + lines[i]);
}
switch (key) {
case DynSave.OpenURL:
break;
......@@ -7428,10 +7151,6 @@ class DynInputFocus extends DynElem {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.dyn.debug) {
console.log("DynInputFocus : " + lines[i]);
}
switch (key) {
case DynSave.InputFocus:
break;
......@@ -7793,7 +7512,7 @@ class DynSlider extends DynElem {
let info = object.get_info();
if (info.min_position !== info.max_position) {
if (!(this.max_value_p !== 0 && this.min_value_p !== 0 &&
if (!(this.max_value !== 0 && this.min_value !== 0 &&
this.max_value !== this.min_value)) {
this.max_value = info.max_value;
this.min_value = info.min_value;
......@@ -7824,7 +7543,7 @@ class DynSlider extends DynElem {
let setObjectInfo = function(pname, value, type) {
if (pname.database === Database.Gdh) {
return this.dyn.graph.getGdh()["setObjectInfo" + type](pname.name, value);
return this.dyn.graph.getGdh().setObjectInfo(pname.name, value, type);
} else if (pname.database === Database.Local) {
return this.dyn.graph.getLdb().setObjectInfo(this.dyn.graph, pname.name, value);
} else {
......@@ -7835,14 +7554,14 @@ class DynSlider extends DynElem {
let sts;
switch (pname.type) {
case Type.Float32:
sts = setObjectInfo(pname, value, "Float");
sts = setObjectInfo(pname, value, pname.type);
break;
case Type.Boolean:
sts = setObjectInfo(pname, (value > 0.5), "Boolean");
sts = setObjectInfo(pname, (value > 0.5), pname.type);
break;
default:
let ivalue = Math.floor(value > 0 ? value + 0.5 : value - 0.5);
sts = setObjectInfo(pname, ivalue, "Int");
sts = setObjectInfo(pname, ivalue, pname.type);
}
if (even(sts)) {
console.log("Slider error: " + this.attribute);
......@@ -7861,10 +7580,6 @@ class DynSlider extends DynElem {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.dyn.debug) {
console.log("DynSlider : " + lines[i]);
}
switch (key) {
case DynSave.Slider:
break;
......@@ -7921,10 +7636,6 @@ class DynFastCurve extends DynElem {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.dyn.debug) {
console.log("DynSlider : " + lines[i]);
}
switch (key) {
case DynSave.FastCurve:
break;
......@@ -8150,7 +7861,6 @@ class DynPulldownMenu extends DynElem {
class DynOptionMenu extends DynElem {
a;
update_a = null;
attribute;
text_attribute;
size_attribute;
update_attribute;
......@@ -8415,10 +8125,6 @@ class DynOptionMenu extends DynElem {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.dyn.debug) {
console.log("OptionsMenu : " + lines[i]);
}
if (key >= DynSave.OptionMenu_items_text0 && key <= DynSave.OptionMenu_items_text31) {
if (tokens.length > 1) {
this.items_text[key - DynSave.OptionMenu_items_text0] = lines[i].substring(5);
......@@ -8487,10 +8193,6 @@ class DynAnalogText extends DynOptionMenu {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.dyn.debug) {
console.log("AnalogText : " + lines[i]);
}
switch (key) {
case DynSave.AnalogText:
break;
......@@ -8510,7 +8212,6 @@ class DynAnalogText extends DynOptionMenu {
}
class DynSetValue extends DynElem {
attribute;
value;
constructor(dyn) {
......@@ -8524,10 +8225,6 @@ class DynSetValue extends DynElem {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.dyn.debug) {
console.log("AnalogText : " + lines[i]);
}
switch (key) {
case DynSave.SetValue:
break;
......@@ -8580,7 +8277,7 @@ class DynSetValue extends DynElem {
let setObjectInfo = function(pname, value, type) {
let sts = 0;
if (pname.database === Database.Gdh) {
sts = this.dyn.graph.getGdh()["setObjectInfo" + type](pname.name, value);
sts = this.dyn.graph.getGdh().setObjectInfo(pname.name, value, type);
} else if (pname.database === Database.Local) {
sts = this.dyn.graph.getLdb().setObjectInfo(this.dyn.graph, pname.name, value);
}
......@@ -8594,7 +8291,7 @@ class DynSetValue extends DynElem {
switch (pname.type) {
case Type.Float32:
let inputValue = parseFloat(this.value.trim());
sts = setObjectInfo(pname, inputValue, "Float");
sts = setObjectInfo(pname, inputValue, pname.type);
if (even(sts)) {
return 0;
}
......@@ -8608,7 +8305,7 @@ class DynSetValue extends DynElem {
case Type.Mask:
case Type.Enum:
let inputValue = parseInt(this.value.trim(), 10);
sts = setObjectInfo(pname, inputValue, "Int");
sts = setObjectInfo(pname, inputValue, pname.type);
if (even(sts)) {
return 0;
}
......@@ -8624,13 +8321,13 @@ class DynSetValue extends DynElem {
break;
}
sts = setObjectInfo(pname, inputValue, "Boolean");
sts = setObjectInfo(pname, inputValue, pname.type);
if (even(sts)) {
return 0;
}
break;
case Type.String:
sts = setObjectInfo(pname, inputValue, "String");
sts = setObjectInfo(pname, inputValue, pname.type);
if (even(sts)) {
return 0;
}
......@@ -8651,7 +8348,7 @@ class DynMethodToolbar extends DynElem {
method_object;
toolbar_type;
pname;
pname_name;
xm_mask_flags = 0;
xm_mask_opmethods = 0;
xm_mask_mntmethods = 0;
......@@ -8670,10 +8367,6 @@ class DynMethodToolbar extends DynElem {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.dyn.debug) {
console.log("MethodToolbar : " + lines[i]);
}
switch (key) {
case DynSave.MethodToolbar:
break;
......@@ -8707,46 +8400,46 @@ class DynMethodToolbar extends DynElem {
this.pname_name = pname.name;
let parsed_name = this.pname_name + ".XttMethodsMask.Flags";
this.dyn.graph.getGdh().getObjectInfoInt(parsed_name, DynMethodToolbar.connect2, this);
this.dyn.graph.getGdh().getObjectInfoInt(parsed_name).then(this.connect2);
}
static connect2(id, self, sts, value) {
if (sts & 1) {
self.xm_mask_flags = value;
connect2(res) {
if (res.sts & 1) {
this.xm_mask_flags = res.value;
if ((self.xm_mask_flags & XttMethodsFlagsMask.IsConfigured) === 0) {
self.mask_configure = 1;
self.mask_store = 1;
self.connect5();
if ((this.xm_mask_flags & XttMethodsFlagsMask.IsConfigured) === 0) {
this.mask_configure = 1;
this.mask_store = 1;
this.connect5();
} else {
let parsed_name = self.pname_name + ".XttMethodsMask.OpMethods";
self.dyn.graph.getGdh().getObjectInfoInt(parsed_name, self.connect3, self);
let parsed_name = this.pname_name + ".XttMethodsMask.OpMethods";
this.dyn.graph.getGdh().getObjectInfoInt(parsed_name).then(this.connect3);
}
} else {
self.mask_configure = 1;
self.connect5();
this.mask_configure = 1;
this.connect5();
}
}
static connect3(id, self, sts, value) {
if (sts & 1) {
self.xm_mask_opmethods = value;
connect3(res) {
if (res.sts & 1) {
this.xm_mask_opmethods = res.value;
} else {
console.log("DynMethodToolbar: " + self.pname_name);
self.mask_configure = 1;
console.log("DynMethodToolbar: " + this.pname_name);
this.mask_configure = 1;
}
let parsed_name = self.pname_name + ".XttMethodsMask.MntMethods";
self.dyn.graph.getGdh().getObjectInfoInt(parsed_name, self.connect4, self);
let parsed_name = this.pname_name + ".XttMethodsMask.MntMethods";
this.dyn.graph.getGdh().getObjectInfoInt(parsed_name).then(this.connect4);
}
static connect4(id, self, sts, value) {
if (sts & 1) {
self.xm_mask_mntmethods = value;
connect4(res) {
if (res.sts & 1) {
this.xm_mask_mntmethods = res.value;
} else {
console.log("DynMethodToolbar: " + self.pname_name);
self.mask_configure = 1;
console.log("DynMethodToolbar: " + this.pname_name);
this.mask_configure = 1;
}
self.connect5();
this.connect5();
}
connect5() {
......@@ -8968,8 +8661,7 @@ class DynMethodPulldownMenu extends DynElem {
this.pname_name = pname.name;
let parsed_name = this.pname_name + ".XttMethodsMask.Flags";
this.dyn.graph.getGdh()
.getObjectInfoInt(parsed_name, DynMethodPulldownMenu.action2, this);
this.dyn.graph.getGdh().getObjectInfoInt(parsed_name).then(this.action2);
}
break;
......@@ -9045,46 +8737,45 @@ class DynMethodPulldownMenu extends DynElem {
return 1;
}
static action2(id, self, sts, value) {
if (sts & 1) {
self.xm_mask_flags = value;
action2(res) {
if (res.sts & 1) {
this.xm_mask_flags = res.value;
if ((self.xm_mask_flags & XttMethodsFlagsMask.IsConfigured) === 0) {
self.mask_configure = 1;
self.mask_store = 1;
self.action5();
if ((this.xm_mask_flags & XttMethodsFlagsMask.IsConfigured) === 0) {
this.mask_configure = 1;
this.mask_store = 1;
this.action5();
} else {
let parsed_name = self.pname_name + ".XttMethodsMask.OpMethods";
let parsed_name = this.pname_name + ".XttMethodsMask.OpMethods";
self.dyn.graph.getGdh()
.getObjectInfoInt(parsed_name, self.action3, self);
this.dyn.graph.getGdh().getObjectInfoInt(parsed_name).then(this.action3);
}
} else {
self.mask_configure = 1;
self.action5();
this.mask_configure = 1;
this.action5();
}
}
static action3(id, self, sts, value) {
if (sts & 1) {
self.xm_mask_opmethods = value;
action3(res) {
if (res.sts & 1) {
this.xm_mask_opmethods = res.value;
} else {
console.log("DynMethodToolbar: " + self.pname_name);
self.mask_configure = 1;
console.log("DynMethodToolbar: " + this.pname_name);
this.mask_configure = 1;
}
let parsed_name = self.pname_name + ".XttMethodsMask.MntMethods";
self.dyn.graph.getGdh().getObjectInfoInt(parsed_name, self.action4, self);
let parsed_name = this.pname_name + ".XttMethodsMask.MntMethods";
this.dyn.graph.getGdh().getObjectInfoInt(parsed_name).then(this.action4);
}
static action4(id, self, sts, value) {
if (sts & 1) {
self.xm_mask_mntmethods = value;
action4(res) {
if (res.sts & 1) {
this.xm_mask_mntmethods = res.value;
} else {
console.log("DynMethodToolbar: " + self.pname_name);
self.mask_configure = 1;
console.log("DynMethodToolbar: " + this.pname_name);
this.mask_configure = 1;
}
self.action5();
this.action5();
}
action5() {
......@@ -9257,10 +8948,6 @@ class DynPopupMenu extends DynElem {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.dyn.debug) {
console.log("DynResetDig : " + lines[i]);
}
switch (key) {
case DynSave.PopupMenu:
break;
......
......@@ -75,7 +75,7 @@ class GraphLocalDb {
let typeId = this.getTypeId(attributeName);
let name = this.getName(attributeName);
if (typeId === 0) {
return i;
return 0;
}
let id = this.nameToId(owner, name);
......@@ -212,7 +212,7 @@ class Graph {
constructor(appl) {
this.appl = appl;
if (typeof InstallTrigger !== 'undefined') {
if (navigator.userAgent.toLowerCase().indexOf('firefox') > -1) {
// Firefox is not os fast...
this.scan_time = 1;
this.fast_scan_time = 1;
......@@ -249,31 +249,27 @@ class Graph {
gdh_init_cb() {
if (this.priv === null) {
this.gdh.login("", "", this.login_cb, this);
this.gdh.login("", "").then(this.login_cb);
}
this.ctx.traceConnect();
this.gdh.refObjectInfoList(this.trace_connected);
}
login_cb(id, data, sts, result) {
console.log("Login:", sts, result);
this.priv = (sts & 1) ? result : 0;
this.gdh.refObjectInfoList().then(e => this.trace_cyclic());
}
trace_connected(id, sts) {
this.trace_cyclic();
login_cb(res) {
console.log("Login:", res.sts, res.value);
this.priv = (res.sts & 1) ? res.value : 0;
}
trace_cyclic() {
if (this.frame.nogdh) {
this.trace_scan(0, 0);
this.trace_scan();
} else {
this.gdh.getRefObjectInfoAll(this.trace_scan);
}
}
trace_scan(id, sts) {
trace_scan() {
this.scan_time = this.ctx.scantime;
this.fast_scan_time = this.ctx.fast_scantime;
this.animation_scan_time = this.ctx.animation_scantime;
......@@ -306,9 +302,6 @@ class Graph {
return ret;
}
let dyn = new Dyn(this);
if (type !== UserdataCbType.NodeClass) {
dyn.userdata = this;
}
ret.userdata = dyn;
ret.row = dyn.open(lines, row);
}
......@@ -354,7 +347,6 @@ class Graph {
case Event.MB1Down:
case Event.MB1DoubleClick:
case Event.MB3Press:
case Event.ValueChanged:
case Event.SliderMoveStart:
case Event.SliderMoveEnd:
case Event.SliderMoved:
......@@ -712,6 +704,18 @@ class Graph {
return Math.min(this.scan_time, this.animation_scan_time);
}
setScanTime(scan_time) {
this.scan_time = scan_time;
}
setFastScanTime(fast_scan_time) {
this.fast_scan_time = fast_scan_time;
}
setAnimationScanTime(animation_scan_time) {
this.animation_scan_time = animation_scan_time;
}
command(cmd) {
if (this.appl) {
return this.appl.command(cmd);
......@@ -754,4 +758,9 @@ class Graph {
loadCtx(file, read_cb) {
return this.frame.readGrowWindow(file, read_cb);
}
getReferenceName(name) {
// TODO
return null;
}
}
\ No newline at end of file
......@@ -1653,20 +1653,93 @@ enum EventType {
}
enum Event {
Null,
MB1Click,
MB1Up = 2,
MB1Down,
MB1DoubleClick,
CursorMotion,
MB1Press,
MB2Click,
MB2DoubleClick,
MB2Press,
MB1ClickShift,
MB1DoubleClickShift,
MB1PressShift,
MB2ClickShift,
MB2DoubleClickShift,
MB2PressShift,
MB1ClickCtrl,
MB1DoubleClickCtrl,
MB1PressCtrl,
MB2ClickCtrl,
MB2DoubleClickCtrl,
MB2PressCtrl,
MB1ClickShiftCtrl,
MB1DoubleClickShiftCtrl,
MB1PressShiftCtrl,
MB2ClickShiftCtrl,
MB2DoubleClickShiftCtrl,
MB2PressShiftCtrl,
MB3Click,
MB3Press,
ButtonRelease,
ButtonMotion,
ValueChanged,
MenuCreate,
MenuActivated,
MenuDelete,
Exposure,
Enter,
Leave,
CursorMotion,
Init,
PasteSequenceStart,
PasteSequenceEnd,
VisibilityUnobscured,
VisibilityObscured,
SelectClear,
ObjectMoved,
ObjectDeleted,
AnnotationInput,
Radiobutton,
Key_Return,
Key_Up,
Key_Down,
Key_Right,
Key_Left,
Key_PageUp,
Key_PageDown,
Key_BackSpace,
Key_PF1,
Key_PF2,
Key_PF3,
Key_PF4,
CreateGrowObject,
GrowDynamics,
SliderMoveStart,
SliderMoved,
SliderMoveEnd,
MB3Press,
SliderMoved,
HotRequest,
MB1Down,
MB1Up,
MB2Down,
MB2Up,
MB3Down,
MB3Up,
Key_Tab,
Map,
Unmap,
Resized,
Translate,
TipText,
Key_Ascii,
InputFocusLost,
InputFocusGained,
InputFocusInit,
Key_CtrlAscii,
Key_ShiftTab,
Key_Escape,
MenuActivated,
MenuCreate,
MenuDelete,
ScrollUp,
ScrollDown,
AnteUndo,
PostUndo,
Signal
}
......
class GlowArrow {
ctx: GrowCtx;
p_dest: GlowPoint;
p1: GlowPoint;
p2: GlowPoint;
arrow_width: Number;
arrow_length: Number;
draw_type: DrawType;
line_width: Number;
constructor(ctx) {
this.ctx = ctx;
this.p_dest = new GlowPoint();
this.p1 = new GlowPoint();
this.p2 = new GlowPoint();
}
open(lines, row) {
let i;
for (i = row; i < lines.length; i++) {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
switch (key) {
case GlowSave.Arrow:
break;
case GlowSave.Arrow_arrow_width:
this.arrow_width = Number(tokens[1]);
break;
case GlowSave.Arrow_arrow_length:
this.arrow_length = Number(tokens[1]);
break;
case GlowSave.Arrow_draw_type:
this.draw_type = DrawType(tokens[1]);
break;
case GlowSave.Arrow_line_width:
this.line_width = parseInt(tokens[1], 10);
break;
case GlowSave.Arrow_p_dest:
i = this.p_dest.open(lines, i + 1);
break;
case GlowSave.Arrow_p1:
i = this.p1.open(lines, i + 1);
break;
case GlowSave.Arrow_p2:
i = this.p2.open(lines, i + 1);
break;
case GlowSave.End:
return i;
default:
console.log("Syntax error in GlowArrow");
break;
}
}
return i;
}
}
\ No newline at end of file
......@@ -329,7 +329,6 @@ class GlowColor {
}
class GlowCustomColors {
debug = false;
colors_size = DrawType.CustomColor__ - DrawType.CustomColor1;
colors = new Array(this.colors_size);
colortheme_lightness = 0;
......@@ -380,10 +379,6 @@ class GlowCustomColors {
this.colors[j][0] = parseFloat(tokens[0]);
this.colors[j][1] = parseFloat(tokens[1]);
this.colors[j][2] = parseFloat(tokens[2]);
if (this.debug) {
console.log(j, this.colors[j][0], this.colors[j][1],
this.colors[j][2]);
}
}
break;
case GlowSave.End:
......
......@@ -13,7 +13,6 @@ class GrowCtxWindow {
class GrowCtx extends Rect {
appl = null;
debug = false;
antiAliasing = 0;
name = null;
version = 0;
......@@ -110,10 +109,6 @@ class GrowCtx extends Rect {
let tokens = lines[i].split(' ');
let key = parseInt(tokens[0], 10);
if (this.debug) {
console.log("ctx : " + lines[i]);
}
switch (key) {
case GlowSave.Ctx:
break;
......
......@@ -470,10 +470,6 @@ class GrowTrend extends GrowRect {
return null;
}
getClassUserData() {
return this.nc.userdata;
}
getUserData() {
return this.userdata;
}
......
......@@ -32,8 +32,8 @@ class OpWindMenu {
gdh_init_cb() {
let oid = new PwrtObjid(0, 0);
this.user = "Default";
this.gdh.login("", "", this.login_cb, this);
this.gdh.getOpwindMenu(this.get_opplace(), this.get_menu_cb, 999);
this.gdh.login("", "").then(this.login_cb);
this.gdh.getOpwindMenu(this.get_opplace()).then(this.get_menu_cb);
}
add_menu_button(context, text) {
......@@ -49,9 +49,9 @@ class OpWindMenu {
return button;
}
get_menu_cb(id, data, sts, result) {
get_menu_cb(res) {
let result = res.value;
this.info = result;
console.log("Menu received", sts, data, result.buttons.length);
let context = document.getElementById("opwindmenu");
document.getElementById("opwind_title").innerHTML = result.title;
......@@ -89,7 +89,7 @@ class OpWindMenu {
passwd = c.crypt("aa", passwd);
this.user = user;
this.gdh.login(user, passwd, this.login_cb, this);
this.gdh.login(user, passwd).then(this.login_cb);
});
document.getElementById("cancel_button")
.addEventListener("click", function (event) {
......@@ -102,7 +102,7 @@ class OpWindMenu {
document.getElementById("login_frame").style.height = '0px';
this.priv = 0;
this.user = "Default";
this.gdh.login("", "", this.login_cb, this);
this.gdh.login("", "").then(this.login_cb);
});
document.getElementById("login_user").innerHTML = "";
......@@ -200,10 +200,9 @@ class OpWindMenu {
}
}
login_cb(id, data, sts, result) {
console.log("Login:", sts, result);
if (sts & 1) {
this.priv = result;
login_cb(res) {
if (res.sts & 1) {
this.priv = res.value;
sessionStorage.setItem("pwr_privilege", String(this.priv));
if (this.user_text !== null) {
this.user_text.textContent = this.user + " on " + this.host;
......
......@@ -32,9 +32,9 @@ class Xtt {
let y = event.pageY - this.ctx.gdraw.offset_top;
let x = event.pageX;
if (event.shiftKey) {
xtt.ctx.event_handler(Event.MB1ClickShift, x, y);
this.ctx.event_handler(Event.MB1ClickShift, x, y);
} else {
xtt.ctx.event_handler(Event.MB1Click, x, y);
this.ctx.event_handler(Event.MB1Click, x, y);
}
});
document.addEventListener("keydown", function (event) {
......@@ -62,9 +62,7 @@ class Xtt {
.addEventListener("click", function (event) {
let o = this.ctx.get_select();
if (o.userdata instanceof XttItemObject) {
let newwindow = window.open("", "_blank");
this.ctx.gdh.getObject(o.userdata.objid, GdhOp.GET_OP_METHOD_GRAPH,
this.open_graph_cb, newwindow);
this.ctx.gdh.getObject(o.userdata.objid, GdhOp.GET_OP_METHOD_GRAPH).then(this.open_graph_cb);
}
console.log("toolitem1 event");
});
......@@ -72,10 +70,7 @@ class Xtt {
.addEventListener("click", function (event) {
let o = this.ctx.get_select();
if (o.userdata instanceof XttItemObject) {
let newwindow = window.open("", "_blank");
this.ctx.gdh.getObject(o.userdata.objid,
GdhOp.GET_OP_METHOD_OBJECTGRAPH, this.open_objectgraph_cb,
newwindow);
this.ctx.gdh.getObject(o.userdata.objid, GdhOp.GET_OP_METHOD_OBJECTGRAPH).then(this.open_objectgraph_cb);
}
console.log("toolitem2 event");
});
......@@ -84,9 +79,7 @@ class Xtt {
console.log("toolitem1 event");
let o = this.ctx.get_select();
if (o.userdata instanceof XttItemObject) {
let newwindow = window.open("", "_blank");
this.ctx.gdh.getObject(o.userdata.objid, GdhOp.GET_OP_METHOD_PLC,
this.open_plc_cb, newwindow);
this.ctx.gdh.getObject(o.userdata.objid, GdhOp.GET_OP_METHOD_PLC).then(this.open_plc_cb);
} else if (o.userdata instanceof XttItemCrr) {
let idx = o.userdata.name.lastIndexOf('-');
let ostring = "";
......@@ -117,7 +110,7 @@ class Xtt {
document.getElementById("toolitem6")
.addEventListener("click", function (event) {
let o = this.ctx.get_select();
this.ctx.gdh.crrSignal(o.userdata.objid, this.open_crr_cb, o);
this.ctx.gdh.crrSignal(o.userdata.objid).then(this.open_crr_cb(o));
console.log("toolitem6 event");
});
document.getElementById("toolitem7")
......@@ -132,9 +125,8 @@ class Xtt {
return;
}
if (o.userdata instanceof XttItemObject) {
let newwindow = window.open("", "_blank");
this.ctx.gdh.getObject(o.userdata.objid,
GdhOp.GET_OP_METHOD_HELPCLASS, this.open_helpclass_cb, newwindow);
GdhOp.GET_OP_METHOD_HELPCLASS).then(this.open_helpclass_cb);
}
});
......@@ -153,45 +145,46 @@ class Xtt {
gdh_init_cb() {
if (this.priv === null) {
this.ctx.gdh.login("", "", this.login_cb, this);
this.ctx.gdh.login("", "").then(this.login_cb);
}
let oid = new PwrtObjid(0, 0);
this.ctx.gdh.getAllXttChildren(oid, this.open_children_cb,
new XttOpenChildrenData(null, null));
this.ctx.gdh.getAllXttChildren(oid).then(this.open_children_cb(new XttOpenChildrenData(null, null)));
this.ctx.gdh.listSent = true;
this.trace_cyclic();
}
login_cb(id, data, sts, result) {
console.log("Login:", sts, result);
this.priv = (sts & 1) ? result : 0;
login_cb(res) {
console.log("Login:", res.sts, res.value);
this.priv = (res.sts & 1) ? res.value : 0;
}
open_children_cb(id, data, sts, result) {
open_children_cb(child) {
return function(res) {
let result = res.value;
this.ctx.set_nodraw();
for (let i = 0; i < result.length; i++) {
if (data.node === null) {
if (child.node === null) {
result[i].full_name = result[i].name;
new XttItemObject(this, result[i], null, Dest.AFTER);
} else {
result[i].full_name =
data.node.userdata.full_name + "-" + result[i].name;
new XttItemObject(this, result[i], data.node, Dest.INTOLAST);
child.node.userdata.full_name + "-" + result[i].name;
new XttItemObject(this, result[i], child.node, Dest.INTOLAST);
}
}
this.ctx.configure();
if (data.open_next !== null) {
if (data.open_next.length === 0) {
if (child.open_next !== null) {
if (child.open_next.length === 0) {
this.ctx.reset_nodraw();
return;
}
let child = this.ctx.a.get_first_child(data.node);
let child = this.ctx.a.get_first_child(child.node);
while (child !== null) {
if (child.userdata.name === data.open_next[0]) {
if (data.open_next.length === 1) {
if (child.userdata.name === child.open_next[0]) {
if (child.open_next.length === 1) {
child.set_select(true);
child.set_invert(true);
if (!this.ctx.is_visible(child)) {
......@@ -199,12 +192,12 @@ class Xtt {
}
window.focus(); // Doesn't work
} else {
data.open_next.splice(0, 1);
if (data.open_next[0] === '.') {
data.open_next.splice(0, 1);
child.userdata.open_attributes(this, data.open_next);
child.open_next.splice(0, 1);
if (child.open_next[0] === '.') {
child.open_next.splice(0, 1);
child.userdata.open_attributes(this, child.open_next);
} else {
child.userdata.open_children(this, data.open_next);
child.userdata.open_children(child.open_next);
}
}
break;
......@@ -216,85 +209,87 @@ class Xtt {
this.ctx.reset_nodraw();
this.ctx.draw();
}
}
open_attributes_cb(id, data, sts, result) {
open_attributes_cb(child) {
return function(res) {
let result = res.value;
this.ctx.set_nodraw();
for (let i = 0; i < result.length; i++) {
result[i].objid = data.node.userdata.objid;
result[i].full_name = data.node.userdata.full_name + "." + result[i].name;
result[i].objid = child.node.userdata.objid;
result[i].full_name = child.node.userdata.full_name + "." + result[i].name;
if ((result[i].flags & Adef.Array) !== 0) {
new XttItemAttrArray(this, result[i], data.node, Dest.INTOLAST);
new XttItemAttrArray(this, result[i], child.node, Dest.INTOLAST);
} else if ((result[i].flags & Adef.Class) !== 0) {
new XttItemAttrObject(this, result[i], data.node, Dest.INTOLAST);
new XttItemAttrObject(this, result[i], child.node, Dest.INTOLAST);
} else {
new XttItemAttr(this, result[i], data.node, Dest.INTOLAST);
new XttItemAttr(this, result[i], child.node, Dest.INTOLAST);
}
}
this.ctx.configure();
if (data.open_next !== null) {
if (data.open_next.length === 0) {
if (child.open_next !== null) {
if (child.open_next.length === 0) {
this.ctx.reset_nodraw();
return;
}
let child = this.ctx.a.get_first_child(data.node);
while (child !== null) {
if (child.userdata.name === data.open_next[0]) {
if (data.open_next.length === 1) {
child.set_select(true);
child.set_invert(true);
if (!this.ctx.is_visible(child)) {
this.ctx.scroll(child.ll_y, 0.50);
let child2 = this.ctx.a.get_first_child(child.node);
while (child2 !== null) {
if (child2.userdata.name === child.open_next[0]) {
if (child.open_next.length === 1) {
child2.set_select(true);
child2.set_invert(true);
if (!this.ctx.is_visible(child2)) {
this.ctx.scroll(child2.ll_y, 0.50);
}
window.focus(); // Doesn't work
} else {
data.open_next.splice(0, 1);
child.userdata.open_attributes(this, data.open_next);
child.open_next.splice(0, 1);
child2.userdata.open_attributes(this, child.open_next);
}
break;
}
child = this.ctx.a.get_next_sibling(child);
child2 = this.ctx.a.get_next_sibling(child2);
}
}
this.ctx.reset_nodraw();
this.ctx.draw();
}
}
open_plc_cb(id, data, sts, result: ObjectInfo) {
if ((sts & 1) === 0) {
data.document.write("Error status " + sts);
} else {
let param1;
if (result.param1 === "") {
param1 = "";
open_plc_cb(res) {
let w = window.open("", "_blank");
if ((res.sts & 1) === 0) {
w.document.write("Error status " + res.sts);
} else {
param1 = "&obj=" + result.param1;
}
console.log("flow.html?vid=" + result.objid.vid + "&oix=" +
result.objid.oix + param1);
data.location.href =
"flow.html?vid=" + result.objid.vid + "&oix=" + result.objid.oix +
param1;
data.document.title = "Trace " + result.fullname;
let result = res.value;
let param1 = result.param1 ? ("&obj=" + result.param1) : "";
w.location.href = "flow.html?vid=" + result.objid.vid + "&oix=" +
result.objid.oix + param1;
w.document.title = "Trace " + result.fullname;
}
}
open_objectgraph_cb(id, data, sts, result: ObjectInfo) {
if ((sts & 1) === 0) {
data.document.write("Error status " + sts);
open_objectgraph_cb(res) {
let w = window.open("", "_blank");
if ((res.sts & 1) === 0) {
w.document.write("Error status " + res.sts);
} else {
data.location.href =
let result = res.value;
w.location.href =
"ge.html?graph=" + result.param1 + "&instance=" + result.fullname;
data.document.title = result.fullname;
w.document.title = result.fullname;
}
}
open_graph_cb(id, data, sts, result: ObjectInfo) {
if ((sts & 1) === 0) {
data.document.write("Error status " + sts);
open_graph_cb(res) {
let w = window.open("", "_blank");
if ((res.sts & 1) === 0) {
w.document.write("Error status " + res.sts);
} else {
let result = res.value;
let idx = result.param1.indexOf('.');
if (idx !== -1) {
result.param1 = result.param1.substring(0, idx);
......@@ -305,25 +300,28 @@ class Xtt {
instancestr = "&instance=" + result.fullname;
}
data.location.href = "ge.html?graph=" + result.param1 + instancestr;
data.document.title = result.param1;
w.location.href = "ge.html?graph=" + result.param1 + instancestr;
w.document.title = result.param1;
}
}
open_crr_cb(id, node, sts, crrdata) {
if ((sts & 1) === 0) {
open_crr_cb(node) {
return function(res) {
if ((res.sts & 1) === 0) {
return;
}
node.userdata.open_crossreferences(this, crrdata);
node.userdata.open_crossreferences(res.value);
}
}
open_helpclass_cb(id, data, sts, result: ObjectInfo) {
if ((sts & 1) === 0) {
data.document.write("Error status " + sts);
open_helpclass_cb(res) {
let w = window.open("", "_blank");
if ((res.sts & 1) === 0) {
w.document.write("Error status " + res.sts);
} else {
console.log("open_helpclass", result.param1);
data.location.href =
location.protocol + "//" + location.host + result.param1;
console.log("open_helpclass", res.value.param1);
w.location.href =
location.protocol + "//" + location.host + res.value.param1;
}
}
......@@ -336,12 +334,12 @@ class Xtt {
switch (event) {
case Event.ObjectDeleted:
if (object.userdata instanceof XttItemAttr) {
object.userdata.scan_close(this);
object.userdata.scan_close();
}
break;
case Event.MB1Click:
if (object.in_icon(x, y)) {
item.open_children(this, null);
item.open_children(null);
} else {
if (object.select) {
object.set_select(false);
......@@ -400,7 +398,7 @@ class Xtt {
let o = this.ctx.get_select();
if (o !== null) {
item = o.userdata;
item.open_children(this, null);
item.open_children(null);
}
break;
case Event.Key_Left:
......@@ -420,15 +418,13 @@ class Xtt {
case Event.Key_CtrlR:
let o = this.ctx.get_select();
if (o !== null) {
this.ctx.gdh.crrSignal(o.userdata.objid, this.open_crr_cb, o);
this.ctx.gdh.crrSignal(o.userdata.objid).then(this.open_crr_cb(o));
}
break;
case Event.Key_CtrlL:
let o = this.ctx.get_select();
if (o.userdata instanceof XttItemObject) {
let newwindow = window.open("", "_blank");
this.ctx.gdh.getObject(o.userdata.objid, GdhOp.GET_OP_METHOD_PLC,
this.open_plc_cb, newwindow);
this.ctx.gdh.getObject(o.userdata.objid, GdhOp.GET_OP_METHOD_PLC).then(this.open_plc_cb);
} else if (o.userdata instanceof XttItemCrr) {
let idx = o.userdata.name.lastIndexOf('-');
let ostring = "";
......@@ -443,10 +439,7 @@ class Xtt {
let o = this.ctx.get_select();
if (o.userdata instanceof XttItemObject) {
console.log("CtrlG", o.userdata.objid.vid, o.userdata.objid.oix);
let newwindow = window.open("", "_blank");
this.ctx.gdh.getObject(o.userdata.objid,
GdhOp.GET_OP_METHOD_OBJECTGRAPH, this.open_objectgraph_cb,
newwindow);
this.ctx.gdh.getObject(o.userdata.objid, GdhOp.GET_OP_METHOD_OBJECTGRAPH).then(this.open_objectgraph_cb);
}
break;
default:
......@@ -526,7 +519,7 @@ class Xtt {
window.focus(); // Doesn't work
} else {
path.splice(0, 1);
(<XttItemObject> this.ctx.a.get(j).userdata).open_children(this, path);
(<XttItemObject> this.ctx.a.get(j).userdata).open_children(path);
}
break;
}
......@@ -537,13 +530,12 @@ class Xtt {
this.ctx.gdh.getRefObjectInfoAll(this.trace_scan);
}
trace_scan(id, sts) {
trace_scan() {
this.scan_update = false;
let self = this;
this.ctx.a.forEach(function (e) {
let item = e.userdata;
if (item instanceof XttItemAttr) {
item.scan(self);
item.scan();
}
});
if (this.scan_update) {
......@@ -567,6 +559,7 @@ class Xtt {
}
class XttItemObject {
xtt: Xtt;
objid: PwrtObjid;
cid: number;
name: string;
......@@ -575,6 +568,7 @@ class XttItemObject {
node: PlowNode;
constructor(xtt, object_info, destination, destCode) {
this.xtt = xtt;
this.objid = object_info.objid;
this.cid = object_info.cid;
this.name = object_info.name;
......@@ -590,67 +584,65 @@ class XttItemObject {
this.node.set_annotation_pixmap(0, object_info.has_children ? Bitmaps.map : Bitmaps.leaf);
}
open_children(xtt, open_next) {
open_children(open_next) {
if (this.node.node_open !== 0) {
this.close(xtt);
this.close();
} else if (!this.has_children) {
this.open_attributes(xtt, null);
this.open_attributes(null);
} else {
xtt.ctx.gdh.getAllXttChildren(this.objid, xtt.open_children_cb,
new XttOpenChildrenData(this.node, open_next));
this.xtt.ctx.gdh.getAllXttChildren(this.objid).then(this.xtt.open_children_cb(new XttOpenChildrenData(this.node, open_next)));
this.node.node_open |= Open.CHILDREN;
this.node.set_annotation_pixmap(0, Bitmaps.openmap);
}
}
open_attributes(xtt, open_next) {
open_attributes(open_next) {
if (this.node.node_open === 0) {
xtt.ctx.gdh.getAllClassAttributes(this.cid, this.objid,
xtt.open_attributes_cb, new XttOpenChildrenData(this.node, open_next));
this.xtt.ctx.gdh.getAllClassAttributes(this.cid, this.objid).then(this.xtt.open_attributes_cb(new XttOpenChildrenData(this.node, open_next)));
this.node.node_open |= Open.ATTRIBUTES;
xtt.ctx.configure();
xtt.ctx.draw();
this.xtt.ctx.configure();
this.xtt.ctx.draw();
} else {
this.close(xtt);
this.close();
}
}
open_crossreferences(xtt, crrdata) {
open_crossreferences(crrdata) {
if (this.node.node_open === 0) {
for (let i = 0; i < crrdata.length; i++) {
new XttItemCrr(xtt, crrdata[i], this.node, Dest.INTOLAST);
new XttItemCrr(this.xtt, crrdata[i], this.node, Dest.INTOLAST);
}
this.node.node_open |= Open.CROSSREFERENCES;
xtt.ctx.configure();
xtt.ctx.draw();
this.xtt.ctx.configure();
this.xtt.ctx.draw();
} else {
this.close(xtt);
this.close();
}
}
close(xtt) {
close() {
if (this.node.node_open & Open.CHILDREN) {
xtt.ctx.close_node(this.node);
this.xtt.ctx.close_node(this.node);
this.node.node_open &= ~Open.CHILDREN;
this.node.set_annotation_pixmap(0, Bitmaps.map);
xtt.ctx.configure();
xtt.ctx.draw();
this.xtt.ctx.configure();
this.xtt.ctx.draw();
} else if (this.node.node_open & Open.ATTRIBUTES) {
xtt.ctx.close_node(this.node);
this.xtt.ctx.close_node(this.node);
this.node.node_open &= ~Open.ATTRIBUTES;
xtt.ctx.configure();
xtt.ctx.draw();
this.xtt.ctx.configure();
this.xtt.ctx.draw();
} else if (this.node.node_open & Open.CROSSREFERENCES) {
xtt.ctx.close_node(this.node);
this.xtt.ctx.close_node(this.node);
this.node.node_open &= ~Open.CROSSREFERENCES;
xtt.ctx.configure();
xtt.ctx.draw();
this.xtt.ctx.configure();
this.xtt.ctx.draw();
} else {
let parent = xtt.ctx.get_parent_object(this.node);
let parent = this.xtt.ctx.get_parent_object(this.node);
if (parent !== null) {
parent.userdata.close(xtt);
parent.userdata.close();
parent.set_select(true);
parent.set_invert(true);
}
......@@ -659,6 +651,7 @@ class XttItemObject {
}
class XttItemAttr {
xtt: Xtt;
name: string;
objid: PwrtObjid;
full_name: string;
......@@ -671,6 +664,7 @@ class XttItemAttr {
node: PlowNode;
constructor(xtt, info, destination, destCode) {
this.xtt = xtt;
this.name = info.name;
this.objid = info.objid;
this.full_name = info.full_name;
......@@ -687,15 +681,15 @@ class XttItemAttr {
this.refid = xtt.ctx.gdh.refObjectInfo(this.full_name, info.type, 1);
}
open_children(xtt, open_next) {
xtt.openValueInputDialog(this, "Enter value");
open_children(open_next) {
this.xtt.openValueInputDialog(this, "Enter value");
}
set_value(xtt, value) {
set_value(value) {
switch (this.type) {
case Type.Float32:
let inputValue = parseFloat(value.trim());
xtt.ctx.gdh.setObjectInfoFloat(this.full_name, inputValue);
this.xtt.ctx.gdh.setObjectInfoFloat(this.full_name, inputValue);
break;
case Type.Int8:
case Type.Int16:
......@@ -708,37 +702,37 @@ class XttItemAttr {
case Type.Enum:
case Type.Boolean:
let inputValue = parseInt(value.trim(), 10);
xtt.ctx.gdh.setObjectInfoInt(this.full_name, inputValue);
this.xtt.ctx.gdh.setObjectInfoInt(this.full_name, inputValue);
break;
case Type.String:
case Type.Time:
case Type.DeltaTime:
case Type.AttrRef:
case Type.Objid:
xtt.ctx.gdh.setObjectInfoString(this.full_name, value);
this.xtt.ctx.gdh.setObjectInfoString(this.full_name, value);
break;
default:
break;
}
}
open_attributes(xtt, open_next) {
open_attributes(open_next) {
}
close(xtt) {
let parent = xtt.ctx.get_parent_object(this.node);
close() {
let parent = this.xtt.ctx.get_parent_object(this.node);
if (parent !== null) {
parent.userdata.close(xtt);
parent.userdata.close();
parent.set_select(true);
parent.set_invert(true);
}
}
scan(xtt) {
scan() {
if (!this.refid) {
return;
}
let value = xtt.ctx.gdh.getObjectRefInfo(this.refid);
let value = this.xtt.ctx.gdh.getObjectRefInfo(this.refid);
if (this.firstScan || value !== this.old_value) {
let value_str;
......@@ -768,17 +762,18 @@ class XttItemAttr {
this.old_value = value;
this.node.set_annotation(1, value_str);
xtt.scan_update = true;
this.xtt.scan_update = true;
}
this.firstScan = false;
}
scan_close(xtt) {
xtt.ctx.gdh.unrefObjectInfo(this.refid);
scan_close() {
this.xtt.ctx.gdh.unrefObjectInfo(this.refid);
}
}
class XttItemAttrArray {
xtt: Xtt;
name: string;
objid: PwrtObjid;
full_name: string;
......@@ -789,6 +784,7 @@ class XttItemAttrArray {
node: PlowNode;
constructor(xtt, info, destination, destCode) {
this.xtt = xtt;
this.name = info.name;
this.objid = info.objid;
this.full_name = info.full_name;
......@@ -803,11 +799,11 @@ class XttItemAttrArray {
xtt.ctx.insertNode(this.node, destination, destCode);
}
open_children(xtt, open_next) {
this.open_attributes(xtt, open_next);
open_children(open_next) {
this.open_attributes(open_next);
}
open_attributes(xtt, open_next) {
open_attributes(open_next) {
let info = new AttributeInfo();
info.objid = this.objid;
......@@ -819,34 +815,34 @@ class XttItemAttrArray {
info.full_name = "";
info.classname = "";
xtt.ctx.set_nodraw();
this.xtt.ctx.set_nodraw();
for (let i = 0; i < this.elements; i++) {
info.name = this.name + "[" + i + "]";
info.full_name = this.full_name + "[" + i + "]";
if ((info.flags & Adef.Array) !== 0) {
new XttItemAttrArray(xtt, info, this.node, Dest.INTOLAST);
new XttItemAttrArray(this.xtt, info, this.node, Dest.INTOLAST);
} else if ((info.flags & Adef.Class) !== 0) {
new XttItemAttrObject(xtt, info, this.node, Dest.INTOLAST);
new XttItemAttrObject(this.xtt, info, this.node, Dest.INTOLAST);
} else {
new XttItemAttr(xtt, info, this.node, Dest.INTOLAST);
new XttItemAttr(this.xtt, info, this.node, Dest.INTOLAST);
}
}
this.node.node_open |= Open.ATTRIBUTES;
xtt.ctx.configure();
xtt.ctx.reset_nodraw();
xtt.ctx.draw();
this.xtt.ctx.configure();
this.xtt.ctx.reset_nodraw();
this.xtt.ctx.draw();
}
close(xtt) {
close() {
if (this.node.node_open & Open.ATTRIBUTES) {
xtt.ctx.close_node(this.node);
this.xtt.ctx.close_node(this.node);
this.node.node_open &= ~Open.ATTRIBUTES;
xtt.ctx.configure();
xtt.ctx.draw();
this.xtt.ctx.configure();
this.xtt.ctx.draw();
} else {
let parent = xtt.ctx.get_parent_object(this.node);
let parent = this.xtt.ctx.get_parent_object(this.node);
if (parent !== null) {
parent.userdata.close(xtt);
parent.userdata.close();
parent.set_select(true);
parent.set_invert(true);
}
......@@ -855,6 +851,7 @@ class XttItemAttrArray {
}
class XttItemAttrObject {
xtt: Xtt;
name: string;
classname: string;
objid: PwrtObjid;
......@@ -865,6 +862,7 @@ class XttItemAttrObject {
node: PlowNode;
constructor(xtt, info, destination, destCode) {
this.xtt = Xtt;
this.name = info.name;
this.classname = info.classname;
this.objid = info.objid;
......@@ -880,36 +878,35 @@ class XttItemAttrObject {
xtt.ctx.insertNode(this.node, destination, destCode);
}
open_children(xtt, open_next) {
this.open_attributes(xtt, null);
open_children(open_next) {
this.open_attributes(null);
}
open_attributes(xtt, open_next) {
open_attributes(open_next) {
if (this.node.node_open === 0) {
xtt.ctx.gdh.getAllClassAttributes(this.cid, this.objid,
xtt.open_attributes_cb, new XttOpenChildrenData(this.node, open_next));
this.xtt.ctx.gdh.getAllClassAttributes(this.cid, this.objid).then(this.xtt.open_attributes_cb(new XttOpenChildrenData(this.node, open_next)));
this.node.node_open |= Open.ATTRIBUTES;
} else {
this.close(xtt);
this.close();
}
}
close(xtt) {
close() {
if (this.node.node_open & Open.ATTRIBUTES) {
xtt.ctx.close_node(this.node);
this.xtt.ctx.close_node(this.node);
this.node.node_open &= ~Open.ATTRIBUTES;
xtt.ctx.configure();
xtt.ctx.draw();
this.xtt.ctx.configure();
this.xtt.ctx.draw();
} else if (this.node.node_open & Open.CROSSREFERENCES) {
xtt.ctx.close_node(this.node);
this.xtt.ctx.close_node(this.node);
this.node.node_open &= ~Open.CROSSREFERENCES;
xtt.ctx.configure();
xtt.ctx.draw();
this.xtt.ctx.configure();
this.xtt.ctx.draw();
} else {
let parent = xtt.ctx.get_parent_object(this.node);
let parent = this.xtt.ctx.get_parent_object(this.node);
if (parent !== null) {
parent.userdata.close(xtt);
parent.userdata.close();
parent.set_select(true);
parent.set_invert(true);
}
......@@ -918,6 +915,7 @@ class XttItemAttrObject {
}
class XttItemCrr {
xtt: Xtt;
name: string;
classname: string;
objid: PwrtObjid;
......@@ -925,6 +923,7 @@ class XttItemCrr {
node: PlowNode;
constructor(xtt, info, destination, destCode) {
this.xtt = Xtt;
this.name = info.name;
this.classname = info.classname;
this.objid = info.objid;
......@@ -939,10 +938,10 @@ class XttItemCrr {
xtt.ctx.insertNode(this.node, destination, destCode);
}
close(xtt) {
let parent = xtt.ctx.get_parent_object(this.node);
close() {
let parent = this.xtt.ctx.get_parent_object(this.node);
if (parent) {
parent.userdata.close(xtt);
parent.userdata.close();
parent.set_select(true);
parent.set_invert(true);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment