Commit 1006a60b authored by Claes Sjofors's avatar Claes Sjofors

Operator enviroment for HTML5 and java script added

parent 852ae8d7
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Trace</title>
<link rel="stylesheet" type="text/css" href="toolbar.css">
</head>
<body>
<div class="toolbar" role="toolbar">
<div id="toolitem1" tabindex="0" class="toolbar-item" role="button"><img src="toolbar_graph.png"><img></div>
<div id="toolitem2" tabindex="-1" class="toolbar-item" role="button"><img src="toolbar_navigator.png"><img></div>
<div id="toolitem3" tabindex="-1" class="toolbar-item" role="button"><img src="toolbar_history.png"><img></div>
<div id="toolitem4" tabindex="-1" class="toolbar-item" role="button"><img src="toolbar_object.png"><img></div>
</div>
<!-- <div style="height:300px;overflow:auto;"> --!>
<canvas id="flowcanvas" width="1200" height="800"></canvas>
<script src=flow.js></script>
<!-- </div> --!>
<hr>
<address><a href="mailto:claes@debian86.ssab.com"></a></address>
<!-- Created: Tue Mar 13 16:22:00 CET 2018 -->
<!-- hhmts start -->
Last modified: Tue May 15 08:59:01 CEST 2018
<!-- hhmts end -->
</body>
</html>
"use strict";
/** Pwr start **/
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;
}
/** 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;
}
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
};
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
};
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;
console.log("sub undefined");
}
else {
var value;
switch ( sub.type) {
case Pwr.eType_Boolean:
value = dv.getUint8(j);
j += 1;
break;
case Pwr.eType_Float32:
if ( sub.elements <= 1) {
value = dv.getFloat32(j);
j += 4;
}
else {
if ( esize != sub.elements * 4)
console.log("Subscription size error", esize, sub.elements, eid);
value = new Array(sub.elements);
for ( var k = 0; k < sub.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_Mask:
case Pwr.eType_Enum:
value = 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:
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);
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: {
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 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;
console.log( "Opmenu", result.title, result.text, result.enable_language,
result.enable_login, result.enable_alarmlist, result.enable_eventlog,
result.enable_navigator, result.disable_help, result.disable_proview, result.language, bsize);
console.log("Opmenu buttons size", bsize);
for ( var i = 0; i < bsize; i++) {
var button = new MenuButton();
button.type = dv.getUint32(j);
j += 4;
nsize = dv.getUint16(j);
j += 2;
console.log( "text size", button.type, nsize);
iarr = new Uint8Array( nsize);
for ( var k = 0; k < nsize; k++) {
console.log("Button.text", j);
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);
console.log("Button", button.text, button.name, button.url);
}
}
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;
}
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);
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.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++;
};
}
/** End Gdh **/
/** Start Flow **/
var Flow = {
DRAWOFFSET : 2,
eConType_Straight : 0,
eConType_Fixed : 1,
eConType_AllFixed : 2,
eConType_Routed : 3,
eConType_StepDiv : 4,
eConType_StepConv : 5,
eConType_TransDiv : 6,
eConType_TransConv : 7,
eConType_StraightOneArrow : 8,
eConType_Reference : 9,
eDrawType_Line : 0,
eDrawType_LineRed : 1,
eDrawType_LineGray : 2,
eDrawType_LineErase : 3,
eDrawType_LineDashed : 4,
eDrawType_LineDashedRed : 5,
eDrawType_TextHelvetica : 6,
eDrawType_TextHelveticaBold : 7,
eDrawType_TextHelveticaErase : 8,
eDrawType_TextHelveticaEraseBold : 9,
eDrawType_ : 10,
eDrawType_Green : 11,
eDrawType_Yellow : 12,
eDrawType_DarkGray : 13,
eDrawType_Inherit : 9999,
mDisplayLevel_1 : 1 << 0,
mDisplayLevel_2 : 1 << 2,
mDisplayLevel_3 : 1 << 3,
mDisplayLevel_4 : 1 << 4,
mDisplayLevel_5 : 1 << 5,
mDisplayLevel_6 : 1 << 6,
eNodeGroup_Common : 0,
eNodeGroup_Document : 1,
eNodeGroup_Trace : 2,
eTraceType_Boolean : 0,
eTraceType_Int32 : 1,
eTraceType_Float32 : 2,
eTraceType_User : 3,
eSave_Ctx : 1,
eSave_Array : 2,
eSave_NodeClass : 3,
eSave_ConClass : 4,
eSave_Rect : 5,
eSave_Line : 6,
eSave_Point : 7,
eSave_Arc : 8,
eSave_Text : 9,
eSave_Node : 10,
eSave_Con : 11,
eSave_ConPoint : 12,
eSave_Annot : 13,
eSave_Arrow : 14,
eSave_Pixmap : 15,
eSave_AnnotPixmap : 16,
eSave_Radiobutton : 17,
eSave_Frame : 18,
eSave_AnnotPixmapButton : 19,
eSave_Triangle : 20,
eSave_End : 99,
eSave_Ctx_zoom_factor : 100,
eSave_Ctx_base_zoom_factor : 101,
eSave_Ctx_offset_x : 102,
eSave_Ctx_offset_y : 103,
eSave_Ctx_nav_zoom_factor : 104,
eSave_Ctx_print_zoom_factor : 105,
eSave_Ctx_nav_offset_x : 106,
eSave_Ctx_nav_offset_y : 107,
eSave_Ctx_x_right : 108,
eSave_Ctx_x_left : 109,
eSave_Ctx_y_high : 110,
eSave_Ctx_y_low : 111,
eSave_Ctx_window_width : 112,
eSave_Ctx_window_height : 113,
eSave_Ctx_nav_window_width : 114,
eSave_Ctx_nav_window_height : 115,
eSave_Ctx_nav_rect_ll_x : 116,
eSave_Ctx_nav_rect_ll_y : 117,
eSave_Ctx_nav_rect_ur_x : 118,
eSave_Ctx_nav_rect_ur_y : 119,
eSave_Ctx_nav_rect_hot : 120,
eSave_Ctx_name : 121,
eSave_Ctx_user_highlight : 122,
eSave_Ctx_a_nc : 123,
eSave_Ctx_a_cc : 124,
eSave_Ctx_a : 125,
eSave_Ctx_grid_size_x : 126,
eSave_Ctx_grid_size_y : 127,
eSave_Ctx_grid_on : 128,
eSave_Ctx_draw_delta : 129,
eSave_Ctx_refcon_width : 130,
eSave_Ctx_refcon_height : 131,
eSave_Ctx_refcon_textsize : 132,
eSave_Ctx_refcon_linewidth : 133,
eSave_Ctx_user_version : 134,
eSave_Array_a : 200,
eSave_NodeClass_nc_name : 300,
eSave_NodeClass_a : 301,
eSave_NodeClass_group : 302,
eSave_NodeClass_no_con_obstacle : 303,
eSave_ConClass_cc_name : 400,
eSave_ConClass_con_type : 401,
eSave_ConClass_corner : 402,
eSave_ConClass_draw_type : 403,
eSave_ConClass_line_width : 404,
eSave_ConClass_arrow_width : 405,
eSave_ConClass_arrow_length : 406,
eSave_ConClass_round_corner_amount : 407,
eSave_ConClass_group : 408,
eSave_Rect_draw_type : 500,
eSave_Rect_line_width : 501,
eSave_Rect_ll : 502,
eSave_Rect_ur : 503,
eSave_Rect_display_level : 504,
eSave_Rect_fill : 505,
eSave_Line_draw_type : 600,
eSave_Line_line_width : 601,
eSave_Line_p1 : 602,
eSave_Line_p2 : 603,
eSave_Point_x : 700,
eSave_Point_y : 701,
eSave_Arc_angel1 : 800,
eSave_Arc_angel2 : 801,
eSave_Arc_draw_type : 802,
eSave_Arc_line_width : 803,
eSave_Arc_ll : 804,
eSave_Arc_ur : 805,
eSave_Text_text_size : 900,
eSave_Text_draw_type : 901,
eSave_Text_text : 902,
eSave_Text_p : 903,
eSave_Node_nc : 1000,
eSave_Node_pos : 1001,
eSave_Node_n_name : 1002,
eSave_Node_annotsize : 1003,
eSave_Node_annotv : 1004,
eSave_Node_refcon_cnt : 1005,
eSave_Node_x_right : 1006,
eSave_Node_x_left : 1007,
eSave_Node_y_high : 1008,
eSave_Node_y_low : 1009,
eSave_Node_trace_object : 1010,
eSave_Node_trace_attribute : 1011,
eSave_Node_trace_attr_type : 1012,
eSave_Node_obst_x_right : 1013,
eSave_Node_obst_x_left : 1014,
eSave_Node_obst_y_high : 1015,
eSave_Node_obst_y_low : 1016,
eSave_Node_trace_inverted : 1017,
eSave_Con_x_right : 1100,
eSave_Con_x_left : 1101,
eSave_Con_y_high : 1102,
eSave_Con_y_low : 1103,
eSave_Con_cc : 1104,
eSave_Con_dest_node : 1105,
eSave_Con_source_node : 1106,
eSave_Con_dest_conpoint : 1107,
eSave_Con_source_conpoint : 1108,
eSave_Con_dest_direction : 1109,
eSave_Con_source_direction : 1110,
eSave_Con_line_a : 1111,
eSave_Con_arc_a : 1112,
eSave_Con_arrow_a : 1113,
eSave_Con_ref_a : 1114,
eSave_Con_p_num : 1115,
eSave_Con_l_num : 1116,
eSave_Con_a_num : 1117,
eSave_Con_arrow_num : 1118,
eSave_Con_ref_num : 1119,
eSave_Con_point_x : 1120,
eSave_Con_point_y : 1121,
eSave_Con_source_ref_cnt : 1122,
eSave_Con_dest_ref_cnt : 1123,
eSave_Con_c_name : 1124,
eSave_Con_trace_object : 1125,
eSave_Con_trace_attribute : 1126,
eSave_Con_trace_attr_type : 1127,
eSave_Con_temporary_ref : 1128,
eSave_ConPoint_number : 1200,
eSave_ConPoint_direction : 1201,
eSave_ConPoint_p : 1202,
eSave_ConPoint_trace_attribute : 1203,
eSave_ConPoint_trace_attr_type : 1204,
eSave_Annot_number : 1300,
eSave_Annot_draw_type : 1301,
eSave_Annot_text_size : 1302,
eSave_Annot_p : 1303,
eSave_Annot_annot_type : 1304,
eSave_Annot_display_level : 1305,
eSave_Arrow_arrow_width : 1400,
eSave_Arrow_arrow_length : 1401,
eSave_Arrow_draw_type : 1402,
eSave_Arrow_line_width : 1403,
eSave_Arrow_p_dest : 1404,
eSave_Arrow_p1 : 1405,
eSave_Arrow_p2 : 1406,
eSave_Triangle_rect_part : 2000
}
function GDraw( ctx) {
this.ctx = ctx;
this.canvas = document.querySelector("canvas");
this.gctx = this.canvas.getContext("2d");
this.offset_top = this.canvas.offsetTop;
this.offset_left = this.canvas.offsetTop;
console.log("offset_top", this.offset_top, "offset_left", this.offset_left);
this.rect = function( x, y, width, height) {
this.gctx.strokeRect( x, y, width, height);
}
this.line = function( x1, y1, x2, y2) {
this.gctx.beginPath();
this.gctx.moveTo( x1, y1);
this.gctx.lineTo( x2, y2);
this.gctx.stroke();
}
}
function FlowArray( ctx) {
this.a = [];
this.ctx = ctx;
this.add = function( elem) {
this.a.push(elem);
}
this.size = function() {
return this.a.length;
}
this.get = function( idx) {
return this.a[idx];
}
this.open = function( lines, row) {
var end = false;
var i;
for ( i = row; i < lines.length; i++) {
var tokens = lines[i].split(' ');
var key = parseInt(tokens[0]);
if ( this.ctx.debug) console.log( "array : " + lines[i]);
switch ( key) {
case Flow.eSave_Array:
break;
case Flow.eSave_NodeClass:
var nc = new FlowNodeClass( ctx);
i = nc.open( lines, i+1);
this.a.push( nc);
break;
case Flow.eSave_ConClass:
var cc = new FlowConClass( ctx);
i = cc.open( lines, i+1);
this.a.push( cc);
break;
case Flow.eSave_Node:
var n = new FlowNode( ctx);
i = n.open( lines, i+1);
this.a.push( n);
break;
case Flow.eSave_Con:
var c = new FlowCon( ctx);
i = c.open( lines, i+1);
this.a.push( c);
break;
case Flow.eSave_Rect:
var rect = new FlowRect( ctx);
i = rect.open( lines, i+1);
this.a.push( rect);
break;
case Flow.eSave_Line:
var l = new FlowLine( ctx);
i = l.open( lines, i+1);
this.a.push( l);
break;
case Flow.eSave_Triangle:
var t = new FlowTriangle( ctx);
i = t.open( lines, i+1);
this.a.push( t);
break;
case Flow.eSave_Arc:
var arc = new FlowArc( ctx);
i = arc.open( lines, i+1);
this.a.push( arc);
break;
case Flow.eSave_Text:
var text = new FlowText( ctx);
i = text.open( lines, i+1);
this.a.push( text);
break;
case Flow.eSave_ConPoint:
var cp = new FlowConPoint( ctx);
i = cp.open( lines, i+1);
this.a.push( cp);
break;
case Flow.eSave_Annot:
var annot = new FlowAnnot( ctx);
i = annot.open( lines, i+1);
this.a.push( annot);
break;
case Flow.eSave_Arrow:
var arrow = new FlowArrow( ctx);
i = arrow.open( lines, i+1);
this.a.push( arrow);
break;
case Flow.eSave_Point:
var point = new FlowPoint( ctx);
i = point.open( lines, i+1);
this.a.push( point);
break;
case Flow.eSave_End:
end = true;
break;
default:
console.log( "Syntax error in FlowArray", key);
break;
}
if ( end)
break;
}
return i;
};
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.search_by_name = function( name) {
var uname = name.toUpperCase();
for ( var i = 0; i < this.a.length; i++) {
if ( this.a[i] instanceof FlowNode) {
console.log( "Search", this.a[i].n_name, name);
if ( this.a[i].n_name.toUpperCase() == uname)
return this.a[i];
}
}
return null;
}
}
function FlowNodeClass( ctx) {
this.a = new FlowArray( ctx);
this.ctx = ctx;
this.nc_name = "";
this.group = 0;
this.draw = function( g, p, node, highlight) {
this.a.draw( g, p, node, highlight);
}
this.open = function( lines, row) {
var end = false;
for ( var i = row; i < lines.length; i++) {
var tokens = lines[i].split(' ');
var key = parseInt(tokens[0]);
if ( this.ctx.debug) console.log( "nodeclass : " + lines[i]);
switch ( key) {
case Flow.eSave_NodeClass_nc_name:
this.nc_name = tokens[1];
break;
case Flow.eSave_NodeClass_a:
i = this.a.open( lines, i+1);
break;
case Flow.eSave_NodeClass_group:
this.group = parseInt( tokens[1]);
break;
case Flow.eSave_NodeClass_no_con_obstacle:
break;
case Flow.eSave_End:
end = true;
break;
default:
console.log( "Syntax error in FlowNodeClass");
break;
}
if ( end)
break;
}
return i;
}
this.event_handler = function( x, y) {
return 0;
}
}
function FlowConClass( ctx) {
this.cc_name = "";
this.con_type = 0;
this.corner = 0;
this.draw_type = 0;
this.line_width = 0;
this.arrow_width = 0.0;
this.arrow_length = 0.0;
this.round_corner_amount = 0.0;
this.group = 0;
this.ctx = ctx;
this.open = function( lines, row) {
var end = false;
for ( var i = row; i < lines.length; i++) {
var tokens = lines[i].split(' ');
var key = parseInt(tokens[0]);
if ( this.ctx.debug) console.log( "conclass : " + lines[i]);
switch ( key) {
case Flow.eSave_ConClass:
break;
case Flow.eSave_ConClass_cc_name:
this.cc_name = tokens[1];
break;
case Flow.eSave_ConClass_con_type:
this.con_type = parseInt( tokens[1]);
break;
case Flow.eSave_ConClass_corner:
this.corner = parseInt( tokens[1]);
break;
case Flow.eSave_ConClass_draw_type:
this.draw_type = parseInt( tokens[1]);
break;
case Flow.eSave_ConClass_line_width:
this.line_width = parseInt( tokens[1]);
break;
case Flow.eSave_ConClass_arrow_width:
this.arrow_width = parseFloat( tokens[1]);
break;
case Flow.eSave_ConClass_arrow_length:
this.arrow_length = parseFloat( tokens[1]);
break;
case Flow.eSave_ConClass_round_corner_amount:
this.round_corner_amount = parseFloat( tokens[1]);
break;
case Flow.eSave_ConClass_group:
this.group = parseInt( tokens[1]);
break;
case Flow.eSave_End:
end = true;
break;
default:
console.log( "Syntax error in FlowConClass");
break;
}
if ( end)
break;
}
return i;
}
}
function FlowPoint( ctx) {
this.x = 0.0;
this.y = 0.0;
this.ctx = ctx;
this.open = function( lines, row) {
var end = false;
for ( var i = row; i < lines.length; i++) {
var tokens = lines[i].split(' ');
var key = parseInt(tokens[0]);
if ( this.ctx.debug) console.log( "point : " + lines[i]);
switch ( key) {
case Flow.eSave_Point:
break;
case Flow.eSave_Point_x:
this.x = parseFloat( tokens[1]);
break;
case Flow.eSave_Point_y:
this.y = parseFloat( tokens[1]);
break;
case Flow.eSave_End:
end = true;
break;
default:
System.out.println("Syntax error in FlowPoint");
break;
}
if ( end)
break;
}
return i;
}
}
function FlowLine( ctx) {
this.p1 = new FlowPoint(ctx);
this.p2 = new FlowPoint(ctx);
this.draw_type = 0;
this.line_width = 0;
this.ctx = ctx;
this.draw = function( g, p, node, highlight) {
var x1 = (this.p1.x + p.x) * this.ctx.zoom_factor;
var y1 = (this.p1.y + p.y) * this.ctx.zoom_factor;
var x2 = (this.p2.x + p.x) * this.ctx.zoom_factor;
var y2 = (this.p2.y + p.y) * this.ctx.zoom_factor;
g.lineWidth = this.ctx.zoom_factor / this.ctx.base_zoom_factor * this.line_width;
if ( g.lineWidth < 1)
g.lineWidth = 1;
switch ( this.draw_type) {
case Flow.eDrawType_LineDashed:
case Flow.eDrawType_LineDashedRed:
g.setLineDash([8,8]);
break;
}
switch ( this.draw_type) {
case Flow.eDrawType_LineGray:
g.strokeStyle = "lightgray";
break;
case Flow.eDrawType_LineRed:
case Flow.eDrawType_LineDashedRed:
g.strokeStyle = "red";
break;
case Flow.eDrawType_LineErase:
return;
default:
g.strokeStyle = "black";
}
if ( highlight)
g.strokeStyle = "red";
g.beginPath();
g.moveTo( x1, y1);
g.lineTo( x2, y2);
g.stroke();
switch ( this.draw_type) {
case Flow.eDrawType_LineDashed:
case Flow.eDrawType_LineDashedRed:
g.setLineDash([]);
break;
}
}
this.open = function( lines, row) {
var end = false;
for ( var i = row; i < lines.length; i++) {
var tokens = lines[i].split(' ');
var key = parseInt(tokens[0]);
if ( this.ctx.debug) console.log( "line : " + lines[i]);
switch ( key) {
case Flow.eSave_Line:
break;
case Flow.eSave_Line_draw_type:
this.draw_type = parseInt(tokens[1]);
break;
case Flow.eSave_Line_line_width:
this.line_width = parseInt(tokens[1]);
break;
case Flow.eSave_Line_p1:
i = this.p1.open( lines, i+1);
break;
case Flow.eSave_Line_p2:
i = this.p2.open( lines, i+1);
break;
case Flow.eSave_End:
end = true;
break;
default:
console.log( "Syntax error in FlowLine");
break;
}
if ( end)
break;
}
return i;
}
}
function FlowRect( ctx) {
this.ll = new FlowPoint(ctx);
this.ur = new FlowPoint(ctx);
this.draw_type = 0;
this.line_width = 0;
this.display_level = 0;
this.fill = 0;
this.ctx = ctx;
this.open = function( lines, row) {
var end = false;
for ( var i = row; i < lines.length; i++) {
var tokens = lines[i].split(' ');
var key = parseInt(tokens[0]);
if ( this.ctx.debug) console.log( "rect : " + lines[i]);
switch ( key) {
case Flow.eSave_Rect:
break;
case Flow.eSave_Rect_draw_type:
this.draw_type = parseInt(tokens[1]);
break;
case Flow.eSave_Rect_line_width:
this.line_width = parseInt(tokens[1]);
break;
case Flow.eSave_Rect_display_level:
this.display_level = parseInt(tokens[1]);
break;
case Flow.eSave_Rect_fill:
this.fill = parseInt(tokens[1]);
break;
case Flow.eSave_Rect_ll:
i = this.ll.open( lines, i+1);
break;
case Flow.eSave_Rect_ur:
i = this.ur.open( lines, i+1);
break;
case Flow.eSave_End:
end = true;
break;
default:
console.log( "Syntax error in FlowRect");
break;
}
if ( end)
break;
}
return i;
}
this.draw = function( g, p, node, highlight) {
if ( (this.display_level & this.ctx.display_level) == 0)
return;
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 = this.ctx.zoom_factor / this.ctx.base_zoom_factor * this.line_width;
if ( g.lineWidth < 1)
g.lineWidth = 1;
switch ( this.draw_type) {
case Flow.eDrawType_LineGray:
g.strokeStyle = "grey";
break;
case Flow.eDrawType_LineRed:
case Flow.eDrawType_LineDashedRed:
g.strokeStyle = "red";
break;
case Flow.eDrawType_LineErase:
return;
default:
g.strokeStyle = "black";
}
if ( highlight)
g.strokeStyle = "red";
g.strokeRect( x, y, width, height);
}
}
function FlowArc( ctx) {
this.ll = new FlowPoint(ctx);
this.ur = new FlowPoint(ctx);
this.angel1 = 0.0;
this.angel2 = 0.0;
this.draw_type = 0;
this.line_width = 0;
this.ctx = ctx;
this.draw = function( g, p, node, highlight) {
var r = (this.ur.x - this.ll.x) / 2 * this.ctx.zoom_factor;
var x = (this.ll.x + p.x) * this.ctx.zoom_factor + r;
var y = (this.ll.y + p.y) * this.ctx.zoom_factor + r;
if ( this.angel1 == 90 || this.angel1 == 270)
var a1 = (this.angel1 + 90)/ 180 * Math.PI;
else
var a1 = (this.angel1 - 90)/ 180 * Math.PI;
var a2 = a1 + this.angel2 / 180 * Math.PI;
g.lineWidth = this.ctx.zoom_factor / this.ctx.base_zoom_factor * this.line_width;
if ( g.lineWidth < 1)
g.lineWidth = 1;
g.strokeStyle = "black";
if ( highlight)
g.strokeStyle = "red";
g.beginPath()
g.arc( x, y, r, a1, a2, false);
g.stroke();
}
this.open = function( lines, row) {
var end = false;
for ( var i = row; i < lines.length; i++) {
var tokens = lines[i].split(' ');
var key = parseInt(tokens[0]);
if ( this.ctx.debug) console.log( "arc : " + lines[i]);
switch ( key) {
case Flow.eSave_Arc:
break;
case Flow.eSave_Arc_draw_type:
this.draw_type = parseInt(tokens[1]);
break;
case Flow.eSave_Arc_line_width:
this.line_width = parseInt(tokens[1]);
break;
case Flow.eSave_Arc_angel1:
this.angel1 = parseFloat(tokens[1]);
break;
case Flow.eSave_Arc_angel2:
this.angel2 = parseFloat(tokens[1]);
break;
case Flow.eSave_Arc_ll:
i = this.ll.open( lines, i+1);
break;
case Flow.eSave_Arc_ur:
i = this.ur.open( lines, i+1);
break;
case Flow.eSave_End:
end = true;
break;
default:
console.log( "Syntax error in FlowArc");
break;
}
if ( end)
break;
}
return i;
}
}
function FlowText( ctx) {
this.p = new FlowPoint(ctx);
this.draw_type = 0;
this.text_size = 0;
this.text = "";
this.ctx = ctx;
this.draw = function( g, p0, node, highlight) {
var tsize = 0;
var idx = this.ctx.zoom_factor / this.ctx.base_zoom_factor * (this.text_size +4) - 4;
if ( idx < 0) return;
var x = (this.p.x + p0.x) * this.ctx.zoom_factor;
var y = (this.p.y + p0.y) * this.ctx.zoom_factor;
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 = 8; break;
case 6: tsize = 18; break;
case 7: tsize = 18; break;
default: tsize = 3 * idx;
}
g.font = tsize + "px Arial";
g.lineWidth = 0.5;
g.fillStyle = "black";
if ( highlight)
g.fillStyle = "red";
g.fillText( this.text, x, y);
}
this.open = function( lines, row) {
var end = false;
for ( var i = row; i < lines.length; i++) {
var tokens = lines[i].split(' ');
var key = parseInt(tokens[0]);
if ( this.ctx.debug) console.log( "text : " + lines[i]);
switch ( key) {
case Flow.eSave_Text:
break;
case Flow.eSave_Text_text_size:
this.text_size = parseInt(tokens[1]);
break;
case Flow.eSave_Text_draw_type:
this.draw_type = parseInt(tokens[1]);
break;
case Flow.eSave_Text_text:
this.text = tokens[1];
break;
case Flow.eSave_Text_p:
i = this.p.open( lines, i+1);
break;
case Flow.eSave_End:
end = true;
break;
default:
console.log( "Syntax error in FlowText");
break;
}
if ( end)
break;
}
return i;
}
}
function FlowArrow( ctx) {
this.p1 = new FlowPoint(ctx);
this.p2 = new FlowPoint(ctx);
this.p_dest = new FlowPoint(ctx);
this.arrow_width = 0.0;
this.arrow_length = 0.0;
this.draw_type = 0;
this.line_width = 0;
this.ctx = ctx;
this.draw = function( g, p, node, highlight) {
var x1 = (this.p1.x + p.x) * this.ctx.zoom_factor;
var x2 = (this.p2.x + p.x) * this.ctx.zoom_factor;
var x3 = (this.p_dest.x + p.x) * this.ctx.zoom_factor;
var y1 = (this.p1.y + p.y) * this.ctx.zoom_factor;
var y2 = (this.p2.y + p.y) * this.ctx.zoom_factor;
var y3 = (this.p_dest.y + p.y) * this.ctx.zoom_factor;
switch ( this.draw_type) {
case Flow.eDrawType_LineGray:
g.fillStyle = "lightgray";
break;
case Flow.eDrawType_LineRed:
case Flow.eDrawType_LineDashedRed:
g.fillStyle = "red";
break;
case Flow.eDrawType_LineErase:
return;
default:
g.fillStyle = "black";
}
if ( highlight)
g.fillStyle = "red";
g.beginPath()
g.moveTo( x1, y1);
g.lineTo( x2, y2);
g.lineTo( x3, y3);
g.lineTo( x1, y1);
g.fill();
}
this.open = function( lines, row) {
var end = false;
for ( var i = row; i < lines.length; i++) {
var tokens = lines[i].split(' ');
var key = parseInt(tokens[0]);
if ( this.ctx.debug) console.log( "arrow : " + lines[i]);
switch ( key) {
case Flow.eSave_Arrow:
break;
case Flow.eSave_Arrow_arrow_width:
this.arrow_width = parseFloat( tokens[1]);
break;
case Flow.eSave_Arrow_arrow_length:
this.arrow_length = parseFloat( tokens[1]);
break;
case Flow.eSave_Arrow_draw_type:
this.draw_type = parseInt( tokens[1]);
break;
case Flow.eSave_Arrow_line_width:
this.line_width = parseInt( tokens[1]);
break;
case Flow.eSave_Arrow_p_dest:
i = this.p_dest.open( lines, i+1);
break;
case Flow.eSave_Arrow_p1:
i = this.p1.open( lines, i+1);
break;
case Flow.eSave_Arrow_p2:
i = this.p2.open( lines, i+1);
break;
case Flow.eSave_End:
end = true;
break;
default:
console.log( "Syntax error in FlowArrow");
break;
}
if ( end)
break;
}
}
}
function FlowTriangle( ctx) {
this.prototype = new FlowRect(ctx);
this.draw = function( g, p, node, highlight) {
var x1 = (this.prototype.ll.x + p.x) * this.prototype.ctx.zoom_factor;
var y1 = (this.prototype.ll.y + p.y) * this.prototype.ctx.zoom_factor;
var x2 = (this.prototype.ur.x + p.x) * this.prototype.ctx.zoom_factor;
var y2 = (this.prototype.ur.y + p.y) * this.prototype.ctx.zoom_factor;
g.lineWidth = this.prototype.ctx.zoom_factor / this.prototype.ctx.base_zoom_factor *
this.prototype.line_width;
if ( g.lineWidth < 1)
g.lineWidth = 1;
var dtype = this.prototype.draw_type;
if ( dtype == Flow.eDrawType_Inherit && node != null)
dtype = node.fill_color;
if ( this.prototype.fill == 1) {
switch ( dtype) {
case Flow.eDrawType_LineRed:
g.fillStyle = "red";
break;
case Flow.eDrawType_Green:
g.fillStyle = "green";
break;
case Flow.eDrawType_Yellow:
g.fillStyle = "yellow";
break;
default:
g.fillStyle = "gray";
}
g.beginPath();
g.moveTo( x1, y2);
g.lineTo( (x1 + x2) / 2, y1);
g.lineTo( x2, y2);
g.lineTo( x1, y2);
g.fill();
}
else {
g.strokeStyle = "black";
g.beginPath();
g.moveTo( x1, y2);
g.lineTo( (x1 + x2) / 2, y1);
g.lineTo( x2, y2);
g.lineTo( x1, y2);
g.stroke();
}
}
this.open = function( lines, row) {
var end = false;
for ( var i = row; i < lines.length; i++) {
var tokens = lines[i].split(' ');
var key = parseInt(tokens[0]);
if ( this.prototype.ctx.debug) console.log( "triangle : " + lines[i]);
switch ( key) {
case Flow.eSave_Triangle_rect_part:
i = this.prototype.open( lines, i+1);
break;
case Flow.eSave_End:
end = true;
break;
default:
console.log( "Syntax error in FlowTriangle");
break;
}
if ( end)
break;
}
return i;
}
}
function FlowConPoint( ctx) {
this.p = new FlowPoint( ctx);
this.number = 0;
this.direction = 0;
this.trace_attribute = "";
this.trace_attr_type = 0;
this.ctx = ctx;
this.draw = function( g, p, node, highlight) {
}
this.open = function( lines, row) {
var end = false;
for ( var i = row; i < lines.length; i++) {
var tokens = lines[i].split(' ');
var key = parseInt(tokens[0]);
if ( ctx.debug) console.log( "conpoint : " + lines[i]);
switch ( key) {
case Flow.eSave_ConPoint:
break;
case Flow.eSave_ConPoint_number:
this.number = parseInt(tokens[1]);
break;
case Flow.eSave_ConPoint_direction:
this.direction = parseInt(tokens[1]);
break;
case Flow.eSave_ConPoint_p:
i = this.p.open( lines, i+1);
break;
case Flow.eSave_ConPoint_trace_attribute:
this.trace_attribute = tokens[1];
break;
case Flow.eSave_ConPoint_trace_attr_type:
this.trace_attr_type = parseInt(tokens[1]);
break;
case Flow.eSave_End:
end = true;
break;
default:
console.log( "Syntax error in FlowConPoint");
break;
}
if ( end)
break;
}
return i;
}
}
function FlowAnnot( ctx) {
this.p = new FlowPoint(ctx);
this.draw_type = 0;
this.text_size = 0;
this.display_level = 0;
this.annot_type = 0;
this.number = 0;
this.ctx = ctx;
this.draw = function( g, p0, node, highlight) {
if ( node == null)
return;
if ( node.annotv[this.number] == null)
return;
if ( (this.display_level & this.ctx.display_level) == 0)
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;
}
switch ( this.draw_type) {
case Flow.eDrawType_TextHelveticaBold:
g.font = "bold " + tsize + "px Arial";
break;
default:
g.font = tsize + "px Arial";
}
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;
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;
}
}
this.open = function( lines, row) {
var end = false;
for ( var i = row; i < lines.length; i++) {
var tokens = lines[i].split(' ');
var key = parseInt(tokens[0]);
if ( this.ctx.debug) console.log( "annot : " + lines[i]);
switch ( key) {
case Flow.eSave_Annot:
break;
case Flow.eSave_Annot_number:
this.number = parseInt( tokens[1]);
break;
case Flow.eSave_Annot_draw_type:
this.draw_type = parseInt( tokens[1]);
break;
case Flow.eSave_Annot_text_size:
this.text_size = parseInt( tokens[1]);
break;
case Flow.eSave_Annot_display_level:
this.display_level = parseInt( tokens[1]);
break;
case Flow.eSave_Annot_p:
i = this.p.open( lines, i+1);
break;
case Flow.eSave_Annot_annot_type:
this.annot_type = parseInt( tokens[1]);
break;
case Flow.eSave_End:
end = true;
break;
default:
console.log( "Syntax error in FlowAnnot");
break;
}
if ( end)
break;
}
return i;
}
}
function FlowCon(ctx) {
this.ctx = ctx;
this.x_right = 0.0;
this.x_left = 0.0;
this.y_high = 0.0;
this.y_low = 0.0;
this.cc = null;
this.p_num = 0;
this.l_num = 0;
this.a_num = 0;
this.arrow_num = 0;
this.ref_num = 0;
this.point_x = new FlowArray(ctx);
this.point_y = new FlowArray(ctx);
this.line_a = new FlowArray(ctx);
this.arc_a = new FlowArray(ctx);
this.arrow_a = new FlowArray(ctx);
this.ref_a = new FlowArray(ctx);
this.c_name = "";
this.trace_object = "";
this.trace_attribute = "";
this.trace_attr_type = 0;
this.temporary_ref = 0;
this.highlight = false;
this.redraw = true;
this.draw = function( g, p0, node, highlight) {
if ( !this.redraw)
return;
var p = new FlowPoint(ctx);
p.x = 0;
p.y = 0;
if ( this.temporary_ref != 0 || this.cc.con_type == Flow.eConType_Reference)
this.ref_a.draw( g, p, null, highlight);
else {
this.line_a.draw( g, p, null, highlight);
this.arc_a.draw( g, p, null, highlight);
this.arrow_a.draw( g, p, null, highlight);
}
this.redraw = false;
}
this.open = function( lines, row) {
var end = false;
for ( var i = row; i < lines.length; i++) {
var tokens = lines[i].split(' ');
var key = parseInt(tokens[0]);
if ( this.ctx.debug) console.log( "con : " + lines[i]);
switch ( key) {
case Flow.eSave_Con:
break;
case Flow.eSave_Con_cc:
var cc_name = tokens[1];
var found = false;
for ( var j = 0; j < this.ctx.a_cc.size(); j++) {
if ( this.ctx.a_cc.get(j).cc_name === cc_name) {
this.cc = this.ctx.a_cc.get(j);
found = true;
break;
}
}
if ( !found)
console.log( "FlowCon: ConClass not found: " + cc_name);
break;
case Flow.eSave_Con_c_name:
if ( tokens[1] != null)
this.c_name = tokens[1];
break;
case Flow.eSave_Con_x_right:
this.x_right = parseFloat(tokens[1]);
break;
case Flow.eSave_Con_x_left:
this.x_left = parseFloat(tokens[1]);
break;
case Flow.eSave_Con_y_high:
this.y_high = parseFloat(tokens[1]);
break;
case Flow.eSave_Con_y_low:
this.y_low = parseFloat(tokens[1]);
break;
case Flow.eSave_Con_dest_node:
i++;
break;
case Flow.eSave_Con_source_node:
i++;
break;
case Flow.eSave_Con_dest_conpoint:
case Flow.eSave_Con_source_conpoint:
case Flow.eSave_Con_dest_direction:
case Flow.eSave_Con_source_direction:
break;
case Flow.eSave_Con_line_a:
i = this.line_a.open( lines, i+1);
break;
case Flow.eSave_Con_arc_a:
i = this.arc_a.open( lines, i+1);
break;
case Flow.eSave_Con_arrow_a:
i = this.arrow_a.open( lines, i+1);
break;
case Flow.eSave_Con_ref_a:
i = this.ref_a.open( lines, i+1);
break;
case Flow.eSave_Con_p_num:
this.p_num = parseInt(tokens[1]);
break;
case Flow.eSave_Con_l_num:
this.l_num = parseInt(tokens[1]);
break;
case Flow.eSave_Con_a_num:
this.a_num = parseInt(tokens[1]);
break;
case Flow.eSave_Con_arrow_num:
this.arrow_num = parseInt(tokens[1]);
break;
case Flow.eSave_Con_ref_num:
this.ref_num = parseInt(tokens[1]);
break;
case Flow.eSave_Con_point_x:
for ( var j = 0; j < this.p_num; j++) {
i++;
this.point_x[j] = parseFloat(lines[i]);
}
break;
case Flow.eSave_Con_point_y:
for ( var j = 0; j < this.p_num; j++) {
i++;
this.point_y[j] = parseFloat(lines[i]);
}
break;
case Flow.eSave_Con_source_ref_cnt:
case Flow.eSave_Con_dest_ref_cnt:
break;
case Flow.eSave_Con_trace_object:
if ( tokens[1] != null)
this.trace_object = tokens[1];
break;
case Flow.eSave_Con_trace_attribute:
if ( tokens[1] != null)
this.trace_attribute = tokens[1];
break;
case Flow.eSave_Con_trace_attr_type:
this.trace_attr_type = parseInt(tokens[1]);
break;
case Flow.eSave_Con_temporary_ref:
this.temporary_ref = parseInt(tokens[1]);
break;
case Flow.eSave_End:
end = true;
break;
default:
console.log( "Syntax error in FlowCon");
break;
}
if ( end)
break;
}
return i;
}
this.connect = function() {
}
this.scan = function() {
}
}
function FlowNode( ctx) {
this.ctx = ctx;
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 = null;
this.pos = new FlowPoint(ctx);
this.n_name = "";
this.annotv = [];
this.annotsize = [];
this.trace_object = "";
this.trace_attribute = "";
this.trace_attr_type = 0;
this.highlight = false;
this.select = false;
this.fill_color = 0;
this.p = 0;
this.old_value = 0;
this.first_scan = true;
this.redraw = true;
this.draw = function( g, p, node, highlight) {
if ( !this.redraw)
return;
if ( this.nc.group != Flow.eNodeGroup_Document) {
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.redraw = false;
}
this.open = function( lines, row) {
var end = false;
for ( var i = row; i < lines.length; i++) {
var tokens = lines[i].split(' ');
var key = parseInt(tokens[0]);
if ( this.ctx.debug) console.log( "node : " + lines[i]);
switch ( key) {
case Flow.eSave_Node_nc:
var nc_name = tokens[1];
var found = false;
for ( var j = 0; j < this.ctx.a_nc.size(); j++) {
if ( this.ctx.a_nc.get(j).nc_name === nc_name) {
this.nc = this.ctx.a_nc.get(j);
found = true;
break;
}
}
if ( !found)
console.log( "FlowNode: NodeClass not found: " + nc_name);
break;
case Flow.eSave_Node_n_name:
if ( tokens[1] != null)
this.n_name = tokens[1];
break;
case Flow.eSave_Node_refcon_cnt:
i += 32;
break;
case Flow.eSave_Node_x_right:
this.x_right = parseFloat(tokens[1]);
break;
case Flow.eSave_Node_x_left:
this.x_left = parseFloat(tokens[1]);
break;
case Flow.eSave_Node_y_high:
this.y_high = parseFloat(tokens[1]);
break;
case Flow.eSave_Node_y_low:
this.y_low = parseFloat(tokens[1]);
break;
case Flow.eSave_Node_annotsize:
for ( var j = 0; j < 10; j++) {
i++;
this.annotsize[j] = parseInt(lines[i]);
}
break;
case Flow.eSave_Node_annotv:
// Annotation are surrounded by quotes. A quote inside a
// annotation is preceeded by a backslash. The size is calculated
// without backslashes
for ( var j = 0; j < 10; j++) {
if ( this.annotsize[j] > 0) {
var sb = [];
var c = 0;
var prevc;
var end_found = false;
var first = true;
for ( ;;) {
i++;
if ( lines[i] == null) {
sb.push('\n');
continue;
}
for ( var k = 0; k < lines[i].length; k++) {
prevc = c;
c = lines[i].charAt(k);
if ( first) {
first = false;
continue;
}
if ( c === '\"' && prevc === '\\') {
sb[sb.length-1] = null;
continue;
}
if ( c === '\"') {
end_found = true;
break;
}
sb.push(c);
if ( k == lines[i].length - 1)
sb.push('\n');
}
if ( end_found)
break;
}
this.annotv[j] = sb.join("");
}
}
break;
case Flow.eSave_Node_pos:
i = this.pos.open( lines, i+1);
break;
case Flow.eSave_Node_trace_object:
if ( tokens[1] != null)
this.trace_object = tokens[1];
break;
case Flow.eSave_Node_trace_attribute:
if ( tokens[1] != null)
this.trace_attribute = tokens[1];
break;
case Flow.eSave_Node_trace_attr_type:
this.trace_attr_type = parseInt(tokens[1]);
break;
case Flow.eSave_Node_obst_x_right:
case Flow.eSave_Node_obst_x_left:
case Flow.eSave_Node_obst_y_high:
case Flow.eSave_Node_obst_y_low:
case Flow.eSave_Node_trace_inverted:
break;
case Flow.eSave_End:
end = true;
break;
default:
console.log( "Syntax error in FlowNode");
break;
}
if ( end)
break;
}
console.log("Node", this.trace_attr_type, this.n_name);
return i;
}
this.connect = function() {
if ( this.trace_object == "" || this.trace_attribute == "")
return;
if ( this.trace_attr_type == Flow.eTraceType_User)
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;
var pwr_type;
switch ( this.trace_attr_type) {
case Flow.eTraceType_Boolean:
pwr_type = Pwr.eType_Boolean;
break;
case Flow.eTraceType_Int32:
pwr_type = Pwr.eType_Int32;
break;
case Flow.eTraceType_Float32:
pwr_type = Pwr.eType_Float32;
break;
case Flow.eTraceType_User:
return;
}
this.p = this.ctx.gdh.refObjectInfo( o, pwr_type, 1);
console.log("connecting", o, this.p);
}
this.scan = function() {
if ( this.p == 0)
return;
var v1 = this.ctx.gdh.getObjectRefInfo( 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.redraw = true;
}
this.event_handler = function( x, y) {
var zx = x / this.ctx.zoom_factor + ctx.x_left;
var zy = y / this.ctx.zoom_factor + ctx.y_low;
if ( zx >= this.x_left && zx <= this.x_right &&
zy >= this.y_low && zy <= this.y_high) {
console.log("Hit in node");
if ( this.select) {
this.select = false;
this.redraw = true;
}
else {
this.ctx.set_select(false);
this.set_select(true);
}
console.log("Hit in", this.n_name);
return 1;
}
return 0;
}
this.set_select = function( select) {
if ( select != this.select) {
this.select = select;
this.redraw = true;
if ( this.select)
this.ctx.select_object = this;
else
this.ctx.select_object = null;
}
}
}
function FlowCtx() {
this.display_level = Flow.mDisplayLevel_1;
this.gdh = 0;
this.debug = false;
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 FlowArray(this);
this.a_nc = new FlowArray(this);
this.a_cc = new FlowArray(this);
this.name = "Claes context";
this.gdraw = new GDraw(this);
this.select_object = null;
this.draw = function() {
this.a.draw( this.gdraw.gctx, null, null, false);
}
this.open = function( lines, row) {
var end = false;
for ( var i = row; i < lines.length; i++) {
var tokens = lines[i].split(' ');
var key = parseInt(tokens[0]);
if ( this.debug) console.log( "ctx : " + lines[i]);
switch ( key) {
case Flow.eSave_Ctx:
break;
case Flow.eSave_Ctx_zoom_factor:
this.zoom_factor = parseFloat(tokens[1]);
break;
case Flow.eSave_Ctx_base_zoom_factor:
this.base_zoom_factor = parseFloat(tokens[1]);
break;
case Flow.eSave_Ctx_offset_x:
this.offset_x = parseInt(tokens[1]);
break;
case Flow.eSave_Ctx_offset_y:
this.offset_y = parseInt(tokens[1]);
break;
case Flow.eSave_Ctx_nav_zoom_factor:
case Flow.eSave_Ctx_print_zoom_factor:
case Flow.eSave_Ctx_nav_offset_x:
case Flow.eSave_Ctx_nav_offset_y:
break;
case Flow.eSave_Ctx_x_right:
this.x_right = parseFloat(tokens[1]);
break;
case Flow.eSave_Ctx_x_left:
this.x_left = parseFloat(tokens[1]);
break;
case Flow.eSave_Ctx_y_high:
this.y_high = parseFloat(tokens[1]);
break;
case Flow.eSave_Ctx_y_low:
this.y_low = parseFloat(tokens[1]);
break;
case Flow.eSave_Ctx_nav_rect_ll_x:
case Flow.eSave_Ctx_nav_rect_ll_y:
case Flow.eSave_Ctx_nav_rect_ur_x:
case Flow.eSave_Ctx_nav_rect_ur_y:
case Flow.eSave_Ctx_nav_rect_hot:
break;
case Flow.eSave_Ctx_name:
this.name = tokens[1];
break;
case Flow.eSave_Ctx_user_highlight:
case Flow.eSave_Ctx_grid_size_x:
case Flow.eSave_Ctx_grid_size_y:
case Flow.eSave_Ctx_grid_on:
case Flow.eSave_Ctx_draw_delta:
case Flow.eSave_Ctx_refcon_width:
case Flow.eSave_Ctx_refcon_height:
case Flow.eSave_Ctx_refcon_textsize:
case Flow.eSave_Ctx_refcon_linewidth:
case Flow.eSave_Ctx_user_version:
break;
case Flow.eSave_Ctx_a_nc:
i = this.a_nc.open( lines, i+1);
break;
case Flow.eSave_Ctx_a_cc:
i = this.a_cc.open( lines, i+1);
break;
case Flow.eSave_Ctx_a:
i = this.a.open( lines, i+1);
break;
case Flow.eSave_End:
end = true;
break;
default:
console.log( "Syntax error in FlowCtx", key);
}
if ( end)
break;
}
return i;
};
this.connect = function() {
console.log("ctx connect", this.a.size());
for ( var i = 0; i < this.a.size(); i++)
this.a.get(i).connect();
}
this.scan = function() {
for ( var i = 0; i < this.a.size(); i++)
this.a.get(i).scan();
}
this.event_handler = function( x, y) {
var sts = 0;
for ( var i = 0; i < this.a.size(); i++) {
if ( this.a.get(i) instanceof FlowNode) {
sts = this.a.get(i).event_handler( x, y);
if ( sts == 1)
break;
}
}
if ( sts == 1)
this.draw();
}
this.set_select = function( select) {
for ( var i = 0; i < this.a.size(); i++) {
if ( this.a.get(i) instanceof FlowNode)
this.a.get(i).set_select( select);
}
}
this.search_object = function( name) {
console.log("Searching for ", name);
var node = this.a.search_by_name( name);
if ( node != null)
console.log("Found", name);
return node;
}
this.center_object = function( o) {
console.log( "center_object", o.pos.x * this.zoom_factor + this.offset_x, window.innerWidth, o.pos.x * this.zoom_factor + this.offset_x- window.innerWidth / 2);
console.log( "center_object", o.pos.y * this.zoom_factor + this.offset_y, window.innerHeight, o.pos.y * this.zoom_factor + this.offset_y - window.innerHeight / 2);
window.scrollTo( o.pos.x * this.zoom_factor + this.offset_x - window.innerWidth / 2,
o.pos.y * this.zoom_factor + this.offset_y - window.innerHeight / 2 + this.gdraw.offset_top);
}
}
function FlowFrame() {
var self = this;
this.ctx = new FlowCtx();
this.timer = null;
console.log("ctx: ", this.ctx);
this.vars_object = null;
this.readFlowWeb = function( fname, read_cb) {
var n = window.location.href.lastIndexOf('/');
var target = window.location.href.substring(0,n+1);
target += fname;
console.log("Target: ", target);
var req = new XMLHttpRequest();
req.read_cb = read_cb;
req.open("GET", target, true);
req.addEventListener( "load", function() {
console.log("Done:", req.status);
var lines = req.responseText.split('\n');
req.read_cb( lines, 0);
});
req.send(null);
}
this.read_func = function( lines, row) {
console.log( "this.ctx:", self.ctx);
self.ctx.open( lines, row);
self.ctx.gdraw.canvas.addEventListener( "click", function( event) {
var y = event.pageY - self.ctx.gdraw.offset_top;
var x = event.pageX - 10; // Correction for left offset
console.log("Click", x, y);
self.ctx.event_handler( x, y);
});
document.getElementById("toolitem1").addEventListener( "click", function( event) {
console.log("toolitem3 event");
});
document.getElementById("toolitem2").addEventListener( "click", function( event) {
console.log("toolitem1 event, storage");
console.log("storage", localStorage.getItem("XttMethodNavigator"));
if ( self.ctx.select_object != null) {
localStorage.setItem("XttMethodNavigator", self.ctx.select_object.trace_object);
}
console.log("storage", localStorage.getItem("XttMethodNavigator"));
console.log("toolitem2 event window", window.opener);
window.opener.focus();
});
document.getElementById("toolitem3").addEventListener( "click", function( event) {
});
document.getElementById("toolitem4").addEventListener( "click", function( event) {
});
self.ctx.gdraw.canvas.width = (self.ctx.x_right - self.ctx.x_left) * self.ctx.zoom_factor;
self.ctx.gdraw.canvas.height = (self.ctx.y_high - self.ctx.y_low) * self.ctx.zoom_factor;
self.ctx.gdraw.gctx.translate( -self.ctx.x_left * self.ctx.zoom_factor, -self.ctx.y_low * self.ctx.zoom_factor);
self.ctx.offset_x -= self.ctx.x_left * self.ctx.zoom_factor;
self.ctx.offset_y -= self.ctx.y_low * self.ctx.zoom_factor;
self.ctx.draw();
console.log("New Gdh");
self.ctx.gdh = new Gdh( self.flow_open);
self.ctx.gdh.open_cb = self.flow_open;
self.ctx.gdh.close_cb = self.flow_close;
console.log( "ctx.gdh", self.ctx.gdh);
self.ctx.gdh.init();
if ( self.vars_object != null) {
var o = self.ctx.search_object( self.vars_object);
if ( o != null) {
self.ctx.center_object( o);
self.ctx.set_select(false);
o.set_select(true);
}
}
}
this.flow_open = function() {
console.log("flow_open");
console.log( "ctx.gdh", self.ctx.gdh);
self.ctx.connect();
self.ctx.gdh.refObjectInfoList( self.ctx.gdh.refObjectInfoListReply);
self.timer = setTimeout( self.flow_cyclic, 1000);
}
this.flow_scan = function() {
self.ctx.scan();
}
this.flow_cyclic = function() {
self.ctx.gdh.getRefObjectInfoAll( self.flow_scan);
self.ctx.draw();
self.timer = setTimeout( self.flow_cyclic, 1000);
}
this.flow_close = function() {
console.log("Close function", self.timer);
clearTimeout(self.timer);
for ( var i in self.ctx.gdh.pending)
delete self.ctx.gdh.pending[i];
}
this.get_filename = function() {
var query = window.location.search.substring(1);
console.log("query", query);
var vars = query.split('&');
console.log("vars", vars.length, vars[0].substring(4), vars[1].substring(4));
var vid = parseInt(vars[0].substring(4));
var oix = parseInt(vars[1].substring(4));
var avid = [];
var svid = [];
avid[0] = vid & 0xFF;
avid[1] = (vid >> 8) & 0xFF;
avid[2] = (vid >> 16) & 0xFF;
avid[3] = (vid >> 24) & 0xFF;
for ( var i = 0; i < 4; i++) {
svid[i] = avid[i].toString();
for ( var j = 0; j < 3; j++) {
if ( svid[i].length < 3)
svid[i] = "0" + svid[i];
}
}
var soix = oix.toString(16);
for ( var j = 0; j < 8; j++) {
if ( soix.length < 8)
soix = "0" + soix;
}
var fname = "pwr_" + svid[3] + "_" + svid[2] + "_" + svid[1] + "_" + svid[0] + "_" + soix + ".flw";
console.log( fname);
if ( vars.length > 2) {
this.vars_object = vars[2].substring(4);
console.log("vars object: ", this.vars_object);
}
return fname;
}
}
var frame = new FlowFrame();
// readFlow( "t.flw", read_func);
frame.readFlowWeb( frame.get_filename(), frame.read_func);
console.log( "eSave", Flow.eSave_Ctx);
include $(pwre_dir_symbols)
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(hw_name)/$(type_name)_generic.mk
ifeq ($($(type_name)_generic_mk),)
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(type_name)_generic.mk
endif
ifeq ($($(type_name)_generic_mk),)
include $(pwre_kroot)/tools/bld/src/$(type_name)_generic.mk
endif
-include ../../special.mk
-include ../special.mk
-include special.mk
<!DOCTYPE html>
<html>
<head>
<title>Ge graph</title>
<link rel="stylesheet" type="text/css" href="toolbar.css">
</head>
<body>
<!-- <div style="height:300px;overflow:auto;"> -->
<canvas id="flowcanvas" width="1200" height="800"></canvas>
<script src=ge.js></script>
<!-- </div> -->
<hr>
<address><a href="mailto:claes@debian86.ssab.com"></a></address>
</body>
</html>
This source diff could not be displayed because it is too large. You can view the blob instead.
include $(pwre_dir_symbols)
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(hw_name)/$(type_name)_generic.mk
ifeq ($($(type_name)_generic_mk),)
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(type_name)_generic.mk
endif
ifeq ($($(type_name)_generic_mk),)
include $(pwre_kroot)/tools/bld/src/$(type_name)_generic.mk
endif
-include ../../special.mk
-include ../special.mk
-include special.mk
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Operator window</title>
<link rel="stylesheet" type="text/css" href="toolbar.css">
<style>
.menu {
float:left;
width:20%;
height:100%;
}
.main {
float:left;
width:79%;
height:100%;
}
</style>
</head>
<body>
<iframe class="menu" src="opwind_menu.html"></iframe>
<iframe class="main" src="xtt_help_index.html"></iframe>
</body>
</html>
"use strict";
/** 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 **/
/** Pwr start **/
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 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;};
}
/** 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;
}
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
};
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
};
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:
value = dv.getUint8(j);
j += 1;
break;
case Pwr.eType_Float32:
if ( sub.elements <= 1) {
value = dv.getFloat32(j);
j += 4;
}
else {
if ( esize != sub.elements * 4)
console.log("Subscription size error", esize, sub.elements, eid);
value = new Array(sub.elements);
for ( var k = 0; k < sub.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_Mask:
case Pwr.eType_Enum:
value = 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:
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);
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: {
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 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;
}
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);
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.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++;
};
}
/** End Gdh **/
/** Start OpWind **/
function OpWindMenu() {
this.gdh = 0;
this.buttons = null;
this.priv = 0;
this.user = "";
this.user_text = null;
this.host;
var self = this;
this.init = function() {
this.host = window.location.hostname;
if ( this.host == "")
this.host = "localhost";
this.gdh = new Gdh();
this.gdh.open_cb = this.gdh_init_cb;
this.gdh.init();
};
this.is_authorized = function( access) {
return ( this.priv & access) ? true : false;
}
this.get_opplace = function() {
var query = window.location.search.substring(1);
console.log("query", query);
var vars = query.split('&');
console.log("vars", vars.length, vars[0].substring(8));
return vars[0].substring(8);
};
this.gdh_init_cb = function() {
var oid = new PwrtObjid( 0, 0);
self.user = "Default";
self.gdh.login( "", "", self.login_cb, self);
self.gdh.getOpwindMenu( self.get_opplace(), self.get_menu_cb, 999);
};
this.add_menu_button = function( context, text) {
var button = document.createElement( "input");
button.type = "button";
button.className = "leftmenu-button";
button.value = text;
button.addEventListener( 'click', new Function( "menu.button_cb(\"" + button.value + "\")"));
context.appendChild( button);
context.appendChild( document.createElement( "br"));
return button;
};
this.get_menu_cb = function( id, data, sts, result) {
self.info = result;
console.log( "Menu received", sts, data, result.buttons.length);
var context = document.getElementById("opwindmenu");
var header = document.createElement("H1");
var title = document.createTextNode( result.title);
header.appendChild( title);
context.appendChild( header);
var text = document.createTextNode( result.text);
context.appendChild( text);
context.appendChild( document.createElement( "hr"));
self.user_text = document.createTextNode( self.user + " on " + self.host);
context.appendChild( self.user_text);
context.appendChild( document.createElement( "hr"));
if ( result.enable_language)
self.add_menu_button( context, "Language");
if ( result.enable_login)
self.add_menu_button( context, "Login");
if ( result.enable_alarmlist)
self.add_menu_button( context, "AlarmList");
if ( result.enable_eventlog)
self.add_menu_button( context, "EventLog");
if ( result.enable_navigator)
self.add_menu_button( context, "Navigator");
if ( !result.disable_help)
self.add_menu_button( context, "Help");
if ( !result.disable_proview)
self.add_menu_button( context, "ProviewR");
context.appendChild( document.createElement( "hr"));
var button;
for ( var i = 0; i < result.buttons.length; i++) {
console.log( "Child", result.buttons[i].name);
self.add_menu_button( context, result.buttons[i].text);
}
};
this.button_cb = function( text) {
if ( self.info.enable_language && text == "Language") {
console.log("Language activated");
}
else if ( self.info.enable_login && text == "Login") {
console.log("Login activated");
var user = prompt( "Username");
var passwd = prompt( "Password");
var c = new JopCrypt();
passwd = c.crypt( "aa", passwd);
console.log( "Login", user, passwd);
self.user = user;
self.gdh.login( user, passwd, self.login_cb, self);
}
else if ( self.info.enable_alarmlist && text == "AlarmList") {
console.log("AlarmList activated");
if ( !(self.is_authorized( Pwr.mAccess_RtRead | Pwr.mAccess_RtWrite |
Pwr.mAccess_AllOperators |
Pwr.mAccess_System | Pwr.mAccess_Maintenance |
Pwr.mAccess_Process | Pwr.mAccess_Instrument)))
window.alert("Not authorized for this operation");
else
window.alert("Not yet implemented");
}
else if ( self.info.enable_eventlog && text == "EventLog") {
console.log("EventLog activated");
if ( !(self.is_authorized( Pwr.mAccess_RtRead | Pwr.mAccess_RtWrite |
Pwr.mAccess_AllOperators |
Pwr.mAccess_System | Pwr.mAccess_Maintenance |
Pwr.mAccess_Process | Pwr.mAccess_Instrument)))
window.alert("Not authorized for this operation");
else
window.alert("Not yet implemented");
}
else if ( self.info.enable_navigator && text == "Navigator") {
console.log("Navigator activated");
if ( !(self.is_authorized( Pwr.mAccess_RtNavigator |
Pwr.mAccess_System | Pwr.mAccess_Maintenance |
Pwr.mAccess_Process | Pwr.mAccess_Instrument)))
window.alert("Not authorized for this operation");
else
window.open( "xtt.html", "_blank");
}
else if ( !self.info.disable_help && text == "Help") {
console.log("Help activated");
window.open( "xtt_help_index.html", "_blank");
}
else if ( !self.info.disable_proview && text == "ProviewR") {
console.log("ProviewR activated");
window.open( "http://www.proview.se", "_blank");
}
else {
if ( !(self.is_authorized( Pwr.mAccess_RtRead | Pwr.mAccess_RtWrite |
Pwr.mAccess_AllOperators |
Pwr.mAccess_System | Pwr.mAccess_Maintenance |
Pwr.mAccess_Process | Pwr.mAccess_Instrument)))
window.alert("Not authorized for this operation");
else {
for ( var i = 0; i < self.info.buttons.length; i++) {
if ( self.info.buttons[i].text == text) {
console.log("Found", self.info.buttons[i].text);
var name = self.info.buttons[i].name;
var n = name.indexOf(".pwg");
if ( n != -1)
name = name.substring(0,n);
var url = "ge.html?graph=" + name;
console.log("url", url);
window.open( url, "_blank");
break;
}
}
}
}
};
this.login_cb = function( id, data, sts, result) {
console.log( "Login:", sts, result);
if ( sts & 1) {
self.priv = result;
sessionStorage.setItem("pwr_privilege", self.priv);
if ( self.user_text != null)
self.user_text.textContent = self.user + " on " + self.host;
console.log( "sessionStorage set");
}
else {
self.priv = 0;
self.user = "none";
console.log("user_text", self.user_text);
if ( self.user_text != null)
self.user_text.textContent = "None on " + self.host;
}
};
}
var menu = new OpWindMenu();
menu.init();
/** End OpWind **/
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Xtt</title>
<link rel="stylesheet" type="text/css" href="toolbar.css">
</head>
<body>
<div id="opwindmenu" width="120" height="800"></div>
<script src=opwind.js></script>
<hr>
<address><a href="mailto:claes@debian86.ssab.com"></a></address>
</body>
</html>
include $(pwre_dir_symbols)
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(hw_name)/$(type_name)_generic.mk
ifeq ($($(type_name)_generic_mk),)
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(type_name)_generic.mk
endif
ifeq ($($(type_name)_generic_mk),)
include $(pwre_kroot)/tools/bld/src/$(type_name)_generic.mk
endif
-include ../../special.mk
-include ../special.mk
-include special.mk
include $(pwre_dir_symbols)
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(hw_name)/$(type_name)_generic.mk
ifeq ($($(type_name)_generic_mk),)
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(type_name)_generic.mk
endif
ifeq ($($(type_name)_generic_mk),)
include $(pwre_kroot)/tools/bld/src/$(type_name)_generic.mk
endif
-include ../../special.mk
-include ../special.mk
-include special.mk
.annotate {
color: #366ED4;
font-style: italic;
}
.toolbar {
border-left: 1px solid #aaa;
margin-top: 10px;
margin: 0 0 0 0;
font-size: 0;
}
.toolbar-item {
display: inline-block;
padding: 0.0em 0.0em;
background: #fff;
margin: 0 0 0 0;
border: 0px solid #aaa;
border-left: none;
color: blue;
font-size: 16px;
line-height: 1.5em;
vertical-align: top;
}
.toolbar-item.selected {
background-color: #ccc;
color: black;
font-weight: bold;
}
.menu-wrapper {
display: inline-block;
font-size: 16px;
}
.menu-button {
padding-right: 2.5em;
position: relative;
}
.menu-button::after {
content: " ";
border-left: 0.4em solid transparent;
border-right: 0.4em solid transparent;
border-top: 0.4em solid black;
position: absolute;
right: 1em;
top: 1.1em;
}
.leftmenu-button {
width:100%;
}
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<title>Xtt</title>
<link rel="stylesheet" type="text/css" href="toolbar.css">
</head>
<body>
<div class="toolbar" role="toolbar">
<div id="toolitem1" tabindex="0" class="toolbar-item" role="button"><img src="toolbar_graph.png"><img></div>
<div id="toolitem2" tabindex="-1" class="toolbar-item" role="button"><img src="toolbar_plc.png"><img></div>
<div id="toolitem3" tabindex="-1" class="toolbar-item" role="button"><img src="toolbar_history.png"><img></div>
<div id="toolitem4" tabindex="-1" class="toolbar-item" role="button"><img src="toolbar_object.png"><img></div>
<div id="toolitem5" tabindex="-1" class="toolbar-item" role="button"><img src="toolbar_crossref.png"><img></div>
<div id="toolitem6" tabindex="-1" class="toolbar-item" role="button"><img src="toolbar_help.png"><img></div>
<div id="toolitem7" tabindex="-1" class="toolbar-item" role="button"><img src="toolbar_classhelp.png"><img></div>
</div>
<!-- <div style="height:300px;overflow:auto;"> -->
<canvas id="flowcanvas" width="1200" height="800"></canvas>
<script src=xtt.js></script>
<!-- </div> -->
<hr>
<address><a href="mailto:claes@debian86.ssab.com"></a></address>
</body>
</html>
"use strict";
/** Pwr start **/
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 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;};
}
function UserdataCbReturn() {
this.userdata;
this.row;
}
/** 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 **/
/** 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;
}
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
};
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
};
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:
value = dv.getUint8(j);
j += 1;
break;
case Pwr.eType_Float32:
if ( sub.elements <= 1) {
value = dv.getFloat32(j);
j += 4;
}
else {
if ( esize != sub.elements * 4)
console.log("Subscription size error", esize, sub.elements, eid);
value = new Array(sub.elements);
for ( var k = 0; k < sub.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_Mask:
case Pwr.eType_Enum:
value = 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:
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);
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: {
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 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;
console.log( "Opmenu", result.title, result.text, result.enable_language,
result.enable_login, result.enable_alarmlist, result.enable_eventlog,
result.enable_navigator, result.disable_help, result.disable_proview, result.language, bsize);
console.log("Opmenu buttons size", bsize);
for ( var i = 0; i < bsize; i++) {
var button = new MenuButton();
button.type = dv.getUint32(j);
j += 4;
nsize = dv.getUint16(j);
j += 2;
console.log( "text size", button.type, nsize);
iarr = new Uint8Array( nsize);
for ( var k = 0; k < nsize; k++) {
console.log("Button.text", j);
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);
console.log("Button", button.text, button.name, button.url);
}
}
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;
}
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);
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.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++;
};
}
/** 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,
img : [ 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],
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']
};
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 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.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.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;
}
}
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 ( 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_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.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.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_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 **/
function XttOpenChildrenData( node, open_next) {
this.node = node;
this.open_next = open_next;
}
function Xtt() {
this.ctx = null;
this.ncObject = null;
this.scan_update;
this.priv = 0;
var self = this;
this.init = function() {
this.priv = sessionStorage.getItem("pwr_privilege");
console.log("pwr_privilege" ,this.priv);
this.methods_init();
this.ctx = new PlowCtx();
this.ctx.event_cb = this.plow_event;
this.createNodeClasses();
this.ctx.gdh = new Gdh();
this.ctx.gdh.open_cb = this.gdh_init_cb;
this.ctx.gdh.init()
this.ctx.gdraw.canvas.addEventListener( "click", function( event) {
var y = event.pageY - self.ctx.gdraw.offset_top;
var x = event.pageX;
if ( event.shiftKey)
xtt.ctx.event_handler( Plow.eEvent_MB1ClickShift, x, y);
else
xtt.ctx.event_handler( Plow.eEvent_MB1Click, x, y);
});
document.addEventListener( "keydown", function( event) {
if ( event.keyCode == 40) {
self.ctx.event_handler( Plow.eEvent_Key_Down);
event.preventDefault();
}
else if ( event.keyCode == 39) {
if ( event.shiftKey)
self.ctx.event_handler( Plow.eEvent_Key_ShiftRight);
else
self.ctx.event_handler( Plow.eEvent_Key_Right);
event.preventDefault();
}
else if ( event.keyCode == 37) {
self.ctx.event_handler( Plow.eEvent_Key_Left);
event.preventDefault();
}
else if ( event.keyCode == 38) {
self.ctx.event_handler( Plow.eEvent_Key_Up);
event.preventDefault();
}
else if ( event.keyCode == 82) {
if ( event.ctrlKey)
self.ctx.event_handler( Plow.eEvent_Key_CtrlR);
event.preventDefault();
}
else if ( event.keyCode == 76) {
if ( event.ctrlKey)
self.ctx.event_handler( Plow.eEvent_Key_CtrlL);
event.preventDefault();
}
else if ( event.keyCode == 71) {
if ( event.ctrlKey)
self.ctx.event_handler( Plow.eEvent_Key_CtrlG);
event.preventDefault();
}
});
document.getElementById("toolitem1").addEventListener( "click", function( event) {
});
document.getElementById("toolitem2").addEventListener( "click", function( event) {
console.log("toolitem1 event");
var o = self.ctx.get_select();
var newwindow = window.open("", "_blank");
self.ctx.gdh.getObject( o.userdata.objid, GdhOp.GET_OP_METHOD_PLC, self.open_plc_cb, newwindow);
console.log("toolitem2 event");
});
document.getElementById("toolitem3").addEventListener( "click", function( event) {
console.log("toolitem3 event");
});
document.getElementById("toolitem4").addEventListener( "click", function( event) {
console.log("toolitem4 event");
var o = self.ctx.get_select();
if ( o == null)
return;
var item = o.userdata;
item.open_attributes( self);
});
document.getElementById("toolitem5").addEventListener( "click", function( event) {
var o = self.ctx.get_select();
self.ctx.gdh.crrSignal( o.userdata.objid, self.open_crr_cb, o);
console.log("toolitem5 event");
});
document.getElementById("toolitem6").addEventListener( "click", function( event) {
console.log("toolitem6 event");
});
document.getElementById("toolitem7").addEventListener( "click", function( event) {
console.log("toolitem7 event");
var o = self.ctx.get_select();
if ( o == null)
return;
if ( o.userdata instanceof XttItemObject) {
var newwindow = window.open("", "_blank");
self.ctx.gdh.getObject( o.userdata.objid, GdhOp.GET_OP_SELF, self.open_helpclass_cb, newwindow);
}
});
window.addEventListener( "storage", function( event) {
if ( event.newValue == "")
return;
localStorage.setItem( "XttMethodNavigator", "");
self.display_object( event.newValue);
});
}
this.is_authorized = function( access) {
return ( this.priv & access) ? true : false;
}
this.gdh_init_cb = function() {
if ( self.priv == null)
self.ctx.gdh.login( "", "", self.login_cb, self);
var oid = new PwrtObjid( 0, 0);
self.ctx.gdh.getAllXttChildren( oid, self.open_children_cb, new XttOpenChildrenData(null,null));
self.ctx.gdh.listSent = true;
self.trace_cyclic();
}
this.login_cb = function( id, data, sts, result) {
console.log( "Login:", sts, result);
if ( sts & 1)
self.priv = result;
else
self.priv = 0;
};
this.open_children_cb = function( id, data, sts, result) {
self.ctx.set_nodraw();
for ( var i = 0; i < result.length; i++) {
if ( data.node == null) {
result[i].full_name = result[i].name;
new XttItemObject( self, result[i], null, Plow.DEST_AFTER);
}
else {
result[i].full_name = data.node.userdata.full_name + "-" + result[i].name;
new XttItemObject( self, result[i], data.node, Plow.DEST_INTOLAST);
}
}
self.ctx.configure();
if ( data.open_next != null) {
if ( data.open_next.length == 0) {
self.ctx.reset_nodraw();
return;
}
var child = self.ctx.a.get_first_child( data.node);
while ( child != null) {
if ( child.userdata.name == data.open_next[0]) {
if ( data.open_next.length == 1) {
child.set_select( true);
child.set_invert( true);
if ( !self.ctx.is_visible( child))
self.ctx.scroll( child.y_low, 0.50);
window.focus(); // Doesn't work
}
else {
data.open_next.splice( 0, 1);
child.userdata.open_children( self, data.open_next);
}
break;
}
child = self.ctx.a.get_next_sibling( child);
}
}
self.ctx.reset_nodraw();
self.ctx.draw();
}
this.open_attributes_cb = function( id, node, sts, result) {
self.ctx.set_nodraw();
for ( var i = 0; i < result.length; i++) {
result[i].objid = node.userdata.objid;
result[i].full_name = node.userdata.full_name + "." + result[i].name;
if ( (result[i].flags & Pwr.mAdef_array) != 0)
new XttItemAttrArray( self, result[i], node, Plow.DEST_INTOLAST);
else if ( (result[i].flags & Pwr.mAdef_class) != 0)
new XttItemAttrObject( self, result[i], node, Plow.DEST_INTOLAST);
else
new XttItemAttr( self, result[i], node, Plow.DEST_INTOLAST);
}
self.ctx.configure();
self.ctx.reset_nodraw();
self.ctx.draw();
}
this.open_plc_cb = function( id, data, sts, result) {
if ( (sts & 1) != 0) {
data.location.href = "flow.html?vid=" + result.objid.vid + "&oix=" + result.objid.oix;
data.document.title = "Trace " + result.fullname;
}
else
data.document.write("Error status " + sts);
}
this.open_objectgraph_cb = function( id, data, sts, result) {
if ( (sts & 1) != 0) {
var graphname = "pwr_c_" + result.classname.toLowerCase();
data.location.href = "ge.html?graph=" + graphname + "&instance=" + result.fullname;
data.document.title = graphname + " " + result.fullname;
}
else
data.document.write("Error status " + sts);
}
this.open_crr_cb = function( id, node, sts, crrdata) {
if ( (sts & 1) == 0) {
return;
}
node.userdata.open_crossreferences( self, crrdata);
}
this.open_helpclass_cb = function( id, data, sts, result) {
if ( (sts & 1) != 0) {
var url = location.protocol + "//" + location.host + "/pwr_doc/en_us/orm/pwrb_" + result.classname.toLowerCase() + ".html";
data.location.href = url;
}
else
data.document.write("Error status " + sts);
}
this.plow_event = function( event, object, x, y) {
var item = null;
if ( object != null)
item = object.get_userdata();
switch ( event) {
case Plow.eEvent_ObjectDeleted:
console.log("Object deleted cb");
if ( object.userdata instanceof XttItemAttr) {
console.log("Object deleted cb XttItemAttr");
object.userdata.scan_close( self);
}
break;
case Plow.eEvent_MB1Click:
if ( object.in_icon( x, y)) {
item.open_children( self, null);
}
else {
if ( object.select) {
object.set_select(false);
object.set_invert(false);
}
else {
self.ctx.set_select(false);
object.set_select(true);
self.ctx.set_invert(false);
object.set_invert(true);
self.ctx.draw();
}
}
break;
case Plow.eEvent_MB1ClickShift:
if ( object.in_icon( x, y)) {
item.open_attributes( self);
}
break;
case Plow.eEvent_Key_Down: {
var o = self.ctx.get_select();
if ( o != null) {
var next = self.ctx.get_next_object( o);
if ( next != null) {
o.set_select(false);
o.set_invert(false);
next.set_select(true);
next.set_invert(true);
if ( !self.ctx.is_visible( next))
self.ctx.scroll( next.y_low, 0.10);
}
}
else {
o = self.ctx.a.a[0];
o.set_select(true);
o.set_invert(true);
}
break;
}
case Plow.eEvent_Key_Up: {
var o = self.ctx.get_select();
if ( o != null) {
var next = self.ctx.get_previous_object( o);
if ( next != null) {
o.set_select(false);
o.set_invert(false);
next.set_select(true);
next.set_invert(true);
o.draw( self.ctx.gdraw.gctx, null, null, 0);
next.draw( self.ctx.gdraw.gctx, null, null, 0);
if ( !self.ctx.is_visible( next))
self.ctx.scroll( next.y_low, 0.90);
}
}
break;
}
case Plow.eEvent_Key_Right: {
var o = self.ctx.get_select();
if ( o != null) {
item = o.userdata;
item.open_children( self, null);
}
break;
}
case Plow.eEvent_Key_Left: {
var o = self.ctx.get_select();
if ( o != null) {
item = o.userdata;
item.close( self);
}
break;
}
case Plow.eEvent_Key_ShiftRight: {
var o = self.ctx.get_select();
if ( o != null) {
item = o.userdata;
item.open_attributes( self);
}
break;
}
case Plow.eEvent_Key_CtrlR: {
var o = self.ctx.get_select();
if ( o != null)
self.ctx.gdh.crrSignal( o.userdata.objid, self.open_crr_cb, o);
break;
}
case Plow.eEvent_Key_CtrlL: {
var o = self.ctx.get_select();
if ( o.userdata instanceof XttItemObject) {
var newwindow = window.open("", "_blank");
self.ctx.gdh.getObject( o.userdata.objid, GdhOp.GET_OP_METHOD_PLC, self.open_plc_cb, newwindow);
}
else if ( o.userdata instanceof XttItemCrr) {
var idx = o.userdata.name.lastIndexOf('-');
var ostring = "";
if ( idx != -1) {
ostring = "&obj=" + o.userdata.name.substring(idx+1);
}
window.open("flow.html?vid=" + o.userdata.objid.vid + "&oix=" + o.userdata.objid.oix + ostring);
}
break;
}
case Plow.eEvent_Key_CtrlG: {
var o = self.ctx.get_select();
if ( o.userdata instanceof XttItemObject) {
var newwindow = window.open("", "_blank");
console.log("CtrlG", newwindow);
self.ctx.gdh.getObject( o.userdata.objid, GdhOp.GET_OP_METHOD_PLC, self.open_objectgraph_cb, newwindow);
}
break;
}
}
}
this.createNodeClasses = function() {
var r1 = new PlowRect( this.ctx, 0, 0, 50, 1.0, Plow.COLOR_WHITE, Plow.COLOR_WHITE, true, false);
var a1 = new PlowAnnot(this.ctx, 3, 0.9, 4, Plow.COLOR_BLACK, Plow.NEXT_RELATIVE_POSITION, 0);
var a11 = new PlowAnnot(this.ctx, 7.5, 0.9, 4, Plow.COLOR_BLACK, Plow.RELATIVE_POSITION, 1);
var a12 = new PlowAnnot(this.ctx, 12, 0.9, 4, Plow.COLOR_BLACK, Plow.RELATIVE_POSITION, 2);
var p1 = new PlowAnnotPixmap(this.ctx, 0.4, 0.2 , 0);
this.ncObject = new PlowNodeClass( this.ctx);
this.ncObject.insert(r1);
this.ncObject.insert(a1);
this.ncObject.insert(a11);
this.ncObject.insert(a12);
this.ncObject.insert(p1);
this.ctx.insert_nc( this.ncObject);
}
this.methods_init = function() {
localStorage.setItem("XttMethodNavigator", "");
}
this.collapse = function() {
this.ctx.set_nodraw();
for ( var i = 0; i < this.ctx.a.size(); i++) {
var node = this.ctx.a.get(i);
if ( node.level == 0)
node.userdata.close( this);
}
this.ctx.reset_nodraw();
this.ctx.draw();
}
this.display_object = function( name) {
var i = name.indexOf('.');
if ( i != -1)
name = name.substring(0,i);
var path = name.split('-');
var idx = 0;
this.collapse();
for ( var j = idx; j < this.ctx.a.size(); j++) {
if ( this.ctx.a.get(j).userdata.name == path[0]) {
if ( j == this.ctx.a.size() - 1) {
var node = this.ctx.a.get(j);
node.set_select( true);
node.set_invert( true);
if ( !this.ctx.is_visible( node))
this.ctx.scroll( node.y_low, 0.50);
window.focus(); // Doesn't work
}
else {
path.splice( 0, 1);
this.ctx.a.get(j).userdata.open_children( this, path);
}
break;
}
}
}
this.trace_cyclic = function() {
self.ctx.gdh.getRefObjectInfoAll( self.trace_scan);
};
this.trace_scan = function( id, sts) {
self.scan_update = false;
for ( var i = 0; i < self.ctx.a.size(); i++) {
var item = self.ctx.a.get(i).userdata;
if ( item instanceof XttItemAttr) {
item.scan( self);
}
}
if ( self.scan_update)
self.ctx.draw();
self.timer = setTimeout( self.trace_cyclic, 1000);
};
this.openValueInputDialog = function( item, text) {
console.log( "priv acc", this.priv, Pwr.mAccess_RtWrite | Pwr.mAccess_System);
if ( this.is_authorized( Pwr.mAccess_RtWrite | Pwr.mAccess_System)) {
var value = prompt( text, "");
if ( value !== null)
item.set_value( this, value);
}
else
alert( "Not authorized for this operation");
};
}
function XttItemObject( xtt, object_info, destination, destCode) {
this.objid = object_info.objid;
this.cid = object_info.cid;
this.name = object_info.name;
this.full_name = object_info.full_name;
this.has_children = object_info.has_children;
this.node = new PlowNode(xtt.ctx, xtt.ncObject, 0);
this.node.set_userdata(this);
this.node.set_annotation( 0, object_info.name);
this.node.set_annotation( 1, object_info.classname);
this.node.set_annotation( 2, object_info.description);
this.node.set_annotation_pixmap( 0, Bitmaps.map);
xtt.ctx.insertNode( this.node, destination, destCode);
if ( object_info.has_children)
this.node.set_annotation_pixmap( 0, Bitmaps.map);
else
this.node.set_annotation_pixmap( 0, Bitmaps.leaf);
this.open_children = function( xtt, open_next) {
if ( this.node.node_open != 0)
this.close( xtt);
else if ( !this.has_children)
this.open_attributes( xtt);
else {
xtt.ctx.gdh.getAllXttChildren( this.objid, xtt.open_children_cb, new XttOpenChildrenData(this.node,open_next));
this.node.node_open |= Plow.OPEN_CHILDREN;
this.node.set_annotation_pixmap( 0, Bitmaps.openmap);
}
}
this.open_attributes = function( xtt) {
if ( this.node.node_open != 0)
this.close( xtt);
else {
xtt.ctx.gdh.getAllClassAttributes( this.cid, this.objid, xtt.open_attributes_cb, this.node)
this.node.node_open |= Plow.OPEN_ATTRIBUTES;
xtt.ctx.configure();
xtt.ctx.draw();
}
}
this.open_crossreferences = function( xtt, crrdata) {
if ( this.node.node_open != 0)
this.close( xtt);
else {
for ( var i = 0; i < crrdata.length; i++) {
new XttItemCrr( xtt, crrdata[i], this.node, Plow.DEST_INTOLAST);
}
this.node.node_open |= Plow.OPEN_CROSSREFERENCES;
xtt.ctx.configure();
xtt.ctx.draw();
}
}
this.close = function( xtt) {
if ( this.node.node_open & Plow.OPEN_CHILDREN) {
xtt.ctx.close_node( this.node);
this.node.node_open &= ~Plow.OPEN_CHILDREN;
this.node.set_annotation_pixmap( 0, Bitmaps.map);
xtt.ctx.configure();
xtt.ctx.draw();
}
else if ( this.node.node_open & Plow.OPEN_ATTRIBUTES) {
xtt.ctx.close_node( this.node);
this.node.node_open &= ~Plow.OPEN_ATTRIBUTES;
xtt.ctx.configure();
xtt.ctx.draw();
}
else if ( this.node.node_open & Plow.OPEN_CROSSREFERENCES) {
xtt.ctx.close_node( this.node);
this.node.node_open &= ~Plow.OPEN_CROSSREFERENCES;
xtt.ctx.configure();
xtt.ctx.draw();
}
else {
var parent = xtt.ctx.get_parent_object( this.node);
if ( parent != null) {
parent.userdata.close(xtt);
parent.set_select( true);
parent.set_invert( true);
}
}
}
}
function XttItemAttr( xtt, info, destination, destCode) {
this.name = info.name;
this.objid = info.objid;
this.full_name = info.full_name;
this.type = info.type;
this.flags = info.flags;
this.size = info.size;
this.refid;
this.firstScan = true;
this.old_value;
this.node = new PlowNode(xtt.ctx, xtt.ncObject, 0);
this.node.set_userdata(this);
this.node.set_annotation( 0, this.name);
this.node.set_annotation_pixmap( 0, Bitmaps.attr);
xtt.ctx.insertNode( this.node, destination, destCode);
console.log("Attr refObjectInfo", this.full_name, info.type);
this.refid = xtt.ctx.gdh.refObjectInfo( this.full_name, info.type, 1);
this.open_children = function( xtt, open_next) {
xtt.openValueInputDialog( this, "Enter value");
};
this.set_value = function( xtt, value) {
var sts;
switch ( this.type) {
case Pwr.eType_Float32:
var inputValue = parseFloat( value.trim());
sts = xtt.ctx.gdh.setObjectInfoFloat( this.full_name, inputValue);
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_Mask:
case Pwr.eType_Enum:
case Pwr.eType_Boolean:
var inputValue = parseInt( value.trim(), 10);
sts = xtt.ctx.gdh.setObjectInfoInt( this.full_name, inputValue);
break;
case Pwr.eType_String:
case Pwr.eType_Time:
case Pwr.eType_DeltaTime:
case Pwr.eType_AttrRef:
case Pwr.eType_Objid:
sts = xtt.ctx.gdh.setObjectInfoString( this.full_name, value);
break;
default:
break;
}
};
this.open_attributes = function( xtt) {
}
this.close = function( xtt) {
var parent = xtt.ctx.get_parent_object( this.node);
if ( parent != null) {
parent.userdata.close( xtt);
parent.set_select( true);
parent.set_invert( true);
}
}
this.scan = function( xtt) {
if ( !this.refid)
return;
var value = xtt.ctx.gdh.getObjectRefInfo( this.refid);
if ( this.firstScan || value != this.old_value) {
var value_str;
switch ( this.type) {
case Pwr.eType_Float32:
value_str = "" + value;
break;
case Pwr.eType_Boolean:
value_str = value ? "1" : "0";
break;
case Pwr.eType_Int32:
case Pwr.eType_Int16:
case Pwr.eType_Int8:
case Pwr.eType_UInt32:
case Pwr.eType_UInt16:
case Pwr.eType_UInt8:
value_str = "" + value;
break;
case Pwr.eType_String:
case Pwr.eType_AttrRef:
case Pwr.eType_Objid:
value_str = value;
break;
default:
value_str = "" + value;
}
this.old_value = value;
this.node.set_annotation( 1, value_str);
xtt.scan_update = true;
}
this.firstScan = false;
}
this.scan_close = function( xtt) {
xtt.ctx.gdh.unrefObjectInfo( this.refid);
};
}
function XttItemAttrArray( xtt, info, destination, destCode) {
this.name = info.name;
this.objid = info.objid;
this.full_name = info.full_name;
this.type = info.type;
this.flags = info.flags;
this.size = info.size;
this.elements = info.elements;
this.node = new PlowNode(xtt.ctx, xtt.ncObject, 0);
this.node.set_userdata(this);
this.node.set_annotation( 0, this.name);
this.node.set_annotation_pixmap( 0, Bitmaps.attrarra);
xtt.ctx.insertNode( this.node, destination, destCode);
this.open_children = function( xtt, open_next) {
this.open_attributes( xtt);
}
this.open_attributes = function( xtt) {
var info = new AttributeInfo();
info.objid = this.objid;
info.type = this.type;
info.flags = this.flags & ~Pwr.mAdef_array;
info.size = this.size / this.elements;
info.elements = 1;
info.name = ""
info.full_name = ""
info.classname = ""
xtt.ctx.set_nodraw();
for ( var i = 0; i < this.elements; i++) {
info.name = this.name + "[" + i + "]";
info.full_name = this.full_name + "[" + i + "]";
console.log( "AttrArray", info.name, info.type);
if ( (info.flags & Pwr.mAdef_array) != 0)
new XttItemAttrArray( xtt, info, this.node, Plow.DEST_INTOLAST);
else if ( (info.flags & Pwr.mAdef_class) != 0)
new XttItemAttrObject( xtt, info, this.node, Plow.DEST_INTOLAST);
else
new XttItemAttr( xtt, info, this.node, Plow.DEST_INTOLAST);
}
this.node.node_open |= Plow.OPEN_ATTRIBUTES;
xtt.ctx.configure();
xtt.ctx.reset_nodraw();
xtt.ctx.draw();
};
this.close = function( xtt) {
if ( this.node.node_open & Plow.OPEN_ATTRIBUTES) {
xtt.ctx.close_node( this.node);
this.node.node_open &= ~Plow.OPEN_ATTRIBUTES;
xtt.ctx.configure();
xtt.ctx.draw();
}
else {
var parent = xtt.ctx.get_parent_object( this.node);
if ( parent != null) {
parent.userdata.close( xtt);
parent.set_select( true);
parent.set_invert( true);
}
}
};
}
function XttItemAttrObject( xtt, info, destination, destCode) {
this.name = info.name;
this.classname = info.classname;
this.objid = info.objid;
this.full_name = info.full_name;
this.cid = info.type;
this.flags = info.flags;
this.size = info.size;
this.node = new PlowNode(xtt.ctx, xtt.ncObject, 0);
this.node.set_userdata(this);
this.node.set_annotation( 0, this.name);
this.node.set_annotation( 1, this.classname);
this.node.set_annotation_pixmap( 0, Bitmaps.object);
xtt.ctx.insertNode( this.node, destination, destCode);
this.open_children = function( xtt, open_next) {
this.open_attributes( xtt);
}
this.open_attributes = function( xtt) {
if ( this.node.node_open != 0)
this.close( xtt);
else {
xtt.ctx.gdh.getAllClassAttributes( this.cid, this.objid, xtt.open_attributes_cb, this.node)
this.node.node_open |= Plow.OPEN_ATTRIBUTES;
}
}
this.close = function( xtt) {
if ( this.node.node_open & Plow.OPEN_ATTRIBUTES) {
xtt.ctx.close_node( this.node);
this.node.node_open &= ~Plow.OPEN_ATTRIBUTES;
xtt.ctx.configure();
xtt.ctx.draw();
}
else if ( this.node.node_open & Plow.OPEN_CROSSREFERENCES) {
xtt.ctx.close_node( this.node);
this.node.node_open &= ~Plow.OPEN_CROSSREFERENCES;
xtt.ctx.configure();
xtt.ctx.draw();
}
else {
var parent = xtt.ctx.get_parent_object( this.node);
if ( parent != null) {
parent.userdata.close( xtt);
parent.set_select( true);
parent.set_invert( true);
}
}
};
}
function XttItemCrr( xtt, info, destination, destCode) {
this.name = info.name;
this.classname = info.classname;
this.objid = info.objid;
this.type = info.type;
this.node = new PlowNode(xtt.ctx, xtt.ncObject, 0);
this.node.set_userdata(this);
this.node.set_annotation( 0, this.name);
this.node.set_annotation( 1, this.classname);
switch ( this.type) {
case 0:
this.node.set_annotation_pixmap( 0, Bitmaps.crrread);
break;
case 1:
this.node.set_annotation_pixmap( 0, Bitmaps.crrwrite);
break;
case 2:
this.node.set_annotation_pixmap( 0, Bitmaps.crrwrite);
// this.node.set_annotation_pixmap( 1, Bitmaps.crrread);
break;
}
xtt.ctx.insertNode( this.node, destination, destCode);
this.close = function( xtt) {
var parent = xtt.ctx.get_parent_object( this.node);
if ( parent != null) {
parent.userdata.close( xtt);
parent.set_select( true);
parent.set_invert( true);
}
}
}
var xtt = new Xtt();
xtt.init();
/** End Xtt **/
...@@ -246,6 +246,7 @@ copy : \ ...@@ -246,6 +246,7 @@ copy : \
$(doc_dir)/en_us/man_exlib_index.html \ $(doc_dir)/en_us/man_exlib_index.html \
$(doc_dir)/en_us/man_exlib.pdf \ $(doc_dir)/en_us/man_exlib.pdf \
$(doc_dir)/en_us/man_exlib.ps \ $(doc_dir)/en_us/man_exlib.ps \
$(web_dir)/pwr_logga.png \
$(mediatargets) $(csstargets) \ $(mediatargets) $(csstargets) \
$(export_html) $(export_html_en_us) $(export_html_sv_se) \ $(export_html) $(export_html_en_us) $(export_html_sv_se) \
$(doc_dir)/en_us/changelog.html | silent $(doc_dir)/en_us/changelog.html | silent
...@@ -464,6 +465,10 @@ $(doc_dir)/en_us/changelog.html : $(pwre_croot)/src/changelog.txt \ ...@@ -464,6 +465,10 @@ $(doc_dir)/en_us/changelog.html : $(pwre_croot)/src/changelog.txt \
@ $(co_convert) -e @ $(co_convert) -e
@ mv $(pwre_croot)/src/doc/man/en_us/changelog.html $(target) @ mv $(pwre_croot)/src/doc/man/en_us/changelog.html $(target)
$(web_dir)/pwr_logga.png : $(pwre_sroot)/doc/man/src/pwr_logga.png
@ $(log_h_h)
@ $(cp) $(cpflags) $(source) $(target)
# implicit rules, docbook-related, added by jonas_h 2006-04-nn # implicit rules, docbook-related, added by jonas_h 2006-04-nn
#%.fo :: %.xml #%.fo :: %.xml
...@@ -494,6 +499,8 @@ $(doc_dir)/% :: $(pwre_sroot)/doc/man/src/% ...@@ -494,6 +499,8 @@ $(doc_dir)/% :: $(pwre_sroot)/doc/man/src/%
@ echo "copy $(source)" @ echo "copy $(source)"
@ cp $(source) $(target) @ cp $(source) $(target)
# Rule for creating titlepage xsl templates # Rule for creating titlepage xsl templates
#$(pwre_sroot)/doc/man/src/pwrtitlepages.xsl :: $(pwre_sroot)/doc/man/src/pwrtitlepage.spec.xml #$(pwre_sroot)/doc/man/src/pwrtitlepages.xsl :: $(pwre_sroot)/doc/man/src/pwrtitlepage.spec.xml
# $(xsltproc) -o $(target) $(docbook_stylesheetdir)/template/titlepage.xsl $(source) # $(xsltproc) -o $(target) $(docbook_stylesheetdir)/template/titlepage.xsl $(source)
......
...@@ -641,7 +641,7 @@ EOF ...@@ -641,7 +641,7 @@ EOF
# #
<topic> index <topic> index
<image> pwr_logga.gif <image> pwr_logga.png
<h1>Welcome to $pname <h1>Welcome to $pname
<h2>Description <h2>Description
......
...@@ -13,3 +13,7 @@ endif ...@@ -13,3 +13,7 @@ endif
-include ../../special.mk -include ../../special.mk
-include ../special.mk -include ../special.mk
-include special.mk -include special.mk
copy : $(web_dir)/pwr_logohalf.png
$(web_dir)/pwr_logohalf.png : ../../pwr_logohalf.png
...@@ -22,6 +22,7 @@ lis_dir := $(module_root)/lis ...@@ -22,6 +22,7 @@ lis_dir := $(module_root)/lis
kit_dir := $(module_root)/kit kit_dir := $(module_root)/kit
src_dir := $(module_root)/src src_dir := $(module_root)/src
load_dir := $(module_root)/load load_dir := $(module_root)/load
web_dir := $(module_root)/web
doc_dir := $(release_root)/exp/doc doc_dir := $(release_root)/exp/doc
elib_dir := $(release_root)/exp/lib elib_dir := $(release_root)/exp/lib
......
# jsw_generic.mk -- generic makefile for jsw
#
# PROVIEW/R
# Copyright (C) 1996 by Comator Process AB.
#
# To build a library.
#
ifndef jsw_generic_mk
jsw_generic_mk := 1
ifndef variables_mk
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(hw_name)/variables.mk
endif
ifndef variables_mk
include $(pwre_kroot)/tools/bld/src/$(os_name)/variables.mk
endif
ifndef rules_mk
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(hw_name)/rules.mk
endif
ifndef rules_mk
include $(pwre_kroot)/tools/bld/src/$(os_name)/rules.mk
endif
source_dirs = $(hw_source) $(os_source) $(co_source)
-include ../../jsw_local.mk
-include ../jsw_local.mk
-include jsw_local.mk
vpath %.js $(hw_source):$(os_source):$(co_source)
vpath %.html $(hw_source):$(os_source):$(co_source)
vpath %.png $(hw_source):$(os_source):$(co_source)
source_dirs = $(hw_source) $(os_source) $(co_source)
js_sources := $(sort \
$(foreach file, \
$(foreach dir, \
$(source_dirs), \
$(wildcard $(dir)/*.js) \
), $(notdir $(file)) \
) \
)
html_sources := $(sort \
$(foreach file, \
$(foreach dir, \
$(source_dirs), \
$(wildcard $(dir)/*.html) \
), $(notdir $(file)) \
) \
)
png_sources := $(sort \
$(foreach file, \
$(foreach dir, \
$(source_dirs), \
$(wildcard $(dir)/*.png) \
), $(notdir $(file)) \
) \
)
export_js := $(addprefix $(web_dir)/,$(js_sources))
export_html := $(addprefix $(web_dir)/,$(html_sources))
export_png := $(addprefix $(web_dir)/,$(png_sources))
clean_js := $(patsubst %.js,clean_%.js, $(js_sources))
clean_html := $(patsubst %.html,clean_%.html, $(html_sources))
clean_png := $(patsubst %.png,clean_%.png, $(png_sources))
.PHONY : all init copy lib exe clean realclean
all : init copy lib exe | silent
init :
copy : $(export_js) $(export_html) $(export_png) | silent
lib :
exe :
clean : $(clean_js) $(clean_html) $(clean_png)
clean_copy: $(clean)
realclean : $(clean)
silent:
@ :
$(clean_js) : clean_%.js : %.js
@ echo "Removing js: $(web_dir)/$*.js"
@ $(rm) $(rmflags) $(web_dir)/$*.js
$(clean_html) : clean_%.html : %.html
@ echo "Removing html: $(web_dir)/$*.html"
@ $(rm) $(rmflags) $(web_dir)/$*.html
$(clean_png) : clean_%.png : %.png
@ echo "Removing png: $(web_dir)/$*.png"
@ $(rm) $(rmflags) $(web_dir)/$*.png
-include $(source_dependencies)
endif
...@@ -256,6 +256,10 @@ $(exe_dir)/%.pwgc : %.pwgc ...@@ -256,6 +256,10 @@ $(exe_dir)/%.pwgc : %.pwgc
@ $(log_h_h) @ $(log_h_h)
@ $(cp) $(cpflags) $(source) $(target) @ $(cp) $(cpflags) $(source) $(target)
$(web_dir)/%.pwgc : %.pwgc
@ $(log_h_h)
@ $(cp) $(cpflags) $(source) $(target)
$(bld_dir)/%.png : %.png $(bld_dir)/%.png : %.png
@ $(log_h_h) @ $(log_h_h)
@ $(cp) $(cpflags) $(source) $(target) @ $(cp) $(cpflags) $(source) $(target)
...@@ -264,6 +268,10 @@ $(exe_dir)/%.png : %.png ...@@ -264,6 +268,10 @@ $(exe_dir)/%.png : %.png
@ $(log_h_h) @ $(log_h_h)
@ $(cp) $(cpflags) $(source) $(target) @ $(cp) $(cpflags) $(source) $(target)
$(web_dir)/%.png : %.png
@ $(log_h_h)
@ $(cp) $(cpflags) $(source) $(target)
$(exe_dir)/%.html : ../../%.html $(exe_dir)/%.html : ../../%.html
@ $(log_h_h) @ $(log_h_h)
@ $(cp) $(cpflags) $(source) $(target) @ $(cp) $(cpflags) $(source) $(target)
...@@ -272,6 +280,14 @@ $(doc_dir)/%.html : ../../%.html ...@@ -272,6 +280,14 @@ $(doc_dir)/%.html : ../../%.html
@ $(log_h_h) @ $(log_h_h)
@ $(cp) $(cpflags) $(source) $(target) @ $(cp) $(cpflags) $(source) $(target)
$(web_dir)/%.html : ../../%.html
@ $(log_h_h)
@ $(cp) $(cpflags) $(source) $(target)
$(web_dir)/%.js : ../../%.js
@ $(log_h_h)
@ $(cp) $(cpflags) $(source) $(target)
$(inc_dir)/%.meth : %.meth $(inc_dir)/%.meth : %.meth
@ $(log_h_h) @ $(log_h_h)
@ $(cp) $(cpflags) $(source) $(target) @ $(cp) $(cpflags) $(source) $(target)
......
...@@ -1080,6 +1080,9 @@ sub build_module () ...@@ -1080,6 +1080,9 @@ sub build_module ()
} }
} }
elsif ( $module eq "java") { elsif ( $module eq "java") {
if ( $copy == 1) {
_build("jsw", "*", "src", "all");
}
if ( $lib == 1) { if ( $lib == 1) {
_build("jpwr", "rt", "src", "all"); _build("jpwr", "rt", "src", "all");
_build("jpwr", "jopg", "src", "all"); _build("jpwr", "jopg", "src", "all");
...@@ -1622,6 +1625,7 @@ sub create_base() ...@@ -1622,6 +1625,7 @@ sub create_base()
create_dir($newdir . "/doc/sv_se/dsh"); create_dir($newdir . "/doc/sv_se/dsh");
create_dir($newdir . "/doc/en_us/dsh"); create_dir($newdir . "/doc/en_us/dsh");
create_dir($newdir . "/doc/help"); create_dir($newdir . "/doc/help");
create_dir($newdir . "/web");
} }
sub create_dir() sub create_dir()
......
...@@ -79,6 +79,7 @@ set_env() ...@@ -79,6 +79,7 @@ set_env()
export pwr_lib="$pwre_broot/$pwre_os/$pwre_hw/$pwre_bmodule/lib" export pwr_lib="$pwre_broot/$pwre_os/$pwre_hw/$pwre_bmodule/lib"
export pwr_lis="$pwre_broot/$pwre_os/$pwre_hw/$pwre_bmodule/lis" export pwr_lis="$pwre_broot/$pwre_os/$pwre_hw/$pwre_bmodule/lis"
export pwr_obj="$pwre_broot/$pwre_os/$pwre_hw/$pwre_bmodule/obj" export pwr_obj="$pwre_broot/$pwre_os/$pwre_hw/$pwre_bmodule/obj"
export pwr_web="$pwre_broot/$pwre_os/$pwre_hw/$pwre_bmodule/web"
# Common doc # Common doc
export pwr_doc="$pwre_broot/$pwre_os/$pwre_hw/exp/doc" export pwr_doc="$pwre_broot/$pwre_os/$pwre_hw/exp/doc"
...@@ -88,6 +89,7 @@ set_env() ...@@ -88,6 +89,7 @@ set_env()
export pwr_elib="$pwre_broot/$pwre_os/$pwre_hw/exp/lib" export pwr_elib="$pwre_broot/$pwre_os/$pwre_hw/exp/lib"
export pwr_elis="$pwre_broot/$pwre_os/$pwre_hw/exp/lis" export pwr_elis="$pwre_broot/$pwre_os/$pwre_hw/exp/lis"
export pwr_eobj="$pwre_broot/$pwre_os/$pwre_hw/exp/obj" export pwr_eobj="$pwre_broot/$pwre_os/$pwre_hw/exp/obj"
export pwr_eweb="$pwre_broot/$pwre_os/$pwre_hw/exp/web"
export pwr_edoc="$pwre_broot/$pwre_os/$pwre_hw/exp/doc" export pwr_edoc="$pwre_broot/$pwre_os/$pwre_hw/exp/doc"
export pwrp_load="./" export pwrp_load="./"
......
...@@ -70,6 +70,7 @@ else ...@@ -70,6 +70,7 @@ else
merge_dir_func $toroot/inc $fromroot/inc merge_dir_func $toroot/inc $fromroot/inc
merge_dir_func $toroot/load $fromroot/load merge_dir_func $toroot/load $fromroot/load
merge_dir_func $toroot/obj $fromroot/obj merge_dir_func $toroot/obj $fromroot/obj
merge_dir_func $toroot/web $fromroot/web
# Merge archives # Merge archives
cd ${toroot%/*}/tmp cd ${toroot%/*}/tmp
......
...@@ -69,6 +69,7 @@ html_sources := $(sort \ ...@@ -69,6 +69,7 @@ html_sources := $(sort \
export_pwg := $(addprefix $(exe_dir)/,$(pwg_c_sources)) $(addprefix $(exe_dir)/,$(pwg_t_sources)) export_pwg := $(addprefix $(exe_dir)/,$(pwg_c_sources)) $(addprefix $(exe_dir)/,$(pwg_t_sources))
export_pwsg := $(addprefix $(exe_dir)/,$(pwsg_sources)) export_pwsg := $(addprefix $(exe_dir)/,$(pwsg_sources))
export_pwgc := $(addprefix $(exe_dir)/,$(pwgc_sources)) export_pwgc := $(addprefix $(exe_dir)/,$(pwgc_sources))
export_web_pwgc := $(addprefix $(web_dir)/,$(pwgc_sources))
export_html := $(addprefix $(exe_dir)/,$(html_sources)) export_html := $(addprefix $(exe_dir)/,$(html_sources))
clean_pwsg := $(patsubst %.pwg,clean_%.pwsg,$(sources)) clean_pwsg := $(patsubst %.pwg,clean_%.pwsg,$(sources))
clean_pwg := $(patsubst %.pwg,clean_%.pwg,$(sources)) clean_pwg := $(patsubst %.pwg,clean_%.pwg,$(sources))
...@@ -76,17 +77,20 @@ clean_pwgc := $(patsubst %.pwgc,clean_%.pwgc,$(sources)) ...@@ -76,17 +77,20 @@ clean_pwgc := $(patsubst %.pwgc,clean_%.pwgc,$(sources))
clean_html := $(patsubst %.html,clean_%.html,$(sources)) clean_html := $(patsubst %.html,clean_%.html,$(sources))
export_ge := $(export_pwg) $(export_pwsg) $(export_pwgc) $(export_html) export_ge := $(export_pwg) $(export_pwsg) $(export_pwgc) $(export_html)
clean_ge := $(clean_pwg) $(clean_pwsg) $(clean_pwgc) $(clean_html) clean_ge := $(clean_pwg) $(clean_pwsg) $(clean_pwgc) $(clean_html)
export_web := $(export_web_pwgc)
clean_web := $(patsubst %.pwgc,clean_%.pwgc,$(sources))
.SUFFIXES: .SUFFIXES:
.PHONY : all init copy lib exe clean realclean \ .PHONY : all init copy lib exe clean realclean \
$(clean_ge) $(clean_ge) $(clean_web)
all : init copy lib exe | silent all : init copy lib exe | silent
init : silent init : silent
copy : $(export_ge)\ copy : $(export_ge)\
$(export_web)\
$(exe_dir)/pwr_css.css \ $(exe_dir)/pwr_css.css \
| silent | silent
...@@ -96,7 +100,7 @@ exe : silent ...@@ -96,7 +100,7 @@ exe : silent
clean : clean :
realclean : $(clean_ge) realclean : $(clean_ge) $(clean_web)
silent : silent :
@ : @ :
...@@ -113,6 +117,9 @@ $(clean_pwgc) : clean_%.pwgc : %.pwgc ...@@ -113,6 +117,9 @@ $(clean_pwgc) : clean_%.pwgc : %.pwgc
$(clean_html) : clean_%.html : %.html $(clean_html) : clean_%.html : %.html
@ $(rm) $(rmflags) $(exe_dir)/$*.html @ $(rm) $(rmflags) $(exe_dir)/$*.html
$(clean_web) : clean_%.pwgc : %.pwgc
@ $(rm) $(rmflags) $(web_dir)/$*.pwgc
$(exe_dir)/pwr_css.css : ../../pwr_css.css $(exe_dir)/pwr_css.css : ../../pwr_css.css
@ echo "copy $(source) $(target)" @ echo "copy $(source) $(target)"
@ cp $(source) $(target) @ cp $(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