Commit dee415bd authored by Christoffer Ackelman's avatar Christoffer Ackelman

Autoformat JS files.

parent 926a2760
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
"use strict";
/** Crypt start **/
/****************************************************************************
* Proview
*
......@@ -18,7 +19,7 @@
Java-based implementation of the unix crypt command
Based upon C source code written by Eric Young, eay@psych.uq.oz.au
and the java version JCrypt by John Dumas.
*/
*/
function JopCrypt() {
this.ITERATIONS = 16;
......@@ -372,15 +373,13 @@ function JopCrypt() {
0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A
];
this.byteToUnsigned = function(b)
{
this.byteToUnsigned = function (b) {
var value = Math.floor(b);
return(value >= 0 ? value : value + 256);
return (value >= 0 ? value : value + 256);
}
this.fourBytesToInt = function(b, offset)
{
this.fourBytesToInt = function (b, offset) {
var value;
value = this.byteToUnsigned(b[offset++]);
......@@ -391,16 +390,14 @@ function JopCrypt() {
return value;
}
this.intToFourBytes = function(iValue, b, offset)
{
this.intToFourBytes = function (iValue, b, offset) {
b[offset++] = ((iValue) & 0xff);
b[offset++] = ((iValue >>> 8 ) & 0xff);
b[offset++] = ((iValue >>> 8) & 0xff);
b[offset++] = ((iValue >>> 16) & 0xff);
b[offset++] = ((iValue >>> 24) & 0xff);
}
this.PERM_OP = function(a, b, n, m, results)
{
this.PERM_OP = function (a, b, n, m, results) {
var t;
t = ((a >>> n) ^ b) & m;
......@@ -411,17 +408,16 @@ function JopCrypt() {
results[1] = b;
}
this.HPERM_OP = function(a, n, m)
{
this.HPERM_OP = function (a, n, m) {
var t;
t = ((a << (16 - n)) ^ a) & m;
a = a ^ t ^ (t >>> (16 - n));
return(a);
return (a);
}
this.des_set_key = function(key) {
this.des_set_key = function (key) {
var schedule = new Array(this.ITERATIONS * 2);
var c = this.fourBytesToInt(key, 0);
......@@ -430,19 +426,23 @@ function JopCrypt() {
var results = new Array(2);
this.PERM_OP(d, c, 4, 0x0f0f0f0f, results);
d = results[0]; c = results[1];
d = results[0];
c = results[1];
c = this.HPERM_OP(c, -2, 0xcccc0000);
d = this.HPERM_OP(d, -2, 0xcccc0000);
this.PERM_OP(d, c, 1, 0x55555555, results);
d = results[0]; c = results[1];
d = results[0];
c = results[1];
this.PERM_OP(c, d, 8, 0x00ff00ff, results);
c = results[0]; d = results[1];
c = results[0];
d = results[1];
this.PERM_OP(d, c, 1, 0x55555555, results);
d = results[0]; c = results[1];
d = results[0];
c = results[1];
d = (((d & 0x000000ff) << 16) | (d & 0x0000ff00) |
((d & 0x00ff0000) >>> 16) | ((c & 0xf0000000) >>> 4));
......@@ -451,13 +451,12 @@ function JopCrypt() {
var s, t;
var j = 0;
for(var i = 0; i < this.ITERATIONS; i++) {
if(this.shifts2[i]) {
for (var i = 0; i < this.ITERATIONS; i++) {
if (this.shifts2[i]) {
c = (c >>> 2) | (c << 26);
d = (d >>> 2) | (d << 26);
}
else
{
else {
c = (c >>> 1) | (c << 27);
d = (d >>> 1) | (d << 27);
}
......@@ -465,16 +464,16 @@ function JopCrypt() {
c &= 0x0fffffff;
d &= 0x0fffffff;
s = this.skb[0][ (c ) & 0x3f ]|
this.skb[1][((c >>> 6) & 0x03) | ((c >>> 7) & 0x3c)]|
this.skb[2][((c >>> 13) & 0x0f) | ((c >>> 14) & 0x30)]|
s = this.skb[0][(c) & 0x3f] |
this.skb[1][((c >>> 6) & 0x03) | ((c >>> 7) & 0x3c)] |
this.skb[2][((c >>> 13) & 0x0f) | ((c >>> 14) & 0x30)] |
this.skb[3][((c >>> 20) & 0x01) | ((c >>> 21) & 0x06) |
((c >>> 22) & 0x38)];
t = this.skb[4][ (d ) & 0x3f ]|
this.skb[5][((d >>> 7) & 0x03) | ((d >>> 8) & 0x3c)]|
this.skb[6][ (d >>>15) & 0x3f ]|
this.skb[7][((d >>>21) & 0x0f) | ((d >>> 22) & 0x30)];
t = this.skb[4][(d) & 0x3f] |
this.skb[5][((d >>> 7) & 0x03) | ((d >>> 8) & 0x3c)] |
this.skb[6][(d >>> 15) & 0x3f] |
this.skb[7][((d >>> 21) & 0x0f) | ((d >>> 22) & 0x30)];
schedule[j++] = ((t << 16) | (s & 0x0000ffff)) & 0xffffffff;
s = ((s >>> 16) | (t & 0xffff0000));
......@@ -485,7 +484,7 @@ function JopCrypt() {
return schedule;
}
this.D_ENCRYPT = function( L, R, S, E0, E1, s) {
this.D_ENCRYPT = function (L, R, S, E0, E1, s) {
var t, u, v;
v = R ^ (R >>> 16);
......@@ -495,11 +494,11 @@ function JopCrypt() {
t = (v ^ (v << 16)) ^ R ^ s[S + 1];
t = (t >>> 4) | (t << 28);
L ^= this.SPtrans[1][(t ) & 0x3f] |
L ^= this.SPtrans[1][(t) & 0x3f] |
this.SPtrans[3][(t >>> 8) & 0x3f] |
this.SPtrans[5][(t >>> 16) & 0x3f] |
this.SPtrans[7][(t >>> 24) & 0x3f] |
this.SPtrans[0][(u ) & 0x3f] |
this.SPtrans[0][(u) & 0x3f] |
this.SPtrans[2][(u >>> 8) & 0x3f] |
this.SPtrans[4][(u >>> 16) & 0x3f] |
this.SPtrans[6][(u >>> 24) & 0x3f];
......@@ -507,15 +506,13 @@ function JopCrypt() {
return L;
}
this.body = function(schedule, Eswap0, Eswap1) {
this.body = function (schedule, Eswap0, Eswap1) {
var left = 0;
var right = 0;
var t = 0;
for(var j = 0; j < 25; j ++)
{
for(var i = 0; i < this.ITERATIONS * 2; i += 4)
{
for (var j = 0; j < 25; j++) {
for (var i = 0; i < this.ITERATIONS * 2; i += 4) {
left = this.D_ENCRYPT(left, right, i, Eswap0, Eswap1, schedule);
right = this.D_ENCRYPT(right, left, i + 2, Eswap0, Eswap1, schedule);
}
......@@ -535,48 +532,53 @@ function JopCrypt() {
var results = new Array(2);
this.PERM_OP(right, left, 1, 0x55555555, results);
right = results[0]; left = results[1];
right = results[0];
left = results[1];
this.PERM_OP(left, right, 8, 0x00ff00ff, results);
left = results[0]; right = results[1];
left = results[0];
right = results[1];
this.PERM_OP(right, left, 2, 0x33333333, results);
right = results[0]; left = results[1];
right = results[0];
left = results[1];
this.PERM_OP(left, right, 16, 0x0000ffff, results);
left = results[0]; right = results[1];
left = results[0];
right = results[1];
this.PERM_OP(right, left, 4, 0x0f0f0f0f, results);
right = results[0]; left = results[1];
right = results[0];
left = results[1];
var out = new Array(2);
out[0] = left; out[1] = right;
out[0] = left;
out[1] = right;
return(out);
return (out);
}
this.crypt = function(salt, original) {
while(salt.length < 2)
this.crypt = function (salt, original) {
while (salt.length < 2)
salt += "A";
var buffer;
var charZero = salt.charAt(0)+'';
var charOne = salt.charAt(1)+'';
var charZero = salt.charAt(0) + '';
var charOne = salt.charAt(1) + '';
var ccZ = charZero.charCodeAt(0);
var ccO = charOne.charCodeAt(0);
console.log( "charZero", charZero, "charOne", charOne);
console.log("charZero", charZero, "charOne", charOne);
buffer = charZero + charOne + " ";
console.log( "buffer \"" + buffer + "\"");
console.log("buffer \"" + buffer + "\"");
var Eswap0 = this.con_salt[ccZ];
var Eswap1 = this.con_salt[ccO] << 4;
var key = new Array(0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0);
var key = new Array(0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0);
for(var i = 0; i < key.length && i < original.length; i ++)
{
for (var i = 0; i < key.length && i < original.length; i++) {
var iChar = original.charCodeAt(i);
key[i] = iChar << 1;
......@@ -591,117 +593,120 @@ function JopCrypt() {
this.intToFourBytes(out[1], b, 4);
b[8] = 0;
for(var i = 2, y = 0, u = 0x80; i < 13; i ++)
{
for(var j = 0, c = 0; j < 6; j ++)
{
for (var i = 2, y = 0, u = 0x80; i < 13; i++) {
for (var j = 0, c = 0; j < 6; j++) {
c <<= 1;
if((b[y] & u) != 0)
if ((b[y] & u) != 0)
c |= 1;
u >>>= 1;
if(u == 0)
{
if (u == 0) {
y++;
u = 0x80;
}
buffer = buffer.substring(0,i) + String.fromCharCode(this.cov_2char[c]) +
buffer.substring(i+1,buffer.length);
buffer = buffer.substring(0, i) + String.fromCharCode(this.cov_2char[c]) +
buffer.substring(i + 1, buffer.length);
}
}
return buffer;
};
}
/** Crypt end **/
/** Start Pwr **/
function PwrtStatus( sts)
{
function PwrtStatus(sts) {
this.sts = sts;
this.evenSts = function() { return (sts % 2 === 0);};
this.oddSts = function() { return (sts % 2 == 1);};
this.getSts = function() { return sts;};
this.evenSts = function () {
return (sts % 2 === 0);
};
this.oddSts = function () {
return (sts % 2 == 1);
};
this.getSts = function () {
return sts;
};
}
var Pwr = {
eType_Boolean : 98305,
eType_Float32 : 98306,
eType_Float64 : 98307,
eType_Char : 98308,
eType_Int8 : 98309,
eType_Int16 : 98310,
eType_Int32 : 98311,
eType_UInt8 : 98312,
eType_UInt16 : 98313,
eType_UInt32 : 98314,
eType_Objid : 98315,
eType_Buffer : 98316,
eType_String : 98317,
eType_Enum : 98318,
eType_Struct : 98319,
eType_Mask : 98320,
eType_Array : 98321,
eType_Time : 98322,
eType_Text : 98323,
eType_AttrRef : 98324,
eType_UInt64 : 98325,
eType_Int64 : 98326,
eType_ClassId : 98327,
eType_TypeId : 98328,
eType_VolumeId : 98329,
eType_ObjectIx : 98330,
eType_RefId : 98331,
eType_DeltaTime : 98332,
eType_Status : 98333,
eType_NetStatus : 98334,
eType_CastId : 98335,
eType_ProString : 98336,
eType_DisableAttr : 98337,
eType_DataRef : 98338,
mPrv_RtRead : 1 << 0,
mPrv_RtWrite : 1 << 1,
mPrv_System : 1 << 2,
mPrv_Maintenance : 1 << 3,
mPrv_Process : 1 << 4,
mPrv_Instrument : 1 << 5,
mPrv_Operator1 : 1 << 6,
mPrv_Operator2 : 1 << 7,
mPrv_Operator3 : 1 << 8,
mPrv_Operator4 : 1 << 9,
mPrv_Operator5 : 1 << 10,
mPrv_Operator6 : 1 << 11,
mPrv_Operator7 : 1 << 12,
mPrv_Operator8 : 1 << 13,
mPrv_Operator9 : 1 << 14,
mPrv_Operator10 : 1 << 15,
mPrv_RtEventsAck : 1 << 18,
mPrv_RtPlc : 1 << 19,
mPrv_RtNavigator : 1 << 20,
mPrv_DevRead : 1 << 21,
mPrv_DevPlc : 1 << 22,
mPrv_DevConfig : 1 << 23,
mPrv_DevClass : 1 << 24,
mPrv_RtEventsBlock : 1 << 25,
mPrv_Administrator : 1 << 26,
mPrv_SevRead : 1 << 27,
mPrv_SevAdmin : 1 << 28,
mAccess_RtRead : 1 << 0,
mAccess_RtWrite : 1 << 1,
mAccess_System : 1 << 2,
mAccess_Maintenance : 1 << 3,
mAccess_Process : 1 << 4,
mAccess_Instrument : 1 << 5,
mAccess_RtEventsBlock : 1 << 25,
mAccess_RtEventsAck : 1 << 18,
mAccess_RtPlc : 1 << 19,
mAccess_RtNavigator : 1 << 20,
mAccess_AllRt : 1 << 2 |
eType_Boolean: 98305,
eType_Float32: 98306,
eType_Float64: 98307,
eType_Char: 98308,
eType_Int8: 98309,
eType_Int16: 98310,
eType_Int32: 98311,
eType_UInt8: 98312,
eType_UInt16: 98313,
eType_UInt32: 98314,
eType_Objid: 98315,
eType_Buffer: 98316,
eType_String: 98317,
eType_Enum: 98318,
eType_Struct: 98319,
eType_Mask: 98320,
eType_Array: 98321,
eType_Time: 98322,
eType_Text: 98323,
eType_AttrRef: 98324,
eType_UInt64: 98325,
eType_Int64: 98326,
eType_ClassId: 98327,
eType_TypeId: 98328,
eType_VolumeId: 98329,
eType_ObjectIx: 98330,
eType_RefId: 98331,
eType_DeltaTime: 98332,
eType_Status: 98333,
eType_NetStatus: 98334,
eType_CastId: 98335,
eType_ProString: 98336,
eType_DisableAttr: 98337,
eType_DataRef: 98338,
mPrv_RtRead: 1 << 0,
mPrv_RtWrite: 1 << 1,
mPrv_System: 1 << 2,
mPrv_Maintenance: 1 << 3,
mPrv_Process: 1 << 4,
mPrv_Instrument: 1 << 5,
mPrv_Operator1: 1 << 6,
mPrv_Operator2: 1 << 7,
mPrv_Operator3: 1 << 8,
mPrv_Operator4: 1 << 9,
mPrv_Operator5: 1 << 10,
mPrv_Operator6: 1 << 11,
mPrv_Operator7: 1 << 12,
mPrv_Operator8: 1 << 13,
mPrv_Operator9: 1 << 14,
mPrv_Operator10: 1 << 15,
mPrv_RtEventsAck: 1 << 18,
mPrv_RtPlc: 1 << 19,
mPrv_RtNavigator: 1 << 20,
mPrv_DevRead: 1 << 21,
mPrv_DevPlc: 1 << 22,
mPrv_DevConfig: 1 << 23,
mPrv_DevClass: 1 << 24,
mPrv_RtEventsBlock: 1 << 25,
mPrv_Administrator: 1 << 26,
mPrv_SevRead: 1 << 27,
mPrv_SevAdmin: 1 << 28,
mAccess_RtRead: 1 << 0,
mAccess_RtWrite: 1 << 1,
mAccess_System: 1 << 2,
mAccess_Maintenance: 1 << 3,
mAccess_Process: 1 << 4,
mAccess_Instrument: 1 << 5,
mAccess_RtEventsBlock: 1 << 25,
mAccess_RtEventsAck: 1 << 18,
mAccess_RtPlc: 1 << 19,
mAccess_RtNavigator: 1 << 20,
mAccess_AllRt: 1 << 2 |
1 << 3 |
1 << 4 |
1 << 5 |
......@@ -721,7 +726,7 @@ var Pwr = {
1 << 13 |
1 << 14 |
1 << 15,
mAccess_AllOperators : 1 << 6 |
mAccess_AllOperators: 1 << 6 |
1 << 7 |
1 << 8 |
1 << 9 |
......@@ -731,61 +736,61 @@ var Pwr = {
1 << 13 |
1 << 14 |
1 << 15,
mAccess_AllPwr : ~0,
mAdef_pointer : 1,
mAdef_array : 2,
mAdef_backup : 4,
mAdef_changelog : 8,
mAdef_state : 16,
mAdef_const : 32,
mAdef_rtvirtual : 64,
mAdef_devbodyref : 128,
mAdef_dynamic : 256,
mAdef_publicwrite : 512,
mAdef_noedit : 1024,
mAdef_invisible : 2048,
mAdef_refdirect : 4096,
mAdef_noinvert : 8192,
mAdef_noremove : 16384,
mAdef_rtdbref : 32768,
mAdef_private : 65536,
mAdef_class : 131072,
mAdef_superclass : 262144,
mAdef_buffer : 524288,
mAdef_nowbl : 1048576,
mAdef_alwayswbl : 2097152,
mAdef_disableattr : 4194304,
mAdef_rthide : 8388608
mAccess_AllPwr: ~0,
mAdef_pointer: 1,
mAdef_array: 2,
mAdef_backup: 4,
mAdef_changelog: 8,
mAdef_state: 16,
mAdef_const: 32,
mAdef_rtvirtual: 64,
mAdef_devbodyref: 128,
mAdef_dynamic: 256,
mAdef_publicwrite: 512,
mAdef_noedit: 1024,
mAdef_invisible: 2048,
mAdef_refdirect: 4096,
mAdef_noinvert: 8192,
mAdef_noremove: 16384,
mAdef_rtdbref: 32768,
mAdef_private: 65536,
mAdef_class: 131072,
mAdef_superclass: 262144,
mAdef_buffer: 524288,
mAdef_nowbl: 1048576,
mAdef_alwayswbl: 2097152,
mAdef_disableattr: 4194304,
mAdef_rthide: 8388608
};
var Pwrb = {
mXttMethodsFlagsMask_IsConfigured : 1,
mXttOpMethodsMask_OpenGraph : 1,
mXttOpMethodsMask_OpenObjectGraph : 2,
mXttOpMethodsMask_OpenTrend : 4,
mXttOpMethodsMask_OpenHistory : 8,
mXttOpMethodsMask_OpenFast : 16,
mXttOpMethodsMask_Camera : 32,
mXttOpMethodsMask_HistEvent : 64,
mXttOpMethodsMask_BlockEvents : 128,
mXttOpMethodsMask_Help : 256,
mXttOpMethodsMask_Photo : 512,
mXttOpMethodsMask_Note : 1024,
mXttOpMethodsMask_ParentObjectGraph : 2048,
mXttMntMethodsMask_OpenObject : 1,
mXttMntMethodsMask_OpenTrace : 2,
mXttMntMethodsMask_RtNavigator : 4,
mXttMntMethodsMask_OpenCrossref : 8,
mXttMntMethodsMask_HelpClass : 16,
mXttMntMethodsMask_DataSheet : 32,
mXttMntMethodsMask_CircuitDiagram : 64,
mXttMntMethodsMask_Simulate : 1 << 31
mXttMethodsFlagsMask_IsConfigured: 1,
mXttOpMethodsMask_OpenGraph: 1,
mXttOpMethodsMask_OpenObjectGraph: 2,
mXttOpMethodsMask_OpenTrend: 4,
mXttOpMethodsMask_OpenHistory: 8,
mXttOpMethodsMask_OpenFast: 16,
mXttOpMethodsMask_Camera: 32,
mXttOpMethodsMask_HistEvent: 64,
mXttOpMethodsMask_BlockEvents: 128,
mXttOpMethodsMask_Help: 256,
mXttOpMethodsMask_Photo: 512,
mXttOpMethodsMask_Note: 1024,
mXttOpMethodsMask_ParentObjectGraph: 2048,
mXttMntMethodsMask_OpenObject: 1,
mXttMntMethodsMask_OpenTrace: 2,
mXttMntMethodsMask_RtNavigator: 4,
mXttMntMethodsMask_OpenCrossref: 8,
mXttMntMethodsMask_HelpClass: 16,
mXttMntMethodsMask_DataSheet: 32,
mXttMntMethodsMask_CircuitDiagram: 64,
mXttMntMethodsMask_Simulate: 1 << 31
};
function PwrtObjid( vid, oix) {
function PwrtObjid(vid, oix) {
this.oix = oix;
this.vid = vid;
}
......@@ -798,25 +803,31 @@ function PwrtAttrRef() {
this.flags;
}
function CdhrNumber( value, sts)
{
function CdhrNumber(value, sts) {
this.value = value;
this.sts = sts;
this.evenSts = function() { return (sts % 2 === 0);};
this.oddSts = function() { return (sts % 2 == 1);};
this.getSts = function() { return sts;};
this.evenSts = function () {
return (sts % 2 === 0);
};
this.oddSts = function () {
return (sts % 2 == 1);
};
this.getSts = function () {
return sts;
};
}
var CdhC = {
cUserVolMin : (0 + (0 << 24) + (1 << 16) + (1 << 8) + 1),
cUserVolMax : (0 + (0 << 24) + (254 << 16) + (254 << 8) + 254)
cUserVolMin: (0 + (0 << 24) + (1 << 16) + (1 << 8) + 1),
cUserVolMax: (0 + (0 << 24) + (254 << 16) + (254 << 8) + 254)
};
function UserdataCbReturn() {
this.userdata;
this.row;
}
/** End Pwr **/
/** Start Gdh **/
......@@ -898,89 +909,89 @@ function GlowTableInfo() {
this.column_size = new Array(Glow.TABLE_MAX_COL);
}
function PendingData( func_cb, data) {
function PendingData(func_cb, data) {
this.func_cb = func_cb;
this.data = data;
}
var GdhOp = {
GET_OP_SELF : 1,
GET_OP_METHOD_PLC : 2,
GET_OP_METHOD_OBJECTGRAPH : 3,
GET_OP_METHOD_GRAPH : 4,
GET_OP_METHOD_HELPCLASS : 5
GET_OP_SELF: 1,
GET_OP_METHOD_PLC: 2,
GET_OP_METHOD_OBJECTGRAPH: 3,
GET_OP_METHOD_GRAPH: 4,
GET_OP_METHOD_HELPCLASS: 5
};
function Gdh() {
var Msg = {
SET_OBJECT_INFO_BOOLEAN : 1,
SET_OBJECT_INFO_FLOAT : 2,
SET_OBJECT_INFO_INT : 3,
SET_OBJECT_INFO_STRING : 4,
GET_OBJECT_INFO_BOOLEAN : 5,
GET_OBJECT_INFO_FLOAT : 6,
GET_OBJECT_INFO_INT : 7,
GET_OBJECT_INFO_STRING : 8,
TOGGLE_OBJECT_INFO : 9,
REF_OBJECT_INFO : 10,
GET_OBJECT_REF_INFO_BOOLEAN : 11,
GET_OBJECT_REF_INFO_FLOAT : 12,
GET_OBJECT_REF_INFO_INT : 13,
GET_OBJECT_REF_INFO_STRING : 14,
UNREF_OBJECT_INFO : 15,
NAME_TO_OBJID : 16,
OBJID_TO_NAME : 17,
GET_ROOT_LIST : 18,
GET_NEXT_OBJECT : 19,
GET_CHILD : 20,
GET_NEXT_SIBLING : 21,
GET_OBJECT_CLASS : 22,
GET_CLASS_LIST : 23,
CLASS_ID_TO_OBJID : 24,
GET_OBJECT_REF_INFO_ALL : 25,
REF_OBJECT_INFO_LIST : 26,
POLL : 27,
STATISTICS : 28,
CHECK_USER : 29,
GET_NODE_OBJECT : 30,
LOG_STRING : 31,
UNREF_OBJECT_INFO_ALL : 32,
CREATE_INSTANCE_FILE : 33,
GET_ATTRIBUTE_CHAR : 34,
GET_CLASS_ATTRIBUTE : 35,
GET_ALL_CLASS_ATTRIBUTES : 36,
GET_ALL_SIBLINGS : 37,
GET_ALL_XTT_SIBLINGS : 38,
GET_ALL_XTT_CHILDREN : 39,
REF_OBJECT_INFO_VECTOR : 40,
GET_SUBSCRIPTIONS : 41,
CRR_SIGNAL : 42,
CRR_OBJECT : 43,
GET_PARENT : 44,
GET_OBJECT_INFO_OBJID : 45,
GET_OBJECT_REF_INFO_BOOLEAN_ARRAY : 46,
GET_OBJECT_REF_INFO_FLOAT_ARRAY : 47,
GET_OBJECT_REF_INFO_INT_ARRAY : 48,
GET_OBJECT_REF_INFO_STRING_ARRAY : 49,
GET_MSG : 50,
GET_MSG_TEXT : 51,
NAME_TO_ATTRREF : 52,
ATTRREF_TO_NAME : 53,
GET_ATTRREF_TID : 54,
GET_SUPER_CLASS : 55,
GET_ALL_CLASS_ATTRIBUTES_STRING : 56,
GET_OBJECT_INFO_FLOAT_ARRAY : 57,
GET_OBJECT_INFO_INT_ARRAY : 58,
GET_CIRCBUFF_INFO : 59,
UPDATE_CIRCBUFF_INFO : 60,
GET_ATTRIBUTE_FLAGS : 61,
CLASSNAME_TO_ID : 62,
GET_OBJECT : 63,
GET_OPWIND_MENU : 64,
GET_OBJECT_FROM_NAME : 65,
MH_SYNC : 66,
MH_ACK : 67,
GET_OBJECT_FROM_AREF : 68
SET_OBJECT_INFO_BOOLEAN: 1,
SET_OBJECT_INFO_FLOAT: 2,
SET_OBJECT_INFO_INT: 3,
SET_OBJECT_INFO_STRING: 4,
GET_OBJECT_INFO_BOOLEAN: 5,
GET_OBJECT_INFO_FLOAT: 6,
GET_OBJECT_INFO_INT: 7,
GET_OBJECT_INFO_STRING: 8,
TOGGLE_OBJECT_INFO: 9,
REF_OBJECT_INFO: 10,
GET_OBJECT_REF_INFO_BOOLEAN: 11,
GET_OBJECT_REF_INFO_FLOAT: 12,
GET_OBJECT_REF_INFO_INT: 13,
GET_OBJECT_REF_INFO_STRING: 14,
UNREF_OBJECT_INFO: 15,
NAME_TO_OBJID: 16,
OBJID_TO_NAME: 17,
GET_ROOT_LIST: 18,
GET_NEXT_OBJECT: 19,
GET_CHILD: 20,
GET_NEXT_SIBLING: 21,
GET_OBJECT_CLASS: 22,
GET_CLASS_LIST: 23,
CLASS_ID_TO_OBJID: 24,
GET_OBJECT_REF_INFO_ALL: 25,
REF_OBJECT_INFO_LIST: 26,
POLL: 27,
STATISTICS: 28,
CHECK_USER: 29,
GET_NODE_OBJECT: 30,
LOG_STRING: 31,
UNREF_OBJECT_INFO_ALL: 32,
CREATE_INSTANCE_FILE: 33,
GET_ATTRIBUTE_CHAR: 34,
GET_CLASS_ATTRIBUTE: 35,
GET_ALL_CLASS_ATTRIBUTES: 36,
GET_ALL_SIBLINGS: 37,
GET_ALL_XTT_SIBLINGS: 38,
GET_ALL_XTT_CHILDREN: 39,
REF_OBJECT_INFO_VECTOR: 40,
GET_SUBSCRIPTIONS: 41,
CRR_SIGNAL: 42,
CRR_OBJECT: 43,
GET_PARENT: 44,
GET_OBJECT_INFO_OBJID: 45,
GET_OBJECT_REF_INFO_BOOLEAN_ARRAY: 46,
GET_OBJECT_REF_INFO_FLOAT_ARRAY: 47,
GET_OBJECT_REF_INFO_INT_ARRAY: 48,
GET_OBJECT_REF_INFO_STRING_ARRAY: 49,
GET_MSG: 50,
GET_MSG_TEXT: 51,
NAME_TO_ATTRREF: 52,
ATTRREF_TO_NAME: 53,
GET_ATTRREF_TID: 54,
GET_SUPER_CLASS: 55,
GET_ALL_CLASS_ATTRIBUTES_STRING: 56,
GET_OBJECT_INFO_FLOAT_ARRAY: 57,
GET_OBJECT_INFO_INT_ARRAY: 58,
GET_CIRCBUFF_INFO: 59,
UPDATE_CIRCBUFF_INFO: 60,
GET_ATTRIBUTE_FLAGS: 61,
CLASSNAME_TO_ID: 62,
GET_OBJECT: 63,
GET_OPWIND_MENU: 64,
GET_OBJECT_FROM_NAME: 65,
MH_SYNC: 66,
MH_ACK: 67,
GET_OBJECT_FROM_AREF: 68
};
this.debug = false;
......@@ -995,155 +1006,155 @@ function Gdh() {
this.subscriptionCount = 1;
this.listSend = false;
this.init = function() {
if ( window.location.hostname === "")
this.ws = new WebSocket( "ws:127.0.0.1:4448");
this.init = function () {
if (window.location.hostname === "")
this.ws = new WebSocket("ws:127.0.0.1:4448");
else
this.ws = new WebSocket( "ws://" + window.location.hostname + ":4448");
this.ws = new WebSocket("ws://" + window.location.hostname + ":4448");
this.ws.binaryType = "arraybuffer";
this.ws.gdh = this;
this.ws.onopen = function( e) {
if ( this.gdh.open_cb !== null)
this.ws.onopen = function (e) {
if (this.gdh.open_cb !== null)
this.gdh.open_cb();
};
this.ws.onclose = function() {
if ( this.debug) console.log( "Socket closed");
if ( this.gdh.close_cb !== null)
this.ws.onclose = function () {
if (this.debug) console.log("Socket closed");
if (this.gdh.close_cb !== null)
this.gdh.close_cb();
};
this.ws.onmessage = function(e) {
if ( typeof e.data == "string") {
this.ws.onmessage = function (e) {
if (typeof e.data == "string") {
console.log("String message received", e, e.data);
}
else {
if ( e.data instanceof ArrayBuffer) {
if (e.data instanceof ArrayBuffer) {
var dv = new DataView(e.data);
var type = dv.getUint8(0);
var id = dv.getUint32(1);
var sts = dv.getUint32(5);
switch( type) {
switch (type) {
case Msg.GET_OBJECT_INFO_BOOLEAN: {
if ( this.gdh.debug) console.log("GetObjectInfoBoolean received");
if (this.gdh.debug) console.log("GetObjectInfoBoolean received");
var value = dv.getUint8(9);
var func_cb = this.gdh.pending[id].func_cb;
func_cb( id, sts, value);
func_cb(id, sts, value);
delete this.gdh.pending[id];
break;
}
case Msg.GET_OBJECT_INFO_INT: {
if ( this.gdh.debug) console.log("GetObjectInfoInt received");
if (this.gdh.debug) console.log("GetObjectInfoInt received");
var value = dv.getUint32(9);
var pending_data = this.gdh.pending[id];
pending_data.func_cb( id, pending_data.data, sts, value);
pending_data.func_cb(id, pending_data.data, sts, value);
delete this.gdh.pending[id];
break;
}
case Msg.GET_OBJECT_INFO_FLOAT: {
if ( this.gdh.debug) console.log("GetObjectInfoFloat received");
if (this.gdh.debug) console.log("GetObjectInfoFloat received");
var value = dv.getFloat32(9);
var pending_data = this.gdh.pending[id];
pending_data.func_cb( id, pending_data.data, sts, value);
pending_data.func_cb(id, pending_data.data, sts, value);
delete this.gdh.pending[id];
break;
}
case Msg.GET_OBJECT_INFO_FLOAT_ARRAY: {
if ( this.gdh.debug) console.log("GetObjectInfoFloatArray received");
if (this.gdh.debug) console.log("GetObjectInfoFloatArray received");
var asize = dv.getInt32(9);
var value = new Array(asize);
k = 13;
for ( var i = 0; i < asize; i++) {
for (var i = 0; i < asize; i++) {
value[i] = dv.getFloat32(k);
k += 4;
}
var pending_data = this.gdh.pending[id];
pending_data.func_cb( id, pending_data.data, sts, value);
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);
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);
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);
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);
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);
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);
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);
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);
if (this.gdh.debug) console.log("RefObjectInfoList received", id, sts);
var func_cb = this.gdh.pending[id].func_cb;
func_cb( id, sts);
func_cb(id, sts);
delete this.gdh.pending[id];
break;
}
case Msg.GET_OBJECT_REF_INFO_ALL: {
var j = 9;
var size = dv.getUint32(j);
if ( this.gdh.debug) console.log("GetObjectRefInfoAll received", id, size);
if (this.gdh.debug) console.log("GetObjectRefInfoAll received", id, size);
j += 4;
for ( var i = 0; i < size; i++) {
for (var i = 0; i < size; i++) {
var eid = dv.getUint32(j);
j += 4;
var esize = dv.getUint32(j);
j += 4;
var sub = this.gdh.sub[eid];
if ( typeof sub == 'undefined')
if (typeof sub == 'undefined')
j += esize;
else {
var value;
switch ( sub.type) {
switch (sub.type) {
case Pwr.eType_Boolean:
if ( sub.elements <= 1) {
if (sub.elements <= 1) {
value = dv.getUint8(j);
j += 1;
}
else {
var elements = esize;
if ( elements != sub.elements)
if (elements != sub.elements)
console.log("Subscription size error", elements, sub.elements, eid);
value = new Array(elements);
for ( var k = 0; k < elements; k++) {
for (var k = 0; k < elements; k++) {
value[k] = dv.getUint8(j);
j += 1;
}
}
break;
case Pwr.eType_Float32:
if ( sub.elements <= 1) {
if (sub.elements <= 1) {
value = dv.getFloat32(j);
j += 4;
}
else {
var elements = esize / 4;
if ( elements != sub.elements)
if (elements != sub.elements)
console.log("Subscription size error", elements, sub.elements, eid);
value = new Array(elements);
for ( var k = 0; k < elements; k++) {
for (var k = 0; k < elements; k++) {
value[k] = dv.getFloat32(j);
j += 4;
}
......@@ -1160,16 +1171,16 @@ function Gdh() {
case Pwr.eType_Mask:
case Pwr.eType_Enum:
case GraphIfc.eType_Bit:
if ( sub.elements <= 1) {
if (sub.elements <= 1) {
value = dv.getInt32(j);
j += 4;
}
else {
var elements = esize / 4;
if ( elements != sub.elements)
if (elements != sub.elements)
console.log("Subscription size error", elements, sub.elements, eid);
value = new Array(elements);
for ( var k = 0; k < elements; k++) {
for (var k = 0; k < elements; k++) {
value[k] = dv.getInt32(j);
j += 4;
}
......@@ -1180,42 +1191,43 @@ function Gdh() {
case Pwr.eType_DeltaTime:
case Pwr.eType_AttrRef:
case Pwr.eType_Objid:
if ( sub.elements <= 1) {
if (sub.elements <= 1) {
var nsize = dv.getInt16(j);
j += 2;
var iarr = new Uint8Array( nsize);
for ( var k = 0; k < nsize; k++) {
var iarr = new Uint8Array(nsize);
for (var k = 0; k < nsize; k++) {
iarr[k] = dv.getUint8(j++);
}
value = String.fromCharCode.apply( null, iarr);
value = String.fromCharCode.apply(null, iarr);
}
else {
var elements = sub.elements;
if ( elements != sub.elements)
if (elements != sub.elements)
console.log("Subscription size error", elements, sub.elements, eid);
value = new Array(elements);
for ( var l = 0; l < elements; l++) {
for (var l = 0; l < elements; l++) {
var nsize = dv.getInt16(j);
j += 2;
var iarr = new Uint8Array( nsize);
for ( var k = 0; k < nsize; k++) {
var iarr = new Uint8Array(nsize);
for (var k = 0; k < nsize; k++) {
iarr[k] = dv.getUint8(j++);
}
value[l] = String.fromCharCode.apply( null, iarr);
value[l] = String.fromCharCode.apply(null, iarr);
}
}
break;
default: break;
default:
break;
}
this.gdh.sub[eid].value = value;
}
}
if ( typeof this.gdh.pending[id] == 'undefined') {
console.log( "** GetObjectRefInfoAll received removed", id);
if (typeof this.gdh.pending[id] == 'undefined') {
console.log("** GetObjectRefInfoAll received removed", id);
break;
}
var func_cb = this.gdh.pending[id].func_cb;
func_cb( id, sts);
func_cb(id, sts);
delete this.gdh.pending[id];
break;
}
......@@ -1223,10 +1235,10 @@ function Gdh() {
var result = [];
var j = 9;
var size = dv.getUint32(j);
if ( this.gdh.debug) console.log("GetAllXttChildren received", id, size);
if (this.gdh.debug) console.log("GetAllXttChildren received", id, size);
console.log("GetAllXttChildren received", sts, id, size);
j += 4;
for ( var i = 0; i < size; i++) {
for (var i = 0; i < size; i++) {
var info = new ObjectInfo();
info.objid = new PwrtObjid();
info.objid.vid = dv.getUint32(j);
......@@ -1239,30 +1251,30 @@ function Gdh() {
j += 2;
var nsize = dv.getUint16(j);
j += 2;
var iarr = new Uint8Array( nsize);
for ( var k = 0; k < nsize; k++) {
var iarr = new Uint8Array(nsize);
for (var k = 0; k < nsize; k++) {
iarr[k] = dv.getUint8(j++);
}
info.name = String.fromCharCode.apply( null, iarr);
info.name = String.fromCharCode.apply(null, iarr);
//j += nsize;
var dsize = dv.getUint16(j);
j += 2;
iarr = new Uint8Array( dsize);
for ( var k = 0; k < dsize; k++) {
iarr = new Uint8Array(dsize);
for (var k = 0; k < dsize; k++) {
iarr[k] = dv.getUint8(j++);
}
info.description = String.fromCharCode.apply( null, iarr);
info.description = String.fromCharCode.apply(null, iarr);
var csize = dv.getUint16(j);
j += 2;
iarr = new Uint8Array( csize);
for ( var k = 0; k < csize; k++) {
iarr = new Uint8Array(csize);
for (var k = 0; k < csize; k++) {
iarr[k] = dv.getUint8(j++);
}
info.classname = String.fromCharCode.apply( null, iarr);
info.classname = String.fromCharCode.apply(null, iarr);
result.push(info);
}
var pending_data = this.gdh.pending[id];
pending_data.func_cb( id, pending_data.data, sts, result);
pending_data.func_cb(id, pending_data.data, sts, result);
delete this.gdh.pending[id];
break;
}
......@@ -1270,9 +1282,9 @@ function Gdh() {
var result = [];
var j = 9;
var size = dv.getUint32(j);
if ( this.gdh.debug) console.log("GetAllClassAttributes received", id, size);
if (this.gdh.debug) console.log("GetAllClassAttributes received", id, size);
j += 4;
for ( var i = 0; i < size; i++) {
for (var i = 0; i < size; i++) {
var info = new AttributeInfo();
info.type = dv.getUint32(j);
j += 4;
......@@ -1284,32 +1296,32 @@ function Gdh() {
j += 2;
var nsize = dv.getUint16(j);
j += 2;
var iarr = new Uint8Array( nsize);
for ( var k = 0; k < nsize; k++) {
var iarr = new Uint8Array(nsize);
for (var k = 0; k < nsize; k++) {
iarr[k] = dv.getUint8(j++);
}
info.name = String.fromCharCode.apply( null, iarr);
info.name = String.fromCharCode.apply(null, iarr);
nsize = dv.getUint16(j);
j += 2;
iarr = new Uint8Array( nsize);
for ( var k = 0; k < nsize; k++) {
iarr = new Uint8Array(nsize);
for (var k = 0; k < nsize; k++) {
iarr[k] = dv.getUint8(j++);
}
info.classname = String.fromCharCode.apply( null, iarr);
info.classname = String.fromCharCode.apply(null, iarr);
result.push(info);
}
var pending_data = this.gdh.pending[id];
pending_data.func_cb( id, pending_data.data, sts, result);
pending_data.func_cb(id, pending_data.data, sts, result);
delete this.gdh.pending[id];
break;
}
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);
if (this.gdh.debug) console.log("GetObject received", id, sts);
var info = null;
if ( (sts & 1) !== 0) {
if ((sts & 1) !== 0) {
var j = 9;
info = new ObjectInfo();
info.objid = new PwrtObjid();
......@@ -1324,58 +1336,58 @@ function Gdh() {
var nsize = dv.getUint16(j);
j += 2;
var iarr = new Uint8Array( nsize);
for ( var k = 0; k < nsize; k++) {
var iarr = new Uint8Array(nsize);
for (var k = 0; k < nsize; k++) {
iarr[k] = dv.getUint8(j++);
}
info.name = String.fromCharCode.apply( null, iarr);
info.name = String.fromCharCode.apply(null, iarr);
nsize = dv.getUint16(j);
j += 2;
iarr = new Uint8Array( nsize);
for ( var k = 0; k < nsize; k++) {
iarr = new Uint8Array(nsize);
for (var k = 0; k < nsize; k++) {
iarr[k] = dv.getUint8(j++);
}
info.fullname = String.fromCharCode.apply( null, iarr);
info.fullname = String.fromCharCode.apply(null, iarr);
var csize = dv.getUint16(j);
j += 2;
iarr = new Uint8Array( csize);
for ( var k = 0; k < csize; k++) {
iarr = new Uint8Array(csize);
for (var k = 0; k < csize; k++) {
iarr[k] = dv.getUint8(j++);
}
info.classname = String.fromCharCode.apply( null, iarr);
info.classname = String.fromCharCode.apply(null, iarr);
var dsize = dv.getUint16(j);
j += 2;
iarr = new Uint8Array( dsize);
for ( var k = 0; k < dsize; k++) {
iarr = new Uint8Array(dsize);
for (var k = 0; k < dsize; k++) {
iarr[k] = dv.getUint8(j++);
}
info.description = String.fromCharCode.apply( null, iarr);
info.description = String.fromCharCode.apply(null, iarr);
var p1size = dv.getUint16(j);
j += 2;
iarr = new Uint8Array( p1size);
for ( var k = 0; k < p1size; k++) {
iarr = new Uint8Array(p1size);
for (var k = 0; k < p1size; k++) {
iarr[k] = dv.getUint8(j++);
}
info.param1 = String.fromCharCode.apply( null, iarr);
info.param1 = String.fromCharCode.apply(null, iarr);
}
var pending_data = this.gdh.pending[id];
pending_data.func_cb( id, pending_data.data, sts, info);
pending_data.func_cb(id, pending_data.data, sts, info);
delete this.gdh.pending[id];
break;
}
case Msg.CRR_SIGNAL: {
var crrtext = null;
if ( (sts & 1) !== 0) {
if ((sts & 1) !== 0) {
var j = 9;
var result = [];
var size = dv.getUint16(j);
j += 2;
if ( this.gdh.debug) console.log("CrrSignal received", id, size);
for ( var i = 0; i < size; i++) {
if (this.gdh.debug) console.log("CrrSignal received", id, size);
for (var i = 0; i < size; i++) {
var info = new CrrInfo();
info.type = dv.getUint16(j);
j += 2;
......@@ -1386,49 +1398,49 @@ function Gdh() {
j += 4;
var nsize = dv.getUint16(j);
j += 2;
var iarr = new Uint8Array( nsize);
for ( var k = 0; k < nsize; k++) {
var iarr = new Uint8Array(nsize);
for (var k = 0; k < nsize; k++) {
iarr[k] = dv.getUint8(j++);
}
info.name = String.fromCharCode.apply( null, iarr);
info.name = String.fromCharCode.apply(null, iarr);
var csize = dv.getUint16(j);
j += 2;
iarr = new Uint8Array( csize);
for ( var k = 0; k < csize; k++) {
iarr = new Uint8Array(csize);
for (var k = 0; k < csize; k++) {
iarr[k] = dv.getUint8(j++);
}
info.classname = String.fromCharCode.apply( null, iarr);
info.classname = String.fromCharCode.apply(null, iarr);
result.push(info);
}
}
var pending_data = this.gdh.pending[id];
pending_data.func_cb( id, pending_data.data, sts, result);
pending_data.func_cb(id, pending_data.data, sts, result);
delete this.gdh.pending[id];
break;
}
case Msg.GET_OPWIND_MENU: {
var result = new OpwindMenuInfo();
var j = 9;
if ( this.gdh.debug) console.log("GetOpwindMenu received", id, size);
if (this.gdh.debug) console.log("GetOpwindMenu received", id, size);
console.log("GetOpwindMenu received", sts, id);
if ( sts & 1) {
if (sts & 1) {
var nsize = dv.getUint16(j);
j += 2;
var iarr = new Uint8Array( nsize);
for ( var k = 0; k < nsize; k++) {
var iarr = new Uint8Array(nsize);
for (var k = 0; k < nsize; k++) {
iarr[k] = dv.getUint8(j++);
}
result.title = String.fromCharCode.apply( null, iarr);
result.title = String.fromCharCode.apply(null, iarr);
nsize = dv.getUint16(j);
j += 2;
iarr = new Uint8Array( nsize);
for ( var k = 0; k < nsize; k++) {
iarr = new Uint8Array(nsize);
for (var k = 0; k < nsize; k++) {
iarr[k] = dv.getUint8(j++);
}
result.text = String.fromCharCode.apply( null, iarr);
result.text = String.fromCharCode.apply(null, iarr);
result.enable_language = dv.getUint32(j);
j += 4;
......@@ -1450,67 +1462,67 @@ function Gdh() {
var bsize = dv.getUint16(j);
j += 2;
for ( var i = 0; i < bsize; i++) {
for (var i = 0; i < bsize; i++) {
var button = new MenuButton();
button.type = dv.getUint32(j);
j += 4;
nsize = dv.getUint16(j);
j += 2;
iarr = new Uint8Array( nsize);
for ( var k = 0; k < nsize; k++) {
iarr = new Uint8Array(nsize);
for (var k = 0; k < nsize; k++) {
iarr[k] = dv.getUint8(j++);
}
button.text = String.fromCharCode.apply( null, iarr);
button.text = String.fromCharCode.apply(null, iarr);
nsize = dv.getUint16(j);
j += 2;
iarr = new Uint8Array( nsize);
for ( var k = 0; k < nsize; k++) {
iarr = new Uint8Array(nsize);
for (var k = 0; k < nsize; k++) {
iarr[k] = dv.getUint8(j++);
}
button.name = String.fromCharCode.apply( null, iarr);
button.name = String.fromCharCode.apply(null, iarr);
nsize = dv.getUint16(j);
j += 2;
iarr = new Uint8Array( nsize);
for ( var k = 0; k < nsize; k++) {
iarr = new Uint8Array(nsize);
for (var k = 0; k < nsize; k++) {
iarr[k] = dv.getUint8(j++);
}
button.url = String.fromCharCode.apply( null, iarr);
button.url = String.fromCharCode.apply(null, iarr);
result.buttons.push(button);
}
}
var pending_data = this.gdh.pending[id];
pending_data.func_cb( id, pending_data.data, sts, result);
pending_data.func_cb(id, pending_data.data, sts, result);
delete this.gdh.pending[id];
break;
}
case Msg.CHECK_USER: {
var j = 9;
if ( this.gdh.debug) console.log("Check user received", id, size);
if (this.gdh.debug) console.log("Check user received", id, size);
console.log("Check user received", sts, id);
var priv = 0;
if ( sts & 1) {
if (sts & 1) {
priv = dv.getUint32(j);
j += 4;
}
var pending_data = this.gdh.pending[id];
pending_data.func_cb( id, pending_data.data, sts, priv);
pending_data.func_cb(id, pending_data.data, sts, priv);
delete this.gdh.pending[id];
break;
}
case Msg.GET_MSG: {
if ( sts & 1) {
if (sts & 1) {
var j = 9;
var nsize = dv.getUint16(j);
j += 2;
var iarr = new Uint8Array( nsize);
for ( var k = 0; k < nsize; k++) {
var iarr = new Uint8Array(nsize);
for (var k = 0; k < nsize; k++) {
iarr[k] = dv.getUint8(j++);
}
var msg = String.fromCharCode.apply( null, iarr);
var msg = String.fromCharCode.apply(null, iarr);
}
var pending_data = this.gdh.pending[id];
pending_data.func_cb( id, pending_data.data, sts, msg);
pending_data.func_cb(id, pending_data.data, sts, msg);
delete this.gdh.pending[id];
break;
}
......@@ -1518,34 +1530,34 @@ function Gdh() {
var result = [];
var j = 9;
var size = dv.getUint32(j);
if ( this.gdh.debug) console.log("MhSync received", id, size);
if (this.gdh.debug) console.log("MhSync received", id, size);
j += 4;
for ( var i = 0; i < size; i++) {
for (var i = 0; i < size; i++) {
var e = new MhEvent();
var len = dv.getUint16(j);
j += 2;
var iarr = new Uint8Array( len);
for ( var k = 0; k < len; k++) {
var iarr = new Uint8Array(len);
for (var k = 0; k < len; k++) {
iarr[k] = dv.getUint8(j++);
}
e.eventTime = String.fromCharCode.apply( null, iarr);
e.eventTime = String.fromCharCode.apply(null, iarr);
len = dv.getUint16(j);
j += 2;
iarr = new Uint8Array( len);
for ( var k = 0; k < len; k++) {
iarr = new Uint8Array(len);
for (var k = 0; k < len; k++) {
iarr[k] = dv.getUint8(j++);
}
e.eventText = String.fromCharCode.apply( null, iarr);
e.eventText = String.fromCharCode.apply(null, iarr);
len = dv.getUint16(j);
j += 2;
iarr = new Uint8Array( len);
for ( var k = 0; k < len; k++) {
iarr = new Uint8Array(len);
for (var k = 0; k < len; k++) {
iarr[k] = dv.getUint8(j++);
}
e.eventName = String.fromCharCode.apply( null, iarr);
e.eventName = String.fromCharCode.apply(null, iarr);
e.eventFlags = dv.getUint32(j);
j += 4;
......@@ -1561,11 +1573,11 @@ function Gdh() {
j += 4;
len = dv.getUint16(j);
j += 2;
iarr = new Uint8Array( len);
for ( var k = 0; k < len; k++) {
iarr = new Uint8Array(len);
for (var k = 0; k < len; k++) {
iarr[k] = dv.getUint8(j++);
}
e.eventId.birthTime = String.fromCharCode.apply( null, iarr);
e.eventId.birthTime = String.fromCharCode.apply(null, iarr);
e.targetId = new MhEventId();
e.targetId.nix = dv.getUint32(j);
......@@ -1574,15 +1586,15 @@ function Gdh() {
j += 4;
len = dv.getUint16(j);
j += 2;
iarr = new Uint8Array( len);
for ( var k = 0; k < len; k++) {
iarr = new Uint8Array(len);
for (var k = 0; k < len; k++) {
iarr[k] = dv.getUint8(j++);
}
e.targetId.birthTime = String.fromCharCode.apply( null, iarr);
e.targetId.birthTime = String.fromCharCode.apply(null, iarr);
e.eventType = dv.getUint32(j);
j += 4;
var objid = new PwrtObjid(0,0);
var objid = new PwrtObjid(0, 0);
objid.vid = dv.getUint32(j);
j += 4;
objid.oix = dv.getUint32(j);
......@@ -1597,7 +1609,7 @@ function Gdh() {
j += 4;
e.object.flags = dv.getUint32(j);
j += 4;
var supObjid = new PwrtObjid(0,0);
var supObjid = new PwrtObjid(0, 0);
supObjid.vid = dv.getUint32(j);
j += 4;
supObjid.oix = dv.getUint32(j);
......@@ -1615,24 +1627,24 @@ function Gdh() {
len = dv.getUint16(j);
j += 2;
iarr = new Uint8Array( len);
for ( var k = 0; k < len; k++) {
iarr = new Uint8Array(len);
for (var k = 0; k < len; k++) {
iarr[k] = dv.getUint8(j++);
}
e.eventMoreText = String.fromCharCode.apply( null, iarr);
e.eventMoreText = String.fromCharCode.apply(null, iarr);
e.syncIdx = dv.getUint32(j);
j += 4;
result.push(e);
}
var pending_data = this.gdh.pending[id];
pending_data.func_cb( id, pending_data.data, sts, result);
pending_data.func_cb(id, pending_data.data, sts, result);
delete this.gdh.pending[id];
break;
}
case Msg.MH_ACK: {
var pending_data = this.gdh.pending[id];
pending_data.func_cb( id, pending_data.data, sts);
pending_data.func_cb(id, pending_data.data, sts);
delete this.gdh.pending[id];
break;
}
......@@ -1644,61 +1656,61 @@ function Gdh() {
};
};
this.getObjectInfoBoolean = function( name, return_cb) {
this.getObjectInfoBoolean = function (name, return_cb) {
this.return_cb = return_cb;
var buf = new Uint8Array(name.length+6);
var buf = new Uint8Array(name.length + 6);
buf[0] = Msg.GET_OBJECT_INFO_BOOLEAN;
buf[2] = this.next_id & 0xFF;
buf[3] = (this.next_id >> 8) & 0xFF;
buf[4] = (this.next_id >> 16) & 0xFF;
buf[5] = (this.next_id >> 24) & 0xFF;
for ( var i = 0; i < name.length; i++) {
buf[i+6] = name.charCodeAt(i);
for (var i = 0; i < name.length; i++) {
buf[i + 6] = name.charCodeAt(i);
}
this.pending[this.next_id] = new PendingData( return_cb, null);
this.pending[this.next_id] = new PendingData(return_cb, null);
this.ws.send(buf);
this.next_id++;
};
this.getObjectInfoInt = function( name, return_cb, data) {
this.getObjectInfoInt = function (name, return_cb, data) {
this.return_cb = return_cb;
var buf = new Uint8Array(name.length+6);
var buf = new Uint8Array(name.length + 6);
buf[0] = Msg.GET_OBJECT_INFO_INT;
buf[2] = this.next_id & 0xFF;
buf[3] = (this.next_id >> 8) & 0xFF;
buf[4] = (this.next_id >> 16) & 0xFF;
buf[5] = (this.next_id >> 24) & 0xFF;
for ( var i = 0; i < name.length; i++) {
buf[i+6] = name.charCodeAt(i);
for (var i = 0; i < name.length; i++) {
buf[i + 6] = name.charCodeAt(i);
}
this.pending[this.next_id] = new PendingData( return_cb, data);
this.pending[this.next_id] = new PendingData(return_cb, data);
this.ws.send(buf);
this.next_id++;
};
this.getObjectInfoFloat = function( name, return_cb, data) {
this.getObjectInfoFloat = function (name, return_cb, data) {
this.return_cb = return_cb;
var buf = new Uint8Array(name.length+6);
var buf = new Uint8Array(name.length + 6);
buf[0] = Msg.GET_OBJECT_INFO_FLOAT;
buf[2] = this.next_id & 0xFF;
buf[3] = (this.next_id >> 8) & 0xFF;
buf[4] = (this.next_id >> 16) & 0xFF;
buf[5] = (this.next_id >> 24) & 0xFF;
for ( var i = 0; i < name.length; i++) {
buf[i+6] = name.charCodeAt(i);
for (var i = 0; i < name.length; i++) {
buf[i + 6] = name.charCodeAt(i);
}
this.pending[this.next_id] = new PendingData( return_cb, data);
this.pending[this.next_id] = new PendingData(return_cb, data);
this.ws.send(buf);
this.next_id++;
};
this.getObjectInfoFloatArray = function( name, asize, return_cb, data) {
this.getObjectInfoFloatArray = function (name, asize, return_cb, data) {
this.return_cb = return_cb;
var buf = new Uint8Array(name.length+10);
var buf = new Uint8Array(name.length + 10);
buf[0] = Msg.GET_OBJECT_INFO_FLOAT_ARRAY;
buf[2] = this.next_id & 0xFF;
buf[3] = (this.next_id >> 8) & 0xFF;
......@@ -1708,15 +1720,15 @@ function Gdh() {
buf[7] = (asize >> 8) & 0xFF;
buf[8] = (asize >> 16) & 0xFF;
buf[9] = (asize >> 24) & 0xFF;
for ( var i = 0; i < name.length; i++) {
buf[i+10] = name.charCodeAt(i);
for (var i = 0; i < name.length; i++) {
buf[i + 10] = name.charCodeAt(i);
}
this.pending[this.next_id] = new PendingData( return_cb, data);
this.pending[this.next_id] = new PendingData(return_cb, data);
this.ws.send(buf);
this.next_id++;
};
this.refObjectInfo = function( name, type, elements) {
this.refObjectInfo = function (name, type, elements) {
var sub = new Sub();
sub.name = name;
sub.refid = this.subscriptionCount;
......@@ -1724,7 +1736,7 @@ function Gdh() {
sub.elements = elements;
this.sub[this.subscriptionCount] = sub;
this.subscriptionCount++;
if ( !this.listSent) {
if (!this.listSent) {
return sub.refid;
}
else {
......@@ -1733,13 +1745,13 @@ function Gdh() {
size = 12 + sub.name.length;
var buf = new Uint8Array(size+10);
var buf = new Uint8Array(size + 10);
buf[0] = Msg.REF_OBJECT_INFO;
buf[2] = this.next_id & 0xFF;
buf[3] = (this.next_id >> 8) & 0xFF;
buf[4] = (this.next_id >> 16) & 0xFF;
buf[5] = (this.next_id >> 24) & 0xFF;
if ( this.debug) console.log("RefObjectInfo: ", sub.refid);
if (this.debug) console.log("RefObjectInfo: ", sub.refid);
var k = 6;
buf[k++] = sub.refid & 0xFF;
buf[k++] = (sub.refid >> 8) & 0xFF;
......@@ -1754,12 +1766,12 @@ function Gdh() {
buf[k++] = (sub.name.length >> 16) & 0xFF;
buf[k++] = (sub.name.length >> 24) & 0xFF;
for ( var j = 0; j < sub.name.length; j++) {
for (var j = 0; j < sub.name.length; j++) {
buf[k++] = sub.name.charCodeAt(j);
}
this.pending[this.next_id] = new PendingData( this.refObjectInfoReply, null);
if ( this.debug) console.log( "Sending RefObjectInfo", this.next_id, size, k);
this.pending[this.next_id] = new PendingData(this.refObjectInfoReply, null);
if (this.debug) console.log("Sending RefObjectInfo", this.next_id, size, k);
this.ws.send(buf);
this.next_id++;
......@@ -1767,46 +1779,46 @@ function Gdh() {
return sub.refid;
}
};
this.refObjectInfoReply = function( id, sts) {
if ( this.debug) console.log( "refObjectInfoReply", id, sts);
this.refObjectInfoReply = function (id, sts) {
if (this.debug) console.log("refObjectInfoReply", id, sts);
};
this.unrefObjectInfo = function( refid) {
this.unrefObjectInfo = function (refid) {
var size = 0;
var len = 0;
size = 4;
var buf = new Uint8Array(size+10);
var buf = new Uint8Array(size + 10);
buf[0] = Msg.UNREF_OBJECT_INFO;
buf[2] = this.next_id & 0xFF;
buf[3] = (this.next_id >> 8) & 0xFF;
buf[4] = (this.next_id >> 16) & 0xFF;
buf[5] = (this.next_id >> 24) & 0xFF;
if ( this.debug) console.log("UnrefObjectInfo: ", refid);
if (this.debug) console.log("UnrefObjectInfo: ", refid);
var k = 6;
buf[k++] = refid & 0xFF;
buf[k++] = (refid >> 8) & 0xFF;
buf[k++] = (refid >> 16) & 0xFF;
buf[k++] = (refid >> 24) & 0xFF;
this.pending[this.next_id] = new PendingData( this.unrefObjectInfoReply, null);
if ( this.debug) console.log( "Sending UnrefObjectInfo", this.next_id, size, k, refid);
this.pending[this.next_id] = new PendingData(this.unrefObjectInfoReply, null);
if (this.debug) console.log("Sending UnrefObjectInfo", this.next_id, size, k, refid);
this.ws.send(buf);
this.next_id++;
delete this.sub[refid];
};
this.refObjectInfoList = function( return_cb) {
this.refObjectInfoList = function (return_cb) {
var size = 0;
var len = 0;
this.return_cb = return_cb;
for( var i in this.sub) {
for (var i in this.sub) {
size += 12 + this.sub[i].name.length;
len++;
}
var buf = new Uint8Array(size+10);
var buf = new Uint8Array(size + 10);
buf[0] = Msg.REF_OBJECT_INFO_LIST;
buf[2] = this.next_id & 0xFF;
buf[3] = (this.next_id >> 8) & 0xFF;
......@@ -1817,10 +1829,10 @@ function Gdh() {
buf[8] = (len >> 16) & 0xFF;
buf[9] = (len >> 24) & 0xFF;
var k = 10;
for ( var i in this.sub) {
if ( i === 0)
for (var i in this.sub) {
if (i === 0)
continue;
if ( this.debug) console.log("RefObjectInfoList: ", this.sub[i].refid);
if (this.debug) console.log("RefObjectInfoList: ", this.sub[i].refid);
buf[k++] = this.sub[i].refid & 0xFF;
buf[k++] = (this.sub[i].refid >> 8) & 0xFF;
buf[k++] = (this.sub[i].refid >> 16) & 0xFF;
......@@ -1834,40 +1846,40 @@ function Gdh() {
buf[k++] = (this.sub[i].name.length >> 16) & 0xFF;
buf[k++] = (this.sub[i].name.length >> 24) & 0xFF;
for ( var j = 0; j < this.sub[i].name.length; j++) {
for (var j = 0; j < this.sub[i].name.length; j++) {
buf[k++] = this.sub[i].name.charCodeAt(j);
}
}
this.pending[this.next_id] = new PendingData( return_cb, null);
if ( this.debug) console.log( "Sending RefObjectInfoList", this.next_id, size, k, this.next_id);
this.pending[this.next_id] = new PendingData(return_cb, null);
if (this.debug) console.log("Sending RefObjectInfoList", this.next_id, size, k, this.next_id);
this.ws.send(buf);
this.next_id++;
this.listSent = true;
};
this.refObjectInfoListReply = function( id, sts) {
if ( this.debug) console.log( "refObjectInfoListReply", id, sts);
this.refObjectInfoListReply = function (id, sts) {
if (this.debug) console.log("refObjectInfoListReply", id, sts);
};
this.getRefObjectInfoAll = function( return_cb) {
this.getRefObjectInfoAll = function (return_cb) {
var buf = new Uint8Array(6);
buf[0] = Msg.GET_OBJECT_REF_INFO_ALL;
buf[2] = this.next_id & 0xFF;
buf[3] = (this.next_id >> 8) & 0xFF;
buf[4] = (this.next_id >> 16) & 0xFF;
buf[5] = (this.next_id >> 24) & 0xFF;
this.pending[this.next_id] = new PendingData( return_cb, null);
if ( this.debug) console.log( "Sending getRefObjectInfoAll", 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(buf);
this.next_id++;
};
this.getRefObjectInfoAllReply = function( id, sts) {
if ( this.debug) console.log( "getRefObjectInfoAllReply", id, sts);
this.getRefObjectInfoAllReply = function (id, sts) {
if (this.debug) console.log("getRefObjectInfoAllReply", id, sts);
};
this.getObjectRefInfo = function( id) {
if ( this.debug) console.log("getObjectRefInfo", id, this.sub[id].value);
this.getObjectRefInfo = function (id) {
if (this.debug) console.log("getObjectRefInfo", id, this.sub[id].value);
return this.sub[id].value;
};
this.setObjectInfoBoolean = function( name, value) {
this.setObjectInfoBoolean = function (name, value) {
var buf = new Uint8Array(12 + name.length);
buf[0] = Msg.SET_OBJECT_INFO_BOOLEAN;
buf[2] = this.next_id & 0xFF;
......@@ -1881,17 +1893,17 @@ function Gdh() {
buf[10] = name.length & 0xFF;
buf[11] = (name.length >> 8) & 0xFF;
var k = 12;
for ( var i = 0; i < name.length; i++) {
for (var i = 0; i < name.length; i++) {
buf[k++] = name.charCodeAt(i);
}
this.ws.send(buf);
if ( this.debug) console.log("Sending setObjectInfoBoolean", this.next_id, name, value);
if (this.debug) console.log("Sending setObjectInfoBoolean", this.next_id, name, value);
this.next_id++;
return new PwrtStatus( 1);
return new PwrtStatus(1);
};
this.setObjectInfoInt = function( name, value) {
this.setObjectInfoInt = function (name, value) {
var buf = new Uint8Array(12 + name.length);
buf[0] = Msg.SET_OBJECT_INFO_INT;
buf[2] = this.next_id & 0xFF;
......@@ -1905,18 +1917,18 @@ function Gdh() {
buf[10] = name.length & 0xFF;
buf[11] = (name.length >> 8) & 0xFF;
var k = 12;
for ( var i = 0; i < name.length; i++) {
for (var i = 0; i < name.length; i++) {
buf[k++] = name.charCodeAt(i);
}
// this.pending[this.next_id] = new PendingData( return_cb, null);
this.ws.send(buf);
if ( this.debug) console.log("Sending setObjectInfoInt", this.next_id, name, value);
if (this.debug) console.log("Sending setObjectInfoInt", this.next_id, name, value);
this.next_id++;
return new PwrtStatus( 1);
return new PwrtStatus(1);
};
this.setObjectInfoFloat = function( name, value) {
this.setObjectInfoFloat = function (name, value) {
var buf = new Uint8Array(12 + name.length);
buf[0] = Msg.SET_OBJECT_INFO_FLOAT;
buf[2] = this.next_id & 0xFF;
......@@ -1934,20 +1946,20 @@ function Gdh() {
buf[10] = name.length & 0xFF;
buf[11] = (name.length >> 8) & 0xFF;
var k = 12;
for ( var i = 0; i < name.length; i++) {
for (var i = 0; i < name.length; i++) {
buf[k++] = name.charCodeAt(i);
}
// this.pending[this.next_id] = new PendingData( return_cb, null);
this.ws.send(buf);
if ( this.debug) console.log("Sending setObjectInfoFloat", this.next_id, name, value);
if (this.debug) console.log("Sending setObjectInfoFloat", this.next_id, name, value);
this.next_id++;
return new PwrtStatus( 1);
return new PwrtStatus(1);
};
this.setObjectInfoString = function( name, value) {
this.setObjectInfoString = function (name, value) {
var i;
var buf = new Uint8Array( 10 + value.length + name.length);
var buf = new Uint8Array(10 + value.length + name.length);
buf[0] = Msg.SET_OBJECT_INFO_STRING;
buf[2] = this.next_id & 0xFF;
buf[3] = (this.next_id >> 8) & 0xFF;
......@@ -1956,22 +1968,22 @@ function Gdh() {
buf[6] = value.length & 0xFF;
buf[7] = (value.length >> 8) & 0xFF;
var k = 8;
for ( i = 0; i < value.length; i++)
for (i = 0; i < value.length; i++)
buf[k++] = value.charCodeAt(i);
buf[k++] = name.length & 0xFF;
buf[k++] = (name.length >> 8) & 0xFF;
for ( i = 0; i < name.length; i++) {
for (i = 0; i < name.length; i++) {
buf[k++] = name.charCodeAt(i);
}
// this.pending[this.next_id] = new PendingData( return_cb, null);
this.ws.send(buf);
if ( this.debug) console.log("Sending setObjectInfoString", this.next_id, name, value);
if (this.debug) console.log("Sending setObjectInfoString", this.next_id, name, value);
this.next_id++;
return new PwrtStatus( 1);
return new PwrtStatus(1);
};
this.toggleObjectInfo = function( name) {
this.toggleObjectInfo = function (name) {
var buf = new Uint8Array(8 + name.length);
buf[0] = Msg.TOGGLE_OBJECT_INFO;
buf[2] = this.next_id & 0xFF;
......@@ -1981,18 +1993,18 @@ function Gdh() {
buf[6] = name.length & 0xFF;
buf[7] = (name.length >> 8) & 0xFF;
var k = 8;
for ( var i = 0; i < name.length; i++) {
for (var i = 0; i < name.length; i++) {
buf[k++] = name.charCodeAt(i);
}
// this.pending[this.next_id] = new PendingData( return_cb, null);
this.ws.send(buf);
if ( this.debug) console.log("Sending toggleObjectInfoBoolean", this.next_id, name, value);
if (this.debug) console.log("Sending toggleObjectInfoBoolean", this.next_id, name, value);
this.next_id++;
return new PwrtStatus( 1);
return new PwrtStatus(1);
};
this.getAllXttChildren = function( oid, return_cb, data) {
this.getAllXttChildren = function (oid, return_cb, data) {
var buf = new Uint8Array(14);
buf[0] = Msg.GET_ALL_XTT_CHILDREN;
buf[2] = this.next_id & 0xFF;
......@@ -2007,13 +2019,13 @@ function Gdh() {
buf[11] = (oid.oix >> 8) & 0xFF;
buf[12] = (oid.oix >> 16) & 0xFF;
buf[13] = (oid.oix >> 24) & 0xFF;
this.pending[this.next_id] = new PendingData( return_cb, data);
if ( this.debug) console.log( "Sending getAllXttChildren", this.next_id);
this.pending[this.next_id] = new PendingData(return_cb, data);
if (this.debug) console.log("Sending getAllXttChildren", this.next_id);
this.ws.send(buf);
this.next_id++;
};
this.getAllClassAttributes = function( cid, oid, return_cb, data) {
this.getAllClassAttributes = function (cid, oid, return_cb, data) {
var buf = new Uint8Array(18);
buf[0] = Msg.GET_ALL_CLASS_ATTRIBUTES;
buf[2] = this.next_id & 0xFF;
......@@ -2032,13 +2044,13 @@ function Gdh() {
buf[15] = (oid.oix >> 8) & 0xFF;
buf[16] = (oid.oix >> 16) & 0xFF;
buf[17] = (oid.oix >> 24) & 0xFF;
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.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(buf);
this.next_id++;
};
this.getObject = function( oid, op, return_cb, data) {
this.getObject = function (oid, op, return_cb, data) {
var buf = new Uint8Array(16);
buf[0] = Msg.GET_OBJECT;
buf[2] = this.next_id & 0xFF;
......@@ -2055,13 +2067,13 @@ function Gdh() {
buf[13] = (oid.oix >> 8) & 0xFF;
buf[14] = (oid.oix >> 16) & 0xFF;
buf[15] = (oid.oix >> 24) & 0xFF;
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.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(buf);
this.next_id++;
};
this.getObjectFromAref = function( aref, op, return_cb, data) {
this.getObjectFromAref = function (aref, op, return_cb, data) {
var buf = new Uint8Array(32);
buf[0] = Msg.GET_OBJECT_FROM_AREF;
buf[2] = this.next_id & 0xFF;
......@@ -2094,13 +2106,13 @@ function Gdh() {
buf[29] = (aref.flags >> 8) & 0xFF;
buf[30] = (aref.flags >> 16) & 0xFF;
buf[31] = (aref.flags >> 24) & 0xFF;
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.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(buf);
this.next_id++;
};
this.getObjectFromName = function( name, op, return_cb, data) {
this.getObjectFromName = function (name, op, return_cb, data) {
var buf = new Uint8Array(10 + name.length);
buf[0] = Msg.GET_OBJECT_FROM_NAME;
buf[2] = this.next_id & 0xFF;
......@@ -2112,16 +2124,16 @@ function Gdh() {
buf[8] = name.length & 0xFF;
buf[9] = (name.length >> 8) & 0xFF;
var k = 10;
for ( var i = 0; i < name.length; i++) {
for (var i = 0; i < name.length; i++) {
buf[k++] = name.charCodeAt(i);
}
this.pending[this.next_id] = new PendingData( return_cb, data);
if ( this.debug) console.log( "Sending getObjectFromName", this.next_id, 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(buf);
this.next_id++;
};
this.crrSignal = function( oid, return_cb, data) {
this.crrSignal = function (oid, return_cb, data) {
var buf = new Uint8Array(14);
buf[0] = Msg.CRR_SIGNAL;
buf[2] = this.next_id & 0xFF;
......@@ -2136,13 +2148,13 @@ function Gdh() {
buf[11] = (oid.oix >> 8) & 0xFF;
buf[12] = (oid.oix >> 16) & 0xFF;
buf[13] = (oid.oix >> 24) & 0xFF;
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.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(buf);
this.next_id++;
};
this.getOpwindMenu = function( name, return_cb, data) {
this.getOpwindMenu = function (name, return_cb, data) {
var len = name.length;
var buf = new Uint8Array(8 + name.length);
......@@ -2154,16 +2166,16 @@ function Gdh() {
buf[6] = name.length & 0xFF;
buf[7] = (name.length >> 8) & 0xFF;
var k = 8;
for ( var i = 0; i < name.length; i++) {
for (var i = 0; i < name.length; i++) {
buf[k++] = name.charCodeAt(i);
}
this.pending[this.next_id] = new PendingData( return_cb, data);
if ( this.debug) console.log( "Sending getOpwindMenu", this.next_id);
this.pending[this.next_id] = new PendingData(return_cb, data);
if (this.debug) console.log("Sending getOpwindMenu", this.next_id);
this.ws.send(buf);
this.next_id++;
};
this.login = function( user, passwd, return_cb, data) {
this.login = function (user, passwd, return_cb, data) {
var buf = new Uint8Array(6 + 2 + user.length + 2 + passwd.length);
buf[0] = Msg.CHECK_USER;
......@@ -2173,24 +2185,24 @@ function Gdh() {
buf[5] = (this.next_id >> 24) & 0xFF;
var k = 6;
buf[k] = user.length & 0xFF;
buf[k+1] = (user.length >> 8) & 0xFF;
buf[k + 1] = (user.length >> 8) & 0xFF;
k += 2;
for ( var i = 0; i < user.length; i++) {
for (var i = 0; i < user.length; i++) {
buf[k++] = user.charCodeAt(i);
}
buf[k] = passwd.length & 0xFF;
buf[k+1] = (passwd.length >> 8) & 0xFF;
buf[k + 1] = (passwd.length >> 8) & 0xFF;
k += 2;
for ( var i = 0; i < passwd.length; i++) {
for (var i = 0; i < passwd.length; i++) {
buf[k++] = passwd.charCodeAt(i);
}
this.pending[this.next_id] = new PendingData( return_cb, data);
if ( this.debug) console.log( "Sending login", this.next_id);
this.pending[this.next_id] = new PendingData(return_cb, data);
if (this.debug) console.log("Sending login", this.next_id);
this.ws.send(buf);
this.next_id++;
};
this.getMsg = function( value, return_cb, data) {
this.getMsg = function (value, return_cb, data) {
var buf = new Uint8Array(10);
buf[0] = Msg.GET_MSG;
buf[2] = this.next_id & 0xFF;
......@@ -2201,13 +2213,13 @@ function Gdh() {
buf[7] = (value >> 8) & 0xFF;
buf[8] = (value >> 16) & 0xFF;
buf[9] = (value >> 24) & 0xFF;
this.pending[this.next_id] = new PendingData( return_cb, data);
this.pending[this.next_id] = new PendingData(return_cb, data);
this.ws.send(buf);
if ( this.debug) console.log("Sending getMsg", this.next_id, value);
if (this.debug) console.log("Sending getMsg", this.next_id, value);
this.next_id++;
};
this.mhSync = function( sync, return_cb, data) {
this.mhSync = function (sync, return_cb, data) {
var buf = new Uint8Array(10);
buf[0] = Msg.MH_SYNC;
buf[2] = this.next_id & 0xFF;
......@@ -2218,13 +2230,13 @@ function Gdh() {
buf[7] = (sync >> 8) & 0xFF;
buf[8] = (sync >> 16) & 0xFF;
buf[9] = (sync >> 24) & 0xFF;
this.pending[this.next_id] = new PendingData( return_cb, data);
if ( this.debug) console.log( "Sending mhSync", this.next_id);
this.pending[this.next_id] = new PendingData(return_cb, data);
if (this.debug) console.log("Sending mhSync", this.next_id);
this.ws.send(buf);
this.next_id++;
};
this.mhAcknowledge = function( event_id, return_cb, data) {
this.mhAcknowledge = function (event_id, return_cb, data) {
var buf = new Uint8Array(16 + event_id.birthTime.length);
buf[0] = Msg.MH_ACK;
buf[2] = this.next_id & 0xFF;
......@@ -2241,18 +2253,19 @@ function Gdh() {
buf[13] = (event_id.idx >> 24) & 0xFF;
var k = 14;
buf[k] = event_id.birthTime.length & 0xFF;
buf[k+1] = (event_id.birthTime.length >> 8) & 0xFF;
buf[k + 1] = (event_id.birthTime.length >> 8) & 0xFF;
k += 2;
for ( var i = 0; i < event_id.birthTime.length; i++) {
for (var i = 0; i < event_id.birthTime.length; i++) {
buf[k++] = event_id.birthTime.charCodeAt(i);
}
this.pending[this.next_id] = new PendingData( return_cb, data);
if ( this.debug) console.log( "Sending mhAcknowledge", this.next_id);
console.log( "Sending mhAcknowledge", this.next_id);
this.pending[this.next_id] = new PendingData(return_cb, data);
if (this.debug) console.log("Sending mhAcknowledge", this.next_id);
console.log("Sending mhAcknowledge", this.next_id);
this.ws.send(buf);
this.next_id++;
};
}
/** End Gdh **/
/** Start OpWind **/
......@@ -2267,9 +2280,9 @@ function OpWindMenu() {
var self = this;
this.init = function() {
this.init = function () {
this.host = window.location.hostname;
if ( this.host == "")
if (this.host == "")
this.host = "localhost";
this.gdh = new Gdh();
......@@ -2277,11 +2290,11 @@ function OpWindMenu() {
this.gdh.init();
};
this.is_authorized = function( access) {
return ( this.priv & access) ? true : false;
this.is_authorized = function (access) {
return (this.priv & access) ? true : false;
}
this.get_opplace = function() {
this.get_opplace = function () {
var query = window.location.search.substring(1);
console.log("query", query);
......@@ -2290,138 +2303,138 @@ function OpWindMenu() {
return vars[0].substring(8);
};
this.gdh_init_cb = function() {
var oid = new PwrtObjid( 0, 0);
this.gdh_init_cb = function () {
var oid = new PwrtObjid(0, 0);
self.user = "Default";
self.gdh.login( "", "", self.login_cb, self);
self.gdh.getOpwindMenu( self.get_opplace(), self.get_menu_cb, 999);
self.gdh.login("", "", self.login_cb, self);
self.gdh.getOpwindMenu(self.get_opplace(), self.get_menu_cb, 999);
};
this.add_menu_button = function( context, text) {
var button = document.createElement( "input");
this.add_menu_button = function (context, text) {
var button = document.createElement("input");
button.type = "button";
button.className = "leftmenu-button";
button.value = text;
button.addEventListener( 'click', new Function( "menu.button_cb(\"" + button.value + "\")"));
context.appendChild( button);
context.appendChild( document.createElement( "br"));
button.addEventListener('click', new Function("menu.button_cb(\"" + button.value + "\")"));
context.appendChild(button);
context.appendChild(document.createElement("br"));
return button;
};
this.get_menu_cb = function( id, data, sts, result) {
this.get_menu_cb = function (id, data, sts, result) {
self.info = result;
console.log( "Menu received", sts, data, result.buttons.length);
console.log("Menu received", sts, data, result.buttons.length);
var context = document.getElementById("opwindmenu");
document.getElementById("opwind_title").innerHTML = result.title;
document.getElementById("opwind_text").innerHTML = result.text;
if ( result.enable_login) {
self.user_text = document.createTextNode( self.user + " on " + self.host);
context.appendChild( self.user_text);
context.appendChild( document.createElement( "hr"));
if (result.enable_login) {
self.user_text = document.createTextNode(self.user + " on " + self.host);
context.appendChild(self.user_text);
context.appendChild(document.createElement("hr"));
document.getElementById("login_button").addEventListener( "click", function( event) {
if ( document.getElementById("login_frame").style.visibility == 'hidden') {
document.getElementById("login_button").addEventListener("click", function (event) {
if (document.getElementById("login_frame").style.visibility == 'hidden') {
document.getElementById("login_user").value = "";
document.getElementById("login_passw").value = "";
document.getElementById("login_frame").style.visibility='visible';
document.getElementById("login_frame").style.height='120px';
document.getElementById("login_frame").style.visibility = 'visible';
document.getElementById("login_frame").style.height = '120px';
document.getElementById("login_user").focus();
}
else {
document.getElementById("login_frame").style.visibility='hidden';
document.getElementById("login_frame").style.height='0px';
document.getElementById("login_frame").style.visibility = 'hidden';
document.getElementById("login_frame").style.height = '0px';
}
});
document.getElementById("apply_button").addEventListener( "click", function( event) {
document.getElementById("apply_button").addEventListener("click", function (event) {
var user = document.getElementById("login_user").value;
var passwd = document.getElementById("login_passw").value;
if ( user.trim() == "")
if (user.trim() == "")
return;
document.getElementById("login_frame").style.visibility='hidden';
document.getElementById("login_frame").style.height='0px';
document.getElementById("login_frame").style.visibility = 'hidden';
document.getElementById("login_frame").style.height = '0px';
var c = new JopCrypt();
passwd = c.crypt( "aa", passwd);
passwd = c.crypt("aa", passwd);
self.user = user;
self.gdh.login( user, passwd, self.login_cb, self);
self.gdh.login(user, passwd, self.login_cb, self);
});
document.getElementById("cancel_button").addEventListener( "click", function( event) {
document.getElementById("login_frame").style.visibility='hidden';
document.getElementById("login_frame").style.height='0px';
document.getElementById("cancel_button").addEventListener("click", function (event) {
document.getElementById("login_frame").style.visibility = 'hidden';
document.getElementById("login_frame").style.height = '0px';
});
document.getElementById("logout_button").addEventListener( "click", function( event) {
document.getElementById("login_frame").style.visibility='hidden';
document.getElementById("login_frame").style.height='0px';
document.getElementById("logout_button").addEventListener("click", function (event) {
document.getElementById("login_frame").style.visibility = 'hidden';
document.getElementById("login_frame").style.height = '0px';
self.priv = 0;
self.user = "Default";
self.gdh.login( "", "", self.login_cb, self);
self.gdh.login("", "", self.login_cb, self);
});
document.getElementById("login_user").value = "";
document.getElementById("login_passw").value = "";
//document.getElementById("login_frame").setAttribute("style", "visibility:hidden;height:10px";
document.getElementById("login_frame").style.visibility='hidden';
document.getElementById("login_frame").style.height='0px';
document.getElementById("login_frame").style.visibility = 'hidden';
document.getElementById("login_frame").style.height = '0px';
}
else {
document.getElementById("login_button").remove();
document.getElementById("login_frame").remove();
}
if ( result.enable_language)
self.add_menu_button( context, "Language");
if ( result.enable_alarmlist) {
self.add_menu_button( context, "AlarmList");
self.add_menu_button( context, "EventList");
if (result.enable_language)
self.add_menu_button(context, "Language");
if (result.enable_alarmlist) {
self.add_menu_button(context, "AlarmList");
self.add_menu_button(context, "EventList");
}
if ( result.enable_eventlog)
self.add_menu_button( context, "EventLog");
if ( result.enable_navigator)
self.add_menu_button( context, "Navigator");
if ( !result.disable_help)
self.add_menu_button( context, "Help");
if ( !result.disable_proview)
self.add_menu_button( context, "ProviewR");
if (result.enable_eventlog)
self.add_menu_button(context, "EventLog");
if (result.enable_navigator)
self.add_menu_button(context, "Navigator");
if (!result.disable_help)
self.add_menu_button(context, "Help");
if (!result.disable_proview)
self.add_menu_button(context, "ProviewR");
context.appendChild( document.createElement( "hr"));
context.appendChild(document.createElement("hr"));
var button;
for ( var i = 0; i < result.buttons.length; i++) {
self.add_menu_button( context, result.buttons[i].text);
for (var i = 0; i < result.buttons.length; i++) {
self.add_menu_button(context, result.buttons[i].text);
}
};
this.button_cb = function( text) {
this.button_cb = function (text) {
if ( self.info.enable_language && text == "Language") {
if (self.info.enable_language && text == "Language") {
console.log("Language activated");
}
else if ( self.info.enable_alarmlist && text == "AlarmList") {
else if (self.info.enable_alarmlist && text == "AlarmList") {
console.log("AlarmList activated");
if ( !(self.is_authorized( Pwr.mAccess_RtRead | Pwr.mAccess_RtWrite |
if (!(self.is_authorized(Pwr.mAccess_RtRead | Pwr.mAccess_RtWrite |
Pwr.mAccess_AllOperators |
Pwr.mAccess_System | Pwr.mAccess_Maintenance |
Pwr.mAccess_Process | Pwr.mAccess_Instrument)))
window.alert("Not authorized for this operation");
else
window.open( "ev.html?list=alarm", "_blank");
window.open("ev.html?list=alarm", "_blank");
}
else if ( self.info.enable_alarmlist && text == "EventList") {
else if (self.info.enable_alarmlist && text == "EventList") {
console.log("EventList activated");
if ( !(self.is_authorized( Pwr.mAccess_RtRead | Pwr.mAccess_RtWrite |
if (!(self.is_authorized(Pwr.mAccess_RtRead | Pwr.mAccess_RtWrite |
Pwr.mAccess_AllOperators |
Pwr.mAccess_System | Pwr.mAccess_Maintenance |
Pwr.mAccess_Process | Pwr.mAccess_Instrument)))
window.alert("Not authorized for this operation");
else
window.open( "ev.html?list=event", "_blank");
window.open("ev.html?list=event", "_blank");
}
else if ( self.info.enable_eventlog && text == "EventLog") {
else if (self.info.enable_eventlog && text == "EventLog") {
console.log("EventLog activated");
if ( !(self.is_authorized( Pwr.mAccess_RtRead | Pwr.mAccess_RtWrite |
if (!(self.is_authorized(Pwr.mAccess_RtRead | Pwr.mAccess_RtWrite |
Pwr.mAccess_AllOperators |
Pwr.mAccess_System | Pwr.mAccess_Maintenance |
Pwr.mAccess_Process | Pwr.mAccess_Instrument)))
......@@ -2430,40 +2443,40 @@ function OpWindMenu() {
else
window.alert("Not yet implemented");
}
else if ( self.info.enable_navigator && text == "Navigator") {
else if (self.info.enable_navigator && text == "Navigator") {
console.log("Navigator activated");
if ( !(self.is_authorized( Pwr.mAccess_RtNavigator |
if (!(self.is_authorized(Pwr.mAccess_RtNavigator |
Pwr.mAccess_System | Pwr.mAccess_Maintenance |
Pwr.mAccess_Process | Pwr.mAccess_Instrument)))
window.alert("Not authorized for this operation");
else
window.open( "xtt.html", "_blank");
window.open("xtt.html", "_blank");
}
else if ( !self.info.disable_help && text == "Help") {
else if (!self.info.disable_help && text == "Help") {
console.log("Help activated");
window.open( "xtt_help_index.html", "_blank");
window.open("xtt_help_index.html", "_blank");
}
else if ( !self.info.disable_proview && text == "ProviewR") {
else if (!self.info.disable_proview && text == "ProviewR") {
console.log("ProviewR activated");
window.open( "http://www.proview.se", "_blank");
window.open("http://www.proview.se", "_blank");
}
else {
if ( !(self.is_authorized( Pwr.mAccess_RtRead | Pwr.mAccess_RtWrite |
if (!(self.is_authorized(Pwr.mAccess_RtRead | Pwr.mAccess_RtWrite |
Pwr.mAccess_AllOperators |
Pwr.mAccess_System | Pwr.mAccess_Maintenance |
Pwr.mAccess_Process | Pwr.mAccess_Instrument)))
window.alert("Not authorized for this operation");
else {
for ( var i = 0; i < self.info.buttons.length; i++) {
if ( self.info.buttons[i].text == text) {
for (var i = 0; i < self.info.buttons.length; i++) {
if (self.info.buttons[i].text == text) {
console.log("Found", self.info.buttons[i].text);
var name = self.info.buttons[i].name;
var n = name.indexOf(".pwg");
if ( n != -1)
name = name.substring(0,n);
if (n != -1)
name = name.substring(0, n);
var url = "ge.html?graph=" + name;
console.log("url", url);
window.open( url, "_blank");
window.open(url, "_blank");
break;
}
}
......@@ -2471,23 +2484,23 @@ function OpWindMenu() {
}
};
this.login_cb = function( id, data, sts, result) {
console.log( "Login:", sts, result);
if ( sts & 1) {
this.login_cb = function (id, data, sts, result) {
console.log("Login:", sts, result);
if (sts & 1) {
self.priv = result;
sessionStorage.setItem("pwr_privilege", self.priv);
if ( self.user_text != null)
if (self.user_text != null)
self.user_text.textContent = self.user + " on " + self.host;
console.log( "Login", self.user, "Priv", self.priv);
console.log("Login", self.user, "Priv", self.priv);
}
else {
self.priv = 0;
self.user = "none";
sessionStorage.setItem("pwr_privilege", self.priv);
if ( self.user_text != null)
if (self.user_text != null)
self.user_text.textContent = "None on " + self.host;
console.log( "Login failure", "Priv", self.priv);
console.log("Login failure", "Priv", self.priv);
}
};
}
......
This source diff could not be displayed because it is too large. You can view the blob instead.
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