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

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

parent d4f7f2f2
......@@ -2251,7 +2251,10 @@ public class GdhWebSocketServer
int oppDisableHelp = 0;
int oppDisableProview = 0;
int oppLanguage = 0;
String[] oppURL_Symbols = new String[10];
String webBrowser;
CdhrObjid oret;
CdhrString sret;
Vector<WebButton> v = new Vector<WebButton>();
if ( opPlace.isEmpty()) {
......@@ -2301,6 +2304,22 @@ public class GdhWebSocketServer
if (iret.oddSts())
oppDisableProview = iret.value;
oret = gdh.getClassList( Pwrb.cClass_WebBrowserConfig);
if ( oret.oddSts()) {
webBrowser = gdh.objidToName(oret.objid, Cdh.mName_pathStrict).str;
for (int j = 0; j < 10; j++) {
sret = gdh.getObjectInfoString(webBrowser + ".URL_Symbols[" + j +"]");
if (sret.oddSts())
oppURL_Symbols[j] = sret.str;
else
oppURL_Symbols[j] = "";
}
}
else {
for (int j = 0; j < 10; j++)
oppURL_Symbols[j] = "";
}
CdhrObjid cdhrObjId = (CdhrObjid)gdh.getChild(objid);
while(cdhrObjId.oddSts()) {
String childName = gdh.objidToName(cdhrObjId.objid, Cdh.mName_pathStrict).str;
......@@ -2359,6 +2378,10 @@ public class GdhWebSocketServer
refsize += 4; // disable help
refsize += 4; // disable proview
refsize += 4; // language
for ( i = 0; i < 10; i++) {
refsize += 2; // URL symbol length
refsize += oppURL_Symbols[i].length();
}
refsize += 2; // button vector length
if ( (sts & 1) != 0) {
for ( i = 0; i < v.size(); i++) {
......@@ -2427,6 +2450,13 @@ public class GdhWebSocketServer
bb.putInt( j, oppLanguage);
j += 4;
for ( i = 0; i < 10; i++) {
bb.putShort( j, (short)oppURL_Symbols[i].length());
j += 2;
for ( int k = 0; k < oppURL_Symbols[i].length(); k++) {
bb.put( j++, (byte)oppURL_Symbols[i].charAt(k));
}
}
bb.putShort( j, (short)v.size());
j += 2;
for ( i = 0; i < v.size(); i++) {
......@@ -2781,7 +2811,44 @@ public class GdhWebSocketServer
}
}
catch ( java.io.IOException e) {
errh.error("DataStream failed");
try {
out.close();
}
catch(IOException e2) {
System.err.println("Close failed");
}
try {
in.close();
}
catch(IOException e2) {
System.err.println("Close failed");
}
try {
clientSocket.close();
}
catch(IOException e2) {
System.err.println("Close failed");
}
//check that all subscriptions has stopped
for(int i = 0; i < thSub.size(); i++) {
try {
sub = thSub.elementAt(i);
int index = thSub.elementAt(i).getIndex();
PwrtStatus sts = this.unrefObjectInfo(sub.subId, threadNumber);
}
catch(ArrayIndexOutOfBoundsException exc) {
}
}
// Reduce subscription size to save memory
this.trimRefObjectList();
connectionOccupied[threadNumber] = false;
threadCount--;
setCurrentConnections(threadCount);
System.out.println("ServerSocket IOException " + e.toString());
System.out.println("Terminating thread " + threadNumber);
return;
}
}
public synchronized Sub refObjectInfo(String attrName, int threadNumber, int refId, int elements)
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/** Start Pwr **/
function PwrtStatus( sts)
{
this.sts = sts;
this.evenSts = function() { return (sts % 2 === 0);};
this.oddSts = function() { return (sts % 2 == 1);};
this.getSts = function() { return sts;};
}
var Pwr = {
eType_Boolean : 98305,
eType_Float32 : 98306,
eType_Float64 : 98307,
eType_Char : 98308,
eType_Int8 : 98309,
eType_Int16 : 98310,
eType_Int32 : 98311,
eType_UInt8 : 98312,
eType_UInt16 : 98313,
eType_UInt32 : 98314,
eType_Objid : 98315,
eType_Buffer : 98316,
eType_String : 98317,
eType_Enum : 98318,
eType_Struct : 98319,
eType_Mask : 98320,
eType_Array : 98321,
eType_Time : 98322,
eType_Text : 98323,
eType_AttrRef : 98324,
eType_UInt64 : 98325,
eType_Int64 : 98326,
eType_ClassId : 98327,
eType_TypeId : 98328,
eType_VolumeId : 98329,
eType_ObjectIx : 98330,
eType_RefId : 98331,
eType_DeltaTime : 98332,
eType_Status : 98333,
eType_NetStatus : 98334,
eType_CastId : 98335,
eType_ProString : 98336,
eType_DisableAttr : 98337,
eType_DataRef : 98338,
mPrv_RtRead : 1 << 0,
mPrv_RtWrite : 1 << 1,
mPrv_System : 1 << 2,
mPrv_Maintenance : 1 << 3,
mPrv_Process : 1 << 4,
mPrv_Instrument : 1 << 5,
mPrv_Operator1 : 1 << 6,
mPrv_Operator2 : 1 << 7,
mPrv_Operator3 : 1 << 8,
mPrv_Operator4 : 1 << 9,
mPrv_Operator5 : 1 << 10,
mPrv_Operator6 : 1 << 11,
mPrv_Operator7 : 1 << 12,
mPrv_Operator8 : 1 << 13,
mPrv_Operator9 : 1 << 14,
mPrv_Operator10 : 1 << 15,
mPrv_RtEventsAck : 1 << 18,
mPrv_RtPlc : 1 << 19,
mPrv_RtNavigator : 1 << 20,
mPrv_DevRead : 1 << 21,
mPrv_DevPlc : 1 << 22,
mPrv_DevConfig : 1 << 23,
mPrv_DevClass : 1 << 24,
mPrv_RtEventsBlock : 1 << 25,
mPrv_Administrator : 1 << 26,
mPrv_SevRead : 1 << 27,
mPrv_SevAdmin : 1 << 28,
mAccess_RtRead : 1 << 0,
mAccess_RtWrite : 1 << 1,
mAccess_System : 1 << 2,
mAccess_Maintenance : 1 << 3,
mAccess_Process : 1 << 4,
mAccess_Instrument : 1 << 5,
mAccess_RtEventsBlock : 1 << 25,
mAccess_RtEventsAck : 1 << 18,
mAccess_RtPlc : 1 << 19,
mAccess_RtNavigator : 1 << 20,
mAccess_AllRt : 1 << 2 |
1 << 3 |
1 << 4 |
1 << 5 |
1 << 0 |
1 << 1 |
1 << 25 |
1 << 18 |
1 << 19 |
1 << 20 |
1 << 6 |
1 << 7 |
1 << 8 |
1 << 9 |
1 << 10 |
1 << 11 |
1 << 12 |
1 << 13 |
1 << 14 |
1 << 15,
mAccess_AllOperators : 1 << 6 |
1 << 7 |
1 << 8 |
1 << 9 |
1 << 10 |
1 << 11 |
1 << 12 |
1 << 13 |
1 << 14 |
1 << 15,
mAccess_AllPwr : ~0,
mAdef_pointer : 1,
mAdef_array : 2,
mAdef_backup : 4,
mAdef_changelog : 8,
mAdef_state : 16,
mAdef_const : 32,
mAdef_rtvirtual : 64,
mAdef_devbodyref : 128,
mAdef_dynamic : 256,
mAdef_publicwrite : 512,
mAdef_noedit : 1024,
mAdef_invisible : 2048,
mAdef_refdirect : 4096,
mAdef_noinvert : 8192,
mAdef_noremove : 16384,
mAdef_rtdbref : 32768,
mAdef_private : 65536,
mAdef_class : 131072,
mAdef_superclass : 262144,
mAdef_buffer : 524288,
mAdef_nowbl : 1048576,
mAdef_alwayswbl : 2097152,
mAdef_disableattr : 4194304,
mAdef_rthide : 8388608
};
var Pwrb = {
mXttMethodsFlagsMask_IsConfigured : 1,
mXttOpMethodsMask_OpenGraph : 1,
mXttOpMethodsMask_OpenObjectGraph : 2,
mXttOpMethodsMask_OpenTrend : 4,
mXttOpMethodsMask_OpenHistory : 8,
mXttOpMethodsMask_OpenFast : 16,
mXttOpMethodsMask_Camera : 32,
mXttOpMethodsMask_HistEvent : 64,
mXttOpMethodsMask_BlockEvents : 128,
mXttOpMethodsMask_Help : 256,
mXttOpMethodsMask_Photo : 512,
mXttOpMethodsMask_Note : 1024,
mXttOpMethodsMask_ParentObjectGraph : 2048,
mXttMntMethodsMask_OpenObject : 1,
mXttMntMethodsMask_OpenTrace : 2,
mXttMntMethodsMask_RtNavigator : 4,
mXttMntMethodsMask_OpenCrossref : 8,
mXttMntMethodsMask_HelpClass : 16,
mXttMntMethodsMask_DataSheet : 32,
mXttMntMethodsMask_CircuitDiagram : 64,
mXttMntMethodsMask_Simulate : 1 << 31
};
function PwrtObjid( vid, oix) {
this.oix = oix;
this.vid = vid;
}
function PwrtAttrRef() {
this.objid;
this.offset;
this.body;
this.size;
this.flags;
}
function CdhrNumber( value, sts)
{
this.value = value;
this.sts = sts;
this.evenSts = function() { return (sts % 2 === 0);};
this.oddSts = function() { return (sts % 2 == 1);};
this.getSts = function() { return sts;};
}
var CdhC = {
cUserVolMin : (0 + (0 << 24) + (1 << 16) + (1 << 8) + 1),
cUserVolMax : (0 + (0 << 24) + (254 << 16) + (254 << 8) + 254)
};
function UserdataCbReturn() {
this.userdata;
this.row;
}
/** End Pwr **/
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
#include <stdio.h>
#include <string.h>
#include "pwr.h"
#include "co_dcli.h"
#include "co_string.h"
static pwr_tFileName inc_path[10];
static unsigned int inc_path_cnt = 0;
void usage()
{
printf("\nco_jsconcat\n\n> co_jsconcat [-I include-directory] -o outfile infile\n\n");
}
int read_file(FILE *ofp, char *incfile)
{
pwr_tFileName fname;
FILE *ifp;
int i;
char line[400];
for (i = 0; i < inc_path_cnt; i++) {
strcpy(fname, inc_path[i]);
strcat(fname, "/");
strcat(fname, incfile);
dcli_translate_filename(fname, fname);
ifp = fopen(fname, "r");
if (ifp)
break;
else if (i == inc_path_cnt - 1) {
printf("** Unable to open file %s\n", incfile);
exit(0);
}
}
while (dcli_read_line(line, sizeof(line), ifp)) {
if (strncmp(line, "#jsc_include", 12) == 0) {
str_trim(incfile, &line[13]);
read_file(ofp, (char *)incfile);
}
else {
fputs(line, ofp);
fputc('\n', ofp);
// fprintf(ofp, "%s\n", line);
}
}
return 1;
}
int main(int argc, char* argv[])
{
pwr_tFileName outfile = "";
pwr_tFileName infile = "";
pwr_tFileName incfile;
pwr_tFileName fname;
int i;
FILE *ifp;
FILE *ofp;
char line[400];
for (i = 1; i < argc; i++) {
if ((argv)[i][0] == '-') {
int i_incr = 0;
for (int j = 1; (argv)[i][j] != 0 && (argv)[i][j] != ' '
&& (argv)[i][j] != ' ';
j++) {
switch ((argv)[i][j]) {
case 'I':
if (i + 1 >= argc
|| !((argv)[i][j + 1] == ' ' || (argv)[i][j + 1] != ' ')) {
usage();
exit(0);
}
if (inc_path_cnt >= sizeof(inc_path)/sizeof(inc_path[0])) {
printf("** Max number of include paths exceeded\n");
exit(0);
}
strncpy(inc_path[inc_path_cnt], (argv)[i + 1], sizeof(inc_path[0]));
inc_path_cnt++;
i++;
i_incr = 1;
break;
case 'o':
if (i + 1 >= argc
|| !((argv)[i][j + 1] == ' ' || (argv)[i][j + 1] != ' ')) {
usage();
exit(0);
}
strncpy(outfile, (argv)[i + 1], sizeof(outfile));
inc_path_cnt++;
i++;
i_incr = 1;
break;
default:
usage();
exit(0);
}
if (i_incr)
break;
}
} else {
// Input file
strcpy(infile, (argv)[i]);
}
}
printf("-I %s -l %s %s\n", inc_path[0], outfile, infile);
dcli_translate_filename(fname, infile);
ifp = fopen(fname, "r");
if (!ifp) {
printf("** Unable to open file %s\n", fname);
exit(0);
}
dcli_translate_filename(fname, outfile);
ofp = fopen(fname, "w");
if (!ofp) {
printf("** Unable to open file %s\n", fname);
exit(0);
}
while (dcli_read_line(line, sizeof(line), ifp)) {
if (strncmp(line, "#jsc_include", 12) == 0) {
str_trim(incfile, &line[13]);
read_file(ofp, incfile);
}
else {
fputs(line, ofp);
fputc('\n', ofp);
// fprintf(ofp, "%s\n", line);
}
}
}
ifndef link_rule_mk
link_rule_mk := 1
link = $(ldxx) $(linkflags) $(domap) -o $(export_exe) $(export_obj) \
$(objects) -lpwr_co $(pwre_conf_libdir) $(pwre_conf_lib)
endif
......@@ -274,8 +274,7 @@ $(web_dir)/%.css : %.css
$(web_dir)/%.js : %.js
@ $(log_h_h)
@ $(cp) $(cpflags) $(source) $(target)
@ co_jsconcat -I $(pwre_croot)/java/jsw/cmn/src -o $(target) $(source)
$(inc_dir)/%.meth : %.meth
@ $(log_h_h)
@ $(cp) $(cpflags) $(source) $(target)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment