Commit b12b2d08 authored by Claes Sjöfors's avatar Claes Sjöfors

javascript, URL_Symbols in WebLink added, socket server fix when page closed and include modules

parent d4f7f2f2
...@@ -2251,7 +2251,10 @@ public class GdhWebSocketServer ...@@ -2251,7 +2251,10 @@ public class GdhWebSocketServer
int oppDisableHelp = 0; int oppDisableHelp = 0;
int oppDisableProview = 0; int oppDisableProview = 0;
int oppLanguage = 0; int oppLanguage = 0;
String[] oppURL_Symbols = new String[10];
String webBrowser;
CdhrObjid oret; CdhrObjid oret;
CdhrString sret;
Vector<WebButton> v = new Vector<WebButton>(); Vector<WebButton> v = new Vector<WebButton>();
if ( opPlace.isEmpty()) { if ( opPlace.isEmpty()) {
...@@ -2301,6 +2304,22 @@ public class GdhWebSocketServer ...@@ -2301,6 +2304,22 @@ public class GdhWebSocketServer
if (iret.oddSts()) if (iret.oddSts())
oppDisableProview = iret.value; oppDisableProview = iret.value;
oret = gdh.getClassList( Pwrb.cClass_WebBrowserConfig);
if ( oret.oddSts()) {
webBrowser = gdh.objidToName(oret.objid, Cdh.mName_pathStrict).str;
for (int j = 0; j < 10; j++) {
sret = gdh.getObjectInfoString(webBrowser + ".URL_Symbols[" + j +"]");
if (sret.oddSts())
oppURL_Symbols[j] = sret.str;
else
oppURL_Symbols[j] = "";
}
}
else {
for (int j = 0; j < 10; j++)
oppURL_Symbols[j] = "";
}
CdhrObjid cdhrObjId = (CdhrObjid)gdh.getChild(objid); CdhrObjid cdhrObjId = (CdhrObjid)gdh.getChild(objid);
while(cdhrObjId.oddSts()) { while(cdhrObjId.oddSts()) {
String childName = gdh.objidToName(cdhrObjId.objid, Cdh.mName_pathStrict).str; String childName = gdh.objidToName(cdhrObjId.objid, Cdh.mName_pathStrict).str;
...@@ -2359,6 +2378,10 @@ public class GdhWebSocketServer ...@@ -2359,6 +2378,10 @@ public class GdhWebSocketServer
refsize += 4; // disable help refsize += 4; // disable help
refsize += 4; // disable proview refsize += 4; // disable proview
refsize += 4; // language refsize += 4; // language
for ( i = 0; i < 10; i++) {
refsize += 2; // URL symbol length
refsize += oppURL_Symbols[i].length();
}
refsize += 2; // button vector length refsize += 2; // button vector length
if ( (sts & 1) != 0) { if ( (sts & 1) != 0) {
for ( i = 0; i < v.size(); i++) { for ( i = 0; i < v.size(); i++) {
...@@ -2427,6 +2450,13 @@ public class GdhWebSocketServer ...@@ -2427,6 +2450,13 @@ public class GdhWebSocketServer
bb.putInt( j, oppLanguage); bb.putInt( j, oppLanguage);
j += 4; j += 4;
for ( i = 0; i < 10; i++) {
bb.putShort( j, (short)oppURL_Symbols[i].length());
j += 2;
for ( int k = 0; k < oppURL_Symbols[i].length(); k++) {
bb.put( j++, (byte)oppURL_Symbols[i].charAt(k));
}
}
bb.putShort( j, (short)v.size()); bb.putShort( j, (short)v.size());
j += 2; j += 2;
for ( i = 0; i < v.size(); i++) { for ( i = 0; i < v.size(); i++) {
...@@ -2781,7 +2811,44 @@ public class GdhWebSocketServer ...@@ -2781,7 +2811,44 @@ public class GdhWebSocketServer
} }
} }
catch ( java.io.IOException e) { catch ( java.io.IOException e) {
errh.error("DataStream failed");
try {
out.close();
}
catch(IOException e2) {
System.err.println("Close failed");
}
try {
in.close();
}
catch(IOException e2) {
System.err.println("Close failed");
}
try {
clientSocket.close();
}
catch(IOException e2) {
System.err.println("Close failed");
}
//check that all subscriptions has stopped
for(int i = 0; i < thSub.size(); i++) {
try {
sub = thSub.elementAt(i);
int index = thSub.elementAt(i).getIndex();
PwrtStatus sts = this.unrefObjectInfo(sub.subId, threadNumber);
}
catch(ArrayIndexOutOfBoundsException exc) {
}
}
// Reduce subscription size to save memory
this.trimRefObjectList();
connectionOccupied[threadNumber] = false;
threadCount--;
setCurrentConnections(threadCount);
System.out.println("ServerSocket IOException " + e.toString()); System.out.println("ServerSocket IOException " + e.toString());
System.out.println("Terminating thread " + threadNumber);
return;
} }
} }
public synchronized Sub refObjectInfo(String attrName, int threadNumber, int refId, int elements) public synchronized Sub refObjectInfo(String attrName, int threadNumber, int refId, int elements)
......
/** Start Cli **/
function CliTable( command, qualifier) {
this.command = command;
this.qualifier = qualifier;
}
var CliC = {
SUCCESS : 1,
SYNTAX_ERROR : 2,
UNKNOWN_COMMAND : 4,
QUALNOTFOUND : 6,
VERB_VECT_SIZE : 5,
STATE_INIT : 0,
STATE_VERB : 1,
STATE_QUAL : 2,
STATE_QUALVALUE : 3,
STATE_SPACE : 4,
STATE_EQUAL : 5,
STATE_ERROR : 6,
STATE_QUOTE_VERB : 7,
STATE_QUOTE_QUALVALUE : 8,
STATE_QUALVALUE_EXACT : 9,
STATE_VERB_EXACT : 10,
TAB : ' ',
SPACE : ' '
};
function Cli( cliTable) {
this.verb = new Array(CliC.VERB_VECT_SIZE);
this.verbCount = 0;
this.qualifier = new Array(30);
this.qualValue = new Array(30);
this.qualifierCount = 0;
this.status;
this.cliTableIndex;
this.cliQualifierIndex = new Array(30);
this.configuredVerbs;
this.cliTable = cliTable;
/**
* Return the status of the last operation as a string.
* @return The status of the last operation.
*/
this.getStsString = function() {
switch ( this.status) {
case CliC.SUCCESS: return "Success";
case CliC.SYNTAX_ERROR: return "Syntax error";
case CliC.UNKNOWN_COMMAND: return "Unknown command verb";
case CliC.QUALNOTFOUND: return "Unknown qualifier";
default: return "Unknown command interpreter error";
}
};
/**
* Check if status of last operation is even. An error or warning
* will result in an even status.
* @return Returns true if status of last operation is even.
*/
this.evenSts = function() {
return (this.status % 2 === 0);
};
/**
* Check if status of last operation is odd. A success or information
* will result in an odd status.
* @return Returns true if status of last operation is odd.
*/
this.oddSts = function() {
return (this.status % 2 !== 0);
};
/**
* Parse a command line and detect verbs and qualifiers.
* @param cmd Command line.
*/
this.parse = function( cmd) {
// Parse command string
var state = CliC.STATE_INIT;
var start_pos = 0;
this.status = CliC.SUCCESS;
this.verbCount = 0;
this.qualifierCount = 0;
var i;
for ( i = 0; i < cmd.length; i++) {
var c = cmd.charAt(i);
switch ( state) {
case CliC.STATE_INIT:
if ( c == CliC.SPACE || c == CliC.TAB)
break;
else {
state = CliC.STATE_VERB;
start_pos = i;
}
break;
case CliC.STATE_SPACE:
if ( c == CliC.SPACE || c == CliC.TAB)
break;
if ( c == '/') {
state = CliC.STATE_QUAL;
start_pos = i;
}
else if ( c == '=') {
if ( this.qualifierCount === 0) {
state = CliC.STATE_ERROR;
this.status = CliC.SYNTAX_ERROR;
break;
}
state = CliC.STATE_EQUAL;
}
else if ( c == '"') {
state = CliC.STATE_QUOTE_VERB;
break;
}
else {
state = CliC.STATE_VERB;
start_pos = i;
}
break;
case CliC.STATE_VERB:
if ( c == CliC.SPACE || c == CliC.TAB) {
if ( this.verbCount == CliC.VERB_VECT_SIZE) {
state = CliC.STATE_ERROR;
break;
}
if ( this.verbCount === 0)
this.verb[this.verbCount++] = cmd.substring( start_pos, i).toUpperCase();
else
this.verb[this.verbCount++] = cmd.substring( start_pos, i);
state = CliC.STATE_SPACE;
}
else if ( c == '/') {
if ( this.verbCount == CliC.VERB_VECT_SIZE) {
state = CliC.STATE_ERROR;
break;
}
this.verb[this.verbCount++] = cmd.substring( start_pos, i).toUpperCase();
state = CliC.STATE_QUAL;
start_pos = i;
}
break;
case CliC.STATE_VERB_EXACT:
if ( c == '"') {
if ( this.verbCount == CliC.VERB_VECT_SIZE) {
state = CliC.STATE_ERROR;
break;
}
this.verb[this.verbCount++] = cmd.substring( start_pos, i);
state = CliC.STATE_SPACE;
}
break;
case CliC.STATE_QUAL:
if ( c == CliC.SPACE || c == CliC.TAB) {
this.qualifier[this.qualifierCount++] = cmd.substring( start_pos, i).toUpperCase();
state = CliC.STATE_SPACE;
}
else if ( c == '=') {
this.qualifier[this.qualifierCount++] = cmd.substring( start_pos, i).toUpperCase();
state = CliC.STATE_EQUAL;
}
else if ( c == '/') {
this.qualifier[this.qualifierCount++] = cmd.substring( start_pos, i).toUpperCase();
state = CliC.STATE_QUAL;
start_pos = i;
}
break;
case CliC.STATE_QUALVALUE:
if ( c == CliC.SPACE || c == CliC.TAB) {
this.qualValue[this.qualifierCount-1] = cmd.substring( start_pos, i);
state = CliC.STATE_SPACE;
}
else if ( c == '/') {
this.qualValue[this.qualifierCount-1] = cmd.substring( start_pos, i);
state = CliC.STATE_QUAL;
start_pos = i;
}
break;
case CliC.STATE_QUALVALUE_EXACT:
if ( c == '"') {
this.qualValue[this.qualifierCount-1] = cmd.substring( start_pos, i);
state = CliC.STATE_SPACE;
}
break;
case CliC.STATE_QUOTE_VERB:
state = CliC.STATE_VERB_EXACT;
start_pos = i;
break;
case CliC.STATE_QUOTE_QUALVALUE:
state = CliC.STATE_QUALVALUE_EXACT;
start_pos = i;
break;
case CliC.STATE_EQUAL:
if ( c == CliC.SPACE || c == CliC.TAB)
break;
if ( c == '"') {
state = CliC.STATE_QUOTE_QUALVALUE;
}
else {
state = CliC.STATE_QUALVALUE;
start_pos = i;
}
break;
}
if ( state == CliC.STATE_ERROR)
break;
}
switch ( state) {
case CliC.STATE_INIT:
case CliC.STATE_ERROR:
return "";
case CliC.STATE_VERB:
if ( this.verbCount == CliC.VERB_VECT_SIZE) {
state = CliC.STATE_ERROR;
break;
}
if ( this.verbCount === 0)
this.verb[this.verbCount++] = cmd.substring( start_pos, i).toUpperCase();
else
this.verb[this.verbCount++] = cmd.substring( start_pos, i);
break;
case CliC.STATE_VERB_EXACT:
if ( this.verbCount == CliC.VERB_VECT_SIZE) {
state = CliC.STATE_ERROR;
break;
}
this.verb[this.verbCount++] = cmd.substring( start_pos, i);
break;
case CliC.STATE_QUAL:
this.qualifier[this.qualifierCount++] = cmd.substring( start_pos, i).toUpperCase();
break;
case CliC.STATE_QUALVALUE:
this.qualValue[this.qualifierCount-1] = cmd.substring( start_pos, i);
break;
case CliC.STATE_QUALVALUE_EXACT:
this.qualValue[this.qualifierCount-1] = cmd.substring( start_pos, i);
break;
case CliC.STATE_QUOTE_VERB:
case CliC.STATE_QUOTE_QUALVALUE:
case CliC.STATE_EQUAL:
this.status = CliC.SYNTAX_ERROR;
return "";
}
if ( this.verbCount === 0) {
this.status = CliC.SYNTAX_ERROR;
return "";
}
// for ( i = 0; i < this.verbCount; i++)
// console.log("verb: \"" + this.verb[i] + "\"");
// for ( i = 0; i < this.qualifierCount; i++)
// console.log("qual: \"" + this.qualifier[i] + "\" , \"" + this.qualValue[i] + "\"");
// Identify verbs and qualifiers
var found = false;
for ( i = 0; i < this.cliTable.length; i++) {
if ( this.verb[0].length > this.cliTable[i].command.length)
continue;
if ( this.verb[0] == ( this.cliTable[i].command.substring( 0, this.verb[0].length))) {
this.verb[0] = this.cliTable[i].command;
found = true;
break;
}
}
if ( !found) {
this.status = CliC.UNKNOWN_COMMAND;
return "";
}
this.cliTableIndex = i;
this.configuredVerbs = 0;
if ( this.cliTable[this.cliTableIndex].qualifier !== null)
{
for ( i = 0; i < this.cliTable[this.cliTableIndex].qualifier.length; i++) {
if ( this.cliTable[this.cliTableIndex].qualifier[i] === null)
break;
if ( this.cliTable[this.cliTableIndex].qualifier[i] == ("cli_arg1"))
this.configuredVerbs++;
if ( this.cliTable[this.cliTableIndex].qualifier[i] == ("cli_arg2"))
this.configuredVerbs++;
if ( this.cliTable[this.cliTableIndex].qualifier[i] == ("cli_arg3"))
this.configuredVerbs++;
if ( this.cliTable[this.cliTableIndex].qualifier[i] == ("cli_arg4"))
this.configuredVerbs++;
if ( this.cliTable[this.cliTableIndex].qualifier[i] == ("cli_arg5"))
this.configuredVerbs++;
}
for ( var j = 0; j < this.qualifierCount; j++) {
found = false;
for ( i = 0; i < this.cliTable[this.cliTableIndex].qualifier.length; i++) {
if ( this.cliTable[this.cliTableIndex].qualifier[i] === null)
break;
if ( this.qualifier[j].length > this.cliTable[this.cliTableIndex].qualifier[i].length)
continue;
if ( this.qualifier[j] == ( this.cliTable[this.cliTableIndex].qualifier[i].substring( 0, this.qualifier[j].length))) {
this.cliQualifierIndex[j] = i;
found = true;
this.qualifier[j] = this.cliTable[this.cliTableIndex].qualifier[i];
}
}
if ( !found) {
this.status = CliC.QUALNOTFOUND;
return "";
}
}
}
else if ( this.qualifierCount > 0) {
this.status = CliC.QUALNOTFOUND;
return "";
}
return this.verb[0];
};
/**
* Check if a qualifier was present in the last parse operation.
* @param qual Qualifier to check.
* @return Returns true if the qualifier is present.
*/
this.qualifierFound = function( qual) {
if ( qual == ("cli_arg1")) {
if ( this.verbCount < 2 || this.configuredVerbs < 1)
return false;
return true;
}
if ( qual == ("cli_arg2")) {
if ( this.verbCount < 3 || this.configuredVerbs < 2)
return false;
return true;
}
if ( qual == ("cli_arg3")) {
if ( this.verbCount < 4 || this.configuredVerbs < 3)
return false;
return true;
}
if ( qual == ("cli_arg4")) {
if ( this.verbCount < 5 || this.configuredVerbs < 4)
return false;
return true;
}
for ( var i = 0; i < this.qualifierCount; i++) {
if ( qual == (this.qualifier[i]))
return true;
}
return false;
};
/**
* Get the value of a qualifier in the last parse operation.
* @param qual Qualifier to check.
* @return Returns the value of the qualifier.
*/
this.getQualValue = function( qual) {
if ( qual == ("cli_arg1")) {
if ( this.verbCount < 2 || this.configuredVerbs < 1)
return "";
return this.verb[1];
}
if ( qual == ("cli_arg2")) {
if ( this.verbCount < 3 || this.configuredVerbs < 2)
return "";
return this.verb[2];
}
if ( qual == ("cli_arg3")) {
if ( this.verbCount < 4 || this.configuredVerbs < 3)
return this.verb[3];
}
if ( qual == ("cli_arg4")) {
if ( this.verbCount < 5 || this.configuredVerbs < 4)
return "";
return this.verb[4];
}
for ( var i = 0; i < this.qualifierCount; i++) {
if ( qual == (this.qualifier[i])) {
if ( this.qualValue[i] === null)
return "";
else
return this.qualValue[i];
}
}
return "";
};
}
/** End Cli **/
/** Crypt start **/
/****************************************************************************
* Proview
*
* Java-based implementation of the unix crypt command
*
* Based upon C source code written by Eric Young, eay@psych.uq.oz.au
*
* Author John Dumas, original name JCrypt
*
* Used and distributed with Proview by permission of the author.
*
****************************************************************************/
/**
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;
this.con_salt =
[
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,
0x0A, 0x0B, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A,
0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12,
0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A,
0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22,
0x23, 0x24, 0x25, 0x20, 0x21, 0x22, 0x23, 0x24,
0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C,
0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34,
0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C,
0x3D, 0x3E, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00,
];
this.shifts2 =
[
false, false, true, true, true, true, true, true,
false, true, true, true, true, true, true, false
];
this.skb =
[
[
/* for C bits (numbered as per FIPS 46) 1 2 3 4 5 6 */
0x00000000, 0x00000010, 0x20000000, 0x20000010,
0x00010000, 0x00010010, 0x20010000, 0x20010010,
0x00000800, 0x00000810, 0x20000800, 0x20000810,
0x00010800, 0x00010810, 0x20010800, 0x20010810,
0x00000020, 0x00000030, 0x20000020, 0x20000030,
0x00010020, 0x00010030, 0x20010020, 0x20010030,
0x00000820, 0x00000830, 0x20000820, 0x20000830,
0x00010820, 0x00010830, 0x20010820, 0x20010830,
0x00080000, 0x00080010, 0x20080000, 0x20080010,
0x00090000, 0x00090010, 0x20090000, 0x20090010,
0x00080800, 0x00080810, 0x20080800, 0x20080810,
0x00090800, 0x00090810, 0x20090800, 0x20090810,
0x00080020, 0x00080030, 0x20080020, 0x20080030,
0x00090020, 0x00090030, 0x20090020, 0x20090030,
0x00080820, 0x00080830, 0x20080820, 0x20080830,
0x00090820, 0x00090830, 0x20090820, 0x20090830,
],
[
/* for C bits (numbered as per FIPS 46) 7 8 10 11 12 13 */
0x00000000, 0x02000000, 0x00002000, 0x02002000,
0x00200000, 0x02200000, 0x00202000, 0x02202000,
0x00000004, 0x02000004, 0x00002004, 0x02002004,
0x00200004, 0x02200004, 0x00202004, 0x02202004,
0x00000400, 0x02000400, 0x00002400, 0x02002400,
0x00200400, 0x02200400, 0x00202400, 0x02202400,
0x00000404, 0x02000404, 0x00002404, 0x02002404,
0x00200404, 0x02200404, 0x00202404, 0x02202404,
0x10000000, 0x12000000, 0x10002000, 0x12002000,
0x10200000, 0x12200000, 0x10202000, 0x12202000,
0x10000004, 0x12000004, 0x10002004, 0x12002004,
0x10200004, 0x12200004, 0x10202004, 0x12202004,
0x10000400, 0x12000400, 0x10002400, 0x12002400,
0x10200400, 0x12200400, 0x10202400, 0x12202400,
0x10000404, 0x12000404, 0x10002404, 0x12002404,
0x10200404, 0x12200404, 0x10202404, 0x12202404,
],
[
/* for C bits (numbered as per FIPS 46) 14 15 16 17 19 20 */
0x00000000, 0x00000001, 0x00040000, 0x00040001,
0x01000000, 0x01000001, 0x01040000, 0x01040001,
0x00000002, 0x00000003, 0x00040002, 0x00040003,
0x01000002, 0x01000003, 0x01040002, 0x01040003,
0x00000200, 0x00000201, 0x00040200, 0x00040201,
0x01000200, 0x01000201, 0x01040200, 0x01040201,
0x00000202, 0x00000203, 0x00040202, 0x00040203,
0x01000202, 0x01000203, 0x01040202, 0x01040203,
0x08000000, 0x08000001, 0x08040000, 0x08040001,
0x09000000, 0x09000001, 0x09040000, 0x09040001,
0x08000002, 0x08000003, 0x08040002, 0x08040003,
0x09000002, 0x09000003, 0x09040002, 0x09040003,
0x08000200, 0x08000201, 0x08040200, 0x08040201,
0x09000200, 0x09000201, 0x09040200, 0x09040201,
0x08000202, 0x08000203, 0x08040202, 0x08040203,
0x09000202, 0x09000203, 0x09040202, 0x09040203,
],
[
/* for C bits (numbered as per FIPS 46) 21 23 24 26 27 28 */
0x00000000, 0x00100000, 0x00000100, 0x00100100,
0x00000008, 0x00100008, 0x00000108, 0x00100108,
0x00001000, 0x00101000, 0x00001100, 0x00101100,
0x00001008, 0x00101008, 0x00001108, 0x00101108,
0x04000000, 0x04100000, 0x04000100, 0x04100100,
0x04000008, 0x04100008, 0x04000108, 0x04100108,
0x04001000, 0x04101000, 0x04001100, 0x04101100,
0x04001008, 0x04101008, 0x04001108, 0x04101108,
0x00020000, 0x00120000, 0x00020100, 0x00120100,
0x00020008, 0x00120008, 0x00020108, 0x00120108,
0x00021000, 0x00121000, 0x00021100, 0x00121100,
0x00021008, 0x00121008, 0x00021108, 0x00121108,
0x04020000, 0x04120000, 0x04020100, 0x04120100,
0x04020008, 0x04120008, 0x04020108, 0x04120108,
0x04021000, 0x04121000, 0x04021100, 0x04121100,
0x04021008, 0x04121008, 0x04021108, 0x04121108,
],
[
/* for D bits (numbered as per FIPS 46) 1 2 3 4 5 6 */
0x00000000, 0x10000000, 0x00010000, 0x10010000,
0x00000004, 0x10000004, 0x00010004, 0x10010004,
0x20000000, 0x30000000, 0x20010000, 0x30010000,
0x20000004, 0x30000004, 0x20010004, 0x30010004,
0x00100000, 0x10100000, 0x00110000, 0x10110000,
0x00100004, 0x10100004, 0x00110004, 0x10110004,
0x20100000, 0x30100000, 0x20110000, 0x30110000,
0x20100004, 0x30100004, 0x20110004, 0x30110004,
0x00001000, 0x10001000, 0x00011000, 0x10011000,
0x00001004, 0x10001004, 0x00011004, 0x10011004,
0x20001000, 0x30001000, 0x20011000, 0x30011000,
0x20001004, 0x30001004, 0x20011004, 0x30011004,
0x00101000, 0x10101000, 0x00111000, 0x10111000,
0x00101004, 0x10101004, 0x00111004, 0x10111004,
0x20101000, 0x30101000, 0x20111000, 0x30111000,
0x20101004, 0x30101004, 0x20111004, 0x30111004,
],
[
/* for D bits (numbered as per FIPS 46) 8 9 11 12 13 14 */
0x00000000, 0x08000000, 0x00000008, 0x08000008,
0x00000400, 0x08000400, 0x00000408, 0x08000408,
0x00020000, 0x08020000, 0x00020008, 0x08020008,
0x00020400, 0x08020400, 0x00020408, 0x08020408,
0x00000001, 0x08000001, 0x00000009, 0x08000009,
0x00000401, 0x08000401, 0x00000409, 0x08000409,
0x00020001, 0x08020001, 0x00020009, 0x08020009,
0x00020401, 0x08020401, 0x00020409, 0x08020409,
0x02000000, 0x0A000000, 0x02000008, 0x0A000008,
0x02000400, 0x0A000400, 0x02000408, 0x0A000408,
0x02020000, 0x0A020000, 0x02020008, 0x0A020008,
0x02020400, 0x0A020400, 0x02020408, 0x0A020408,
0x02000001, 0x0A000001, 0x02000009, 0x0A000009,
0x02000401, 0x0A000401, 0x02000409, 0x0A000409,
0x02020001, 0x0A020001, 0x02020009, 0x0A020009,
0x02020401, 0x0A020401, 0x02020409, 0x0A020409,
],
[
/* for D bits (numbered as per FIPS 46) 16 17 18 19 20 21 */
0x00000000, 0x00000100, 0x00080000, 0x00080100,
0x01000000, 0x01000100, 0x01080000, 0x01080100,
0x00000010, 0x00000110, 0x00080010, 0x00080110,
0x01000010, 0x01000110, 0x01080010, 0x01080110,
0x00200000, 0x00200100, 0x00280000, 0x00280100,
0x01200000, 0x01200100, 0x01280000, 0x01280100,
0x00200010, 0x00200110, 0x00280010, 0x00280110,
0x01200010, 0x01200110, 0x01280010, 0x01280110,
0x00000200, 0x00000300, 0x00080200, 0x00080300,
0x01000200, 0x01000300, 0x01080200, 0x01080300,
0x00000210, 0x00000310, 0x00080210, 0x00080310,
0x01000210, 0x01000310, 0x01080210, 0x01080310,
0x00200200, 0x00200300, 0x00280200, 0x00280300,
0x01200200, 0x01200300, 0x01280200, 0x01280300,
0x00200210, 0x00200310, 0x00280210, 0x00280310,
0x01200210, 0x01200310, 0x01280210, 0x01280310,
],
[
/* for D bits (numbered as per FIPS 46) 22 23 24 25 27 28 */
0x00000000, 0x04000000, 0x00040000, 0x04040000,
0x00000002, 0x04000002, 0x00040002, 0x04040002,
0x00002000, 0x04002000, 0x00042000, 0x04042000,
0x00002002, 0x04002002, 0x00042002, 0x04042002,
0x00000020, 0x04000020, 0x00040020, 0x04040020,
0x00000022, 0x04000022, 0x00040022, 0x04040022,
0x00002020, 0x04002020, 0x00042020, 0x04042020,
0x00002022, 0x04002022, 0x00042022, 0x04042022,
0x00000800, 0x04000800, 0x00040800, 0x04040800,
0x00000802, 0x04000802, 0x00040802, 0x04040802,
0x00002800, 0x04002800, 0x00042800, 0x04042800,
0x00002802, 0x04002802, 0x00042802, 0x04042802,
0x00000820, 0x04000820, 0x00040820, 0x04040820,
0x00000822, 0x04000822, 0x00040822, 0x04040822,
0x00002820, 0x04002820, 0x00042820, 0x04042820,
0x00002822, 0x04002822, 0x00042822, 0x04042822,
],
];
this.SPtrans =
[
[
/* nibble 0 */
0x00820200, 0x00020000, 0x80800000, 0x80820200,
0x00800000, 0x80020200, 0x80020000, 0x80800000,
0x80020200, 0x00820200, 0x00820000, 0x80000200,
0x80800200, 0x00800000, 0x00000000, 0x80020000,
0x00020000, 0x80000000, 0x00800200, 0x00020200,
0x80820200, 0x00820000, 0x80000200, 0x00800200,
0x80000000, 0x00000200, 0x00020200, 0x80820000,
0x00000200, 0x80800200, 0x80820000, 0x00000000,
0x00000000, 0x80820200, 0x00800200, 0x80020000,
0x00820200, 0x00020000, 0x80000200, 0x00800200,
0x80820000, 0x00000200, 0x00020200, 0x80800000,
0x80020200, 0x80000000, 0x80800000, 0x00820000,
0x80820200, 0x00020200, 0x00820000, 0x80800200,
0x00800000, 0x80000200, 0x80020000, 0x00000000,
0x00020000, 0x00800000, 0x80800200, 0x00820200,
0x80000000, 0x80820000, 0x00000200, 0x80020200,
],
[
/* nibble 1 */
0x10042004, 0x00000000, 0x00042000, 0x10040000,
0x10000004, 0x00002004, 0x10002000, 0x00042000,
0x00002000, 0x10040004, 0x00000004, 0x10002000,
0x00040004, 0x10042000, 0x10040000, 0x00000004,
0x00040000, 0x10002004, 0x10040004, 0x00002000,
0x00042004, 0x10000000, 0x00000000, 0x00040004,
0x10002004, 0x00042004, 0x10042000, 0x10000004,
0x10000000, 0x00040000, 0x00002004, 0x10042004,
0x00040004, 0x10042000, 0x10002000, 0x00042004,
0x10042004, 0x00040004, 0x10000004, 0x00000000,
0x10000000, 0x00002004, 0x00040000, 0x10040004,
0x00002000, 0x10000000, 0x00042004, 0x10002004,
0x10042000, 0x00002000, 0x00000000, 0x10000004,
0x00000004, 0x10042004, 0x00042000, 0x10040000,
0x10040004, 0x00040000, 0x00002004, 0x10002000,
0x10002004, 0x00000004, 0x10040000, 0x00042000,
],
[
/* nibble 2 */
0x41000000, 0x01010040, 0x00000040, 0x41000040,
0x40010000, 0x01000000, 0x41000040, 0x00010040,
0x01000040, 0x00010000, 0x01010000, 0x40000000,
0x41010040, 0x40000040, 0x40000000, 0x41010000,
0x00000000, 0x40010000, 0x01010040, 0x00000040,
0x40000040, 0x41010040, 0x00010000, 0x41000000,
0x41010000, 0x01000040, 0x40010040, 0x01010000,
0x00010040, 0x00000000, 0x01000000, 0x40010040,
0x01010040, 0x00000040, 0x40000000, 0x00010000,
0x40000040, 0x40010000, 0x01010000, 0x41000040,
0x00000000, 0x01010040, 0x00010040, 0x41010000,
0x40010000, 0x01000000, 0x41010040, 0x40000000,
0x40010040, 0x41000000, 0x01000000, 0x41010040,
0x00010000, 0x01000040, 0x41000040, 0x00010040,
0x01000040, 0x00000000, 0x41010000, 0x40000040,
0x41000000, 0x40010040, 0x00000040, 0x01010000,
],
[
/* nibble 3 */
0x00100402, 0x04000400, 0x00000002, 0x04100402,
0x00000000, 0x04100000, 0x04000402, 0x00100002,
0x04100400, 0x04000002, 0x04000000, 0x00000402,
0x04000002, 0x00100402, 0x00100000, 0x04000000,
0x04100002, 0x00100400, 0x00000400, 0x00000002,
0x00100400, 0x04000402, 0x04100000, 0x00000400,
0x00000402, 0x00000000, 0x00100002, 0x04100400,
0x04000400, 0x04100002, 0x04100402, 0x00100000,
0x04100002, 0x00000402, 0x00100000, 0x04000002,
0x00100400, 0x04000400, 0x00000002, 0x04100000,
0x04000402, 0x00000000, 0x00000400, 0x00100002,
0x00000000, 0x04100002, 0x04100400, 0x00000400,
0x04000000, 0x04100402, 0x00100402, 0x00100000,
0x04100402, 0x00000002, 0x04000400, 0x00100402,
0x00100002, 0x00100400, 0x04100000, 0x04000402,
0x00000402, 0x04000000, 0x04000002, 0x04100400,
],
[
/* nibble 4 */
0x02000000, 0x00004000, 0x00000100, 0x02004108,
0x02004008, 0x02000100, 0x00004108, 0x02004000,
0x00004000, 0x00000008, 0x02000008, 0x00004100,
0x02000108, 0x02004008, 0x02004100, 0x00000000,
0x00004100, 0x02000000, 0x00004008, 0x00000108,
0x02000100, 0x00004108, 0x00000000, 0x02000008,
0x00000008, 0x02000108, 0x02004108, 0x00004008,
0x02004000, 0x00000100, 0x00000108, 0x02004100,
0x02004100, 0x02000108, 0x00004008, 0x02004000,
0x00004000, 0x00000008, 0x02000008, 0x02000100,
0x02000000, 0x00004100, 0x02004108, 0x00000000,
0x00004108, 0x02000000, 0x00000100, 0x00004008,
0x02000108, 0x00000100, 0x00000000, 0x02004108,
0x02004008, 0x02004100, 0x00000108, 0x00004000,
0x00004100, 0x02004008, 0x02000100, 0x00000108,
0x00000008, 0x00004108, 0x02004000, 0x02000008,
],
[
/* nibble 5 */
0x20000010, 0x00080010, 0x00000000, 0x20080800,
0x00080010, 0x00000800, 0x20000810, 0x00080000,
0x00000810, 0x20080810, 0x00080800, 0x20000000,
0x20000800, 0x20000010, 0x20080000, 0x00080810,
0x00080000, 0x20000810, 0x20080010, 0x00000000,
0x00000800, 0x00000010, 0x20080800, 0x20080010,
0x20080810, 0x20080000, 0x20000000, 0x00000810,
0x00000010, 0x00080800, 0x00080810, 0x20000800,
0x00000810, 0x20000000, 0x20000800, 0x00080810,
0x20080800, 0x00080010, 0x00000000, 0x20000800,
0x20000000, 0x00000800, 0x20080010, 0x00080000,
0x00080010, 0x20080810, 0x00080800, 0x00000010,
0x20080810, 0x00080800, 0x00080000, 0x20000810,
0x20000010, 0x20080000, 0x00080810, 0x00000000,
0x00000800, 0x20000010, 0x20000810, 0x20080800,
0x20080000, 0x00000810, 0x00000010, 0x20080010,
],
[
/* nibble 6 */
0x00001000, 0x00000080, 0x00400080, 0x00400001,
0x00401081, 0x00001001, 0x00001080, 0x00000000,
0x00400000, 0x00400081, 0x00000081, 0x00401000,
0x00000001, 0x00401080, 0x00401000, 0x00000081,
0x00400081, 0x00001000, 0x00001001, 0x00401081,
0x00000000, 0x00400080, 0x00400001, 0x00001080,
0x00401001, 0x00001081, 0x00401080, 0x00000001,
0x00001081, 0x00401001, 0x00000080, 0x00400000,
0x00001081, 0x00401000, 0x00401001, 0x00000081,
0x00001000, 0x00000080, 0x00400000, 0x00401001,
0x00400081, 0x00001081, 0x00001080, 0x00000000,
0x00000080, 0x00400001, 0x00000001, 0x00400080,
0x00000000, 0x00400081, 0x00400080, 0x00001080,
0x00000081, 0x00001000, 0x00401081, 0x00400000,
0x00401080, 0x00000001, 0x00001001, 0x00401081,
0x00400001, 0x00401080, 0x00401000, 0x00001001,
],
[
/* nibble 7 */
0x08200020, 0x08208000, 0x00008020, 0x00000000,
0x08008000, 0x00200020, 0x08200000, 0x08208020,
0x00000020, 0x08000000, 0x00208000, 0x00008020,
0x00208020, 0x08008020, 0x08000020, 0x08200000,
0x00008000, 0x00208020, 0x00200020, 0x08008000,
0x08208020, 0x08000020, 0x00000000, 0x00208000,
0x08000000, 0x00200000, 0x08008020, 0x08200020,
0x00200000, 0x00008000, 0x08208000, 0x00000020,
0x00200000, 0x00008000, 0x08000020, 0x08208020,
0x00008020, 0x08000000, 0x00000000, 0x00208000,
0x08200020, 0x08008020, 0x08008000, 0x00200020,
0x08208000, 0x00000020, 0x00200020, 0x08008000,
0x08208020, 0x00200000, 0x08200000, 0x08000020,
0x00208000, 0x00008020, 0x08008020, 0x08200000,
0x00000020, 0x08208000, 0x00208020, 0x00000000,
0x08000000, 0x08200020, 0x00008000, 0x00208020
]
];
this.cov_2char =
[
0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35,
0x36, 0x37, 0x38, 0x39, 0x41, 0x42, 0x43, 0x44,
0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C,
0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54,
0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x61, 0x62,
0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A,
0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72,
0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A
];
this.byteToUnsigned = function(b)
{
var value = Math.floor(b);
return(value >= 0 ? value : value + 256);
}
this.fourBytesToInt = function(b, offset)
{
var value;
value = this.byteToUnsigned(b[offset++]);
value |= (this.byteToUnsigned(b[offset++]) << 8);
value |= (this.byteToUnsigned(b[offset++]) << 16);
value |= (this.byteToUnsigned(b[offset++]) << 24);
return value;
}
this.intToFourBytes = function(iValue, b, offset)
{
b[offset++] = ((iValue) & 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)
{
var t;
t = ((a >>> n) ^ b) & m;
a ^= t << n;
b ^= t;
results[0] = a;
results[1] = b;
}
this.HPERM_OP = function(a, n, m)
{
var t;
t = ((a << (16 - n)) ^ a) & m;
a = a ^ t ^ (t >>> (16 - n));
return(a);
}
this.des_set_key = function(key) {
var schedule = new Array(this.ITERATIONS * 2);
var c = this.fourBytesToInt(key, 0);
var d = this.fourBytesToInt(key, 4);
var results = new Array(2);
this.PERM_OP(d, c, 4, 0x0f0f0f0f, results);
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];
this.PERM_OP(c, d, 8, 0x00ff00ff, results);
c = results[0]; d = results[1];
this.PERM_OP(d, c, 1, 0x55555555, results);
d = results[0]; c = results[1];
d = (((d & 0x000000ff) << 16) | (d & 0x0000ff00) |
((d & 0x00ff0000) >>> 16) | ((c & 0xf0000000) >>> 4));
c &= 0x0fffffff;
var s, t;
var j = 0;
for(var i = 0; i < this.ITERATIONS; i++) {
if(this.shifts2[i]) {
c = (c >>> 2) | (c << 26);
d = (d >>> 2) | (d << 26);
}
else
{
c = (c >>> 1) | (c << 27);
d = (d >>> 1) | (d << 27);
}
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)]|
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)];
schedule[j++] = ((t << 16) | (s & 0x0000ffff)) & 0xffffffff;
s = ((s >>> 16) | (t & 0xffff0000));
s = (s << 4) | (s >>> 28);
schedule[j++] = s & 0xffffffff;
}
return schedule;
}
this.D_ENCRYPT = function( L, R, S, E0, E1, s) {
var t, u, v;
v = R ^ (R >>> 16);
u = v & E0;
v = v & E1;
u = (u ^ (u << 16)) ^ R ^ s[S];
t = (v ^ (v << 16)) ^ R ^ s[S + 1];
t = (t >>> 4) | (t << 28);
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[2][(u >>> 8) & 0x3f] |
this.SPtrans[4][(u >>> 16) & 0x3f] |
this.SPtrans[6][(u >>> 24) & 0x3f];
return L;
}
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)
{
left = this.D_ENCRYPT(left, right, i, Eswap0, Eswap1, schedule);
right = this.D_ENCRYPT(right, left, i + 2, Eswap0, Eswap1, schedule);
}
t = left;
left = right;
right = t;
}
t = right;
right = (left >>> 1) | (left << 31);
left = (t >>> 1) | (t << 31);
left &= 0xffffffff;
right &= 0xffffffff;
var results = new Array(2);
this.PERM_OP(right, left, 1, 0x55555555, results);
right = results[0]; left = results[1];
this.PERM_OP(left, right, 8, 0x00ff00ff, results);
left = results[0]; right = results[1];
this.PERM_OP(right, left, 2, 0x33333333, results);
right = results[0]; left = results[1];
this.PERM_OP(left, right, 16, 0x0000ffff, results);
left = results[0]; right = results[1];
this.PERM_OP(right, left, 4, 0x0f0f0f0f, results);
right = results[0]; left = results[1];
var out = new Array(2);
out[0] = left; out[1] = right;
return(out);
}
this.crypt = function(salt, original) {
while(salt.length < 2)
salt += "A";
var buffer;
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);
buffer = charZero + charOne + " ";
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);
for(var i = 0; i < key.length && i < original.length; i ++)
{
var iChar = original.charCodeAt(i);
key[i] = iChar << 1;
}
var schedule = this.des_set_key(key);
var out = this.body(schedule, Eswap0, Eswap1);
var b = new Array(9);
this.intToFourBytes(out[0], b, 0);
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 ++)
{
c <<= 1;
if((b[y] & u) != 0)
c |= 1;
u >>>= 1;
if(u == 0)
{
y++;
u = 0x80;
}
buffer = buffer.substring(0,i) + String.fromCharCode(this.cov_2char[c]) +
buffer.substring(i+1,buffer.length);
}
}
return buffer;
};
}
/** Crypt end **/
/** Start Gdh **/
function Sub() {
this.sts;
this.refid;
this.type;
this.elements;
this.name;
this.value;
}
function ObjectInfo() {
this.objid;
this.cid;
this.has_children;
this.name;
this.description;
this.classname;
this.full_name;
this.param1;
}
function AttributeInfo() {
this.name;
this.type;
this.size;
this.flags;
this.element;
this.objid;
this.full_name;
this.classname;
}
function MenuButton() {
this.type;
this.text;
this.name;
this.url;
}
function OpwindMenuInfo() {
this.title;
this.text;
this.enable_language;
this.enable_login;
this.enable_alarmlist;
this.enable_eventlog;
this.enable_navigator;
this.disable_help;
this.disable_proview;
this.language;
this.url_symbols = [];
this.buttons = [];
}
function CrrInfo() {
this.type;
this.objid;
this.name;
this.classname;
}
function GlowPieInfo() {
this.sector_num;
this.min_val;
this.max_val;
}
function GlowBarChartInfo() {
this.bars;
this.barsegments;
this.min_value;
this.max_value;
}
function GlowTableInfo() {
this.columns;
this.rows;
this.column_size = new Array(Glow.TABLE_MAX_COL);
}
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
};
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
};
this.debug = false;
this.pending = [];
this.sub = [];
this.PORT = 4448;
this.ws = null;
this.open_cb = null;
this.close_cb = null;
this.return_cb = null;
this.next_id = 1234;
this.subscriptionCount = 1;
this.listSend = false;
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.binaryType = "arraybuffer";
this.ws.gdh = this;
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.gdh.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) {
var dv = new DataView(e.data);
var type = dv.getUint8(0);
var id = dv.getUint32(1);
var sts = dv.getUint32(5);
switch( type) {
case Msg.GET_OBJECT_INFO_BOOLEAN: {
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);
delete this.gdh.pending[id];
break;
}
case Msg.GET_OBJECT_INFO_INT: {
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);
delete this.gdh.pending[id];
break;
}
case Msg.GET_OBJECT_INFO_FLOAT: {
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);
delete this.gdh.pending[id];
break;
}
case Msg.GET_OBJECT_INFO_FLOAT_ARRAY: {
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++) {
value[i] = dv.getFloat32(k);
k += 4;
}
var 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);
var 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: {
var j = 9;
var size = dv.getUint32(j);
if ( this.gdh.debug) console.log("GetObjectRefInfoAll received", id, size);
j += 4;
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')
j += esize;
else {
var value;
switch ( sub.type) {
case Pwr.eType_Boolean:
if ( sub.elements <= 1) {
value = dv.getUint8(j);
j += 1;
}
else {
var elements = esize;
if ( elements != sub.elements)
console.log("Subscription size error", elements, sub.elements, eid);
value = new Array(elements);
for ( var k = 0; k < elements; k++) {
value[k] = dv.getUint8(j);
j += 1;
}
}
break;
case Pwr.eType_Float32:
if ( sub.elements <= 1) {
value = dv.getFloat32(j);
j += 4;
}
else {
var elements = esize / 4;
if ( elements != sub.elements)
console.log("Subscription size error", elements, sub.elements, eid);
value = new Array(elements);
for ( var k = 0; k < elements; k++) {
value[k] = dv.getFloat32(j);
j += 4;
}
}
break;
case Pwr.eType_Int8:
case Pwr.eType_Int16:
case Pwr.eType_Int32:
case Pwr.eType_UInt8:
case Pwr.eType_UInt16:
case Pwr.eType_UInt32:
case Pwr.eType_Status:
case Pwr.eType_NetStatus:
case Pwr.eType_Mask:
case Pwr.eType_Enum:
case GraphIfc.eType_Bit:
if ( sub.elements <= 1) {
value = dv.getInt32(j);
j += 4;
}
else {
var elements = esize / 4;
if ( elements != sub.elements)
console.log("Subscription size error", elements, sub.elements, eid);
value = new Array(elements);
for ( var k = 0; k < elements; k++) {
value[k] = dv.getInt32(j);
j += 4;
}
}
break;
case Pwr.eType_String:
case Pwr.eType_Time:
case Pwr.eType_DeltaTime:
case Pwr.eType_AttrRef:
case Pwr.eType_Objid:
if ( sub.elements <= 1) {
var nsize = dv.getInt16(j);
j += 2;
var iarr = new Uint8Array( nsize);
for ( var k = 0; k < nsize; k++) {
iarr[k] = dv.getUint8(j++);
}
value = String.fromCharCode.apply( null, iarr);
}
else {
var 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++) {
var nsize = dv.getInt16(j);
j += 2;
var iarr = new Uint8Array( nsize);
for ( var k = 0; k < nsize; k++) {
iarr[k] = dv.getUint8(j++);
}
value[l] = String.fromCharCode.apply( null, iarr);
}
}
break;
default: break;
}
this.gdh.sub[eid].value = value;
}
}
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);
delete this.gdh.pending[id];
break;
}
case Msg.GET_ALL_XTT_CHILDREN: {
var result = [];
var j = 9;
var size = dv.getUint32(j);
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++) {
var info = new ObjectInfo();
info.objid = new PwrtObjid();
info.objid.vid = dv.getUint32(j);
j += 4;
info.objid.oix = dv.getUint32(j);
j += 4;
info.cid = dv.getUint32(j);
j += 4;
info.has_children = dv.getUint16(j) !== 0;
j += 2;
var nsize = dv.getUint16(j);
j += 2;
var iarr = new Uint8Array( nsize);
for ( var k = 0; k < nsize; k++) {
iarr[k] = dv.getUint8(j++);
}
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[k] = dv.getUint8(j++);
}
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[k] = dv.getUint8(j++);
}
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);
delete this.gdh.pending[id];
break;
}
case Msg.GET_ALL_CLASS_ATTRIBUTES: {
var result = [];
var j = 9;
var size = dv.getUint32(j);
if ( this.gdh.debug) console.log("GetAllClassAttributes received", id, size);
j += 4;
for ( var i = 0; i < size; i++) {
var info = new AttributeInfo();
info.type = dv.getUint32(j);
j += 4;
info.flags = dv.getUint32(j);
j += 4;
info.size = dv.getUint16(j);
j += 2;
info.elements = dv.getUint16(j);
j += 2;
var nsize = dv.getUint16(j);
j += 2;
var iarr = new Uint8Array( nsize);
for ( var k = 0; k < nsize; k++) {
iarr[k] = dv.getUint8(j++);
}
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[k] = dv.getUint8(j++);
}
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);
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);
var info = null;
if ( (sts & 1) !== 0) {
var j = 9;
info = new ObjectInfo();
info.objid = new PwrtObjid();
info.objid.vid = dv.getUint32(j);
j += 4;
info.objid.oix = dv.getUint32(j);
j += 4;
info.cid = dv.getUint32(j);
j += 4;
info.has_children = dv.getUint16(j) !== 0;
j += 2;
var nsize = dv.getUint16(j);
j += 2;
var iarr = new Uint8Array( nsize);
for ( var k = 0; k < nsize; k++) {
iarr[k] = dv.getUint8(j++);
}
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[k] = dv.getUint8(j++);
}
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[k] = dv.getUint8(j++);
}
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[k] = dv.getUint8(j++);
}
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[k] = dv.getUint8(j++);
}
info.param1 = String.fromCharCode.apply( null, iarr);
}
var pending_data = this.gdh.pending[id];
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) {
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++) {
var info = new CrrInfo();
info.type = dv.getUint16(j);
j += 2;
info.objid = new PwrtObjid();
info.objid.vid = dv.getUint32(j);
j += 4;
info.objid.oix = dv.getUint32(j);
j += 4;
var nsize = dv.getUint16(j);
j += 2;
var iarr = new Uint8Array( nsize);
for ( var k = 0; k < nsize; k++) {
iarr[k] = dv.getUint8(j++);
}
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[k] = dv.getUint8(j++);
}
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);
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);
console.log("GetOpwindMenu received", sts, id);
if ( sts & 1) {
var nsize = dv.getUint16(j);
j += 2;
var iarr = new Uint8Array( nsize);
for ( var k = 0; k < nsize; k++) {
iarr[k] = dv.getUint8(j++);
}
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[k] = dv.getUint8(j++);
}
result.text = String.fromCharCode.apply( null, iarr);
result.enable_language = dv.getUint32(j);
j += 4;
result.enable_login = dv.getUint32(j);
j += 4;
result.enable_alarmlist = dv.getUint32(j);
j += 4;
result.enable_eventlog = dv.getUint32(j);
j += 4;
result.enable_navigator = dv.getUint32(j);
j += 4;
result.disable_help = dv.getUint32(j);
j += 4;
result.disable_proview = dv.getUint32(j);
j += 4;
result.language = dv.getUint32(j);
j += 4;
for ( var i = 0; i < 10; i++) {
nsize = dv.getUint16(j);
j += 2;
if ( nsize > 0) {
iarr = new Uint8Array( nsize);
for ( var k = 0; k < nsize; k++) {
iarr[k] = dv.getUint8(j++);
}
result.url_symbols[i] = String.fromCharCode.apply( null, iarr);
}
else
result.url_symbols[i] = "";
}
var bsize = dv.getUint16(j);
j += 2;
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[k] = dv.getUint8(j++);
}
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[k] = dv.getUint8(j++);
}
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[k] = dv.getUint8(j++);
}
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);
delete this.gdh.pending[id];
break;
}
case Msg.CHECK_USER: {
var j = 9;
if ( this.gdh.debug) console.log("Check user received", id, size);
console.log("Check user received", sts, id);
var priv = 0;
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);
delete this.gdh.pending[id];
break;
}
case Msg.GET_MSG: {
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++) {
iarr[k] = dv.getUint8(j++);
}
var msg = String.fromCharCode.apply( null, iarr);
}
var pending_data = this.gdh.pending[id];
pending_data.func_cb( id, pending_data.data, sts, msg);
delete this.gdh.pending[id];
break;
}
case Msg.MH_SYNC: {
var result = [];
var j = 9;
var size = dv.getUint32(j);
if ( this.gdh.debug) console.log("MhSync received", id, size);
j += 4;
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++) {
iarr[k] = dv.getUint8(j++);
}
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[k] = dv.getUint8(j++);
}
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[k] = dv.getUint8(j++);
}
e.eventName = String.fromCharCode.apply( null, iarr);
e.eventFlags = dv.getUint32(j);
j += 4;
e.eventStatus = dv.getUint32(j);
j += 4;
e.eventPrio = dv.getUint32(j);
j += 4;
e.eventId = new MhEventId();
e.eventId.nix = dv.getUint32(j);
j += 4;
e.eventId.idx = dv.getUint32(j);
j += 4;
len = dv.getUint16(j);
j += 2;
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.targetId = new MhEventId();
e.targetId.nix = dv.getUint32(j);
j += 4;
e.targetId.idx = dv.getUint32(j);
j += 4;
len = dv.getUint16(j);
j += 2;
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.eventType = dv.getUint32(j);
j += 4;
var objid = new PwrtObjid(0,0);
objid.vid = dv.getUint32(j);
j += 4;
objid.oix = dv.getUint32(j);
j += 4;
e.object = new PwrtAttrRef();
e.object.objid = objid;
e.object.offset = dv.getUint32(j);
j += 4;
e.object.body = dv.getUint32(j);
j += 4;
e.object.size = dv.getUint32(j);
j += 4;
e.object.flags = dv.getUint32(j);
j += 4;
var supObjid = new PwrtObjid(0,0);
supObjid.vid = dv.getUint32(j);
j += 4;
supObjid.oix = dv.getUint32(j);
j += 4;
e.supObject = new PwrtAttrRef();
e.supObject.objid = supObjid;
e.supObject.offset = dv.getUint32(j);
j += 4;
e.supObject.body = dv.getUint32(j);
j += 4;
e.supObject.size = dv.getUint32(j);
j += 4;
e.supObject.flags = dv.getUint32(j);
j += 4;
len = dv.getUint16(j);
j += 2;
iarr = new Uint8Array( len);
for ( var k = 0; k < len; k++) {
iarr[k] = dv.getUint8(j++);
}
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);
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);
delete this.gdh.pending[id];
break;
}
default:
console.log("Unknown message type");
}
}
}
};
};
this.getObjectInfoBoolean = function( name, return_cb) {
this.return_cb = return_cb;
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);
}
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.return_cb = return_cb;
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);
}
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.return_cb = return_cb;
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);
}
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.return_cb = return_cb;
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;
buf[4] = (this.next_id >> 16) & 0xFF;
buf[5] = (this.next_id >> 24) & 0xFF;
buf[6] = asize & 0xFF;
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);
}
this.pending[this.next_id] = new PendingData( return_cb, data);
this.ws.send(buf);
this.next_id++;
};
this.refObjectInfo = function( name, type, elements) {
var sub = new Sub();
sub.name = name;
sub.refid = this.subscriptionCount;
sub.type = type;
sub.elements = elements;
this.sub[this.subscriptionCount] = sub;
this.subscriptionCount++;
if ( !this.listSent) {
return sub.refid;
}
else {
var size = 0;
var len = 0;
size = 12 + sub.name.length;
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);
var k = 6;
buf[k++] = sub.refid & 0xFF;
buf[k++] = (sub.refid >> 8) & 0xFF;
buf[k++] = (sub.refid >> 16) & 0xFF;
buf[k++] = (sub.refid >> 24) & 0xFF;
buf[k++] = sub.elements & 0xFF;
buf[k++] = (sub.elements >> 8) & 0xFF;
buf[k++] = (sub.elements >> 16) & 0xFF;
buf[k++] = (sub.elements >> 24) & 0xFF;
buf[k++] = sub.name.length & 0xFF;
buf[k++] = (sub.name.length >> 8) & 0xFF;
buf[k++] = (sub.name.length >> 16) & 0xFF;
buf[k++] = (sub.name.length >> 24) & 0xFF;
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.ws.send(buf);
this.next_id++;
return sub.refid;
}
};
this.refObjectInfoReply = function( id, sts) {
if ( this.debug) console.log( "refObjectInfoReply", id, sts);
};
this.unrefObjectInfo = function( refid) {
var size = 0;
var len = 0;
size = 4;
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);
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.ws.send(buf);
this.next_id++;
delete this.sub[refid];
};
this.refObjectInfoList = function( return_cb) {
var size = 0;
var len = 0;
this.return_cb = return_cb;
for( var i in this.sub) {
size += 12 + this.sub[i].name.length;
len++;
}
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;
buf[4] = (this.next_id >> 16) & 0xFF;
buf[5] = (this.next_id >> 24) & 0xFF;
buf[6] = len & 0xFF;
buf[7] = (len >> 8) & 0xFF;
buf[8] = (len >> 16) & 0xFF;
buf[9] = (len >> 24) & 0xFF;
var k = 10;
for ( var i in this.sub) {
if ( i === 0)
continue;
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;
buf[k++] = (this.sub[i].refid >> 24) & 0xFF;
buf[k++] = this.sub[i].elements & 0xFF;
buf[k++] = (this.sub[i].elements >> 8) & 0xFF;
buf[k++] = (this.sub[i].elements >> 16) & 0xFF;
buf[k++] = (this.sub[i].elements >> 24) & 0xFF;
buf[k++] = this.sub[i].name.length & 0xFF;
buf[k++] = (this.sub[i].name.length >> 8) & 0xFF;
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++) {
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.ws.send(buf);
this.next_id++;
this.listSent = true;
};
this.refObjectInfoListReply = function( id, sts) {
if ( this.debug) console.log( "refObjectInfoListReply", id, sts);
};
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.ws.send(buf);
this.next_id++;
};
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);
return this.sub[id].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;
buf[3] = (this.next_id >> 8) & 0xFF;
buf[4] = (this.next_id >> 16) & 0xFF;
buf[5] = (this.next_id >> 24) & 0xFF;
buf[6] = value & 0xFF;
buf[7] = (value >> 8) & 0xFF;
buf[8] = (value >> 16) & 0xFF;
buf[9] = (value >> 24) & 0xFF;
buf[10] = name.length & 0xFF;
buf[11] = (name.length >> 8) & 0xFF;
var k = 12;
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);
this.next_id++;
return new PwrtStatus( 1);
};
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;
buf[3] = (this.next_id >> 8) & 0xFF;
buf[4] = (this.next_id >> 16) & 0xFF;
buf[5] = (this.next_id >> 24) & 0xFF;
buf[6] = value & 0xFF;
buf[7] = (value >> 8) & 0xFF;
buf[8] = (value >> 16) & 0xFF;
buf[9] = (value >> 24) & 0xFF;
buf[10] = name.length & 0xFF;
buf[11] = (name.length >> 8) & 0xFF;
var k = 12;
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);
this.next_id++;
return new PwrtStatus( 1);
};
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;
buf[3] = (this.next_id >> 8) & 0xFF;
buf[4] = (this.next_id >> 16) & 0xFF;
buf[5] = (this.next_id >> 24) & 0xFF;
var fbuf = new ArrayBuffer(4);
var fa = new Float32Array(fbuf);
fa[0] = value;
var ba = new Uint8Array(fbuf);
buf[6] = ba[0];
buf[7] = ba[1];
buf[8] = ba[2];
buf[9] = ba[3];
buf[10] = name.length & 0xFF;
buf[11] = (name.length >> 8) & 0xFF;
var k = 12;
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);
this.next_id++;
return new PwrtStatus( 1);
};
this.setObjectInfoString = function( name, value) {
var i;
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;
buf[4] = (this.next_id >> 16) & 0xFF;
buf[5] = (this.next_id >> 24) & 0xFF;
buf[6] = value.length & 0xFF;
buf[7] = (value.length >> 8) & 0xFF;
var k = 8;
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++) {
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);
this.next_id++;
return new PwrtStatus( 1);
};
this.toggleObjectInfo = function( name) {
var buf = new Uint8Array(8 + name.length);
buf[0] = Msg.TOGGLE_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;
buf[6] = name.length & 0xFF;
buf[7] = (name.length >> 8) & 0xFF;
var k = 8;
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);
this.next_id++;
return new PwrtStatus( 1);
};
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;
buf[3] = (this.next_id >> 8) & 0xFF;
buf[4] = (this.next_id >> 16) & 0xFF;
buf[5] = (this.next_id >> 24) & 0xFF;
buf[6] = oid.vid & 0xFF;
buf[7] = (oid.vid >> 8) & 0xFF;
buf[8] = (oid.vid >> 16) & 0xFF;
buf[9] = (oid.vid >> 24) & 0xFF;
buf[10] = oid.oix & 0xFF;
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.ws.send(buf);
this.next_id++;
};
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;
buf[3] = (this.next_id >> 8) & 0xFF;
buf[4] = (this.next_id >> 16) & 0xFF;
buf[5] = (this.next_id >> 24) & 0xFF;
buf[6] = cid & 0xFF;
buf[7] = (cid >> 8) & 0xFF;
buf[8] = (cid >> 16) & 0xFF;
buf[9] = (cid >> 24) & 0xFF;
buf[10] = oid.vid & 0xFF;
buf[11] = (oid.vid >> 8) & 0xFF;
buf[12] = (oid.vid >> 16) & 0xFF;
buf[13] = (oid.vid >> 24) & 0xFF;
buf[14] = oid.oix & 0xFF;
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.ws.send(buf);
this.next_id++;
};
this.getObject = function( oid, op, return_cb, data) {
var buf = new Uint8Array(16);
buf[0] = Msg.GET_OBJECT;
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;
buf[6] = op & 0xFF;
buf[7] = (op >> 8) & 0xFF;
buf[8] = oid.vid & 0xFF;
buf[9] = (oid.vid >> 8) & 0xFF;
buf[10] = (oid.vid >> 16) & 0xFF;
buf[11] = (oid.vid >> 24) & 0xFF;
buf[12] = oid.oix & 0xFF;
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.ws.send(buf);
this.next_id++;
};
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;
buf[3] = (this.next_id >> 8) & 0xFF;
buf[4] = (this.next_id >> 16) & 0xFF;
buf[5] = (this.next_id >> 24) & 0xFF;
buf[6] = op & 0xFF;
buf[7] = (op >> 8) & 0xFF;
buf[8] = aref.objid.vid & 0xFF;
buf[9] = (aref.objid.vid >> 8) & 0xFF;
buf[10] = (aref.objid.vid >> 16) & 0xFF;
buf[11] = (aref.objid.vid >> 24) & 0xFF;
buf[12] = aref.objid.oix & 0xFF;
buf[13] = (aref.objid.oix >> 8) & 0xFF;
buf[14] = (aref.objid.oix >> 16) & 0xFF;
buf[15] = (aref.objid.oix >> 24) & 0xFF;
buf[16] = aref.offset & 0xFF;
buf[17] = (aref.offset >> 8) & 0xFF;
buf[18] = (aref.offset >> 16) & 0xFF;
buf[19] = (aref.offset >> 24) & 0xFF;
buf[20] = aref.body & 0xFF;
buf[21] = (aref.body >> 8) & 0xFF;
buf[22] = (aref.body >> 16) & 0xFF;
buf[23] = (aref.body >> 24) & 0xFF;
buf[24] = aref.size & 0xFF;
buf[25] = (aref.size >> 8) & 0xFF;
buf[26] = (aref.size >> 16) & 0xFF;
buf[27] = (aref.size >> 24) & 0xFF;
buf[28] = aref.flags & 0xFF;
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.ws.send(buf);
this.next_id++;
};
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;
buf[3] = (this.next_id >> 8) & 0xFF;
buf[4] = (this.next_id >> 16) & 0xFF;
buf[5] = (this.next_id >> 24) & 0xFF;
buf[6] = op & 0xFF;
buf[7] = (op >> 8) & 0xFF;
buf[8] = name.length & 0xFF;
buf[9] = (name.length >> 8) & 0xFF;
var k = 10;
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.ws.send(buf);
this.next_id++;
};
this.crrSignal = function( oid, return_cb, data) {
var buf = new Uint8Array(14);
buf[0] = Msg.CRR_SIGNAL;
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;
buf[6] = oid.vid & 0xFF;
buf[7] = (oid.vid >> 8) & 0xFF;
buf[8] = (oid.vid >> 16) & 0xFF;
buf[9] = (oid.vid >> 24) & 0xFF;
buf[10] = oid.oix & 0xFF;
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.ws.send(buf);
this.next_id++;
};
this.getOpwindMenu = function( name, return_cb, data) {
var len = name.length;
var buf = new Uint8Array(8 + name.length);
buf[0] = Msg.GET_OPWIND_MENU;
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;
buf[6] = name.length & 0xFF;
buf[7] = (name.length >> 8) & 0xFF;
var k = 8;
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.ws.send(buf);
this.next_id++;
};
this.login = function( user, passwd, return_cb, data) {
var buf = new Uint8Array(6 + 2 + user.length + 2 + passwd.length);
buf[0] = Msg.CHECK_USER;
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;
var k = 6;
buf[k] = user.length & 0xFF;
buf[k+1] = (user.length >> 8) & 0xFF;
k += 2;
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;
k += 2;
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.ws.send(buf);
this.next_id++;
};
this.getMsg = function( value, return_cb, data) {
var buf = new Uint8Array(10);
buf[0] = Msg.GET_MSG;
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;
buf[6] = value & 0xFF;
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.ws.send(buf);
if ( this.debug) console.log("Sending getMsg", this.next_id, value);
this.next_id++;
};
this.mhSync = function( sync, return_cb, data) {
var buf = new Uint8Array(10);
buf[0] = Msg.MH_SYNC;
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;
buf[6] = sync & 0xFF;
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.ws.send(buf);
this.next_id++;
};
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;
buf[3] = (this.next_id >> 8) & 0xFF;
buf[4] = (this.next_id >> 16) & 0xFF;
buf[5] = (this.next_id >> 24) & 0xFF;
buf[6] = event_id.nix & 0xFF;
buf[7] = (event_id.nix >> 8) & 0xFF;
buf[8] = (event_id.nix >> 16) & 0xFF;
buf[9] = (event_id.nix >> 24) & 0xFF;
buf[10] = event_id.idx & 0xFF;
buf[11] = (event_id.idx >> 8) & 0xFF;
buf[12] = (event_id.idx >> 16) & 0xFF;
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;
k += 2;
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.ws.send(buf);
this.next_id++;
};
}
/** End Gdh **/
This source diff could not be displayed because it is too large. You can view the blob instead.
/** Start Plow **/
var Bitmaps = {
leaf : 0,
map : 2,
openmap : 4,
object : 6,
attrenum : 8,
attrarra : 10,
attrarel : 12,
attr : 14,
crrwrite : 16,
crrread : 18,
ack : 20,
alarm : 22,
eventacked : 24,
eventalarm : 26,
eventreturn : 28,
info : 30,
system : 32,
maintenance : 34,
blockl : 36,
blockr : 38,
img : [ null, null, null, null, null, null, null, null, null, null,
null, null, null, null, null, null, null, null, null, null,
null, null, null, null, null, null, null, null, null, null,
null, null, null, null, null, null, null, null],
pending : [ null, null, null, null, null, null, null, null, null, null,
null, null, null, null, null, null, null, null, null, null,
null, null, null, null, null, null, null, null, null, null,
null, null, null, null, null, null, null, null],
images : [
// leaf
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAMCAYAAABSgIzaAAAASElEQVQokWP4jwMwMDBgYBR5XBpwGYZVIzYNGDZB+QyEFOBiM+CyCacGBI0hgEGjsxkYGCiwkSI/4tKMz0DqxCM2A4hOOcQCAObFEQyI2PpKAAAAAElFTkSuQmCC',
// leaf inverted
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAMCAYAAABSgIzaAAAAQUlEQVQokWNgYGD4jw1jA2hqsGvAZRhWjdg0oIsh8QkqwMXGbhMuDXAxdAFsNDobyifTRor8SFGoUhSPFKUcYjEAMsMz2y6w8kgAAAAASUVORK5CYII=',
// map
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAMCAYAAABSgIzaAAAAKElEQVQokWP4DwUMDAwYGB9gwKUQm0FoGL/JOGwb1TgINZKFSbYOCgD1JxQJG0vK9AAAAABJRU5ErkJggg==',
// map inverted
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAMCAYAAABSgIzaAAAAK0lEQVQokWNgYGD4z8DA8B8bgMlhxbgUEgIMBE3Ggkc1Dk6N5AAGUm2DYQAkYTDe0vu7CAAAAABJRU5ErkJggg==',
// openmap
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAMCAYAAABSgIzaAAAAQklEQVQokaXOwQ4AIAgCUP7/p+nUlpMSzY2bDwWHA5IEkFJCtaiKxE7dvsue8HZNJEPneoAuSq+OYAf9wy4K0Mk5C+d++RWimsw3AAAAAElFTkSuQmCC',
// openmap inverted
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAMCAYAAABSgIzaAAAAPUlEQVQokaXRQQoAQAgCQP//6brKZmSt0M2hIACI4yBURqiKXQp0ThuhGwmt7Vy00XvqCa7QN1wjhtYLCCYyCkvDVnkJOQAAAABJRU5ErkJggg==',
// object
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAH0lEQVQokWP4TyJgYGBg+E8iZiDFdHrZMKqBGA2kYAD8gaJsjwzf9wAAAABJRU5ErkJggg==',
// object inverted
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAIklEQVQokWNgYGD4TxL+TyJg+P//P9GmwzXQ3oZRDdSOBwAGOSrkrXppgQAAAABJRU5ErkJggg==',
// attrenum
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAMCAYAAABSgIzaAAAAPklEQVQokWP4////fwYGBgxMCDBgU4jNICyYsOlYbENoJNIW7BqJsYm2NuJyBVE2EqWRfjbiUoQ3oAgpwgUANLqccvbgec0AAAAASUVORK5CYII=',
// attrenum inverted
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAMCAYAAABSgIzaAAAAPElEQVQokWNgYGD4jw0wMDDgx9gUEgMYiDIdDaNoJBZg1UiUTTS1EZcriLKRKI30sxGXIgKBhF8RrqgBAOTOqGZ5aiCnAAAAAElFTkSuQmCC',
// attrarra
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAMCAYAAABSgIzaAAAAMElEQVQokWP4////fwYGBgxMCDBgU4jNICwYv+nY5InWOGojXW0khLEahtc6PDYCAB9hxkjBPICvAAAAAElFTkSuQmCC',
// attrarray inverted
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAMCAYAAABSgIzaAAAALUlEQVQokWNgYGD4jw0wMDDgx9gUEgMYCJmOTZ5ojaM20tVGQgCHK/AnLVwAAPonfpBwU5f4AAAAAElFTkSuQmCC',
// attrarel
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAIklEQVQokWP4////fwYGBpwYHTDANGADeDWM2jAEbSAFAADB26JsIjYj1AAAAABJRU5ErkJggg==',
// attrarel inverted
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAIElEQVQokWNgYGD4jw8wMDCgYwZcEvg1jNowBG0gBQMAQN8q5COZl1cAAAAASUVORK5CYII=',
// attr
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAIUlEQVQokWP4TyJgGIQaGBgY/pOIibcEroEkTLIfhoEGADzs8B5gcUg/AAAAAElFTkSuQmCC',
// attr inverted
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAJUlEQVQokWNgYGD4TyIedBr+kwgY/v//T7TpcA0k2TAIQ4nmGgDFzt0jExR7hgAAAABJRU5ErkJggg==',
// crrwrite
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAN0lEQVQokaWNQQoAMAjD8v9P633WVWhBkJIotQQoYPYbrHYrqC9D+MG54OBMuMC54GApuPBed9OxiMNLGke1JwAAAABJRU5ErkJggg==',
// crrwrite inverted
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAANElEQVQokWNgYGD4jw3DABY57IqxsQlqwGELSYop1ECEYgo0EKmYQg1EKMbUQEAxRAMpAABRMgoFjbTzXgAAAABJRU5ErkJggg==',
// crrread
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAPElEQVQokWNgYGD4j4yRATY5BmyKkGks4qgS2BSj2UYFDdgAdW2gvpOwhDW6ItwaCGI8JuHWgMOtWD0PACufaaWhXDFDAAAAAElFTkSuQmCC',
// crrread inverted
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAPElEQVQokWP4jwYYGBjgGKscNkXINLo4hgZsipFto44GbJi6NlDfSehhjUxjyGMVxQMYcJmEVwPB5ICEAdcbY6vf9TVAAAAAAElFTkSuQmCC',
// ack
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAS0lEQVQokZ2Q2w4AIAhCz///ND11M3RVmxuDUBRAtw8QHRyC4SSJSDjDht1Yhxdudks+bFNxYsX9G6rz2qVHxqRspGi2Wpoji/dqaLh22DbO2VuXAAAAAElFTkSuQmCC',
// ack inverted
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAASklEQVQokWP4////fwYGBqIwVC2cgSKBTQzKxhDA0ICmGau12BRCMLJp2BQgy8H9gM9ELGJkasAXvFg9TQjgDCVc8YBXAwFMmgYASkT1C9E5Ya0AAAAASUVORK5CYII=',
// alarm
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAARklEQVQokZ2QQQoAMAjD+v9Pu9PA1ThQQRBtoFUBJSkk0SlwOwKykCAEcn+BK8hih/aAe++y7IDuhWgXfcKHCuBBfX6ASR3Vn8ZINQzCrQAAAABJRU5ErkJggg==',
// alarm inverted
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAQ0lEQVQokWNgYGD4j45hAJscA8UakBXi0ITddDy2YJqOrBiLJjI1oLsdj1/I0IAnCLFpwtSALYQwNKB7FJ2NooEUDAAtGwcI+Svs4gAAAABJRU5ErkJggg==',
// eventacked
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAL0lEQVQokWP4TyJgGCkaGBgQyhhwSeASw9CAYho2A3CZiE0xVg34FOPUgA+QrAEA1FYi+tWeG/cAAAAASUVORK5CYII=',
// eventacked inverted
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAMElEQVQokWNgYGD4TyIeGRr+//+PXQOaBC4xVElkBdgMwHASTBEOxdj9gEcxHYIVAC5kqlZXl5JMAAAAAElFTkSuQmCC',
// eventalarm
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAJ0lEQVQokWP4jwMwMDBgF8elGIZHNeDSANOEVRyXBpwGUcUGqvoBAK+H8xt0qXFWAAAAAElFTkSuQmCC',
// eventalarm inverted
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAJ0lEQVQokWNgYGD4jw3///8fqzgDLsUwMKoBlwaSg5UAHoiIw2cDAFMz2iY65DAoAAAAAElFTkSuQmC',
// eventreturn
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAASUlEQVQokZ2RUQoAIAjFdv9L11dhskeUEIQ2mcYIAXjeisA+EahFA9ad/siAA0wqSUsnu87wDZh3VEodO6Rr1c51rc8fd9OoMQHLk7dXak3qLwAAAABJRU5ErkJggg==',
// eventreturn inverted
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAR0lEQVQokZ2S2woAIAhD9/8/vV6tjgMNhLxMN1SSTGYb46JkfS2gJglQ/ncRAZ5JTCXQYsFRwxpAvFtKoeMvmoqDv1jc5DQONycV+bfOetgAAAAASUVORK5CYII=',
// info
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAOUlEQVQokWNgYGD4///////E0AwMDP8hPDQAk8QhjlMCuzg2G3AB6tlAez8MglAiCZNiw/////8DACmmtFrq9aGNAAAAAElFTkSuQmCC',
// info inverted
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAN0lEQVQokWP4////fwYGhv/E0FA2w390jCSJIc6ASwKnBmw24MLUs4H2fhgEoUQKIMkGBgaG/wDZFBj2pVi3HgAAAABJRU5ErkJggg==',
// system
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAN0lEQVQokWNgYGD4TyJm+E8sgGugig3YxHFqwGcIQQ3obAwN6G7GawMuhVg1EFKMUwM+QJ+IAwDD1Gyi1EZc6gAAAABJRU5ErkJggg==',
// system inverted
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAO0lEQVQokWP4TyJg+P///38GBgaiMFwDVWzAJo5TA15DCGnAYKNrwHAzPhtwKcSqgZBinBqIigeaRhwAPuZgrlZXy70AAAAASUVORK5CYII=',
// maintenance
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAP0lEQVQokZWPQQoAMAzC8v9Pu8soDOxaBS82QkWNgPKTJ/BYsLekAOxfquwHWyfws6ED7OgtfNk9bAuTSGBJOufqnHIsmYkzAAAAAElFTkSuQmCC',
// maintenance inverted
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAQUlEQVQokZWPQQ4AMAQE5/+f1kuTCkuROGAmADCVPsJsBfdCsX0u3N7sJFfXsAqW8BMaID+9gE3SJayEFo7CFwY7GtAw3ouVj50AAAAASUVORK5CYII=',
// blockl
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAQElEQVQokZ2QQQ4AMAjC+v9Pu9MWl5AJ42a0IlKBgCIadgGgQ8imqo9D3zDBvJoyR+zwlWHS9SUHaOf4QOywtQCQGucn0g2dEQAAAABJRU5ErkJggg==',
// blockl inverted
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAOklEQVQokWNgYGD4Tyz+////fwZSFBOtAaoQQsM46JLY+HAbUEwgrJmwyZTZQJYfSAolmsQDWTENwwByoOYaWbAqegAAAABJRU5ErkJggg==',
// blockr
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAPElEQVQokWP4jwMwMDBgF8enAZsmvBqw2cSARQBDIQqbGEUoaggpQBcj3Qay/IAN4AwlfBrIigeiNeACADpU5yeYXn+XAAAAAElFTkSuQmCC',
// blockr inverted
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAPElEQVQokWNgYGD4jw3///8fqzgDPg04NOG3AUMTugA2hWhqiFKEzCeoAF2MRBvI8gNJoUT1eCBaAy4MAMhm5hr5iTaWAAAAAElFTkSuQmCC'
]
};
var Plow = {
DRAWOFFSET : 2,
DEST_INTOLAST : 0,
DEST_INTOFIRST : 1,
DEST_AFTER : 2,
DEST_BEFORE : 3,
TREE_INDENTATION : 1.0,
OPEN_ATTRIBUTES : 1,
OPEN_CHILDREN : 2,
OPEN_CROSSREFERENCES : 4,
OPEN_ALL : 7,
COLOR_BLACK : 1,
COLOR_RED : 2,
COLOR_GRAY : 3,
COLOR_DARKGRAY : 4,
COLOR_LIGHTGRAY : 5,
COLOR_WHITE : 6,
COLOR_YELLOW : 7,
COLOR_GREEN : 8,
COLOR_LIGHTBLUE : 9,
COLOR_BLUE : 10,
COLOR_VIOLET : 11,
eEvent_MB1Click : 0,
eEvent_MB1ClickShift : 1,
eEvent_Key_Up : 2,
eEvent_Key_Down : 3,
eEvent_Key_Right : 4,
eEvent_Key_Left : 5,
eEvent_Key_ShiftRight : 6,
eEvent_Key_CtrlR : 7,
eEvent_Key_CtrlL : 8,
eEvent_Key_CtrlG : 9,
eEvent_ObjectDeleted : 10,
RELATIVE_POSITION : 1,
NEXT_RELATIVE_POSITION : 2
}
function PlowGeometry() {
this.ll_x = 0;
this.ll_y = 0;
this.ur_x = 0;
this.ur_y = 0;
}
function PlowNodeClass( ctx) {
this.a = new PlowArray( ctx);
this.ctx = ctx;
this.nc_name = "";
this.group = 0;
this.node_open = 0;
this.draw = function( g, p, node, highlight) {
this.a.draw( g, p, node, highlight);
}
this.insert = function( elem) {
this.a.add(elem);
}
}
function PlowArray( ctx) {
this.a = [];
this.ctx = ctx;
this.add = function( elem) {
this.a.push(elem);
}
this.insertNode = function( elem, destination, code) {
var idx = this.find( elem);
if ( idx != -1)
return;
if ( destination == null) {
switch( code) {
case Plow.DEST_INTOLAST:
case Plow.DEST_AFTER:
this.a.push(elem);
elem.level = 0;
break;
default:
elem.level = 0;
this.a.unshift(elem);
}
}
else {
var dest_idx = this.find( destination);
if ( dest_idx == -1)
return;
switch( code) {
case Plow.DEST_INTOFIRST:
if ( dest_idx == this.a.length - 1)
this.a.push( elem);
else
this.a.splice( dest_idx + 1, 0, elem);
elem.level = destination.level + 1;
break;
case Plow.DEST_INTOLAST: {
if ( dest_idx == this.a.length - 1)
this.a.push( elem);
else {
idx = this.a.length;
for ( var i = dest_idx + 1; i < this.a.length; i++) {
if ( this.a[i].level <= destination.level) {
idx = i;
break;
}
}
if ( idx == this.a.length)
this.a.push( elem);
else
this.a.splice( idx, 0, elem);
}
elem.level = destination.level + 1;
break;
}
case Plow.DEST_AFTER: {
if ( dest_idx == this.a.length - 1)
this.a.push( elem);
else {
var i;
for ( i = idx; i < this.a.length; i++) {
if ( this.a[i].level < destination.level)
break;
}
this.a.splice( i, 0, elem);
}
elem.level = destination.level;
break;
}
case Plow.DEST_BEFORE:
if ( idx > 0)
idx--;
this.a.splice( idx, 0, elem);
elem.level = destination.level;
break;
}
}
}
this.remove = function( elem) {
var idx = this.find( elem);
if ( idx == -1)
return;
this.ctx.event_cb( Plow.eEvent_ObjectDeleted, this.a[idx+1], 0, 0);
this.a.splice( idx, 1);
}
this.size = function() {
return this.a.length;
}
this.get = function( idx) {
return this.a[idx];
}
this.draw = function( g, p, node, highlight) {
for ( var i = 0; i < this.a.length; i++)
this.a[i].draw( g, p, node, highlight);
}
this.set_borders = function( node) {
for ( var i = 0; i < this.a.length; i++)
this.a[i].set_borders( node);
}
this.configure = function() {
for ( var i = 0; i < this.a.length; i++) {
this.a[i].pos.x = this.a[i].level * 1.0;
this.a[i].pos.y = i * 1.0;
}
}
this.close_node = function( node) {
var idx = this.find( node);
if ( idx == -1)
return;
var level = node.level;
var i;
for ( i = idx + 1; i < this.a.length; i++) {
if ( this.a[i].level <= level)
break;
}
var next_idx = i;
if ( next_idx == idx + 1)
return;
for ( i = idx + 1; i < next_idx; i++) {
// Event backcall
if ( ctx.select_object == this.a[idx+1])
ctx.select_object = null;
this.ctx.event_cb( Plow.eEvent_ObjectDeleted, this.a[idx+1], 0, 0);
this.a.splice( idx+1, 1);
}
}
this.get_parent_object = function( node) {
var idx = this.find( node);
if ( idx == -1)
return null;
for ( var i = idx; i >= 0; i--) {
if ( this.a[i].level < node.level)
return this.a[i];
}
return null;
}
this.get_first_child = function( node) {
var idx = this.find( node);
if ( idx == -1)
return null;
if ( this.a.length == idx - 1)
return null;
if ( this.a[idx + 1].level > node.level)
return this.a[idx + 1];
return null;
}
this.get_next_sibling = function( node) {
var found = false;
for ( var i = 0; i < this.a.length; i++) {
if ( this.a[i] == node) {
found = true;
continue;
}
if ( found) {
if ( this.a[i].level == node.level)
return this.a[i];
if ( this.a[i].level < node.level)
return null;
}
}
return null;
}
this.get_next_object = function( node) {
for ( var i = 0; i < this.a.length; i++) {
if ( this.a[i] == node) {
if ( i == this.a.length - 1)
return null;
return this.a[i+1];
}
}
return null;
}
this.get_previous_object = function( node) {
for ( var i = 0; i < this.a.length; i++) {
if ( this.a[i] == node) {
if ( i == 0)
return null;
return this.a[i-1];
}
}
return null;
}
this.get_first_object = function() {
if ( this.a.length == 0)
return null;
return this.a[0];
}
this.get_last_object = function() {
if ( this.a.length == 0)
return null;
return this.a[this.a.length - 1];
}
this.find = function( elem) {
for ( var i = 0; i < this.a.length; i++) {
if ( this.a[i] == elem)
return i;
}
return -1;
}
}
function PlowNode( ctx, nc, level) {
this.ctx = ctx;
this.userdata = null;
this.OFFSET = 2;
this.x_right = 0.0;
this.x_left = 0.0;
this.y_high = 0.0;
this.y_low = 0.0;
this.nc = nc;
this.pos = new PlowPoint(ctx,0,0);
this.n_name = "";
this.annotv = [];
this.annotsize = [];
this.pixmapv = [];
this.trace_object = "";
this.trace_attribute = "";
this.trace_attr_type = 0;
this.highlight = false;
this.select = false;
this.invert = false;
this.level = level;
this.node_open = false;
this.fill_color = 0;
this.p = 0;
this.old_value = 0;
this.first_scan = true;
this.relative_position = 0;
this.set_annotation = function( number, text) {
if ( number >= 10)
return;
this.annotv[number] = text;
}
this.set_annotation_pixmap = function( number, pixmap) {
if ( number >= 10)
return;
this.pixmapv[number] = pixmap;
}
this.draw_object = function() {
this.draw( this.ctx.gdraw.gctx, null, null, false);
}
this.draw = function( g, p, node, highlight) {
var x = this.x_left * this.ctx.zoom_factor;
var y = this.y_low * this.ctx.zoom_factor-1;
var width = (this.x_right - this.x_left) * this.ctx.zoom_factor;
var height = (this.y_high - this.y_low) * this.ctx.zoom_factor+2;
g.fillStyle = "white";
if ( this.select)
g.fillStyle = "lightblue";
g.fillRect( x, y, width, height);
this.nc.draw( g, this.pos, this, this.highlight);
}
this.connect = function() {
if ( this.trace_object == "" || this.trace_attribute == "")
return;
var n = this.trace_attribute.indexOf('#');
if ( n != -1)
this.trace_attribute = this.trace_attribute.substring(0, n);
var o = this.trace_object + "." + this.trace_attribute;
this.p = ctx.gdh.refObjectInfo( o, this.trace_attr_type);
console.log("connecting", o, this.p);
}
this.scan = function() {
if ( this.p == 0)
return;
var v1 = ctx.gdh.getRefObjectInfo( this.p);
var evaluate = true;
if ( this.first_scan)
this.first_scan = false;
else if ( v1 == this.old_value)
return;
if ( v1)
this.highlight = true;
else
this.highlight = false;
this.old_value = v1;
this.draw_object();
}
this.set_borders = function() {
this.x_left = 1e37;
this.x_right = -1e37;
this.y_low = 1e37;
this.y_high = -1e37;
nc.a.set_borders( this);
}
this.event_handler = function( event, x, y) {
if ( (x - this.ctx.offset_x) / this.ctx.zoom_factor >= this.x_left &&
(x - this.ctx.offset_x) / this.ctx.zoom_factor <= this.x_right &&
(y - this.ctx.offset_y) / this.ctx.zoom_factor >= this.y_low &&
(y - this.ctx.offset_y) / this.ctx.zoom_factor <= this.y_high) {
ctx.event_object = this;
return 1;
}
return 0;
}
this.set_select = function( select) {
if ( select) {
this.select = true;
this.ctx.select_object = this;
}
else {
this.select = false;
if ( this.ctx.select_object == this)
this.ctx.select_object = null;
}
if ( select != this.select)
this.draw_object();
}
this.set_invert = function( invert) {
this.invert = invert;
this.draw_object();
}
this.set_userdata = function( userdata) {
this.userdata = userdata;
}
this.get_userdata = function() {
return this.userdata;
}
this.in_icon = function( x, y) {
if ( x >= this.x_left * this.ctx.zoom_factor &&
x <= (this.x_left + 1.75) * this.ctx.zoom_factor)
return true;
return false;
}
this.measure = function() {
var geom = new PlowGeometry();
geom.ll_x = this.x_left * this.ctx.zoom_factor;
geom.ll_y = this.y_low * this.ctx.zoom_factor;
geom.ur_x = this.x_right * this.ctx.zoom_factor;
geom.ur_y = this.y_high * this.ctx.zoom_factor;
return geom;
};
}
function PlowPoint( ctx, x, y) {
this.x = x;
this.y = y;
this.ctx = ctx;
}
function PlowAnnot( ctx, x, y, text_size, text_color, annot_type, number) {
this.RELATIVE_OFFSET = 1;
this.p = new PlowPoint(ctx, x, y);
this.draw_type = text_color;
this.text_size = text_size;
this.annot_type = annot_type;
this.number = number;
this.ctx = ctx;
this.draw = function( g, p0, node, highlight) {
if ( node == null)
return;
if ( node.annotv[this.number] == null)
return;
var tsize = 0;
var idx = this.ctx.zoom_factor / this.ctx.base_zoom_factor * (this.text_size +4) - 4;
if ( idx < 0) return;
switch( idx) {
case 0: tsize = 8; break;
case 1: tsize = 10; break;
case 2: tsize = 12; break;
case 3: tsize = 14; break;
case 4: tsize = 14; break;
case 5: tsize = 18; break;
case 6: tsize = 18; break;
case 7: tsize = 18; break;
default: tsize = idx * 3;
}
g.font = tsize + "px Arial";
if ( node.invert)
g.fillStyle = "white";
else
g.fillStyle = "black";
if ( highlight)
g.fillStyle = "red";
g.lineWidth = 0.5;
var x = (this.p.x + p0.x) * this.ctx.zoom_factor;
var y = (this.p.y + p0.y) * this.ctx.zoom_factor - tsize/4;
if ( (this.annot_type & Plow.RELATIVE_POSITION) != 0) {
var rel_x = (p0.x + node.relative_position + this.RELATIVE_OFFSET) * this.ctx.zoom_factor;
if ( x < rel_x)
x = rel_x;
}
var tokens = node.annotv[this.number].split('\n');
for ( var i = 0; i < tokens.length; i++) {
g.fillText( tokens[i], x, y);
y += tsize * 1.4;
}
if ( (this.annot_type & Plow.NEXT_RELATIVE_POSITION) != 0 || (this.annot_type & Plow.RELATIVE_POSITION) != 0) {
node.relative_position = (x + g.measureText(node.annotv[this.number]).width) / this.ctx.zoom_factor - p0.x;
}
}
this.set_borders = function( node) {
}
}
function PlowAnnotPixmap( ctx, x, y, number) {
this.p = new PlowPoint(ctx, x, y);
this.number = number;
this.ctx = ctx;
this.draw = function( gctx, p0, node, highlight) {
var x = (this.p.x + p0.x) * this.ctx.zoom_factor;
var y = (this.p.y + p0.y) * this.ctx.zoom_factor;
var img;
var bix = node.pixmapv[this.number];
if ( typeof bix === 'undefined' || bix === null)
return;
if ( node.invert)
bix++;
img = Bitmaps.img[bix];
if ( img == null) {
var img = new Image();
img.src = Bitmaps.images[bix];
Bitmaps.img[bix] = img;
Bitmaps.pending[bix] = [];
Bitmaps.pending[bix].push(new PlowPoint(this.ctx, x, y));
img.onload = function() {
for ( var i = 0; i < Bitmaps.pending[bix].length; i++)
gctx.drawImage(img, Bitmaps.pending[bix][i].x, Bitmaps.pending[bix][i].y);
Bitmaps.pending[bix] = null;
}
}
else {
if ( !img.complete)
Bitmaps.pending[bix].push(new PlowPoint(this.ctx, x, y));
else
gctx.drawImage(img, x, y);
}
}
this.set_borders = function( node) {
}
}
function PlowRect( ctx, x, y, width, height, fill_color, border_color, fill, fix_color) {
this.ll = new PlowPoint(ctx, x, y);
this.ur = new PlowPoint(ctx, x + width, y + height);
this.border_color = border_color;
this.fill_color = fill_color;
this.fill = fill;
this.fix_color = fix_color;
this.ctx = ctx;
this.draw = function( g, p, node, highlight) {
var x = (this.ll.x + p.x) * this.ctx.zoom_factor;
var y = (this.ll.y + p.y) * this.ctx.zoom_factor;
var width = (this.ur.x - this.ll.x) * this.ctx.zoom_factor;
var height = (this.ur.y - this.ll.y) * this.ctx.zoom_factor;
g.lineWidth = 1;
switch ( this.border_color) {
case Plow.COLOR_GRAY:
g.strokeStyle = "grey";
break;
case Plow.COLOR_RED:
g.strokeStyle = "red";
break;
case Plow.COLOR_WHITE:
g.strokeStyle = "white";
break;
default:
g.strokeStyle = "black";
}
if ( highlight)
g.strokeStyle = "red";
g.strokeRect( x, y, width, height);
if ( this.fill) {
switch ( this.fill_color) {
case Plow.COLOR_GRAY:
g.fillStyle = "grey";
break;
case Plow.COLOR_RED:
g.fillStyle = "red";
break;
case Plow.COLOR_YELLOW:
g.fillStyle = "yellow";
break;
case Plow.COLOR_GREEN:
g.fillStyle = "lightgreen";
break;
case Plow.COLOR_WHITE:
if ( node.invert)
g.fillStyle = "black";
else
g.fillStyle = "white";
break;
default:
if ( node.invert)
g.fillStyle = "white";
else
g.fillStyle = "black";
}
g.fillRect( x, y, width, height);
}
}
this.set_borders = function( node) {
if ( this.ll.x + node.pos.x < node.x_left)
node.x_left = this.ll.x + node.pos.x;
if ( this.ur.x + node.pos.x > node.x_right)
node.x_right = this.ur.x + node.pos.x;
if ( this.ll.y + node.pos.y < node.y_low)
node.y_low = this.ll.y + node.pos.y;
if ( this.ur.y + node.pos.y > node.y_high)
node.y_high = this.ur.y + node.pos.y;
}
}
function GDraw( ctx) {
this.ctx = ctx;
this.canvas = document.querySelector("canvas");
this.gctx = this.canvas.getContext("2d");
this.offset_top = this.canvas.offsetTop;
}
function PlowCtx() {
this.gdh = 0;
this.debug = false;
this.nodraw = 0;
this.zoom_factor = 20.0;
this.base_zoom_factor = 20.0;
this.offset_x = 0;
this.offset_y = 0;
this.x_right = 0.0;
this.x_left = 0.0;
this.y_high = 0.0;
this.y_low = 0.0;
this.a = new PlowArray(this);
this.a_nc = new PlowArray(this);
this.name = "Claes context";
this.gdraw = new GDraw(this);
this.selct_object = null;
this.event_cb = null;
this.event_object = null;
this.draw = function() {
if ( this.nodraw > 0)
return;
this.gdraw.gctx.fillStyle = "white";
this.gdraw.gctx.fillRect( 0, 0, this.gdraw.canvas.width, this.gdraw.canvas.height);
this.a.draw( this.gdraw.gctx, null, null, false);
};
this.connect = function() {
for ( var i = 0; i < this.a.size(); i++)
this.a.get(i).connect();
};
this.scan = function() {
console.log("ctx scan", this.a.size());
for ( var i = 0; i < this.a.size(); i++)
this.a.get(i).scan();
};
this.set_nodraw = function() {
this.nodraw++;
};
this.reset_nodraw = function() {
this.nodraw--;
};
this.size = function() {
return this.a.size()
};
this.event_handler = function( event, x, y) {
var sts = 0;
switch ( event) {
case Plow.eEvent_MB1Click:
case Plow.eEvent_MB1ClickShift:
for ( var i = 0; i < this.a.size(); i++) {
if ( this.a.get(i) instanceof PlowNode) {
sts = this.a.get(i).event_handler( event, x, y);
if ( sts == 1)
break;
}
}
if ( sts == 1) {
this.event_cb( event, this.event_object, x, y);
this.draw();
}
break;
case Plow.eEvent_Key_Up:
case Plow.eEvent_Key_Down:
case Plow.eEvent_Key_Left:
case Plow.eEvent_Key_Right:
case Plow.eEvent_Key_ShiftRight:
case Plow.eEvent_Key_CtrlR:
case Plow.eEvent_Key_CtrlL:
case Plow.eEvent_Key_CtrlG:
this.event_cb( event, null, 0, 0);
break;
}
};
this.set_select = function( select) {
for ( var i = 0; i < this.a.size(); i++) {
if ( this.a.get(i) instanceof PlowNode)
this.a.get(i).set_select( select);
}
};
this.set_invert = function( invert) {
for ( var i = 0; i < this.a.size(); i++) {
if ( this.a.get(i) instanceof PlowNode)
this.a.get(i).set_invert( invert);
}
};
this.get_select = function () {
return this.select_object;
};
this.insert = function( n, dest) {
this.a.add(n);
};
this.insertNode = function( n, destination, destCode) {
this.a.insertNode(n, destination, destCode);
};
this.remove = function( n) {
if ( this.select_object == n)
this.select_object = null;
this.a.remove(n);
};
this.insert_nc = function( nc) {
this.a_nc.add(nc);
};
this.configure = function() {
this.a.configure();
this.a.set_borders();
var height = this.a.a.length * 1.0 * this.zoom_factor;
this.gdraw.canvas.height = height;
};
this.get_parent_object = function( o) {
return this.a.get_parent_object(o);
};
this.get_next_object = function( o) {
return this.a.get_next_object(o);
};
this.get_last_object = function() {
return this.a.get_last_object();
};
this.get_first_object = function() {
return this.a.get_first_object();
};
this.get_previous_object = function( o) {
return this.a.get_previous_object(o);
};
this.close_node = function( o) {
this.a.close_node(o);
};
this.is_visible = function( o) {
if ((o.y_high * this.zoom_factor <= window.pageYOffset + window.innerHeight - this.gdraw.offset_top) &&
(o.y_low * this.zoom_factor >= window.pageYOffset - this.gdraw.offset_top))
return true;
return false;
};
this.scroll = function( y, factor) {
window.scrollTo( window.scrollX, y * this.zoom_factor - window.innerHeight * factor + this.gdraw.offset_top)
};
}
/** End Plow **/
/** Start Pwr **/
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;};
}
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 |
1 << 3 |
1 << 4 |
1 << 5 |
1 << 0 |
1 << 1 |
1 << 25 |
1 << 18 |
1 << 19 |
1 << 20 |
1 << 6 |
1 << 7 |
1 << 8 |
1 << 9 |
1 << 10 |
1 << 11 |
1 << 12 |
1 << 13 |
1 << 14 |
1 << 15,
mAccess_AllOperators : 1 << 6 |
1 << 7 |
1 << 8 |
1 << 9 |
1 << 10 |
1 << 11 |
1 << 12 |
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
};
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
};
function PwrtObjid( vid, oix) {
this.oix = oix;
this.vid = vid;
}
function PwrtAttrRef() {
this.objid;
this.offset;
this.body;
this.size;
this.flags;
}
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;};
}
var CdhC = {
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 **/
"use strict"; "use strict";
/** Start Pwr **/ #jsc_include pwr.jsi
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;};
}
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 |
1 << 3 |
1 << 4 |
1 << 5 |
1 << 0 |
1 << 1 |
1 << 25 |
1 << 18 |
1 << 19 |
1 << 20 |
1 << 6 |
1 << 7 |
1 << 8 |
1 << 9 |
1 << 10 |
1 << 11 |
1 << 12 |
1 << 13 |
1 << 14 |
1 << 15,
mAccess_AllOperators : 1 << 6 |
1 << 7 |
1 << 8 |
1 << 9 |
1 << 10 |
1 << 11 |
1 << 12 |
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
};
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
};
function PwrtObjid( vid, oix) {
this.oix = oix;
this.vid = vid;
}
function PwrtAttrRef() {
this.objid;
this.offset;
this.body;
this.size;
this.flags;
}
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;};
}
var CdhC = {
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 Cli **/ /** Start Cli **/
function CliTable( command, qualifier) { function CliTable( command, qualifier) {
...@@ -281,2308 +81,8 @@ function MhEvent() { ...@@ -281,2308 +81,8 @@ function MhEvent() {
this.syncIdx; this.syncIdx;
} }
/** Start Gdh **/ #jsc_include gdh.jsi
function Sub() { #jsc_include plow.jsi
this.sts;
this.refid;
this.type;
this.elements;
this.name;
this.value;
}
function ObjectInfo() {
this.objid;
this.cid;
this.has_children;
this.name;
this.description;
this.classname;
this.full_name;
this.param1;
}
function AttributeInfo() {
this.name;
this.type;
this.size;
this.flags;
this.element;
this.objid;
this.full_name;
this.classname;
}
function MenuButton() {
this.type;
this.text;
this.name;
this.url;
}
function OpwindMenuInfo() {
this.title;
this.text;
this.enable_language;
this.enable_login;
this.enable_alarmlist;
this.enable_eventlog;
this.enable_navigator;
this.disable_help;
this.disable_proview;
this.language;
this.buttons = [];
}
function CrrInfo() {
this.type;
this.objid;
this.name;
this.classname;
}
function GlowPieInfo() {
this.sector_num;
this.min_val;
this.max_val;
}
function GlowBarChartInfo() {
this.bars;
this.barsegments;
this.min_value;
this.max_value;
}
function GlowTableInfo() {
this.columns;
this.rows;
this.column_size = new Array(Glow.TABLE_MAX_COL);
}
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
};
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
};
this.debug = false;
this.pending = [];
this.sub = [];
this.PORT = 4448;
this.ws = null;
this.open_cb = null;
this.close_cb = null;
this.return_cb = null;
this.next_id = 1234;
this.subscriptionCount = 1;
this.listSend = false;
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.binaryType = "arraybuffer";
this.ws.gdh = this;
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.gdh.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) {
var dv = new DataView(e.data);
var type = dv.getUint8(0);
var id = dv.getUint32(1);
var sts = dv.getUint32(5);
switch( type) {
case Msg.GET_OBJECT_INFO_BOOLEAN: {
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);
delete this.gdh.pending[id];
break;
}
case Msg.GET_OBJECT_INFO_INT: {
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);
delete this.gdh.pending[id];
break;
}
case Msg.GET_OBJECT_INFO_FLOAT: {
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);
delete this.gdh.pending[id];
break;
}
case Msg.GET_OBJECT_INFO_FLOAT_ARRAY: {
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++) {
value[i] = dv.getFloat32(k);
k += 4;
}
var 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);
var 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: {
var j = 9;
var size = dv.getUint32(j);
if ( this.gdh.debug) console.log("GetObjectRefInfoAll received", id, size);
j += 4;
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')
j += esize;
else {
var value;
switch ( sub.type) {
case Pwr.eType_Boolean:
if ( sub.elements <= 1) {
value = dv.getUint8(j);
j += 1;
}
else {
var elements = esize;
if ( elements != sub.elements)
console.log("Subscription size error", elements, sub.elements, eid);
value = new Array(elements);
for ( var k = 0; k < elements; k++) {
value[k] = dv.getUint8(j);
j += 1;
}
}
break;
case Pwr.eType_Float32:
if ( sub.elements <= 1) {
value = dv.getFloat32(j);
j += 4;
}
else {
var elements = esize / 4;
if ( elements != sub.elements)
console.log("Subscription size error", elements, sub.elements, eid);
value = new Array(elements);
for ( var k = 0; k < elements; k++) {
value[k] = dv.getFloat32(j);
j += 4;
}
}
break;
case Pwr.eType_Int8:
case Pwr.eType_Int16:
case Pwr.eType_Int32:
case Pwr.eType_UInt8:
case Pwr.eType_UInt16:
case Pwr.eType_UInt32:
case Pwr.eType_Status:
case Pwr.eType_NetStatus:
case Pwr.eType_Mask:
case Pwr.eType_Enum:
case GraphIfc.eType_Bit:
if ( sub.elements <= 1) {
value = dv.getInt32(j);
j += 4;
}
else {
var elements = esize / 4;
if ( elements != sub.elements)
console.log("Subscription size error", elements, sub.elements, eid);
value = new Array(elements);
for ( var k = 0; k < elements; k++) {
value[k] = dv.getInt32(j);
j += 4;
}
}
break;
case Pwr.eType_String:
case Pwr.eType_Time:
case Pwr.eType_DeltaTime:
case Pwr.eType_AttrRef:
case Pwr.eType_Objid:
if ( sub.elements <= 1) {
var nsize = dv.getInt16(j);
j += 2;
var iarr = new Uint8Array( nsize);
for ( var k = 0; k < nsize; k++) {
iarr[k] = dv.getUint8(j++);
}
value = String.fromCharCode.apply( null, iarr);
}
else {
var 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++) {
var nsize = dv.getInt16(j);
j += 2;
var iarr = new Uint8Array( nsize);
for ( var k = 0; k < nsize; k++) {
iarr[k] = dv.getUint8(j++);
}
value[l] = String.fromCharCode.apply( null, iarr);
}
}
break;
default: break;
}
this.gdh.sub[eid].value = value;
}
}
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);
delete this.gdh.pending[id];
break;
}
case Msg.GET_ALL_XTT_CHILDREN: {
var result = [];
var j = 9;
var size = dv.getUint32(j);
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++) {
var info = new ObjectInfo();
info.objid = new PwrtObjid();
info.objid.vid = dv.getUint32(j);
j += 4;
info.objid.oix = dv.getUint32(j);
j += 4;
info.cid = dv.getUint32(j);
j += 4;
info.has_children = dv.getUint16(j) !== 0;
j += 2;
var nsize = dv.getUint16(j);
j += 2;
var iarr = new Uint8Array( nsize);
for ( var k = 0; k < nsize; k++) {
iarr[k] = dv.getUint8(j++);
}
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[k] = dv.getUint8(j++);
}
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[k] = dv.getUint8(j++);
}
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);
delete this.gdh.pending[id];
break;
}
case Msg.GET_ALL_CLASS_ATTRIBUTES: {
var result = [];
var j = 9;
var size = dv.getUint32(j);
if ( this.gdh.debug) console.log("GetAllClassAttributes received", id, size);
j += 4;
for ( var i = 0; i < size; i++) {
var info = new AttributeInfo();
info.type = dv.getUint32(j);
j += 4;
info.flags = dv.getUint32(j);
j += 4;
info.size = dv.getUint16(j);
j += 2;
info.elements = dv.getUint16(j);
j += 2;
var nsize = dv.getUint16(j);
j += 2;
var iarr = new Uint8Array( nsize);
for ( var k = 0; k < nsize; k++) {
iarr[k] = dv.getUint8(j++);
}
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[k] = dv.getUint8(j++);
}
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);
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);
var info = null;
if ( (sts & 1) !== 0) {
var j = 9;
info = new ObjectInfo();
info.objid = new PwrtObjid();
info.objid.vid = dv.getUint32(j);
j += 4;
info.objid.oix = dv.getUint32(j);
j += 4;
info.cid = dv.getUint32(j);
j += 4;
info.has_children = dv.getUint16(j) !== 0;
j += 2;
var nsize = dv.getUint16(j);
j += 2;
var iarr = new Uint8Array( nsize);
for ( var k = 0; k < nsize; k++) {
iarr[k] = dv.getUint8(j++);
}
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[k] = dv.getUint8(j++);
}
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[k] = dv.getUint8(j++);
}
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[k] = dv.getUint8(j++);
}
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[k] = dv.getUint8(j++);
}
info.param1 = String.fromCharCode.apply( null, iarr);
}
var pending_data = this.gdh.pending[id];
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) {
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++) {
var info = new CrrInfo();
info.type = dv.getUint16(j);
j += 2;
info.objid = new PwrtObjid();
info.objid.vid = dv.getUint32(j);
j += 4;
info.objid.oix = dv.getUint32(j);
j += 4;
var nsize = dv.getUint16(j);
j += 2;
var iarr = new Uint8Array( nsize);
for ( var k = 0; k < nsize; k++) {
iarr[k] = dv.getUint8(j++);
}
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[k] = dv.getUint8(j++);
}
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);
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);
console.log("GetOpwindMenu received", sts, id);
if ( sts & 1) {
var nsize = dv.getUint16(j);
j += 2;
var iarr = new Uint8Array( nsize);
for ( var k = 0; k < nsize; k++) {
iarr[k] = dv.getUint8(j++);
}
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[k] = dv.getUint8(j++);
}
result.text = String.fromCharCode.apply( null, iarr);
result.enable_language = dv.getUint32(j);
j += 4;
result.enable_login = dv.getUint32(j);
j += 4;
result.enable_alarmlist = dv.getUint32(j);
j += 4;
result.enable_eventlog = dv.getUint32(j);
j += 4;
result.enable_navigator = dv.getUint32(j);
j += 4;
result.disable_help = dv.getUint32(j);
j += 4;
result.disable_proview = dv.getUint32(j);
j += 4;
result.language = dv.getUint32(j);
j += 4;
var bsize = dv.getUint16(j);
j += 2;
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[k] = dv.getUint8(j++);
}
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[k] = dv.getUint8(j++);
}
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[k] = dv.getUint8(j++);
}
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);
delete this.gdh.pending[id];
break;
}
case Msg.CHECK_USER: {
var j = 9;
if ( this.gdh.debug) console.log("Check user received", id, size);
console.log("Check user received", sts, id);
var priv = 0;
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);
delete this.gdh.pending[id];
break;
}
case Msg.GET_MSG: {
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++) {
iarr[k] = dv.getUint8(j++);
}
var msg = String.fromCharCode.apply( null, iarr);
}
var pending_data = this.gdh.pending[id];
pending_data.func_cb( id, pending_data.data, sts, msg);
delete this.gdh.pending[id];
break;
}
case Msg.MH_SYNC: {
var result = [];
var j = 9;
var size = dv.getUint32(j);
if ( this.gdh.debug) console.log("MhSync received", id, size);
j += 4;
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++) {
iarr[k] = dv.getUint8(j++);
}
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[k] = dv.getUint8(j++);
}
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[k] = dv.getUint8(j++);
}
e.eventName = String.fromCharCode.apply( null, iarr);
e.eventFlags = dv.getUint32(j);
j += 4;
e.eventStatus = dv.getUint32(j);
j += 4;
e.eventPrio = dv.getUint32(j);
j += 4;
e.eventId = new MhEventId();
e.eventId.nix = dv.getUint32(j);
j += 4;
e.eventId.idx = dv.getUint32(j);
j += 4;
len = dv.getUint16(j);
j += 2;
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.targetId = new MhEventId();
e.targetId.nix = dv.getUint32(j);
j += 4;
e.targetId.idx = dv.getUint32(j);
j += 4;
len = dv.getUint16(j);
j += 2;
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.eventType = dv.getUint32(j);
j += 4;
var objid = new PwrtObjid(0,0);
objid.vid = dv.getUint32(j);
j += 4;
objid.oix = dv.getUint32(j);
j += 4;
e.object = new PwrtAttrRef();
e.object.objid = objid;
e.object.offset = dv.getUint32(j);
j += 4;
e.object.body = dv.getUint32(j);
j += 4;
e.object.size = dv.getUint32(j);
j += 4;
e.object.flags = dv.getUint32(j);
j += 4;
var supObjid = new PwrtObjid(0,0);
supObjid.vid = dv.getUint32(j);
j += 4;
supObjid.oix = dv.getUint32(j);
j += 4;
e.supObject = new PwrtAttrRef();
e.supObject.objid = supObjid;
e.supObject.offset = dv.getUint32(j);
j += 4;
e.supObject.body = dv.getUint32(j);
j += 4;
e.supObject.size = dv.getUint32(j);
j += 4;
e.supObject.flags = dv.getUint32(j);
j += 4;
len = dv.getUint16(j);
j += 2;
iarr = new Uint8Array( len);
for ( var k = 0; k < len; k++) {
iarr[k] = dv.getUint8(j++);
}
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);
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);
delete this.gdh.pending[id];
break;
}
default:
console.log("Unknown message type");
}
}
}
};
};
this.getObjectInfoBoolean = function( name, return_cb) {
this.return_cb = return_cb;
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);
}
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.return_cb = return_cb;
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);
}
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.return_cb = return_cb;
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);
}
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.return_cb = return_cb;
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;
buf[4] = (this.next_id >> 16) & 0xFF;
buf[5] = (this.next_id >> 24) & 0xFF;
buf[6] = asize & 0xFF;
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);
}
this.pending[this.next_id] = new PendingData( return_cb, data);
this.ws.send(buf);
this.next_id++;
};
this.refObjectInfo = function( name, type, elements) {
var sub = new Sub();
sub.name = name;
sub.refid = this.subscriptionCount;
sub.type = type;
sub.elements = elements;
this.sub[this.subscriptionCount] = sub;
this.subscriptionCount++;
if ( !this.listSent) {
return sub.refid;
}
else {
var size = 0;
var len = 0;
size = 12 + sub.name.length;
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);
var k = 6;
buf[k++] = sub.refid & 0xFF;
buf[k++] = (sub.refid >> 8) & 0xFF;
buf[k++] = (sub.refid >> 16) & 0xFF;
buf[k++] = (sub.refid >> 24) & 0xFF;
buf[k++] = sub.elements & 0xFF;
buf[k++] = (sub.elements >> 8) & 0xFF;
buf[k++] = (sub.elements >> 16) & 0xFF;
buf[k++] = (sub.elements >> 24) & 0xFF;
buf[k++] = sub.name.length & 0xFF;
buf[k++] = (sub.name.length >> 8) & 0xFF;
buf[k++] = (sub.name.length >> 16) & 0xFF;
buf[k++] = (sub.name.length >> 24) & 0xFF;
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.ws.send(buf);
this.next_id++;
return sub.refid;
}
};
this.refObjectInfoReply = function( id, sts) {
if ( this.debug) console.log( "refObjectInfoReply", id, sts);
};
this.unrefObjectInfo = function( refid) {
var size = 0;
var len = 0;
size = 4;
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);
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.ws.send(buf);
this.next_id++;
delete this.sub[refid];
};
this.refObjectInfoList = function( return_cb) {
var size = 0;
var len = 0;
this.return_cb = return_cb;
for( var i in this.sub) {
size += 12 + this.sub[i].name.length;
len++;
}
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;
buf[4] = (this.next_id >> 16) & 0xFF;
buf[5] = (this.next_id >> 24) & 0xFF;
buf[6] = len & 0xFF;
buf[7] = (len >> 8) & 0xFF;
buf[8] = (len >> 16) & 0xFF;
buf[9] = (len >> 24) & 0xFF;
var k = 10;
for ( var i in this.sub) {
if ( i === 0)
continue;
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;
buf[k++] = (this.sub[i].refid >> 24) & 0xFF;
buf[k++] = this.sub[i].elements & 0xFF;
buf[k++] = (this.sub[i].elements >> 8) & 0xFF;
buf[k++] = (this.sub[i].elements >> 16) & 0xFF;
buf[k++] = (this.sub[i].elements >> 24) & 0xFF;
buf[k++] = this.sub[i].name.length & 0xFF;
buf[k++] = (this.sub[i].name.length >> 8) & 0xFF;
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++) {
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.ws.send(buf);
this.next_id++;
this.listSent = true;
};
this.refObjectInfoListReply = function( id, sts) {
if ( this.debug) console.log( "refObjectInfoListReply", id, sts);
};
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.ws.send(buf);
this.next_id++;
};
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);
return this.sub[id].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;
buf[3] = (this.next_id >> 8) & 0xFF;
buf[4] = (this.next_id >> 16) & 0xFF;
buf[5] = (this.next_id >> 24) & 0xFF;
buf[6] = value & 0xFF;
buf[7] = (value >> 8) & 0xFF;
buf[8] = (value >> 16) & 0xFF;
buf[9] = (value >> 24) & 0xFF;
buf[10] = name.length & 0xFF;
buf[11] = (name.length >> 8) & 0xFF;
var k = 12;
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);
this.next_id++;
return new PwrtStatus( 1);
};
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;
buf[3] = (this.next_id >> 8) & 0xFF;
buf[4] = (this.next_id >> 16) & 0xFF;
buf[5] = (this.next_id >> 24) & 0xFF;
buf[6] = value & 0xFF;
buf[7] = (value >> 8) & 0xFF;
buf[8] = (value >> 16) & 0xFF;
buf[9] = (value >> 24) & 0xFF;
buf[10] = name.length & 0xFF;
buf[11] = (name.length >> 8) & 0xFF;
var k = 12;
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);
this.next_id++;
return new PwrtStatus( 1);
};
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;
buf[3] = (this.next_id >> 8) & 0xFF;
buf[4] = (this.next_id >> 16) & 0xFF;
buf[5] = (this.next_id >> 24) & 0xFF;
var fbuf = new ArrayBuffer(4);
var fa = new Float32Array(fbuf);
fa[0] = value;
var ba = new Uint8Array(fbuf);
buf[6] = ba[0];
buf[7] = ba[1];
buf[8] = ba[2];
buf[9] = ba[3];
buf[10] = name.length & 0xFF;
buf[11] = (name.length >> 8) & 0xFF;
var k = 12;
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);
this.next_id++;
return new PwrtStatus( 1);
};
this.setObjectInfoString = function( name, value) {
var i;
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;
buf[4] = (this.next_id >> 16) & 0xFF;
buf[5] = (this.next_id >> 24) & 0xFF;
buf[6] = value.length & 0xFF;
buf[7] = (value.length >> 8) & 0xFF;
var k = 8;
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++) {
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);
this.next_id++;
return new PwrtStatus( 1);
};
this.toggleObjectInfo = function( name) {
var buf = new Uint8Array(8 + name.length);
buf[0] = Msg.TOGGLE_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;
buf[6] = name.length & 0xFF;
buf[7] = (name.length >> 8) & 0xFF;
var k = 8;
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);
this.next_id++;
return new PwrtStatus( 1);
};
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;
buf[3] = (this.next_id >> 8) & 0xFF;
buf[4] = (this.next_id >> 16) & 0xFF;
buf[5] = (this.next_id >> 24) & 0xFF;
buf[6] = oid.vid & 0xFF;
buf[7] = (oid.vid >> 8) & 0xFF;
buf[8] = (oid.vid >> 16) & 0xFF;
buf[9] = (oid.vid >> 24) & 0xFF;
buf[10] = oid.oix & 0xFF;
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.ws.send(buf);
this.next_id++;
};
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;
buf[3] = (this.next_id >> 8) & 0xFF;
buf[4] = (this.next_id >> 16) & 0xFF;
buf[5] = (this.next_id >> 24) & 0xFF;
buf[6] = cid & 0xFF;
buf[7] = (cid >> 8) & 0xFF;
buf[8] = (cid >> 16) & 0xFF;
buf[9] = (cid >> 24) & 0xFF;
buf[10] = oid.vid & 0xFF;
buf[11] = (oid.vid >> 8) & 0xFF;
buf[12] = (oid.vid >> 16) & 0xFF;
buf[13] = (oid.vid >> 24) & 0xFF;
buf[14] = oid.oix & 0xFF;
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.ws.send(buf);
this.next_id++;
};
this.getObject = function( oid, op, return_cb, data) {
var buf = new Uint8Array(16);
buf[0] = Msg.GET_OBJECT;
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;
buf[6] = op & 0xFF;
buf[7] = (op >> 8) & 0xFF;
buf[8] = oid.vid & 0xFF;
buf[9] = (oid.vid >> 8) & 0xFF;
buf[10] = (oid.vid >> 16) & 0xFF;
buf[11] = (oid.vid >> 24) & 0xFF;
buf[12] = oid.oix & 0xFF;
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.ws.send(buf);
this.next_id++;
};
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;
buf[3] = (this.next_id >> 8) & 0xFF;
buf[4] = (this.next_id >> 16) & 0xFF;
buf[5] = (this.next_id >> 24) & 0xFF;
buf[6] = op & 0xFF;
buf[7] = (op >> 8) & 0xFF;
buf[8] = aref.objid.vid & 0xFF;
buf[9] = (aref.objid.vid >> 8) & 0xFF;
buf[10] = (aref.objid.vid >> 16) & 0xFF;
buf[11] = (aref.objid.vid >> 24) & 0xFF;
buf[12] = aref.objid.oix & 0xFF;
buf[13] = (aref.objid.oix >> 8) & 0xFF;
buf[14] = (aref.objid.oix >> 16) & 0xFF;
buf[15] = (aref.objid.oix >> 24) & 0xFF;
buf[16] = aref.offset & 0xFF;
buf[17] = (aref.offset >> 8) & 0xFF;
buf[18] = (aref.offset >> 16) & 0xFF;
buf[19] = (aref.offset >> 24) & 0xFF;
buf[20] = aref.body & 0xFF;
buf[21] = (aref.body >> 8) & 0xFF;
buf[22] = (aref.body >> 16) & 0xFF;
buf[23] = (aref.body >> 24) & 0xFF;
buf[24] = aref.size & 0xFF;
buf[25] = (aref.size >> 8) & 0xFF;
buf[26] = (aref.size >> 16) & 0xFF;
buf[27] = (aref.size >> 24) & 0xFF;
buf[28] = aref.flags & 0xFF;
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.ws.send(buf);
this.next_id++;
};
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;
buf[3] = (this.next_id >> 8) & 0xFF;
buf[4] = (this.next_id >> 16) & 0xFF;
buf[5] = (this.next_id >> 24) & 0xFF;
buf[6] = op & 0xFF;
buf[7] = (op >> 8) & 0xFF;
buf[8] = name.length & 0xFF;
buf[9] = (name.length >> 8) & 0xFF;
var k = 10;
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.ws.send(buf);
this.next_id++;
};
this.crrSignal = function( oid, return_cb, data) {
var buf = new Uint8Array(14);
buf[0] = Msg.CRR_SIGNAL;
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;
buf[6] = oid.vid & 0xFF;
buf[7] = (oid.vid >> 8) & 0xFF;
buf[8] = (oid.vid >> 16) & 0xFF;
buf[9] = (oid.vid >> 24) & 0xFF;
buf[10] = oid.oix & 0xFF;
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.ws.send(buf);
this.next_id++;
};
this.getOpwindMenu = function( name, return_cb, data) {
var len = name.length;
var buf = new Uint8Array(8 + name.length);
buf[0] = Msg.GET_OPWIND_MENU;
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;
buf[6] = name.length & 0xFF;
buf[7] = (name.length >> 8) & 0xFF;
var k = 8;
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.ws.send(buf);
this.next_id++;
};
this.login = function( user, passwd, return_cb, data) {
var buf = new Uint8Array(6 + 2 + user.length + 2 + passwd.length);
buf[0] = Msg.CHECK_USER;
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;
var k = 6;
buf[k] = user.length & 0xFF;
buf[k+1] = (user.length >> 8) & 0xFF;
k += 2;
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;
k += 2;
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.ws.send(buf);
this.next_id++;
};
this.getMsg = function( value, return_cb, data) {
var buf = new Uint8Array(10);
buf[0] = Msg.GET_MSG;
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;
buf[6] = value & 0xFF;
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.ws.send(buf);
if ( this.debug) console.log("Sending getMsg", this.next_id, value);
this.next_id++;
};
this.mhSync = function( sync, return_cb, data) {
var buf = new Uint8Array(10);
buf[0] = Msg.MH_SYNC;
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;
buf[6] = sync & 0xFF;
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.ws.send(buf);
this.next_id++;
};
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;
buf[3] = (this.next_id >> 8) & 0xFF;
buf[4] = (this.next_id >> 16) & 0xFF;
buf[5] = (this.next_id >> 24) & 0xFF;
buf[6] = event_id.nix & 0xFF;
buf[7] = (event_id.nix >> 8) & 0xFF;
buf[8] = (event_id.nix >> 16) & 0xFF;
buf[9] = (event_id.nix >> 24) & 0xFF;
buf[10] = event_id.idx & 0xFF;
buf[11] = (event_id.idx >> 8) & 0xFF;
buf[12] = (event_id.idx >> 16) & 0xFF;
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;
k += 2;
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.ws.send(buf);
this.next_id++;
};
}
/** End Gdh **/
/** Start Plow **/
var Bitmaps = {
leaf : 0,
map : 2,
openmap : 4,
object : 6,
attrenum : 8,
attrarra : 10,
attrarel : 12,
attr : 14,
crrwrite : 16,
crrread : 18,
ack : 20,
alarm : 22,
eventacked : 24,
eventalarm : 26,
eventreturn : 28,
info : 30,
system : 32,
maintenance : 34,
blockl : 36,
blockr : 38,
img : [ null, null, null, null, null, null, null, null, null, null,
null, null, null, null, null, null, null, null, null, null,
null, null, null, null, null, null, null, null, null, null,
null, null, null, null, null, null, null, null],
pending : [ null, null, null, null, null, null, null, null, null, null,
null, null, null, null, null, null, null, null, null, null,
null, null, null, null, null, null, null, null, null, null,
null, null, null, null, null, null, null, null],
images : [
// leaf
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAMCAYAAABSgIzaAAAASElEQVQokWP4jwMwMDBgYBR5XBpwGYZVIzYNGDZB+QyEFOBiM+CyCacGBI0hgEGjsxkYGCiwkSI/4tKMz0DqxCM2A4hOOcQCAObFEQyI2PpKAAAAAElFTkSuQmCC',
// leaf inverted
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAMCAYAAABSgIzaAAAAQUlEQVQokWNgYGD4jw1jA2hqsGvAZRhWjdg0oIsh8QkqwMXGbhMuDXAxdAFsNDobyifTRor8SFGoUhSPFKUcYjEAMsMz2y6w8kgAAAAASUVORK5CYII=',
// map
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAMCAYAAABSgIzaAAAAKElEQVQokWP4DwUMDAwYGB9gwKUQm0FoGL/JOGwb1TgINZKFSbYOCgD1JxQJG0vK9AAAAABJRU5ErkJggg==',
// map inverted
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAMCAYAAABSgIzaAAAAK0lEQVQokWNgYGD4z8DA8B8bgMlhxbgUEgIMBE3Ggkc1Dk6N5AAGUm2DYQAkYTDe0vu7CAAAAABJRU5ErkJggg==',
// openmap
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAMCAYAAABSgIzaAAAAQklEQVQokaXOwQ4AIAgCUP7/p+nUlpMSzY2bDwWHA5IEkFJCtaiKxE7dvsue8HZNJEPneoAuSq+OYAf9wy4K0Mk5C+d++RWimsw3AAAAAElFTkSuQmCC',
// openmap inverted
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAMCAYAAABSgIzaAAAAPUlEQVQokaXRQQoAQAgCQP//6brKZmSt0M2hIACI4yBURqiKXQp0ThuhGwmt7Vy00XvqCa7QN1wjhtYLCCYyCkvDVnkJOQAAAABJRU5ErkJggg==',
// object
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAH0lEQVQokWP4TyJgYGBg+E8iZiDFdHrZMKqBGA2kYAD8gaJsjwzf9wAAAABJRU5ErkJggg==',
// object inverted
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAIklEQVQokWNgYGD4TxL+TyJg+P//P9GmwzXQ3oZRDdSOBwAGOSrkrXppgQAAAABJRU5ErkJggg==',
// attrenum
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAMCAYAAABSgIzaAAAAPklEQVQokWP4////fwYGBgxMCDBgU4jNICyYsOlYbENoJNIW7BqJsYm2NuJyBVE2EqWRfjbiUoQ3oAgpwgUANLqccvbgec0AAAAASUVORK5CYII=',
// attrenum inverted
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAMCAYAAABSgIzaAAAAPElEQVQokWNgYGD4jw0wMDDgx9gUEgMYiDIdDaNoJBZg1UiUTTS1EZcriLKRKI30sxGXIgKBhF8RrqgBAOTOqGZ5aiCnAAAAAElFTkSuQmCC',
// attrarra
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAMCAYAAABSgIzaAAAAMElEQVQokWP4////fwYGBgxMCDBgU4jNICwYv+nY5InWOGojXW0khLEahtc6PDYCAB9hxkjBPICvAAAAAElFTkSuQmCC',
// attrarray inverted
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAMCAYAAABSgIzaAAAALUlEQVQokWNgYGD4jw0wMDDgx9gUEgMYCJmOTZ5ojaM20tVGQgCHK/AnLVwAAPonfpBwU5f4AAAAAElFTkSuQmCC',
// attrarel
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAIklEQVQokWP4////fwYGBpwYHTDANGADeDWM2jAEbSAFAADB26JsIjYj1AAAAABJRU5ErkJggg==',
// attrarel inverted
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAIElEQVQokWNgYGD4jw8wMDCgYwZcEvg1jNowBG0gBQMAQN8q5COZl1cAAAAASUVORK5CYII=',
// attr
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAIUlEQVQokWP4TyJgGIQaGBgY/pOIibcEroEkTLIfhoEGADzs8B5gcUg/AAAAAElFTkSuQmCC',
// attr inverted
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAJUlEQVQokWNgYGD4TyIedBr+kwgY/v//T7TpcA0k2TAIQ4nmGgDFzt0jExR7hgAAAABJRU5ErkJggg==',
// crrwrite
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAN0lEQVQokaWNQQoAMAjD8v9P633WVWhBkJIotQQoYPYbrHYrqC9D+MG54OBMuMC54GApuPBed9OxiMNLGke1JwAAAABJRU5ErkJggg==',
// crrwrite inverted
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAANElEQVQokWNgYGD4jw3DABY57IqxsQlqwGELSYop1ECEYgo0EKmYQg1EKMbUQEAxRAMpAABRMgoFjbTzXgAAAABJRU5ErkJggg==',
// crrread
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAPElEQVQokWNgYGD4j4yRATY5BmyKkGks4qgS2BSj2UYFDdgAdW2gvpOwhDW6ItwaCGI8JuHWgMOtWD0PACufaaWhXDFDAAAAAElFTkSuQmCC',
// crrread inverted
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAPElEQVQokWP4jwYYGBjgGKscNkXINLo4hgZsipFto44GbJi6NlDfSehhjUxjyGMVxQMYcJmEVwPB5ICEAdcbY6vf9TVAAAAAAElFTkSuQmCC',
// ack
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAS0lEQVQokZ2Q2w4AIAhCz///ND11M3RVmxuDUBRAtw8QHRyC4SSJSDjDht1Yhxdudks+bFNxYsX9G6rz2qVHxqRspGi2Wpoji/dqaLh22DbO2VuXAAAAAElFTkSuQmCC',
// ack inverted
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAASklEQVQokWP4////fwYGBqIwVC2cgSKBTQzKxhDA0ICmGau12BRCMLJp2BQgy8H9gM9ELGJkasAXvFg9TQjgDCVc8YBXAwFMmgYASkT1C9E5Ya0AAAAASUVORK5CYII=',
// alarm
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAARklEQVQokZ2QQQoAMAjD+v9Pu9PA1ThQQRBtoFUBJSkk0SlwOwKykCAEcn+BK8hih/aAe++y7IDuhWgXfcKHCuBBfX6ASR3Vn8ZINQzCrQAAAABJRU5ErkJggg==',
// alarm inverted
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAQ0lEQVQokWNgYGD4j45hAJscA8UakBXi0ITddDy2YJqOrBiLJjI1oLsdj1/I0IAnCLFpwtSALYQwNKB7FJ2NooEUDAAtGwcI+Svs4gAAAABJRU5ErkJggg==',
// eventacked
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAL0lEQVQokWP4TyJgGCkaGBgQyhhwSeASw9CAYho2A3CZiE0xVg34FOPUgA+QrAEA1FYi+tWeG/cAAAAASUVORK5CYII=',
// eventacked inverted
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAMElEQVQokWNgYGD4TyIeGRr+//+PXQOaBC4xVElkBdgMwHASTBEOxdj9gEcxHYIVAC5kqlZXl5JMAAAAAElFTkSuQmCC',
// eventalarm
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAJ0lEQVQokWP4jwMwMDBgF8elGIZHNeDSANOEVRyXBpwGUcUGqvoBAK+H8xt0qXFWAAAAAElFTkSuQmCC',
// eventalarm inverted
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAJ0lEQVQokWNgYGD4jw3///8fqzgDLsUwMKoBlwaSg5UAHoiIw2cDAFMz2iY65DAoAAAAAElFTkSuQmC',
// eventreturn
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAASUlEQVQokZ2RUQoAIAjFdv9L11dhskeUEIQ2mcYIAXjeisA+EahFA9ad/siAA0wqSUsnu87wDZh3VEodO6Rr1c51rc8fd9OoMQHLk7dXak3qLwAAAABJRU5ErkJggg==',
// eventreturn inverted
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAR0lEQVQokZ2S2woAIAhD9/8/vV6tjgMNhLxMN1SSTGYb46JkfS2gJglQ/ncRAZ5JTCXQYsFRwxpAvFtKoeMvmoqDv1jc5DQONycV+bfOetgAAAAASUVORK5CYII=',
// info
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAOUlEQVQokWNgYGD4///////E0AwMDP8hPDQAk8QhjlMCuzg2G3AB6tlAez8MglAiCZNiw/////8DACmmtFrq9aGNAAAAAElFTkSuQmCC',
// info inverted
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAN0lEQVQokWP4////fwYGhv/E0FA2w390jCSJIc6ASwKnBmw24MLUs4H2fhgEoUQKIMkGBgaG/wDZFBj2pVi3HgAAAABJRU5ErkJggg==',
// system
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAN0lEQVQokWNgYGD4TyJm+E8sgGugig3YxHFqwGcIQQ3obAwN6G7GawMuhVg1EFKMUwM+QJ+IAwDD1Gyi1EZc6gAAAABJRU5ErkJggg==',
// system inverted
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAO0lEQVQokWP4TyJg+P///38GBgaiMFwDVWzAJo5TA15DCGnAYKNrwHAzPhtwKcSqgZBinBqIigeaRhwAPuZgrlZXy70AAAAASUVORK5CYII=',
// maintenance
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAP0lEQVQokZWPQQoAMAzC8v9Pu8soDOxaBS82QkWNgPKTJ/BYsLekAOxfquwHWyfws6ED7OgtfNk9bAuTSGBJOufqnHIsmYkzAAAAAElFTkSuQmCC',
// maintenance inverted
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAQUlEQVQokZWPQQ4AMAQE5/+f1kuTCkuROGAmADCVPsJsBfdCsX0u3N7sJFfXsAqW8BMaID+9gE3SJayEFo7CFwY7GtAw3ouVj50AAAAASUVORK5CYII=',
// blockl
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAQElEQVQokZ2QQQ4AMAjC+v9Pu9MWl5AJ42a0IlKBgCIadgGgQ8imqo9D3zDBvJoyR+zwlWHS9SUHaOf4QOywtQCQGucn0g2dEQAAAABJRU5ErkJggg==',
// blockl inverted
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAOklEQVQokWNgYGD4Tyz+////fwZSFBOtAaoQQsM46JLY+HAbUEwgrJmwyZTZQJYfSAolmsQDWTENwwByoOYaWbAqegAAAABJRU5ErkJggg==',
// blockr
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAPElEQVQokWP4jwMwMDBgF8enAZsmvBqw2cSARQBDIQqbGEUoaggpQBcj3Qay/IAN4AwlfBrIigeiNeACADpU5yeYXn+XAAAAAElFTkSuQmCC',
// blockr inverted
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAPElEQVQokWNgYGD4jw3///8fqzgDPg04NOG3AUMTugA2hWhqiFKEzCeoAF2MRBvI8gNJoUT1eCBaAy4MAMhm5hr5iTaWAAAAAElFTkSuQmCC'
]
};
var Plow = {
DRAWOFFSET : 2,
DEST_INTOLAST : 0,
DEST_INTOFIRST : 1,
DEST_AFTER : 2,
DEST_BEFORE : 3,
TREE_INDENTATION : 1.0,
OPEN_ATTRIBUTES : 1,
OPEN_CHILDREN : 2,
OPEN_CROSSREFERENCES : 4,
OPEN_ALL : 7,
COLOR_BLACK : 1,
COLOR_RED : 2,
COLOR_GRAY : 3,
COLOR_DARKGRAY : 4,
COLOR_LIGHTGRAY : 5,
COLOR_WHITE : 6,
COLOR_YELLOW : 7,
COLOR_GREEN : 8,
COLOR_LIGHTBLUE : 9,
COLOR_BLUE : 10,
COLOR_VIOLET : 11,
eEvent_MB1Click : 0,
eEvent_MB1ClickShift : 1,
eEvent_Key_Up : 2,
eEvent_Key_Down : 3,
eEvent_Key_Right : 4,
eEvent_Key_Left : 5,
eEvent_Key_ShiftRight : 6,
eEvent_Key_CtrlR : 7,
eEvent_Key_CtrlL : 8,
eEvent_Key_CtrlG : 9,
eEvent_ObjectDeleted : 10,
RELATIVE_POSITION : 1,
NEXT_RELATIVE_POSITION : 2
}
function PlowGeometry() {
this.ll_x = 0;
this.ll_y = 0;
this.ur_x = 0;
this.ur_y = 0;
}
function PlowNodeClass( ctx) {
this.a = new PlowArray( ctx);
this.ctx = ctx;
this.nc_name = "";
this.group = 0;
this.node_open = 0;
this.draw = function( g, p, node, highlight) {
this.a.draw( g, p, node, highlight);
}
this.insert = function( elem) {
this.a.add(elem);
}
}
function PlowArray( ctx) {
this.a = [];
this.ctx = ctx;
this.add = function( elem) {
this.a.push(elem);
}
this.insertNode = function( elem, destination, code) {
var idx = this.find( elem);
if ( idx != -1)
return;
if ( destination == null) {
switch( code) {
case Plow.DEST_INTOLAST:
case Plow.DEST_AFTER:
this.a.push(elem);
elem.level = 0;
break;
default:
elem.level = 0;
this.a.unshift(elem);
}
}
else {
var dest_idx = this.find( destination);
if ( dest_idx == -1)
return;
switch( code) {
case Plow.DEST_INTOFIRST:
if ( dest_idx == this.a.length - 1)
this.a.push( elem);
else
this.a.splice( dest_idx + 1, 0, elem);
elem.level = destination.level + 1;
break;
case Plow.DEST_INTOLAST: {
if ( dest_idx == this.a.length - 1)
this.a.push( elem);
else {
idx = this.a.length;
for ( var i = dest_idx + 1; i < this.a.length; i++) {
if ( this.a[i].level <= destination.level) {
idx = i;
break;
}
}
if ( idx == this.a.length)
this.a.push( elem);
else
this.a.splice( idx, 0, elem);
}
elem.level = destination.level + 1;
break;
}
case Plow.DEST_AFTER: {
if ( dest_idx == this.a.length - 1)
this.a.push( elem);
else {
var i;
for ( i = idx; i < this.a.length; i++) {
if ( this.a[i].level < destination.level)
break;
}
this.a.splice( i, 0, elem);
}
elem.level = destination.level;
break;
}
case Plow.DEST_BEFORE:
if ( idx > 0)
idx--;
this.a.splice( idx, 0, elem);
elem.level = destination.level;
break;
}
}
}
this.remove = function( elem) {
var idx = this.find( elem);
if ( idx == -1)
return;
this.ctx.event_cb( Plow.eEvent_ObjectDeleted, this.a[idx+1], 0, 0);
this.a.splice( idx, 1);
}
this.size = function() {
return this.a.length;
}
this.get = function( idx) {
return this.a[idx];
}
this.draw = function( g, p, node, highlight) {
for ( var i = 0; i < this.a.length; i++)
this.a[i].draw( g, p, node, highlight);
}
this.set_borders = function( node) {
for ( var i = 0; i < this.a.length; i++)
this.a[i].set_borders( node);
}
this.configure = function() {
for ( var i = 0; i < this.a.length; i++) {
this.a[i].pos.x = this.a[i].level * 1.0;
this.a[i].pos.y = i * 1.0;
}
}
this.close_node = function( node) {
var idx = this.find( node);
if ( idx == -1)
return;
var level = node.level;
var i;
for ( i = idx + 1; i < this.a.length; i++) {
if ( this.a[i].level <= level)
break;
}
var next_idx = i;
if ( next_idx == idx + 1)
return;
for ( i = idx + 1; i < next_idx; i++) {
// Event backcall
if ( ctx.select_object == this.a[idx+1])
ctx.select_object = null;
this.ctx.event_cb( Plow.eEvent_ObjectDeleted, this.a[idx+1], 0, 0);
this.a.splice( idx+1, 1);
}
}
this.get_parent_object = function( node) {
var idx = this.find( node);
if ( idx == -1)
return null;
for ( var i = idx; i >= 0; i--) {
if ( this.a[i].level < node.level)
return this.a[i];
}
return null;
}
this.get_first_child = function( node) {
var idx = this.find( node);
if ( idx == -1)
return null;
if ( this.a.length == idx - 1)
return null;
if ( this.a[idx + 1].level > node.level)
return this.a[idx + 1];
return null;
}
this.get_next_sibling = function( node) {
var found = false;
for ( var i = 0; i < this.a.length; i++) {
if ( this.a[i] == node) {
found = true;
continue;
}
if ( found) {
if ( this.a[i].level == node.level)
return this.a[i];
if ( this.a[i].level < node.level)
return null;
}
}
return null;
}
this.get_next_object = function( node) {
for ( var i = 0; i < this.a.length; i++) {
if ( this.a[i] == node) {
if ( i == this.a.length - 1)
return null;
return this.a[i+1];
}
}
return null;
}
this.get_previous_object = function( node) {
for ( var i = 0; i < this.a.length; i++) {
if ( this.a[i] == node) {
if ( i == 0)
return null;
return this.a[i-1];
}
}
return null;
}
this.get_first_object = function() {
if ( this.a.length == 0)
return null;
return this.a[0];
}
this.get_last_object = function() {
if ( this.a.length == 0)
return null;
return this.a[this.a.length - 1];
}
this.find = function( elem) {
for ( var i = 0; i < this.a.length; i++) {
if ( this.a[i] == elem)
return i;
}
return -1;
}
}
function PlowNode( ctx, nc, level) {
this.ctx = ctx;
this.userdata = null;
this.OFFSET = 2;
this.x_right = 0.0;
this.x_left = 0.0;
this.y_high = 0.0;
this.y_low = 0.0;
this.nc = nc;
this.pos = new PlowPoint(ctx,0,0);
this.n_name = "";
this.annotv = [];
this.annotsize = [];
this.pixmapv = [];
this.trace_object = "";
this.trace_attribute = "";
this.trace_attr_type = 0;
this.highlight = false;
this.select = false;
this.invert = false;
this.level = level;
this.node_open = false;
this.fill_color = 0;
this.p = 0;
this.old_value = 0;
this.first_scan = true;
this.relative_position = 0;
this.set_annotation = function( number, text) {
if ( number >= 10)
return;
this.annotv[number] = text;
}
this.set_annotation_pixmap = function( number, pixmap) {
if ( number >= 10)
return;
this.pixmapv[number] = pixmap;
}
this.draw_object = function() {
this.draw( this.ctx.gdraw.gctx, null, null, false);
}
this.draw = function( g, p, node, highlight) {
var x = this.x_left * this.ctx.zoom_factor;
var y = this.y_low * this.ctx.zoom_factor-1;
var width = (this.x_right - this.x_left) * this.ctx.zoom_factor;
var height = (this.y_high - this.y_low) * this.ctx.zoom_factor+2;
g.fillStyle = "white";
if ( this.select)
g.fillStyle = "lightblue";
g.fillRect( x, y, width, height);
this.nc.draw( g, this.pos, this, this.highlight);
}
this.connect = function() {
if ( this.trace_object == "" || this.trace_attribute == "")
return;
var n = this.trace_attribute.indexOf('#');
if ( n != -1)
this.trace_attribute = this.trace_attribute.substring(0, n);
var o = this.trace_object + "." + this.trace_attribute;
this.p = ctx.gdh.refObjectInfo( o, this.trace_attr_type);
console.log("connecting", o, this.p);
}
this.scan = function() {
if ( this.p == 0)
return;
var v1 = ctx.gdh.getRefObjectInfo( this.p);
var evaluate = true;
if ( this.first_scan)
this.first_scan = false;
else if ( v1 == this.old_value)
return;
if ( v1)
this.highlight = true;
else
this.highlight = false;
this.old_value = v1;
this.draw_object();
}
this.set_borders = function() {
this.x_left = 1e37;
this.x_right = -1e37;
this.y_low = 1e37;
this.y_high = -1e37;
nc.a.set_borders( this);
}
this.event_handler = function( event, x, y) {
if ( (x - this.ctx.offset_x) / this.ctx.zoom_factor >= this.x_left &&
(x - this.ctx.offset_x) / this.ctx.zoom_factor <= this.x_right &&
(y - this.ctx.offset_y) / this.ctx.zoom_factor >= this.y_low &&
(y - this.ctx.offset_y) / this.ctx.zoom_factor <= this.y_high) {
ctx.event_object = this;
return 1;
}
return 0;
}
this.set_select = function( select) {
if ( select) {
this.select = true;
this.ctx.select_object = this;
}
else {
this.select = false;
if ( this.ctx.select_object == this)
this.ctx.select_object = null;
}
if ( select != this.select)
this.draw_object();
}
this.set_invert = function( invert) {
this.invert = invert;
this.draw_object();
}
this.set_userdata = function( userdata) {
this.userdata = userdata;
}
this.get_userdata = function() {
return this.userdata;
}
this.in_icon = function( x, y) {
if ( x >= this.x_left * this.ctx.zoom_factor &&
x <= (this.x_left + 1.75) * this.ctx.zoom_factor)
return true;
return false;
}
this.measure = function() {
var geom = new PlowGeometry();
geom.ll_x = this.x_left * this.ctx.zoom_factor;
geom.ll_y = this.y_low * this.ctx.zoom_factor;
geom.ur_x = this.x_right * this.ctx.zoom_factor;
geom.ur_y = this.y_high * this.ctx.zoom_factor;
return geom;
};
}
function PlowPoint( ctx, x, y) {
this.x = x;
this.y = y;
this.ctx = ctx;
}
function PlowAnnot( ctx, x, y, text_size, text_color, annot_type, number) {
this.RELATIVE_OFFSET = 1;
this.p = new PlowPoint(ctx, x, y);
this.draw_type = text_color;
this.text_size = text_size;
this.annot_type = annot_type;
this.number = number;
this.ctx = ctx;
this.draw = function( g, p0, node, highlight) {
if ( node == null)
return;
if ( node.annotv[this.number] == null)
return;
var tsize = 0;
var idx = this.ctx.zoom_factor / this.ctx.base_zoom_factor * (this.text_size +4) - 4;
if ( idx < 0) return;
switch( idx) {
case 0: tsize = 8; break;
case 1: tsize = 10; break;
case 2: tsize = 12; break;
case 3: tsize = 14; break;
case 4: tsize = 14; break;
case 5: tsize = 18; break;
case 6: tsize = 18; break;
case 7: tsize = 18; break;
default: tsize = idx * 3;
}
g.font = tsize + "px Arial";
if ( node.invert)
g.fillStyle = "white";
else
g.fillStyle = "black";
if ( highlight)
g.fillStyle = "red";
g.lineWidth = 0.5;
var x = (this.p.x + p0.x) * this.ctx.zoom_factor;
var y = (this.p.y + p0.y) * this.ctx.zoom_factor - tsize/4;
if ( (this.annot_type & Plow.RELATIVE_POSITION) != 0) {
var rel_x = (p0.x + node.relative_position + this.RELATIVE_OFFSET) * this.ctx.zoom_factor;
if ( x < rel_x)
x = rel_x;
}
var tokens = node.annotv[this.number].split('\n');
for ( var i = 0; i < tokens.length; i++) {
g.fillText( tokens[i], x, y);
y += tsize * 1.4;
}
if ( (this.annot_type & Plow.NEXT_RELATIVE_POSITION) != 0 || (this.annot_type & Plow.RELATIVE_POSITION) != 0) {
node.relative_position = (x + g.measureText(node.annotv[this.number]).width) / this.ctx.zoom_factor - p0.x;
}
}
this.set_borders = function( node) {
}
}
function PlowAnnotPixmap( ctx, x, y, number) {
this.p = new PlowPoint(ctx, x, y);
this.number = number;
this.ctx = ctx;
this.draw = function( gctx, p0, node, highlight) {
var x = (this.p.x + p0.x) * this.ctx.zoom_factor;
var y = (this.p.y + p0.y) * this.ctx.zoom_factor;
var img;
var bix = node.pixmapv[this.number];
if ( typeof bix === 'undefined' || bix === null)
return;
if ( node.invert)
bix++;
img = Bitmaps.img[bix];
if ( img == null) {
var img = new Image();
img.src = Bitmaps.images[bix];
Bitmaps.img[bix] = img;
Bitmaps.pending[bix] = [];
Bitmaps.pending[bix].push(new PlowPoint(this.ctx, x, y));
img.onload = function() {
for ( var i = 0; i < Bitmaps.pending[bix].length; i++)
gctx.drawImage(img, Bitmaps.pending[bix][i].x, Bitmaps.pending[bix][i].y);
Bitmaps.pending[bix] = null;
}
}
else {
if ( !img.complete)
Bitmaps.pending[bix].push(new PlowPoint(this.ctx, x, y));
else
gctx.drawImage(img, x, y);
}
}
this.set_borders = function( node) {
}
}
function PlowRect( ctx, x, y, width, height, fill_color, border_color, fill, fix_color) {
this.ll = new PlowPoint(ctx, x, y);
this.ur = new PlowPoint(ctx, x + width, y + height);
this.border_color = border_color;
this.fill_color = fill_color;
this.fill = fill;
this.fix_color = fix_color;
this.ctx = ctx;
this.draw = function( g, p, node, highlight) {
var x = (this.ll.x + p.x) * this.ctx.zoom_factor;
var y = (this.ll.y + p.y) * this.ctx.zoom_factor;
var width = (this.ur.x - this.ll.x) * this.ctx.zoom_factor;
var height = (this.ur.y - this.ll.y) * this.ctx.zoom_factor;
g.lineWidth = 1;
switch ( this.border_color) {
case Plow.COLOR_GRAY:
g.strokeStyle = "grey";
break;
case Plow.COLOR_RED:
g.strokeStyle = "red";
break;
case Plow.COLOR_WHITE:
g.strokeStyle = "white";
break;
default:
g.strokeStyle = "black";
}
if ( highlight)
g.strokeStyle = "red";
g.strokeRect( x, y, width, height);
if ( this.fill) {
switch ( this.fill_color) {
case Plow.COLOR_GRAY:
g.fillStyle = "grey";
break;
case Plow.COLOR_RED:
g.fillStyle = "red";
break;
case Plow.COLOR_YELLOW:
g.fillStyle = "yellow";
break;
case Plow.COLOR_GREEN:
g.fillStyle = "lightgreen";
break;
case Plow.COLOR_WHITE:
if ( node.invert)
g.fillStyle = "black";
else
g.fillStyle = "white";
break;
default:
if ( node.invert)
g.fillStyle = "white";
else
g.fillStyle = "black";
}
g.fillRect( x, y, width, height);
}
}
this.set_borders = function( node) {
if ( this.ll.x + node.pos.x < node.x_left)
node.x_left = this.ll.x + node.pos.x;
if ( this.ur.x + node.pos.x > node.x_right)
node.x_right = this.ur.x + node.pos.x;
if ( this.ll.y + node.pos.y < node.y_low)
node.y_low = this.ll.y + node.pos.y;
if ( this.ur.y + node.pos.y > node.y_high)
node.y_high = this.ur.y + node.pos.y;
}
}
function GDraw( ctx) {
this.ctx = ctx;
this.canvas = document.querySelector("canvas");
this.gctx = this.canvas.getContext("2d");
this.offset_top = this.canvas.offsetTop;
}
function PlowCtx() {
this.gdh = 0;
this.debug = false;
this.nodraw = 0;
this.zoom_factor = 20.0;
this.base_zoom_factor = 20.0;
this.offset_x = 0;
this.offset_y = 0;
this.x_right = 0.0;
this.x_left = 0.0;
this.y_high = 0.0;
this.y_low = 0.0;
this.a = new PlowArray(this);
this.a_nc = new PlowArray(this);
this.name = "Claes context";
this.gdraw = new GDraw(this);
this.selct_object = null;
this.event_cb = null;
this.event_object = null;
this.draw = function() {
if ( this.nodraw > 0)
return;
this.gdraw.gctx.fillStyle = "white";
this.gdraw.gctx.fillRect( 0, 0, this.gdraw.canvas.width, this.gdraw.canvas.height);
this.a.draw( this.gdraw.gctx, null, null, false);
};
this.connect = function() {
for ( var i = 0; i < this.a.size(); i++)
this.a.get(i).connect();
};
this.scan = function() {
console.log("ctx scan", this.a.size());
for ( var i = 0; i < this.a.size(); i++)
this.a.get(i).scan();
};
this.set_nodraw = function() {
this.nodraw++;
};
this.reset_nodraw = function() {
this.nodraw--;
};
this.size = function() {
return this.a.size()
};
this.event_handler = function( event, x, y) {
var sts = 0;
switch ( event) {
case Plow.eEvent_MB1Click:
case Plow.eEvent_MB1ClickShift:
for ( var i = 0; i < this.a.size(); i++) {
if ( this.a.get(i) instanceof PlowNode) {
sts = this.a.get(i).event_handler( event, x, y);
if ( sts == 1)
break;
}
}
if ( sts == 1) {
this.event_cb( event, this.event_object, x, y);
this.draw();
}
break;
case Plow.eEvent_Key_Up:
case Plow.eEvent_Key_Down:
case Plow.eEvent_Key_Left:
case Plow.eEvent_Key_Right:
case Plow.eEvent_Key_ShiftRight:
case Plow.eEvent_Key_CtrlR:
case Plow.eEvent_Key_CtrlL:
case Plow.eEvent_Key_CtrlG:
this.event_cb( event, null, 0, 0);
break;
}
};
this.set_select = function( select) {
for ( var i = 0; i < this.a.size(); i++) {
if ( this.a.get(i) instanceof PlowNode)
this.a.get(i).set_select( select);
}
};
this.set_invert = function( invert) {
for ( var i = 0; i < this.a.size(); i++) {
if ( this.a.get(i) instanceof PlowNode)
this.a.get(i).set_invert( invert);
}
};
this.get_select = function () {
return this.select_object;
};
this.insert = function( n, dest) {
this.a.add(n);
};
this.insertNode = function( n, destination, destCode) {
this.a.insertNode(n, destination, destCode);
};
this.remove = function( n) {
if ( this.select_object == n)
this.select_object = null;
this.a.remove(n);
};
this.insert_nc = function( nc) {
this.a_nc.add(nc);
};
this.configure = function() {
this.a.configure();
this.a.set_borders();
var height = this.a.a.length * 1.0 * this.zoom_factor;
this.gdraw.canvas.height = height;
};
this.get_parent_object = function( o) {
return this.a.get_parent_object(o);
};
this.get_next_object = function( o) {
return this.a.get_next_object(o);
};
this.get_last_object = function() {
return this.a.get_last_object();
};
this.get_first_object = function() {
return this.a.get_first_object();
};
this.get_previous_object = function( o) {
return this.a.get_previous_object(o);
};
this.close_node = function( o) {
this.a.close_node(o);
};
this.is_visible = function( o) {
if ((o.y_high * this.zoom_factor <= window.pageYOffset + window.innerHeight - this.gdraw.offset_top) &&
(o.y_low * this.zoom_factor >= window.pageYOffset - this.gdraw.offset_top))
return true;
return false;
};
this.scroll = function( y, factor) {
window.scrollTo( window.scrollX, y * this.zoom_factor - window.innerHeight * factor + this.gdraw.offset_top)
};
}
/** End Plow **/
/** Start Ev **/ /** Start Ev **/
function EvOpenChildrenData( node, open_next) { function EvOpenChildrenData( node, open_next) {
......
"use strict"; "use strict";
/** Start Pwr **/ #jsc_include pwr.jsi
#jsc_include gdh.jsi
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;};
}
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 |
1 << 3 |
1 << 4 |
1 << 5 |
1 << 0 |
1 << 1 |
1 << 25 |
1 << 18 |
1 << 19 |
1 << 20 |
1 << 6 |
1 << 7 |
1 << 8 |
1 << 9 |
1 << 10 |
1 << 11 |
1 << 12 |
1 << 13 |
1 << 14 |
1 << 15,
mAccess_AllOperators : 1 << 6 |
1 << 7 |
1 << 8 |
1 << 9 |
1 << 10 |
1 << 11 |
1 << 12 |
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
};
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
};
function PwrtObjid( vid, oix) {
this.oix = oix;
this.vid = vid;
}
function PwrtAttrRef() {
this.objid;
this.offset;
this.body;
this.size;
this.flags;
}
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;};
}
var CdhC = {
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 **/
function Sub() {
this.sts;
this.refid;
this.type;
this.elements;
this.name;
this.value;
}
function ObjectInfo() {
this.objid;
this.cid;
this.has_children;
this.name;
this.description;
this.classname;
this.full_name;
this.param1;
}
function AttributeInfo() {
this.name;
this.type;
this.size;
this.flags;
this.element;
this.objid;
this.full_name;
this.classname;
}
function MenuButton() {
this.type;
this.text;
this.name;
this.url;
}
function OpwindMenuInfo() {
this.title;
this.text;
this.enable_language;
this.enable_login;
this.enable_alarmlist;
this.enable_eventlog;
this.enable_navigator;
this.disable_help;
this.disable_proview;
this.language;
this.buttons = [];
}
function CrrInfo() {
this.type;
this.objid;
this.name;
this.classname;
}
function GlowPieInfo() {
this.sector_num;
this.min_val;
this.max_val;
}
function GlowBarChartInfo() {
this.bars;
this.barsegments;
this.min_value;
this.max_value;
}
function GlowTableInfo() {
this.columns;
this.rows;
this.column_size = new Array(Glow.TABLE_MAX_COL);
}
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
};
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
};
this.debug = false;
this.pending = [];
this.sub = [];
this.PORT = 4448;
this.ws = null;
this.open_cb = null;
this.close_cb = null;
this.return_cb = null;
this.next_id = 1234;
this.subscriptionCount = 1;
this.listSend = false;
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.binaryType = "arraybuffer";
this.ws.gdh = this;
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.gdh.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) {
var dv = new DataView(e.data);
var type = dv.getUint8(0);
var id = dv.getUint32(1);
var sts = dv.getUint32(5);
switch( type) {
case Msg.GET_OBJECT_INFO_BOOLEAN: {
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);
delete this.gdh.pending[id];
break;
}
case Msg.GET_OBJECT_INFO_INT: {
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);
delete this.gdh.pending[id];
break;
}
case Msg.GET_OBJECT_INFO_FLOAT: {
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);
delete this.gdh.pending[id];
break;
}
case Msg.GET_OBJECT_INFO_FLOAT_ARRAY: {
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++) {
value[i] = dv.getFloat32(k);
k += 4;
}
var 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);
var 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: {
var j = 9;
var size = dv.getUint32(j);
if ( this.gdh.debug) console.log("GetObjectRefInfoAll received", id, size);
j += 4;
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')
j += esize;
else {
var value;
switch ( sub.type) {
case Pwr.eType_Boolean:
if ( sub.elements <= 1) {
value = dv.getUint8(j);
j += 1;
}
else {
var elements = esize;
if ( elements != sub.elements)
console.log("Subscription size error", elements, sub.elements, eid);
value = new Array(elements);
for ( var k = 0; k < elements; k++) {
value[k] = dv.getUint8(j);
j += 1;
}
}
break;
case Pwr.eType_Float32:
if ( sub.elements <= 1) {
value = dv.getFloat32(j);
j += 4;
}
else {
var elements = esize / 4;
if ( elements != sub.elements)
console.log("Subscription size error", elements, sub.elements, eid);
value = new Array(elements);
for ( var k = 0; k < elements; k++) {
value[k] = dv.getFloat32(j);
j += 4;
}
}
break;
case Pwr.eType_Int8:
case Pwr.eType_Int16:
case Pwr.eType_Int32:
case Pwr.eType_UInt8:
case Pwr.eType_UInt16:
case Pwr.eType_UInt32:
case Pwr.eType_Status:
case Pwr.eType_NetStatus:
case Pwr.eType_Mask:
case Pwr.eType_Enum:
case GraphIfc.eType_Bit:
if ( sub.elements <= 1) {
value = dv.getInt32(j);
j += 4;
}
else {
var elements = esize / 4;
if ( elements != sub.elements)
console.log("Subscription size error", elements, sub.elements, eid);
value = new Array(elements);
for ( var k = 0; k < elements; k++) {
value[k] = dv.getInt32(j);
j += 4;
}
}
break;
case Pwr.eType_String:
case Pwr.eType_Time:
case Pwr.eType_DeltaTime:
case Pwr.eType_AttrRef:
case Pwr.eType_Objid:
if ( sub.elements <= 1) {
var nsize = dv.getInt16(j);
j += 2;
var iarr = new Uint8Array( nsize);
for ( var k = 0; k < nsize; k++) {
iarr[k] = dv.getUint8(j++);
}
value = String.fromCharCode.apply( null, iarr);
}
else {
var 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++) {
var nsize = dv.getInt16(j);
j += 2;
var iarr = new Uint8Array( nsize);
for ( var k = 0; k < nsize; k++) {
iarr[k] = dv.getUint8(j++);
}
value[l] = String.fromCharCode.apply( null, iarr);
}
}
break;
default: break;
}
this.gdh.sub[eid].value = value;
}
}
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);
delete this.gdh.pending[id];
break;
}
case Msg.GET_ALL_XTT_CHILDREN: {
var result = [];
var j = 9;
var size = dv.getUint32(j);
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++) {
var info = new ObjectInfo();
info.objid = new PwrtObjid();
info.objid.vid = dv.getUint32(j);
j += 4;
info.objid.oix = dv.getUint32(j);
j += 4;
info.cid = dv.getUint32(j);
j += 4;
info.has_children = dv.getUint16(j) !== 0;
j += 2;
var nsize = dv.getUint16(j);
j += 2;
var iarr = new Uint8Array( nsize);
for ( var k = 0; k < nsize; k++) {
iarr[k] = dv.getUint8(j++);
}
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[k] = dv.getUint8(j++);
}
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[k] = dv.getUint8(j++);
}
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);
delete this.gdh.pending[id];
break;
}
case Msg.GET_ALL_CLASS_ATTRIBUTES: {
var result = [];
var j = 9;
var size = dv.getUint32(j);
if ( this.gdh.debug) console.log("GetAllClassAttributes received", id, size);
j += 4;
for ( var i = 0; i < size; i++) {
var info = new AttributeInfo();
info.type = dv.getUint32(j);
j += 4;
info.flags = dv.getUint32(j);
j += 4;
info.size = dv.getUint16(j);
j += 2;
info.elements = dv.getUint16(j);
j += 2;
var nsize = dv.getUint16(j);
j += 2;
var iarr = new Uint8Array( nsize);
for ( var k = 0; k < nsize; k++) {
iarr[k] = dv.getUint8(j++);
}
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[k] = dv.getUint8(j++);
}
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);
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);
var info = null;
if ( (sts & 1) !== 0) {
var j = 9;
info = new ObjectInfo();
info.objid = new PwrtObjid();
info.objid.vid = dv.getUint32(j);
j += 4;
info.objid.oix = dv.getUint32(j);
j += 4;
info.cid = dv.getUint32(j);
j += 4;
info.has_children = dv.getUint16(j) !== 0;
j += 2;
var nsize = dv.getUint16(j);
j += 2;
var iarr = new Uint8Array( nsize);
for ( var k = 0; k < nsize; k++) {
iarr[k] = dv.getUint8(j++);
}
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[k] = dv.getUint8(j++);
}
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[k] = dv.getUint8(j++);
}
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[k] = dv.getUint8(j++);
}
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[k] = dv.getUint8(j++);
}
info.param1 = String.fromCharCode.apply( null, iarr);
}
var pending_data = this.gdh.pending[id];
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) {
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++) {
var info = new CrrInfo();
info.type = dv.getUint16(j);
j += 2;
info.objid = new PwrtObjid();
info.objid.vid = dv.getUint32(j);
j += 4;
info.objid.oix = dv.getUint32(j);
j += 4;
var nsize = dv.getUint16(j);
j += 2;
var iarr = new Uint8Array( nsize);
for ( var k = 0; k < nsize; k++) {
iarr[k] = dv.getUint8(j++);
}
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[k] = dv.getUint8(j++);
}
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);
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);
console.log("GetOpwindMenu received", sts, id);
if ( sts & 1) {
var nsize = dv.getUint16(j);
j += 2;
var iarr = new Uint8Array( nsize);
for ( var k = 0; k < nsize; k++) {
iarr[k] = dv.getUint8(j++);
}
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[k] = dv.getUint8(j++);
}
result.text = String.fromCharCode.apply( null, iarr);
result.enable_language = dv.getUint32(j);
j += 4;
result.enable_login = dv.getUint32(j);
j += 4;
result.enable_alarmlist = dv.getUint32(j);
j += 4;
result.enable_eventlog = dv.getUint32(j);
j += 4;
result.enable_navigator = dv.getUint32(j);
j += 4;
result.disable_help = dv.getUint32(j);
j += 4;
result.disable_proview = dv.getUint32(j);
j += 4;
result.language = dv.getUint32(j);
j += 4;
var bsize = dv.getUint16(j);
j += 2;
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[k] = dv.getUint8(j++);
}
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[k] = dv.getUint8(j++);
}
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[k] = dv.getUint8(j++);
}
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);
delete this.gdh.pending[id];
break;
}
case Msg.CHECK_USER: {
var j = 9;
if ( this.gdh.debug) console.log("Check user received", id, size);
console.log("Check user received", sts, id);
var priv = 0;
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);
delete this.gdh.pending[id];
break;
}
case Msg.GET_MSG: {
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++) {
iarr[k] = dv.getUint8(j++);
}
var msg = String.fromCharCode.apply( null, iarr);
}
var pending_data = this.gdh.pending[id];
pending_data.func_cb( id, pending_data.data, sts, msg);
delete this.gdh.pending[id];
break;
}
case Msg.MH_SYNC: {
var result = [];
var j = 9;
var size = dv.getUint32(j);
if ( this.gdh.debug) console.log("MhSync received", id, size);
j += 4;
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++) {
iarr[k] = dv.getUint8(j++);
}
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[k] = dv.getUint8(j++);
}
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[k] = dv.getUint8(j++);
}
e.eventName = String.fromCharCode.apply( null, iarr);
e.eventFlags = dv.getUint32(j);
j += 4;
e.eventStatus = dv.getUint32(j);
j += 4;
e.eventPrio = dv.getUint32(j);
j += 4;
e.eventId = new MhEventId();
e.eventId.nix = dv.getUint32(j);
j += 4;
e.eventId.idx = dv.getUint32(j);
j += 4;
len = dv.getUint16(j);
j += 2;
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.targetId = new MhEventId();
e.targetId.nix = dv.getUint32(j);
j += 4;
e.targetId.idx = dv.getUint32(j);
j += 4;
len = dv.getUint16(j);
j += 2;
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.eventType = dv.getUint32(j);
j += 4;
var objid = new PwrtObjid(0,0);
objid.vid = dv.getUint32(j);
j += 4;
objid.oix = dv.getUint32(j);
j += 4;
e.object = new PwrtAttrRef();
e.object.objid = objid;
e.object.offset = dv.getUint32(j);
j += 4;
e.object.body = dv.getUint32(j);
j += 4;
e.object.size = dv.getUint32(j);
j += 4;
e.object.flags = dv.getUint32(j);
j += 4;
var supObjid = new PwrtObjid(0,0);
supObjid.vid = dv.getUint32(j);
j += 4;
supObjid.oix = dv.getUint32(j);
j += 4;
e.supObject = new PwrtAttrRef();
e.supObject.objid = supObjid;
e.supObject.offset = dv.getUint32(j);
j += 4;
e.supObject.body = dv.getUint32(j);
j += 4;
e.supObject.size = dv.getUint32(j);
j += 4;
e.supObject.flags = dv.getUint32(j);
j += 4;
len = dv.getUint16(j);
j += 2;
iarr = new Uint8Array( len);
for ( var k = 0; k < len; k++) {
iarr[k] = dv.getUint8(j++);
}
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);
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);
delete this.gdh.pending[id];
break;
}
default:
console.log("Unknown message type");
}
}
}
};
};
this.getObjectInfoBoolean = function( name, return_cb) {
this.return_cb = return_cb;
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);
}
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.return_cb = return_cb;
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);
}
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.return_cb = return_cb;
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);
}
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.return_cb = return_cb;
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;
buf[4] = (this.next_id >> 16) & 0xFF;
buf[5] = (this.next_id >> 24) & 0xFF;
buf[6] = asize & 0xFF;
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);
}
this.pending[this.next_id] = new PendingData( return_cb, data);
this.ws.send(buf);
this.next_id++;
};
this.refObjectInfo = function( name, type, elements) {
var sub = new Sub();
sub.name = name;
sub.refid = this.subscriptionCount;
sub.type = type;
sub.elements = elements;
this.sub[this.subscriptionCount] = sub;
this.subscriptionCount++;
if ( !this.listSent) {
return sub.refid;
}
else {
var size = 0;
var len = 0;
size = 12 + sub.name.length;
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);
var k = 6;
buf[k++] = sub.refid & 0xFF;
buf[k++] = (sub.refid >> 8) & 0xFF;
buf[k++] = (sub.refid >> 16) & 0xFF;
buf[k++] = (sub.refid >> 24) & 0xFF;
buf[k++] = sub.elements & 0xFF;
buf[k++] = (sub.elements >> 8) & 0xFF;
buf[k++] = (sub.elements >> 16) & 0xFF;
buf[k++] = (sub.elements >> 24) & 0xFF;
buf[k++] = sub.name.length & 0xFF;
buf[k++] = (sub.name.length >> 8) & 0xFF;
buf[k++] = (sub.name.length >> 16) & 0xFF;
buf[k++] = (sub.name.length >> 24) & 0xFF;
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.ws.send(buf);
this.next_id++;
return sub.refid;
}
};
this.refObjectInfoReply = function( id, sts) {
if ( this.debug) console.log( "refObjectInfoReply", id, sts);
};
this.unrefObjectInfo = function( refid) {
var size = 0;
var len = 0;
size = 4;
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);
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.ws.send(buf);
this.next_id++;
delete this.sub[refid];
};
this.refObjectInfoList = function( return_cb) {
var size = 0;
var len = 0;
this.return_cb = return_cb;
for( var i in this.sub) {
size += 12 + this.sub[i].name.length;
len++;
}
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;
buf[4] = (this.next_id >> 16) & 0xFF;
buf[5] = (this.next_id >> 24) & 0xFF;
buf[6] = len & 0xFF;
buf[7] = (len >> 8) & 0xFF;
buf[8] = (len >> 16) & 0xFF;
buf[9] = (len >> 24) & 0xFF;
var k = 10;
for ( var i in this.sub) {
if ( i === 0)
continue;
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;
buf[k++] = (this.sub[i].refid >> 24) & 0xFF;
buf[k++] = this.sub[i].elements & 0xFF;
buf[k++] = (this.sub[i].elements >> 8) & 0xFF;
buf[k++] = (this.sub[i].elements >> 16) & 0xFF;
buf[k++] = (this.sub[i].elements >> 24) & 0xFF;
buf[k++] = this.sub[i].name.length & 0xFF;
buf[k++] = (this.sub[i].name.length >> 8) & 0xFF;
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++) {
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.ws.send(buf);
this.next_id++;
this.listSent = true;
};
this.refObjectInfoListReply = function( id, sts) {
if ( this.debug) console.log( "refObjectInfoListReply", id, sts);
};
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.ws.send(buf);
this.next_id++;
};
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);
return this.sub[id].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;
buf[3] = (this.next_id >> 8) & 0xFF;
buf[4] = (this.next_id >> 16) & 0xFF;
buf[5] = (this.next_id >> 24) & 0xFF;
buf[6] = value & 0xFF;
buf[7] = (value >> 8) & 0xFF;
buf[8] = (value >> 16) & 0xFF;
buf[9] = (value >> 24) & 0xFF;
buf[10] = name.length & 0xFF;
buf[11] = (name.length >> 8) & 0xFF;
var k = 12;
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);
this.next_id++;
return new PwrtStatus( 1);
};
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;
buf[3] = (this.next_id >> 8) & 0xFF;
buf[4] = (this.next_id >> 16) & 0xFF;
buf[5] = (this.next_id >> 24) & 0xFF;
buf[6] = value & 0xFF;
buf[7] = (value >> 8) & 0xFF;
buf[8] = (value >> 16) & 0xFF;
buf[9] = (value >> 24) & 0xFF;
buf[10] = name.length & 0xFF;
buf[11] = (name.length >> 8) & 0xFF;
var k = 12;
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);
this.next_id++;
return new PwrtStatus( 1);
};
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;
buf[3] = (this.next_id >> 8) & 0xFF;
buf[4] = (this.next_id >> 16) & 0xFF;
buf[5] = (this.next_id >> 24) & 0xFF;
var fbuf = new ArrayBuffer(4);
var fa = new Float32Array(fbuf);
fa[0] = value;
var ba = new Uint8Array(fbuf);
buf[6] = ba[0];
buf[7] = ba[1];
buf[8] = ba[2];
buf[9] = ba[3];
buf[10] = name.length & 0xFF;
buf[11] = (name.length >> 8) & 0xFF;
var k = 12;
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);
this.next_id++;
return new PwrtStatus( 1);
};
this.setObjectInfoString = function( name, value) {
var i;
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;
buf[4] = (this.next_id >> 16) & 0xFF;
buf[5] = (this.next_id >> 24) & 0xFF;
buf[6] = value.length & 0xFF;
buf[7] = (value.length >> 8) & 0xFF;
var k = 8;
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++) {
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);
this.next_id++;
return new PwrtStatus( 1);
};
this.toggleObjectInfo = function( name) {
var buf = new Uint8Array(8 + name.length);
buf[0] = Msg.TOGGLE_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;
buf[6] = name.length & 0xFF;
buf[7] = (name.length >> 8) & 0xFF;
var k = 8;
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);
this.next_id++;
return new PwrtStatus( 1);
};
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;
buf[3] = (this.next_id >> 8) & 0xFF;
buf[4] = (this.next_id >> 16) & 0xFF;
buf[5] = (this.next_id >> 24) & 0xFF;
buf[6] = oid.vid & 0xFF;
buf[7] = (oid.vid >> 8) & 0xFF;
buf[8] = (oid.vid >> 16) & 0xFF;
buf[9] = (oid.vid >> 24) & 0xFF;
buf[10] = oid.oix & 0xFF;
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.ws.send(buf);
this.next_id++;
};
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;
buf[3] = (this.next_id >> 8) & 0xFF;
buf[4] = (this.next_id >> 16) & 0xFF;
buf[5] = (this.next_id >> 24) & 0xFF;
buf[6] = cid & 0xFF;
buf[7] = (cid >> 8) & 0xFF;
buf[8] = (cid >> 16) & 0xFF;
buf[9] = (cid >> 24) & 0xFF;
buf[10] = oid.vid & 0xFF;
buf[11] = (oid.vid >> 8) & 0xFF;
buf[12] = (oid.vid >> 16) & 0xFF;
buf[13] = (oid.vid >> 24) & 0xFF;
buf[14] = oid.oix & 0xFF;
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.ws.send(buf);
this.next_id++;
};
this.getObject = function( oid, op, return_cb, data) {
var buf = new Uint8Array(16);
buf[0] = Msg.GET_OBJECT;
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;
buf[6] = op & 0xFF;
buf[7] = (op >> 8) & 0xFF;
buf[8] = oid.vid & 0xFF;
buf[9] = (oid.vid >> 8) & 0xFF;
buf[10] = (oid.vid >> 16) & 0xFF;
buf[11] = (oid.vid >> 24) & 0xFF;
buf[12] = oid.oix & 0xFF;
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.ws.send(buf);
this.next_id++;
};
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;
buf[3] = (this.next_id >> 8) & 0xFF;
buf[4] = (this.next_id >> 16) & 0xFF;
buf[5] = (this.next_id >> 24) & 0xFF;
buf[6] = op & 0xFF;
buf[7] = (op >> 8) & 0xFF;
buf[8] = aref.objid.vid & 0xFF;
buf[9] = (aref.objid.vid >> 8) & 0xFF;
buf[10] = (aref.objid.vid >> 16) & 0xFF;
buf[11] = (aref.objid.vid >> 24) & 0xFF;
buf[12] = aref.objid.oix & 0xFF;
buf[13] = (aref.objid.oix >> 8) & 0xFF;
buf[14] = (aref.objid.oix >> 16) & 0xFF;
buf[15] = (aref.objid.oix >> 24) & 0xFF;
buf[16] = aref.offset & 0xFF;
buf[17] = (aref.offset >> 8) & 0xFF;
buf[18] = (aref.offset >> 16) & 0xFF;
buf[19] = (aref.offset >> 24) & 0xFF;
buf[20] = aref.body & 0xFF;
buf[21] = (aref.body >> 8) & 0xFF;
buf[22] = (aref.body >> 16) & 0xFF;
buf[23] = (aref.body >> 24) & 0xFF;
buf[24] = aref.size & 0xFF;
buf[25] = (aref.size >> 8) & 0xFF;
buf[26] = (aref.size >> 16) & 0xFF;
buf[27] = (aref.size >> 24) & 0xFF;
buf[28] = aref.flags & 0xFF;
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.ws.send(buf);
this.next_id++;
};
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;
buf[3] = (this.next_id >> 8) & 0xFF;
buf[4] = (this.next_id >> 16) & 0xFF;
buf[5] = (this.next_id >> 24) & 0xFF;
buf[6] = op & 0xFF;
buf[7] = (op >> 8) & 0xFF;
buf[8] = name.length & 0xFF;
buf[9] = (name.length >> 8) & 0xFF;
var k = 10;
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.ws.send(buf);
this.next_id++;
};
this.crrSignal = function( oid, return_cb, data) {
var buf = new Uint8Array(14);
buf[0] = Msg.CRR_SIGNAL;
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;
buf[6] = oid.vid & 0xFF;
buf[7] = (oid.vid >> 8) & 0xFF;
buf[8] = (oid.vid >> 16) & 0xFF;
buf[9] = (oid.vid >> 24) & 0xFF;
buf[10] = oid.oix & 0xFF;
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.ws.send(buf);
this.next_id++;
};
this.getOpwindMenu = function( name, return_cb, data) {
var len = name.length;
var buf = new Uint8Array(8 + name.length);
buf[0] = Msg.GET_OPWIND_MENU;
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;
buf[6] = name.length & 0xFF;
buf[7] = (name.length >> 8) & 0xFF;
var k = 8;
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.ws.send(buf);
this.next_id++;
};
this.login = function( user, passwd, return_cb, data) {
var buf = new Uint8Array(6 + 2 + user.length + 2 + passwd.length);
buf[0] = Msg.CHECK_USER;
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;
var k = 6;
buf[k] = user.length & 0xFF;
buf[k+1] = (user.length >> 8) & 0xFF;
k += 2;
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;
k += 2;
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.ws.send(buf);
this.next_id++;
};
this.getMsg = function( value, return_cb, data) {
var buf = new Uint8Array(10);
buf[0] = Msg.GET_MSG;
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;
buf[6] = value & 0xFF;
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.ws.send(buf);
if ( this.debug) console.log("Sending getMsg", this.next_id, value);
this.next_id++;
};
this.mhSync = function( sync, return_cb, data) {
var buf = new Uint8Array(10);
buf[0] = Msg.MH_SYNC;
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;
buf[6] = sync & 0xFF;
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.ws.send(buf);
this.next_id++;
};
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;
buf[3] = (this.next_id >> 8) & 0xFF;
buf[4] = (this.next_id >> 16) & 0xFF;
buf[5] = (this.next_id >> 24) & 0xFF;
buf[6] = event_id.nix & 0xFF;
buf[7] = (event_id.nix >> 8) & 0xFF;
buf[8] = (event_id.nix >> 16) & 0xFF;
buf[9] = (event_id.nix >> 24) & 0xFF;
buf[10] = event_id.idx & 0xFF;
buf[11] = (event_id.idx >> 8) & 0xFF;
buf[12] = (event_id.idx >> 16) & 0xFF;
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;
k += 2;
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.ws.send(buf);
this.next_id++;
};
}
/** End Gdh **/
/** Start Flow **/ /** Start Flow **/
......
This source diff could not be displayed because it is too large. You can view the blob instead.
"use strict"; "use strict";
/** Crypt start **/ #jsc_include crypt.jsi
/**************************************************************************** #jsc_include pwr.jsi
* Proview #jsc_include gdh.jsi
*
* Java-based implementation of the unix crypt command
*
* Based upon C source code written by Eric Young, eay@psych.uq.oz.au
*
* Author John Dumas, original name JCrypt
*
* Used and distributed with Proview by permission of the author.
*
****************************************************************************/
/**
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;
this.con_salt =
[
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,
0x0A, 0x0B, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A,
0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12,
0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A,
0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22,
0x23, 0x24, 0x25, 0x20, 0x21, 0x22, 0x23, 0x24,
0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C,
0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34,
0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C,
0x3D, 0x3E, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00,
];
this.shifts2 =
[
false, false, true, true, true, true, true, true,
false, true, true, true, true, true, true, false
];
this.skb =
[
[
/* for C bits (numbered as per FIPS 46) 1 2 3 4 5 6 */
0x00000000, 0x00000010, 0x20000000, 0x20000010,
0x00010000, 0x00010010, 0x20010000, 0x20010010,
0x00000800, 0x00000810, 0x20000800, 0x20000810,
0x00010800, 0x00010810, 0x20010800, 0x20010810,
0x00000020, 0x00000030, 0x20000020, 0x20000030,
0x00010020, 0x00010030, 0x20010020, 0x20010030,
0x00000820, 0x00000830, 0x20000820, 0x20000830,
0x00010820, 0x00010830, 0x20010820, 0x20010830,
0x00080000, 0x00080010, 0x20080000, 0x20080010,
0x00090000, 0x00090010, 0x20090000, 0x20090010,
0x00080800, 0x00080810, 0x20080800, 0x20080810,
0x00090800, 0x00090810, 0x20090800, 0x20090810,
0x00080020, 0x00080030, 0x20080020, 0x20080030,
0x00090020, 0x00090030, 0x20090020, 0x20090030,
0x00080820, 0x00080830, 0x20080820, 0x20080830,
0x00090820, 0x00090830, 0x20090820, 0x20090830,
],
[
/* for C bits (numbered as per FIPS 46) 7 8 10 11 12 13 */
0x00000000, 0x02000000, 0x00002000, 0x02002000,
0x00200000, 0x02200000, 0x00202000, 0x02202000,
0x00000004, 0x02000004, 0x00002004, 0x02002004,
0x00200004, 0x02200004, 0x00202004, 0x02202004,
0x00000400, 0x02000400, 0x00002400, 0x02002400,
0x00200400, 0x02200400, 0x00202400, 0x02202400,
0x00000404, 0x02000404, 0x00002404, 0x02002404,
0x00200404, 0x02200404, 0x00202404, 0x02202404,
0x10000000, 0x12000000, 0x10002000, 0x12002000,
0x10200000, 0x12200000, 0x10202000, 0x12202000,
0x10000004, 0x12000004, 0x10002004, 0x12002004,
0x10200004, 0x12200004, 0x10202004, 0x12202004,
0x10000400, 0x12000400, 0x10002400, 0x12002400,
0x10200400, 0x12200400, 0x10202400, 0x12202400,
0x10000404, 0x12000404, 0x10002404, 0x12002404,
0x10200404, 0x12200404, 0x10202404, 0x12202404,
],
[
/* for C bits (numbered as per FIPS 46) 14 15 16 17 19 20 */
0x00000000, 0x00000001, 0x00040000, 0x00040001,
0x01000000, 0x01000001, 0x01040000, 0x01040001,
0x00000002, 0x00000003, 0x00040002, 0x00040003,
0x01000002, 0x01000003, 0x01040002, 0x01040003,
0x00000200, 0x00000201, 0x00040200, 0x00040201,
0x01000200, 0x01000201, 0x01040200, 0x01040201,
0x00000202, 0x00000203, 0x00040202, 0x00040203,
0x01000202, 0x01000203, 0x01040202, 0x01040203,
0x08000000, 0x08000001, 0x08040000, 0x08040001,
0x09000000, 0x09000001, 0x09040000, 0x09040001,
0x08000002, 0x08000003, 0x08040002, 0x08040003,
0x09000002, 0x09000003, 0x09040002, 0x09040003,
0x08000200, 0x08000201, 0x08040200, 0x08040201,
0x09000200, 0x09000201, 0x09040200, 0x09040201,
0x08000202, 0x08000203, 0x08040202, 0x08040203,
0x09000202, 0x09000203, 0x09040202, 0x09040203,
],
[
/* for C bits (numbered as per FIPS 46) 21 23 24 26 27 28 */
0x00000000, 0x00100000, 0x00000100, 0x00100100,
0x00000008, 0x00100008, 0x00000108, 0x00100108,
0x00001000, 0x00101000, 0x00001100, 0x00101100,
0x00001008, 0x00101008, 0x00001108, 0x00101108,
0x04000000, 0x04100000, 0x04000100, 0x04100100,
0x04000008, 0x04100008, 0x04000108, 0x04100108,
0x04001000, 0x04101000, 0x04001100, 0x04101100,
0x04001008, 0x04101008, 0x04001108, 0x04101108,
0x00020000, 0x00120000, 0x00020100, 0x00120100,
0x00020008, 0x00120008, 0x00020108, 0x00120108,
0x00021000, 0x00121000, 0x00021100, 0x00121100,
0x00021008, 0x00121008, 0x00021108, 0x00121108,
0x04020000, 0x04120000, 0x04020100, 0x04120100,
0x04020008, 0x04120008, 0x04020108, 0x04120108,
0x04021000, 0x04121000, 0x04021100, 0x04121100,
0x04021008, 0x04121008, 0x04021108, 0x04121108,
],
[
/* for D bits (numbered as per FIPS 46) 1 2 3 4 5 6 */
0x00000000, 0x10000000, 0x00010000, 0x10010000,
0x00000004, 0x10000004, 0x00010004, 0x10010004,
0x20000000, 0x30000000, 0x20010000, 0x30010000,
0x20000004, 0x30000004, 0x20010004, 0x30010004,
0x00100000, 0x10100000, 0x00110000, 0x10110000,
0x00100004, 0x10100004, 0x00110004, 0x10110004,
0x20100000, 0x30100000, 0x20110000, 0x30110000,
0x20100004, 0x30100004, 0x20110004, 0x30110004,
0x00001000, 0x10001000, 0x00011000, 0x10011000,
0x00001004, 0x10001004, 0x00011004, 0x10011004,
0x20001000, 0x30001000, 0x20011000, 0x30011000,
0x20001004, 0x30001004, 0x20011004, 0x30011004,
0x00101000, 0x10101000, 0x00111000, 0x10111000,
0x00101004, 0x10101004, 0x00111004, 0x10111004,
0x20101000, 0x30101000, 0x20111000, 0x30111000,
0x20101004, 0x30101004, 0x20111004, 0x30111004,
],
[
/* for D bits (numbered as per FIPS 46) 8 9 11 12 13 14 */
0x00000000, 0x08000000, 0x00000008, 0x08000008,
0x00000400, 0x08000400, 0x00000408, 0x08000408,
0x00020000, 0x08020000, 0x00020008, 0x08020008,
0x00020400, 0x08020400, 0x00020408, 0x08020408,
0x00000001, 0x08000001, 0x00000009, 0x08000009,
0x00000401, 0x08000401, 0x00000409, 0x08000409,
0x00020001, 0x08020001, 0x00020009, 0x08020009,
0x00020401, 0x08020401, 0x00020409, 0x08020409,
0x02000000, 0x0A000000, 0x02000008, 0x0A000008,
0x02000400, 0x0A000400, 0x02000408, 0x0A000408,
0x02020000, 0x0A020000, 0x02020008, 0x0A020008,
0x02020400, 0x0A020400, 0x02020408, 0x0A020408,
0x02000001, 0x0A000001, 0x02000009, 0x0A000009,
0x02000401, 0x0A000401, 0x02000409, 0x0A000409,
0x02020001, 0x0A020001, 0x02020009, 0x0A020009,
0x02020401, 0x0A020401, 0x02020409, 0x0A020409,
],
[
/* for D bits (numbered as per FIPS 46) 16 17 18 19 20 21 */
0x00000000, 0x00000100, 0x00080000, 0x00080100,
0x01000000, 0x01000100, 0x01080000, 0x01080100,
0x00000010, 0x00000110, 0x00080010, 0x00080110,
0x01000010, 0x01000110, 0x01080010, 0x01080110,
0x00200000, 0x00200100, 0x00280000, 0x00280100,
0x01200000, 0x01200100, 0x01280000, 0x01280100,
0x00200010, 0x00200110, 0x00280010, 0x00280110,
0x01200010, 0x01200110, 0x01280010, 0x01280110,
0x00000200, 0x00000300, 0x00080200, 0x00080300,
0x01000200, 0x01000300, 0x01080200, 0x01080300,
0x00000210, 0x00000310, 0x00080210, 0x00080310,
0x01000210, 0x01000310, 0x01080210, 0x01080310,
0x00200200, 0x00200300, 0x00280200, 0x00280300,
0x01200200, 0x01200300, 0x01280200, 0x01280300,
0x00200210, 0x00200310, 0x00280210, 0x00280310,
0x01200210, 0x01200310, 0x01280210, 0x01280310,
],
[
/* for D bits (numbered as per FIPS 46) 22 23 24 25 27 28 */
0x00000000, 0x04000000, 0x00040000, 0x04040000,
0x00000002, 0x04000002, 0x00040002, 0x04040002,
0x00002000, 0x04002000, 0x00042000, 0x04042000,
0x00002002, 0x04002002, 0x00042002, 0x04042002,
0x00000020, 0x04000020, 0x00040020, 0x04040020,
0x00000022, 0x04000022, 0x00040022, 0x04040022,
0x00002020, 0x04002020, 0x00042020, 0x04042020,
0x00002022, 0x04002022, 0x00042022, 0x04042022,
0x00000800, 0x04000800, 0x00040800, 0x04040800,
0x00000802, 0x04000802, 0x00040802, 0x04040802,
0x00002800, 0x04002800, 0x00042800, 0x04042800,
0x00002802, 0x04002802, 0x00042802, 0x04042802,
0x00000820, 0x04000820, 0x00040820, 0x04040820,
0x00000822, 0x04000822, 0x00040822, 0x04040822,
0x00002820, 0x04002820, 0x00042820, 0x04042820,
0x00002822, 0x04002822, 0x00042822, 0x04042822,
],
];
this.SPtrans =
[
[
/* nibble 0 */
0x00820200, 0x00020000, 0x80800000, 0x80820200,
0x00800000, 0x80020200, 0x80020000, 0x80800000,
0x80020200, 0x00820200, 0x00820000, 0x80000200,
0x80800200, 0x00800000, 0x00000000, 0x80020000,
0x00020000, 0x80000000, 0x00800200, 0x00020200,
0x80820200, 0x00820000, 0x80000200, 0x00800200,
0x80000000, 0x00000200, 0x00020200, 0x80820000,
0x00000200, 0x80800200, 0x80820000, 0x00000000,
0x00000000, 0x80820200, 0x00800200, 0x80020000,
0x00820200, 0x00020000, 0x80000200, 0x00800200,
0x80820000, 0x00000200, 0x00020200, 0x80800000,
0x80020200, 0x80000000, 0x80800000, 0x00820000,
0x80820200, 0x00020200, 0x00820000, 0x80800200,
0x00800000, 0x80000200, 0x80020000, 0x00000000,
0x00020000, 0x00800000, 0x80800200, 0x00820200,
0x80000000, 0x80820000, 0x00000200, 0x80020200,
],
[
/* nibble 1 */
0x10042004, 0x00000000, 0x00042000, 0x10040000,
0x10000004, 0x00002004, 0x10002000, 0x00042000,
0x00002000, 0x10040004, 0x00000004, 0x10002000,
0x00040004, 0x10042000, 0x10040000, 0x00000004,
0x00040000, 0x10002004, 0x10040004, 0x00002000,
0x00042004, 0x10000000, 0x00000000, 0x00040004,
0x10002004, 0x00042004, 0x10042000, 0x10000004,
0x10000000, 0x00040000, 0x00002004, 0x10042004,
0x00040004, 0x10042000, 0x10002000, 0x00042004,
0x10042004, 0x00040004, 0x10000004, 0x00000000,
0x10000000, 0x00002004, 0x00040000, 0x10040004,
0x00002000, 0x10000000, 0x00042004, 0x10002004,
0x10042000, 0x00002000, 0x00000000, 0x10000004,
0x00000004, 0x10042004, 0x00042000, 0x10040000,
0x10040004, 0x00040000, 0x00002004, 0x10002000,
0x10002004, 0x00000004, 0x10040000, 0x00042000,
],
[
/* nibble 2 */
0x41000000, 0x01010040, 0x00000040, 0x41000040,
0x40010000, 0x01000000, 0x41000040, 0x00010040,
0x01000040, 0x00010000, 0x01010000, 0x40000000,
0x41010040, 0x40000040, 0x40000000, 0x41010000,
0x00000000, 0x40010000, 0x01010040, 0x00000040,
0x40000040, 0x41010040, 0x00010000, 0x41000000,
0x41010000, 0x01000040, 0x40010040, 0x01010000,
0x00010040, 0x00000000, 0x01000000, 0x40010040,
0x01010040, 0x00000040, 0x40000000, 0x00010000,
0x40000040, 0x40010000, 0x01010000, 0x41000040,
0x00000000, 0x01010040, 0x00010040, 0x41010000,
0x40010000, 0x01000000, 0x41010040, 0x40000000,
0x40010040, 0x41000000, 0x01000000, 0x41010040,
0x00010000, 0x01000040, 0x41000040, 0x00010040,
0x01000040, 0x00000000, 0x41010000, 0x40000040,
0x41000000, 0x40010040, 0x00000040, 0x01010000,
],
[
/* nibble 3 */
0x00100402, 0x04000400, 0x00000002, 0x04100402,
0x00000000, 0x04100000, 0x04000402, 0x00100002,
0x04100400, 0x04000002, 0x04000000, 0x00000402,
0x04000002, 0x00100402, 0x00100000, 0x04000000,
0x04100002, 0x00100400, 0x00000400, 0x00000002,
0x00100400, 0x04000402, 0x04100000, 0x00000400,
0x00000402, 0x00000000, 0x00100002, 0x04100400,
0x04000400, 0x04100002, 0x04100402, 0x00100000,
0x04100002, 0x00000402, 0x00100000, 0x04000002,
0x00100400, 0x04000400, 0x00000002, 0x04100000,
0x04000402, 0x00000000, 0x00000400, 0x00100002,
0x00000000, 0x04100002, 0x04100400, 0x00000400,
0x04000000, 0x04100402, 0x00100402, 0x00100000,
0x04100402, 0x00000002, 0x04000400, 0x00100402,
0x00100002, 0x00100400, 0x04100000, 0x04000402,
0x00000402, 0x04000000, 0x04000002, 0x04100400,
],
[
/* nibble 4 */
0x02000000, 0x00004000, 0x00000100, 0x02004108,
0x02004008, 0x02000100, 0x00004108, 0x02004000,
0x00004000, 0x00000008, 0x02000008, 0x00004100,
0x02000108, 0x02004008, 0x02004100, 0x00000000,
0x00004100, 0x02000000, 0x00004008, 0x00000108,
0x02000100, 0x00004108, 0x00000000, 0x02000008,
0x00000008, 0x02000108, 0x02004108, 0x00004008,
0x02004000, 0x00000100, 0x00000108, 0x02004100,
0x02004100, 0x02000108, 0x00004008, 0x02004000,
0x00004000, 0x00000008, 0x02000008, 0x02000100,
0x02000000, 0x00004100, 0x02004108, 0x00000000,
0x00004108, 0x02000000, 0x00000100, 0x00004008,
0x02000108, 0x00000100, 0x00000000, 0x02004108,
0x02004008, 0x02004100, 0x00000108, 0x00004000,
0x00004100, 0x02004008, 0x02000100, 0x00000108,
0x00000008, 0x00004108, 0x02004000, 0x02000008,
],
[
/* nibble 5 */
0x20000010, 0x00080010, 0x00000000, 0x20080800,
0x00080010, 0x00000800, 0x20000810, 0x00080000,
0x00000810, 0x20080810, 0x00080800, 0x20000000,
0x20000800, 0x20000010, 0x20080000, 0x00080810,
0x00080000, 0x20000810, 0x20080010, 0x00000000,
0x00000800, 0x00000010, 0x20080800, 0x20080010,
0x20080810, 0x20080000, 0x20000000, 0x00000810,
0x00000010, 0x00080800, 0x00080810, 0x20000800,
0x00000810, 0x20000000, 0x20000800, 0x00080810,
0x20080800, 0x00080010, 0x00000000, 0x20000800,
0x20000000, 0x00000800, 0x20080010, 0x00080000,
0x00080010, 0x20080810, 0x00080800, 0x00000010,
0x20080810, 0x00080800, 0x00080000, 0x20000810,
0x20000010, 0x20080000, 0x00080810, 0x00000000,
0x00000800, 0x20000010, 0x20000810, 0x20080800,
0x20080000, 0x00000810, 0x00000010, 0x20080010,
],
[
/* nibble 6 */
0x00001000, 0x00000080, 0x00400080, 0x00400001,
0x00401081, 0x00001001, 0x00001080, 0x00000000,
0x00400000, 0x00400081, 0x00000081, 0x00401000,
0x00000001, 0x00401080, 0x00401000, 0x00000081,
0x00400081, 0x00001000, 0x00001001, 0x00401081,
0x00000000, 0x00400080, 0x00400001, 0x00001080,
0x00401001, 0x00001081, 0x00401080, 0x00000001,
0x00001081, 0x00401001, 0x00000080, 0x00400000,
0x00001081, 0x00401000, 0x00401001, 0x00000081,
0x00001000, 0x00000080, 0x00400000, 0x00401001,
0x00400081, 0x00001081, 0x00001080, 0x00000000,
0x00000080, 0x00400001, 0x00000001, 0x00400080,
0x00000000, 0x00400081, 0x00400080, 0x00001080,
0x00000081, 0x00001000, 0x00401081, 0x00400000,
0x00401080, 0x00000001, 0x00001001, 0x00401081,
0x00400001, 0x00401080, 0x00401000, 0x00001001,
],
[
/* nibble 7 */
0x08200020, 0x08208000, 0x00008020, 0x00000000,
0x08008000, 0x00200020, 0x08200000, 0x08208020,
0x00000020, 0x08000000, 0x00208000, 0x00008020,
0x00208020, 0x08008020, 0x08000020, 0x08200000,
0x00008000, 0x00208020, 0x00200020, 0x08008000,
0x08208020, 0x08000020, 0x00000000, 0x00208000,
0x08000000, 0x00200000, 0x08008020, 0x08200020,
0x00200000, 0x00008000, 0x08208000, 0x00000020,
0x00200000, 0x00008000, 0x08000020, 0x08208020,
0x00008020, 0x08000000, 0x00000000, 0x00208000,
0x08200020, 0x08008020, 0x08008000, 0x00200020,
0x08208000, 0x00000020, 0x00200020, 0x08008000,
0x08208020, 0x00200000, 0x08200000, 0x08000020,
0x00208000, 0x00008020, 0x08008020, 0x08200000,
0x00000020, 0x08208000, 0x00208020, 0x00000000,
0x08000000, 0x08200020, 0x00008000, 0x00208020
]
];
this.cov_2char =
[
0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35,
0x36, 0x37, 0x38, 0x39, 0x41, 0x42, 0x43, 0x44,
0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C,
0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54,
0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x61, 0x62,
0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A,
0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72,
0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A
];
this.byteToUnsigned = function(b)
{
var value = Math.floor(b);
return(value >= 0 ? value : value + 256);
}
this.fourBytesToInt = function(b, offset)
{
var value;
value = this.byteToUnsigned(b[offset++]);
value |= (this.byteToUnsigned(b[offset++]) << 8);
value |= (this.byteToUnsigned(b[offset++]) << 16);
value |= (this.byteToUnsigned(b[offset++]) << 24);
return value;
}
this.intToFourBytes = function(iValue, b, offset)
{
b[offset++] = ((iValue) & 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)
{
var t;
t = ((a >>> n) ^ b) & m;
a ^= t << n;
b ^= t;
results[0] = a;
results[1] = b;
}
this.HPERM_OP = function(a, n, m)
{
var t;
t = ((a << (16 - n)) ^ a) & m;
a = a ^ t ^ (t >>> (16 - n));
return(a);
}
this.des_set_key = function(key) {
var schedule = new Array(this.ITERATIONS * 2);
var c = this.fourBytesToInt(key, 0);
var d = this.fourBytesToInt(key, 4);
var results = new Array(2);
this.PERM_OP(d, c, 4, 0x0f0f0f0f, results);
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];
this.PERM_OP(c, d, 8, 0x00ff00ff, results);
c = results[0]; d = results[1];
this.PERM_OP(d, c, 1, 0x55555555, results);
d = results[0]; c = results[1];
d = (((d & 0x000000ff) << 16) | (d & 0x0000ff00) |
((d & 0x00ff0000) >>> 16) | ((c & 0xf0000000) >>> 4));
c &= 0x0fffffff;
var s, t;
var j = 0;
for(var i = 0; i < this.ITERATIONS; i++) {
if(this.shifts2[i]) {
c = (c >>> 2) | (c << 26);
d = (d >>> 2) | (d << 26);
}
else
{
c = (c >>> 1) | (c << 27);
d = (d >>> 1) | (d << 27);
}
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)]|
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)];
schedule[j++] = ((t << 16) | (s & 0x0000ffff)) & 0xffffffff;
s = ((s >>> 16) | (t & 0xffff0000));
s = (s << 4) | (s >>> 28);
schedule[j++] = s & 0xffffffff;
}
return schedule;
}
this.D_ENCRYPT = function( L, R, S, E0, E1, s) {
var t, u, v;
v = R ^ (R >>> 16);
u = v & E0;
v = v & E1;
u = (u ^ (u << 16)) ^ R ^ s[S];
t = (v ^ (v << 16)) ^ R ^ s[S + 1];
t = (t >>> 4) | (t << 28);
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[2][(u >>> 8) & 0x3f] |
this.SPtrans[4][(u >>> 16) & 0x3f] |
this.SPtrans[6][(u >>> 24) & 0x3f];
return L;
}
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)
{
left = this.D_ENCRYPT(left, right, i, Eswap0, Eswap1, schedule);
right = this.D_ENCRYPT(right, left, i + 2, Eswap0, Eswap1, schedule);
}
t = left;
left = right;
right = t;
}
t = right;
right = (left >>> 1) | (left << 31);
left = (t >>> 1) | (t << 31);
left &= 0xffffffff;
right &= 0xffffffff;
var results = new Array(2);
this.PERM_OP(right, left, 1, 0x55555555, results);
right = results[0]; left = results[1];
this.PERM_OP(left, right, 8, 0x00ff00ff, results);
left = results[0]; right = results[1];
this.PERM_OP(right, left, 2, 0x33333333, results);
right = results[0]; left = results[1];
this.PERM_OP(left, right, 16, 0x0000ffff, results);
left = results[0]; right = results[1];
this.PERM_OP(right, left, 4, 0x0f0f0f0f, results);
right = results[0]; left = results[1];
var out = new Array(2);
out[0] = left; out[1] = right;
return(out);
}
this.crypt = function(salt, original) {
while(salt.length < 2)
salt += "A";
var buffer;
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);
buffer = charZero + charOne + " ";
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);
for(var i = 0; i < key.length && i < original.length; i ++)
{
var iChar = original.charCodeAt(i);
key[i] = iChar << 1;
}
var schedule = this.des_set_key(key);
var out = this.body(schedule, Eswap0, Eswap1);
var b = new Array(9);
this.intToFourBytes(out[0], b, 0);
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 ++)
{
c <<= 1;
if((b[y] & u) != 0)
c |= 1;
u >>>= 1;
if(u == 0)
{
y++;
u = 0x80;
}
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)
{
this.sts = 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 |
1 << 3 |
1 << 4 |
1 << 5 |
1 << 0 |
1 << 1 |
1 << 25 |
1 << 18 |
1 << 19 |
1 << 20 |
1 << 6 |
1 << 7 |
1 << 8 |
1 << 9 |
1 << 10 |
1 << 11 |
1 << 12 |
1 << 13 |
1 << 14 |
1 << 15,
mAccess_AllOperators : 1 << 6 |
1 << 7 |
1 << 8 |
1 << 9 |
1 << 10 |
1 << 11 |
1 << 12 |
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
};
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
};
function PwrtObjid( vid, oix) {
this.oix = oix;
this.vid = vid;
}
function PwrtAttrRef() {
this.objid;
this.offset;
this.body;
this.size;
this.flags;
}
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;};
}
var CdhC = {
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 **/
function Sub() {
this.sts;
this.refid;
this.type;
this.elements;
this.name;
this.value;
}
function ObjectInfo() {
this.objid;
this.cid;
this.has_children;
this.name;
this.description;
this.classname;
this.full_name;
this.param1;
}
function AttributeInfo() {
this.name;
this.type;
this.size;
this.flags;
this.element;
this.objid;
this.full_name;
this.classname;
}
function MenuButton() {
this.type;
this.text;
this.name;
this.url;
}
function OpwindMenuInfo() {
this.title;
this.text;
this.enable_language;
this.enable_login;
this.enable_alarmlist;
this.enable_eventlog;
this.enable_navigator;
this.disable_help;
this.disable_proview;
this.language;
this.buttons = [];
}
function CrrInfo() {
this.type;
this.objid;
this.name;
this.classname;
}
function GlowPieInfo() {
this.sector_num;
this.min_val;
this.max_val;
}
function GlowBarChartInfo() {
this.bars;
this.barsegments;
this.min_value;
this.max_value;
}
function GlowTableInfo() {
this.columns;
this.rows;
this.column_size = new Array(Glow.TABLE_MAX_COL);
}
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
};
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
};
this.debug = false;
this.pending = [];
this.sub = [];
this.PORT = 4448;
this.ws = null;
this.open_cb = null;
this.close_cb = null;
this.return_cb = null;
this.next_id = 1234;
this.subscriptionCount = 1;
this.listSend = false;
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.binaryType = "arraybuffer";
this.ws.gdh = this;
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.gdh.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) {
var dv = new DataView(e.data);
var type = dv.getUint8(0);
var id = dv.getUint32(1);
var sts = dv.getUint32(5);
switch( type) {
case Msg.GET_OBJECT_INFO_BOOLEAN: {
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);
delete this.gdh.pending[id];
break;
}
case Msg.GET_OBJECT_INFO_INT: {
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);
delete this.gdh.pending[id];
break;
}
case Msg.GET_OBJECT_INFO_FLOAT: {
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);
delete this.gdh.pending[id];
break;
}
case Msg.GET_OBJECT_INFO_FLOAT_ARRAY: {
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++) {
value[i] = dv.getFloat32(k);
k += 4;
}
var 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);
var 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: {
var j = 9;
var size = dv.getUint32(j);
if ( this.gdh.debug) console.log("GetObjectRefInfoAll received", id, size);
j += 4;
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')
j += esize;
else {
var value;
switch ( sub.type) {
case Pwr.eType_Boolean:
if ( sub.elements <= 1) {
value = dv.getUint8(j);
j += 1;
}
else {
var elements = esize;
if ( elements != sub.elements)
console.log("Subscription size error", elements, sub.elements, eid);
value = new Array(elements);
for ( var k = 0; k < elements; k++) {
value[k] = dv.getUint8(j);
j += 1;
}
}
break;
case Pwr.eType_Float32:
if ( sub.elements <= 1) {
value = dv.getFloat32(j);
j += 4;
}
else {
var elements = esize / 4;
if ( elements != sub.elements)
console.log("Subscription size error", elements, sub.elements, eid);
value = new Array(elements);
for ( var k = 0; k < elements; k++) {
value[k] = dv.getFloat32(j);
j += 4;
}
}
break;
case Pwr.eType_Int8:
case Pwr.eType_Int16:
case Pwr.eType_Int32:
case Pwr.eType_UInt8:
case Pwr.eType_UInt16:
case Pwr.eType_UInt32:
case Pwr.eType_Status:
case Pwr.eType_NetStatus:
case Pwr.eType_Mask:
case Pwr.eType_Enum:
case GraphIfc.eType_Bit:
if ( sub.elements <= 1) {
value = dv.getInt32(j);
j += 4;
}
else {
var elements = esize / 4;
if ( elements != sub.elements)
console.log("Subscription size error", elements, sub.elements, eid);
value = new Array(elements);
for ( var k = 0; k < elements; k++) {
value[k] = dv.getInt32(j);
j += 4;
}
}
break;
case Pwr.eType_String:
case Pwr.eType_Time:
case Pwr.eType_DeltaTime:
case Pwr.eType_AttrRef:
case Pwr.eType_Objid:
if ( sub.elements <= 1) {
var nsize = dv.getInt16(j);
j += 2;
var iarr = new Uint8Array( nsize);
for ( var k = 0; k < nsize; k++) {
iarr[k] = dv.getUint8(j++);
}
value = String.fromCharCode.apply( null, iarr);
}
else {
var 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++) {
var nsize = dv.getInt16(j);
j += 2;
var iarr = new Uint8Array( nsize);
for ( var k = 0; k < nsize; k++) {
iarr[k] = dv.getUint8(j++);
}
value[l] = String.fromCharCode.apply( null, iarr);
}
}
break;
default: break;
}
this.gdh.sub[eid].value = value;
}
}
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);
delete this.gdh.pending[id];
break;
}
case Msg.GET_ALL_XTT_CHILDREN: {
var result = [];
var j = 9;
var size = dv.getUint32(j);
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++) {
var info = new ObjectInfo();
info.objid = new PwrtObjid();
info.objid.vid = dv.getUint32(j);
j += 4;
info.objid.oix = dv.getUint32(j);
j += 4;
info.cid = dv.getUint32(j);
j += 4;
info.has_children = dv.getUint16(j) !== 0;
j += 2;
var nsize = dv.getUint16(j);
j += 2;
var iarr = new Uint8Array( nsize);
for ( var k = 0; k < nsize; k++) {
iarr[k] = dv.getUint8(j++);
}
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[k] = dv.getUint8(j++);
}
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[k] = dv.getUint8(j++);
}
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);
delete this.gdh.pending[id];
break;
}
case Msg.GET_ALL_CLASS_ATTRIBUTES: {
var result = [];
var j = 9;
var size = dv.getUint32(j);
if ( this.gdh.debug) console.log("GetAllClassAttributes received", id, size);
j += 4;
for ( var i = 0; i < size; i++) {
var info = new AttributeInfo();
info.type = dv.getUint32(j);
j += 4;
info.flags = dv.getUint32(j);
j += 4;
info.size = dv.getUint16(j);
j += 2;
info.elements = dv.getUint16(j);
j += 2;
var nsize = dv.getUint16(j);
j += 2;
var iarr = new Uint8Array( nsize);
for ( var k = 0; k < nsize; k++) {
iarr[k] = dv.getUint8(j++);
}
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[k] = dv.getUint8(j++);
}
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);
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);
var info = null;
if ( (sts & 1) !== 0) {
var j = 9;
info = new ObjectInfo();
info.objid = new PwrtObjid();
info.objid.vid = dv.getUint32(j);
j += 4;
info.objid.oix = dv.getUint32(j);
j += 4;
info.cid = dv.getUint32(j);
j += 4;
info.has_children = dv.getUint16(j) !== 0;
j += 2;
var nsize = dv.getUint16(j);
j += 2;
var iarr = new Uint8Array( nsize);
for ( var k = 0; k < nsize; k++) {
iarr[k] = dv.getUint8(j++);
}
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[k] = dv.getUint8(j++);
}
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[k] = dv.getUint8(j++);
}
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[k] = dv.getUint8(j++);
}
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[k] = dv.getUint8(j++);
}
info.param1 = String.fromCharCode.apply( null, iarr);
}
var pending_data = this.gdh.pending[id];
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) {
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++) {
var info = new CrrInfo();
info.type = dv.getUint16(j);
j += 2;
info.objid = new PwrtObjid();
info.objid.vid = dv.getUint32(j);
j += 4;
info.objid.oix = dv.getUint32(j);
j += 4;
var nsize = dv.getUint16(j);
j += 2;
var iarr = new Uint8Array( nsize);
for ( var k = 0; k < nsize; k++) {
iarr[k] = dv.getUint8(j++);
}
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[k] = dv.getUint8(j++);
}
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);
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);
console.log("GetOpwindMenu received", sts, id);
if ( sts & 1) {
var nsize = dv.getUint16(j);
j += 2;
var iarr = new Uint8Array( nsize);
for ( var k = 0; k < nsize; k++) {
iarr[k] = dv.getUint8(j++);
}
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[k] = dv.getUint8(j++);
}
result.text = String.fromCharCode.apply( null, iarr);
result.enable_language = dv.getUint32(j);
j += 4;
result.enable_login = dv.getUint32(j);
j += 4;
result.enable_alarmlist = dv.getUint32(j);
j += 4;
result.enable_eventlog = dv.getUint32(j);
j += 4;
result.enable_navigator = dv.getUint32(j);
j += 4;
result.disable_help = dv.getUint32(j);
j += 4;
result.disable_proview = dv.getUint32(j);
j += 4;
result.language = dv.getUint32(j);
j += 4;
var bsize = dv.getUint16(j);
j += 2;
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[k] = dv.getUint8(j++);
}
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[k] = dv.getUint8(j++);
}
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[k] = dv.getUint8(j++);
}
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);
delete this.gdh.pending[id];
break;
}
case Msg.CHECK_USER: {
var j = 9;
if ( this.gdh.debug) console.log("Check user received", id, size);
console.log("Check user received", sts, id);
var priv = 0;
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);
delete this.gdh.pending[id];
break;
}
case Msg.GET_MSG: {
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++) {
iarr[k] = dv.getUint8(j++);
}
var msg = String.fromCharCode.apply( null, iarr);
}
var pending_data = this.gdh.pending[id];
pending_data.func_cb( id, pending_data.data, sts, msg);
delete this.gdh.pending[id];
break;
}
case Msg.MH_SYNC: {
var result = [];
var j = 9;
var size = dv.getUint32(j);
if ( this.gdh.debug) console.log("MhSync received", id, size);
j += 4;
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++) {
iarr[k] = dv.getUint8(j++);
}
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[k] = dv.getUint8(j++);
}
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[k] = dv.getUint8(j++);
}
e.eventName = String.fromCharCode.apply( null, iarr);
e.eventFlags = dv.getUint32(j);
j += 4;
e.eventStatus = dv.getUint32(j);
j += 4;
e.eventPrio = dv.getUint32(j);
j += 4;
e.eventId = new MhEventId();
e.eventId.nix = dv.getUint32(j);
j += 4;
e.eventId.idx = dv.getUint32(j);
j += 4;
len = dv.getUint16(j);
j += 2;
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.targetId = new MhEventId();
e.targetId.nix = dv.getUint32(j);
j += 4;
e.targetId.idx = dv.getUint32(j);
j += 4;
len = dv.getUint16(j);
j += 2;
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.eventType = dv.getUint32(j);
j += 4;
var objid = new PwrtObjid(0,0);
objid.vid = dv.getUint32(j);
j += 4;
objid.oix = dv.getUint32(j);
j += 4;
e.object = new PwrtAttrRef();
e.object.objid = objid;
e.object.offset = dv.getUint32(j);
j += 4;
e.object.body = dv.getUint32(j);
j += 4;
e.object.size = dv.getUint32(j);
j += 4;
e.object.flags = dv.getUint32(j);
j += 4;
var supObjid = new PwrtObjid(0,0);
supObjid.vid = dv.getUint32(j);
j += 4;
supObjid.oix = dv.getUint32(j);
j += 4;
e.supObject = new PwrtAttrRef();
e.supObject.objid = supObjid;
e.supObject.offset = dv.getUint32(j);
j += 4;
e.supObject.body = dv.getUint32(j);
j += 4;
e.supObject.size = dv.getUint32(j);
j += 4;
e.supObject.flags = dv.getUint32(j);
j += 4;
len = dv.getUint16(j);
j += 2;
iarr = new Uint8Array( len);
for ( var k = 0; k < len; k++) {
iarr[k] = dv.getUint8(j++);
}
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);
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);
delete this.gdh.pending[id];
break;
}
default:
console.log("Unknown message type");
}
}
}
};
};
this.getObjectInfoBoolean = function( name, return_cb) {
this.return_cb = return_cb;
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);
}
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.return_cb = return_cb;
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);
}
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.return_cb = return_cb;
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);
}
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.return_cb = return_cb;
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;
buf[4] = (this.next_id >> 16) & 0xFF;
buf[5] = (this.next_id >> 24) & 0xFF;
buf[6] = asize & 0xFF;
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);
}
this.pending[this.next_id] = new PendingData( return_cb, data);
this.ws.send(buf);
this.next_id++;
};
this.refObjectInfo = function( name, type, elements) {
var sub = new Sub();
sub.name = name;
sub.refid = this.subscriptionCount;
sub.type = type;
sub.elements = elements;
this.sub[this.subscriptionCount] = sub;
this.subscriptionCount++;
if ( !this.listSent) {
return sub.refid;
}
else {
var size = 0;
var len = 0;
size = 12 + sub.name.length;
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);
var k = 6;
buf[k++] = sub.refid & 0xFF;
buf[k++] = (sub.refid >> 8) & 0xFF;
buf[k++] = (sub.refid >> 16) & 0xFF;
buf[k++] = (sub.refid >> 24) & 0xFF;
buf[k++] = sub.elements & 0xFF;
buf[k++] = (sub.elements >> 8) & 0xFF;
buf[k++] = (sub.elements >> 16) & 0xFF;
buf[k++] = (sub.elements >> 24) & 0xFF;
buf[k++] = sub.name.length & 0xFF;
buf[k++] = (sub.name.length >> 8) & 0xFF;
buf[k++] = (sub.name.length >> 16) & 0xFF;
buf[k++] = (sub.name.length >> 24) & 0xFF;
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.ws.send(buf);
this.next_id++;
return sub.refid;
}
};
this.refObjectInfoReply = function( id, sts) {
if ( this.debug) console.log( "refObjectInfoReply", id, sts);
};
this.unrefObjectInfo = function( refid) {
var size = 0;
var len = 0;
size = 4;
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);
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.ws.send(buf);
this.next_id++;
delete this.sub[refid];
};
this.refObjectInfoList = function( return_cb) {
var size = 0;
var len = 0;
this.return_cb = return_cb;
for( var i in this.sub) {
size += 12 + this.sub[i].name.length;
len++;
}
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;
buf[4] = (this.next_id >> 16) & 0xFF;
buf[5] = (this.next_id >> 24) & 0xFF;
buf[6] = len & 0xFF;
buf[7] = (len >> 8) & 0xFF;
buf[8] = (len >> 16) & 0xFF;
buf[9] = (len >> 24) & 0xFF;
var k = 10;
for ( var i in this.sub) {
if ( i === 0)
continue;
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;
buf[k++] = (this.sub[i].refid >> 24) & 0xFF;
buf[k++] = this.sub[i].elements & 0xFF;
buf[k++] = (this.sub[i].elements >> 8) & 0xFF;
buf[k++] = (this.sub[i].elements >> 16) & 0xFF;
buf[k++] = (this.sub[i].elements >> 24) & 0xFF;
buf[k++] = this.sub[i].name.length & 0xFF;
buf[k++] = (this.sub[i].name.length >> 8) & 0xFF;
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++) {
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.ws.send(buf);
this.next_id++;
this.listSent = true;
};
this.refObjectInfoListReply = function( id, sts) {
if ( this.debug) console.log( "refObjectInfoListReply", id, sts);
};
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.ws.send(buf);
this.next_id++;
};
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);
return this.sub[id].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;
buf[3] = (this.next_id >> 8) & 0xFF;
buf[4] = (this.next_id >> 16) & 0xFF;
buf[5] = (this.next_id >> 24) & 0xFF;
buf[6] = value & 0xFF;
buf[7] = (value >> 8) & 0xFF;
buf[8] = (value >> 16) & 0xFF;
buf[9] = (value >> 24) & 0xFF;
buf[10] = name.length & 0xFF;
buf[11] = (name.length >> 8) & 0xFF;
var k = 12;
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);
this.next_id++;
return new PwrtStatus( 1);
};
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;
buf[3] = (this.next_id >> 8) & 0xFF;
buf[4] = (this.next_id >> 16) & 0xFF;
buf[5] = (this.next_id >> 24) & 0xFF;
buf[6] = value & 0xFF;
buf[7] = (value >> 8) & 0xFF;
buf[8] = (value >> 16) & 0xFF;
buf[9] = (value >> 24) & 0xFF;
buf[10] = name.length & 0xFF;
buf[11] = (name.length >> 8) & 0xFF;
var k = 12;
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);
this.next_id++;
return new PwrtStatus( 1);
};
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;
buf[3] = (this.next_id >> 8) & 0xFF;
buf[4] = (this.next_id >> 16) & 0xFF;
buf[5] = (this.next_id >> 24) & 0xFF;
var fbuf = new ArrayBuffer(4);
var fa = new Float32Array(fbuf);
fa[0] = value;
var ba = new Uint8Array(fbuf);
buf[6] = ba[0];
buf[7] = ba[1];
buf[8] = ba[2];
buf[9] = ba[3];
buf[10] = name.length & 0xFF;
buf[11] = (name.length >> 8) & 0xFF;
var k = 12;
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);
this.next_id++;
return new PwrtStatus( 1);
};
this.setObjectInfoString = function( name, value) {
var i;
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;
buf[4] = (this.next_id >> 16) & 0xFF;
buf[5] = (this.next_id >> 24) & 0xFF;
buf[6] = value.length & 0xFF;
buf[7] = (value.length >> 8) & 0xFF;
var k = 8;
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++) {
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);
this.next_id++;
return new PwrtStatus( 1);
};
this.toggleObjectInfo = function( name) {
var buf = new Uint8Array(8 + name.length);
buf[0] = Msg.TOGGLE_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;
buf[6] = name.length & 0xFF;
buf[7] = (name.length >> 8) & 0xFF;
var k = 8;
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);
this.next_id++;
return new PwrtStatus( 1);
};
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;
buf[3] = (this.next_id >> 8) & 0xFF;
buf[4] = (this.next_id >> 16) & 0xFF;
buf[5] = (this.next_id >> 24) & 0xFF;
buf[6] = oid.vid & 0xFF;
buf[7] = (oid.vid >> 8) & 0xFF;
buf[8] = (oid.vid >> 16) & 0xFF;
buf[9] = (oid.vid >> 24) & 0xFF;
buf[10] = oid.oix & 0xFF;
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.ws.send(buf);
this.next_id++;
};
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;
buf[3] = (this.next_id >> 8) & 0xFF;
buf[4] = (this.next_id >> 16) & 0xFF;
buf[5] = (this.next_id >> 24) & 0xFF;
buf[6] = cid & 0xFF;
buf[7] = (cid >> 8) & 0xFF;
buf[8] = (cid >> 16) & 0xFF;
buf[9] = (cid >> 24) & 0xFF;
buf[10] = oid.vid & 0xFF;
buf[11] = (oid.vid >> 8) & 0xFF;
buf[12] = (oid.vid >> 16) & 0xFF;
buf[13] = (oid.vid >> 24) & 0xFF;
buf[14] = oid.oix & 0xFF;
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.ws.send(buf);
this.next_id++;
};
this.getObject = function( oid, op, return_cb, data) {
var buf = new Uint8Array(16);
buf[0] = Msg.GET_OBJECT;
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;
buf[6] = op & 0xFF;
buf[7] = (op >> 8) & 0xFF;
buf[8] = oid.vid & 0xFF;
buf[9] = (oid.vid >> 8) & 0xFF;
buf[10] = (oid.vid >> 16) & 0xFF;
buf[11] = (oid.vid >> 24) & 0xFF;
buf[12] = oid.oix & 0xFF;
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.ws.send(buf);
this.next_id++;
};
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;
buf[3] = (this.next_id >> 8) & 0xFF;
buf[4] = (this.next_id >> 16) & 0xFF;
buf[5] = (this.next_id >> 24) & 0xFF;
buf[6] = op & 0xFF;
buf[7] = (op >> 8) & 0xFF;
buf[8] = aref.objid.vid & 0xFF;
buf[9] = (aref.objid.vid >> 8) & 0xFF;
buf[10] = (aref.objid.vid >> 16) & 0xFF;
buf[11] = (aref.objid.vid >> 24) & 0xFF;
buf[12] = aref.objid.oix & 0xFF;
buf[13] = (aref.objid.oix >> 8) & 0xFF;
buf[14] = (aref.objid.oix >> 16) & 0xFF;
buf[15] = (aref.objid.oix >> 24) & 0xFF;
buf[16] = aref.offset & 0xFF;
buf[17] = (aref.offset >> 8) & 0xFF;
buf[18] = (aref.offset >> 16) & 0xFF;
buf[19] = (aref.offset >> 24) & 0xFF;
buf[20] = aref.body & 0xFF;
buf[21] = (aref.body >> 8) & 0xFF;
buf[22] = (aref.body >> 16) & 0xFF;
buf[23] = (aref.body >> 24) & 0xFF;
buf[24] = aref.size & 0xFF;
buf[25] = (aref.size >> 8) & 0xFF;
buf[26] = (aref.size >> 16) & 0xFF;
buf[27] = (aref.size >> 24) & 0xFF;
buf[28] = aref.flags & 0xFF;
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.ws.send(buf);
this.next_id++;
};
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;
buf[3] = (this.next_id >> 8) & 0xFF;
buf[4] = (this.next_id >> 16) & 0xFF;
buf[5] = (this.next_id >> 24) & 0xFF;
buf[6] = op & 0xFF;
buf[7] = (op >> 8) & 0xFF;
buf[8] = name.length & 0xFF;
buf[9] = (name.length >> 8) & 0xFF;
var k = 10;
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.ws.send(buf);
this.next_id++;
};
this.crrSignal = function( oid, return_cb, data) {
var buf = new Uint8Array(14);
buf[0] = Msg.CRR_SIGNAL;
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;
buf[6] = oid.vid & 0xFF;
buf[7] = (oid.vid >> 8) & 0xFF;
buf[8] = (oid.vid >> 16) & 0xFF;
buf[9] = (oid.vid >> 24) & 0xFF;
buf[10] = oid.oix & 0xFF;
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.ws.send(buf);
this.next_id++;
};
this.getOpwindMenu = function( name, return_cb, data) {
var len = name.length;
var buf = new Uint8Array(8 + name.length);
buf[0] = Msg.GET_OPWIND_MENU;
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;
buf[6] = name.length & 0xFF;
buf[7] = (name.length >> 8) & 0xFF;
var k = 8;
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.ws.send(buf);
this.next_id++;
};
this.login = function( user, passwd, return_cb, data) {
var buf = new Uint8Array(6 + 2 + user.length + 2 + passwd.length);
buf[0] = Msg.CHECK_USER;
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;
var k = 6;
buf[k] = user.length & 0xFF;
buf[k+1] = (user.length >> 8) & 0xFF;
k += 2;
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;
k += 2;
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.ws.send(buf);
this.next_id++;
};
this.getMsg = function( value, return_cb, data) {
var buf = new Uint8Array(10);
buf[0] = Msg.GET_MSG;
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;
buf[6] = value & 0xFF;
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.ws.send(buf);
if ( this.debug) console.log("Sending getMsg", this.next_id, value);
this.next_id++;
};
this.mhSync = function( sync, return_cb, data) {
var buf = new Uint8Array(10);
buf[0] = Msg.MH_SYNC;
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;
buf[6] = sync & 0xFF;
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.ws.send(buf);
this.next_id++;
};
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;
buf[3] = (this.next_id >> 8) & 0xFF;
buf[4] = (this.next_id >> 16) & 0xFF;
buf[5] = (this.next_id >> 24) & 0xFF;
buf[6] = event_id.nix & 0xFF;
buf[7] = (event_id.nix >> 8) & 0xFF;
buf[8] = (event_id.nix >> 16) & 0xFF;
buf[9] = (event_id.nix >> 24) & 0xFF;
buf[10] = event_id.idx & 0xFF;
buf[11] = (event_id.idx >> 8) & 0xFF;
buf[12] = (event_id.idx >> 16) & 0xFF;
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;
k += 2;
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.ws.send(buf);
this.next_id++;
};
}
/** End Gdh **/
/** Start OpWind **/ /** Start OpWind **/
...@@ -2457,11 +208,29 @@ function OpWindMenu() { ...@@ -2457,11 +208,29 @@ function OpWindMenu() {
for ( var i = 0; i < self.info.buttons.length; i++) { for ( var i = 0; i < self.info.buttons.length; i++) {
if ( self.info.buttons[i].text == text) { if ( self.info.buttons[i].text == text) {
console.log("Found", self.info.buttons[i].text); console.log("Found", self.info.buttons[i].text);
var name = self.info.buttons[i].name; if (self.info.buttons[i].name != "") {
var n = name.indexOf(".pwg"); var name = self.info.buttons[i].name;
if ( n != -1) var n = name.indexOf(".pwg");
name = name.substring(0,n); if ( n != -1)
var url = "ge.html?graph=" + name; name = name.substring(0,n);
var url = "ge.html?graph=" + name;
}
else {
var url = self.info.buttons[i].url;
if (url.charAt(0) == '$') {
var idx = url.indexOf("/");
if (idx == -1)
idx = url.length;
var sym = url.substring(1, idx);
for (var j = 0; j < 10; j++) {
var symbols = self.info.url_symbols[j].split(" ");
if (sym == symbols[0]) {
url = symbols[1] + url.substring(idx);
break;
}
}
}
}
console.log("url", url); console.log("url", url);
window.open( url, "_blank"); window.open( url, "_blank");
break; break;
......
"use strict"; "use strict";
/** Start Pwr **/ #jsc_include pwr.jsi
#jsc_include cli.jsi
#jsc_include gdh.jsi
#jsc_include plow.jsi
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;};
}
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 |
1 << 3 |
1 << 4 |
1 << 5 |
1 << 0 |
1 << 1 |
1 << 25 |
1 << 18 |
1 << 19 |
1 << 20 |
1 << 6 |
1 << 7 |
1 << 8 |
1 << 9 |
1 << 10 |
1 << 11 |
1 << 12 |
1 << 13 |
1 << 14 |
1 << 15,
mAccess_AllOperators : 1 << 6 |
1 << 7 |
1 << 8 |
1 << 9 |
1 << 10 |
1 << 11 |
1 << 12 |
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
};
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
};
function PwrtObjid( vid, oix) {
this.oix = oix;
this.vid = vid;
}
function PwrtAttrRef() {
this.objid;
this.offset;
this.body;
this.size;
this.flags;
}
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;};
}
var CdhC = {
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 Cli **/
function CliTable( command, qualifier) {
this.command = command;
this.qualifier = qualifier;
}
var CliC = {
SUCCESS : 1,
SYNTAX_ERROR : 2,
UNKNOWN_COMMAND : 4,
QUALNOTFOUND : 6,
VERB_VECT_SIZE : 5,
STATE_INIT : 0,
STATE_VERB : 1,
STATE_QUAL : 2,
STATE_QUALVALUE : 3,
STATE_SPACE : 4,
STATE_EQUAL : 5,
STATE_ERROR : 6,
STATE_QUOTE_VERB : 7,
STATE_QUOTE_QUALVALUE : 8,
STATE_QUALVALUE_EXACT : 9,
STATE_VERB_EXACT : 10,
TAB : ' ',
SPACE : ' '
};
function Cli( cliTable) {
this.verb = new Array(CliC.VERB_VECT_SIZE);
this.verbCount = 0;
this.qualifier = new Array(30);
this.qualValue = new Array(30);
this.qualifierCount = 0;
this.status;
this.cliTableIndex;
this.cliQualifierIndex = new Array(30);
this.configuredVerbs;
this.cliTable = cliTable;
/**
* Return the status of the last operation as a string.
* @return The status of the last operation.
*/
this.getStsString = function() {
switch ( this.status) {
case CliC.SUCCESS: return "Success";
case CliC.SYNTAX_ERROR: return "Syntax error";
case CliC.UNKNOWN_COMMAND: return "Unknown command verb";
case CliC.QUALNOTFOUND: return "Unknown qualifier";
default: return "Unknown command interpreter error";
}
};
/**
* Check if status of last operation is even. An error or warning
* will result in an even status.
* @return Returns true if status of last operation is even.
*/
this.evenSts = function() {
return (this.status % 2 === 0);
};
/**
* Check if status of last operation is odd. A success or information
* will result in an odd status.
* @return Returns true if status of last operation is odd.
*/
this.oddSts = function() {
return (this.status % 2 !== 0);
};
/**
* Parse a command line and detect verbs and qualifiers.
* @param cmd Command line.
*/
this.parse = function( cmd) {
// Parse command string
var state = CliC.STATE_INIT;
var start_pos = 0;
this.status = CliC.SUCCESS;
this.verbCount = 0;
this.qualifierCount = 0;
var i;
for ( i = 0; i < cmd.length; i++) {
var c = cmd.charAt(i);
switch ( state) {
case CliC.STATE_INIT:
if ( c == CliC.SPACE || c == CliC.TAB)
break;
else {
state = CliC.STATE_VERB;
start_pos = i;
}
break;
case CliC.STATE_SPACE:
if ( c == CliC.SPACE || c == CliC.TAB)
break;
if ( c == '/') {
state = CliC.STATE_QUAL;
start_pos = i;
}
else if ( c == '=') {
if ( this.qualifierCount === 0) {
state = CliC.STATE_ERROR;
this.status = CliC.SYNTAX_ERROR;
break;
}
state = CliC.STATE_EQUAL;
}
else if ( c == '"') {
state = CliC.STATE_QUOTE_VERB;
break;
}
else {
state = CliC.STATE_VERB;
start_pos = i;
}
break;
case CliC.STATE_VERB:
if ( c == CliC.SPACE || c == CliC.TAB) {
if ( this.verbCount == CliC.VERB_VECT_SIZE) {
state = CliC.STATE_ERROR;
break;
}
if ( this.verbCount === 0)
this.verb[this.verbCount++] = cmd.substring( start_pos, i).toUpperCase();
else
this.verb[this.verbCount++] = cmd.substring( start_pos, i);
state = CliC.STATE_SPACE;
}
else if ( c == '/') {
if ( this.verbCount == CliC.VERB_VECT_SIZE) {
state = CliC.STATE_ERROR;
break;
}
this.verb[this.verbCount++] = cmd.substring( start_pos, i).toUpperCase();
state = CliC.STATE_QUAL;
start_pos = i;
}
break;
case CliC.STATE_VERB_EXACT:
if ( c == '"') {
if ( this.verbCount == CliC.VERB_VECT_SIZE) {
state = CliC.STATE_ERROR;
break;
}
this.verb[this.verbCount++] = cmd.substring( start_pos, i);
state = CliC.STATE_SPACE;
}
break;
case CliC.STATE_QUAL:
if ( c == CliC.SPACE || c == CliC.TAB) {
this.qualifier[this.qualifierCount++] = cmd.substring( start_pos, i).toUpperCase();
state = CliC.STATE_SPACE;
}
else if ( c == '=') {
this.qualifier[this.qualifierCount++] = cmd.substring( start_pos, i).toUpperCase();
state = CliC.STATE_EQUAL;
}
else if ( c == '/') {
this.qualifier[this.qualifierCount++] = cmd.substring( start_pos, i).toUpperCase();
state = CliC.STATE_QUAL;
start_pos = i;
}
break;
case CliC.STATE_QUALVALUE:
if ( c == CliC.SPACE || c == CliC.TAB) {
this.qualValue[this.qualifierCount-1] = cmd.substring( start_pos, i);
state = CliC.STATE_SPACE;
}
else if ( c == '/') {
this.qualValue[this.qualifierCount-1] = cmd.substring( start_pos, i);
state = CliC.STATE_QUAL;
start_pos = i;
}
break;
case CliC.STATE_QUALVALUE_EXACT:
if ( c == '"') {
this.qualValue[this.qualifierCount-1] = cmd.substring( start_pos, i);
state = CliC.STATE_SPACE;
}
break;
case CliC.STATE_QUOTE_VERB:
state = CliC.STATE_VERB_EXACT;
start_pos = i;
break;
case CliC.STATE_QUOTE_QUALVALUE:
state = CliC.STATE_QUALVALUE_EXACT;
start_pos = i;
break;
case CliC.STATE_EQUAL:
if ( c == CliC.SPACE || c == CliC.TAB)
break;
if ( c == '"') {
state = CliC.STATE_QUOTE_QUALVALUE;
}
else {
state = CliC.STATE_QUALVALUE;
start_pos = i;
}
break;
}
if ( state == CliC.STATE_ERROR)
break;
}
switch ( state) {
case CliC.STATE_INIT:
case CliC.STATE_ERROR:
return "";
case CliC.STATE_VERB:
if ( this.verbCount == CliC.VERB_VECT_SIZE) {
state = CliC.STATE_ERROR;
break;
}
if ( this.verbCount === 0)
this.verb[this.verbCount++] = cmd.substring( start_pos, i).toUpperCase();
else
this.verb[this.verbCount++] = cmd.substring( start_pos, i);
break;
case CliC.STATE_VERB_EXACT:
if ( this.verbCount == CliC.VERB_VECT_SIZE) {
state = CliC.STATE_ERROR;
break;
}
this.verb[this.verbCount++] = cmd.substring( start_pos, i);
break;
case CliC.STATE_QUAL:
this.qualifier[this.qualifierCount++] = cmd.substring( start_pos, i).toUpperCase();
break;
case CliC.STATE_QUALVALUE:
this.qualValue[this.qualifierCount-1] = cmd.substring( start_pos, i);
break;
case CliC.STATE_QUALVALUE_EXACT:
this.qualValue[this.qualifierCount-1] = cmd.substring( start_pos, i);
break;
case CliC.STATE_QUOTE_VERB:
case CliC.STATE_QUOTE_QUALVALUE:
case CliC.STATE_EQUAL:
this.status = CliC.SYNTAX_ERROR;
return "";
}
if ( this.verbCount === 0) {
this.status = CliC.SYNTAX_ERROR;
return "";
}
// for ( i = 0; i < this.verbCount; i++)
// console.log("verb: \"" + this.verb[i] + "\"");
// for ( i = 0; i < this.qualifierCount; i++)
// console.log("qual: \"" + this.qualifier[i] + "\" , \"" + this.qualValue[i] + "\"");
// Identify verbs and qualifiers
var found = false;
for ( i = 0; i < this.cliTable.length; i++) {
if ( this.verb[0].length > this.cliTable[i].command.length)
continue;
if ( this.verb[0] == ( this.cliTable[i].command.substring( 0, this.verb[0].length))) {
this.verb[0] = this.cliTable[i].command;
found = true;
break;
}
}
if ( !found) {
this.status = CliC.UNKNOWN_COMMAND;
return "";
}
this.cliTableIndex = i;
this.configuredVerbs = 0;
if ( this.cliTable[this.cliTableIndex].qualifier !== null)
{
for ( i = 0; i < this.cliTable[this.cliTableIndex].qualifier.length; i++) {
if ( this.cliTable[this.cliTableIndex].qualifier[i] === null)
break;
if ( this.cliTable[this.cliTableIndex].qualifier[i] == ("cli_arg1"))
this.configuredVerbs++;
if ( this.cliTable[this.cliTableIndex].qualifier[i] == ("cli_arg2"))
this.configuredVerbs++;
if ( this.cliTable[this.cliTableIndex].qualifier[i] == ("cli_arg3"))
this.configuredVerbs++;
if ( this.cliTable[this.cliTableIndex].qualifier[i] == ("cli_arg4"))
this.configuredVerbs++;
if ( this.cliTable[this.cliTableIndex].qualifier[i] == ("cli_arg5"))
this.configuredVerbs++;
}
for ( var j = 0; j < this.qualifierCount; j++) {
found = false;
for ( i = 0; i < this.cliTable[this.cliTableIndex].qualifier.length; i++) {
if ( this.cliTable[this.cliTableIndex].qualifier[i] === null)
break;
if ( this.qualifier[j].length > this.cliTable[this.cliTableIndex].qualifier[i].length)
continue;
if ( this.qualifier[j] == ( this.cliTable[this.cliTableIndex].qualifier[i].substring( 0, this.qualifier[j].length))) {
this.cliQualifierIndex[j] = i;
found = true;
this.qualifier[j] = this.cliTable[this.cliTableIndex].qualifier[i];
}
}
if ( !found) {
this.status = CliC.QUALNOTFOUND;
return "";
}
}
}
else if ( this.qualifierCount > 0) {
this.status = CliC.QUALNOTFOUND;
return "";
}
return this.verb[0];
};
/**
* Check if a qualifier was present in the last parse operation.
* @param qual Qualifier to check.
* @return Returns true if the qualifier is present.
*/
this.qualifierFound = function( qual) {
if ( qual == ("cli_arg1")) {
if ( this.verbCount < 2 || this.configuredVerbs < 1)
return false;
return true;
}
if ( qual == ("cli_arg2")) {
if ( this.verbCount < 3 || this.configuredVerbs < 2)
return false;
return true;
}
if ( qual == ("cli_arg3")) {
if ( this.verbCount < 4 || this.configuredVerbs < 3)
return false;
return true;
}
if ( qual == ("cli_arg4")) {
if ( this.verbCount < 5 || this.configuredVerbs < 4)
return false;
return true;
}
for ( var i = 0; i < this.qualifierCount; i++) {
if ( qual == (this.qualifier[i]))
return true;
}
return false;
};
/**
* Get the value of a qualifier in the last parse operation.
* @param qual Qualifier to check.
* @return Returns the value of the qualifier.
*/
this.getQualValue = function( qual) {
if ( qual == ("cli_arg1")) {
if ( this.verbCount < 2 || this.configuredVerbs < 1)
return "";
return this.verb[1];
}
if ( qual == ("cli_arg2")) {
if ( this.verbCount < 3 || this.configuredVerbs < 2)
return "";
return this.verb[2];
}
if ( qual == ("cli_arg3")) {
if ( this.verbCount < 4 || this.configuredVerbs < 3)
return this.verb[3];
}
if ( qual == ("cli_arg4")) {
if ( this.verbCount < 5 || this.configuredVerbs < 4)
return "";
return this.verb[4];
}
for ( var i = 0; i < this.qualifierCount; i++) {
if ( qual == (this.qualifier[i])) {
if ( this.qualValue[i] === null)
return "";
else
return this.qualValue[i];
}
}
return "";
};
}
/** End Cli **/
var GraphIfc = { var GraphIfc = {
eType_Bit : (1 << 15) + 1 eType_Bit : (1 << 15) + 1
}; };
/** Start Gdh **/
function Sub() {
this.sts;
this.refid;
this.type;
this.elements;
this.name;
this.value;
}
function ObjectInfo() {
this.objid;
this.cid;
this.has_children;
this.name;
this.description;
this.classname;
this.full_name;
this.param1;
}
function AttributeInfo() {
this.name;
this.type;
this.size;
this.flags;
this.element;
this.objid;
this.full_name;
this.classname;
}
function MenuButton() {
this.type;
this.text;
this.name;
this.url;
}
function OpwindMenuInfo() {
this.title;
this.text;
this.enable_language;
this.enable_login;
this.enable_alarmlist;
this.enable_eventlog;
this.enable_navigator;
this.disable_help;
this.disable_proview;
this.language;
this.buttons = [];
}
function CrrInfo() {
this.type;
this.objid;
this.name;
this.classname;
}
function GlowPieInfo() {
this.sector_num;
this.min_val;
this.max_val;
}
function GlowBarChartInfo() {
this.bars;
this.barsegments;
this.min_value;
this.max_value;
}
function GlowTableInfo() {
this.columns;
this.rows;
this.column_size = new Array(Glow.TABLE_MAX_COL);
}
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
};
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
};
this.debug = false;
this.pending = [];
this.sub = [];
this.PORT = 4448;
this.ws = null;
this.open_cb = null;
this.close_cb = null;
this.return_cb = null;
this.next_id = 1234;
this.subscriptionCount = 1;
this.listSend = false;
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.binaryType = "arraybuffer";
this.ws.gdh = this;
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.gdh.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) {
var dv = new DataView(e.data);
var type = dv.getUint8(0);
var id = dv.getUint32(1);
var sts = dv.getUint32(5);
switch( type) {
case Msg.GET_OBJECT_INFO_BOOLEAN: {
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);
delete this.gdh.pending[id];
break;
}
case Msg.GET_OBJECT_INFO_INT: {
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);
delete this.gdh.pending[id];
break;
}
case Msg.GET_OBJECT_INFO_FLOAT: {
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);
delete this.gdh.pending[id];
break;
}
case Msg.GET_OBJECT_INFO_FLOAT_ARRAY: {
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++) {
value[i] = dv.getFloat32(k);
k += 4;
}
var 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);
var 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: {
var j = 9;
var size = dv.getUint32(j);
if ( this.gdh.debug) console.log("GetObjectRefInfoAll received", id, size);
j += 4;
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')
j += esize;
else {
var value;
switch ( sub.type) {
case Pwr.eType_Boolean:
if ( sub.elements <= 1) {
value = dv.getUint8(j);
j += 1;
}
else {
var elements = esize;
if ( elements != sub.elements)
console.log("Subscription size error", elements, sub.elements, eid);
value = new Array(elements);
for ( var k = 0; k < elements; k++) {
value[k] = dv.getUint8(j);
j += 1;
}
}
break;
case Pwr.eType_Float32:
if ( sub.elements <= 1) {
value = dv.getFloat32(j);
j += 4;
}
else {
var elements = esize / 4;
if ( elements != sub.elements)
console.log("Subscription size error", elements, sub.elements, eid);
value = new Array(elements);
for ( var k = 0; k < elements; k++) {
value[k] = dv.getFloat32(j);
j += 4;
}
}
break;
case Pwr.eType_Int8:
case Pwr.eType_Int16:
case Pwr.eType_Int32:
case Pwr.eType_UInt8:
case Pwr.eType_UInt16:
case Pwr.eType_UInt32:
case Pwr.eType_Status:
case Pwr.eType_NetStatus:
case Pwr.eType_Mask:
case Pwr.eType_Enum:
case GraphIfc.eType_Bit:
if ( sub.elements <= 1) {
value = dv.getInt32(j);
j += 4;
}
else {
var elements = esize / 4;
if ( elements != sub.elements)
console.log("Subscription size error", elements, sub.elements, eid);
value = new Array(elements);
for ( var k = 0; k < elements; k++) {
value[k] = dv.getInt32(j);
j += 4;
}
}
break;
case Pwr.eType_String:
case Pwr.eType_Time:
case Pwr.eType_DeltaTime:
case Pwr.eType_AttrRef:
case Pwr.eType_Objid:
if ( sub.elements <= 1) {
var nsize = dv.getInt16(j);
j += 2;
var iarr = new Uint8Array( nsize);
for ( var k = 0; k < nsize; k++) {
iarr[k] = dv.getUint8(j++);
}
value = String.fromCharCode.apply( null, iarr);
}
else {
var 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++) {
var nsize = dv.getInt16(j);
j += 2;
var iarr = new Uint8Array( nsize);
for ( var k = 0; k < nsize; k++) {
iarr[k] = dv.getUint8(j++);
}
value[l] = String.fromCharCode.apply( null, iarr);
}
}
break;
default: break;
}
this.gdh.sub[eid].value = value;
}
}
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);
delete this.gdh.pending[id];
break;
}
case Msg.GET_ALL_XTT_CHILDREN: {
var result = [];
var j = 9;
var size = dv.getUint32(j);
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++) {
var info = new ObjectInfo();
info.objid = new PwrtObjid();
info.objid.vid = dv.getUint32(j);
j += 4;
info.objid.oix = dv.getUint32(j);
j += 4;
info.cid = dv.getUint32(j);
j += 4;
info.has_children = dv.getUint16(j) !== 0;
j += 2;
var nsize = dv.getUint16(j);
j += 2;
var iarr = new Uint8Array( nsize);
for ( var k = 0; k < nsize; k++) {
iarr[k] = dv.getUint8(j++);
}
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[k] = dv.getUint8(j++);
}
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[k] = dv.getUint8(j++);
}
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);
delete this.gdh.pending[id];
break;
}
case Msg.GET_ALL_CLASS_ATTRIBUTES: {
var result = [];
var j = 9;
var size = dv.getUint32(j);
if ( this.gdh.debug) console.log("GetAllClassAttributes received", id, size);
j += 4;
for ( var i = 0; i < size; i++) {
var info = new AttributeInfo();
info.type = dv.getUint32(j);
j += 4;
info.flags = dv.getUint32(j);
j += 4;
info.size = dv.getUint16(j);
j += 2;
info.elements = dv.getUint16(j);
j += 2;
var nsize = dv.getUint16(j);
j += 2;
var iarr = new Uint8Array( nsize);
for ( var k = 0; k < nsize; k++) {
iarr[k] = dv.getUint8(j++);
}
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[k] = dv.getUint8(j++);
}
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);
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);
var info = null;
if ( (sts & 1) !== 0) {
var j = 9;
info = new ObjectInfo();
info.objid = new PwrtObjid();
info.objid.vid = dv.getUint32(j);
j += 4;
info.objid.oix = dv.getUint32(j);
j += 4;
info.cid = dv.getUint32(j);
j += 4;
info.has_children = dv.getUint16(j) !== 0;
j += 2;
var nsize = dv.getUint16(j);
j += 2;
var iarr = new Uint8Array( nsize);
for ( var k = 0; k < nsize; k++) {
iarr[k] = dv.getUint8(j++);
}
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[k] = dv.getUint8(j++);
}
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[k] = dv.getUint8(j++);
}
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[k] = dv.getUint8(j++);
}
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[k] = dv.getUint8(j++);
}
info.param1 = String.fromCharCode.apply( null, iarr);
}
var pending_data = this.gdh.pending[id];
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) {
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++) {
var info = new CrrInfo();
info.type = dv.getUint16(j);
j += 2;
info.objid = new PwrtObjid();
info.objid.vid = dv.getUint32(j);
j += 4;
info.objid.oix = dv.getUint32(j);
j += 4;
var nsize = dv.getUint16(j);
j += 2;
var iarr = new Uint8Array( nsize);
for ( var k = 0; k < nsize; k++) {
iarr[k] = dv.getUint8(j++);
}
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[k] = dv.getUint8(j++);
}
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);
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);
console.log("GetOpwindMenu received", sts, id);
if ( sts & 1) {
var nsize = dv.getUint16(j);
j += 2;
var iarr = new Uint8Array( nsize);
for ( var k = 0; k < nsize; k++) {
iarr[k] = dv.getUint8(j++);
}
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[k] = dv.getUint8(j++);
}
result.text = String.fromCharCode.apply( null, iarr);
result.enable_language = dv.getUint32(j);
j += 4;
result.enable_login = dv.getUint32(j);
j += 4;
result.enable_alarmlist = dv.getUint32(j);
j += 4;
result.enable_eventlog = dv.getUint32(j);
j += 4;
result.enable_navigator = dv.getUint32(j);
j += 4;
result.disable_help = dv.getUint32(j);
j += 4;
result.disable_proview = dv.getUint32(j);
j += 4;
result.language = dv.getUint32(j);
j += 4;
var bsize = dv.getUint16(j);
j += 2;
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[k] = dv.getUint8(j++);
}
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[k] = dv.getUint8(j++);
}
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[k] = dv.getUint8(j++);
}
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);
delete this.gdh.pending[id];
break;
}
case Msg.CHECK_USER: {
var j = 9;
if ( this.gdh.debug) console.log("Check user received", id, size);
console.log("Check user received", sts, id);
var priv = 0;
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);
delete this.gdh.pending[id];
break;
}
case Msg.GET_MSG: {
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++) {
iarr[k] = dv.getUint8(j++);
}
var msg = String.fromCharCode.apply( null, iarr);
}
var pending_data = this.gdh.pending[id];
pending_data.func_cb( id, pending_data.data, sts, msg);
delete this.gdh.pending[id];
break;
}
case Msg.MH_SYNC: {
var result = [];
var j = 9;
var size = dv.getUint32(j);
if ( this.gdh.debug) console.log("MhSync received", id, size);
j += 4;
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++) {
iarr[k] = dv.getUint8(j++);
}
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[k] = dv.getUint8(j++);
}
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[k] = dv.getUint8(j++);
}
e.eventName = String.fromCharCode.apply( null, iarr);
e.eventFlags = dv.getUint32(j);
j += 4;
e.eventStatus = dv.getUint32(j);
j += 4;
e.eventPrio = dv.getUint32(j);
j += 4;
e.eventId = new MhEventId();
e.eventId.nix = dv.getUint32(j);
j += 4;
e.eventId.idx = dv.getUint32(j);
j += 4;
len = dv.getUint16(j);
j += 2;
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.targetId = new MhEventId();
e.targetId.nix = dv.getUint32(j);
j += 4;
e.targetId.idx = dv.getUint32(j);
j += 4;
len = dv.getUint16(j);
j += 2;
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.eventType = dv.getUint32(j);
j += 4;
var objid = new PwrtObjid(0,0);
objid.vid = dv.getUint32(j);
j += 4;
objid.oix = dv.getUint32(j);
j += 4;
e.object = new PwrtAttrRef();
e.object.objid = objid;
e.object.offset = dv.getUint32(j);
j += 4;
e.object.body = dv.getUint32(j);
j += 4;
e.object.size = dv.getUint32(j);
j += 4;
e.object.flags = dv.getUint32(j);
j += 4;
var supObjid = new PwrtObjid(0,0);
supObjid.vid = dv.getUint32(j);
j += 4;
supObjid.oix = dv.getUint32(j);
j += 4;
e.supObject = new PwrtAttrRef();
e.supObject.objid = supObjid;
e.supObject.offset = dv.getUint32(j);
j += 4;
e.supObject.body = dv.getUint32(j);
j += 4;
e.supObject.size = dv.getUint32(j);
j += 4;
e.supObject.flags = dv.getUint32(j);
j += 4;
len = dv.getUint16(j);
j += 2;
iarr = new Uint8Array( len);
for ( var k = 0; k < len; k++) {
iarr[k] = dv.getUint8(j++);
}
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);
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);
delete this.gdh.pending[id];
break;
}
default:
console.log("Unknown message type");
}
}
}
};
};
this.getObjectInfoBoolean = function( name, return_cb) {
this.return_cb = return_cb;
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);
}
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.return_cb = return_cb;
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);
}
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.return_cb = return_cb;
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);
}
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.return_cb = return_cb;
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;
buf[4] = (this.next_id >> 16) & 0xFF;
buf[5] = (this.next_id >> 24) & 0xFF;
buf[6] = asize & 0xFF;
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);
}
this.pending[this.next_id] = new PendingData( return_cb, data);
this.ws.send(buf);
this.next_id++;
};
this.refObjectInfo = function( name, type, elements) {
var sub = new Sub();
sub.name = name;
sub.refid = this.subscriptionCount;
sub.type = type;
sub.elements = elements;
this.sub[this.subscriptionCount] = sub;
this.subscriptionCount++;
if ( !this.listSent) {
return sub.refid;
}
else {
var size = 0;
var len = 0;
size = 12 + sub.name.length;
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);
var k = 6;
buf[k++] = sub.refid & 0xFF;
buf[k++] = (sub.refid >> 8) & 0xFF;
buf[k++] = (sub.refid >> 16) & 0xFF;
buf[k++] = (sub.refid >> 24) & 0xFF;
buf[k++] = sub.elements & 0xFF;
buf[k++] = (sub.elements >> 8) & 0xFF;
buf[k++] = (sub.elements >> 16) & 0xFF;
buf[k++] = (sub.elements >> 24) & 0xFF;
buf[k++] = sub.name.length & 0xFF;
buf[k++] = (sub.name.length >> 8) & 0xFF;
buf[k++] = (sub.name.length >> 16) & 0xFF;
buf[k++] = (sub.name.length >> 24) & 0xFF;
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.ws.send(buf);
this.next_id++;
return sub.refid;
}
};
this.refObjectInfoReply = function( id, sts) {
if ( this.debug) console.log( "refObjectInfoReply", id, sts);
};
this.unrefObjectInfo = function( refid) {
var size = 0;
var len = 0;
size = 4;
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);
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.ws.send(buf);
this.next_id++;
delete this.sub[refid];
};
this.refObjectInfoList = function( return_cb) {
var size = 0;
var len = 0;
this.return_cb = return_cb;
for( var i in this.sub) {
size += 12 + this.sub[i].name.length;
len++;
}
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;
buf[4] = (this.next_id >> 16) & 0xFF;
buf[5] = (this.next_id >> 24) & 0xFF;
buf[6] = len & 0xFF;
buf[7] = (len >> 8) & 0xFF;
buf[8] = (len >> 16) & 0xFF;
buf[9] = (len >> 24) & 0xFF;
var k = 10;
for ( var i in this.sub) {
if ( i === 0)
continue;
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;
buf[k++] = (this.sub[i].refid >> 24) & 0xFF;
buf[k++] = this.sub[i].elements & 0xFF;
buf[k++] = (this.sub[i].elements >> 8) & 0xFF;
buf[k++] = (this.sub[i].elements >> 16) & 0xFF;
buf[k++] = (this.sub[i].elements >> 24) & 0xFF;
buf[k++] = this.sub[i].name.length & 0xFF;
buf[k++] = (this.sub[i].name.length >> 8) & 0xFF;
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++) {
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.ws.send(buf);
this.next_id++;
this.listSent = true;
};
this.refObjectInfoListReply = function( id, sts) {
if ( this.debug) console.log( "refObjectInfoListReply", id, sts);
};
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.ws.send(buf);
this.next_id++;
};
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);
return this.sub[id].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;
buf[3] = (this.next_id >> 8) & 0xFF;
buf[4] = (this.next_id >> 16) & 0xFF;
buf[5] = (this.next_id >> 24) & 0xFF;
buf[6] = value & 0xFF;
buf[7] = (value >> 8) & 0xFF;
buf[8] = (value >> 16) & 0xFF;
buf[9] = (value >> 24) & 0xFF;
buf[10] = name.length & 0xFF;
buf[11] = (name.length >> 8) & 0xFF;
var k = 12;
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);
this.next_id++;
return new PwrtStatus( 1);
};
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;
buf[3] = (this.next_id >> 8) & 0xFF;
buf[4] = (this.next_id >> 16) & 0xFF;
buf[5] = (this.next_id >> 24) & 0xFF;
buf[6] = value & 0xFF;
buf[7] = (value >> 8) & 0xFF;
buf[8] = (value >> 16) & 0xFF;
buf[9] = (value >> 24) & 0xFF;
buf[10] = name.length & 0xFF;
buf[11] = (name.length >> 8) & 0xFF;
var k = 12;
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);
this.next_id++;
return new PwrtStatus( 1);
};
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;
buf[3] = (this.next_id >> 8) & 0xFF;
buf[4] = (this.next_id >> 16) & 0xFF;
buf[5] = (this.next_id >> 24) & 0xFF;
var fbuf = new ArrayBuffer(4);
var fa = new Float32Array(fbuf);
fa[0] = value;
var ba = new Uint8Array(fbuf);
buf[6] = ba[0];
buf[7] = ba[1];
buf[8] = ba[2];
buf[9] = ba[3];
buf[10] = name.length & 0xFF;
buf[11] = (name.length >> 8) & 0xFF;
var k = 12;
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);
this.next_id++;
return new PwrtStatus( 1);
};
this.setObjectInfoString = function( name, value) {
var i;
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;
buf[4] = (this.next_id >> 16) & 0xFF;
buf[5] = (this.next_id >> 24) & 0xFF;
buf[6] = value.length & 0xFF;
buf[7] = (value.length >> 8) & 0xFF;
var k = 8;
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++) {
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);
this.next_id++;
return new PwrtStatus( 1);
};
this.toggleObjectInfo = function( name) {
var buf = new Uint8Array(8 + name.length);
buf[0] = Msg.TOGGLE_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;
buf[6] = name.length & 0xFF;
buf[7] = (name.length >> 8) & 0xFF;
var k = 8;
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);
this.next_id++;
return new PwrtStatus( 1);
};
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;
buf[3] = (this.next_id >> 8) & 0xFF;
buf[4] = (this.next_id >> 16) & 0xFF;
buf[5] = (this.next_id >> 24) & 0xFF;
buf[6] = oid.vid & 0xFF;
buf[7] = (oid.vid >> 8) & 0xFF;
buf[8] = (oid.vid >> 16) & 0xFF;
buf[9] = (oid.vid >> 24) & 0xFF;
buf[10] = oid.oix & 0xFF;
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.ws.send(buf);
this.next_id++;
};
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;
buf[3] = (this.next_id >> 8) & 0xFF;
buf[4] = (this.next_id >> 16) & 0xFF;
buf[5] = (this.next_id >> 24) & 0xFF;
buf[6] = cid & 0xFF;
buf[7] = (cid >> 8) & 0xFF;
buf[8] = (cid >> 16) & 0xFF;
buf[9] = (cid >> 24) & 0xFF;
buf[10] = oid.vid & 0xFF;
buf[11] = (oid.vid >> 8) & 0xFF;
buf[12] = (oid.vid >> 16) & 0xFF;
buf[13] = (oid.vid >> 24) & 0xFF;
buf[14] = oid.oix & 0xFF;
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.ws.send(buf);
this.next_id++;
};
this.getObject = function( oid, op, return_cb, data) {
var buf = new Uint8Array(16);
buf[0] = Msg.GET_OBJECT;
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;
buf[6] = op & 0xFF;
buf[7] = (op >> 8) & 0xFF;
buf[8] = oid.vid & 0xFF;
buf[9] = (oid.vid >> 8) & 0xFF;
buf[10] = (oid.vid >> 16) & 0xFF;
buf[11] = (oid.vid >> 24) & 0xFF;
buf[12] = oid.oix & 0xFF;
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.ws.send(buf);
this.next_id++;
};
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;
buf[3] = (this.next_id >> 8) & 0xFF;
buf[4] = (this.next_id >> 16) & 0xFF;
buf[5] = (this.next_id >> 24) & 0xFF;
buf[6] = op & 0xFF;
buf[7] = (op >> 8) & 0xFF;
buf[8] = aref.objid.vid & 0xFF;
buf[9] = (aref.objid.vid >> 8) & 0xFF;
buf[10] = (aref.objid.vid >> 16) & 0xFF;
buf[11] = (aref.objid.vid >> 24) & 0xFF;
buf[12] = aref.objid.oix & 0xFF;
buf[13] = (aref.objid.oix >> 8) & 0xFF;
buf[14] = (aref.objid.oix >> 16) & 0xFF;
buf[15] = (aref.objid.oix >> 24) & 0xFF;
buf[16] = aref.offset & 0xFF;
buf[17] = (aref.offset >> 8) & 0xFF;
buf[18] = (aref.offset >> 16) & 0xFF;
buf[19] = (aref.offset >> 24) & 0xFF;
buf[20] = aref.body & 0xFF;
buf[21] = (aref.body >> 8) & 0xFF;
buf[22] = (aref.body >> 16) & 0xFF;
buf[23] = (aref.body >> 24) & 0xFF;
buf[24] = aref.size & 0xFF;
buf[25] = (aref.size >> 8) & 0xFF;
buf[26] = (aref.size >> 16) & 0xFF;
buf[27] = (aref.size >> 24) & 0xFF;
buf[28] = aref.flags & 0xFF;
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.ws.send(buf);
this.next_id++;
};
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;
buf[3] = (this.next_id >> 8) & 0xFF;
buf[4] = (this.next_id >> 16) & 0xFF;
buf[5] = (this.next_id >> 24) & 0xFF;
buf[6] = op & 0xFF;
buf[7] = (op >> 8) & 0xFF;
buf[8] = name.length & 0xFF;
buf[9] = (name.length >> 8) & 0xFF;
var k = 10;
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.ws.send(buf);
this.next_id++;
};
this.crrSignal = function( oid, return_cb, data) {
var buf = new Uint8Array(14);
buf[0] = Msg.CRR_SIGNAL;
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;
buf[6] = oid.vid & 0xFF;
buf[7] = (oid.vid >> 8) & 0xFF;
buf[8] = (oid.vid >> 16) & 0xFF;
buf[9] = (oid.vid >> 24) & 0xFF;
buf[10] = oid.oix & 0xFF;
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.ws.send(buf);
this.next_id++;
};
this.getOpwindMenu = function( name, return_cb, data) {
var len = name.length;
var buf = new Uint8Array(8 + name.length);
buf[0] = Msg.GET_OPWIND_MENU;
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;
buf[6] = name.length & 0xFF;
buf[7] = (name.length >> 8) & 0xFF;
var k = 8;
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.ws.send(buf);
this.next_id++;
};
this.login = function( user, passwd, return_cb, data) {
var buf = new Uint8Array(6 + 2 + user.length + 2 + passwd.length);
buf[0] = Msg.CHECK_USER;
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;
var k = 6;
buf[k] = user.length & 0xFF;
buf[k+1] = (user.length >> 8) & 0xFF;
k += 2;
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;
k += 2;
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.ws.send(buf);
this.next_id++;
};
this.getMsg = function( value, return_cb, data) {
var buf = new Uint8Array(10);
buf[0] = Msg.GET_MSG;
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;
buf[6] = value & 0xFF;
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.ws.send(buf);
if ( this.debug) console.log("Sending getMsg", this.next_id, value);
this.next_id++;
};
this.mhSync = function( sync, return_cb, data) {
var buf = new Uint8Array(10);
buf[0] = Msg.MH_SYNC;
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;
buf[6] = sync & 0xFF;
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.ws.send(buf);
this.next_id++;
};
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;
buf[3] = (this.next_id >> 8) & 0xFF;
buf[4] = (this.next_id >> 16) & 0xFF;
buf[5] = (this.next_id >> 24) & 0xFF;
buf[6] = event_id.nix & 0xFF;
buf[7] = (event_id.nix >> 8) & 0xFF;
buf[8] = (event_id.nix >> 16) & 0xFF;
buf[9] = (event_id.nix >> 24) & 0xFF;
buf[10] = event_id.idx & 0xFF;
buf[11] = (event_id.idx >> 8) & 0xFF;
buf[12] = (event_id.idx >> 16) & 0xFF;
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;
k += 2;
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.ws.send(buf);
this.next_id++;
};
}
/** End Gdh **/
/** Start Plow **/
var Bitmaps = {
leaf : 0,
map : 2,
openmap : 4,
object : 6,
attrenum : 8,
attrarra : 10,
attrarel : 12,
attr : 14,
crrwrite : 16,
crrread : 18,
ack : 20,
alarm : 22,
eventacked : 24,
eventalarm : 26,
eventreturn : 28,
info : 30,
system : 32,
maintenance : 34,
blockl : 36,
blockr : 38,
img : [ null, null, null, null, null, null, null, null, null, null,
null, null, null, null, null, null, null, null, null, null,
null, null, null, null, null, null, null, null, null, null,
null, null, null, null, null, null, null, null],
pending : [ null, null, null, null, null, null, null, null, null, null,
null, null, null, null, null, null, null, null, null, null,
null, null, null, null, null, null, null, null, null, null,
null, null, null, null, null, null, null, null],
images : [
// leaf
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAMCAYAAABSgIzaAAAASElEQVQokWP4jwMwMDBgYBR5XBpwGYZVIzYNGDZB+QyEFOBiM+CyCacGBI0hgEGjsxkYGCiwkSI/4tKMz0DqxCM2A4hOOcQCAObFEQyI2PpKAAAAAElFTkSuQmCC',
// leaf inverted
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAMCAYAAABSgIzaAAAAQUlEQVQokWNgYGD4jw1jA2hqsGvAZRhWjdg0oIsh8QkqwMXGbhMuDXAxdAFsNDobyifTRor8SFGoUhSPFKUcYjEAMsMz2y6w8kgAAAAASUVORK5CYII=',
// map
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAMCAYAAABSgIzaAAAAKElEQVQokWP4DwUMDAwYGB9gwKUQm0FoGL/JOGwb1TgINZKFSbYOCgD1JxQJG0vK9AAAAABJRU5ErkJggg==',
// map inverted
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAMCAYAAABSgIzaAAAAK0lEQVQokWNgYGD4z8DA8B8bgMlhxbgUEgIMBE3Ggkc1Dk6N5AAGUm2DYQAkYTDe0vu7CAAAAABJRU5ErkJggg==',
// openmap
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAMCAYAAABSgIzaAAAAQklEQVQokaXOwQ4AIAgCUP7/p+nUlpMSzY2bDwWHA5IEkFJCtaiKxE7dvsue8HZNJEPneoAuSq+OYAf9wy4K0Mk5C+d++RWimsw3AAAAAElFTkSuQmCC',
// openmap inverted
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAMCAYAAABSgIzaAAAAPUlEQVQokaXRQQoAQAgCQP//6brKZmSt0M2hIACI4yBURqiKXQp0ThuhGwmt7Vy00XvqCa7QN1wjhtYLCCYyCkvDVnkJOQAAAABJRU5ErkJggg==',
// object
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAH0lEQVQokWP4TyJgYGBg+E8iZiDFdHrZMKqBGA2kYAD8gaJsjwzf9wAAAABJRU5ErkJggg==',
// object inverted
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAIklEQVQokWNgYGD4TxL+TyJg+P//P9GmwzXQ3oZRDdSOBwAGOSrkrXppgQAAAABJRU5ErkJggg==',
// attrenum
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAMCAYAAABSgIzaAAAAPklEQVQokWP4////fwYGBgxMCDBgU4jNICyYsOlYbENoJNIW7BqJsYm2NuJyBVE2EqWRfjbiUoQ3oAgpwgUANLqccvbgec0AAAAASUVORK5CYII=',
// attrenum inverted
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAMCAYAAABSgIzaAAAAPElEQVQokWNgYGD4jw0wMDDgx9gUEgMYiDIdDaNoJBZg1UiUTTS1EZcriLKRKI30sxGXIgKBhF8RrqgBAOTOqGZ5aiCnAAAAAElFTkSuQmCC',
// attrarra
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAMCAYAAABSgIzaAAAAMElEQVQokWP4////fwYGBgxMCDBgU4jNICwYv+nY5InWOGojXW0khLEahtc6PDYCAB9hxkjBPICvAAAAAElFTkSuQmCC',
// attrarray inverted
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAMCAYAAABSgIzaAAAALUlEQVQokWNgYGD4jw0wMDDgx9gUEgMYCJmOTZ5ojaM20tVGQgCHK/AnLVwAAPonfpBwU5f4AAAAAElFTkSuQmCC',
// attrarel
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAIklEQVQokWP4////fwYGBpwYHTDANGADeDWM2jAEbSAFAADB26JsIjYj1AAAAABJRU5ErkJggg==',
// attrarel inverted
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAIElEQVQokWNgYGD4jw8wMDCgYwZcEvg1jNowBG0gBQMAQN8q5COZl1cAAAAASUVORK5CYII=',
// attr
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAIUlEQVQokWP4TyJgGIQaGBgY/pOIibcEroEkTLIfhoEGADzs8B5gcUg/AAAAAElFTkSuQmCC',
// attr inverted
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAJUlEQVQokWNgYGD4TyIedBr+kwgY/v//T7TpcA0k2TAIQ4nmGgDFzt0jExR7hgAAAABJRU5ErkJggg==',
// crrwrite
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAN0lEQVQokaWNQQoAMAjD8v9P633WVWhBkJIotQQoYPYbrHYrqC9D+MG54OBMuMC54GApuPBed9OxiMNLGke1JwAAAABJRU5ErkJggg==',
// crrwrite inverted
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAANElEQVQokWNgYGD4jw3DABY57IqxsQlqwGELSYop1ECEYgo0EKmYQg1EKMbUQEAxRAMpAABRMgoFjbTzXgAAAABJRU5ErkJggg==',
// crrread
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAPElEQVQokWNgYGD4j4yRATY5BmyKkGks4qgS2BSj2UYFDdgAdW2gvpOwhDW6ItwaCGI8JuHWgMOtWD0PACufaaWhXDFDAAAAAElFTkSuQmCC',
// crrread inverted
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAPElEQVQokWP4jwYYGBjgGKscNkXINLo4hgZsipFto44GbJi6NlDfSehhjUxjyGMVxQMYcJmEVwPB5ICEAdcbY6vf9TVAAAAAAElFTkSuQmCC',
// ack
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAS0lEQVQokZ2Q2w4AIAhCz///ND11M3RVmxuDUBRAtw8QHRyC4SSJSDjDht1Yhxdudks+bFNxYsX9G6rz2qVHxqRspGi2Wpoji/dqaLh22DbO2VuXAAAAAElFTkSuQmCC',
// ack inverted
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAASklEQVQokWP4////fwYGBqIwVC2cgSKBTQzKxhDA0ICmGau12BRCMLJp2BQgy8H9gM9ELGJkasAXvFg9TQjgDCVc8YBXAwFMmgYASkT1C9E5Ya0AAAAASUVORK5CYII=',
// alarm
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAARklEQVQokZ2QQQoAMAjD+v9Pu9PA1ThQQRBtoFUBJSkk0SlwOwKykCAEcn+BK8hih/aAe++y7IDuhWgXfcKHCuBBfX6ASR3Vn8ZINQzCrQAAAABJRU5ErkJggg==',
// alarm inverted
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAQ0lEQVQokWNgYGD4j45hAJscA8UakBXi0ITddDy2YJqOrBiLJjI1oLsdj1/I0IAnCLFpwtSALYQwNKB7FJ2NooEUDAAtGwcI+Svs4gAAAABJRU5ErkJggg==',
// eventacked
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAL0lEQVQokWP4TyJgGCkaGBgQyhhwSeASw9CAYho2A3CZiE0xVg34FOPUgA+QrAEA1FYi+tWeG/cAAAAASUVORK5CYII=',
// eventacked inverted
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAMElEQVQokWNgYGD4TyIeGRr+//+PXQOaBC4xVElkBdgMwHASTBEOxdj9gEcxHYIVAC5kqlZXl5JMAAAAAElFTkSuQmCC',
// eventalarm
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAJ0lEQVQokWP4jwMwMDBgF8elGIZHNeDSANOEVRyXBpwGUcUGqvoBAK+H8xt0qXFWAAAAAElFTkSuQmCC',
// eventalarm inverted
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAJ0lEQVQokWNgYGD4jw3///8fqzgDLsUwMKoBlwaSg5UAHoiIw2cDAFMz2iY65DAoAAAAAElFTkSuQmC',
// eventreturn
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAASUlEQVQokZ2RUQoAIAjFdv9L11dhskeUEIQ2mcYIAXjeisA+EahFA9ad/siAA0wqSUsnu87wDZh3VEodO6Rr1c51rc8fd9OoMQHLk7dXak3qLwAAAABJRU5ErkJggg==',
// eventreturn inverted
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAR0lEQVQokZ2S2woAIAhD9/8/vV6tjgMNhLxMN1SSTGYb46JkfS2gJglQ/ncRAZ5JTCXQYsFRwxpAvFtKoeMvmoqDv1jc5DQONycV+bfOetgAAAAASUVORK5CYII=',
// info
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAOUlEQVQokWNgYGD4///////E0AwMDP8hPDQAk8QhjlMCuzg2G3AB6tlAez8MglAiCZNiw/////8DACmmtFrq9aGNAAAAAElFTkSuQmCC',
// info inverted
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAN0lEQVQokWP4////fwYGhv/E0FA2w390jCSJIc6ASwKnBmw24MLUs4H2fhgEoUQKIMkGBgaG/wDZFBj2pVi3HgAAAABJRU5ErkJggg==',
// system
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAN0lEQVQokWNgYGD4TyJm+E8sgGugig3YxHFqwGcIQQ3obAwN6G7GawMuhVg1EFKMUwM+QJ+IAwDD1Gyi1EZc6gAAAABJRU5ErkJggg==',
// system inverted
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAO0lEQVQokWP4TyJg+P///38GBgaiMFwDVWzAJo5TA15DCGnAYKNrwHAzPhtwKcSqgZBinBqIigeaRhwAPuZgrlZXy70AAAAASUVORK5CYII=',
// maintenance
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAP0lEQVQokZWPQQoAMAzC8v9Pu8soDOxaBS82QkWNgPKTJ/BYsLekAOxfquwHWyfws6ED7OgtfNk9bAuTSGBJOufqnHIsmYkzAAAAAElFTkSuQmCC',
// maintenance inverted
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAQUlEQVQokZWPQQ4AMAQE5/+f1kuTCkuROGAmADCVPsJsBfdCsX0u3N7sJFfXsAqW8BMaID+9gE3SJayEFo7CFwY7GtAw3ouVj50AAAAASUVORK5CYII=',
// blockl
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAQElEQVQokZ2QQQ4AMAjC+v9Pu9MWl5AJ42a0IlKBgCIadgGgQ8imqo9D3zDBvJoyR+zwlWHS9SUHaOf4QOywtQCQGucn0g2dEQAAAABJRU5ErkJggg==',
// blockl inverted
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAOklEQVQokWNgYGD4Tyz+////fwZSFBOtAaoQQsM46JLY+HAbUEwgrJmwyZTZQJYfSAolmsQDWTENwwByoOYaWbAqegAAAABJRU5ErkJggg==',
// blockr
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAPElEQVQokWP4jwMwMDBgF8enAZsmvBqw2cSARQBDIQqbGEUoaggpQBcj3Qay/IAN4AwlfBrIigeiNeACADpU5yeYXn+XAAAAAElFTkSuQmCC',
// blockr inverted
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAPElEQVQokWNgYGD4jw3///8fqzgDPg04NOG3AUMTugA2hWhqiFKEzCeoAF2MRBvI8gNJoUT1eCBaAy4MAMhm5hr5iTaWAAAAAElFTkSuQmCC'
]
};
var Plow = {
DRAWOFFSET : 2,
DEST_INTOLAST : 0,
DEST_INTOFIRST : 1,
DEST_AFTER : 2,
DEST_BEFORE : 3,
TREE_INDENTATION : 1.0,
OPEN_ATTRIBUTES : 1,
OPEN_CHILDREN : 2,
OPEN_CROSSREFERENCES : 4,
OPEN_ALL : 7,
COLOR_BLACK : 1,
COLOR_RED : 2,
COLOR_GRAY : 3,
COLOR_DARKGRAY : 4,
COLOR_LIGHTGRAY : 5,
COLOR_WHITE : 6,
COLOR_YELLOW : 7,
COLOR_GREEN : 8,
COLOR_LIGHTBLUE : 9,
COLOR_BLUE : 10,
COLOR_VIOLET : 11,
eEvent_MB1Click : 0,
eEvent_MB1ClickShift : 1,
eEvent_Key_Up : 2,
eEvent_Key_Down : 3,
eEvent_Key_Right : 4,
eEvent_Key_Left : 5,
eEvent_Key_ShiftRight : 6,
eEvent_Key_CtrlR : 7,
eEvent_Key_CtrlL : 8,
eEvent_Key_CtrlG : 9,
eEvent_ObjectDeleted : 10,
RELATIVE_POSITION : 1,
NEXT_RELATIVE_POSITION : 2
}
function PlowGeometry() {
this.ll_x = 0;
this.ll_y = 0;
this.ur_x = 0;
this.ur_y = 0;
}
function PlowNodeClass( ctx) {
this.a = new PlowArray( ctx);
this.ctx = ctx;
this.nc_name = "";
this.group = 0;
this.node_open = 0;
this.draw = function( g, p, node, highlight) {
this.a.draw( g, p, node, highlight);
}
this.insert = function( elem) {
this.a.add(elem);
}
}
function PlowArray( ctx) {
this.a = [];
this.ctx = ctx;
this.add = function( elem) {
this.a.push(elem);
}
this.insertNode = function( elem, destination, code) {
var idx = this.find( elem);
if ( idx != -1)
return;
if ( destination == null) {
switch( code) {
case Plow.DEST_INTOLAST:
case Plow.DEST_AFTER:
this.a.push(elem);
elem.level = 0;
break;
default:
elem.level = 0;
this.a.unshift(elem);
}
}
else {
var dest_idx = this.find( destination);
if ( dest_idx == -1)
return;
switch( code) {
case Plow.DEST_INTOFIRST:
if ( dest_idx == this.a.length - 1)
this.a.push( elem);
else
this.a.splice( dest_idx + 1, 0, elem);
elem.level = destination.level + 1;
break;
case Plow.DEST_INTOLAST: {
if ( dest_idx == this.a.length - 1)
this.a.push( elem);
else {
idx = this.a.length;
for ( var i = dest_idx + 1; i < this.a.length; i++) {
if ( this.a[i].level <= destination.level) {
idx = i;
break;
}
}
if ( idx == this.a.length)
this.a.push( elem);
else
this.a.splice( idx, 0, elem);
}
elem.level = destination.level + 1;
break;
}
case Plow.DEST_AFTER: {
if ( dest_idx == this.a.length - 1)
this.a.push( elem);
else {
var i;
for ( i = idx; i < this.a.length; i++) {
if ( this.a[i].level < destination.level)
break;
}
this.a.splice( i, 0, elem);
}
elem.level = destination.level;
break;
}
case Plow.DEST_BEFORE:
if ( idx > 0)
idx--;
this.a.splice( idx, 0, elem);
elem.level = destination.level;
break;
}
}
}
this.remove = function( elem) {
var idx = this.find( elem);
if ( idx == -1)
return;
this.ctx.event_cb( Plow.eEvent_ObjectDeleted, this.a[idx+1], 0, 0);
this.a.splice( idx, 1);
}
this.size = function() {
return this.a.length;
}
this.get = function( idx) {
return this.a[idx];
}
this.draw = function( g, p, node, highlight) {
for ( var i = 0; i < this.a.length; i++)
this.a[i].draw( g, p, node, highlight);
}
this.set_borders = function( node) {
for ( var i = 0; i < this.a.length; i++)
this.a[i].set_borders( node);
}
this.configure = function() {
for ( var i = 0; i < this.a.length; i++) {
this.a[i].pos.x = this.a[i].level * 1.0;
this.a[i].pos.y = i * 1.0;
}
}
this.close_node = function( node) {
var idx = this.find( node);
if ( idx == -1)
return;
var level = node.level;
var i;
for ( i = idx + 1; i < this.a.length; i++) {
if ( this.a[i].level <= level)
break;
}
var next_idx = i;
if ( next_idx == idx + 1)
return;
for ( i = idx + 1; i < next_idx; i++) {
// Event backcall
if ( ctx.select_object == this.a[idx+1])
ctx.select_object = null;
this.ctx.event_cb( Plow.eEvent_ObjectDeleted, this.a[idx+1], 0, 0);
this.a.splice( idx+1, 1);
}
}
this.get_parent_object = function( node) {
var idx = this.find( node);
if ( idx == -1)
return null;
for ( var i = idx; i >= 0; i--) {
if ( this.a[i].level < node.level)
return this.a[i];
}
return null;
}
this.get_first_child = function( node) {
var idx = this.find( node);
if ( idx == -1)
return null;
if ( this.a.length == idx - 1)
return null;
if ( this.a[idx + 1].level > node.level)
return this.a[idx + 1];
return null;
}
this.get_next_sibling = function( node) {
var found = false;
for ( var i = 0; i < this.a.length; i++) {
if ( this.a[i] == node) {
found = true;
continue;
}
if ( found) {
if ( this.a[i].level == node.level)
return this.a[i];
if ( this.a[i].level < node.level)
return null;
}
}
return null;
}
this.get_next_object = function( node) {
for ( var i = 0; i < this.a.length; i++) {
if ( this.a[i] == node) {
if ( i == this.a.length - 1)
return null;
return this.a[i+1];
}
}
return null;
}
this.get_previous_object = function( node) {
for ( var i = 0; i < this.a.length; i++) {
if ( this.a[i] == node) {
if ( i == 0)
return null;
return this.a[i-1];
}
}
return null;
}
this.get_first_object = function() {
if ( this.a.length == 0)
return null;
return this.a[0];
}
this.get_last_object = function() {
if ( this.a.length == 0)
return null;
return this.a[this.a.length - 1];
}
this.find = function( elem) {
for ( var i = 0; i < this.a.length; i++) {
if ( this.a[i] == elem)
return i;
}
return -1;
}
}
function PlowNode( ctx, nc, level) {
this.ctx = ctx;
this.userdata = null;
this.OFFSET = 2;
this.x_right = 0.0;
this.x_left = 0.0;
this.y_high = 0.0;
this.y_low = 0.0;
this.nc = nc;
this.pos = new PlowPoint(ctx,0,0);
this.n_name = "";
this.annotv = [];
this.annotsize = [];
this.pixmapv = [];
this.trace_object = "";
this.trace_attribute = "";
this.trace_attr_type = 0;
this.highlight = false;
this.select = false;
this.invert = false;
this.level = level;
this.node_open = false;
this.fill_color = 0;
this.p = 0;
this.old_value = 0;
this.first_scan = true;
this.relative_position = 0;
this.set_annotation = function( number, text) {
if ( number >= 10)
return;
this.annotv[number] = text;
}
this.set_annotation_pixmap = function( number, pixmap) {
if ( number >= 10)
return;
this.pixmapv[number] = pixmap;
}
this.draw_object = function() {
this.draw( this.ctx.gdraw.gctx, null, null, false);
}
this.draw = function( g, p, node, highlight) {
var x = this.x_left * this.ctx.zoom_factor;
var y = this.y_low * this.ctx.zoom_factor-1;
var width = (this.x_right - this.x_left) * this.ctx.zoom_factor;
var height = (this.y_high - this.y_low) * this.ctx.zoom_factor+2;
g.fillStyle = "white";
if ( this.select)
g.fillStyle = "lightblue";
g.fillRect( x, y, width, height);
this.nc.draw( g, this.pos, this, this.highlight);
}
this.connect = function() {
if ( this.trace_object == "" || this.trace_attribute == "")
return;
var n = this.trace_attribute.indexOf('#');
if ( n != -1)
this.trace_attribute = this.trace_attribute.substring(0, n);
var o = this.trace_object + "." + this.trace_attribute;
this.p = ctx.gdh.refObjectInfo( o, this.trace_attr_type);
console.log("connecting", o, this.p);
}
this.scan = function() {
if ( this.p == 0)
return;
var v1 = ctx.gdh.getRefObjectInfo( this.p);
var evaluate = true;
if ( this.first_scan)
this.first_scan = false;
else if ( v1 == this.old_value)
return;
if ( v1)
this.highlight = true;
else
this.highlight = false;
this.old_value = v1;
this.draw_object();
}
this.set_borders = function() {
this.x_left = 1e37;
this.x_right = -1e37;
this.y_low = 1e37;
this.y_high = -1e37;
nc.a.set_borders( this);
}
this.event_handler = function( event, x, y) {
if ( (x - this.ctx.offset_x) / this.ctx.zoom_factor >= this.x_left &&
(x - this.ctx.offset_x) / this.ctx.zoom_factor <= this.x_right &&
(y - this.ctx.offset_y) / this.ctx.zoom_factor >= this.y_low &&
(y - this.ctx.offset_y) / this.ctx.zoom_factor <= this.y_high) {
ctx.event_object = this;
return 1;
}
return 0;
}
this.set_select = function( select) {
if ( select) {
this.select = true;
this.ctx.select_object = this;
}
else {
this.select = false;
if ( this.ctx.select_object == this)
this.ctx.select_object = null;
}
if ( select != this.select)
this.draw_object();
}
this.set_invert = function( invert) {
this.invert = invert;
this.draw_object();
}
this.set_userdata = function( userdata) {
this.userdata = userdata;
}
this.get_userdata = function() {
return this.userdata;
}
this.in_icon = function( x, y) {
if ( x >= this.x_left * this.ctx.zoom_factor &&
x <= (this.x_left + 1.75) * this.ctx.zoom_factor)
return true;
return false;
}
this.measure = function() {
var geom = new PlowGeometry();
geom.ll_x = this.x_left * this.ctx.zoom_factor;
geom.ll_y = this.y_low * this.ctx.zoom_factor;
geom.ur_x = this.x_right * this.ctx.zoom_factor;
geom.ur_y = this.y_high * this.ctx.zoom_factor;
return geom;
};
}
function PlowPoint( ctx, x, y) {
this.x = x;
this.y = y;
this.ctx = ctx;
}
function PlowAnnot( ctx, x, y, text_size, text_color, annot_type, number) {
this.RELATIVE_OFFSET = 1;
this.p = new PlowPoint(ctx, x, y);
this.draw_type = text_color;
this.text_size = text_size;
this.annot_type = annot_type;
this.number = number;
this.ctx = ctx;
this.draw = function( g, p0, node, highlight) {
if ( node == null)
return;
if ( node.annotv[this.number] == null)
return;
var tsize = 0;
var idx = this.ctx.zoom_factor / this.ctx.base_zoom_factor * (this.text_size +4) - 4;
if ( idx < 0) return;
switch( idx) {
case 0: tsize = 8; break;
case 1: tsize = 10; break;
case 2: tsize = 12; break;
case 3: tsize = 14; break;
case 4: tsize = 14; break;
case 5: tsize = 18; break;
case 6: tsize = 18; break;
case 7: tsize = 18; break;
default: tsize = idx * 3;
}
g.font = tsize + "px Arial";
if ( node.invert)
g.fillStyle = "white";
else
g.fillStyle = "black";
if ( highlight)
g.fillStyle = "red";
g.lineWidth = 0.5;
var x = (this.p.x + p0.x) * this.ctx.zoom_factor;
var y = (this.p.y + p0.y) * this.ctx.zoom_factor - tsize/4;
if ( (this.annot_type & Plow.RELATIVE_POSITION) != 0) {
var rel_x = (p0.x + node.relative_position + this.RELATIVE_OFFSET) * this.ctx.zoom_factor;
if ( x < rel_x)
x = rel_x;
}
var tokens = node.annotv[this.number].split('\n');
for ( var i = 0; i < tokens.length; i++) {
g.fillText( tokens[i], x, y);
y += tsize * 1.4;
}
if ( (this.annot_type & Plow.NEXT_RELATIVE_POSITION) != 0 || (this.annot_type & Plow.RELATIVE_POSITION) != 0) {
node.relative_position = (x + g.measureText(node.annotv[this.number]).width) / this.ctx.zoom_factor - p0.x;
}
}
this.set_borders = function( node) {
}
}
function PlowAnnotPixmap( ctx, x, y, number) {
this.p = new PlowPoint(ctx, x, y);
this.number = number;
this.ctx = ctx;
this.draw = function( gctx, p0, node, highlight) {
var x = (this.p.x + p0.x) * this.ctx.zoom_factor;
var y = (this.p.y + p0.y) * this.ctx.zoom_factor;
var img;
var bix = node.pixmapv[this.number];
if ( typeof bix === 'undefined' || bix === null)
return;
if ( node.invert)
bix++;
img = Bitmaps.img[bix];
if ( img == null) {
var img = new Image();
img.src = Bitmaps.images[bix];
Bitmaps.img[bix] = img;
Bitmaps.pending[bix] = [];
Bitmaps.pending[bix].push(new PlowPoint(this.ctx, x, y));
img.onload = function() {
for ( var i = 0; i < Bitmaps.pending[bix].length; i++)
gctx.drawImage(img, Bitmaps.pending[bix][i].x, Bitmaps.pending[bix][i].y);
Bitmaps.pending[bix] = null;
}
}
else {
if ( !img.complete)
Bitmaps.pending[bix].push(new PlowPoint(this.ctx, x, y));
else
gctx.drawImage(img, x, y);
}
}
this.set_borders = function( node) {
}
}
function PlowRect( ctx, x, y, width, height, fill_color, border_color, fill, fix_color) {
this.ll = new PlowPoint(ctx, x, y);
this.ur = new PlowPoint(ctx, x + width, y + height);
this.border_color = border_color;
this.fill_color = fill_color;
this.fill = fill;
this.fix_color = fix_color;
this.ctx = ctx;
this.draw = function( g, p, node, highlight) {
var x = (this.ll.x + p.x) * this.ctx.zoom_factor;
var y = (this.ll.y + p.y) * this.ctx.zoom_factor;
var width = (this.ur.x - this.ll.x) * this.ctx.zoom_factor;
var height = (this.ur.y - this.ll.y) * this.ctx.zoom_factor;
g.lineWidth = 1;
switch ( this.border_color) {
case Plow.COLOR_GRAY:
g.strokeStyle = "grey";
break;
case Plow.COLOR_RED:
g.strokeStyle = "red";
break;
case Plow.COLOR_WHITE:
g.strokeStyle = "white";
break;
default:
g.strokeStyle = "black";
}
if ( highlight)
g.strokeStyle = "red";
g.strokeRect( x, y, width, height);
if ( this.fill) {
switch ( this.fill_color) {
case Plow.COLOR_GRAY:
g.fillStyle = "grey";
break;
case Plow.COLOR_RED:
g.fillStyle = "red";
break;
case Plow.COLOR_YELLOW:
g.fillStyle = "yellow";
break;
case Plow.COLOR_GREEN:
g.fillStyle = "lightgreen";
break;
case Plow.COLOR_WHITE:
if ( node.invert)
g.fillStyle = "black";
else
g.fillStyle = "white";
break;
default:
if ( node.invert)
g.fillStyle = "white";
else
g.fillStyle = "black";
}
g.fillRect( x, y, width, height);
}
}
this.set_borders = function( node) {
if ( this.ll.x + node.pos.x < node.x_left)
node.x_left = this.ll.x + node.pos.x;
if ( this.ur.x + node.pos.x > node.x_right)
node.x_right = this.ur.x + node.pos.x;
if ( this.ll.y + node.pos.y < node.y_low)
node.y_low = this.ll.y + node.pos.y;
if ( this.ur.y + node.pos.y > node.y_high)
node.y_high = this.ur.y + node.pos.y;
}
}
function GDraw( ctx) {
this.ctx = ctx;
this.canvas = document.querySelector("canvas");
this.gctx = this.canvas.getContext("2d");
this.offset_top = this.canvas.offsetTop;
}
function PlowCtx() {
this.gdh = 0;
this.debug = false;
this.nodraw = 0;
this.zoom_factor = 20.0;
this.base_zoom_factor = 20.0;
this.offset_x = 0;
this.offset_y = 0;
this.x_right = 0.0;
this.x_left = 0.0;
this.y_high = 0.0;
this.y_low = 0.0;
this.a = new PlowArray(this);
this.a_nc = new PlowArray(this);
this.name = "Claes context";
this.gdraw = new GDraw(this);
this.selct_object = null;
this.event_cb = null;
this.event_object = null;
this.draw = function() {
if ( this.nodraw > 0)
return;
this.gdraw.gctx.fillStyle = "white";
this.gdraw.gctx.fillRect( 0, 0, this.gdraw.canvas.width, this.gdraw.canvas.height);
this.a.draw( this.gdraw.gctx, null, null, false);
};
this.connect = function() {
for ( var i = 0; i < this.a.size(); i++)
this.a.get(i).connect();
};
this.scan = function() {
console.log("ctx scan", this.a.size());
for ( var i = 0; i < this.a.size(); i++)
this.a.get(i).scan();
};
this.set_nodraw = function() {
this.nodraw++;
};
this.reset_nodraw = function() {
this.nodraw--;
};
this.size = function() {
return this.a.size()
};
this.event_handler = function( event, x, y) {
var sts = 0;
switch ( event) {
case Plow.eEvent_MB1Click:
case Plow.eEvent_MB1ClickShift:
for ( var i = 0; i < this.a.size(); i++) {
if ( this.a.get(i) instanceof PlowNode) {
sts = this.a.get(i).event_handler( event, x, y);
if ( sts == 1)
break;
}
}
if ( sts == 1) {
this.event_cb( event, this.event_object, x, y);
this.draw();
}
break;
case Plow.eEvent_Key_Up:
case Plow.eEvent_Key_Down:
case Plow.eEvent_Key_Left:
case Plow.eEvent_Key_Right:
case Plow.eEvent_Key_ShiftRight:
case Plow.eEvent_Key_CtrlR:
case Plow.eEvent_Key_CtrlL:
case Plow.eEvent_Key_CtrlG:
this.event_cb( event, null, 0, 0);
break;
}
};
this.set_select = function( select) {
for ( var i = 0; i < this.a.size(); i++) {
if ( this.a.get(i) instanceof PlowNode)
this.a.get(i).set_select( select);
}
};
this.set_invert = function( invert) {
for ( var i = 0; i < this.a.size(); i++) {
if ( this.a.get(i) instanceof PlowNode)
this.a.get(i).set_invert( invert);
}
};
this.get_select = function () {
return this.select_object;
};
this.insert = function( n, dest) {
this.a.add(n);
};
this.insertNode = function( n, destination, destCode) {
this.a.insertNode(n, destination, destCode);
};
this.remove = function( n) {
if ( this.select_object == n)
this.select_object = null;
this.a.remove(n);
};
this.insert_nc = function( nc) {
this.a_nc.add(nc);
};
this.configure = function() {
this.a.configure();
this.a.set_borders();
var height = this.a.a.length * 1.0 * this.zoom_factor;
this.gdraw.canvas.height = height;
};
this.get_parent_object = function( o) {
return this.a.get_parent_object(o);
};
this.get_next_object = function( o) {
return this.a.get_next_object(o);
};
this.get_last_object = function() {
return this.a.get_last_object();
};
this.get_first_object = function() {
return this.a.get_first_object();
};
this.get_previous_object = function( o) {
return this.a.get_previous_object(o);
};
this.close_node = function( o) {
this.a.close_node(o);
};
this.is_visible = function( o) {
if ((o.y_high * this.zoom_factor <= window.pageYOffset + window.innerHeight - this.gdraw.offset_top) &&
(o.y_low * this.zoom_factor >= window.pageYOffset - this.gdraw.offset_top))
return true;
return false;
};
this.scroll = function( y, factor) {
window.scrollTo( window.scrollX, y * this.zoom_factor - window.innerHeight * factor + this.gdraw.offset_top)
};
}
/** End Plow **/
/** Start Xtt **/ /** Start Xtt **/
function XttOpenChildrenData( node, open_next) { function XttOpenChildrenData( node, open_next) {
......
#include <stdio.h>
#include <string.h>
#include "pwr.h"
#include "co_dcli.h"
#include "co_string.h"
static pwr_tFileName inc_path[10];
static unsigned int inc_path_cnt = 0;
void usage()
{
printf("\nco_jsconcat\n\n> co_jsconcat [-I include-directory] -o outfile infile\n\n");
}
int read_file(FILE *ofp, char *incfile)
{
pwr_tFileName fname;
FILE *ifp;
int i;
char line[400];
for (i = 0; i < inc_path_cnt; i++) {
strcpy(fname, inc_path[i]);
strcat(fname, "/");
strcat(fname, incfile);
dcli_translate_filename(fname, fname);
ifp = fopen(fname, "r");
if (ifp)
break;
else if (i == inc_path_cnt - 1) {
printf("** Unable to open file %s\n", incfile);
exit(0);
}
}
while (dcli_read_line(line, sizeof(line), ifp)) {
if (strncmp(line, "#jsc_include", 12) == 0) {
str_trim(incfile, &line[13]);
read_file(ofp, (char *)incfile);
}
else {
fputs(line, ofp);
fputc('\n', ofp);
// fprintf(ofp, "%s\n", line);
}
}
return 1;
}
int main(int argc, char* argv[])
{
pwr_tFileName outfile = "";
pwr_tFileName infile = "";
pwr_tFileName incfile;
pwr_tFileName fname;
int i;
FILE *ifp;
FILE *ofp;
char line[400];
for (i = 1; i < argc; i++) {
if ((argv)[i][0] == '-') {
int i_incr = 0;
for (int j = 1; (argv)[i][j] != 0 && (argv)[i][j] != ' '
&& (argv)[i][j] != ' ';
j++) {
switch ((argv)[i][j]) {
case 'I':
if (i + 1 >= argc
|| !((argv)[i][j + 1] == ' ' || (argv)[i][j + 1] != ' ')) {
usage();
exit(0);
}
if (inc_path_cnt >= sizeof(inc_path)/sizeof(inc_path[0])) {
printf("** Max number of include paths exceeded\n");
exit(0);
}
strncpy(inc_path[inc_path_cnt], (argv)[i + 1], sizeof(inc_path[0]));
inc_path_cnt++;
i++;
i_incr = 1;
break;
case 'o':
if (i + 1 >= argc
|| !((argv)[i][j + 1] == ' ' || (argv)[i][j + 1] != ' ')) {
usage();
exit(0);
}
strncpy(outfile, (argv)[i + 1], sizeof(outfile));
inc_path_cnt++;
i++;
i_incr = 1;
break;
default:
usage();
exit(0);
}
if (i_incr)
break;
}
} else {
// Input file
strcpy(infile, (argv)[i]);
}
}
printf("-I %s -l %s %s\n", inc_path[0], outfile, infile);
dcli_translate_filename(fname, infile);
ifp = fopen(fname, "r");
if (!ifp) {
printf("** Unable to open file %s\n", fname);
exit(0);
}
dcli_translate_filename(fname, outfile);
ofp = fopen(fname, "w");
if (!ofp) {
printf("** Unable to open file %s\n", fname);
exit(0);
}
while (dcli_read_line(line, sizeof(line), ifp)) {
if (strncmp(line, "#jsc_include", 12) == 0) {
str_trim(incfile, &line[13]);
read_file(ofp, incfile);
}
else {
fputs(line, ofp);
fputc('\n', ofp);
// fprintf(ofp, "%s\n", line);
}
}
}
ifndef link_rule_mk
link_rule_mk := 1
link = $(ldxx) $(linkflags) $(domap) -o $(export_exe) $(export_obj) \
$(objects) -lpwr_co $(pwre_conf_libdir) $(pwre_conf_lib)
endif
...@@ -274,8 +274,7 @@ $(web_dir)/%.css : %.css ...@@ -274,8 +274,7 @@ $(web_dir)/%.css : %.css
$(web_dir)/%.js : %.js $(web_dir)/%.js : %.js
@ $(log_h_h) @ $(log_h_h)
@ $(cp) $(cpflags) $(source) $(target) @ co_jsconcat -I $(pwre_croot)/java/jsw/cmn/src -o $(target) $(source)
$(inc_dir)/%.meth : %.meth $(inc_dir)/%.meth : %.meth
@ $(log_h_h) @ $(log_h_h)
@ $(cp) $(cpflags) $(source) $(target) @ $(cp) $(cpflags) $(source) $(target)
......
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